void SolutionbasedShapeFunction :: giveValueAtPoint(FloatArray &answer, const FloatArray &coords, IntArray &dofIDs, EngngModel &myEngngModel) { answer.resize( dofIDs.giveSize() ); FloatArray closest, lcoords, values; Element *elementAtCoords = myEngngModel.giveDomain(1)->giveSpatialLocalizer()->giveElementClosestToPoint(lcoords, closest, coords, 1); if ( elementAtCoords == NULL ) { OOFEM_WARNING("Cannot find element closest to point"); coords.pY(); } EIPrimaryUnknownMapperInterface *em = dynamic_cast< EIPrimaryUnknownMapperInterface * >( elementAtCoords->giveInterface(EIPrimaryUnknownMapperInterfaceType) ); IntArray eldofids; em->EIPrimaryUnknownMI_givePrimaryUnknownVectorDofID(eldofids); em->EIPrimaryUnknownMI_computePrimaryUnknownVectorAtLocal(VM_Total, thisTimestep, lcoords, values); for ( int i = 1; i <= dofIDs.giveSize(); i++ ) { for ( int j = 1; j <= eldofids.giveSize(); j++ ) { if ( dofIDs.at(i) == eldofids.at(j) ) { answer.at(i) = values.at(j); break; } } } }
void POIExportModule :: exportPrimVarAs(UnknownType valID, FILE *stream, TimeStep *tStep) { Domain *d = emodel->giveDomain(1); FloatArray pv, coords(3), lcoords, closest; InternalStateValueType type = ISVT_UNDEFINED; if ( valID == DisplacementVector ) { type = ISVT_VECTOR; } else if ( valID == FluxVector ) { type = ISVT_SCALAR; } else { OOFEM_ERROR("unsupported UnknownType"); } // print header if ( type == ISVT_SCALAR ) { fprintf(stream, "SCALARS prim_scalar_%d\n", ( int ) valID); } else if ( type == ISVT_VECTOR ) { fprintf(stream, "VECTORS vector_%d float\n", ( int ) valID); } else { OOFEM_ERROR("unsupported variable type"); } SpatialLocalizer *sl = d->giveSpatialLocalizer(); // loop over POIs for ( auto &poi: POIList ) { coords.at(1) = poi.x; coords.at(3) = poi.z; //region = poi.region; Element *source = sl->giveElementClosestToPoint(lcoords, closest, coords); if ( source ) { // ask interface EIPrimaryUnknownMapperInterface *interface = static_cast< EIPrimaryUnknownMapperInterface * >( source->giveInterface(EIPrimaryUnknownMapperInterfaceType) ); if ( interface ) { interface->EIPrimaryUnknownMI_computePrimaryUnknownVectorAtLocal(VM_Total, tStep, lcoords, pv); } else { pv.clear(); OOFEM_WARNING("element %d with no EIPrimaryUnknownMapperInterface support", source->giveNumber() ); } fprintf(stream, "%10d ", poi.id); if ( pv.giveSize() ) { for ( int j = 1; j <= pv.giveSize(); j++ ) { fprintf( stream, " %15e ", pv.at(j) ); } } fprintf(stream, "\n"); } else { OOFEM_ERROR("no element containing POI(%e,%e,%e) found", coords.at(1), coords.at(2), coords.at(3) ); } } }
int EIPrimaryUnknownMapper :: evaluateAt(FloatArray &answer, IntArray &dofMask, ValueModeType mode, Domain *oldd, FloatArray &coords, IntArray ®List, TimeStep *tStep) { Element *oelem; EIPrimaryUnknownMapperInterface *interface; SpatialLocalizer *sl = oldd->giveSpatialLocalizer(); FloatArray lcoords, closest; if ( regList.isEmpty() ) { oelem = sl->giveElementClosestToPoint(lcoords, closest, coords, 0); } else { // Take the minimum of any region double mindist = 0.0, distance; oelem = NULL; for ( int i = 1; i < regList.giveSize(); ++i ) { Element *tmpelem = sl->giveElementClosestToPoint( lcoords, closest, coords, regList.at(i) ); distance = closest.distance_square(coords); if ( tmpelem != NULL ) { distance = closest.distance_square(coords); if ( distance < mindist || i == 1 ) { mindist = distance; oelem = tmpelem; if ( distance == 0.0 ) { break; } } } } } if ( !oelem ) { OOFEM_WARNING("Couldn't find any element containing point."); return false; } interface = static_cast< EIPrimaryUnknownMapperInterface * >( oelem->giveInterface(EIPrimaryUnknownMapperInterfaceType) ); if ( interface ) { oelem->giveElementDofIDMask(dofMask); interface->EIPrimaryUnknownMI_computePrimaryUnknownVectorAtLocal(mode, tStep, lcoords, answer); } else { OOFEM_ERROR("Element does not support EIPrimaryUnknownMapperInterface"); } return true; }
int EIPrimaryUnknownMapper :: evaluateAt(FloatArray &answer, IntArray &dofMask, ValueModeType mode, Domain *oldd, FloatArray &coords, IntArray ®List, TimeStep *tStep) { Element *oelem; EIPrimaryUnknownMapperInterface *interface; SpatialLocalizer *sl = oldd->giveSpatialLocalizer(); ///@todo Change to the other version after checking that it works properly. Will render "giveElementCloseToPoint" obsolete (superseeded by giveElementClosestToPoint). #if 1 if ( regList.isEmpty() ) { oelem = sl->giveElementContainingPoint(coords); } else { oelem = sl->giveElementContainingPoint(coords, & regList); } if ( !oelem ) { if ( regList.isEmpty() ) { oelem = oldd->giveSpatialLocalizer()->giveElementCloseToPoint(coords); } else { oelem = oldd->giveSpatialLocalizer()->giveElementCloseToPoint(coords, & regList); } if ( !oelem ) { OOFEM_WARNING("Couldn't find any element containing point."); return false; } } #else FloatArray lcoords, closest; if ( regList.isEmpty() ) { oelem = sl->giveElementClosestToPoint(lcoords, closest, coords, 0); } else { // Take the minimum of any region double mindist = 0.0, distance; oelem = NULL; for ( int i = 1; i < regList.giveSize(); ++i ) { Element *tmpelem = sl->giveElementClosestToPoint( lcoords, closest, coords, regList.at(i) ); distance = closest.distance_square(coords); if ( tmpelem != NULL ) { distance = closest.distance_square(coords); if ( distance < mindist || i == 1 ) { mindist = distance; oelem = tmpelem; if ( distance == 0.0 ) { break; } } } } } if ( !oelem ) { OOFEM_WARNING("Couldn't find any element containing point."); return false; } #endif interface = static_cast< EIPrimaryUnknownMapperInterface * >( oelem->giveInterface(EIPrimaryUnknownMapperInterfaceType) ); if ( interface ) { oelem->giveElementDofIDMask(dofMask); #if 1 FloatArray lcoords; if ( oelem->computeLocalCoordinates(lcoords, coords) ) { interface->EIPrimaryUnknownMI_computePrimaryUnknownVectorAtLocal(mode, tStep, lcoords, answer); } else { answer.clear(); } #else interface->EIPrimaryUnknownMI_computePrimaryUnknownVectorAtLocal(mode, tStep, lcoords, answer); #endif } else { OOFEM_ERROR("Element does not support EIPrimaryUnknownMapperInterface"); } return true; }