### DVGeometryESP Initialization Example Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeoESP.html Demonstrates how to initialize the DVGeometryESP class with a CSM file and add a point set to it. Ensure OCSM and pyOCSM are installed. ```Python from pygeo import DVGeometryESP DVGeo = DVGeometryESP("wing.csm", MPI_COMM_WORLD) DVGeo.addPointSet(Xpt, "myPoints") ``` -------------------------------- ### Install pyGeo Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_sources/install.rst.txt Install pyGeo from a cloned repository. Ensure you have a working Fortran compiler for the pyspline dependency. ```bash pip install . ``` -------------------------------- ### Install pyGeo Package Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/install.html Use this command to install the pyGeo package from a cloned repository. Ensure you have a working Fortran compiler. ```bash pip install . ``` -------------------------------- ### Install pyGeo with Testing Dependencies Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/install.html Install pyGeo along with additional testing dependencies like numpy-stl and parameterized. This command is useful for setting up a testing environment. ```bash pip install .[testing] ``` -------------------------------- ### Install pyGeo with Testing Dependencies Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_sources/install.rst.txt Install pyGeo along with additional testing dependencies like numpy-stl and parameterized. This command is used after cloning the repository. ```bash pip install .[testing] ``` -------------------------------- ### DVCon Proximity Constraint Setup Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/constraints/DVCon.html This snippet illustrates the initialization and setup for adding proximity constraints using the DVCon class. It shows how to define points, vectors, and surface names for constraint calculations, including error handling for projection failures. ```python self._checkDVGeo(DVGeoName) if pointSetKwargsA is None: pointSetKwargsA = {} if pointSetKwargsB is None: pointSetKwargsB = {} ptList = np.atleast_2d(ptList) vecList = np.atleast_2d(vecList) nCon = ptList.shape[0] if nCon != vecList.shape[0]: raise Error( "The vecList argument of addProximityConstraints needs to have the same number of vectors as the number of points." ) coordsA = np.zeros((nCon, 3)) coordsB = np.zeros((nCon, 3)) # get the intersections with both components A and B p0A, p1A, p2A = self._getSurfaceVertices(surfaceName=surfA) v1A = p1A - p0A v2A = p2A - p0A p0B, p1B, p2B = self._getSurfaceVertices(surfaceName=surfB) v1B = p1B - p0B v2B = p2B - p0B # Project all the points for ii in range(nCon): # get the point and vector pt = ptList[ii] vec = vecList[ii] # Projections. Surf A first. projA, fail = geo_utils.projectNodePosOnly(pt, vec, p0A, v1A, v2A) if fail > 0: raise Error( "There was an error projecting a node to surf A " "at (%f, %f, %f) with normal (%f, %f, %f)." % (pt[0], pt[1], pt[2], vec[0], vec[1], vec[2]) ) ``` -------------------------------- ### Setup OM_DVGEOCOMP with Single DVGeo Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/mphys/mphys_dvgeo.html Sets up the OM_DVGEOCOMP component for a single DVGeo instance. This maintains compatibility with older interfaces. ```python # create a constraints object to go with this DVGeo(s) self.DVCon = DVConstraints() # hold the DVGeo(s) in a dictionary self.DVGeos = {} # conventional setup with one DVGeo. maintains old interface if self.options["DVGeoInfo"] is None: self.multDVGeo = False # set up DVGeoInfo so a single DVGeo can be initialized with the multi-DVGeo case DVGeoInfo = { "defaultDVGeo": { "file": self.options["file"], "type": self.options["type"], "options": self.options["options"], } } # DVGeo and DVCon expect different defaults DVConName = "default" DVGeoName = None # we need to add multiple DVGeos to this geometry component # the actual initialization is handled in the same way regardless else: self.multDVGeo = True DVGeoInfo = self.options["DVGeoInfo"] ``` -------------------------------- ### Coordinate Transformation Example Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeo.html Demonstrates forward and backward coordinate transformations including rotation and translation. The order of operations is critical. ```python rot_mat = np.array([ [1, 0, 0], [0, 0, -1], [0, 1, 0], ]) if mode == "fwd": # apply the rotation first coords_new = np.dot(coords, rot_mat) # then the translation if applyDisplacement: coords_new[:, 2] -= 5 elif mode == "bwd": # apply the operations in reverse coords_new = coords.copy() if applyDisplacement: coords_new[:, 2] += 5 # and the rotation. note the rotation matrix is transposed # for switching the direction of rotation coords_new = np.dot(coords_new, rot_mat.T) return coords_new ``` -------------------------------- ### Coordinate Transformation Callback Example Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeo.html This example demonstrates a user-defined callback function for coordinate transformations between DVGeo and other reference frames (e.g., CFD). It highlights the importance of correctly handling 'fwd' and 'bwd' modes and the 'applyDisplacement' flag for derivative accuracy. ```python def coordXfer(coords, mode="fwd", applyDisplacement=True, **kwargs): # given the (npt by 3) array "coords" apply the coordinate transformation. # The "fwd" mode implies we go from DVGeo reference frame to the # application, e.g. CFD, the "bwd" mode is the opposite; # goes from the CFD reference frame back to the DVGeo reference frame. # the applyDisplacement flag needs to be correctly implemented # by the user; the derivatives are also passed through this routine # and they only need to be rotated when going between reference frames, # and they should NOT be displaced. # In summary, all the displacements MUST be within the if applyDisplacement == True # checks, otherwise the derivatives will be wrong. ``` -------------------------------- ### Setting Surface from pyGeo Object Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/constraints/DVCon.html This example demonstrates how to set a surface using a pyGeo object, typically loaded from a file like an IGES file. ```python surf = pyGeo("iges", fileName="wing.igs") DVCon.setSurface(surf) ``` -------------------------------- ### Initialize DVGeometryMulti Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeoMulti.html Initializes the DVGeometryMulti class. Requires pySurf to be installed. Sets up data structures for components, design variables, points, and communication. ```python from collections import OrderedDict from baseclasses.utils import Error from mpi4py import MPI import numpy as np from scipy import sparse try: from pysurf import ( adtAPI, adtAPI_cs, curveSearchAPI, curveSearchAPI_cs, intersectionAPI, intersectionAPI_cs, tecplot_interface, tsurf_tools, utilitiesAPI, utilitiesAPI_cs, ) pysurfInstalled = True except ImportError: pysurfInstalled = False class DVGeometryMulti: def __init__(self, comm=MPI.COMM_WORLD, checkDVs=True, debug=False, isComplex=False): if not pysurfInstalled: raise ImportError("pySurf is not installed and is required to use DVGeometryMulti.") self.compNames = [] self.comps = OrderedDict() self.DVGeoDict = OrderedDict() self.points = OrderedDict() self.comm = comm self.updated = {} self.intersectComps = [] self.checkDVs = checkDVs self.debug = debug self.complex = isComplex if isComplex: self.dtype = complex self.adtAPI = adtAPI_cs.adtapi else: self.dtype = float self.adtAPI = adtapi.adtapi ``` -------------------------------- ### DVGeometryESP Class Initialization Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeoESP.html Initializes the DVGeometryESP class, setting up parameters for ESP geometry manipulation. Requires OCSM and pyOCSM to be installed. ```Python def __init__( self, fileName, comm=MPI.COMM_WORLD, scale=1.0, bodies=[], projTol=0.01, debug=False, maxproc=None, suppress_stdout=False, exclude_edge_projections=False, ulimits=None, vlimits=None, name=None, ): if not ocsmImported: raise ImportError("OCSM and pyOCSM must be installed to use DVGeometryESP.") if comm.rank == 0: print("Initializing DVGeometryESP") t0 = time.time() super().__init__(fileName=fileName, comm=comm, scale=scale, projTol=projTol, name=name) self.maxproc = maxproc self.esp = True # will become a list of tuples with (DVName, localIndex) - used for finite difference load balancing self.globalDVList = [] self.useComposite = False self.suppress_stdout = suppress_stdout self.exclude_edge_projections = exclude_edge_projections ``` -------------------------------- ### Initialize DVGeometry and Add Wing Pointset Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_sources/advanced_ffd.rst.txt Initializes a DVGeometry object with an FFD file and adds the wing pointset. This is the starting point for FFD parameterization. ```python import pygeo # Initialize DVGeometry object dvGeo = pygeo.DVGeometry('../examples/c172_wing/c172.stl') # Add the wing pointset dvGeo.add_point_cloud(name='wing', filename='../examples/c172_wing/c172.stl') ``` -------------------------------- ### Initialize DVGeometryVSP and Add Point Set Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/DVGeometryVSP.html Demonstrates the basic setup for DVGeometryVSP, including initialization with a VSP file and adding a set of coordinates. Ensure MPI is initialized if using MPI_COMM_WORLD. ```python from pygeo import DVGeometryVSP DVGeo = DVGeometryVSP("wing.vsp3", MPI_COMM_WORLD) # Add a set of coordinates Xpt into the object DVGeo.addPointSet(Xpt, "myPoints") ``` -------------------------------- ### Initialize DVGeo Component Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/mphys_dvgeo.html Set up a geometry component using either a single DVGeo or multiple DVGeos. Specify the file and type for a single DVGeo, or use a dictionary for multiple DVGeos, each with a unique name. ```python DVGeoInfo = { "name1": {"file": file1, "type": type1, "options": options1} "name2": {"file": file2, "type": type2, "options": options2} } ``` -------------------------------- ### Project Points to Component Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeoMulti.html Initializes the projection process by setting up a bounding box for a new ADT (Abstract Data Type) for a given component. It prepares for spatial partitioning, though the actual projection logic is not detailed in this snippet. ```python def _projectToComponent(self, pts, comp, projDict, surface=None): # We build an ADT for this component using pySurf # Set bounding box for new tree BBox = np.zeros((2, 3)) useBBox = False # dummy connectivity data for quad elements since we have all tris quadConn = np.zeros((0, 4)) ``` -------------------------------- ### Get Number of Design Variables Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/DVGeometryCST.html Returns the total count of design variables managed by this object. ```python getNDV()[source] Return the total number of design variables this object has. Returns: **nDV** int Total number of design variables ``` -------------------------------- ### Getting Number of Design Variables Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeoVSP.html Returns the total count of design variables managed by the DVGeoVSP instance. ```python def getNDV(self): """ Return the number of DVs Returns ------- len(self.DVs) : int number of design variables """ return len(self.DVs) ``` -------------------------------- ### Initialize DVGeometry and Add Geometry Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeo.html Demonstrates the basic workflow of initializing DVGeometry with a file and adding a point set. This is the starting point for defining geometric design variables. ```python from pygeo import DVGeometry DVGeo = DVGeometry('FFD_file.fmt') # Embed a set of coordinates Xpt into the object DVGeo.addPointSet(Xpt, 'myPoints') ``` -------------------------------- ### Get Design Variable Bounds Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/DVGeometryCST.html Retrieves the lower and upper bounds for the design variables managed by the object. ```python getDVBounds()[source] Return the bounds on the design variables. Returns: **lowerBounds** dict Dictionary of design variable lower bounds **upperBounds** dict Dictionary of design variable upper bounds ``` -------------------------------- ### Basic DVGeometry Usage Example Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/DVGeometry.html Illustrates the general sequence of operations for using DVGeometry, including embedding point sets, adding reference axes, and defining global and local design variables. ```python >>> from pygeo import DVGeometry >>> DVGeo = DVGeometry('FFD_file.fmt') >>> # Embed a set of coordinates Xpt into the object >>> DVGeo.addPointSet(Xpt, 'myPoints') >>> # Associate a 'reference axis' for large-scale manipulation >>> DVGeo.addRefAxis('wing_axis', axis_curve) >>> # Define a global design variable function: >>> def twist(val, geo): >>> geo.rot_z['wing_axis'].coef[:] = val[:] >>> # Now add this as a global variable: >>> DVGeo.addGlobalDV('wing_twist', 0.0, twist, lower=-10, upper=10) >>> # Now add local (shape) variables >>> DVGeo.addLocalDV('shape', lower=-0.5, upper=0.5, axis='y') ``` -------------------------------- ### Get Total Number of Design Variables Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeoMulti.html Calculates and returns the total number of design variables across all managed components. ```python def getNDV(self): """Return the number of DVs.""" # Loop over components and sum the number of DVs nDV = 0 for comp in self.compNames: nDV += self.comps[comp].DVGeo.getNDV() return nDV ``` -------------------------------- ### Initialize DVGeometry VSP Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeoVSP.html Initializes the DVGeometry VSP object, setting up component lists, names, bounding boxes, and quad meshes for efficient projections. This is typically done once during the setup phase. ```python if not comps: # no components specified, we use all self.allComps = allComps[:] else: # we get the vsp comp IDs from the comps list self.allComps = [] for c in comps: self.allComps.append(allComps[allNames.index(c)]) # we need the names and bounding boxes of components self.compNames = [] self.bbox = OrderedDict() self.bboxuv = self._getuv() for c in self.allComps: self.compNames.append(self.vspModel.GetContainerName(c)) self.bbox[c] = self._getBBox(c) # Now, we need to form our own quad meshes for fast projections if comm.rank == 0: print("Building a quad mesh for fast projections.") self._getQuads() self.useComposite = False if comm.rank == 0: t3 = time.time() print("Initialized DVGeometry VSP in", (t3 - t0), "seconds.") ``` -------------------------------- ### Get Design Variable Names Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/DVGeometryCST.html Returns a list of design variable names, often used for specifying optimization sensitivities. ```python getVarNames(_** kwargs_)[source] Return a list of the design variable names. This is typically used when specifying a wrt= argument for pyOptSparse. Examples ``` >>> optProb.addCon(.....wrt=DVGeo.getVarNames()) ``` ``` -------------------------------- ### Get Local Design Variables (Self) Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeo.html Calculates the number of local design variables belonging directly to this object, excluding any from children. ```python def _getNDVLocalSelf(self): """ Get total number of local variables, not including children """ nDV = 0 for key in self.DV_listLocal: nDV += self.DV_listLocal[key].nVal return nDV ``` -------------------------------- ### Get Global Design Variables (Self) Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeo.html Calculates the number of global design variables belonging directly to this object, excluding any from children. ```python def _getNDVGlobalSelf(self): """ Get total number of global variables, not including children """ nDV = 0 for key in self.DV_listGlobal: nDV += self.DV_listGlobal[key].nVal return nDV ``` -------------------------------- ### Get Original Points from DVGeo Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeo.html Retrieves the original coordinates for a specified point set. These are the coordinates that were initially passed to the `addPointSet` function. ```python def getOrigPoints(self, ptSetName): """Get the original coordinates for a point set. a.k.a the coordinates that were passed to :func:`addPointSet`. Parameters ---------- ptSetName : str Name of the point set to return the original coordinates for. """ return self.points[ptSetName] ``` -------------------------------- ### Setting up DVGeometry for Wing Twist Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/update_pygeo.html This snippet demonstrates how to initialize DVGeometry, add a reference axis for twisting, define a twist function, and add it as a global design variable. It also shows how to retrieve, modify, and set the design variables to apply a specific twist. ```python DVGeo = DVGeometry(input_files + "deform_geometry_ffd.xyz") # Create reference axis nRefAxPts = DVGeo.addRefAxis("wing", xFraction=0.25, alignIndex="k") # Set the Twist Variable def twist(val, geo): for i in range(nRefAxPts): geo.rot_z["wing"].coef[i] = val[i] # Add the Twist Design Variable to DVGeo DVGeo.addGlobalDV(dvName="twist", value=[0] * nRefAxPts, func=twist, lower=-10, upper=10, scale=1.0) # Get Design Variables dvDict = DVGeo.getDesignVars() # Set First Twist Section to 5deg dvDict["twist"][0] = 5 # Set Design Variables DVGeo.setDesignVars(dvDict) ``` -------------------------------- ### Get Surface Vertices Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/constraints/DVCon.html Retrieves the vertices defining a triangulated surface mesh. Can fetch from the original surface or from a specific DVGeo object. ```python p0, p1, p2 = self._getSurfaceVertices(surfaceName="default", fromDVGeo=None) ``` -------------------------------- ### Initialize Component with Bounding Box Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeoMulti.html Initializes a component with its geometry, connectivity, and bounding box information. Allows modification of the initial bounding box if user-specified coordinates are provided. ```python # we will need the bounding box information later on, so save this here xMin, xMax = DVGeo.FFD.getBounds() # also we might want to modify the bounding box if the user specified any coordinates if "xmin" in bbox: xMin[0] = bbox["xmin"] if "ymin" in bbox: xMin[1] = bbox["ymin"] if "zmin" in bbox: xMin[2] = bbox["zmin"] if "xmax" in bbox: xMax[0] = bbox["xmax"] if "ymax" in bbox: xMax[1] = bbox["ymax"] if "zmax" in bbox: xMax[2] = bbox["zmax"] # initialize the component object self.comps[comp] = component(comp, DVGeo, nodes, triConn, triConnStack, barsConn, xMin, xMax, triMeshData) # add the name to the list self.compNames.append(comp) # also save the DVGeometry pointer in the dictionary we pass back self.DVGeoDict[comp] = DVGeo ``` -------------------------------- ### Get Original Point Set Coordinates Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/DVGeometryCST.html Retrieves the original coordinates that were passed to the addPointSet() method for a specified point set name. ```python getOrigPoints(_ptSetName_)[source] Get the original coordinates for a point set. a.k.a the coordinates that were passed to `addPointSet()`. Parameters: **ptSetName** str Name of the point set to return the original coordinates for. ``` -------------------------------- ### Initialize DVGeoESP with ESP Model Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeoESP.html Initializes the DVGeoESP object by loading an ESP model from a specified file. It sets up design variable limits and builds the baseline model, printing the loading time. Handles potential errors during model build. ```python if ulimits is not None: self.ulimits = ulimits else: self.ulimits = np.array([-99999.0, 99999.0]) if vlimits is not None: self.vlimits = vlimits else: self.vlimits = np.array([-99999.0, 99999.0]) self.debug = debug t1 = time.time() # read the model self.espModel = ocsm.Ocsm(self.fileName) ocsm.SetOutLevel(0) # build the baseline model if self.comm.rank == 0: ocsm.SetOutLevel(0) else: ocsm.SetOutLevel(0) self.num_branches_baseline, _, allBodyIndices = self.espModel.Build( 0, 200 ) # pick 200 as arbitrary large number of bodies to allocate if self.num_branches_baseline < 0: raise ValueError("It appears the initial build of the ESP model did not succeed") t2 = time.time() if self.comm.rank == 0: print("Loading the esp model took:", (t2 - t1)) ``` -------------------------------- ### OM_DVGEOCOMP.initialize Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/mphys_dvgeo.html Initializes a geometry component using either a single DVGeo or multiple DVGeos. It supports specifying the DVGeo file, type, and additional options for single DVGeo initialization. For multiple DVGeos, a dictionary of configurations is used, where each entry must have a unique name. The two initialization methods cannot be used concurrently. ```APIDOC ## OM_DVGEOCOMP.initialize() ### Description Set up a geometry component with either 1 DVGeo or multiple DVGeos. A single DVGeo is initialized by specifying its file and type and, optionally, additional options. Available options can be found in the specific DVGeometry class. Multiple DVGeos are initialized in a dictionary of these values and must have a unique name. The format is: ``` DVGeoInfo = { "name1": {"file": file1, "type": type1, "options": options1} "name2": {"file": file2, "type": type2, "options": options2} } ``` The two setup methods cannot currently be used together. ### Method `initialize()` ``` -------------------------------- ### Get Design Variable Names for pyOptSparse Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/DVGeometryMulti.html Retrieves a list of design variable names, useful for specifying the 'wrt' argument in pyOptSparse. ```python optProb.addCon(.....wrt=DVGeo.getVarNames()) ``` -------------------------------- ### DVGeoESP Initialization with Caching Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeoESP.html Initializes the DVGeoESP class, optionally caching point projections to a specified file. This is useful for saving initialization time on subsequent runs. The cache is validated against current run parameters (distribution, number of processors, point counts) to ensure integrity. ```python def __init__(self, points, ptName, distributed, cache_projections=None): """ Parameters ---------- points : array, size (N,3) The coordinates to embed. These coordinates *should* all project into the interior of the ESP model volume. ptName : str A user supplied name to associate with the set of coordinates. This name will need to be provided when updating the coordinates or when getting the derivatives of the coordinates. distributed : bool Whether the pointset is distributed (different each proc) or non-distributed (duplicated and identical each proc). Should be set to false for duplicated pointsets to avoid very poor parallel scaling in the derivatives routine. cache_projections : None or str The user can optionally cache the point set projections to save initialization time. If a filename is provided, the cached ``u, v, t`` coordinates will be saved in numpy compressed format ('.npz' extension should be used). The points will be validated to ensure that the projections remain within tolerance of the model and if not, the projections will be recreated. """ # save this name so that we can zero out the jacobians properly self.ptSetNames.append(ptName) self.points[ptName] = True # ADFlow checks self.points to see if something is added or not points = np.array(points).real.astype("d") # check that duplicated pointsets are actually the same length sizes = np.array(self.comm.allgather(points.shape[0]), dtype="intc") if not distributed: all_same_length = np.all(sizes == sizes[0]) if not all_same_length: raise ValueError( "Nondistributed pointsets must be identical on each proc, but these pointsets vary in length per proc. Lengths: ", str(sizes), ) # check if a cache file exists cache_loaded = False # cache_projections=False will disable caching, but None will generate a cachefile name automatically if cache_projections is None: cache_projections = ptName + ".npz" if cache_projections: if os.path.isfile(cache_projections): cache_loaded = True if self.comm.rank == 0: cached_pt_arrays = np.load(cache_projections) cached_sizes = cached_pt_arrays["sizes"] cached_nprocs = cached_pt_arrays["nprocs"] cached_distrib = cached_pt_arrays["distributed"] bodyIDg = cached_pt_arrays["bodyID"] faceIDg = cached_pt_arrays["faceID"] edgeIDg = cached_pt_arrays["edgeID"] ug = cached_pt_arrays["u"] vg = cached_pt_arrays["v"] tg = cached_pt_arrays["t"] uvlimg = cached_pt_arrays["uvlimits"] tlimg = cached_pt_arrays["tlimits"] cached_dmax = cached_pt_arrays["dmax"] else: cached_dmax = 0.0 cached_sizes = 0.0 cached_nprocs = 0.0 cached_distrib = False cached_dmax = self.comm.bcast(cached_dmax, 0) cached_sizes = self.comm.bcast(cached_sizes, 0) cached_nprocs = self.comm.bcast(cached_nprocs, 0) cached_distrib = self.comm.bcast(cached_distrib, 0) # find easy cache invalidations: if distributed: if not cached_distrib: raise ValueError( "Cached pointset file ", cache_projections, " is invalid because the cache was saved for a nondistributed pointset", ) if cached_nprocs != self.comm.size: raise ValueError( "Cached pointset file ", cache_projections, " is invalid because the cache was saved with different num procs", ) if not np.all(cached_sizes == sizes): raise ValueError( "Cached pointset file ", cache_projections, " is invalid because point counts have changed on some proc", ) else: if cached_distrib: raise ValueError( "Cached pointset file ", cache_projections, " is invalid because the cache was saved for a distributed pointset", ) # now figure out which proc has how many points. ``` -------------------------------- ### Get DV Offsets Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeo.html Placeholder method intended to return the global and local DV offsets for this FFD object. The implementation is not provided in the source. ```python def _getDVOffsets(self): """ Return the global and local DV offsets for this FFD """ ``` -------------------------------- ### Print Initialization Time Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeoESP.html Prints the total time taken to initialize DVGeometryESP, including loading the model and extracting design parameters, to the console if running on the main rank. ```python if comm.rank == 0: t3 = time.time() print("Initialized DVGeometryESP in", (t3 - t0), "seconds.") ``` -------------------------------- ### Initialize DVConstraints Object Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/constraints/DVCon.html Creates an empty DVConstraints object. Specific constraint types are added individually later. ```python dvCon = DVConstraints(name="DVCon1") ``` -------------------------------- ### Get Design Variable Bounds in DVGeoMulti Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/_modules/pygeo/parameterization/DVGeoMulti.html Collects and returns the lower and upper bounds for all design variables across all component DVGeo objects. ```python def getDVBounds(self): """ Return the bounds on the design variables. Returns ------- lowerBounds : dict Dictionary of design variable lower bounds upperBounds : dict Dictionary of design variable upper bounds """ lowerBounds = {} upperBounds = {} # we need to loop over each DVGeo object and get the DVs for comp in self.compNames: lowerBoundsComp, upperBoundsComp = self.comps[comp].DVGeo.getDVBounds() lowerBounds.update(lowerBoundsComp) upperBounds.update(upperBoundsComp) return lowerBounds, upperBounds ``` -------------------------------- ### Get current design variables Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/DVGeometryMulti.html Retrieves the current values of all design variables. The variables are returned in a dictionary format suitable for the setDesignVars() method. ```python getDesignVars() ``` -------------------------------- ### Get dictionary of component DVGeo objects Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/DVGeometryMulti.html Returns a dictionary containing DVGeo objects for each component. This can be useful for accessing component-specific geometric data. ```python getDVGeoDict() ``` -------------------------------- ### Initialize DVGeometryMulti Source: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/DVGeometryMulti.html Instantiate the DVGeometryMulti class. Optional parameters control communication, design variable checking, debugging output, and the use of complex variables. ```python DVGeometryMulti(_comm=mpi4py.MPI.COMM_WORLD_, _checkDVs=True_, _debug=False_, _isComplex=False_) ```