double Dt( void* _context ) { FiniteElementContext* context = (FiniteElementContext*) _context; double dt; FeVariable* velocityField = (FeVariable*) LiveComponentRegister_Get( context->CF->LCRegister, (Name)"VelocityField" ); double velMax; double delta[3], minDelta; velMax = FieldVariable_GetMaxGlobalFieldMagnitude( velocityField ); FeVariable_GetMinimumSeparation( velocityField, &minDelta, delta ); dt = 0.5 * minDelta / velMax; return dt; }
Bool _BelowHeightField_IsCoordInside( void* belowHeightField, Coord coord ) { BelowHeightField* self = (BelowHeightField*)belowHeightField; double height; InterpolationResult interpRes; /** first check global max of field before proceeding further */ if( FieldVariable_GetMaxGlobalFieldMagnitude( self->heightField ) < coord[ self->vertAxis ] ) return False; interpRes = FieldVariable_InterpolateValueAt( self->heightField, coord, &height ); if( interpRes == OUTSIDE_GLOBAL ) return False; if ( coord[ self->vertAxis ] < height ) { return True; } return False; }
double SwarmAdvector_MaxDt( void* swarmAdvector ) { SwarmAdvector* self = (SwarmAdvector*) swarmAdvector; double velMax = 0; double minSeparation = 0; double minSeparationEachDim[3] = { 0, 0, 0 }; FeVariable* velFeVar = self->velocityField; double localDt; double globalDt; velMax = FieldVariable_GetMaxGlobalFieldMagnitude( velFeVar ); FeVariable_GetMinimumSeparation( velFeVar, &minSeparation, minSeparationEachDim ); localDt = 0.5 * minSeparation / velMax; (void)MPI_Allreduce( &localDt, &globalDt, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD ); return globalDt; }
void _lucVectorArrowCrossSection_DrawCrossSection( void* drawingObject, lucDatabase* database, Dimension_Index dim ) { lucVectorArrowCrossSection* self = (lucVectorArrowCrossSection*)drawingObject; FieldVariable* vectorVariable = self->fieldVariable; double min = 0.0, max = self->maximum; Index aIndex, bIndex; Journal_Firewall( vectorVariable->fieldComponentCount == vectorVariable->dim, lucError, "Error - in %s(): provided FieldVariable \"%s\" has %u components - but %s Component " "can only visualse FieldVariables with %d components.\n", __func__, vectorVariable->name, vectorVariable->fieldComponentCount, self->type, vectorVariable->dim ); if ( True == self->dynamicRange ) { min = FieldVariable_GetMinGlobalFieldMagnitude( vectorVariable ); max = FieldVariable_GetMaxGlobalFieldMagnitude( vectorVariable ); } /* Force 3d vectors */ lucCrossSection_AllocateSampleData(self, 3); /* Sample the 2d cross-section */ lucCrossSection_SampleField(self, False); /* Write only values that have data on this processor! */ for ( aIndex = 0 ; aIndex < self->resolutionA ; aIndex++ ) { for ( bIndex = 0 ; bIndex < self->resolutionB ; bIndex++ ) { if (self->values[aIndex][bIndex][0] != HUGE_VAL) { lucDatabase_AddVertices(database, 1, lucVectorType, &self->vertices[aIndex][bIndex][0]); lucDatabase_AddVectors(database, 1, lucVectorType, min, max, &self->values[aIndex][bIndex][0]); } } } lucCrossSection_FreeSampleData(self); }
void _lucIsosurface_Setup( void* drawingObject, lucDatabase* database, void* _context ) { lucIsosurface* self = (lucIsosurface*)drawingObject; lucDrawingObject_SyncShadowValues( self, self->isosurfaceField ); lucDrawingObject_SyncShadowValues( self, self->colourField ); lucDrawingObject_SyncShadowValues( self, self->maskField ); FieldVariable_GetMinAndMaxGlobalCoords(self->isosurfaceField, self->globalMin, self->globalMax); self->triangleCount = 0; Journal_Printf( lucInfo, "Sampling %s for %s (global=%d)\n", self->isosurfaceField->name, self->name, self->sampleGlobal); /* Anything to sample? */ double min = FieldVariable_GetMinGlobalFieldMagnitude(self->isosurfaceField); double max = FieldVariable_GetMaxGlobalFieldMagnitude(self->isosurfaceField); if (min == max) return; if (self->sampleGlobal) lucIsosurface_SampleGlobal(drawingObject); else lucIsosurface_SampleLocal(drawingObject); }