12 auto core_log = logging::core::get();
15 "FieldEvaluatorWorld"));
17 "FieldEvaluatorSync"));
19 "FieldEvaluatorSelf"));
30 MOFEM_LOG(
"FieldEvaluatorWorld", Sev::noisy) <<
"Field evaluator intreface";
43 const std::string finite_element) {
49 CHKERR m_field.
get_moab().get_entities_by_dimension(fe_meshset,
D, entities,
51 spd_ptr->treePtr.reset(
new AdaptiveKDTree(&m_field.
get_moab()));
52 CHKERR spd_ptr->treePtr->build_tree(entities, &spd_ptr->rooTreeSet);
58 const std::string finite_element) {
59 return buildTree<3>(spd_ptr, finite_element);
64 const std::string finite_element) {
65 return buildTree<2>(spd_ptr, finite_element);
70 int order_row,
int order_col,
74 if (
auto data_ptr =
dataPtr.lock()) {
76 const auto nb_eval_points = data_ptr->nbEvalPoints;
77 const auto &shape_functions = data_ptr->shapeFunctions;
78 const auto &eval_pointentity_handle = data_ptr->evalPointEntityHandle;
80 if (
auto fe_ptr = data_ptr->feMethodPtr.lock()) {
85 if (fe_ptr.get() != fe_raw_ptr)
89 const auto fe_ent = fe.numeredEntFiniteElementPtr->getEnt();
91 const auto fe_dim = moab::CN::Dimension(fe_type);
93 auto &gauss_pts = fe.gaussPts;
97 gauss_pts.resize(4, nb_eval_points,
false);
99 &shape_functions(0, 0), &shape_functions(0, 1),
100 &shape_functions(0, 2), &shape_functions(0, 3)};
102 &gauss_pts(0, 0), &gauss_pts(1, 0), &gauss_pts(2, 0)};
105 for (
int nn = 0; nn != nb_eval_points; ++nn) {
106 if (eval_pointentity_handle[nn] == fe_ent) {
107 for (
const int i : {0, 1, 2}) {
108 t_gauss_pts(
i) = t_shape(
i + 1);
110 gauss_pts(3, nb_gauss_pts) = nn;
116 gauss_pts.resize(4, nb_gauss_pts,
true);
117 }
else if (fe_dim == 2) {
118 gauss_pts.resize(3, nb_eval_points,
false);
120 &shape_functions(0, 0), &shape_functions(0, 1),
121 &shape_functions(0, 2)};
123 &gauss_pts(0, 0), &gauss_pts(1, 0)};
125 for (
int nn = 0; nn != nb_eval_points; ++nn) {
126 if (eval_pointentity_handle[nn] == fe_ent) {
127 for (
const int i : {0, 1}) {
128 t_gauss_pts(
i) = t_shape(
i + 1);
130 gauss_pts(2, nb_gauss_pts) = nn;
136 gauss_pts.resize(3, nb_gauss_pts,
true);
139 "Dimension not implemented");
144 <<
"nbEvalOPoints / nbGau_sspt_s: " << nb_eval_points <<
" / "
146 MOFEM_LOG(
"SELF", Sev::noisy) <<
"gauss pts: " << gauss_pts;
151 "Pointer to element does not exists");
155 "Pointer to data does not exists");
162 const double *
const point,
const double distance,
const std::string problem,
163 const std::string finite_element, boost::shared_ptr<SetPtsData> data_ptr,
164 int lower_rank,
int upper_rank, boost::shared_ptr<CacheTuple> cache_ptr,
169 std::vector<EntityHandle> leafs_out;
170 CHKERR data_ptr->treePtr->distance_search(point, distance, leafs_out);
172 for (
auto lit : leafs_out)
176 MOFEM_LOG(
"SELF", Sev::noisy) <<
"tree entities: " << tree_ents;
178 data_ptr->evalPointEntityHandle.resize(data_ptr->nbEvalPoints);
179 std::fill(data_ptr->evalPointEntityHandle.begin(),
180 data_ptr->evalPointEntityHandle.end(), 0);
182 std::vector<double> local_coords;
183 std::vector<double> shape;
185 auto nb_eval_points = data_ptr->nbEvalPoints;
187 for (
auto tet : tree_ents) {
190 CHKERR m_field.
get_moab().get_connectivity(tet, conn, num_nodes,
true);
192 if constexpr (
D == 3) {
194 local_coords.resize(3 * nb_eval_points);
195 shape.resize(4 * nb_eval_points);
197 std::array<double, 12> coords;
198 CHKERR m_field.
get_moab().get_coords(conn, num_nodes, coords.data());
201 coords.data(), &data_ptr->evalPoints[0], nb_eval_points,
203 CHKERR Tools::shapeFunMBTET<3>(&shape[0], &local_coords[0],
204 &local_coords[1], &local_coords[2],
209 &shape[0], &shape[1], &shape[2], &shape[3]};
211 &data_ptr->shapeFunctions(0, 0), &data_ptr->shapeFunctions(0, 1),
212 &data_ptr->shapeFunctions(0, 2), &data_ptr->shapeFunctions(0, 3)};
216 &local_coords[0], &local_coords[1], &local_coords[2]};
218 &(data_ptr->localCoords(0, 0)), &(data_ptr->localCoords(0, 1)),
219 &(data_ptr->localCoords(0, 2))};
221 for (
int n = 0;
n != nb_eval_points; ++
n) {
223 const double eps = data_ptr->eps;
224 if (t_shape(0) >= 0 -
eps && t_shape(0) <= 1 +
eps &&
226 t_shape(1) >= 0 -
eps && t_shape(1) <= 1 +
eps &&
228 t_shape(2) >= 0 -
eps && t_shape(2) <= 1 +
eps &&
230 t_shape(3) >= 0 -
eps && t_shape(3) <= 1 +
eps) {
232 data_ptr->evalPointEntityHandle[
n] = tet;
233 t_shape_data(i4) = t_shape(i4);
234 t_local_data(j3) = t_local(j3);
244 if constexpr (
D == 2) {
246 local_coords.resize(2 * nb_eval_points);
247 shape.resize(3 * nb_eval_points);
249 std::array<double, 9> coords;
250 CHKERR m_field.
get_moab().get_coords(conn, num_nodes, coords.data());
253 coords.data(), &data_ptr->evalPoints[0], nb_eval_points,
255 CHKERR Tools::shapeFunMBTRI<2>(&shape[0], &local_coords[0],
256 &local_coords[1], nb_eval_points);
260 &shape[0], &shape[1], &shape[2]};
262 &data_ptr->shapeFunctions(0, 0), &data_ptr->shapeFunctions(0, 1),
263 &data_ptr->shapeFunctions(0, 2)};
267 &local_coords[0], &local_coords[1]};
268 data_ptr->localCoords.resize(nb_eval_points, 2);
270 &(data_ptr->localCoords(0, 0)), &(data_ptr->localCoords(0, 1))};
272 for (
int n = 0;
n != nb_eval_points; ++
n) {
274 const double eps = data_ptr->eps;
275 if (t_shape(0) >= 0 -
eps && t_shape(0) <= 1 +
eps &&
277 t_shape(1) >= 0 -
eps && t_shape(1) <= 1 +
eps &&
279 t_shape(2) >= 0 -
eps && t_shape(2) <= 1 +
eps) {
281 data_ptr->evalPointEntityHandle[
n] = tet;
282 t_shape_data(i3) = t_shape(i3);
283 t_local_data(j2) = t_local(j2);
296 boost::shared_ptr<NumeredEntFiniteElement_multiIndex> numered_fes(
300 in_tets.insert_list(data_ptr->evalPointEntityHandle.begin(),
301 data_ptr->evalPointEntityHandle.end());
302 in_tets = in_tets.subset_by_dimension(
D);
305 MOFEM_LOG(
"SELF", Sev::noisy) <<
"in tets: " << in_tets << endl;
313 for (
auto peit = in_tets.pair_begin(); peit != in_tets.pair_end(); ++peit) {
318 peit->first, (*fe_miit)->getFEUId()));
322 peit->second, (*fe_miit)->getFEUId()));
323 numered_fes->insert(lo, hi);
326 std::cerr <<
"numered elements:" << std::endl;
327 for (; lo != hi; ++lo)
329 std::cerr << **lo << endl;
332 std::cerr << std::endl;
334 if (
auto fe_ptr = data_ptr->feMethodPtr.lock()) {
337 "Number elements %d to evaluate at proc %d",
342 cache_ptr = boost::make_shared<CacheTuple>();
345 MOFEM_LOG(
"FieldEvaluatorSync", Sev::noisy)
346 <<
"If you call that function many times in the loop consider to "
348 "cache_ptr outside of the loop. Otherwise code can be slow.";
352 lower_rank, upper_rank, numered_fes,
353 bh, cache_ptr, verb);
357 "Pointer to element does not exists");
364 const double *
const point,
const double distance,
const std::string problem,
365 const std::string finite_element, boost::shared_ptr<SetPtsData> data_ptr,
366 int lower_rank,
int upper_rank, boost::shared_ptr<CacheTuple> cache_ptr,
368 return evalFEAtThePoint<3>(point, distance, problem, finite_element, data_ptr,
369 lower_rank, upper_rank, cache_ptr, bh, verb);
373 const double *
const point,
const double distance,
const std::string problem,
374 const std::string finite_element, boost::shared_ptr<SetPtsData> data_ptr,
375 int lower_rank,
int upper_rank, boost::shared_ptr<CacheTuple> cache_ptr,
377 return evalFEAtThePoint<2>(point, distance, problem, finite_element, data_ptr,
378 lower_rank, upper_rank, cache_ptr, bh, verb);
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
#define MOFEM_LOG_C(channel, severity, format,...)
VERBOSITY_LEVELS
Verbosity levels.
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
FTensor::Index< 'n', SPACE_DIM > n
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.
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
virtual const FiniteElement_multiIndex * get_finite_elements() const =0
Get the finite elements object.
virtual EntityHandle get_finite_element_meshset(const std::string name) const =0
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.
virtual MoFEMErrorCode loop_finite_elements(const std::string problem_name, const std::string &fe_name, FEMethod &method, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)=0
Make a loop over finite elements.
FTensor::Index< 'i', SPACE_DIM > i
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
auto type_from_handle(const EntityHandle h)
get type from entity handle
virtual moab::Interface & get_moab()=0
virtual MoFEMErrorCode cache_problem_entities(const std::string prb_name, CacheTupleWeakPtr cache_ptr)=0
Cache variables.
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
UId getLocalUniqueIdCalculate() const
Generate UId for finite element entity.
MoFEMErrorCode operator()(ForcesAndSourcesCore *fe_raw_ptr, int order_row, int order_col, int order_data)
boost::weak_ptr< SetPtsData > dataPtr
Field evaluator interface.
MoFEMErrorCode buildTree3D(boost::shared_ptr< SetPtsData > spd_ptr, const std::string finite_element)
Build spatial tree.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
MoFEMErrorCode buildTree2D(boost::shared_ptr< SetPtsData > spd_ptr, const std::string finite_element)
Build spatial tree.
MoFEMErrorCode evalFEAtThePoint2D(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, boost::shared_ptr< CacheTuple > cache_ptr, MoFEMTypes bh=MF_EXIST, VERBOSITY_LEVELS verb=QUIET)
Evaluate field at artbitray position.
FieldEvaluatorInterface(const MoFEM::Core &core)
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, boost::shared_ptr< CacheTuple > cache_ptr, MoFEMTypes bh=MF_EXIST, VERBOSITY_LEVELS verb=QUIET)
Evaluate field at artbitray position.
MoFEMErrorCode buildTree(boost::shared_ptr< SetPtsData > spd_ptr, const std::string finite_element)
Build spatial tree.
MoFEMErrorCode evalFEAtThePoint(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, boost::shared_ptr< CacheTuple > cache_ptr, MoFEMTypes bh=MF_EXIST, VERBOSITY_LEVELS verb=QUIET)
Evaluate field at artbitray position.
structure to get information form mofem into EntitiesFieldData
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.
keeps basic data about problem
boost::shared_ptr< NumeredEntFiniteElement_multiIndex > numeredFiniteElementsPtr
store finite elements
base class for all interface classes