v0.8.23
Classes | Public Member Functions | Public 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  SetPts
 Default evaluator for setting integration points. More...
 
struct  SetPtsData
 

Public Member Functions

MoFEMErrorCode query_interface (const MOFEMuuid &uuid, UnknownInterface **iface) const
 
 FieldEvaluatorInterface (const MoFEM::Core &core)
 
template<typename VE , typename SPD = SetPtsData, typename SP = SetPts>
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. More...
 
MoFEMErrorCode buildTree3D (boost::shared_ptr< SetPtsData > spd_ptr, const std::string finite_element)
 Build spatial tree. More...
 
MoFEMErrorCode evalFEAtThePoint3D (const double *const point, const double distance, const std::string problem, const std::string finite_element, boost::shared_ptr< SetPtsData > data_ptr, int lower_rank, int upper_rank, MoFEMTypes bh=MF_EXIST, VERBOSITY_LEVELS verb=QUIET)
 Evaluate field at artbitray position. More...
 
- Public Member Functions inherited from MoFEM::UnknownInterface
template<class IFACE >
MoFEMErrorCode registerInterface (const MOFEMuuid &uuid, bool error_if_registration_failed=true)
 Register interface. More...
 
template<class IFACE , bool VERIFY = false>
MoFEMErrorCode getInterface (const MOFEMuuid &uuid, IFACE *&iface) const
 Get interface by uuid and return reference to pointer of interface. More...
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE *&iface) const
 Get interface refernce to pointer of interface. More...
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE **const iface) const
 Get interface pointer to pointer of interface. More...
 
template<class IFACE , typename boost::enable_if< boost::is_pointer< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get interface pointer to pointer of interface. More...
 
template<class IFACE , typename boost::enable_if< boost::is_reference< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get reference to interface. More...
 
template<class IFACE >
IFACE * getInterface () const
 Function returning pointer to interface. More...
 
virtual ~UnknownInterface ()
 
virtual MoFEMErrorCode getLibVersion (Version &version) const
 Get library version. More...
 
virtual const MoFEMErrorCode getFileVersion (moab::Interface &moab, Version &version) const
 Get database major version. More...
 
virtual MoFEMErrorCode getInterfaceVersion (Version &version) const
 Get database major version. More...
 
template<>
MoFEMErrorCode getInterface (const MOFEMuuid &uuid, UnknownInterface *&iface) const
 

Public Attributes

MoFEM::CorecOre
 

Additional Inherited Members

- Protected Member Functions inherited from MoFEM::UnknownInterface
boost::typeindex::type_index getClassIdx (const MOFEMuuid &uid) const
 Get type name for interface Id. More...
 
MOFEMuuid getUId (const boost::typeindex::type_index &class_idx) const
 Get interface Id for class name. More...
 

Detailed Description

Field evaluator interface.

Examples
EshelbianPlasticity.cpp, field_evaluator.cpp, and lorentz_force.cpp.

Definition at line 34 of file FieldEvaluator.hpp.

Constructor & Destructor Documentation

◆ FieldEvaluatorInterface()

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

Definition at line 40 of file FieldEvaluator.hpp.

41  : cOre(const_cast<MoFEM::Core &>(core)) {}

Member Function Documentation

◆ buildTree3D()

MoFEMErrorCode MoFEM::FieldEvaluatorInterface::buildTree3D ( boost::shared_ptr< SetPtsData spd_ptr,
const std::string  finite_element 
)

Build spatial tree.

Parameters
finite_elementfinite element name
Returns
MoFEMErrorCode
Examples
field_evaluator.cpp, and lorentz_force.cpp.

Definition at line 37 of file FieldEvaluator.cpp.

38  {
39  CoreInterface &m_field = cOre;
41  EntityHandle fe_meshset;
42  fe_meshset = m_field.get_finite_element_meshset(finite_element);
43  Range entities_3d;
44  CHKERR m_field.get_moab().get_entities_by_dimension(fe_meshset, 3,
45  entities_3d, true);
46  spd_ptr->treePtr.reset(new AdaptiveKDTree(&m_field.get_moab()));
47  CHKERR spd_ptr->treePtr->build_tree(entities_3d, &spd_ptr->rooTreeSet);
49 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define CHKERR
Inline error check.
Definition: definitions.h:596
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ evalFEAtThePoint3D()

MoFEMErrorCode MoFEM::FieldEvaluatorInterface::evalFEAtThePoint3D ( const double *const  point,
const double  distance,
const std::string  problem,
const std::string  finite_element,
boost::shared_ptr< SetPtsData data_ptr,
int  lower_rank,
int  upper_rank,
MoFEMTypes  bh = MF_EXIST,
VERBOSITY_LEVELS  verb = QUIET 
)

Evaluate field at artbitray 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. };
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
CHKERR m_field.getInterface<FieldEvaluatorInterface>()
->evalFEAtThePoint3D(point.data(), dist, prb_ptr->getName(),
"FINITE_ELEMENT_NAME",
data_ptr, m_field.get_comm_rank(),
m_field.get_comm_rank(), MF_EXIST, QUIET);
}
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
bhcontrol looping over entities, e.g. throwing error if element not found
verbverbosity level
Returns
MoFEMErrorCode
Examples
field_evaluator.cpp, and lorentz_force.cpp.

Definition at line 113 of file FieldEvaluator.cpp.

116  {
117  CoreInterface &m_field = cOre;
119 
120  std::vector<EntityHandle> leafs_out;
121  CHKERR data_ptr->treePtr->distance_search(point, distance, leafs_out);
122  Range tree_ents;
123  for (auto lit : leafs_out)
124  CHKERR m_field.get_moab().get_entities_by_dimension(lit, 3, tree_ents,
125  true);
126 
127  if (verb >= VERY_NOISY)
128  std::cout << "tree entities: " << tree_ents << endl;
129 
130  data_ptr->evalPointEntityHandle.resize(data_ptr->nbEvalPoints);
131  std::fill(data_ptr->evalPointEntityHandle.begin(),
132  data_ptr->evalPointEntityHandle.end(), 0);
133 
134  for (auto tet : tree_ents) {
135 
136  const EntityHandle *conn;
137  int num_nodes;
138  CHKERR m_field.get_moab().get_connectivity(tet, conn, num_nodes, true);
139  std::array<double, 12> coords;
140  CHKERR m_field.get_moab().get_coords(conn, num_nodes, coords.data());
141 
142  for (int n = 0; n != data_ptr->nbEvalPoints; ++n) {
143 
144  std::array<double, 3> local_coords;
146  coords.data(), &data_ptr->evalPoints[3 * n], 1, local_coords.data());
147 
148  std::array<double, 4> shape;
149  CHKERR Tools::shapeFunMBTET<3>(shape.data(), &local_coords[0],
150  &local_coords[1], &local_coords[2], 1);
151 
152  const double eps = data_ptr->eps;
153  if (shape[0] >= 0 - eps && shape[0] <= 1 + eps &&
154 
155  shape[1] >= 0 - eps && shape[1] <= 1 + eps &&
156 
157  shape[2] >= 0 - eps && shape[2] <= 1 + eps &&
158 
159  shape[3] >= 0 - eps && shape[3] <= 1 + eps) {
160 
161  std::copy(shape.begin(), shape.end(), &data_ptr->shapeFunctions(n, 0));
162  std::copy(local_coords.begin(), local_coords.end(),
163  &data_ptr->localCoords(n, 0));
164  data_ptr->evalPointEntityHandle[n] = tet;
165  }
166  }
167  }
168 
169  const Problem *prb_ptr;
170  CHKERR m_field.get_problem(problem, &prb_ptr);
171  boost::shared_ptr<NumeredEntFiniteElement_multiIndex> numered_fes(
173 
174  Range in_tets;
175  in_tets.insert_list(data_ptr->evalPointEntityHandle.begin(),
176  data_ptr->evalPointEntityHandle.end());
177  in_tets = in_tets.subset_by_dimension(3);
178 
179  if (verb >= VERY_NOISY)
180  std::cout << "in tets: " << in_tets << endl;
181 
182  for (auto peit = in_tets.pair_begin(); peit != in_tets.pair_end(); ++peit) {
183  auto lo =
184  prb_ptr->numeredFiniteElements->get<Composite_Name_And_Ent_mi_tag>()
185  .lower_bound(boost::make_tuple(finite_element, peit->first));
186  auto hi =
187  prb_ptr->numeredFiniteElements->get<Composite_Name_And_Ent_mi_tag>()
188  .upper_bound(boost::make_tuple(finite_element, peit->second));
189  numered_fes->insert(lo, hi);
190 
191  if (verb >= VERY_NOISY)
192  std::cout << "numered elements:" << std::endl;
193  for (; lo != hi; ++lo)
194  if (verb >= VERY_NOISY)
195  std::cout << **lo << endl;
196  }
197  if (verb >= VERY_NOISY)
198  std::cout << std::endl;
199 
200  if (auto fe_ptr = data_ptr->feMethodPtr.lock()) {
201 
202  if(verb >= VERBOSE) {
203  CHKERR PetscSynchronizedPrintf(
204  m_field.get_comm(), "Number elements %d to evaluate at proc %d\n",
205  numered_fes->size(), m_field.get_comm_rank());
206  PetscSynchronizedFlush(m_field.get_comm(), PETSC_STDOUT);
207  }
208 
209  CHKERR m_field.loop_finite_elements(prb_ptr, finite_element, *fe_ptr,
210  lower_rank, upper_rank, numered_fes, bh,
211  verb);
212  } else
213  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
214  "Pointer to element does not exists");
215 
217 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
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:94
multi_index_container< boost::shared_ptr< NumeredEntFiniteElement >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< NumeredEntFiniteElement::interface_type_EntFiniteElement, UId, &NumeredEntFiniteElement::getGlobalUniqueId > >, ordered_non_unique< tag< Part_mi_tag >, member< NumeredEntFiniteElement, unsigned int, &NumeredEntFiniteElement::part > >, ordered_non_unique< tag< FiniteElement_name_mi_tag >, const_mem_fun< NumeredEntFiniteElement::interface_type_FiniteElement, boost::string_ref, &NumeredEntFiniteElement::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< NumeredEntFiniteElement::interface_type_EntFiniteElement, EntityHandle, &NumeredEntFiniteElement::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< NumeredEntFiniteElement, const_mem_fun< NumeredEntFiniteElement::interface_type_FiniteElement, boost::string_ref, &NumeredEntFiniteElement::getNameRef >, const_mem_fun< NumeredEntFiniteElement::interface_type_EntFiniteElement, 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.
#define CHKERR
Inline error check.
Definition: definitions.h:596
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407
static const double eps

◆ getData()

template<typename VE , typename SPD = SetPtsData, typename SP = SetPts>
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
SetPtsData
SetPts
Parameters
ptr
nb_eval_points
eps
verb
Returns
boost::shared_ptr<SPD>
Examples
EshelbianPlasticity.cpp, field_evaluator.cpp, and lorentz_force.cpp.

Definition at line 118 of file FieldEvaluator.hpp.

119  {
120  struct PackData {
121  boost::scoped_ptr<VE> volElePtr;
122  boost::scoped_ptr<SPD> setPtsDataPtr;
123  boost::scoped_ptr<SP> setPtsPtr;
124  };
125  boost::shared_ptr<PackData> pack_data(new PackData());
126  MoFEM::Interface &m_field = cOre;
127  pack_data->volElePtr.reset(new VE(m_field));
128  pack_data->setPtsDataPtr.reset(
129  new SPD(boost::shared_ptr<VE>(pack_data, pack_data->volElePtr.get()),
130  ptr, nb_eval_points, eps, verb));
131  pack_data->setPtsPtr.reset(new SP(
132  boost::shared_ptr<SPD>(pack_data, pack_data->setPtsDataPtr.get())));
133  pack_data->volElePtr->setRuleHook = boost::ref(*pack_data->setPtsPtr);
134  boost::shared_ptr<SPD> data(pack_data, pack_data->setPtsDataPtr.get());
135  return data;
136  }
static const double eps

◆ query_interface()

MoFEMErrorCode MoFEM::FieldEvaluatorInterface::query_interface ( const MOFEMuuid uuid,
UnknownInterface **  iface 
) const
virtual

Implements MoFEM::UnknownInterface.

Definition at line 24 of file FieldEvaluator.cpp.

25  {
27  *iface = NULL;
28  if (uuid == IDD_MOFEMFieldEvaluator) {
29  *iface = const_cast<FieldEvaluatorInterface *>(this);
31  }
32  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "unknown interface");
34 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
static const MOFEMuuid IDD_MOFEMFieldEvaluator

Member Data Documentation

◆ cOre

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

Definition at line 39 of file FieldEvaluator.hpp.


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