Public Member Functions  
def  __init__ (self) 
Static Public Attributes  
string  solverName = "DASimpleFoam" 
The name of the DASolver to use for primal and adjoint computation. More...  
float  primalMinResTol = 1.0e8 
The convergence tolerance for the primal solver. More...  
dictionary  primalBC = {} 
The boundary condition for primal solution. More...  
dictionary  normalizeStates 
State normalization for dRdWT computation. More...  
dictionary  objFunc = {} 
Information on objective function. More...  
dictionary  designVar = {} 
Design variable information. More...  
list  designSurfaces = ["None"] 
List of patch names for the design surface. More...  
dictionary  fvSource = {} 
Information for the finite volume source term, which will be added in the momentum equation We support multiple source terms Example "fvSource": { "disk1": { "type": "actuatorDisk", # Actuator disk source. More...  
string  adjJacobianOption = "JacobianFD" 
Adjoint solution option. More...  
dictionary  primalVarBounds 
The variable upper and lower bounds for primal solution. More...  
bool  multiPoint = False 
Whether to perform multipoint optimization. More...  
int  nMultiPoints = 1 
If multiPoint = True, how many primal configurations for the multipoint optimization. More...  
dictionary  adjPartDerivFDStep 
The step size for finitedifference computation of partial derivatives. More...  
int  transonicPCOption = 1 
Which options to use to improve the adjoint equation convergence of transonic conditions This is used only for transonic solvers such as DARhoSimpleCFoam. More...  
dictionary  unsteadyAdjoint = {"mode": "None", "nTimeInstances": 1, "periodicity": 1.0} 
Options for unsteady adjoint. More...  
int  objFuncAvgStart = 1 
At which iteration should we start the averaging of objective functions. More...  
int  adjPCLag = 1 
The interval of recomputing the preconditioner matrix dRdWTPC for solveAdjoint By default, dRdWTPC will be recomputed each time the solveAdjoint function is called However, one can increase the lag to skip it and reuse the dRdWTPC computed previously. More...  
dictionary  useAD = {"mode": "None", "dvName": "None", "seedIndex": 9999} 
Whether to use AD: Mode options: forward, reverse, or None. More...  
string  rootDir = "./" 
The root directory is usually . More...  
string  runStatus = "None" 
The run status which can be solvePrimal, solveAdjoint, or calcTotalDeriv. More...  
bool  printPYDAFOAMOptions = False 
Whether to print all options defined in pyDAFoam to screen before optimization. More...  
bool  printDAOptions = True 
Whether to print all DAOption defined in the C++ layer to screen before optimization. More...  
bool  debug = False 
Whether running the optimization in the debug mode, which prints extra information. More...  
list  writeJacobians = ["None"] 
Whether to write Jacobian matrices to file for debugging Example: writeJacobians = ["dRdWT", "dFdW"] This will write the dRdWT and dFdW matrices to the disk. More...  
int  printInterval = 100 
The print interval of primal and adjoint solution, e.g., how frequent to print the primal solution steps, how frequent to print the dRdWT partial derivative computation. More...  
int  printIntervalUnsteady = 500 
The print interval of unsteady primal solvers, e.g., for DAPisoFoam. More...  
float  primalMinResTolDiff = 1.0e2 
Users can adjust primalMinResTolDiff to tweak how much difference between primalMinResTol and the actual primal convergence is consider to be fail=True for the primal solution. More...  
bool  adjUseColoring = True 
Whether to use graph coloring to accelerate partial derivative computation. More...  
dictionary  adjEqnOption 
The Petsc options for solving the adjoint linear equation. More...  
list  normalizeResiduals 
Normalization for residuals. More...  
dictionary  maxResConLv4JacPCMat 
The maximal connectivity level for the dRdWTPC matrix. More...  
dictionary  jacLowerBounds 
The min bound for Jacobians, any value that is smaller than the bound will be set to 0 Setting a large lower bound for preconditioner (PC) can help to reduce memory. More...  
int  maxTractionBCIters = 100 
The maximal iterations of tractionDisplacement boundary conditions. More...  
dictionary  decomposeParDict 
decomposeParDict option. More...  
string  adjStateOrdering = "state" 
The ordering of state variable. More...  
string  meshSurfaceFamily = "None" 
Default name for the mesh surface family. More...  
string  designSurfaceFamily = "designSurfaces" 
Default name for the design surface family. More...  
dictionary  checkMeshThreshold 
The threshold for check mesh call. More...  
list  writeSensMap = ["NONE"] 
The sensitivity map will be saved to disk during optimization for the given design variable names in the list. More...  
bool  writeDeformedFFDs = False 
Whether to write deformed FFDs to the disk during optimization. More...  
Define a set of options to use in PYDAFOAM and set their initial values. This class will be used by PYDAFOAM._getDefOptions() NOTE: Give an initial value for a new option, this help PYDAFOAM determine the type of this option. If it is a list, give at least one default value. If it is a dict, you can leave it blank, e.g., {}. Also, use ## to add comments before the new option such that these comments will be picked up by Doxygen. If possible, give examples. NOTE: We group these options into three categories.  The basic options are those options that will be used for EVERY solvers and EVERY cases.  The intermediate options are options that will be used in some of solvers for special situation (e.g., primalVarBounds to prevent solution from divergence).  The advanced options will be used in special situation to improve performance, e.g., maxResConLv4JacPCMat to reduce memory of preconditioner. Its usage is highly case dependent. It may also include options that have a default value that is rarely changed, except for very special situation.
Definition at line 30 of file pyDAFoam.py.
def __init__  (  self  ) 
Nothing needs to be done for initializing DAOPTION
Definition at line 579 of file pyDAFoam.py.

static 
The name of the DASolver to use for primal and adjoint computation.
See dafoam/src/adjoint/DASolver for more details Currently support:
Definition at line 65 of file pyDAFoam.py.

static 
The convergence tolerance for the primal solver.
If the primal can not converge to 2 orders of magnitude (default) higher than this tolerance, the primal solution will return fail=True
Definition at line 69 of file pyDAFoam.py.

static 
The boundary condition for primal solution.
The keys should include "variable", "patch", and "value". For turbulence variable, one can also set "useWallFunction" [bool]. Note that setting "primalBC" will overwrite any values defined in the "0" folder. The primalBC setting will be printed to screen for each primal solution during the optimization Example "primalBC": { "U0": {"variable": "U", "patches": ["inlet"], "value": [10.0, 0.0, 0.0]}, "p0": {"variable": "p", "patches": ["outlet"], "value": [101325.0]}, "nuTilda0": {"variable": "nuTilda", "patches": ["inlet"], "value": [1.5e4]}, "useWallFunction": True, },
Definition at line 82 of file pyDAFoam.py.

static 
State normalization for dRdWT computation.
Typically, we set far field value for each state variable. NOTE: If you forget to set normalization value for a state variable, the adjoint may not converge or it may be inaccurate! For "phi", use 1.0 to normalization Example normalizeStates = {"U": 10.0, "p": 101325.0, "phi": 1.0, "nuTilda": 1.e4}
Definition at line 89 of file pyDAFoam.py.

static 
Information on objective function.
Each objective function requires a different input forma But for all objectives, we need to give a name to the objective function, e.g., CD or any other preferred name, and the information for each part of the objective function. Most of the time, the objective has only one part (in this case part1), but one can also combine two parts of objectives, e.g., we can define a new objective that is the sum of force and moment. For each part, we need to define the type of objective (e.g., force, moment; we need to use the reserved type names), how to select the discrete mesh faces to compute the objective (e.g., we select them from the name of a patch patchToFace), the name of the patch (wing) for patchToFace, the scaling factor "scale", and whether to compute adjoint for this objective "addToAdjoint". For force objectives, we need to project the force vector to a specific direction. The following example defines that CD is the force that is parallel to flow (parallelToFlow). Alternative, we can also use fixedDirection and provide a direction key for force, i.e., "directionMode": "fixedDirection", "direction": [1.0, 0.0, 0.0]. Since we select parallelToFlow, we need to prescribe the name of angle of attack design variable to determine the flow direction. Here alpha will be defined in runScript.py: DVGeo.addGeoDVGlobal("alpha", [alpha0], alpha, lower=10.0, upper=10.0, scale=1.0). NOTE: if no alpha is added in DVGeo.addGeoDVGlobal, we can NOT use parallelToFlow. For this case, we have to use "directionMode": "fixedDirection". Example "objFunc": { "CD": { "part1": { "type": "force", "source": "patchToFace", "patches": ["wing"], "directionMode": "parallelToFlow", "alphaName": "alpha", "scale": 1.0 / (0.5 * UmagIn * UmagIn * ARef), "addToAdjoint": True, } }, "CL": { "part1": { "type": "force", "source": "patchToFace", "patches": ["wing"], "directionMode": "normalToFlow", "alphaName": "alpha", "scale": 1.0 / (0.5 * UmagIn * UmagIn * ARef), "addToAdjoint": True, } }, "CMZ": { "part1": { "type": "moment", "source": "patchToFace", "patches": ["wing"], "axis": [0.0, 0.0, 1.0], "center": [0.25, 0.0, 0.05], "scale": 1.0 / (0.5 * UmagIn * UmagIn * ARef * LRef), "addToAdjoint": True, } }, "TPR": { "part1": { "type": "totalPressureRatio", "source": "patchToFace", "patches": ["inlet", "outlet"], "inletPatches": ["inlet"], "outletPatches": ["outlet"], "scale": 1.0, "addToAdjoint": True, } }, "TTR": { "part1": { "type": "totalTemperatureRatio", "source": "patchToFace", "patches": ["inlet", "outlet"], "inletPatches": ["inlet"], "outletPatches": ["outlet"], "scale": 1.0, "addToAdjoint": False, } }, "MFR": { "part1": { "type": "massFlowRate", "source": "patchToFace", "patches": ["inlet"], "scale": 1.0, "addToAdjoint": True, } }, "PL": { "part1": { "type": "totalPressure", "source": "patchToFace", "patches": ["inlet"], "scale": 1.0 / (0.5 * U0 * U0), "addToAdjoint": True, }, "part2": { "type": "totalPressure", "source": "patchToFace", "patches": ["outlet"], "scale": 1.0 / (0.5 * U0 * U0), "addToAdjoint": True, } }, "NU": { "part1": { "type": "wallHeatFlux", "source": "patchToFace", "patches": ["ubend"], "scale": 1.0, "addToAdjoint": True, } }, "VMS": { "part1": { "type": "vonMisesStressKS", "source": "boxToCell", "min": [10.0, 10.0, 10.0], "max": [10.0, 10.0, 10.0], "scale": 1.0, "coeffKS": 2.0e3, "addToAdjoint": True, } }, "M": { "part1": { "type": "mass", "source": "boxToCell", "min": [10.0, 10.0, 10.0], "max": [10.0, 10.0, 10.0], "scale": 1.0, "addToAdjoint": True, } }, "THRUST": { "part1": { "type": "variableVolSum", "source": "boxToCell", "min": [50.0, 50.0, 50.0], "max": [50.0, 50.0, 50.0], "varName": "fvSource", "varType": "vector", "component": 0, "isSquare": 0, "scale": 1.0, "addToAdjoint": True, }, }, "FI": { "part1": { "type": "stateErrorNorm", "source": "boxToCell", "min": [100.0, 100.0, 100.0], "max": [100.0, 100.0, 100.0], "stateName": "U", "stateRefName": "UTrue", "stateType": "vector", "scale": 1.0, "addToAdjoint": True, }, "part2": { "type": "stateErrorNorm", "source": "boxToCell", "min": [100.0, 100.0, 100.0], "max": [100.0, 100.0, 100.0], "stateName": "betaSA", "stateRefName": "betaSATrue", "stateType": "scalar", "scale": 0.01, "addToAdjoint": True, }, }, },
Definition at line 271 of file pyDAFoam.py.

static 
Design variable information.
Different type of design variables require different keys For alpha, we need to prescribe a list of far field patch names from which the angle of attack is computed, this is usually a far field patch. Also, we need to prescribe flow and normal axies, and alpha = atan( U_normal / U_flow ) at patches Example designVar = { "shapey" : {"designVarType": "FFD"}, "twist": {"designVarType": "FFD"}, "alpha" = { "designVarType": "AOA", "patches": ["farField"], "flowAxis": "x", "normalAxis": "y" }, "ux0" = { "designVarType": "BC", "patches": ["inlet"], "variable": "U", "comp": 0 }, }
Definition at line 294 of file pyDAFoam.py.

static 
List of patch names for the design surface.
These patch names need to be of wall type and shows up in the constant/polyMesh/boundary file
Definition at line 298 of file pyDAFoam.py.

static 
Information for the finite volume source term, which will be added in the momentum equation We support multiple source terms Example "fvSource": { "disk1": { "type": "actuatorDisk", # Actuator disk source.
This is a child class in DAFvSource "source": "cylinderAnnulusToCell", # Define a volume to add the fvSource term "p1": [0.4, 0.1, 0.05], # p1 and p2 define the axis and width "p2": [0.1, 0.1, 0.05], # p2p1 should be streamwise "innerRadius": 0.01, "outerRadius": 0.5, "rotDir": "left", "scale": 50.0, "POD": 0.7, # pitch/diameter }, "disk2": { "type": "actuatorDisk", "source": "cylinderAnnulusToCell", "p1": [0.4, 0.1, 0.05], "p2": [0.1, 0.1, 0.05], "innerRadius": 0.01, "outerRadius": 0.5, "rotDir": "right", "scale": 25.0, # scale the source such the integral equals desired thrust "POD": 1.0, }, "line1": { "type": "actuatorPoint", "smoothFunction": "hyperbolic", # or gaussian "center": [0.55, 0.0, 0.05], # center and size define a rectangular "size": [0.2, 0.2, 0.1], "amplitude": [0.0, 0.2, 0.0], "thrustDirIdx": 0, "periodicity": 0.1, "eps": 10.0, "scale": 10.0 # scale the source such the integral equals desired thrust }, "gradP" { "type": "uniformPressureGradient", "value": 1e3, "direction": [1.0, 0.0, 0.0], }, },
Definition at line 349 of file pyDAFoam.py.

static 
Adjoint solution option.
JacobianFD: Using finitedifference method to compute the partials JacobianFree: Using the matrixfree GMRES to solve the adjoint equation without computing the state Jacobians.
Definition at line 355 of file pyDAFoam.py.

static 
The variable upper and lower bounds for primal solution.
The key is variable+"Max/Min". Setting the bounds increases the robustness of primal solution for compressible solvers. Also, we set lower bounds for turbulence variables to ensure they are physical Example primalValBounds = {"UMax": 1000, "UMin": 1000, "pMax": 1000000}
Definition at line 362 of file pyDAFoam.py.

static 
Whether to perform multipoint optimization.
Definition at line 394 of file pyDAFoam.py.

static 
If multiPoint = True, how many primal configurations for the multipoint optimization.
Definition at line 397 of file pyDAFoam.py.

static 
The step size for finitedifference computation of partial derivatives.
The default values will work for most of the case.
Definition at line 401 of file pyDAFoam.py.

static 
Which options to use to improve the adjoint equation convergence of transonic conditions This is used only for transonic solvers such as DARhoSimpleCFoam.
Definition at line 413 of file pyDAFoam.py.

static 
Options for unsteady adjoint.
mode can be hybridAdjoint or timeAccurateAdjoint Here nTimeInstances is the number of time instances and periodicity is the periodicity of flow oscillation (hybrid adjoint only)
Definition at line 418 of file pyDAFoam.py.

static 
At which iteration should we start the averaging of objective functions.
This is only used for unsteady solvers
Definition at line 422 of file pyDAFoam.py.

static 
The interval of recomputing the preconditioner matrix dRdWTPC for solveAdjoint By default, dRdWTPC will be recomputed each time the solveAdjoint function is called However, one can increase the lag to skip it and reuse the dRdWTPC computed previously.
This obviously increses the speed because the dRdWTPC computation takes about 30% of the adjoint total runtime. However, setting a too large lag value will decreases the speed of solving the adjoint equations. One needs to balance these factors
Definition at line 430 of file pyDAFoam.py.

static 
Whether to use AD: Mode options: forward, reverse, or None.
If forward mode AD is used the seedIndex will be set to compute derivative by running the whole primal solver. dvName is the name of design variable to set the seed for the forward AD setting seedIndex to 1 for dFdField will assign seeds for all design variables.
Definition at line 436 of file pyDAFoam.py.

static 

static 
The run status which can be solvePrimal, solveAdjoint, or calcTotalDeriv.
This parameter is used internally, so users should never change this option in the Python layer.
Definition at line 447 of file pyDAFoam.py.

static 
Whether to print all options defined in pyDAFoam to screen before optimization.
Definition at line 450 of file pyDAFoam.py.

static 
Whether to print all DAOption defined in the C++ layer to screen before optimization.
Definition at line 453 of file pyDAFoam.py.

static 
Whether running the optimization in the debug mode, which prints extra information.
Definition at line 456 of file pyDAFoam.py.

static 
Whether to write Jacobian matrices to file for debugging Example: writeJacobians = ["dRdWT", "dFdW"] This will write the dRdWT and dFdW matrices to the disk.
Definition at line 462 of file pyDAFoam.py.

static 
The print interval of primal and adjoint solution, e.g., how frequent to print the primal solution steps, how frequent to print the dRdWT partial derivative computation.
Definition at line 466 of file pyDAFoam.py.

static 
The print interval of unsteady primal solvers, e.g., for DAPisoFoam.
Definition at line 469 of file pyDAFoam.py.

static 
Users can adjust primalMinResTolDiff to tweak how much difference between primalMinResTol and the actual primal convergence is consider to be fail=True for the primal solution.
Definition at line 473 of file pyDAFoam.py.

static 
Whether to use graph coloring to accelerate partial derivative computation.
Unless you are debugging the accuracy of partial computation, always set it to True
Definition at line 477 of file pyDAFoam.py.

static 
The Petsc options for solving the adjoint linear equation.
These options should work for most of the case. If the adjoint does not converge, try to increase pcFillLevel to 2, or try "jacMatReOrdering": "nd"
Definition at line 482 of file pyDAFoam.py.

static 
Normalization for residuals.
We should normalize all residuals!
Definition at line 498 of file pyDAFoam.py.

static 
The maximal connectivity level for the dRdWTPC matrix.
Reducing the connectivity level reduce the memory usage, however, it may slow down the adjoint equation convergence. The default value should have the best convergence speed but not optimal memory usage.
Definition at line 514 of file pyDAFoam.py.

static 
The min bound for Jacobians, any value that is smaller than the bound will be set to 0 Setting a large lower bound for preconditioner (PC) can help to reduce memory.
Definition at line 529 of file pyDAFoam.py.

static 
The maximal iterations of tractionDisplacement boundary conditions.
Definition at line 535 of file pyDAFoam.py.

static 
decomposeParDict option.
This file will be automatically written such that users can run optimization with any number of CPU cores without the need to manually change decomposeParDict
Definition at line 540 of file pyDAFoam.py.

static 
The ordering of state variable.
Options are: state or cell. Most of the case, the state odering is the best choice.
Definition at line 548 of file pyDAFoam.py.

static 
Default name for the mesh surface family.
Users typically don't need to change
Definition at line 551 of file pyDAFoam.py.

static 
Default name for the design surface family.
Users typically don't need to change
Definition at line 554 of file pyDAFoam.py.

static 
The threshold for check mesh call.
Definition at line 557 of file pyDAFoam.py.

static 
The sensitivity map will be saved to disk during optimization for the given design variable names in the list.
Currently only support design variable type FFD and Field The surface sensitivity map is separated from the primal solution because they only have surface mesh. They will be saved to folders such as 1e11, 2e11, 3e11, etc, When loading in paraview, you need to uncheck the "internalMesh", and check "allWalls" on the left panel If your design variable is of field type, the sensitivity map will be saved along with the primal solution because they share the same mesh. The sensitivity files read sens_objFuncName_designVarName NOTE: this function only supports adjJacobianOption = JacobianFree Example: "writeSensMap" : ["shapex", "shapey"]
Definition at line 574 of file pyDAFoam.py.

static 
Whether to write deformed FFDs to the disk during optimization.
Definition at line 577 of file pyDAFoam.py.