492 {
494 const int nb_integration_pts = getGaussPts().size2();
495 const double area = getMeasure();
496 auto t_w = getFTensor0IntegrationWeight();
498 auto t_val_grad = getFTensor1FromMat<2>(*(
commonDataPtr->approxValsGrad));
499 auto t_flux = getFTensor1FromMat<3>(*(
commonDataPtr->approxFlux));
500 auto t_coords = getFTensor1CoordsAtGaussPts();
503
504 double error_l2 = 0;
505 double error_h1 = 0;
506 double error_ind = 0;
507 for (int gg = 0; gg != nb_integration_pts; ++gg) {
508 const double alpha = t_w * area;
509
511 t_coords(0), t_coords(1), t_coords(2));
512 error_l2 += alpha *
sqr(diff);
513
515 t_coords(0), t_coords(1), t_coords(2));
516 auto t_fun_grad = getFTensor1FromArray<2, 2>(vec);
517 t_diff(
i) = t_val_grad(
i) - t_fun_grad(
i);
518 error_h1 += alpha * t_diff(
i) * t_diff(
i);
519
520 t_diff(
i) = t_val_grad(
i) - t_flux(
i);
521 error_ind += alpha * t_diff(
i) * t_diff(
i);
522
523 ++t_w;
524 ++t_val;
525 ++t_val_grad;
526 ++t_flux;
527 ++t_coords;
528 }
529
530 const EntityHandle ent = getFEEntityHandle();
531 Tag th_error_l2, th_error_h1, th_error_ind;
533 th_error_l2);
535 th_error_h1);
537 th_error_ind);
538
539 double error_l2_norm = sqrt(error_l2);
540 double error_h1_seminorm = sqrt(error_h1);
541 double error_ind_local = sqrt(error_ind);
544 &error_h1_seminorm);
546 &error_ind_local);
547
550
551 constexpr std::array<int, CommonData::LAST_ELEMENT> indices = {
554 std::array<double, CommonData::LAST_ELEMENT> values;
555 values[0] = error_l2;
556 values[1] = error_h1;
557 values[2] = error_ind;
559 indices.data(), values.data(), ADD_VALUES);
561}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#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
static auto getFTensor0FromVec(V &data)
Get tensor rank 0 (scalar) form data vector.
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
static VectorDouble analyticalFunctionGrad(const double x, const double y, const double z)
[Analytical function]
static double analyticalFunction(const double x, const double y, const double z)
[Analytical function]
static MoFEMErrorCode getTagHandle(MoFEM::Interface &m_field, const char *name, DataType type, Tag &tag_handle)
[Source function]
virtual moab::Interface & get_moab()=0