USMesh
- class idwarp.UnstructuredMesh.USMesh(*args, **kwargs)[source]
This is the main Unstructured Mesh. This mesh object is designed to interact with an structured or unstructured CFD solver though a variety of interface functions.
Create the USMesh object.
- Parameters
- optionsdictionary
A dictionary containing the options for the mesh movement strategies. THIS IS NOT OPTIONAL.
- commMPI_INTRA_COMM
MPI communication (as obtained from mpi4py) on which to create the USMesh object. If not provided, MPI_COMM_WORLD is used.
- debugbool
Flag specifying if the MExt import is automatically deleted. This needs to be true ONLY when a symbolic debugger is used.
- getCommonGrid()[source]
Return the grid in the original ordering. This is required for the OpenFOAM tecplot writer since the connectivity is only known in this ordering.
- getSolverGrid()[source]
Return the current grid in the order specified by setExternalMeshIndices(). This is the main routine for returning the defomed mesh to the external CFD solver.
- Returns
- solverGrid, numpy array, real: The resulting grid.
The output is returned in flatted 1D coordinate format. The len of the array is 3*len(indices) as set by setExternalMeshIndices()
- getSurfaceCoordinates()[source]
Returns all defined surface coordinates on this processor
- Returns
- coordsnumpy array size (N,3)
Specified surface coordinates residing on this processor. This may be empty array, size (0,3)
- getWarpGrid()[source]
Return the current grid. This funtion is typically unused. See getSolverGrid for the more useful interface functionality.
- Returns
- warpGrid, numpy array, real: The resulting grid.
The output is returned in flatted 1D coordinate format.
- getdXs()[source]
Return the current values in dXs. This is the result from a mesh-warp derivative computation.
- Returns
- dXsnumpy array
The specific components of dXs. size(N,3). This the same size as the array obtained with getSurfaceCoordiantes(). N may be zero if this processor does not have any surface coordinates.
- setExternalMeshIndices(ind)[source]
Set the indicies defining the transformation of an external solver grid to the original CGNS grid. This is required to use USMesh functions that involve the word “Solver” and warpDeriv. The indices must be zero-based.
- Parameters
- indnumpy integer array
The list of indicies this processor needs from the common mesh file
- setSurfaceCoordinates(coordinates)[source]
Sets all surface coordinates on this processor
- Parameters
- coordinatesnumpy array, size(N, 3)
The coordinate to set. This MUST be exactly the same size as the array obtained from getSurfaceCoordinates()
- setSurfaceDefinition(pts, conn, faceSizes, cgnsBlockID=None)[source]
This is the master function that determines the definition of the surface to be used for the mesh movement. This surface may be supplied from an external solver (such as SUmb) or it may be generated by IDWarp internally.
- Parameters
- ptsarray, size (M, 3)
Nodes on this processor
- connint array, size (sum(faceSizes))
Connectivity of the nodes on this processor
- faceSizesint Array size (N)
Treat the conn array as a flat list with the faceSizes giving connectivity offset for each element.
- cgnsBlockIDdummy argument.
This argument is not used at all. It is here just to have the same API as the IDWarpMulti class.
- setSurfaceDefinitionFromFile(surfFile)[source]
Set the surface definition for the warping from a multiblock PLOT3D surface file
- Parameters
- surfFilefilename of multiblock PLOT3D surface file.
- setSurfaceFromFile(surfFile)[source]
Update the internal surface surface coordinates using an external PLOT3D surface file. This can be used in an analogous way to setSurfaceDefinitionFromFile. The ‘sense’ of the file must be same as the file used with setSurfaceDefinitionFromFile. That means, the same number of blocks, with the same sizes, in the same order.
- Parameters
- surfFile: filename of multiblock PLOT3D surface file’
- verifyWarpDeriv(dXv=None, solverVec=True, dofStart=0, dofEnd=10, h=1e-06, randomSeed=314)[source]
Run an internal verification of the solid warping derivatives
- warpDeriv(dXv, solverVec=True)[source]
Compute the warping derivative (dXv/dXs^T)*Vec (where vec is the dXv argument to this function.
This is the main routine to compute the mesh warping derivative.
- Parameters
- dXvnumpy array
Vector of size external solver_grid. This is typically obtained from the external solver’s dRdx^T * psi calculation.
- solverVeclogical
Flag to indicate that the dXv vector is in the solver ordering and must be converted to the warp ordering first. This is the usual approach and thus defaults to True.
- Returns
- None. The resulting calculation is available from the getdXs()
- function.
- warpDerivFwd(dXs, solverVec=True)[source]
Compute the forward mode warping derivative
This routine is not used for “regular” optimization; it is used for matrix-free type optimization. dXs is assumed to be the the peturbation on all the surface nodes.
- Parameters
- dXsarray, size Nsx3
This is the forward mode peturbation seed. Same size as the surface mesh from getSurfaceCoordinates().
- solverVecbool
Whether or not to convert to the solver ordering.
- Returns
- dXvarray
The peturbation on the volume meshes. It may be in warp ordering or solver ordering depending on the solverVec flag.
- warpMesh()[source]
Run the applicable mesh warping strategy.
This will update the volume coordinates to match surface coordinates set with setSurfaceCoordinates()
- writeGrid(fileName=None)[source]
Write the current grid to the correct format
- Parameters
- fileNamestr or None
Filename for grid. Should end in .cgns for CGNS files. For PLOT3D whatever you want. It is not optional for CGNS/PLOT3D. It is not required for OpenFOAM meshes. This call will update the ‘points’ file.