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:476
#define CHKERR
Inline error check.
Definition: definitions.h:595
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:406

◆ 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. };
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
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 117 of file FieldEvaluator.cpp.

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