126 for (
const auto & elem : range)
151 std::vector<Real> new_error_per_cell(1, 0.);
153 new_error_per_cell.resize(patch.size(), 0.);
157 for (
unsigned int var=0; var<
n_vars; var++)
160#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
162 bool is_valid_norm_type =
169 norm_type ==
L_INF ||
176 norm_type ==
L_INF ||
188 bool is_valid_norm_combo =
201 ((norm_type ==
L_INF ||
217 const Order element_order = fe_type.
order + elem->p_level();
223 std::unique_ptr<QBase> qrule =
227 fe->attach_quadrature_rule (qrule.get());
230 const std::vector<Real> & JxW = fe->get_JxW();
231 const std::vector<Point> & q_point = fe->get_xyz();
237 const std::vector<std::vector<Real>> * phi =
nullptr;
242 if (norm_type ==
L2 ||
245 phi = &(fe->get_phi());
247 const std::vector<std::vector<RealGradient>> * dphi =
nullptr;
253 dphi = &(fe->get_dphi());
255#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
256 const std::vector<std::vector<RealTensor>> * d2phi =
nullptr;
259 d2phi = &(fe->get_d2phi());
263 std::vector<dof_id_type> dof_indices;
267 unsigned int matsize = element_order + 1;
270 matsize *= (element_order + 2);
275 matsize *= (element_order + 3);
282 if (norm_type ==
L2 ||
331 for (
const auto & e_p : patch)
341 const unsigned int n_dofs =
342 cast_int<unsigned int>(dof_indices.size());
343 const unsigned int n_qp = qrule->n_points();
347 for (
unsigned int qp=0; qp<n_qp; qp++)
350 std::vector<Real> psi(
specpoly(
dim, element_order, q_point[qp], matsize));
352 const unsigned int psi_size = cast_int<unsigned int>(psi.size());
355 const unsigned int m = Kp.
m(), n = Kp.
n();
356 for (
unsigned int i=0; i<m; i++)
357 for (
unsigned int j=0; j<n; j++)
358 Kp(i,j) += JxW[qp]*psi[i]*psi[j];
360 if (norm_type ==
L2 ||
367 for (
unsigned int i=0; i<n_dofs; i++)
371 for (
unsigned int i=0; i != psi_size; i++)
372 F(i) = JxW[qp]*u_h*psi[i];
382 for (std::size_t i=0; i<n_dofs; i++)
389 for (
unsigned int i=0; i != psi_size; i++)
391 Fx(i) += JxW[qp]*grad_u_h(0)*psi[i];
393 Fy(i) += JxW[qp]*grad_u_h(1)*psi[i];
396 Fz(i) += JxW[qp]*grad_u_h(2)*psi[i];
406 for (
unsigned int i=0; i<n_dofs; i++)
413 for (
unsigned int i=0; i != psi_size; i++)
415 Fx(i) += JxW[qp]*grad_u_h(0)*psi[i];
425 for (
unsigned int i=0; i<n_dofs; i++)
432 for (
unsigned int i=0; i != psi_size; i++)
434 Fy(i) += JxW[qp]*grad_u_h(1)*psi[i];
445 for (
unsigned int i=0; i<n_dofs; i++)
452 for (
unsigned int i=0; i != psi_size; i++)
454 Fz(i) += JxW[qp]*grad_u_h(2)*psi[i];
461#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
466 for (
unsigned int i=0; i<n_dofs; i++)
473 for (
unsigned int i=0; i != psi_size; i++)
475 Fx(i) += JxW[qp]*hess_u_h(0,0)*psi[i];
477 Fy(i) += JxW[qp]*hess_u_h(1,1)*psi[i];
478 Fxy(i) += JxW[qp]*hess_u_h(0,1)*psi[i];
481 Fz(i) += JxW[qp]*hess_u_h(2,2)*psi[i];
482 Fxz(i) += JxW[qp]*hess_u_h(0,2)*psi[i];
483 Fyz(i) += JxW[qp]*hess_u_h(1,2)*psi[i];
487 libmesh_error_msg(
"ERROR: --enable-second-derivatives is required \nfor _sobolev_order == 2!");
501 if (norm_type ==
L2 ||
548 Patch::const_iterator patch_re_it;
549 Patch::const_iterator patch_re_end;
557 patch_re_it = patch.begin();
558 patch_re_end = patch.end();
568 patch_re_it = patch_re.begin();
569 patch_re_end = patch_re.end();
586 for (
unsigned int e = 0 ; patch_re_it != patch_re_end; ++patch_re_it, ++e)
591 const Elem * e_p = *patch_re_it;
616 const unsigned int n_dofs =
617 cast_int<unsigned int>(dof_indices.size());
620 Real element_error = 0;
629 fe->attach_quadrature_rule (&samprule);
632 const unsigned int n_sp =
633 cast_int<unsigned int>(JxW.size());
636 for (
unsigned int sp=0; sp<n_sp; sp++)
640 std::vector<Number> temperr(6,0.0);
642 if (norm_type ==
L2 ||
648 for (
unsigned int i=0; i<n_dofs; i++)
652 std::vector<Real> psi(
specpoly(
dim, element_order, q_point[sp], matsize));
653 for (
unsigned int i=0; i<matsize; i++)
655 temperr[0] += psi[i]*Pu_h(i);
666 for (
unsigned int i=0; i<n_dofs; i++)
671 std::vector<Real> psi(
specpoly(
dim, element_order, q_point[sp], matsize));
673 for (
unsigned int i=0; i<matsize; i++)
675 temperr[0] += psi[i]*Pu_x_h(i);
677 temperr[1] += psi[i]*Pu_y_h(i);
680 temperr[2] += psi[i]*Pu_z_h(i);
683 temperr[0] -= grad_u_h(0);
685 temperr[1] -= grad_u_h(1);
688 temperr[2] -= grad_u_h(2);
696 for (
unsigned int i=0; i<n_dofs; i++)
701 std::vector<Real> psi(
specpoly(
dim, element_order, q_point[sp], matsize));
702 for (
unsigned int i=0; i<matsize; i++)
704 temperr[0] += psi[i]*Pu_x_h(i);
707 temperr[0] -= grad_u_h(0);
715 for (
unsigned int i=0; i<n_dofs; i++)
720 std::vector<Real> psi(
specpoly(
dim, element_order, q_point[sp], matsize));
721 for (
unsigned int i=0; i<matsize; i++)
723 temperr[1] += psi[i]*Pu_y_h(i);
726 temperr[1] -= grad_u_h(1);
735 for (
unsigned int i=0; i<n_dofs; i++)
740 std::vector<Real> psi(
specpoly(
dim, element_order, q_point[sp], matsize));
741 for (
unsigned int i=0; i<matsize; i++)
743 temperr[2] += psi[i]*Pu_z_h(i);
746 temperr[2] -= grad_u_h(2);
752#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
756 for (
unsigned int i=0; i<n_dofs; i++)
761 std::vector<Real> psi(
specpoly(
dim, element_order, q_point[sp], matsize));
762 for (
unsigned int i=0; i<matsize; i++)
764 temperr[0] += psi[i]*Pu_x_h(i);
766 temperr[1] += psi[i]*Pu_y_h(i);
767 temperr[3] += psi[i]*Pu_xy_h(i);
770 temperr[2] += psi[i]*Pu_z_h(i);
771 temperr[4] += psi[i]*Pu_xz_h(i);
772 temperr[5] += psi[i]*Pu_yz_h(i);
776 temperr[0] -= hess_u_h(0,0);
778 temperr[1] -= hess_u_h(1,1);
779 temperr[3] -= hess_u_h(0,1);
782 temperr[2] -= hess_u_h(2,2);
783 temperr[4] -= hess_u_h(0,2);
784 temperr[5] -= hess_u_h(1,2);
787 libmesh_error_msg(
"ERROR: --enable-second-derivatives is required \nfor _sobolev_order == 2!");
798 if (norm_type ==
L_INF)
799 element_error = std::max(element_error, std::abs(weight*temperr[0]));
801 for (
unsigned int i=0; i != LIBMESH_DIM; ++i)
802 element_error = std::max(element_error, std::abs(weight*temperr[i]));
804 for (
unsigned int i=0; i != 6; ++i)
805 element_error = std::max(element_error, std::abs(weight*temperr[i]));
806 else if (norm_type ==
L2)
809 for (
unsigned int i=0; i != LIBMESH_DIM; ++i)
819 for (
unsigned int i=0; i != LIBMESH_DIM; ++i)
822 for (
unsigned int i=3; i != 6; ++i)
828 if (norm_type ==
L_INF ||
832 else if (norm_type ==
L2 ||
851 Patch::const_iterator patch_re_it;
852 Patch::const_iterator patch_re_end;
855 Patch current_elem_patch(
mesh.processor_id());
860 patch_re_it = patch.begin();
861 patch_re_end = patch.end();
871 patch_re_it = current_elem_patch.begin();
872 patch_re_end = current_elem_patch.end();
876 for (
unsigned int i = 0 ; patch_re_it != patch_re_end; ++patch_re_it, ++i)
879 const Elem * e_p = *patch_re_it;
895 (std::sqrt(new_error_per_cell[i]));
905 (new_error_per_cell[i]);
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.