Public Member Functions | Public Attributes | List of all members
PYDAFOAM Class Reference
Inheritance diagram for PYDAFOAM:
Inheritance graph
[legend]
Collaboration diagram for PYDAFOAM:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, comm=None, options=None)
 
def __call__ (self)
 
def calcPrimalResidualStatistics (self, mode)
 
def writeAdjointFields (self, function, writeTime, psi)
 
def evalFunctions (self, funcs)
 
def addFamilyGroup (self, groupName, families)
 
def setMesh (self, mesh)
 
def getSurfaceConnectivity (self, groupName=None)
 
def getTriangulatedMeshSurface (self, groupName=None, **kwargs)
 
def printFamilyList (self)
 
def deformDynamicMesh (self)
 
def readDynamicMeshPoints (self, timeVal, deltaT, timeIndex, ddtSchemeOrder)
 
def readStateVars (self, timeVal, deltaT)
 
def set_solver_input (self, inputs, DVGeo=None)
 
def calcFFD2XvSeeds (self, DVGeo=None)
 
def runDecomposePar (self)
 
def deletePrevPrimalSolTime (self)
 
def renameSolution (self, solIndex)
 
def setSurfaceCoordinates (self, coordinates, groupName=None)
 
def getSurfaceCoordinates (self, groupName=None)
 
def setPrimalBoundaryConditions (self, printInfo=1, printInfoAD=0)
 
def getSolverMeshIndices (self)
 
def mapVector (self, vec1, groupName1, groupName2, vec2=None)
 
def setOption (self, name, value)
 
def getNRegressionParameters (self, modelName)
 
def getOption (self, name)
 
def updateDAOption (self)
 
def getNLocalAdjointStates (self)
 
def getNLocalPoints (self)
 
def getStates (self)
 
def setStates (self, states)
 
def setVolCoords (self, vol_coords)
 
def arrayVal2Vec (self, array1, vec)
 
def vecVal2Array (self, vec, array1)
 
def vec2Array (self, vec)
 
def array2Vec (self, array1)
 

Public Attributes

 version
 
 name
 
 families
 
 dtype
 
 solverInitialized
 
 nSolvePrimals
 
 nSolveAdjoints
 
 primalFail
 
 adjointFail
 
 allSurfacesGroup
 
 allWallsGroup
 
 designSurfacesGroup
 
 mesh
 
 dRdWTPC
 
 ksp
 
 dynamicMeshDeformed
 
 solverRegistry
 
 imOptions
 
 defaultOptions
 
 options
 
 comm
 
 parallel
 
 rank
 
 nProcs
 
 parallelFlag
 
 solver
 
 solverAD
 
 neighbours
 
 xv
 
 basicFamilies
 
 wallList
 

Detailed Description

Main class for pyDAFoam

Parameters
----------

comm : mpi4py communicator
    An optional argument to pass in an external communicator.

options : dictionary
    The list of options to use with pyDAFoam.

Definition at line 620 of file pyDAFoam.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  comm = None,
  options = None 
)
Initialize class members

Definition at line 635 of file pyDAFoam.py.

Member Function Documentation

◆ __call__()

def __call__ (   self)

◆ calcPrimalResidualStatistics()

def calcPrimalResidualStatistics (   self,
  mode 
)

Definition at line 860 of file pyDAFoam.py.

References DAOption.getOption(), PYDAFOAM.getOption(), PYDAFOAM.solver, and PYDAFOAM.solverAD.

Here is the call graph for this function:

◆ writeAdjointFields()

def writeAdjointFields (   self,
  function,
  writeTime,
  psi 
)
Write the adjoint variables in OpenFOAM field format for post-processing

Definition at line 866 of file pyDAFoam.py.

References DAOption.getOption(), PYDAFOAM.getOption(), and PYDAFOAM.solver.

Here is the call graph for this function:

◆ evalFunctions()

def evalFunctions (   self,
  funcs 
)
Evaluate the desired functions given in iterable object,

Examples
--------
>>> funcs = {}
>>> CFDsolver()
>>> CFDsolver.evalFunctions(funcs)
>>> # Result will look like:
>>> # {'CL':0.501, 'CD':0.02750}

Definition at line 876 of file pyDAFoam.py.

References DAOption.getOption(), PYDAFOAM.getOption(), PYDAFOAM.solver, and PYDAFOAM.solverAD.

Here is the call graph for this function:

◆ addFamilyGroup()

def addFamilyGroup (   self,
  groupName,
  families 
)
Add a custom grouping of families called groupName. The groupName
must be distinct from the existing families. All families must
in the 'families' list must be present in the mesh file.
Parameters
----------
groupName : str
    User-supplied custom name for the family groupings
families : list
    List of string. Family names to combine into the family group

Definition at line 900 of file pyDAFoam.py.

References PYDAFOAM.families.

◆ setMesh()

def setMesh (   self,
  mesh 
)
Set the mesh object to the aero_solver to do geometric deformations
Parameters
----------
mesh : MBMesh or USMesh object
    The mesh object for doing the warping

Definition at line 938 of file pyDAFoam.py.

References PYDAFOAM.allWallsGroup, PYDAFOAM.getSolverMeshIndices(), PYDAFOAM.getSurfaceConnectivity(), PYDAFOAM.getSurfaceCoordinates(), DACheckMesh.mesh, and PYDAFOAM.mesh.

Here is the call graph for this function:

◆ getSurfaceConnectivity()

def getSurfaceConnectivity (   self,
  groupName = None 
)
Return the connectivity of the coordinates at which the forces (or tractions) are
defined. This is the complement of getForces() which returns
the forces at the locations returned in this routine.

Parameters
----------
groupName : str
    Group identifier to get only forces cooresponding to the
    desired group. The group must be a family or a user-supplied
    group of families. The default is None which corresponds to
    all wall-type surfaces.

Definition at line 959 of file pyDAFoam.py.

References PYDAFOAM.allWallsGroup, PYDAFOAM.basicFamilies, and PYDAFOAM.families.

Referenced by PYDAFOAM.getTriangulatedMeshSurface(), and PYDAFOAM.setMesh().

Here is the caller graph for this function:

◆ getTriangulatedMeshSurface()

def getTriangulatedMeshSurface (   self,
  groupName = None,
**  kwargs 
)
This function returns a trianguled verision of the surface
mesh on all processors. The intent is to use this for doing
constraints in DVConstraints.
Returns
-------
surf : list
   List of points and vectors describing the surface. This may
   be passed directly to DVConstraint setSurface() function.

Definition at line 1008 of file pyDAFoam.py.

References PYDAFOAM.allWallsGroup, DAFoamBuilder.comm, OptFuncs.comm, PYDAFOAM.comm, PYDAFOAM.getSurfaceConnectivity(), and PYDAFOAM.getSurfaceCoordinates().

Here is the call graph for this function:

◆ printFamilyList()

def printFamilyList (   self)
Print a nicely formatted dictionary of the family names

Definition at line 1074 of file pyDAFoam.py.

References PYDAFOAM.families.

◆ deformDynamicMesh()

def deformDynamicMesh (   self)
Deform the dynamic mesh and save to them to the disk

Definition at line 1153 of file pyDAFoam.py.

References PYDAFOAM.dynamicMeshDeformed, PYDAFOAM.getNLocalPoints(), DAOption.getOption(), PYDAFOAM.getOption(), setTime(), and PYDAFOAM.solver.

Here is the call graph for this function:

◆ readDynamicMeshPoints()

def readDynamicMeshPoints (   self,
  timeVal,
  deltaT,
  timeIndex,
  ddtSchemeOrder 
)
Read the dynamic mesh points saved in the folders 0.001, 0.002
NOTE: if the backward scheme is used we need to read the mesh
for 3 time levels to get the correct V0, V00 etc
NOTE: setting the proper time index is critical because the fvMesh
will use timeIndex to calculate meshPhi, V0 etc

Definition at line 1217 of file pyDAFoam.py.

References setTime(), PYDAFOAM.solver, and PYDAFOAM.solverAD.

Here is the call graph for this function:

◆ readStateVars()

def readStateVars (   self,
  timeVal,
  deltaT 
)
Read the state variables in to OpenFOAM's state fields

Definition at line 1256 of file pyDAFoam.py.

References PYDAFOAM.solver, and PYDAFOAM.solverAD.

◆ set_solver_input()

def set_solver_input (   self,
  inputs,
  DVGeo = None 
)
Set solver input. If it is forward mode, we also set the seeds

Definition at line 1279 of file pyDAFoam.py.

References PYDAFOAM.calcFFD2XvSeeds(), DAOption.getOption(), PYDAFOAM.getOption(), PYDAFOAM.solver, and PYDAFOAM.solverAD.

Here is the call graph for this function:

◆ calcFFD2XvSeeds()

def calcFFD2XvSeeds (   self,
  DVGeo = None 
)

◆ runDecomposePar()

def runDecomposePar (   self)
Run decomposePar to parallel run

Definition at line 1383 of file pyDAFoam.py.

References PYDAFOAM._writeDecomposeParDict(), DAFoamBuilder.comm, OptFuncs.comm, PYDAFOAM.comm, DAOption.getOption(), and PYDAFOAM.getOption().

Here is the call graph for this function:

◆ deletePrevPrimalSolTime()

def deletePrevPrimalSolTime (   self)
Delete the previous primal solution time folder

Definition at line 1411 of file pyDAFoam.py.

References DAFoamBuilder.comm, OptFuncs.comm, PYDAFOAM.comm, PYDAFOAM.parallel, and PYDAFOAM.solver.

Referenced by PYDAFOAM.__call__().

Here is the caller graph for this function:

◆ renameSolution()

def renameSolution (   self,
  solIndex 
)
Rename the primal solution folder to specific format for post-processing. The renamed time has the
format like 0.0001, 0.0002, etc. One can load these intermediate shapes and fields and
plot them in paraview.
The way it is implemented is that we sort the solution folder and consider the largest time folder
as the solution folder and rename it

Parameters
----------
solIndex: int
    The major interation index

Definition at line 1436 of file pyDAFoam.py.

References DAFoamBuilder.comm, OptFuncs.comm, PYDAFOAM.comm, PYDAFOAM.parallel, and PYDAFOAM.solver.

Referenced by PYDAFOAM.__call__().

Here is the caller graph for this function:

◆ setSurfaceCoordinates()

def setSurfaceCoordinates (   self,
  coordinates,
  groupName = None 
)
Set the updated surface coordinates for a particular group.
Parameters
----------
coordinates : numpy array
    Numpy array of size Nx3, where N is the number of coordinates on this processor.
    This array must have the same shape as the array obtained with getSurfaceCoordinates()
groupName : str
    Name of family or group of families for which to return coordinates for.

Definition at line 1494 of file pyDAFoam.py.

References PYDAFOAM._updateGeomInfo, PYDAFOAM.allWallsGroup, PYDAFOAM.getSurfaceCoordinates(), PYDAFOAM.mapVector(), DACheckMesh.mesh, and PYDAFOAM.mesh.

Here is the call graph for this function:

◆ getSurfaceCoordinates()

def getSurfaceCoordinates (   self,
  groupName = None 
)
Return the coordinates for the surfaces defined by groupName.

Parameters
----------
groupName : str
    Group identifier to get only coordinates cooresponding to
    the desired group. The group must be a family or a
    user-supplied group of families. The default is None which
    corresponds to all wall-type surfaces.

Output
------
xs: numpy array of size nPoints * 3 for surface points

Definition at line 1523 of file pyDAFoam.py.

References PYDAFOAM._getSurfaceSize(), PYDAFOAM.allSurfacesGroup, PYDAFOAM.allWallsGroup, PYDAFOAM.basicFamilies, PYDAFOAM.dtype, PYDAFOAM.families, and PYDAFOAM.xv.

Referenced by PYDAFOAM.calcFFD2XvSeeds(), PYDAFOAM.getTriangulatedMeshSurface(), PYDAFOAM.setMesh(), and PYDAFOAM.setSurfaceCoordinates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPrimalBoundaryConditions()

def setPrimalBoundaryConditions (   self,
  printInfo = 1,
  printInfoAD = 0 
)
Assign the boundary condition defined in primalBC to the OF fields

Definition at line 1587 of file pyDAFoam.py.

References PYDAFOAM.solver, and PYDAFOAM.solverAD.

◆ getSolverMeshIndices()

def getSolverMeshIndices (   self)
Get the list of indices to pass to the mesh object for the
volume mesh mapping

Definition at line 1670 of file pyDAFoam.py.

References DAFoamBuilder.comm, OptFuncs.comm, and PYDAFOAM.comm.

Referenced by PYDAFOAM.setMesh().

Here is the caller graph for this function:

◆ mapVector()

def mapVector (   self,
  vec1,
  groupName1,
  groupName2,
  vec2 = None 
)
This is the main workhorse routine of everything that deals with
families in pyDAFoam. The purpose of this routine is to convert a
vector 'vec1' (of size Nx3) that was evaluated with
'groupName1' and expand or contract it (and adjust the
ordering) to produce 'vec2' evaluated on groupName2.

A little ascii art might help. Consider the following "mesh"
. Family 'fam1' has 9 points, 'fam2' has 10 pts and 'fam3' has
5 points.  Consider that we have also also added two
additional groups: 'f12' containing 'fam1' and 'fma2' and a
group 'f23' that contains families 'fam2' and 'fam3'. The vector
we want to map is 'vec1'. It is length 9+10. All the 'x's are
significant values.

The call: mapVector(vec1, 'f12', 'f23')

will produce the "returned vec" array, containing the
significant values from 'fam2', where the two groups overlap,
and the new values from 'fam3' set to zero. The values from
fam1 are lost. The returned vec has size 15.

    fam1     fam2      fam3
|---------+----------+------|

|xxxxxxxxx xxxxxxxxxx|        <- vec1
  |xxxxxxxxxx 000000| <- returned vec (vec2)

Parameters
----------
vec1 : Numpy array
    Array of size Nx3 that will be mapped to a different family set.

groupName1 : str
    The family group where the vector vec1 is currently defined

groupName2 : str
    The family group where we want to the vector to mapped into

vec2 : Numpy array or None
    Array containing existing values in the output vector we want to keep.
    If this vector is not given, the values will be filled with zeros.

Returns
-------
vec2 : Numpy array
    The input vector mapped to the families defined in groupName2.

Definition at line 1688 of file pyDAFoam.py.

References PYDAFOAM._getSurfaceSize(), PYDAFOAM.allSurfacesGroup, PYDAFOAM.basicFamilies, DAFoamBuilder.comm, OptFuncs.comm, PYDAFOAM.comm, PYDAFOAM.dtype, and PYDAFOAM.families.

Referenced by PYDAFOAM.calcFFD2XvSeeds(), and PYDAFOAM.setSurfaceCoordinates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setOption()

def setOption (   self,
  name,
  value 
)
Set a value to options.
NOTE: calling this function will only change the values in self.options
It will NOT change values for allOptions_ in DAOption. To make the options changes
from pyDAFoam to DASolvers, call self.updateDAOption()

Parameters
----------
name : str
   Name of option to set. Not case sensitive
value : varies
   Value to set. Type is checked for consistency.

Examples
--------
If self.options reads:
self.options =
{
    'solverName': [str, 'DASimpleFoam'],
    'flowEndTime': [float, 1.0]
}
Then, calling self.options('solverName', 'DARhoSimpleFoam') will give:
self.options =
{
    'solverName': [str, 'DARhoSimpleFoam'],
    'flowEndTime': [float, 1.0]
}


NOTE: if 'value' is of dict type, we will set all the subKey values in
'value' dict to self.options, instead of overiding it. This works for
only THREE levels of subDicts

For example, if self.options reads
self.options =
{
    'function': [dict, {
'name': 'CD',
'direction': [1.0, 0.0, 0.0],
'scale': 1.0}]
}

Then, calling self.setOption('function', {'name': 'CL'}) will give:

self.options =
{
    'function': [dict, {
'name': 'CL',
'direction': [1.0, 0.0, 0.0],
'scale': 1.0}]
}

INSTEAD OF

self.options =
{
    'function': [dict, {'name': 'CL'}]
}

Definition at line 1812 of file pyDAFoam.py.

References PYDAFOAM.defaultOptions, PYDAFOAM.imOptions, PYDAFOAM.name, DAFoamBuilder.options, and PYDAFOAM.options.

Referenced by PYDAFOAM.__call__().

Here is the caller graph for this function:

◆ getNRegressionParameters()

def getNRegressionParameters (   self,
  modelName 
)
Get the number of regression model parameters

Definition at line 1955 of file pyDAFoam.py.

References PYDAFOAM.solver.

◆ getOption()

def getOption (   self,
  name 
)
Get a value from options

Parameters
----------
name : str
   Name of option to get. Not case sensitive

Returns
-------
value : varies
   Return the value of the option.

Definition at line 1962 of file pyDAFoam.py.

References PYDAFOAM.defaultOptions, DAFoamBuilder.options, and PYDAFOAM.options.

Referenced by PYDAFOAM.__call__(), PYDAFOAM.array2Vec(), PYDAFOAM.calcFFD2XvSeeds(), PYDAFOAM.calcPrimalResidualStatistics(), PYDAFOAM.deformDynamicMesh(), PYDAFOAM.evalFunctions(), PYDAFOAM.runDecomposePar(), PYDAFOAM.set_solver_input(), PYDAFOAM.updateDAOption(), and PYDAFOAM.writeAdjointFields().

Here is the caller graph for this function:

◆ updateDAOption()

def updateDAOption (   self)
Update the allOptions_ in DAOption based on the latest self.options in
pyDAFoam. This will pass the changes of self.options from pyDAFoam
to DASolvers. NOTE: need to call this function after calling
self.initSolver

Definition at line 1982 of file pyDAFoam.py.

References DAOption.getOption(), PYDAFOAM.getOption(), DAFoamBuilder.options, PYDAFOAM.options, PYDAFOAM.solver, PYDAFOAM.solverAD, and PYDAFOAM.solverInitialized.

Referenced by PYDAFOAM.__call__().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNLocalAdjointStates()

def getNLocalAdjointStates (   self)
Get number of local adjoint states

Definition at line 1998 of file pyDAFoam.py.

References PYDAFOAM.solver.

Referenced by PYDAFOAM.getStates().

Here is the caller graph for this function:

◆ getNLocalPoints()

def getNLocalPoints (   self)
Get number of local points

Definition at line 2004 of file pyDAFoam.py.

References PYDAFOAM.solver.

Referenced by PYDAFOAM.deformDynamicMesh().

Here is the caller graph for this function:

◆ getStates()

def getStates (   self)
Return the adjoint state array owns by this processor

Definition at line 2010 of file pyDAFoam.py.

References PYDAFOAM.dtype, PYDAFOAM.getNLocalAdjointStates(), and PYDAFOAM.solver.

Here is the call graph for this function:

◆ setStates()

def setStates (   self,
  states 
)
Set the state to the OpenFOAM field

Definition at line 2021 of file pyDAFoam.py.

References PYDAFOAM.solver, and PYDAFOAM.solverAD.

◆ setVolCoords()

def setVolCoords (   self,
  vol_coords 
)
Set the vol_coords to the OpenFOAM field

Definition at line 2031 of file pyDAFoam.py.

References PYDAFOAM.solver, and PYDAFOAM.solverAD.

◆ arrayVal2Vec()

def arrayVal2Vec (   self,
  array1,
  vec 
)
Assign the values from array1 to vec

Definition at line 2041 of file pyDAFoam.py.

◆ vecVal2Array()

def vecVal2Array (   self,
  vec,
  array1 
)
Assign the values from vec to array1

Definition at line 2060 of file pyDAFoam.py.

◆ vec2Array()

def vec2Array (   self,
  vec 
)
Convert a Petsc vector to numpy array

Definition at line 2076 of file pyDAFoam.py.

References PYDAFOAM.dtype.

◆ array2Vec()

def array2Vec (   self,
  array1 
)
Convert a numpy array to Petsc vector

Definition at line 2089 of file pyDAFoam.py.

References PYDAFOAM._writeOpenFoamHeader(), DAFoamBuilder.comm, OptFuncs.comm, PYDAFOAM.comm, DAOption.getOption(), PYDAFOAM.getOption(), and PYDAFOAM.nProcs.

Here is the call graph for this function:

Member Data Documentation

◆ version

version

Definition at line 642 of file pyDAFoam.py.

◆ name

name

Definition at line 651 of file pyDAFoam.py.

Referenced by PYDAFOAM.setOption().

◆ families

families

◆ dtype

dtype

◆ solverInitialized

solverInitialized

Definition at line 675 of file pyDAFoam.py.

Referenced by PYDAFOAM.calcFFD2XvSeeds(), and PYDAFOAM.updateDAOption().

◆ nSolvePrimals

nSolvePrimals

Definition at line 682 of file pyDAFoam.py.

Referenced by PYDAFOAM.__call__().

◆ nSolveAdjoints

nSolveAdjoints

Definition at line 683 of file pyDAFoam.py.

◆ primalFail

primalFail

Definition at line 686 of file pyDAFoam.py.

Referenced by PYDAFOAM.__call__().

◆ adjointFail

adjointFail

Definition at line 687 of file pyDAFoam.py.

◆ allSurfacesGroup

allSurfacesGroup

◆ allWallsGroup

allWallsGroup

◆ designSurfacesGroup

designSurfacesGroup

Definition at line 706 of file pyDAFoam.py.

Referenced by PYDAFOAM.calcFFD2XvSeeds().

◆ mesh

mesh

◆ dRdWTPC

dRdWTPC

Definition at line 717 of file pyDAFoam.py.

◆ ksp

ksp

Definition at line 720 of file pyDAFoam.py.

◆ dynamicMeshDeformed

dynamicMeshDeformed

Definition at line 723 of file pyDAFoam.py.

Referenced by PYDAFOAM.deformDynamicMesh().

◆ solverRegistry

solverRegistry

Definition at line 749 of file pyDAFoam.py.

◆ imOptions

imOptions

Definition at line 1096 of file pyDAFoam.py.

Referenced by PYDAFOAM.setOption().

◆ defaultOptions

defaultOptions

Definition at line 1099 of file pyDAFoam.py.

Referenced by PYDAFOAM.getOption(), and PYDAFOAM.setOption().

◆ options

options

◆ comm

comm

◆ parallel

parallel

Definition at line 1138 of file pyDAFoam.py.

Referenced by PYDAFOAM.deletePrevPrimalSolTime(), and PYDAFOAM.renameSolution().

◆ rank

rank

Definition at line 1143 of file pyDAFoam.py.

◆ nProcs

nProcs

Definition at line 1144 of file pyDAFoam.py.

Referenced by PYDAFOAM.array2Vec().

◆ parallelFlag

parallelFlag

Definition at line 1147 of file pyDAFoam.py.

Referenced by PYDAFOAM.calcFFD2XvSeeds().

◆ solver

solver

◆ solverAD

solverAD

◆ neighbours

neighbours

Definition at line 1489 of file pyDAFoam.py.

◆ xv

xv

Definition at line 1490 of file pyDAFoam.py.

Referenced by PYDAFOAM.getSurfaceCoordinates().

◆ basicFamilies

basicFamilies

◆ wallList

wallList

Definition at line 1604 of file pyDAFoam.py.


The documentation for this class was generated from the following file: