122 {
124
125 const int nb_integration_pts = getGaussPts().size2();
126 auto t_w = getFTensor0IntegrationWeight();
129 auto t_grad_val = getFTensor1FromMat<SPACE_DIM>(
131 ->approxGradVals));
132 auto t_hessian_val = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(
134
135
136 auto t_inv_jac = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(
138 auto t_coords = getFTensor1CoordsAtGaussPts();
139
140
141
146
147 const double volume = getMeasure();
148
149
150 std::array<double, 3> error = {0, 0,
151 0};
152
153 for (int gg = 0; gg != nb_integration_pts; ++gg) {
154
155 const double alpha = t_w * volume;
156
157
158
159 double diff = t_val -
fun(t_coords(0), t_coords(1), t_coords(2));
160 error[0] += alpha * pow(diff, 2);
161 auto t_diff_grad =
diff_fun(t_coords(0), t_coords(1), t_coords(2));
162 t_diff_grad(
i) -= t_grad_val(
i);
163
164 error[1] += alpha * t_diff_grad(
i) *
166
168 MOFEM_LOG(
"SELF", Sev::noisy) <<
"t_hessian_val " << t_hessian_push;
169
170
171 if (std::abs(t_hessian_val(0, 1) - t_hessian_val(1, 0)) >
172 std::numeric_limits<float>::epsilon()) {
173 MOFEM_LOG(
"SELF", Sev::error) <<
"t_hessian_val " << t_hessian_val;
175 "Hessian should be symmetric");
176 }
177
178 auto t_diff_hessian =
diff2_fun(t_coords(0), t_coords(1), t_coords(2));
179 t_diff_hessian(
i,
j) -= t_hessian_val(
i,
j);
180 error[2] = t_diff_hessian(
i,
j) * t_diff_hessian(
i,
j);
181
182
183 ++t_w;
184 ++t_val;
185 ++t_grad_val;
186 ++t_hessian_val;
187 ++t_inv_jac;
188 ++t_coords;
189 }
190
191
192 std::array<int, 3> index = {0, 1, 2};
194 ADD_VALUES);
195
197 }
@ MOFEM_DATA_INCONSISTENCY
#define CHKERR
Inline error check.
FTensor::Index< 'i', SPACE_DIM > i
auto diff2_fun
Function second derivative.
auto diff_fun
Function derivative.
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
static auto getFTensor0FromVec(ublas::vector< T, A > &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.