v0.16.0
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
MoFEM::FieldEvaluatorInterface Struct Reference

Field evaluator interface. More...

#include "src/interfaces/FieldEvaluator.hpp"

Inheritance diagram for MoFEM::FieldEvaluatorInterface:
[legend]
Collaboration diagram for MoFEM::FieldEvaluatorInterface:
[legend]

Classes

struct  SetIntegrationPtsMethod
 
struct  SetIntegrationPtsMethodData
 

Public Types

using SetPtsData = SetIntegrationPtsMethodData
 
using MatDataPts = std::vector< std::pair< boost::shared_ptr< MatrixDouble >, boost::shared_ptr< MatrixDouble > > >
 

Public Member Functions

MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const
 
 FieldEvaluatorInterface (const MoFEM::Core &core)
 
template<typename VE , typename SPD = SetIntegrationPtsMethodData, typename SP = SetIntegrationPtsMethod>
boost::shared_ptr< SPD > getData (const double *ptr=nullptr, const int nb_eval_points=0, const double eps=1e-12, VERBOSITY_LEVELS verb=QUIET)
 Get the Data object.
 
template<int D>
MoFEMErrorCode buildTree (boost::shared_ptr< SetIntegrationPtsMethodData > spd_ptr, const std::string finite_element)
 Build spatial tree.
 
template<int D>
MoFEMErrorCode buildTree (boost::shared_ptr< SetIntegrationPtsMethodData > spd_ptr, const std::string finite_element, BitRefLevel bit, BitRefLevel mask)
 Build spatial tree.
 
template<int D>
MoFEMErrorCode evalFEAtThePoint (const double *const point, const double distance, const std::string problem, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, boost::shared_ptr< CacheTuple > cache_ptr, MoFEMTypes bh=MF_EXIST, VERBOSITY_LEVELS verb=QUIET)
 Evaluate field at arbitrary position.
 
template<int D>
ForcesAndSourcesCore::UserDataOperatorgetDataOperator (MatDataPts mat_data_pts, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, BitRefLevel bit, BitRefLevel mask, MoFEMTypes bh=MF_EXIST, VERBOSITY_LEVELS verb=QUIET, DataLayout data_layout=DataLayout::GaussByCoeffs)
 Evaluate field values at integration points of finite elements to which operator is pushed.
 
template<int D>
MoFEMErrorCode evalFEAtThePoint (const double *const point, const double distance, const std::string problem, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, BitRefLevel bit, BitRefLevel mask, boost::shared_ptr< CacheTuple > cache_ptr, MoFEMTypes bh=MF_EXIST, VERBOSITY_LEVELS verb=QUIET)
 Evaluate field at arbitrary position.
 
template<>
MoFEMErrorCode buildTree (boost::shared_ptr< SetIntegrationPtsMethodData > spd_ptr, const std::string finite_element, BitRefLevel bit, BitRefLevel mask)
 
template<>
MoFEMErrorCode buildTree (boost::shared_ptr< SetIntegrationPtsMethodData > spd_ptr, const std::string finite_element, BitRefLevel bit, BitRefLevel mask)
 
template<>
MoFEMErrorCode evalFEAtThePoint (const double *const point, const double distance, const std::string problem, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, BitRefLevel bit, BitRefLevel mask, boost::shared_ptr< CacheTuple > cache_ptr, MoFEMTypes bh, VERBOSITY_LEVELS verb)
 
template<>
MoFEMErrorCode evalFEAtThePoint (const double *const point, const double distance, const std::string problem, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, BitRefLevel bit, BitRefLevel mask, boost::shared_ptr< CacheTuple > cache_ptr, MoFEMTypes bh, VERBOSITY_LEVELS verb)
 
template<>
ForcesAndSourcesCore::UserDataOperatorgetDataOperator (FieldEvaluatorInterface::MatDataPts mat_data_pts, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, BitRefLevel bit, BitRefLevel mask, MoFEMTypes bh, VERBOSITY_LEVELS verb, DataLayout data_layout)
 
template<>
ForcesAndSourcesCore::UserDataOperatorgetDataOperator (FieldEvaluatorInterface::MatDataPts mat_data_pts, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, BitRefLevel bit, BitRefLevel mask, MoFEMTypes bh, VERBOSITY_LEVELS verb, DataLayout data_layout)
 
template<>
MoFEMErrorCode buildTree (boost::shared_ptr< SetIntegrationPtsMethodData > spd_ptr, const std::string finite_element, BitRefLevel bit, BitRefLevel mask)
 
template<>
MoFEMErrorCode buildTree (boost::shared_ptr< SetIntegrationPtsMethodData > spd_ptr, const std::string finite_element, BitRefLevel bit, BitRefLevel mask)
 
template<>
MoFEMErrorCode evalFEAtThePoint (const double *const point, const double distance, const std::string problem, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, BitRefLevel bit, BitRefLevel mask, boost::shared_ptr< CacheTuple > cache_ptr, MoFEMTypes bh, VERBOSITY_LEVELS verb)
 
template<>
MoFEMErrorCode evalFEAtThePoint (const double *const point, const double distance, const std::string problem, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, BitRefLevel bit, BitRefLevel mask, boost::shared_ptr< CacheTuple > cache_ptr, MoFEMTypes bh, VERBOSITY_LEVELS verb)
 
template<>
ForcesAndSourcesCore::UserDataOperatorgetDataOperator (FieldEvaluatorInterface::MatDataPts mat_data_pts, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, BitRefLevel bit, BitRefLevel mask, MoFEMTypes bh, VERBOSITY_LEVELS verb, DataLayout data_layout)
 
template<>
ForcesAndSourcesCore::UserDataOperatorgetDataOperator (FieldEvaluatorInterface::MatDataPts mat_data_pts, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, BitRefLevel bit, BitRefLevel mask, MoFEMTypes bh, VERBOSITY_LEVELS verb, DataLayout data_layout)
 
- Public Member Functions inherited from MoFEM::UnknownInterface
template<class IFACE >
MoFEMErrorCode registerInterface (bool error_if_registration_failed=true)
 Register interface.
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE *&iface) const
 Get interface reference to pointer of interface.
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE **const iface) const
 Get interface pointer to pointer of interface.
 
template<class IFACE , typename boost::enable_if< boost::is_pointer< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get interface pointer to pointer of interface.
 
template<class IFACE , typename boost::enable_if< boost::is_reference< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get reference to interface.
 
template<class IFACE >
IFACE * getInterface () const
 Function returning pointer to interface.
 
virtual ~UnknownInterface ()=default
 

Private Member Functions

template<int D>
MoFEMErrorCode buildTreeImpl (boost::shared_ptr< SetIntegrationPtsMethodData > spd_ptr, const std::string finite_element, BitRefLevel bit, BitRefLevel mask)
 
template<int D>
MoFEMErrorCode evalFEAtThePointImpl (const double *const point, const double distance, const std::string problem, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, BitRefLevel bit, BitRefLevel mask, boost::shared_ptr< CacheTuple > cache_ptr, MoFEMTypes bh=MF_EXIST, VERBOSITY_LEVELS verb=QUIET)
 
template<int D>
ForcesAndSourcesCore::UserDataOperatorgetDataOperatorImpl (MatDataPts mat_data_pts, const std::string finite_element, boost::shared_ptr< SetIntegrationPtsMethodData > data_ptr, int lower_rank, int upper_rank, BitRefLevel bit, BitRefLevel mask, MoFEMTypes bh=MF_EXIST, VERBOSITY_LEVELS verb=QUIET, DataLayout data_layout=DataLayout::GaussByCoeffs)
 

Private Attributes

MoFEM::CorecOre
 

Additional Inherited Members

- Static Public Member Functions inherited from MoFEM::UnknownInterface
static MoFEMErrorCode getLibVersion (Version &version)
 Get library version.
 
static MoFEMErrorCode getFileVersion (moab::Interface &moab, Version &version)
 Get database major version.
 
static MoFEMErrorCode setFileVersion (moab::Interface &moab, Version version=Version(MoFEM_VERSION_MAJOR, MoFEM_VERSION_MINOR, MoFEM_VERSION_BUILD))
 Get database major version.
 
static MoFEMErrorCode getInterfaceVersion (Version &version)
 Get database major version.
 

Detailed Description

Field evaluator interface.

Examples
mofem/atom_tests/field_evaluator.cpp, mofem/tutorials/adv-0_plasticity/plastic.cpp, mofem/tutorials/adv-4_dynamic_first_order_con_law/dynamic_first_order_con_law.cpp, mofem/tutorials/adv-5_poroelasticity/seepage.cpp, mofem/tutorials/adv-6_dg_projection/between_meshes_dg_projection.cpp, mofem/tutorials/max-1_lorentz_force//lorentz_force.cpp, mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp, mofem/users_modules/basic_finite_elements/elasticity/elasticity.cpp, plastic.cpp, thermo_elastic.cpp, and thermoplastic.cpp.

Definition at line 21 of file FieldEvaluator.hpp.

Member Typedef Documentation

◆ MatDataPts

using MoFEM::FieldEvaluatorInterface::MatDataPts = std::vector< std::pair<boost::shared_ptr<MatrixDouble>, boost::shared_ptr<MatrixDouble> > >

Definition at line 145 of file FieldEvaluator.hpp.

◆ SetPtsData

Definition at line 24 of file FieldEvaluator.hpp.

Constructor & Destructor Documentation

◆ FieldEvaluatorInterface()

MoFEM::FieldEvaluatorInterface::FieldEvaluatorInterface ( const MoFEM::Core core)

Definition at line 8 of file FieldEvaluator.cpp.

9 : cOre(const_cast<MoFEM::Core &>(core)) {
10
11 if (!LogManager::checkIfChannelExist("FieldEvaluatorWorld")) {
12 auto core_log = logging::core::get();
13
15 "FieldEvaluatorWorld"));
17 "FieldEvaluatorSync"));
19 "FieldEvaluatorSelf"));
20
21 LogManager::setLog("FieldEvaluatorWorld");
22 LogManager::setLog("FieldEvaluatorSync");
23 LogManager::setLog("FieldEvaluatorSelf");
24
25 MOFEM_LOG_TAG("FieldEvaluatorWorld", "FieldEvaluator");
26 MOFEM_LOG_TAG("FieldEvaluatorSync", "FieldEvaluator");
27 MOFEM_LOG_TAG("FieldEvaluatorSelf", "FieldEvaluator");
28 }
29
30 MOFEM_LOG("FieldEvaluatorWorld", Sev::noisy) << "Field evaluator intreface";
31}
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Core (interface) class.
Definition Core.hpp:83
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
static bool checkIfChannelExist(const std::string channel)
Check if channel exist.
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.

Member Function Documentation

◆ buildTree() [1/6]

template<int D>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::buildTree ( boost::shared_ptr< SetIntegrationPtsMethodData spd_ptr,
const std::string  finite_element 
)
inline

Build spatial tree.

Parameters
finite_elementfinite element name
Returns
MoFEMErrorCode
Examples
mofem/atom_tests/field_evaluator.cpp, and mofem/tutorials/max-1_lorentz_force//lorentz_force.cpp.

Definition at line 70 of file FieldEvaluator.hpp.

71 {
72 return buildTree<D>(spd_ptr, finite_element, BitRefLevel(), BitRefLevel());
73 }
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40

◆ buildTree() [2/6]

template<int D>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::buildTree ( boost::shared_ptr< SetIntegrationPtsMethodData spd_ptr,
const std::string  finite_element,
BitRefLevel  bit,
BitRefLevel  mask 
)

Build spatial tree.

Parameters
finite_elementfinite element name
bitbit reference level
maskmask reference level
Returns
MoFEMErrorCode

◆ buildTree() [3/6]

template<>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::buildTree ( boost::shared_ptr< SetIntegrationPtsMethodData spd_ptr,
const std::string  finite_element,
BitRefLevel  bit,
BitRefLevel  mask 
)

◆ buildTree() [4/6]

template<>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::buildTree ( boost::shared_ptr< SetIntegrationPtsMethodData spd_ptr,
const std::string  finite_element,
BitRefLevel  bit,
BitRefLevel  mask 
)

◆ buildTree() [5/6]

template<>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::buildTree ( boost::shared_ptr< SetIntegrationPtsMethodData spd_ptr,
const std::string  finite_element,
BitRefLevel  bit,
BitRefLevel  mask 
)

Definition at line 65 of file FieldEvaluator.cpp.

67 {
68 return buildTreeImpl<2>(spd_ptr, finite_element, bit, mask);
69}
auto bit
set bit

◆ buildTree() [6/6]

template<>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::buildTree ( boost::shared_ptr< SetIntegrationPtsMethodData spd_ptr,
const std::string  finite_element,
BitRefLevel  bit,
BitRefLevel  mask 
)

Definition at line 72 of file FieldEvaluator.cpp.

74 {
75 return buildTreeImpl<3>(spd_ptr, finite_element, bit, mask);
76}

◆ buildTreeImpl()

template<int D>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::buildTreeImpl ( boost::shared_ptr< SetIntegrationPtsMethodData spd_ptr,
const std::string  finite_element,
BitRefLevel  bit,
BitRefLevel  mask 
)
private

Definition at line 41 of file FieldEvaluator.cpp.

43 {
44 CoreInterface &m_field = cOre;
46 EntityHandle fe_meshset;
47 fe_meshset = m_field.get_finite_element_meshset(finite_element);
48 Range entities;
49 CHKERR m_field.get_moab().get_entities_by_dimension(fe_meshset, D, entities,
50 true);
51 if (bit.any()) {
52 CHKERR m_field.getInterface<BitRefManager>()->filterEntitiesByRefLevel(
53 bit, mask, entities);
54 }
55 if (spd_ptr->treePtr) {
56 spd_ptr->treePtr->reset_tree();
57 } else {
58 spd_ptr->treePtr = boost::make_shared<AdaptiveKDTree>(&m_field.get_moab());
59 }
60 CHKERR spd_ptr->treePtr->build_tree(entities, &spd_ptr->rooTreeSet);
62}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
double D

◆ evalFEAtThePoint() [1/6]

template<>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtThePoint ( const double *const  point,
const double  distance,
const std::string  problem,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
BitRefLevel  bit,
BitRefLevel  mask,
boost::shared_ptr< CacheTuple cache_ptr,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb 
)

◆ evalFEAtThePoint() [2/6]

template<>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtThePoint ( const double *const  point,
const double  distance,
const std::string  problem,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
BitRefLevel  bit,
BitRefLevel  mask,
boost::shared_ptr< CacheTuple cache_ptr,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb 
)

◆ evalFEAtThePoint() [3/6]

template<>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtThePoint ( const double *const  point,
const double  distance,
const std::string  problem,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
BitRefLevel  bit,
BitRefLevel  mask,
boost::shared_ptr< CacheTuple cache_ptr,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb 
)

Definition at line 398 of file FieldEvaluator.cpp.

404 {
405 return evalFEAtThePointImpl<2>(point, distance, problem, finite_element,
406 data_ptr, lower_rank, upper_rank, bit, mask,
407 cache_ptr, bh, verb);
408}

◆ evalFEAtThePoint() [4/6]

template<>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtThePoint ( const double *const  point,
const double  distance,
const std::string  problem,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
BitRefLevel  bit,
BitRefLevel  mask,
boost::shared_ptr< CacheTuple cache_ptr,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb 
)

Definition at line 411 of file FieldEvaluator.cpp.

417 {
418 return evalFEAtThePointImpl<3>(point, distance, problem, finite_element,
419 data_ptr, lower_rank, upper_rank, bit, mask,
420 cache_ptr, bh, verb);
421}

◆ evalFEAtThePoint() [5/6]

template<int D>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtThePoint ( const double *const  point,
const double  distance,
const std::string  problem,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
BitRefLevel  bit,
BitRefLevel  mask,
boost::shared_ptr< CacheTuple cache_ptr,
MoFEMTypes  bh = MF_EXIST,
VERBOSITY_LEVELS  verb = QUIET 
)

Evaluate field at arbitrary position.

Parameters
pointpoint used to find tetrahedrons
distancedistance from the point where tetrahedrons are searched
problemproblem name
finite_elementfinite element name
data_ptrpointer to data abut gauss points
lower_ranklower processor
upper_rankupper process
bitbit reference level
maskmask reference level
cache_ptrcache or problem entities
bhcontrol looping over entities, e.g. throwing error if element not found
verbverbosity level
Returns
MoFEMErrorCode

◆ evalFEAtThePoint() [6/6]

template<int D>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtThePoint ( const double *const  point,
const double  distance,
const std::string  problem,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
boost::shared_ptr< CacheTuple cache_ptr,
MoFEMTypes  bh = MF_EXIST,
VERBOSITY_LEVELS  verb = QUIET 
)
inline

Evaluate field at arbitrary position.

std::array<double, 3> point = {0, 0, 0};
const double dist = 0.3;
std::array<double, 6> eval_points = {-1., -1., -1., 1., 1., 1. };
using VolEle = VolumeElementForcesAndSourcesCore;
auto data_ptr =
m_field.getInterface<FieldEvaluatorInterface>()->
getData<VolEle>(point.data(), point.size/3);
if(auto vol_ele = data_ptr->feMethod.lock()) {
// push operators to finite element instance, e.g.
vol_ele->getOpPtrVector().push_back(new MyOp());
// iterate over elemnts with evaluated points
auto cache_ptr = boost::make_shared<CacheTuple>();
CHKERR m_field.cache_problem_entities(prb_ptr->getName(), cache_ptr);
// SPACE_DIM is 3 in this example
CHKERR m_field.getInterface<FieldEvaluatorInterface>()
->evalFEAtThePoint<3>(point.data(), dist, prb_ptr->getName(),
"FINITE_ELEMENT_NAME",
data_ptr, m_field.get_comm_rank(),
m_field.get_comm_rank(), cache_ptr);
}
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Operator used to check consistency between local coordinates and global cooridnates for integrated po...
Parameters
pointpoint used to find tetrahedrons
distancedistance from the point where tetrahedrons are searched
problemproblem name
finite_elementfinite element name
data_ptrpointer to data abut gauss points
lower_ranklower processor
upper_rankupper process
cache_ptrcache or problem entities
bhcontrol looping over entities, e.g. throwing error if element not found
verbverbosity level
Returns
MoFEMErrorCode
Examples
mofem/atom_tests/field_evaluator.cpp, and mofem/tutorials/max-1_lorentz_force//lorentz_force.cpp.

Definition at line 134 of file FieldEvaluator.hpp.

139 {
140 return evalFEAtThePoint<D>(point, distance, problem, finite_element,
141 data_ptr, lower_rank, upper_rank, BitRefLevel(),
142 BitRefLevel(), cache_ptr, bh, verb);
143 }

◆ evalFEAtThePointImpl()

template<int D>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtThePointImpl ( const double *const  point,
const double  distance,
const std::string  problem,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
BitRefLevel  bit,
BitRefLevel  mask,
boost::shared_ptr< CacheTuple cache_ptr,
MoFEMTypes  bh = MF_EXIST,
VERBOSITY_LEVELS  verb = QUIET 
)
private

Definition at line 174 of file FieldEvaluator.cpp.

180 {
181 CoreInterface &m_field = cOre;
183
184 std::vector<EntityHandle> leafs_out;
185 CHKERR data_ptr->treePtr->distance_search(point, distance, leafs_out);
186 Range tree_ents;
187 for (auto lit : leafs_out) //{
188 CHKERR m_field.get_moab().get_entities_by_dimension(lit, D, tree_ents,
189 true);
190
191 if (verb >= NOISY)
192 MOFEM_LOG("SELF", Sev::noisy) << "tree entities: " << tree_ents;
193
194 data_ptr->evalPointEntityHandle.resize(data_ptr->nbEvalPoints);
195 std::fill(data_ptr->evalPointEntityHandle.begin(),
196 data_ptr->evalPointEntityHandle.end(), 0);
197
198 std::vector<double> local_coords;
199 std::vector<double> shape;
200
201 auto nb_eval_points = data_ptr->nbEvalPoints;
202
203 for (auto tet : tree_ents) {
204 if ((type_from_handle(tet) != moab::MBTRI) &&
205 (type_from_handle(tet) != moab::MBTET)) {
206 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
207 "Wrong element type, Field Evaluator not implemented for Quads "
208 "and Hexes");
209 }
210 const EntityHandle *conn;
211 int num_nodes;
212 CHKERR m_field.get_moab().get_connectivity(tet, conn, num_nodes, true);
213
214 if constexpr (D == 3) {
215
216 local_coords.resize(3 * nb_eval_points);
217 shape.resize(4 * nb_eval_points);
218
219 std::array<double, 12> coords;
220 CHKERR m_field.get_moab().get_coords(conn, num_nodes, coords.data());
221
223 coords.data(), &data_ptr->evalPoints[0], nb_eval_points,
224 &local_coords[0]);
225 CHKERR Tools::shapeFunMBTET<3>(&shape[0], &local_coords[0],
226 &local_coords[1], &local_coords[2],
227 nb_eval_points);
228
229 FTensor::Index<'i', 4> i4;
231 &shape[0], &shape[1], &shape[2], &shape[3]};
233 &data_ptr->shapeFunctions(0, 0), &data_ptr->shapeFunctions(0, 1),
234 &data_ptr->shapeFunctions(0, 2), &data_ptr->shapeFunctions(0, 3)};
235
236 FTensor::Index<'j', 3> j3;
238 &local_coords[0], &local_coords[1], &local_coords[2]};
240 &(data_ptr->localCoords(0, 0)), &(data_ptr->localCoords(0, 1)),
241 &(data_ptr->localCoords(0, 2))};
242
243 for (int n = 0; n != nb_eval_points; ++n) {
244
245 const double eps = data_ptr->eps;
246 if (t_shape(0) >= 0 - eps && t_shape(0) <= 1 + eps &&
247
248 t_shape(1) >= 0 - eps && t_shape(1) <= 1 + eps &&
249
250 t_shape(2) >= 0 - eps && t_shape(2) <= 1 + eps &&
251
252 t_shape(3) >= 0 - eps && t_shape(3) <= 1 + eps) {
253
254 data_ptr->evalPointEntityHandle[n] = tet;
255 t_shape_data(i4) = t_shape(i4);
256 t_local_data(j3) = t_local(j3);
257 }
258
259 ++t_shape;
260 ++t_shape_data;
261 ++t_local;
262 ++t_local_data;
263 }
264 }
265
266 if constexpr (D == 2) {
267
268 local_coords.resize(2 * nb_eval_points);
269 shape.resize(3 * nb_eval_points);
270
271 std::array<double, 9> coords;
272 CHKERR m_field.get_moab().get_coords(conn, num_nodes, coords.data());
273
275 coords.data(), &data_ptr->evalPoints[0], nb_eval_points,
276 &local_coords[0]);
277 CHKERR Tools::shapeFunMBTRI<2>(&shape[0], &local_coords[0],
278 &local_coords[1], nb_eval_points);
279
280 FTensor::Index<'i', 3> i3;
282 &shape[0], &shape[1], &shape[2]};
284 &data_ptr->shapeFunctions(0, 0), &data_ptr->shapeFunctions(0, 1),
285 &data_ptr->shapeFunctions(0, 2)};
286
287 FTensor::Index<'j', 2> j2;
289 &local_coords[0], &local_coords[1]};
290 data_ptr->localCoords.resize(nb_eval_points, 2);
292 &(data_ptr->localCoords(0, 0)), &(data_ptr->localCoords(0, 1))};
293
294 for (int n = 0; n != nb_eval_points; ++n) {
295
296 const double eps = data_ptr->eps;
297 if (t_shape(0) >= 0 - eps && t_shape(0) <= 1 + eps &&
298
299 t_shape(1) >= 0 - eps && t_shape(1) <= 1 + eps &&
300
301 t_shape(2) >= 0 - eps && t_shape(2) <= 1 + eps) {
302
303 data_ptr->evalPointEntityHandle[n] = tet;
304 t_shape_data(i3) = t_shape(i3);
305 t_local_data(j2) = t_local(j2);
306 }
307
308 ++t_shape;
309 ++t_shape_data;
310 ++t_local;
311 ++t_local_data;
312 }
313 }
314 }
315
316 const Problem *prb_ptr;
317 CHKERR m_field.get_problem(problem, &prb_ptr);
318 boost::shared_ptr<NumeredEntFiniteElement_multiIndex> numered_fes(
320
321 Range in_tets;
322 in_tets.insert_list(data_ptr->evalPointEntityHandle.begin(),
323 data_ptr->evalPointEntityHandle.end());
324 in_tets = in_tets.subset_by_dimension(D);
325
326 if (verb >= NOISY)
327 MOFEM_LOG("SELF", Sev::noisy) << "in tets: " << in_tets << endl;
328
329 auto fe_miit =
330 m_field.get_finite_elements()->get<FiniteElement_name_mi_tag>().find(
331 finite_element);
332 if (fe_miit !=
333 m_field.get_finite_elements()->get<FiniteElement_name_mi_tag>().end()) {
334
335 for (auto peit = in_tets.pair_begin(); peit != in_tets.pair_end(); ++peit) {
336
337 auto lo =
338 prb_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>().lower_bound(
340 peit->first, (*fe_miit)->getFEUId()));
341 auto hi =
342 prb_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>().upper_bound(
344 peit->second, (*fe_miit)->getFEUId()));
345
346 if (bit.any()) {
347 if (verb >= VERY_NOISY)
348 MOFEM_LOG("FieldEvaluatorSelf", Sev::noisy);
349 for (auto it = lo; it != hi; ++it) {
350 auto fe_bit = (*it)->getBitRefLevel();
351 if ((fe_bit & mask) != fe_bit)
352 continue;
353 if ((fe_bit & bit).none())
354 continue;
355 numered_fes->insert(*it);
356 if (verb >= VERY_NOISY)
357 MOFEM_LOG("FieldEvaluatorSelf", Sev::noisy) << **it << endl;
358 }
359 } else {
360 numered_fes->insert(lo, hi);
361 if (verb >= VERY_NOISY) {
362 MOFEM_LOG("FieldEvaluatorSelf", Sev::noisy)
363 << "numbered elements:" << std::endl;
364 for (; lo != hi; ++lo)
365 MOFEM_LOG("FieldEvaluatorSelf", Sev::noisy) << **lo << endl;
366 }
367 }
368 }
369
370 if (auto fe_ptr = data_ptr->feMethodPtr) {
371
372 MOFEM_LOG_C("FieldEvaluatorSelf", Sev::noisy,
373 "Number elements %zu to evaluate at proc %d",
374 numered_fes->size(), m_field.get_comm_rank());
375
376 if (!cache_ptr) {
377 cache_ptr = boost::make_shared<CacheTuple>();
378 CHKERR m_field.cache_problem_entities(prb_ptr->getName(), cache_ptr);
379
380 MOFEM_LOG("FieldEvaluatorSelf", Sev::noisy)
381 << "If you call that function many times in the loop consider to "
382 "set cache_ptr outside of the loop. Otherwise code can be slow.";
383 }
384
385 CHKERR m_field.loop_finite_elements(prb_ptr, finite_element, *fe_ptr,
386 lower_rank, upper_rank, numered_fes,
387 bh, cache_ptr, verb);
388
389 } else
390 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
391 "Pointer to element does not exists");
392 }
393
395}
#define MOFEM_LOG_C(channel, severity, format,...)
static const double eps
@ NOISY
@ VERY_NOISY
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32
multi_index_container< boost::shared_ptr< NumeredEntFiniteElement >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< NumeredEntFiniteElement::interface_type_EntFiniteElement, UId, &NumeredEntFiniteElement::getLocalUniqueId > >, ordered_non_unique< tag< Part_mi_tag >, member< NumeredEntFiniteElement, unsigned int, &NumeredEntFiniteElement::part > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< NumeredEntFiniteElement::interface_type_RefEntity, EntityHandle, &NumeredEntFiniteElement::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Part_mi_tag >, composite_key< NumeredEntFiniteElement, const_mem_fun< NumeredEntFiniteElement::interface_type_FiniteElement, boost::string_ref, &NumeredEntFiniteElement::getNameRef >, member< NumeredEntFiniteElement, unsigned int, &NumeredEntFiniteElement::part > > > > > NumeredEntFiniteElement_multiIndex
MultiIndex for entities for NumeredEntFiniteElement.
const double n
refractive index of diffusive medium
auto type_from_handle(const EntityHandle h)
get type from entity handle
UId getLocalUniqueIdCalculate() const
Generate UId for finite element entity.
static MoFEMErrorCode getLocalCoordinatesOnReferenceFourNodeTet(const double *elem_coords, const double *glob_coords, const int nb_nodes, double *local_coords)
Get the local coordinates on reference four node tet object.
Definition Tools.cpp:88
static MoFEMErrorCode getLocalCoordinatesOnReferenceThreeNodeTri(const double *elem_coords, const double *glob_coords, const int nb_nodes, double *local_coords)
Get the local coordinates on reference three node tri object.
Definition Tools.cpp:188

◆ getData()

template<typename VE , typename SPD , typename SP >
boost::shared_ptr< SPD > MoFEM::FieldEvaluatorInterface::getData ( const double ptr = nullptr,
const int  nb_eval_points = 0,
const double  eps = 1e-12,
VERBOSITY_LEVELS  verb = QUIET 
)

Get the Data object.

Pack pointers with data structures for field evaluator and finite element. Function return shared pointer if returned shared pointer is reset; all data are destroyed. The idea is to pack all data in one structure, create shared pointer to it and return aliased shared pointer to one of the elements of the data structure. It is a bit complicated, but has great flexibility.

Template Parameters
VE
SetIntegrationPtsMethodData
SetIntegrationPtsMethod
Parameters
ptr
nb_eval_points
eps
verb
Returns
boost::shared_ptr<SPD>
Examples
mofem/atom_tests/field_evaluator.cpp, mofem/tutorials/adv-6_dg_projection/between_meshes_dg_projection.cpp, and mofem/tutorials/max-1_lorentz_force//lorentz_force.cpp.

Definition at line 334 of file FieldEvaluator.hpp.

335 {
336 MoFEM::Interface &m_field = cOre;
337 auto ve_method_ptr = boost::make_shared<VE>(m_field);
338 auto spd_ptr =
339 boost::make_shared<SPD>(ve_method_ptr, ptr, nb_eval_points, eps, verb);
340 ve_method_ptr->setRuleHook = SP(spd_ptr);
341 return spd_ptr;
342}
Deprecated interface functions.

◆ getDataOperator() [1/5]

template<>
ForcesAndSourcesCore::UserDataOperator * MoFEM::FieldEvaluatorInterface::getDataOperator ( FieldEvaluatorInterface::MatDataPts  mat_data_pts,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
BitRefLevel  bit,
BitRefLevel  mask,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb,
DataLayout  data_layout 
)

◆ getDataOperator() [2/5]

template<>
ForcesAndSourcesCore::UserDataOperator * MoFEM::FieldEvaluatorInterface::getDataOperator ( FieldEvaluatorInterface::MatDataPts  mat_data_pts,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
BitRefLevel  bit,
BitRefLevel  mask,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb,
DataLayout  data_layout 
)

◆ getDataOperator() [3/5]

template<>
ForcesAndSourcesCore::UserDataOperator * MoFEM::FieldEvaluatorInterface::getDataOperator ( FieldEvaluatorInterface::MatDataPts  mat_data_pts,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
BitRefLevel  bit,
BitRefLevel  mask,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb,
DataLayout  data_layout 
)

Definition at line 583 of file FieldEvaluator.cpp.

589 {
590 return getDataOperatorImpl<2>(mat_data_pts, finite_element,
591 data_ptr, lower_rank, upper_rank, bit, mask,
592 bh, verb, data_layout);
593}

◆ getDataOperator() [4/5]

template<>
ForcesAndSourcesCore::UserDataOperator * MoFEM::FieldEvaluatorInterface::getDataOperator ( FieldEvaluatorInterface::MatDataPts  mat_data_pts,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
BitRefLevel  bit,
BitRefLevel  mask,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb,
DataLayout  data_layout 
)

Definition at line 596 of file FieldEvaluator.cpp.

602 {
603 return getDataOperatorImpl<3>(mat_data_pts, finite_element,
604 data_ptr, lower_rank, upper_rank, bit, mask,
605 bh, verb, data_layout);
606}

◆ getDataOperator() [5/5]

template<int D>
ForcesAndSourcesCore::UserDataOperator * MoFEM::FieldEvaluatorInterface::getDataOperator ( MatDataPts  mat_data_pts,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
BitRefLevel  bit,
BitRefLevel  mask,
MoFEMTypes  bh = MF_EXIST,
VERBOSITY_LEVELS  verb = QUIET,
DataLayout  data_layout = DataLayout::GaussByCoeffs 
)

Evaluate field values at integration points of finite elements to which operator is pushed.

Parameters
mat_data_ptsvector of pairs of pointers to matrices with field values at integration points
finite_elementfinite element name on which field is evaluated
data_ptrdata about field evaluator
lower_ranklower processor
upper_rankupper processor
bitbit reference level
maskmask reference level
bhcontrol looping over entities, e.g. throwing error if element not found
verbverbosity level
data_layoutlayout of evaluated output matrices
Returns
ForcesAndSourcesCore::UserDataOperator*

◆ getDataOperatorImpl()

template<int D>
ForcesAndSourcesCore::UserDataOperator * MoFEM::FieldEvaluatorInterface::getDataOperatorImpl ( FieldEvaluatorInterface::MatDataPts  mat_data_pts,
const std::string  finite_element,
boost::shared_ptr< SetIntegrationPtsMethodData data_ptr,
int  lower_rank,
int  upper_rank,
BitRefLevel  bit,
BitRefLevel  mask,
MoFEMTypes  bh = MF_EXIST,
VERBOSITY_LEVELS  verb = QUIET,
DataLayout  data_layout = DataLayout::GaussByCoeffs 
)
private

Definition at line 425 of file FieldEvaluator.cpp.

430 {
431
432 using BaseOP = ForcesAndSourcesCore::UserDataOperator;
433
434 struct Op : public BaseOP {
435 Op(
436
437 FieldEvaluatorInterface::MatDataPts mat_data_pts,
438 const std::string finite_element,
439 boost::shared_ptr<SetIntegrationPtsMethodData> data_ptr, int lower_rank,
440 int upper_rank, BitRefLevel bit, BitRefLevel mask, double eps,
441 MoFEMTypes bh, VERBOSITY_LEVELS verb, DataLayout data_layout
442
443 )
444 : BaseOP(NOSPACE, BaseOP::OPSPACE),
445 matDataPts(mat_data_pts), finiteElement(finite_element),
446 dataPtr(data_ptr), lowerRank(lower_rank), upperRank(upper_rank),
447 bitRefLevel(bit), maskRefLevel(mask), eps(eps), bhType(bh),
448 verbosity(verb), dataLayout(data_layout) {}
449
450 MoFEMErrorCode doWork(int side, EntityType type,
451 EntitiesFieldData::EntData &data) {
453
454 MOFEM_LOG_CHANNEL("SELF");
455 MOFEM_LOG_TAG("SELF", "FieldEvaluator");
456
457 MoFEM::Interface &m_field = this->getPtrFE()->mField;
458 auto field_eval_ptr = m_field.getInterface<FieldEvaluatorInterface>();
459
460 auto nb_integration_pts = getGaussPts().size2();
461
462 auto prb_name = getPtrFE()->problemPtr->getName();
463 auto cache_ptr = getPtrFE()->getCacheWeakPtr();
464
465 auto coords_at_pts = getCoordsAtGaussPts();
466 for (int gg = 0; gg != nb_integration_pts; ++gg) {
467 double *coords_ptr = &coords_at_pts(gg, 0);
468
469 dataPtr->setEvalPoints(coords_ptr, 1);
470 CHKERR field_eval_ptr->evalFEAtThePoint<D>(
471 coords_ptr, eps, prb_name, finiteElement, dataPtr, lowerRank,
472 upperRank, bitRefLevel, maskRefLevel, cache_ptr.lock(), MF_EXIST,
473 QUIET);
474
475 // Get number of found finite elements, that consist gauss point.
476 // E.g. for edge flip expected is that only one element will be found.
477 auto loop_size = dataPtr->feMethodPtr->getLoopSize();
478 if (loop_size != 1) {
479 if (verbosity >= QUIET) {
481 LogManager::BitLineID | LogManager::BitScope);
482 MOFEM_LOG("SELF", Sev::warning)
483 << "Field evaluator wrong number of elements found: "
484 << loop_size;
485 }
486 }
487
488 for (auto &m : matDataPts) {
489
490 const auto nb_data_rows = m.first->size1();
491 const auto nb_data_cols = m.first->size2();
492
493#ifndef NDEBUG
494 const auto nb_data_gauss_pts =
495 dataLayout == DataLayout::GaussByCoeffs ? nb_data_rows
496 : nb_data_cols;
497 if (nb_data_gauss_pts != loop_size) {
498 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
499 "Inconsistent source data layout for size (%ld, %ld), "
500 "loop size %d, and requested layout %s",
501 nb_data_rows, nb_data_cols, loop_size,
502 dataLayout == DataLayout::GaussByCoeffs ? "GaussByCoeffs"
503 : "CoeffsByGauss");
504 }
505#endif
506
507 const auto nb_data_coeffs =
508 dataLayout == DataLayout::GaussByCoeffs ? nb_data_cols
509 : nb_data_rows;
510
511 if (dataLayout == DataLayout::GaussByCoeffs) {
512 m.second->resize(nb_integration_pts, nb_data_coeffs, false);
513 } else {
514 m.second->resize(nb_data_coeffs, nb_integration_pts, false);
515 }
516 if (gg == 0)
517 m.second->clear();
518 for (auto ll = 0; ll != loop_size; ++ll) {
519 for (int dd = 0; dd != nb_data_coeffs; ++dd) {
520 const auto value = dataLayout == DataLayout::GaussByCoeffs
521 ? (*m.first)(ll, dd)
522 : (*m.first)(dd, ll);
523 if (dataLayout == DataLayout::GaussByCoeffs) {
524 (*m.second)(gg, dd) += value / loop_size;
525 } else {
526 (*m.second)(dd, gg) += value / loop_size;
527 }
528 }
529 }
530 }
531 }
532
533 MOFEM_LOG_CHANNEL("SELF");
534
536 }
537
538 private:
539 FieldEvaluatorInterface::MatDataPts matDataPts;
540 std::string finiteElement;
541 boost::shared_ptr<SetIntegrationPtsMethodData> dataPtr;
542 int lowerRank;
543 int upperRank;
544 BitRefLevel bitRefLevel;
545 BitRefLevel maskRefLevel;
546 double eps;
547 MoFEMTypes bhType;
548 VERBOSITY_LEVELS verbosity;
549 DataLayout dataLayout;
550 };
551
552 double min[3];
553 double max[3];
554 unsigned int dep;
555 CHKERR data_ptr->treePtr->get_info(data_ptr->rooTreeSet, min, max, dep);
556 double dist = std::sqrt(pow(max[0] - min[0], 2) + pow(max[1] - min[1], 2) +
557 pow(max[2] - min[2], 2));
558
559 return new Op(mat_data_pts, finite_element, data_ptr, lower_rank,
560 upper_rank, bit, mask, 1e-6 * dist, bh, verb, data_layout);
561}
std::string type
VERBOSITY_LEVELS
Verbosity levels.
@ QUIET
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
@ MF_EXIST
@ NOSPACE
Definition definitions.h:83
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
#define MOFEM_LOG_ATTRIBUTES(channel, bit)
Add attributes to channel.
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition ddTensor0.hpp:33
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
FTensor::Index< 'm', 3 > m

◆ query_interface()

MoFEMErrorCode MoFEM::FieldEvaluatorInterface::query_interface ( boost::typeindex::type_index  type_index,
UnknownInterface **  iface 
) const
virtual

Implements MoFEM::UnknownInterface.

Definition at line 33 of file FieldEvaluator.cpp.

34 {
36 *iface = const_cast<FieldEvaluatorInterface *>(this);
38}
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
FieldEvaluatorInterface(const MoFEM::Core &core)

Member Data Documentation

◆ cOre

MoFEM::Core& MoFEM::FieldEvaluatorInterface::cOre
private

Definition at line 206 of file FieldEvaluator.hpp.


The documentation for this struct was generated from the following files: