3361 {
3363
3364 if (
tagSense != getSkeletonSense())
3366
3367 auto get_tag = [&](auto name) {
3368 auto &mob = getPtrFE()->mField.get_moab();
3371 return tag;
3372 };
3373
3374 auto get_tag_value = [&](auto &&tag, int dim) {
3375 auto &mob = getPtrFE()->mField.get_moab();
3376 auto face = getSidePtrFE()->getFEEntityHandle();
3377 std::vector<double> value(dim);
3378 CHK_MOAB_THROW(mob.tag_get_data(tag, &face, 1, value.data()),
"set tag");
3379 return value;
3380 };
3381
3382 auto create_tag = [this](const std::string tag_name, const int size) {
3383 double def_VAL[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
3386 th, MB_TAG_CREAT | MB_TAG_SPARSE,
3387 def_VAL);
3389 };
3390
3391 Tag th_cauchy_streess = create_tag(
"CauchyStress", 9);
3392 Tag th_detF = create_tag(
"detF", 1);
3393 Tag th_traction = create_tag(
"traction", 3);
3394 Tag th_disp_error = create_tag(
"DisplacementError", 1);
3395
3396 Tag th_energy = create_tag(
"Energy", 1);
3397 Tag th_young_modulus = create_tag(
"YoungModulus", 1);
3398
3399 const auto nb_gauss_pts = getGaussPts().size2();
3400 auto t_w =
dataAtPts->getFTensorSmallWL2(nb_gauss_pts);
3401 auto t_h =
dataAtPts->getFTensorSmallH(nb_gauss_pts);
3402 auto t_approx_P =
dataAtPts->getFTensorApproxP(nb_gauss_pts);
3403
3404 auto t_normal = getFTensor1NormalsAtGaussPts();
3405 auto t_disp =
dataAtPts->getFTensorSmallWH1(nb_gauss_pts);
3406
3407
3408
3409 if (
dataAtPts->energyAtPts.size() == 0) {
3410
3411 dataAtPts->energyAtPts.resize(nb_gauss_pts);
3413 }
3416
3417 auto next = [&]() {
3418 ++t_w;
3419 ++t_h;
3420 ++t_approx_P;
3421 ++t_normal;
3422 ++t_disp;
3423 ++t_youngs_modulus;
3424 ++t_energy;
3425 };
3426
3431
3432 auto set_float_precision = [](const double x) {
3433 if (std::abs(x) < std::numeric_limits<float>::epsilon())
3434 return 0.;
3435 else
3436 return x;
3437 };
3438
3439
3440 auto save_scal_tag = [&](
auto &
th,
auto v,
const int gg) {
3442 v = set_float_precision(
v);
3445 };
3446
3447
3450 auto save_vec_tag = [&](
auto &
th,
auto &t_d,
const int gg) {
3453 for (
auto &
a :
v.data())
3454 a = set_float_precision(
a);
3456 &*
v.data().begin());
3458 };
3459
3460
3461
3464 &
m(0, 0), &
m(0, 1), &
m(0, 2),
3465
3466 &
m(1, 0), &
m(1, 1), &
m(1, 2),
3467
3468 &
m(2, 0), &
m(2, 1), &
m(2, 2));
3469
3470 auto save_mat_tag = [&](
auto &
th,
auto &t_d,
const int gg) {
3472 t_m(
i,
j) = t_d(
i,
j);
3473 for (
auto &
v :
m.data())
3474 v = set_float_precision(
v);
3476 &*
m.data().begin());
3478 };
3479
3480 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
3481
3483 t_traction(
i) = t_approx_P(
i,
j) * t_normal(
j) / t_normal.
l2();
3484
3486 CHKERR save_vec_tag(th_traction, t_traction, gg);
3487
3488 double u_error = sqrt((t_disp(
i) - t_w(
i)) * (t_disp(
i) - t_w(
i)));
3489 if (!std::isfinite(u_error))
3490 u_error = -1.;
3491 CHKERR save_scal_tag(th_disp_error, u_error, gg);
3492 CHKERR save_scal_tag(th_energy, t_energy, gg);
3494 CHKERR save_scal_tag(th_young_modulus, t_youngs_modulus, gg);
3495
3498 t_cauchy(
i,
j) = (1. / jac) * (t_approx_P(
i,
k) * t_h(
j,
k));
3499 CHKERR save_mat_tag(th_cauchy_streess, t_cauchy, gg);
3501
3502 next();
3503 }
3504
3506}
#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 ...
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
FTensor::Index< 'i', SPACE_DIM > i
const double v
phase velocity of light in medium (cm/ns)
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
VectorBoundedArray< double, 3 > VectorDouble3
static auto getFTensor0FromVec(V &data)
Get tensor rank 0 (scalar) form data vector.
static auto determinantTensor3by3(T &t)
Calculate the determinant of a 3x3 matrix or a tensor of rank 2.
FTensor::Index< 'm', 3 > m
static bool hasNonHomogeneousMaterialBlock