v0.16.3
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 > > >
 
using PointGroupCallback = boost::function< MoFEMErrorCode(const std::vector< size_t > &)>
 

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::UserDataOperator * 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.
 
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<int D>
MoFEMErrorCode evalFEAtPoints (const std::vector< std::array< double, 3 > > &points, 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, const PointGroupCallback &on_element, MoFEMTypes bh=MF_EXIST, VERBOSITY_LEVELS verb=QUIET)
 
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<>
MoFEMErrorCode evalFEAtPoints (const std::vector< std::array< double, 3 > > &points, 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, const PointGroupCallback &on_element, MoFEMTypes bh, VERBOSITY_LEVELS verb)
 
template<>
MoFEMErrorCode evalFEAtPoints (const std::vector< std::array< double, 3 > > &points, 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, const PointGroupCallback &on_element, MoFEMTypes bh, VERBOSITY_LEVELS verb)
 
template<>
ForcesAndSourcesCore::UserDataOperator * 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)
 
template<>
ForcesAndSourcesCore::UserDataOperator * 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)
 
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<>
MoFEMErrorCode evalFEAtPoints (const std::vector< std::array< double, 3 > > &points, 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, const PointGroupCallback &on_element, MoFEMTypes bh, VERBOSITY_LEVELS verb)
 
template<>
MoFEMErrorCode evalFEAtPoints (const std::vector< std::array< double, 3 > > &points, 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, const PointGroupCallback &on_element, MoFEMTypes bh, VERBOSITY_LEVELS verb)
 
template<>
ForcesAndSourcesCore::UserDataOperator * 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)
 
template<>
ForcesAndSourcesCore::UserDataOperator * 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)
 
- 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>
MoFEMErrorCode evalFEAtPointsImpl (const std::vector< std::array< double, 3 > > &points, 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, const PointGroupCallback &on_element, MoFEMTypes bh, VERBOSITY_LEVELS verb)
 
template<int D>
ForcesAndSourcesCore::UserDataOperator * getDataOperatorImpl (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::Core & cOre
 

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/cor-12_cohesive_interface/arc_length_interface.cpp, mofem/tutorials/max-1_lorentz_force//lorentz_force.cpp, mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp, and mofem/users_modules/basic_finite_elements/elasticity/elasticity.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.

◆ PointGroupCallback

using MoFEM::FieldEvaluatorInterface::PointGroupCallback = boost::function<MoFEMErrorCode(const std::vector<size_t> &)>

Locate local points and evaluate each containing element once. The callback sees the original point indices and the current element's operator output, with one output row per index in the supplied order.

Definition at line 208 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 10 of file FieldEvaluator.cpp.

11 : cOre(const_cast<MoFEM::Core &>(core)) {
12
13 if (!LogManager::checkIfChannelExist("FieldEvaluatorWorld")) {
14 auto core_log = logging::core::get();
15
17 "FieldEvaluatorWorld"));
19 "FieldEvaluatorSync"));
21 "FieldEvaluatorSelf"));
22
23 LogManager::setLog("FieldEvaluatorWorld");
24 LogManager::setLog("FieldEvaluatorSync");
25 LogManager::setLog("FieldEvaluatorSelf");
26
27 MOFEM_LOG_TAG("FieldEvaluatorWorld", "FieldEvaluator");
28 MOFEM_LOG_TAG("FieldEvaluatorSync", "FieldEvaluator");
29 MOFEM_LOG_TAG("FieldEvaluatorSelf", "FieldEvaluator");
30 }
31
32 MOFEM_LOG("FieldEvaluatorWorld", Sev::noisy) << "Field evaluator intreface";
33}
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 67 of file FieldEvaluator.cpp.

69 {
70 return buildTreeImpl<2>(spd_ptr, finite_element, bit, mask);
71}
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 74 of file FieldEvaluator.cpp.

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

◆ 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 43 of file FieldEvaluator.cpp.

45 {
46 CoreInterface &m_field = cOre;
48 EntityHandle fe_meshset;
49 fe_meshset = m_field.get_finite_element_meshset(finite_element);
50 Range entities;
51 CHKERR m_field.get_moab().get_entities_by_dimension(fe_meshset, D, entities,
52 true);
53 if (bit.any()) {
54 CHKERR m_field.getInterface<BitRefManager>()->filterEntitiesByRefLevel(
55 bit, mask, entities);
56 }
57 if (spd_ptr->treePtr) {
58 spd_ptr->treePtr->reset_tree();
59 } else {
60 spd_ptr->treePtr = boost::make_shared<AdaptiveKDTree>(&m_field.get_moab());
61 }
62 CHKERR spd_ptr->treePtr->build_tree(entities, &spd_ptr->rooTreeSet);
64}
#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
EntityHandle get_finite_element_meshset(const BitFEId id) const
Definition FECore.cpp:273

◆ evalFEAtPoints() [1/5]

template<>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtPoints ( const std::vector< std::array< double, 3 > > &  points,
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,
const PointGroupCallback &  on_element,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb 
)

◆ evalFEAtPoints() [2/5]

template<>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtPoints ( const std::vector< std::array< double, 3 > > &  points,
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,
const PointGroupCallback &  on_element,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb 
)

◆ evalFEAtPoints() [3/5]

template<>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtPoints ( const std::vector< std::array< double, 3 > > &  points,
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,
const PointGroupCallback &  on_element,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb 
)

Definition at line 539 of file FieldEvaluator.cpp.

546 {
547 return evalFEAtPointsImpl<2>(points, distance, problem, finite_element,
548 data_ptr, lower_rank, upper_rank, bit, mask,
549 cache_ptr, on_element, bh, verb);
550}
double distance
Definition CGALTools.cpp:64
const std::vector< Vec > * points

◆ evalFEAtPoints() [4/5]

template<>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtPoints ( const std::vector< std::array< double, 3 > > &  points,
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,
const PointGroupCallback &  on_element,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb 
)

Definition at line 553 of file FieldEvaluator.cpp.

560 {
561 return evalFEAtPointsImpl<3>(points, distance, problem, finite_element,
562 data_ptr, lower_rank, upper_rank, bit, mask,
563 cache_ptr, on_element, bh, verb);
564}

◆ evalFEAtPoints() [5/5]

template<int D>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtPoints ( const std::vector< std::array< double, 3 > > &  points,
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,
const PointGroupCallback &  on_element,
MoFEMTypes  bh = MF_EXIST,
VERBOSITY_LEVELS  verb = QUIET 
)

◆ evalFEAtPointsImpl()

template<int D>
MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtPointsImpl ( const std::vector< std::array< double, 3 > > &  points,
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,
const PointGroupCallback &  on_element,
MoFEMTypes  bh,
VERBOSITY_LEVELS  verb 
)
private

Definition at line 410 of file FieldEvaluator.cpp.

417 {
418 CoreInterface &m_field = cOre;
420
421 struct ResetEvalPoints {
422 boost::shared_ptr<SetIntegrationPtsMethodData> data;
423 ~ResetEvalPoints() { data->setEvalPoints(nullptr, 0); }
424 } reset{data_ptr};
425 struct LocatedPoint {
426 size_t index;
427 std::array<double, 3> local;
428 std::array<double, 4> shape;
429 };
430 std::map<EntityHandle, std::vector<LocatedPoint>> groups;
431 auto &mb = m_field.get_moab();
432 for (size_t q = 0; q != points.size(); ++q) {
433 std::vector<EntityHandle> leaves;
434 CHKERR data_ptr->treePtr->distance_search(points[q].data(), distance,
435 leaves);
436 Range candidates;
437 for (auto leaf : leaves)
438 CHKERR mb.get_entities_by_dimension(leaf, D, candidates, true);
439
440 EntityHandle selected = 0;
441 LocatedPoint located{q, {}, {}};
442 for (auto ent : candidates) {
443 if (type_from_handle(ent) != (D == 2 ? MBTRI : MBTET))
444 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
445 "Field evaluator requires triangles or tetrahedra");
446 const EntityHandle *conn;
447 int num_nodes;
448 CHKERR mb.get_connectivity(ent, conn, num_nodes, true);
449 std::array<double, 12> coords{};
450 CHKERR mb.get_coords(conn, num_nodes, coords.data());
451 std::array<double, 3> local{};
452 std::array<double, 4> shape{};
453 if constexpr (D == 2) {
455 coords.data(), points[q].data(), 1, local.data());
456 CHKERR Tools::shapeFunMBTRI<2>(shape.data(), &local[0], &local[1], 1);
457 } else {
459 coords.data(), points[q].data(), 1, local.data());
460 CHKERR Tools::shapeFunMBTET<3>(shape.data(), &local[0], &local[1],
461 &local[2], 1);
462 }
463 bool inside = true;
464 for (int i = 0; i != D + 1; ++i)
465 inside = inside && shape[i] >= -data_ptr->eps &&
466 shape[i] <= 1 + data_ptr->eps;
467 if (inside) {
468 selected = ent;
469 located.local = local;
470 located.shape = shape;
471 }
472 }
473 if (selected)
474 groups[selected].push_back(located);
475 }
476
477 const Problem *prb_ptr;
478 CHKERR m_field.get_problem(problem, &prb_ptr);
479 const auto &finite_elements =
480 m_field.get_finite_elements()->get<FiniteElement_name_mi_tag>();
481 const auto fe_it = finite_elements.find(finite_element);
482 if (fe_it == finite_elements.end())
484 if (!data_ptr->feMethodPtr)
485 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
486 "Pointer to element does not exist");
487 if (!cache_ptr) {
488 cache_ptr = boost::make_shared<CacheTuple>();
489 CHKERR m_field.cache_problem_entities(problem, cache_ptr);
490 }
491
492 auto &numbered = prb_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>();
493 std::vector<double> group_coordinates;
494 std::vector<size_t> point_indices;
495 for (const auto &[ent, located_points] : groups) {
496 auto lo = numbered.lower_bound(EntFiniteElement::getLocalUniqueIdCalculate(
497 ent, (*fe_it)->getFEUId()));
498 auto hi = numbered.upper_bound(EntFiniteElement::getLocalUniqueIdCalculate(
499 ent, (*fe_it)->getFEUId()));
500 auto selected_fes = boost::make_shared<NumeredEntFiniteElement_multiIndex>();
501 for (auto it = lo; it != hi; ++it) {
502 if (bit.any()) {
503 const auto fe_bit = (*it)->getBitRefLevel();
504 if ((fe_bit & mask) != fe_bit || (fe_bit & bit).none())
505 continue;
506 }
507 selected_fes->insert(*it);
508 }
509 // The point evaluator treats zero or multiple matching FEs as uncovered.
510 if (selected_fes->size() != 1)
511 continue;
512
513 group_coordinates.clear();
514 point_indices.clear();
515 for (const auto &point : located_points) {
516 point_indices.push_back(point.index);
517 group_coordinates.insert(group_coordinates.end(),
518 points[point.index].begin(),
519 points[point.index].end());
520 }
521 data_ptr->setEvalPoints(group_coordinates.data(), located_points.size());
522 data_ptr->evalPointEntityHandle.assign(located_points.size(), ent);
523 for (size_t row = 0; row != located_points.size(); ++row) {
524 for (int i = 0; i != D; ++i)
525 data_ptr->localCoords(row, i) = located_points[row].local[i];
526 for (int i = 0; i != D + 1; ++i)
527 data_ptr->shapeFunctions(row, i) = located_points[row].shape[i];
528 }
529 CHKERR m_field.loop_finite_elements(
530 prb_ptr, finite_element, *data_ptr->feMethodPtr, lower_rank, upper_rank,
531 selected_fes, bh, cache_ptr, verb);
532 if (data_ptr->feMethodPtr->getLoopSize() == 1)
533 CHKERR on_element(point_indices);
534 }
536}
std::map< EntityHandle, int > index
bool selected
Definition CGALTools.cpp:97
moab::Interface & mb
std::vector< FieldBitNumber > row
Definition Schur.cpp:2488
It it
Definition Schur.cpp:2568
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32
FTensor::Index< 'i', SPACE_DIM > i
auto type_from_handle(const EntityHandle h)
get type from entity handle
double q
moab::Interface & get_moab()
Definition Core.hpp:327
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

◆ 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 384 of file FieldEvaluator.cpp.

390 {
391 return evalFEAtThePointImpl<2>(point, distance, problem, finite_element,
392 data_ptr, lower_rank, upper_rank, bit, mask,
393 cache_ptr, bh, verb);
394}

◆ 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 397 of file FieldEvaluator.cpp.

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

◆ 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 159 of file FieldEvaluator.cpp.

165 {
166 CoreInterface &m_field = cOre;
168
169 std::vector<EntityHandle> leafs_out;
170 CHKERR data_ptr->treePtr->distance_search(point, distance, leafs_out);
171 Range tree_ents;
172 for (auto lit : leafs_out) //{
173 CHKERR m_field.get_moab().get_entities_by_dimension(lit, D, tree_ents,
174 true);
175
176 if (verb >= NOISY)
177 MOFEM_LOG("SELF", Sev::noisy) << "tree entities: " << tree_ents;
178
179 data_ptr->evalPointEntityHandle.resize(data_ptr->nbEvalPoints);
180 std::fill(data_ptr->evalPointEntityHandle.begin(),
181 data_ptr->evalPointEntityHandle.end(), 0);
182
183 std::vector<double> local_coords;
184 std::vector<double> shape;
185
186 auto nb_eval_points = data_ptr->nbEvalPoints;
187
188 for (auto tet : tree_ents) {
189 if ((type_from_handle(tet) != moab::MBTRI) &&
190 (type_from_handle(tet) != moab::MBTET)) {
191 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
192 "Wrong element type, Field Evaluator not implemented for Quads "
193 "and Hexes");
194 }
195 const EntityHandle *conn;
196 int num_nodes;
197 CHKERR m_field.get_moab().get_connectivity(tet, conn, num_nodes, true);
198
199 if constexpr (D == 3) {
200
201 local_coords.resize(3 * nb_eval_points);
202 shape.resize(4 * nb_eval_points);
203
204 std::array<double, 12> coords;
205 CHKERR m_field.get_moab().get_coords(conn, num_nodes, coords.data());
206
208 coords.data(), &data_ptr->evalPoints[0], nb_eval_points,
209 &local_coords[0]);
210 CHKERR Tools::shapeFunMBTET<3>(&shape[0], &local_coords[0],
211 &local_coords[1], &local_coords[2],
212 nb_eval_points);
213
214 FTensor::Index<'i', 4> i4;
216 &shape[0], &shape[1], &shape[2], &shape[3]};
218 &data_ptr->shapeFunctions(0, 0), &data_ptr->shapeFunctions(0, 1),
219 &data_ptr->shapeFunctions(0, 2), &data_ptr->shapeFunctions(0, 3)};
220
221 FTensor::Index<'j', 3> j3;
223 &local_coords[0], &local_coords[1], &local_coords[2]};
225 &(data_ptr->localCoords(0, 0)), &(data_ptr->localCoords(0, 1)),
226 &(data_ptr->localCoords(0, 2))};
227
228 for (int n = 0; n != nb_eval_points; ++n) {
229
230 const double eps = data_ptr->eps;
231 if (t_shape(0) >= 0 - eps && t_shape(0) <= 1 + eps &&
232
233 t_shape(1) >= 0 - eps && t_shape(1) <= 1 + eps &&
234
235 t_shape(2) >= 0 - eps && t_shape(2) <= 1 + eps &&
236
237 t_shape(3) >= 0 - eps && t_shape(3) <= 1 + eps) {
238
239 data_ptr->evalPointEntityHandle[n] = tet;
240 t_shape_data(i4) = t_shape(i4);
241 t_local_data(j3) = t_local(j3);
242 }
243
244 ++t_shape;
245 ++t_shape_data;
246 ++t_local;
247 ++t_local_data;
248 }
249 }
250
251 if constexpr (D == 2) {
252
253 local_coords.resize(2 * nb_eval_points);
254 shape.resize(3 * nb_eval_points);
255
256 std::array<double, 9> coords;
257 CHKERR m_field.get_moab().get_coords(conn, num_nodes, coords.data());
258
260 coords.data(), &data_ptr->evalPoints[0], nb_eval_points,
261 &local_coords[0]);
262 CHKERR Tools::shapeFunMBTRI<2>(&shape[0], &local_coords[0],
263 &local_coords[1], nb_eval_points);
264
265 FTensor::Index<'i', 3> i3;
267 &shape[0], &shape[1], &shape[2]};
268 // The shared barycentric matrix reserves four columns for both simplices.
270 &data_ptr->shapeFunctions(0, 0), &data_ptr->shapeFunctions(0, 1),
271 &data_ptr->shapeFunctions(0, 2)};
272
273 FTensor::Index<'j', 2> j2;
275 &local_coords[0], &local_coords[1]};
276 data_ptr->localCoords.resize(nb_eval_points, 2);
278 &(data_ptr->localCoords(0, 0)), &(data_ptr->localCoords(0, 1))};
279
280 for (int n = 0; n != nb_eval_points; ++n) {
281
282 const double eps = data_ptr->eps;
283 if (t_shape(0) >= 0 - eps && t_shape(0) <= 1 + eps &&
284
285 t_shape(1) >= 0 - eps && t_shape(1) <= 1 + eps &&
286
287 t_shape(2) >= 0 - eps && t_shape(2) <= 1 + eps) {
288
289 data_ptr->evalPointEntityHandle[n] = tet;
290 t_shape_data(i3) = t_shape(i3);
291 t_local_data(j2) = t_local(j2);
292 }
293
294 ++t_shape;
295 ++t_shape_data;
296 ++t_local;
297 ++t_local_data;
298 }
299 }
300 }
301
302 const Problem *prb_ptr;
303 CHKERR m_field.get_problem(problem, &prb_ptr);
304 boost::shared_ptr<NumeredEntFiniteElement_multiIndex> numered_fes(
306
307 Range in_tets;
308 in_tets.insert_list(data_ptr->evalPointEntityHandle.begin(),
309 data_ptr->evalPointEntityHandle.end());
310 in_tets = in_tets.subset_by_dimension(D);
311
312 if (verb >= NOISY)
313 MOFEM_LOG("SELF", Sev::noisy) << "in tets: " << in_tets << endl;
314
315 auto fe_miit =
316 m_field.get_finite_elements()->get<FiniteElement_name_mi_tag>().find(
317 finite_element);
318 if (fe_miit !=
319 m_field.get_finite_elements()->get<FiniteElement_name_mi_tag>().end()) {
320
321 for (auto peit = in_tets.pair_begin(); peit != in_tets.pair_end(); ++peit) {
322
323 auto lo =
324 prb_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>().lower_bound(
326 peit->first, (*fe_miit)->getFEUId()));
327 auto hi =
328 prb_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>().upper_bound(
330 peit->second, (*fe_miit)->getFEUId()));
331
332 if (bit.any()) {
333 if (verb >= VERY_NOISY)
334 MOFEM_LOG("FieldEvaluatorSelf", Sev::noisy);
335 for (auto it = lo; it != hi; ++it) {
336 auto fe_bit = (*it)->getBitRefLevel();
337 if ((fe_bit & mask) != fe_bit)
338 continue;
339 if ((fe_bit & bit).none())
340 continue;
341 numered_fes->insert(*it);
342 if (verb >= VERY_NOISY)
343 MOFEM_LOG("FieldEvaluatorSelf", Sev::noisy) << **it << endl;
344 }
345 } else {
346 numered_fes->insert(lo, hi);
347 if (verb >= VERY_NOISY) {
348 MOFEM_LOG("FieldEvaluatorSelf", Sev::noisy)
349 << "numbered elements:" << std::endl;
350 for (; lo != hi; ++lo)
351 MOFEM_LOG("FieldEvaluatorSelf", Sev::noisy) << **lo << endl;
352 }
353 }
354 }
355
356 if (auto fe_ptr = data_ptr->feMethodPtr) {
357
358 MOFEM_LOG_C("FieldEvaluatorSelf", Sev::noisy,
359 "Number elements %zu to evaluate at proc %d",
360 numered_fes->size(), m_field.get_comm_rank());
361
362 if (!cache_ptr) {
363 cache_ptr = boost::make_shared<CacheTuple>();
364 CHKERR m_field.cache_problem_entities(prb_ptr->getName(), cache_ptr);
365
366 MOFEM_LOG("FieldEvaluatorSelf", Sev::noisy)
367 << "If you call that function many times in the loop consider to "
368 "set cache_ptr outside of the loop. Otherwise code can be slow.";
369 }
370
371 CHKERR m_field.loop_finite_elements(prb_ptr, finite_element, *fe_ptr,
372 lower_rank, upper_rank, numered_fes,
373 bh, cache_ptr, verb);
374
375 } else
376 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
377 "Pointer to element does not exists");
378 }
379
381}
#define MOFEM_LOG_C(channel, severity, format,...)
static const double eps
@ NOISY
@ VERY_NOISY
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.

◆ 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 379 of file FieldEvaluator.hpp.

380 {
381 MoFEM::Interface &m_field = cOre;
382 auto ve_method_ptr = boost::make_shared<VE>(m_field);
383 auto spd_ptr =
384 boost::make_shared<SPD>(ve_method_ptr, ptr, nb_eval_points, eps, verb);
385 ve_method_ptr->setRuleHook = SP(spd_ptr);
386 return spd_ptr;
387}
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 726 of file FieldEvaluator.cpp.

732 {
733 return getDataOperatorImpl<2>(mat_data_pts, finite_element,
734 data_ptr, lower_rank, upper_rank, bit, mask,
735 bh, verb, data_layout);
736}

◆ 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 739 of file FieldEvaluator.cpp.

745 {
746 return getDataOperatorImpl<3>(mat_data_pts, finite_element,
747 data_ptr, lower_rank, upper_rank, bit, mask,
748 bh, verb, data_layout);
749}

◆ 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 568 of file FieldEvaluator.cpp.

573 {
574
575 using BaseOP = ForcesAndSourcesCore::UserDataOperator;
576
577 struct Op : public BaseOP {
578 Op(
579
580 FieldEvaluatorInterface::MatDataPts mat_data_pts,
581 const std::string finite_element,
582 boost::shared_ptr<SetIntegrationPtsMethodData> data_ptr, int lower_rank,
583 int upper_rank, BitRefLevel bit, BitRefLevel mask, double eps,
584 MoFEMTypes bh, VERBOSITY_LEVELS verb, DataLayout data_layout
585
586 )
587 : BaseOP(NOSPACE, BaseOP::OPSPACE),
588 matDataPts(mat_data_pts), finiteElement(finite_element),
589 dataPtr(data_ptr), lowerRank(lower_rank), upperRank(upper_rank),
590 bitRefLevel(bit), maskRefLevel(mask), eps(eps), bhType(bh),
591 verbosity(verb), dataLayout(data_layout) {}
592
593 MoFEMErrorCode doWork(int side, EntityType type,
594 EntitiesFieldData::EntData &data) {
596
597 MOFEM_LOG_CHANNEL("SELF");
598 MOFEM_LOG_TAG("SELF", "FieldEvaluator");
599
600 MoFEM::Interface &m_field = this->getPtrFE()->mField;
601 auto field_eval_ptr = m_field.getInterface<FieldEvaluatorInterface>();
602
603 auto nb_integration_pts = getGaussPts().size2();
604
605 auto prb_name = getPtrFE()->problemPtr->getName();
606 auto cache_ptr = getPtrFE()->getCacheWeakPtr();
607
608 auto coords_at_pts = getCoordsAtGaussPts();
609 for (int gg = 0; gg != nb_integration_pts; ++gg) {
610 double *coords_ptr = &coords_at_pts(gg, 0);
611
612 dataPtr->setEvalPoints(coords_ptr, 1);
613 CHKERR field_eval_ptr->evalFEAtThePoint<D>(
614 coords_ptr, eps, prb_name, finiteElement, dataPtr, lowerRank,
615 upperRank, bitRefLevel, maskRefLevel, cache_ptr.lock(), MF_EXIST,
616 QUIET);
617
618 // Get number of found finite elements, that consist gauss point.
619 // E.g. for edge flip expected is that only one element will be found.
620 auto loop_size = dataPtr->feMethodPtr->getLoopSize();
621 if (loop_size != 1) {
622 if (verbosity >= QUIET) {
624 LogManager::BitLineID | LogManager::BitScope);
625 MOFEM_LOG("SELF", Sev::warning)
626 << "Field evaluator wrong number of elements found: "
627 << loop_size;
628 }
629 }
630
631 for (auto &m : matDataPts) {
632
633 const auto nb_data_rows = m.first->size1();
634 const auto nb_data_cols = m.first->size2();
635
636#ifndef NDEBUG
637 const auto nb_data_gauss_pts =
638 dataLayout == DataLayout::GaussByCoeffs ? nb_data_rows
639 : nb_data_cols;
640 if (nb_data_gauss_pts != loop_size) {
641 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
642 "Inconsistent source data layout for size (%ld, %ld), "
643 "loop size %d, and requested layout %s",
644 nb_data_rows, nb_data_cols, loop_size,
645 dataLayout == DataLayout::GaussByCoeffs ? "GaussByCoeffs"
646 : "CoeffsByGauss");
647 }
648#endif
649
650 const auto nb_data_coeffs =
651 dataLayout == DataLayout::GaussByCoeffs ? nb_data_cols
652 : nb_data_rows;
653
654 if (dataLayout == DataLayout::GaussByCoeffs) {
655 m.second->resize(nb_integration_pts, nb_data_coeffs, false);
656 } else {
657 m.second->resize(nb_data_coeffs, nb_integration_pts, false);
658 }
659 if (gg == 0)
660 m.second->clear();
661 for (auto ll = 0; ll != loop_size; ++ll) {
662 for (int dd = 0; dd != nb_data_coeffs; ++dd) {
663 const auto value = dataLayout == DataLayout::GaussByCoeffs
664 ? (*m.first)(ll, dd)
665 : (*m.first)(dd, ll);
666 if (dataLayout == DataLayout::GaussByCoeffs) {
667 (*m.second)(gg, dd) += value / loop_size;
668 } else {
669 (*m.second)(dd, gg) += value / loop_size;
670 }
671 }
672 }
673 }
674 }
675
676 MOFEM_LOG_CHANNEL("SELF");
677
679 }
680
681 private:
682 FieldEvaluatorInterface::MatDataPts matDataPts;
683 std::string finiteElement;
684 boost::shared_ptr<SetIntegrationPtsMethodData> dataPtr;
685 int lowerRank;
686 int upperRank;
687 BitRefLevel bitRefLevel;
688 BitRefLevel maskRefLevel;
689 double eps;
690 MoFEMTypes bhType;
691 VERBOSITY_LEVELS verbosity;
692 DataLayout dataLayout;
693 };
694
695 double min[3];
696 double max[3];
697 unsigned int dep;
698 CHKERR data_ptr->treePtr->get_info(data_ptr->rooTreeSet, min, max, dep);
699 double dist = std::sqrt(pow(max[0] - min[0], 2) + pow(max[1] - min[1], 2) +
700 pow(max[2] - min[2], 2));
701
702 return new Op(mat_data_pts, finite_element, data_ptr, lower_rank,
703 upper_rank, bit, mask, 1e-6 * dist, bh, verb, data_layout);
704}
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 35 of file FieldEvaluator.cpp.

36 {
38 *iface = const_cast<FieldEvaluatorInterface *>(this);
40}
#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 221 of file FieldEvaluator.hpp.


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