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 =
getData<VolEle>(point.data(), point.size/3);
if(auto vol_ele = data_ptr->feMethod.lock()) {
vol_ele->getOpPtrVector().push_back(
new MyOp());
auto cache_ptr = boost::make_shared<CacheTuple>();
CHKERR m_field.cache_problem_entities(prb_ptr->getName(), cache_ptr);
CHKERR m_field.getInterface<FieldEvaluatorInterface>()
"FINITE_ELEMENT_NAME",
data_ptr, m_field.get_comm_rank(),
m_field.get_comm_rank(), cache_ptr);
}
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 getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Volume finite element base.
Operator used to check consistency between local coordinates and global cooridnates for integrated po...
165 {
166 CoreInterface &m_field =
cOre;
168
169 std::vector<EntityHandle> leafs_out;
170 CHKERR data_ptr->treePtr->distance_search(point, distance, leafs_out);
172 for (auto lit : leafs_out)
173 CHKERR m_field.get_moab().get_entities_by_dimension(lit,
D, tree_ents,
174 true);
175
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) {
190 int num_nodes;
191 CHKERR m_field.get_moab().get_connectivity(tet, conn, num_nodes,
true);
192
193 if constexpr (
D == 3) {
194
195 local_coords.resize(3 * nb_eval_points);
196 shape.resize(4 * nb_eval_points);
197
198 std::array<double, 12> coords;
199 CHKERR m_field.get_moab().get_coords(conn, num_nodes, coords.data());
200
202 coords.data(), &data_ptr->evalPoints[0], nb_eval_points,
203 &local_coords[0]);
204 CHKERR Tools::shapeFunMBTET<3>(&shape[0], &local_coords[0],
205 &local_coords[1], &local_coords[2],
206 nb_eval_points);
207
210 &shape[0], &shape[1], &shape[2], &shape[3]};
212 &data_ptr->shapeFunctions(0, 0), &data_ptr->shapeFunctions(0, 1),
213 &data_ptr->shapeFunctions(0, 2), &data_ptr->shapeFunctions(0, 3)};
214
217 &local_coords[0], &local_coords[1], &local_coords[2]};
219 &(data_ptr->localCoords(0, 0)), &(data_ptr->localCoords(0, 1)),
220 &(data_ptr->localCoords(0, 2))};
221
222 for (
int n = 0;
n != nb_eval_points; ++
n) {
223
224 const double eps = data_ptr->eps;
225 if (t_shape(0) >= 0 -
eps && t_shape(0) <= 1 +
eps &&
226
227 t_shape(1) >= 0 -
eps && t_shape(1) <= 1 +
eps &&
228
229 t_shape(2) >= 0 -
eps && t_shape(2) <= 1 +
eps &&
230
231 t_shape(3) >= 0 -
eps && t_shape(3) <= 1 +
eps) {
232
233 data_ptr->evalPointEntityHandle[
n] = tet;
234 t_shape_data(i4) = t_shape(i4);
235 t_local_data(j3) = t_local(j3);
236 }
237
238 ++t_shape;
239 ++t_shape_data;
240 ++t_local;
241 ++t_local_data;
242 }
243 }
244
245 if constexpr (
D == 2) {
246
247 local_coords.resize(2 * nb_eval_points);
248 shape.resize(3 * nb_eval_points);
249
250 std::array<double, 9> coords;
251 CHKERR m_field.get_moab().get_coords(conn, num_nodes, coords.data());
252
254 coords.data(), &data_ptr->evalPoints[0], nb_eval_points,
255 &local_coords[0]);
256 CHKERR Tools::shapeFunMBTRI<2>(&shape[0], &local_coords[0],
257 &local_coords[1], nb_eval_points);
258
261 &shape[0], &shape[1], &shape[2]};
263 &data_ptr->shapeFunctions(0, 0), &data_ptr->shapeFunctions(0, 1),
264 &data_ptr->shapeFunctions(0, 2)};
265
268 &local_coords[0], &local_coords[1]};
269 data_ptr->localCoords.resize(nb_eval_points, 2);
271 &(data_ptr->localCoords(0, 0)), &(data_ptr->localCoords(0, 1))};
272
273 for (
int n = 0;
n != nb_eval_points; ++
n) {
274
275 const double eps = data_ptr->eps;
276 if (t_shape(0) >= 0 -
eps && t_shape(0) <= 1 +
eps &&
277
278 t_shape(1) >= 0 -
eps && t_shape(1) <= 1 +
eps &&
279
280 t_shape(2) >= 0 -
eps && t_shape(2) <= 1 +
eps) {
281
282 data_ptr->evalPointEntityHandle[
n] = tet;
283 t_shape_data(i3) = t_shape(i3);
284 t_local_data(j2) = t_local(j2);
285 }
286
287 ++t_shape;
288 ++t_shape_data;
289 ++t_local;
290 ++t_local_data;
291 }
292 }
293 }
294
295 const Problem *prb_ptr;
296 CHKERR m_field.get_problem(problem, &prb_ptr);
297 boost::shared_ptr<NumeredEntFiniteElement_multiIndex> numered_fes(
299
301 in_tets.insert_list(data_ptr->evalPointEntityHandle.begin(),
302 data_ptr->evalPointEntityHandle.end());
303 in_tets = in_tets.subset_by_dimension(
D);
304
306 MOFEM_LOG(
"SELF", Sev::noisy) <<
"in tets: " << in_tets << endl;
307
308 auto fe_miit =
309 m_field.get_finite_elements()->get<FiniteElement_name_mi_tag>().find(
310 finite_element);
311 if (fe_miit !=
312 m_field.get_finite_elements()->get<FiniteElement_name_mi_tag>().end()) {
313
314 for (auto peit = in_tets.pair_begin(); peit != in_tets.pair_end(); ++peit) {
315
316 auto lo =
317 prb_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>().lower_bound(
319 peit->first, (*fe_miit)->getFEUId()));
320 auto hi =
321 prb_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>().upper_bound(
323 peit->second, (*fe_miit)->getFEUId()));
324 numered_fes->insert(lo, hi);
325
327 std::cerr << "numered elements:" << std::endl;
328 for (; lo != hi; ++lo)
330 std::cerr << **lo << endl;
331 }
333 std::cerr << std::endl;
334
335 if (auto fe_ptr = data_ptr->feMethodPtr.lock()) {
336
338 "Number elements %d to evaluate at proc %d",
339 numered_fes->size(), m_field.get_comm_rank());
341
342 if (!cache_ptr) {
343 cache_ptr = boost::make_shared<CacheTuple>();
344 CHKERR m_field.cache_problem_entities(prb_ptr->getName(), cache_ptr);
345
346 MOFEM_LOG(
"FieldEvaluatorSync", Sev::noisy)
347 << "If you call that function many times in the loop consider to "
348 "set "
349 "cache_ptr outside of the loop. Otherwise code can be slow.";
350 }
351
352 CHKERR m_field.loop_finite_elements(prb_ptr, finite_element, *fe_ptr,
353 lower_rank, upper_rank, numered_fes,
354 bh, cache_ptr, verb);
355
356 } else
358 "Pointer to element does not exists");
359 }
360
362}
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
#define MOFEM_LOG_C(channel, severity, format,...)
@ MOFEM_DATA_INCONSISTENCY
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.
UId getLocalUniqueIdCalculate() const
Generate UId for finite element entity.