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; } } } }
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("EIPrimaryUnknownMapper :: evaluateAt - 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("EIPrimaryUnknownMapper :: evaluateAt - Couldn't find any element containing point."); return false; } #endif interface = static_cast< EIPrimaryUnknownMapperInterface * >( oelem->giveInterface(EIPrimaryUnknownMapperInterfaceType) ); if ( interface ) { interface->EIPrimaryUnknownMI_givePrimaryUnknownVectorDofID(dofMask); #if 1 interface->EIPrimaryUnknownMI_computePrimaryUnknownVectorAt(mode, tStep, coords, answer); #else interface->EIPrimaryUnknownMI_computePrimaryUnknownVectorAtLocal(mode, tStep, lcoords, answer); #endif } else { OOFEM_ERROR("EIPrimaryUnknownMapper :: evaluateAt - Element does not support EIPrimaryUnknownMapperInterface"); } return true; }