def _defineDataProjectionFields(self): self._dataProjectionLocationFields = [] self._dataProjectionCoordinatesFields = [] self._dataProjectionDeltaFields = [] self._dataProjectionErrorFields = [] self._dataProjectionNodeGroupFields = [] self._dataProjectionNodesetGroups = [] with ChangeManager(self._fieldmodule): datapoints = self._fieldmodule.findNodesetByFieldDomainType( Field.DOMAIN_TYPE_DATAPOINTS) for d in range(2): mesh = self._mesh[d] dataProjectionLocation = findOrCreateFieldStoredMeshLocation( self._fieldmodule, mesh, name="data_projection_location_" + mesh.getName(), managed=False) self._dataProjectionLocationFields.append( dataProjectionLocation) dataProjectionCoordinates = self._fieldmodule.createFieldEmbedded( self._modelCoordinatesField, dataProjectionLocation) dataProjectionCoordinates.setName( getUniqueFieldName( self._fieldmodule, "data_projection_coordinates_" + mesh.getName())) self._dataProjectionCoordinatesFields.append( dataProjectionCoordinates) dataProjectionDelta = dataProjectionCoordinates - self._dataCoordinatesField dataProjectionDelta.setName( getUniqueFieldName( self._fieldmodule, "data_projection_delta_" + mesh.getName())) self._dataProjectionDeltaFields.append(dataProjectionDelta) dataProjectionError = self._fieldmodule.createFieldMagnitude( dataProjectionDelta) dataProjectionError.setName( getUniqueFieldName( self._fieldmodule, "data_projection_error_" + mesh.getName())) self._dataProjectionErrorFields.append(dataProjectionError) field = self._fieldmodule.createFieldNodeGroup(datapoints) field.setName( getUniqueFieldName( self._fieldmodule, "data_projection_group_" + mesh.getName())) self._dataProjectionNodeGroupFields.append(field) self._dataProjectionNodesetGroups.append( field.getNodesetGroup()) self._dataProjectionDirectionField = findOrCreateFieldFiniteElement( self._fieldmodule, "data_projection_direction", components_count=3, component_names=["x", "y", "z"])
def _updateMarkerDataLocationCoordinatesField(self): if self._modelCoordinatesField and self._markerDataLocationField: with ChangeManager(self._fieldmodule): markerPrefix = self._markerGroup.getName() self._markerDataLocationCoordinatesField = self._fieldmodule.createFieldEmbedded( self._modelCoordinatesField, self._markerDataLocationField) self._markerDataLocationCoordinatesField.setName( getUniqueFieldName( self._fieldmodule, markerPrefix + "_data_location_coordinates")) self._markerDataDeltaField = self._markerDataLocationCoordinatesField - self._markerDataCoordinatesField self._markerDataDeltaField.setName( getUniqueFieldName(self._fieldmodule, markerPrefix + "_data_delta")) else: self._markerDataLocationCoordinatesField = None
def _calculateMarkerDataLocations(self): """ Called when markerGroup exists. Find matching marker mesh locations for marker data points. Only finds matching location where there is one datapoint and one node for each name in marker group. Defines datapoint group self._markerDataLocationGroup to contain those with locations. """ self._markerDataLocationField = None self._markerDataLocationCoordinatesField = None self._markerDataDeltaField = None self._markerDataLocationGroupField = None self._markerDataLocationGroup = None if not (self._markerDataGroup and self._markerDataNameField and self._markerNodeGroup and self._markerLocationField and self._markerNameField): return markerPrefix = self._markerGroup.getName() # assume marker locations are in highest dimension mesh mesh = self.getHighestDimensionMesh() datapoints = self._fieldmodule.findNodesetByFieldDomainType( Field.DOMAIN_TYPE_DATAPOINTS) meshDimension = mesh.getDimension() fieldcache = self._fieldmodule.createFieldcache() with ChangeManager(self._fieldmodule): self._markerDataLocationField = findOrCreateFieldStoredMeshLocation( self._fieldmodule, mesh, name=markerPrefix + "_data_location_" + mesh.getName(), managed=False) self._markerDataLocationGroupField = self._fieldmodule.createFieldNodeGroup( datapoints) self._markerDataLocationGroupField.setName( getUniqueFieldName(self._fieldmodule, markerPrefix + "_data_location_group")) self._markerDataLocationGroup = self._markerDataLocationGroupField.getNodesetGroup( ) self._updateMarkerDataLocationCoordinatesField() nodetemplate = self._markerDataGroup.createNodetemplate() nodetemplate.defineField(self._markerDataLocationField) datapointIter = self._markerDataGroup.createNodeiterator() datapoint = datapointIter.next() while datapoint.isValid(): fieldcache.setNode(datapoint) name = self._markerDataNameField.evaluateString(fieldcache) # if this is the only datapoint with name: if name and findNodeWithName(self._markerDataGroup, self._markerDataNameField, name, ignore_case=True, strip_whitespace=True): node = findNodeWithName(self._markerNodeGroup, self._markerNameField, name, ignore_case=True, strip_whitespace=True) if node: fieldcache.setNode(node) element, xi = self._markerLocationField.evaluateMeshLocation( fieldcache, meshDimension) if element.isValid(): datapoint.merge(nodetemplate) fieldcache.setNode(datapoint) self._markerDataLocationField.assignMeshLocation( fieldcache, element, xi) self._markerDataLocationGroup.addNode(datapoint) datapoint = datapointIter.next() # Warn about datapoints without a location in model markerDataGroupSize = self._markerDataGroup.getSize() markerDataLocationGroupSize = self._markerDataLocationGroup.getSize() markerNodeGroupSize = self._markerNodeGroup.getSize() if self.getDiagnosticLevel() > 0: if markerDataLocationGroupSize < markerDataGroupSize: print("Warning: Only " + str(markerDataLocationGroupSize) + " of " + str(markerDataGroupSize) + " marker data points have model locations") if markerDataLocationGroupSize < markerNodeGroupSize: print("Warning: Only " + str(markerDataLocationGroupSize) + " of " + str(markerNodeGroupSize) + " marker model locations used")