Test one_hex: run on meshes/one_hex_with_tags.h5m with the files D_, T_ and WL_ of meshes/fvs_one_hex and -label_time 0.5. At the vertex with GLOBAL_ID i and label L the files give dose i + 10 L, temperature 300 + i + L and weight loss i / 2 + L, for labels 0, 5 and 12. The output is read back.
434 {
437 const std::vector<int>
labels{0, 5, 12};
438 const std::array<std::function<
double(
int,
int)>, 3> expected{
439 [](
int i,
int l) {
return i + 10. *
l; },
440 [](
int i,
int l) {
return 300. +
i +
l; },
441 [](
int i,
int l) {
return 0.5 *
i +
l; }};
442
446 CHKERR mb.get_entities_by_type(0, MBVERTEX, verts);
447 CHKERR mb.get_entities_by_dimension(0, 3, vols);
448 std::vector<int> ids(verts.size());
449 CHKERR mb.tag_get_data(
mb.globalId_tag(), verts, ids.data());
450
451 int nb_tags = 0, on_elements = 0;
452 double error = 0;
453 std::vector<Tag> tags;
455 for (
auto th : tags) {
461 continue;
462 ++nb_tags;
463 for (auto e : vols) {
465 on_elements +=
mb.tag_get_data(
th, &e, 1, &
v) == MB_SUCCESS;
466 }
467 const int step = std::stoi(
name.substr(prefix.size() + 1));
468 if (step >=
labels.size())
469 continue;
470 std::vector<double>
values(verts.size());
472 for (
int i = 0;
i != verts.size(); ++
i)
473 error = std::max(
475 }
476 }
477
479 int lines = 0;
480 double history_error = 0, time;
481 int step;
482 while (in >> time >> step) {
483 if (lines <
labels.size())
484 history_error =
485 std::max(history_error, std::abs(time - 0.5 *
labels[lines]) +
486 std::abs(step - lines));
487 ++lines;
488 }
489
492 CHKERR testing->checkValue<TestType::SCALAR>(
"history tags on elements",
493 on_elements, 0, {0, 0});
494 CHKERR testing->checkValue<TestType::SCALAR>(
"nodal values", error, 0,
495 {1e-12, 0});
496 CHKERR testing->checkValue<TestType::SCALAR>(
"history lines", lines,
498 CHKERR testing->checkValue<TestType::SCALAR>(
"history times and steps",
499 history_error, 0, {1e-12, 0});
501}
std::map< EntityHandle, int > labels
SmartPetscObj< Vec > values
#define CHKERR
Inline error check.
const double v
phase velocity of light in medium (cm/ns)
FTensor::Index< 'l', 3 > l
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.