48 istream::int_type next_char = input.peek();
54 if (buff ==
"NURBS_patches")
57 "NURBS_patches requires NURBS FE space");
62 MFEM_ABORT(
"unknown section: " << buff);
103 int g_nddofs = g_ndofs - (g_nvdofs + g_nedofs + g_nfdofs);
105 vi = ei = fi = di = 0;
106 for (
int i = 0; i < num_pieces; i++)
113 int l_nddofs = l_ndofs - (l_nvdofs + l_nedofs + l_nfdofs);
118 for (
int d = 0; d < vdim; d++)
120 memcpy(g_data+vi, l_data, l_nvdofs*
sizeof(
real_t));
123 memcpy(g_data+ei, l_data, l_nedofs*
sizeof(
real_t));
126 memcpy(g_data+fi, l_data, l_nfdofs*
sizeof(
real_t));
129 memcpy(g_data+di, l_data, l_nddofs*
sizeof(
real_t));
136 memcpy(g_data+vdim*vi, l_data, l_nvdofs*
sizeof(
real_t)*vdim);
137 l_data += vdim*l_nvdofs;
138 g_data += vdim*g_nvdofs;
139 memcpy(g_data+vdim*ei, l_data, l_nedofs*
sizeof(
real_t)*vdim);
140 l_data += vdim*l_nedofs;
141 g_data += vdim*g_nedofs;
142 memcpy(g_data+vdim*fi, l_data, l_nfdofs*
sizeof(
real_t)*vdim);
143 l_data += vdim*l_nfdofs;
144 g_data += vdim*g_nfdofs;
145 memcpy(g_data+vdim*di, l_data, l_nddofs*
sizeof(
real_t)*vdim);
146 l_data += vdim*l_nddofs;
147 g_data += vdim*g_nddofs;
191 old_data.
Swap(*
this);
194 T->
Mult(old_data, *
this);
207 const std::shared_ptr<const PRefinementTransferOperator> Tp =
212 old_data.
Swap(*
this);
213 MFEM_VERIFY(Tp->Width() == old_data.
Size(),
214 "Wrong size of PRefinementTransferOperator in UpdatePRef");
217 Tp->Mult(old_data, *
this);
221 MFEM_ABORT(
"Transfer operator undefined in GridFunction::UpdatePRef");
243 MFEM_ASSERT(v.
Size() >= v_offset +
f->GetVSize(),
"");
275 MFEM_ASSERT(tv.
Size() >= tv_offset +
f->GetTrueVSize(),
"");
296 int nfe = ufes->
GetNE();
304 for (
int i = 0; i < nfe; i++)
306 if (subdomain >= 0 && ufes->
GetAttribute(i) != subdomain)
314 u.GetSubVector(udofs, ul);
322 *ffes->
GetFE(i), fl, wcoef);
331 for (
int j = 0; j < fdofs.
Size(); j++)
347 for (
int i = 0; i < count.
Size(); i++)
349 if (count[i] != 0) { flux(i) /= count[i]; }
416 for (
int k = 0; k < n; k++)
419 nval[k] = shape * (&loc_data[dof * vdim]);
425 for (
int k = 0; k < n; k++)
429 nval[k] = shape * (&loc_data[dof * vdim]);
436 DenseMatrix vshape(dof, FElem->
GetDim());
437 for (
int k = 0; k < n; k++)
439 Tr->SetIntPoint(&ElemVert->
IntPoint(k));
441 nval[k] = loc_data * (&vshape(0,vdim));
470 return (DofVal * LocVec);
477 int dof = FElem->
GetDof();
501 for (
int k = 0; k < vdim; k++)
503 val(k) = shape * (&loc_data[dof * k]);
528 int dof = FElem->
GetDof();
529 Vector DofVal(dof), loc_data(dof);
537 for (
int k = 0; k < n; k++)
540 vals(k) = DofVal * loc_data;
546 for (
int k = 0; k < n; k++)
550 vals(k) = DofVal * loc_data;
579 "invalid FE map type");
581 int dof = FElem->
GetDof();
582 Vector DofLap(dof), loc_data(dof);
584 for (
int k = 0; k < n; k++)
589 laps(k) = DofLap * loc_data;
622 "invalid FE map type");
624 int dof = FElem->
GetDof();
632 for (
int k = 0; k < n; k++)
638 for (
int j = 0; j <
size; j++)
640 for (
int d = 0; d < dof; d++)
642 hess(k,j) += DofHes(d,j) * loc_data[d];
722 int comp,
Vector *tr)
const
748 MFEM_ABORT(
"GridFunction::GetValue: Field continuity type \""
750 <<
"on mesh edges.");
763 MFEM_ABORT(
"GridFunction::GetValue: Field continuity type \""
765 <<
"on mesh faces.");
784 MFEM_ASSERT(FET !=
nullptr,
785 "FaceElementTransformation must be valid for a boundary element");
814 MFEM_ABORT(
"GridFunction::GetValue: Unsupported element type \""
832 return (DofVal * LocVec);
847 for (
int j = 0; j < nip; j++)
884 MFEM_ABORT(
"GridFunction::GetVectorValue: Field continuity type \""
886 <<
"on mesh edges.");
899 MFEM_ABORT(
"GridFunction::GetVectorValue: Field continuity type \""
901 <<
"on mesh faces.");
920 MFEM_ASSERT(FET !=
nullptr,
921 "FaceElementTransformation must be valid for a boundary element");
941 MFEM_ASSERT(FET !=
nullptr,
942 "FaceElementTransformation must be valid for a boundary element");
952 MFEM_ABORT(
"GridFunction::GetVectorValue: Unsupported element type \""
954 if (val.
Size() > 0) { val = NAN; }
979 for (
int k = 0; k < vdim; k++)
981 val(k) = shape * (&loc_data[dof * k]);
1006 int dof = FElem->
GetDof();
1024 for (
int j = 0; j < nip; j++)
1030 for (
int k = 0; k < vdim; k++)
1032 vals(k,j) = shape * (&loc_data[dof * k]);
1039 int vdim = std::max(spaceDim, FElem->
GetRangeDim());
1045 for (
int j = 0; j < nip; j++)
1086 MFEM_ASSERT(Transf !=
nullptr,
"FaceElementTransformation cannot be null!");
1093 MFEM_ASSERT(Transf !=
nullptr,
"FaceElementTransformation cannot be null!");
1109 Vector shape, loc_values, orig_loc_values;
1110 int i, j, d, ne, dof, odof, vdim;
1114 for (i = 0; i < ne; i++)
1126 odof = orig_fe->
GetDof();
1127 loc_values.
SetSize(dof * vdim);
1130 for (j = 0; j < dof; j++)
1134 for (d = 0; d < vdim; d++)
1136 loc_values(d*dof+j) = shape * (&orig_loc_values[d * odof]);
1155 Vector shape, loc_values, loc_values_t, orig_loc_values, orig_loc_values_t;
1156 int i, j, d, nbe, dof, odof, vdim;
1160 for (i = 0; i < nbe; i++)
1168 odof = orig_fe->
GetDof();
1169 loc_values.
SetSize(dof * vdim);
1172 for (j = 0; j < dof; j++)
1176 for (d = 0; d < vdim; d++)
1178 loc_values(d*dof+j) = shape * (&orig_loc_values[d * odof]);
1195 const int dof = fe->
GetDof();
1197 const int vdim = std::max(sdim, fe->
GetRangeDim());
1203 Vector loc_data, val(vdim);
1209 for (
int k = 0; k < n; k++)
1215 for (
int d = 0; d < vdim; d++)
1235 for (j = 0; j < ndofs; j++)
1236 for (i = 0; i < vdim; i++)
1238 temp[j+i*ndofs] =
data[k++];
1241 for (i = 0; i <
size; i++)
1269 val(vertices[k]) += vals(k, comp);
1270 overlap[vertices[k]]++;
1274 for (i = 0; i < overlap.
Size(); i++)
1276 val(i) /= overlap[i];
1291 for (
int i = 0; i < new_fes->
GetNE(); i++)
1297 const int dof = fe->
GetDof();
1298 for (
int d = 0; d < vals.
Width(); d++)
1300 for (
int k = 0; k < dof; k++)
1304 vec_field(ind) += s * vals(k, d);
1310 for (
int i = 0; i < overlap.
Size(); i++)
1312 vec_field(i) /= overlap[i];
1325 Vector pt_grad, loc_func;
1326 int i, j, k,
dim, dof, der_dof, ind;
1333 for (i = 0; i < der_fes->
GetNE(); i++)
1342 der_dof = der_fe->
GetDof();
1348 for (j = 0; j < dof; j++)
1349 loc_func(j) = ( (ind=vdofs[comp*dof+j]) >= 0 ) ?
1351 for (k = 0; k < der_dof; k++)
1359 for (j = 0; j <
dim; j++)
1361 a += inv_jac(j, der_comp) * pt_grad(j);
1363 der(der_dofs[k]) +=
a;
1364 zones_per_dof[der_dofs[k]]++;
1375 for (
int i = 0; i < overlap.
Size(); i++)
1377 der(i) /= overlap[i];
1394 MultAtB(loc_data_mat, dshape, gh);
1408 "invalid FE map type");
1413 for (
int i = 0; i < Jinv.
Width(); i++)
1415 for (
int j = 0; j < Jinv.
Height(); j++)
1417 div_v += grad_hat(i, j) * Jinv(j, i);
1434 return (loc_data * divshape) / T.
Weight();
1476 MFEM_ABORT(
"GridFunction::GetDivergence: Unsupported element type \""
1494 "invalid FE map type");
1500 Mult(grad_hat, Jinv, grad);
1505 curl(0) = grad(2,1) - grad(1,2);
1506 curl(1) = grad(0,2) - grad(2,0);
1507 curl(2) = grad(1,0) - grad(0,1);
1509 else if (grad.
Height() == 2)
1512 curl(0) = grad(1,0) - grad(0,1);
1569 MFEM_ABORT(
"GridFunction::GetCurl: Unsupported element type \""
1583 "invalid FE map type");
1584 MFEM_ASSERT(
fes->
GetVDim() == 1,
"Defined for scalar functions.");
1634 MFEM_ABORT(
"GridFunction::GetGradient: Unsupported element type \""
1644 int elNo = tr.ElementNo;
1657 tr.SetIntPoint(&ip);
1677 Mult(grad_hat, Jinv, grad);
1716 MFEM_ABORT(
"GridFunction::GetVectorGradient: "
1717 "Unsupported element type \"" << T.
ElementType <<
"\"");
1729 Vector loc_avgs, loc_this;
1734 for (
int i = 0; i <
fes->
GetNE(); i++)
1746 loc_mass.
Mult(loc_this, loc_avgs);
1753 loc_mass.
Mult(loc_this, loc_avgs);
1756 for (
int i = 0; i < avgs.
Size(); i++)
1758 avgs(i) /= int_psi(i);
1779 if (!mesh->
GetNE()) {
return; }
1790 MFEM_VERIFY(vdim == src.
fes->
GetVDim(),
"incompatible vector dimensions!");
1795 for (
int i = 0; i < mesh->
GetNE(); i++)
1812 for (
int vd = 0; vd < vdim; vd++)
1839 MFEM_ASSERT(weights.
Size() ==
size,
"Different # of weights and dofs.");
1840 MFEM_ASSERT(lo_.
Size() ==
size,
"Different # of lower bounds and dofs.");
1841 MFEM_ASSERT(hi_.
Size() ==
size,
"Different # of upper bounds and dofs.");
1852 slbqp.
Mult(vals, new_vals);
1877 if (max_val <= min_)
1888 if (min_ <= min_val && max_val <= max_)
1894 minv = (min_ > min_val) ? min_ : min_val;
1895 maxv = (max_ < max_val) ? max_ : max_val;
1908 R->
Mult(*
this, tmp);
1909 P->
Mult(tmp, *
this);
1927 for (j = 0; j < vertices.
Size(); j++)
1929 nval(vertices[j]) += values[j];
1930 overlap[vertices[j]]++;
1933 for (i = 0; i < overlap.
Size(); i++)
1935 nval(i) /= overlap[i];
1946 for (
int i = 0; i <
fes->
GetNE(); i++)
1950 for (
int j = 0; j < vdofs.
Size(); j++)
1952 elem_per_vdof[vdofs[j]]++;
1971 for (
int i = 0; i <
fes->
GetNE(); i++)
1979 for (
int j = 0; j < vdofs.
Size(); j++)
1983 MFEM_VERIFY(vals[j] != 0.0,
1984 "Coefficient has zeros, harmonic avg is undefined!");
1985 (*this)(vdofs[j]) += 1.0 / vals[j];
1989 (*this)(vdofs[j]) += vals[j];
1991 else { MFEM_ABORT(
"Not implemented"); }
1993 zones_per_vdof[vdofs[j]]++;
2012 for (
int i = 0; i <
fes->
GetNE(); i++)
2020 for (
int j = 0; j < vdofs.
Size(); j++)
2037 MFEM_VERIFY(vals[j] != 0.0,
2038 "Coefficient has zeros, harmonic avg is undefined!");
2039 (*this)(ldof) += isign / vals[j];
2043 (*this)(ldof) += isign*vals[j];
2046 else { MFEM_ABORT(
"Not implemented"); }
2048 zones_per_vdof[ldof]++;
2071 const int fdof = fe->
GetDof();
2076 for (
int j = 0; j < fdof; j++)
2080 if (vcoeff) { vcoeff->
Eval(vc, *transf, ip); }
2081 for (
int d = 0; d < vdim; d++)
2083 if (!vcoeff && !coeff[d]) {
continue; }
2085 real_t val = vcoeff ? vc(d) : coeff[d]->
Eval(*transf, ip);
2086 int ind = vdofs[fdof*d+j];
2089 val = -val, ind = -1-ind;
2091 if (++values_counter[ind] == 1)
2097 (*this)(ind) += val;
2118 Array<int> bdr_edges, bdr_vertices, bdr_faces;
2126 for (
int d = 0; d < vdim; d++)
2128 if (!coeff[d]) {
continue; }
2130 fe.Project(*coeff[d], transf, vals);
2131 for (
int k = 0; k < vals.
Size(); k++)
2133 const int ind = vdofs[d*vals.
Size()+k];
2134 if (++values_counter[ind] == 1)
2136 (*this)(ind) = vals(k);
2140 (*this)(ind) += vals(k);
2147 vals.
SetSize(vdim*fe.GetDof());
2148 fe.Project(*vcoeff, transf, vals);
2149 for (
int k = 0; k < vals.
Size(); k++)
2151 const int ind = vdofs[k];
2152 if (++values_counter[ind] == 1)
2154 (*this)(ind) = vals(k);
2158 (*this)(ind) += vals(k);
2164 for (
auto edge : bdr_edges)
2167 if (vdofs.
Size() == 0) {
continue; }
2171 mark_dofs(*transf, *fe);
2174 for (
auto face : bdr_faces)
2177 if (vdofs.
Size() == 0) {
continue; }
2181 mark_dofs(*transf, *fe);
2189 for (
int i = 0; i < dofs.
Size(); i++)
2193 if (k < 0) { k = -1 - k; val = -val; }
2194 if (++values_counter[k] == 1)
2229 fe->
Project(vcoeff, *T, lvec);
2231 accumulate_dofs(dofs, lvec, *
this, values_counter);
2239 Array<int> bdr_edges, bdr_vertices, bdr_faces;
2242 for (
auto edge : bdr_edges)
2245 if (dofs.
Size() == 0) {
continue; }
2250 fe->
Project(vcoeff, *T, lvec);
2251 accumulate_dofs(dofs, lvec, *
this, values_counter);
2254 for (
auto face : bdr_faces)
2257 if (dofs.
Size() == 0) {
continue; }
2262 fe->
Project(vcoeff, *T, lvec);
2263 accumulate_dofs(dofs, lvec, *
this, values_counter);
2273 for (
int i = 0; i <
size; i++)
2275 const int nz = zones_per_vdof[i];
2276 if (nz) { (*this)(i) /= nz; }
2281 for (
int i = 0; i <
size; i++)
2283 const int nz = zones_per_vdof[i];
2284 if (nz) { (*this)(i) = nz/(*
this)(i); }
2289 MFEM_ABORT(
"invalid AvgType");
2311 for (
int i = 0; i < mesh->
GetNV(); i++)
2315 if (dist < min_dist)
2325 if (min_dist >= delta_coeff.
Tol())
2334 Vector vals, loc_mass_vals;
2335 for (
int i = 0; i < mesh->
GetNE(); i++)
2338 for (
int j = 0; j < vertices.
Size(); j++)
2339 if (vertices[j] == v_idx)
2353 loc_mass.
Mult(vals, loc_mass_vals);
2354 integral += loc_mass_vals.
Sum();
2365 if (delta_c == NULL)
2372 for (
int i = 0; i <
fes->
GetNE(); i++)
2417 (*this) *= (delta_c->
Scale() / integral);
2428 for (
int i = 0; i < dofs.
Size(); i++)
2441 (*this)(vdof) = coeff.
Eval(*T, ip);
2504 for (
int i = 0; i < dofs.
Size(); i++)
2516 vcoeff.
Eval(val, *T, ip);
2520 (*this)(vdof) = val(vd);
2553 int i, j, fdof, d, ind, vdim;
2569 for (j = 0; j < fdof; j++)
2573 for (d = 0; d < vdim; d++)
2575 if (!coeff[d]) {
continue; }
2577 val = coeff[d]->
Eval(*transf, ip);
2578 if ( (ind = vdofs[fdof*d+j]) < 0 )
2580 val = -val, ind = -1-ind;
2600 for (
int i = 0; i <
fes->
GetNE(); i++)
2609 for (
int j = 0; j < vdofs.
Size(); j++)
2611 if (attr > dof_attr[vdofs[j]])
2613 (*this)(vdofs[j]) = vals[j];
2614 dof_attr[vdofs[j]] = attr;
2656 for (
int i = 0; i < values_counter.
Size(); i++)
2658 MFEM_ASSERT(
bool(values_counter[i]) ==
bool(ess_vdofs_marker[i]),
2674 ess_vdofs_marker = 0;
2678 if (!coeff[i]) {
continue; }
2680 for (
int j = 0; j<
Size(); j++)
2682 ess_vdofs_marker[j] = bool(ess_vdofs_marker[j]) ||
2683 bool(component_dof_marker[j]);
2686 for (
int i = 0; i < values_counter.
Size(); i++)
2688 MFEM_ASSERT(
bool(values_counter[i]) == ess_vdofs_marker[i],
2724 vcoeff.
Eval(vc, *T, ip);
2727 lvec.
Add(ip.
weight * (vc * nor), shape);
2755 vcoeff.
Eval(vc, *T, ip);
2757 lvec(j) = (vc * nor);
2778 for (
int i = 0; i < values_counter.
Size(); i++)
2780 MFEM_ASSERT(
bool(values_counter[i]) ==
bool(ess_vdofs_marker[i]),
2795 int fdof, d, i, intorder, j, k;
2799 if (elems != NULL && (*elems)[i] == 0) {
continue; }
2824 for (k = 0; k < fdof; k++)
2825 if (vdofs[fdof*d+k] >= 0)
2827 a += (*this)(vdofs[fdof*d+k]) * shape(k);
2831 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
2833 a -= exsol[d]->
Eval(*transf, ip);
2838 error += fabs(elem_error);
2854 for (
int i = 0; i <
fes->
GetNE(); i++)
2856 if (elems != NULL && (*elems)[i] == 0) {
continue; }
2858 int intorder = 2*fe->
GetOrder() + 3;
2871 exsol.
Eval(exact_vals, *T, *ir);
2874 vals.
Norm2(loc_errs);
2879 elem_error += ip.
weight * T->
Weight() * (loc_errs(j) * loc_errs(j));
2882 error += fabs(elem_error);
2918 exgrad->
Eval(vec,*Tr,ip);
2922 return sqrt(fabs(error));
2937 for (
int i = 0; i <
fes->
GetNE(); i++)
2958 exgrad->
Eval(vec,*Tr,ip);
2963 error += fabs(elem_error);
2980 for (
int i = 0; i <
fes->
GetNE(); i++)
3001 excurl->
Eval(vec,*Tr,ip);
3003 elem_error += ip.
weight * Tr->
Weight() * ( vec * vec );
3006 error += fabs(elem_error);
3021 for (
int i = 0; i <
fes->
GetNE(); i++)
3045 error += fabs(elem_error);
3056 int fdof, intorder, k;
3061 Vector shape, el_dofs, err_val, ell_coeff_val;
3083 intorder = 2 * intorder;
3097 transf = face_elem_transf->
Elem1;
3103 for (k = 0; k < fdof; k++)
3106 el_dofs(k) = (*this)(vdofs[k]);
3110 el_dofs(k) = - (*this)(-1-vdofs[k]);
3117 ell_coeff_val(j) = ell_coeff->
Eval(*transf, eip);
3118 err_val(j) = exsol->
Eval(*transf, eip) - (shape * el_dofs);
3124 transf = face_elem_transf->
Elem2;
3130 for (k = 0; k < fdof; k++)
3133 el_dofs(k) = (*this)(vdofs[k]);
3137 el_dofs(k) = - (*this)(-1-vdofs[k]);
3144 ell_coeff_val(j) += ell_coeff->
Eval(*transf, eip);
3145 ell_coeff_val(j) *= 0.5;
3146 err_val(j) -= (exsol->
Eval(*transf, eip) - (shape * el_dofs));
3151 transf = face_elem_transf;
3157 face_error += (ip.
weight * nu * ell_coeff_val(j) *
3159 err_val(j) * err_val(j));
3162 error += fabs(face_error);
3180 int norm_type)
const
3191 return sqrt(error1 * error1 + error2 * error2);
3200 return sqrt(L2error*L2error + GradError*GradError);
3209 return sqrt(L2error*L2error + DivError*DivError);
3218 return sqrt(L2error*L2error + CurlError*CurlError);
3229 int fdof, d, i, intorder, j, k;
3256 for (k = 0; k < fdof; k++)
3257 if (vdofs[fdof*d+k] >= 0)
3259 a += (*this)(vdofs[fdof*d+k]) * shape(k);
3263 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
3265 a -= exsol[d]->
Eval(*transf, ip);
3282 int i, fdof,
dim, intorder, j, k;
3286 Vector e_grad, a_grad, shape, el_dofs, err_val, ell_coeff_val;
3298 for (i = 0; i < mesh->
GetNE(); i++)
3300 if (elems != NULL && (*elems)[i] == 0) {
continue; }
3318 for (k = 0; k < fdof; k++)
3321 el_dofs(k) = (*this)(vdofs[k]);
3325 el_dofs(k) = -(*this)(-1-vdofs[k]);
3332 a = (el_dofs * shape) - (exsol->
Eval(*transf, ip));
3335 error += fabs(elem_error);
3339 for (i = 0; i < mesh->
GetNE(); i++)
3341 if (elems != NULL && (*elems)[i] == 0) {
continue; }
3360 for (k = 0; k < fdof; k++)
3363 el_dofs(k) = (*this)(vdofs[k]);
3367 el_dofs(k) = -(*this)(-1-vdofs[k]);
3374 exgrad->
Eval(e_grad, *transf, ip);
3376 Mult(dshape, Jinv, dshapet);
3381 error += fabs(elem_error);
3397 for (
int i = 0; i <
fes->
GetNE(); i++)
3399 if (elems != NULL && (*elems)[i] == 0) {
continue; }
3408 int intorder = 2*fe->
GetOrder() + 3;
3418 real_t diff = fabs(vals(j) - exsol.
Eval(*T, ip));
3421 diff = pow(diff,
p);
3424 diff *= weight->
Eval(*T, ip);
3432 diff *= weight->
Eval(*T, ip);
3434 error = std::max(error, diff);
3440 error += fabs(elem_error);
3446 error = pow(error, 1./
p);
3458 "Incorrect size for result vector");
3465 for (
int i = 0; i <
fes->
GetNE(); i++)
3475 int intorder = 2*fe->
GetOrder() + 3;
3484 real_t diff = fabs(vals(j) - exsol.
Eval(*T, ip));
3487 diff = pow(diff,
p);
3490 diff *= weight->
Eval(*T, ip);
3498 diff *= weight->
Eval(*T, ip);
3500 error[i] = std::max(error[i], diff);
3506 error[i] = pow(fabs(error[i]), 1./
p);
3522 for (
int i = 0; i <
fes->
GetNE(); i++)
3532 int intorder = 2*fe->
GetOrder() + 3;
3538 exsol.
Eval(exact_vals, *T, *ir);
3545 vals.
Norm2(loc_errs);
3549 v_weight->
Eval(exact_vals, *T, *ir);
3552 for (
int j = 0; j < vals.
Width(); j++)
3555 for (
int d = 0; d < vals.
Height(); d++)
3557 errj += vals(d,j)*exact_vals(d,j);
3559 loc_errs(j) = fabs(errj);
3566 real_t errj = loc_errs(j);
3569 errj = pow(errj,
p);
3572 errj *= weight->
Eval(*T, ip);
3580 errj *= weight->
Eval(*T, ip);
3582 error = std::max(error, errj);
3588 error += fabs(elem_error);
3594 error = pow(error, 1./
p);
3608 "Incorrect size for result vector");
3616 for (
int i = 0; i <
fes->
GetNE(); i++)
3626 int intorder = 2*fe->
GetOrder() + 3;
3631 exsol.
Eval(exact_vals, *T, *ir);
3638 vals.
Norm2(loc_errs);
3642 v_weight->
Eval(exact_vals, *T, *ir);
3645 for (
int j = 0; j < vals.
Width(); j++)
3648 for (
int d = 0; d < vals.
Height(); d++)
3650 errj += vals(d,j)*exact_vals(d,j);
3652 loc_errs(j) = fabs(errj);
3659 real_t errj = loc_errs(j);
3662 errj = pow(errj,
p);
3665 errj *= weight->
Eval(*T, ip);
3673 errj *= weight->
Eval(*T, ip);
3675 error[i] = std::max(error[i], errj);
3681 error[i] = pow(fabs(error[i]), 1./
p);
3707 os <<
"NURBS_patches\n";
3726 ofstream ofs(fname);
3727 ofs.precision(precision);
3731#ifdef MFEM_USE_ADIOS2
3733 const std::string& variable_name,
3736 os.
Save(*
this, variable_name, type);
3752 os <<
"SCALARS " << field_name <<
" double 1\n"
3753 <<
"LOOKUP_TABLE default\n";
3754 for (
int i = 0; i < mesh->
GetNE(); i++)
3761 for (
int j = 0; j < val.
Size(); j++)
3763 os << val(j) <<
'\n';
3767 else if ( (vec_dim == 2 || vec_dim == 3) && mesh->
SpaceDimension() > 1)
3770 os <<
"VECTORS " << field_name <<
" double\n";
3771 for (
int i = 0; i < mesh->
GetNE(); i++)
3780 for (
int j = 0; j < vval.
Width(); j++)
3782 os << vval(0, j) <<
' ' << vval(1, j) <<
' ';
3798 for (
int vd = 0; vd < vec_dim; vd++)
3800 os <<
"SCALARS " << field_name << vd <<
" double 1\n"
3801 <<
"LOOKUP_TABLE default\n";
3802 for (
int i = 0; i < mesh->
GetNE(); i++)
3809 for (
int j = 0; j < val.
Size(); j++)
3811 os << val(j) <<
'\n';
3822 real_t v1[3] = { p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] };
3823 real_t v2[3] = { p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2] };
3824 real_t n[] = { v1[1] * v2[2] - v1[2] * v2[1],
3825 v1[2] * v2[0] - v1[0] * v2[2],
3826 v1[0] * v2[1] - v1[1] * v2[0]
3828 real_t rl = 1.0 / sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);
3829 n[0] *= rl; n[1] *= rl; n[2] *= rl;
3831 os <<
" facet normal " << n[0] <<
' ' << n[1] <<
' ' << n[2]
3833 <<
"\n vertex " << p1[0] <<
' ' << p1[1] <<
' ' << p1[2]
3834 <<
"\n vertex " << p2[0] <<
' ' << p2[1] <<
' ' << p2[2]
3835 <<
"\n vertex " << p3[0] <<
' ' << p3[1] <<
' ' << p3[2]
3836 <<
"\n endloop\n endfacet\n";
3854 os <<
"solid GridFunction\n";
3856 bbox[0][0] = bbox[0][1] = bbox[1][0] = bbox[1][1] =
3857 bbox[2][0] = bbox[2][1] = 0.0;
3858 for (i = 0; i < mesh->
GetNE(); i++)
3865 for (k = 0; k < RG.
Size()/n; k++)
3867 for (j = 0; j < n; j++)
3870 pts[j][0] = pointmat(0,l);
3871 pts[j][1] = pointmat(1,l);
3872 pts[j][2] = values(l);
3888 bbox[0][0] = pointmat(0,0);
3889 bbox[0][1] = pointmat(0,0);
3890 bbox[1][0] = pointmat(1,0);
3891 bbox[1][1] = pointmat(1,0);
3892 bbox[2][0] = values(0);
3893 bbox[2][1] = values(0);
3896 for (j = 0; j < values.
Size(); j++)
3898 if (bbox[0][0] > pointmat(0,j))
3900 bbox[0][0] = pointmat(0,j);
3902 if (bbox[0][1] < pointmat(0,j))
3904 bbox[0][1] = pointmat(0,j);
3906 if (bbox[1][0] > pointmat(1,j))
3908 bbox[1][0] = pointmat(1,j);
3910 if (bbox[1][1] < pointmat(1,j))
3912 bbox[1][1] = pointmat(1,j);
3914 if (bbox[2][0] > values(j))
3916 bbox[2][0] = values(j);
3918 if (bbox[2][1] < values(j))
3920 bbox[2][1] = values(j);
3925 mfem::out <<
"[xmin,xmax] = [" << bbox[0][0] <<
',' << bbox[0][1] <<
"]\n"
3926 <<
"[ymin,ymax] = [" << bbox[1][0] <<
',' << bbox[1][1] <<
"]\n"
3927 <<
"[zmin,zmax] = [" << bbox[2][0] <<
',' << bbox[2][1] <<
']'
3930 os <<
"endsolid GridFunction" << endl;
3947 MFEM_ASSERT(new_vertex.
Size() == mesh->
GetNV(),
"");
3951 for (
int i = 0; i < new_vertex.
Size(); i++)
3953 old_vertex[new_vertex[i]] = i;
3960 for (
int i = 0; i < mesh->
GetNV(); i++)
3965 for (
int j = 0; j < new_vdofs.
Size(); j++)
3967 tmp(new_vdofs[j]) = (*this)(old_vdofs[j]);
3973 for (
int i = 0; i < mesh->
GetNEdges(); i++)
3976 if (old_vertex[ev[0]] > old_vertex[ev[1]])
3981 for (
int k = 0; k < dofs.
Size(); k++)
3983 int new_dof = dofs[k];
3984 int old_dof = dofs[(ind[k] < 0) ? -1-ind[k] : ind[k]];
3991 real_t sign = (ind[k] < 0) ? -1.0 : 1.0;
3992 tmp(new_vdof) = sign * (*this)(old_vdof);
4019 P.
Mult(*
this, *xMax);
4022 return std::unique_ptr<GridFunction>(xMax);
4029 int with_subdomains,
4037 int nfe = ufes->
GetNE();
4041 Vector ul, fl, fla, d_xyz;
4051 if (with_subdomains)
4056 real_t total_error = 0.0;
4057 for (
int s = 1; s <= nsd; s++)
4060 u.ComputeFlux(blfi, flux, with_coeff, (with_subdomains ? s : -1));
4062 for (
int i = 0; i < nfe; i++)
4064 if (with_subdomains && ufes->
GetAttribute(i) != s) {
continue; }
4069 u.GetSubVector(udofs, ul);
4082 *ffes->
GetFE(i), fl, with_coeff);
4087 (aniso_flags ? &d_xyz : NULL));
4089 error_estimates(i) = std::sqrt(eng);
4095 for (
int k = 0; k <
dim; k++)
4102 for (
int k = 0; k <
dim; k++)
4104 if (d_xyz[k] / sum > thresh) { flag |= (1 << k); }
4107 (*aniso_flags)[i] = flag;
4115 auto process_local_error = total_error;
4116 MPI_Allreduce(&process_local_error, &total_error, 1,
4118 MPI_SUM, pfes->GetComm());
4121 return std::sqrt(total_error);
4133 MFEM_VERIFY(
dim >= 1,
"dim must be positive");
4134 MFEM_VERIFY(
dim <= 3,
"dim cannot be greater than 3");
4135 MFEM_VERIFY(order >= 0,
"order cannot be negative");
4137 bool rotate = (angle != 0.0) || (midpoint->
Norml2() != 0.0);
4146 x[0] = tmp[0]*cos(-angle) - tmp[1]*sin(-angle);
4147 x[1] = tmp[0]*sin(-angle) + tmp[1]*cos(-angle);
4156 real_t x1 = (x(0) - xmin(0))/(xmax(0)-xmin(0)), x2, x3;
4157 Vector poly_x(order+1), poly_y(order+1), poly_z(order+1);
4161 x2 = (x(1)-xmin(1))/(xmax(1)-xmin(1));
4166 x3 = (x(2)-xmin(2))/(xmax(2)-xmin(2));
4170 int basis_dimension =
static_cast<int>(pow(order+1,
dim));
4171 poly.
SetSize(basis_dimension);
4176 for (
int i = 0; i <= order; i++)
4178 poly(i) = poly_x(i);
4184 for (
int j = 0; j <= order; j++)
4186 for (
int i = 0; i <= order; i++)
4188 int cnt = i + (order+1) * j;
4189 poly(cnt) = poly_x(i) * poly_y(j);
4196 for (
int k = 0; k <= order; k++)
4198 for (
int j = 0; j <= order; j++)
4200 for (
int i = 0; i <= order; i++)
4202 int cnt = i + (order+1) * j + (order+1) * (order+1) * k;
4203 poly(cnt) = poly_x(i) * poly_y(j) * poly_z(k);
4211 MFEM_ABORT(
"TensorProductLegendre: invalid value of dim");
4227 int num_elems = patch.
Size();
4237 if (
rotate && iface >= 0)
4243 physical_diff = 0.0;
4246 for (
int i = 0; i < 2; i++)
4249 Tr.
Transform(reference_pt, physical_pt);
4250 midpoint += physical_pt;
4251 physical_pt *= pow(-1.0,i);
4252 physical_diff += physical_pt;
4255 angle = atan2(physical_diff(1),physical_diff(0));
4258 for (
int i = 0; i < num_elems; i++)
4260 int ielem = patch[i];
4271 transip -= midpoint;
4274 transip[0] = tmp[0]*cos(-angle) - tmp[1]*sin(-angle);
4275 transip[1] = tmp[0]*sin(-angle) + tmp[1]*cos(-angle);
4277 for (
int d = 0; d <
dim; d++) { xmax(d) = max(xmax(d), transip(d)); }
4278 for (
int d = 0; d <
dim; d++) { xmin(d) = min(xmin(d), transip(d)); }
4286 bool subdomain_reconstruction,
4290 MFEM_VERIFY(tichonov_coeff >= 0.0,
"tichonov_coeff cannot be negative");
4297 int nfe = ufes->
GetNE();
4298 int nfaces = ufes->
GetNF();
4305 error_estimates = 0.0;
4316 if (subdomain_reconstruction)
4321 real_t total_error = 0.0;
4322 for (
int iface = 0; iface < nfaces; iface++)
4329 patch[0] = el1; patch[1] = el2;
4332 if (el1 == -1 || el2 == -1)
4343 if (el1_attr != el2_attr) {
continue; }
4352 int num_basis_functions =
static_cast<int>(pow(patch_order+1,
dim));
4353 int flux_order = 2*patch_order + 1;
4362 xmin, xmax, angle, midpoint, iface);
4367 for (
int i = 0; i < patch.
Size(); i++)
4369 int ielem = patch[i];
4375 u.GetSubVector(udofs, ul);
4383 *dummy, fl, with_coeff, ir);
4387 for (
int k = 0; k < num_integration_pts; k++)
4399 for (
int l = 0; l < num_basis_functions; l++)
4402 for (
int n = 0; n < sdim; n++)
4404 b[l + n * num_basis_functions] +=
p(l) * fl(k + n * num_integration_pts);
4416 for (
int i = 0; i < num_basis_functions; i++)
4418 A(i,i) += tichonov_coeff;
4425 if (!lu.
Factor(num_basis_functions,TOL))
4428 mfem::out <<
"LSZZErrorEstimator: Matrix A is singular.\t"
4429 <<
"Consider increasing tichonov_coeff." << endl;
4430 for (
int i = 0; i < num_basis_functions; i++)
4434 lu.
Factor(num_basis_functions,TOL);
4436 lu.
Solve(num_basis_functions, sdim,
b);
4444 for (
int i = 0; i < num_basis_functions; i++)
4446 for (
int j = 0; j < sdim; j++)
4448 f(j) +=
b[i + j * num_basis_functions] *
p(i);
4455 real_t element_error = 0.0;
4456 real_t patch_error = 0.0;
4457 for (
int i = 0; i < patch.
Size(); i++)
4459 int ielem = patch[i];
4460 element_error =
u.ComputeElementGradError(ielem, &global_poly);
4461 element_error *= element_error;
4462 patch_error += element_error;
4463 error_estimates(ielem) += element_error;
4467 total_error += patch_error;
4475 for (
int ielem = 0; ielem < nfe; ielem++)
4477 if (counters[ielem] == 0)
4479 error_estimates(ielem) =
infinity();
4483 error_estimates(ielem) /= counters[ielem]/2.0;
4484 error_estimates(ielem) = sqrt(error_estimates(ielem));
4487 return std::sqrt(total_error/
dim);
4508 for (
int j = 0; j < nip; j++)
4520 errj = pow(errj,
p);
4525 norm = std::max(norm, errj);
4532 norm = pow(fabs(norm), 1./
p);
4545 return sol_in.
Eval(*T_in, ip);
4556 string cname = name;
4557 if (cname ==
"Linear")
4561 else if (cname ==
"Quadratic")
4565 else if (cname ==
"Cubic")
4569 else if (!strncmp(name,
"H1_", 3))
4573 else if (!strncmp(name,
"H1Pos_", 6))
4578 else if (!strncmp(name,
"L2_T", 4))
4582 else if (!strncmp(name,
"L2_", 3))
4586 else if (!strncmp(name,
"L2Int_", 6))
4593 mfem::err <<
"Extrude1DGridFunction : unknown FE collection : "
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int Size() const
Return the logical size of the array.
@ GaussLegendre
Open type.
Conjugate gradient method.
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the Conjugate Gradient method.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
Piecewise-(bi)cubic continuous finite elements.
Delta function coefficient optionally multiplied by a weight coefficient and a scaled time dependent ...
Coefficient * Weight()
See SetWeight() for description of the weight Coefficient.
real_t Scale()
Return the scale factor times the optional time dependent function. Returns with when not set by th...
real_t Tol()
Return the tolerance used to identify the mesh vertices.
Data type dense matrix using column-major storage.
void Mult(const real_t *x, real_t *y) const
Matrix vector multiplication.
void MultTranspose(const real_t *x, real_t *y) const
Multiply a vector with the transpose matrix.
void GetColumnReference(int c, Vector &col)
real_t * Data() const
Returns the matrix data array.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
void Norm2(real_t *v) const
Take the 2-norm of the columns of A and store in v.
Class for domain integration .
Class used for extruding scalar GridFunctions.
real_t Eval(ElementTransformation &T, const IntegrationPoint &ip) override
Evaluate the coefficient in the element described by T at the point ip.
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
virtual const int * DofOrderForOrientation(Geometry::Type GeomType, int Or) const =0
Returns an array, say p, that maps a local permuted index i to a local base index: base_i = p[i].
static FiniteElementCollection * New(const char *name)
Factory method: return a newly allocated FiniteElementCollection according to the given name.
virtual int GetContType() const =0
virtual FiniteElementCollection * Clone(int p) const
Instantiate a new collection of the same type with a different order.
virtual const char * Name() const
@ CONTINUOUS
Field is continuous across element interfaces.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
void Save(std::ostream &out) const
Save finite element space to output stream out.
int GetNVDofs() const
Number of all scalar vertex dofs.
int GetVectorDim() const
Return the total dimension of a vector in the space.
void DofsToVDofs(Array< int > &dofs, int ndofs=-1) const
Compute the full set of vdofs corresponding to each entry in dofs.
void GetEdgeInteriorDofs(int i, Array< int > &dofs) const
Returns the indices of the degrees of freedom for the interior of the specified edge.
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th boundary fac...
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'. The returned indices are offsets into an ldo...
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i-th element.
void GetEdgeVDofs(int i, Array< int > &vdofs) const
Returns the indices of the degrees of freedom for the specified edge, including the DOFs for the vert...
virtual const SparseMatrix * GetRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
virtual int GetFaceDofs(int face, Array< int > &dofs, int variant=0) const
Returns the indices of the degrees of freedom for the specified face, including the DOFs for the edge...
static void AdjustVDofs(Array< int > &vdofs)
Remove the orientation information encoded into an array of dofs Some basis function types have a rel...
bool Nonconforming() const
void GetVertexVDofs(int i, Array< int > &vdofs) const
Returns the indices of the degrees of freedom for the specified vertices.
int GetNEDofs() const
Number of all scalar edge-interior dofs.
int GetAttribute(int i) const
int GetNDofs() const
Returns number of degrees of freedom. This is the number of Local Degrees of Freedom.
int GetNBE() const
Returns number of boundary elements in the mesh.
const NURBSExtension * GetNURBSext() const
virtual const Operator * GetProlongationMatrix() const
int GetBdrAttribute(int i) const
int GetLocalDofForDof(int i) const
Return the dof index within the element from GetElementForDof() for ldof index i.
int GetElementForDof(int i) const
Return the index of the first element that contains ldof index i.
int GetNF() const
Returns number of faces (i.e. co-dimension 1 entities) in the mesh.
FiniteElementCollection * Load(Mesh *m, std::istream &input)
Read a FiniteElementSpace from a stream. The returned FiniteElementCollection is owned by the caller.
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indices of degrees of freedom for the i'th element. The returned indices are offsets into an ...
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
Ordering::Type GetOrdering() const
Return the ordering method.
ElementTransformation * GetBdrElementTransformation(int i) const
Returns ElementTransformation for the i-th boundary element.
bool LastUpdatePRef() const
Return a flag indicating whether the last update was for p-refinement.
int GetNE() const
Returns number of elements in the mesh.
const FiniteElement * GetEdgeElement(int i, int variant=0) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th edge in the ...
int GetEdgeDofs(int edge, Array< int > &dofs, int variant=0) const
Returns the indices of the degrees of freedom for the specified edge, including the DOFs for the vert...
void GetFaceVDofs(int i, Array< int > &vdofs) const
Returns the indices of the degrees of freedom for the specified face, including the DOFs for the edge...
void GetElementVertices(int i, Array< int > &vertices) const
Returns the vertices of element i.
int GetNFDofs() const
Number of all scalar face-interior dofs.
int GetElementOrder(int i) const
Returns the order of the i'th finite element.
const FiniteElement * GetFaceElement(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th face in the ...
std::shared_ptr< const PRefinementTransferOperator > GetPrefUpdateOperator()
const SparseMatrix * GetConformingProlongation() const
const FiniteElementCollection * FEColl() const
Mesh * GetMesh() const
Returns the mesh.
int GetNV() const
Returns number of vertices in the mesh.
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
DofTransformation * GetBdrElementDofs(int bel, Array< int > &dofs) const
Returns indices of degrees of freedom for boundary element 'bel'. The returned indices are offsets in...
int GetVDim() const
Returns the vector dimension of the finite element space.
const FiniteElement * GetTypicalFE() const
Return GetFE(0) if the local mesh is not empty; otherwise return a typical FE based on the Geometry t...
static int DecodeDof(int dof)
Helper to return the DOF associated with a sign encoded DOF.
virtual int GetMaxElementOrder() const
Return the maximum polynomial order over all elements.
DofTransformation * GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indices of degrees of freedom for i'th boundary element. The returned indices are offsets int...
virtual void GetEssentialVDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_vdofs, int component=-1) const
Mark degrees of freedom associated with boundary elements with the specified boundary attributes (mar...
int DofToVDof(int dof, int vd, int ndofs=-1) const
Compute a single vdof corresponding to the index dof and the vector index vd.
int GetCurlDim() const
Return the dimension of the curl of a GridFunction defined on this space.
const Operator * GetUpdateOperator()
Get the GridFunction update operator.
Abstract class for all finite elements.
virtual void CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in reference space at the given...
int GetRangeDim() const
Returns the vector dimension for vector-valued finite elements, which is also the dimension of the in...
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
int GetDim() const
Returns the reference space dimension for the finite element.
void CalcPhysHessian(ElementTransformation &Trans, DenseMatrix &Hessian) const
Evaluate the Hessian of all shape functions of a scalar finite element in physical space at the given...
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
int GetMapType() const
Returns the FiniteElement::MapType of the element describing how reference functions are mapped to ph...
int GetRangeType() const
Returns the FiniteElement::RangeType of the element, one of {SCALAR, VECTOR}.
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const =0
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in reference space at the g...
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
void CalcPhysLaplacian(ElementTransformation &Trans, Vector &Laplacian) const
Evaluate the Laplacian of all shape functions of a scalar finite element in physical space at the giv...
int GetCurlDim() const
Returns the dimension of the curl for vector-valued finite elements.
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const =0
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
virtual void CalcPhysCurlShape(ElementTransformation &Trans, DenseMatrix &curl_shape) const
Evaluate the curl of all shape functions of a vector finite element in physical space at the point de...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
void CalcPhysShape(ElementTransformation &Trans, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in physical space at the point ...
Data type for Gauss-Seidel smoother of sparse matrix.
RefinedGeometry * Refine(Geometry::Type Geom, int Times, int ETimes=1)
const IntegrationRule * GetVertices(int GeomType) const
Return an IntegrationRule consisting of all vertices of the given Geometry::Type, GeomType.
int NumBdr(int GeomType) const
Return the number of boundary "faces" of a given Geometry::Type.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
Class for grid function - Vector with associated FE space.
void ComputeMeans(AvgType type, Array< int > &zones_per_vdof)
void GetLaplacians(int i, const IntegrationRule &ir, Vector &laps, int vdim=1) const
void AccumulateAndCountBdrTangentValues(VectorCoefficient &vcoeff, const Array< int > &bdr_attr, Array< int > &values_counter)
void ProjectVectorFieldOn(GridFunction &vec_field, int comp=0)
virtual void CountElementsPerVDof(Array< int > &elem_per_vdof) const
For each vdof, counts how many elements contain the vdof, as containment is determined by FiniteEleme...
virtual real_t GetValue(int i, const IntegrationPoint &ip, int vdim=1) const
void SaveVTK(std::ostream &out, const std::string &field_name, int ref)
Write the GridFunction in VTK format. Note that Mesh::PrintVTK must be called first....
virtual real_t ComputeDGFaceJumpError(Coefficient *exsol, Coefficient *ell_coeff, class JumpScaling jump_scaling, const IntegrationRule *irs[]=NULL) const
Returns the Face Jumps error for L2 elements.
void GetValues(int i, const IntegrationRule &ir, Vector &vals, int vdim=1) const
virtual real_t ComputeHCurlError(VectorCoefficient *exsol, VectorCoefficient *excurl, const IntegrationRule *irs[]=NULL) const
Returns the error measured in H(curl)-norm for ND elements.
void UpdatePRef()
P-refinement version of Update().
virtual real_t ComputeH1Error(Coefficient *exsol, VectorCoefficient *exgrad, Coefficient *ell_coef, real_t Nu, int norm_type) const
void GetGradients(ElementTransformation &tr, const IntegrationRule &ir, DenseMatrix &grad) const
Extension of GetGradient(...) for a collection of IntegrationPoints.
void AccumulateAndCountBdrValues(Coefficient *coeff[], VectorCoefficient *vcoeff, const Array< int > &attr, Array< int > &values_counter)
void GetDerivative(int comp, int der_comp, GridFunction &der) const
Compute a certain derivative of a function's component. Derivatives of the function are computed at t...
void GetVectorGradient(ElementTransformation &tr, DenseMatrix &grad) const
Compute the vector gradient with respect to the physical element variable.
virtual real_t ComputeMaxError(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
Returns Max|u_ex - u_h| error for H1 or L2 elements.
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
virtual void MakeRef(FiniteElementSpace *f, real_t *v)
Make the GridFunction reference external data on a new FiniteElementSpace.
void ImposeBounds(int i, const Vector &weights, const Vector &lo_, const Vector &hi_)
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
virtual real_t ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const
Returns ||exsol - u_h||_L2 for scalar or vector H1 or L2 elements.
void MakeTRef(FiniteElementSpace *f, real_t *tv)
Associate a new FiniteElementSpace and new true-dof data with the GridFunction.
void GetVectorFieldValues(int i, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr, int comp=0) const
virtual void ProjectBdrCoefficientTangent(VectorCoefficient &vcoeff, const Array< int > &bdr_attr)
Project the tangential components of the given VectorCoefficient on the boundary. Only boundary attri...
void GetElementAverages(GridFunction &avgs) const
virtual real_t ComputeElementGradError(int ielem, VectorCoefficient *exgrad, const IntegrationRule *irs[]=NULL) const
Returns ||grad u_ex - grad u_h||_L2 in element ielem for H1 or L2 elements.
void MakeOwner(FiniteElementCollection *fec_)
Make the GridFunction the owner of fec_owned and fes.
void SaveSTL(std::ostream &out, int TimesToRefine=1)
Write the GridFunction in STL format. Note that the mesh dimension must be 2 and that quad elements w...
virtual void ComputeElementLpErrors(const real_t p, Coefficient &exsol, Vector &error, Coefficient *weight=NULL, const IntegrationRule *irs[]=NULL) const
Returns ||u_ex - u_h||_Lp elementwise for H1 or L2 elements.
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
virtual void GetElementDofValues(int el, Vector &dof_vals) const
virtual real_t ComputeLpError(const real_t p, Coefficient &exsol, Coefficient *weight=NULL, const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const
Returns ||u_ex - u_h||_Lp for H1 or L2 elements.
FiniteElementSpace * FESpace()
void SaveSTLTri(std::ostream &out, real_t p1[], real_t p2[], real_t p3[])
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
int GetFaceVectorValues(int i, int side, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr) const
void GetValuesFrom(const GridFunction &orig_func)
void LegacyNCReorder()
Loading helper.
void ProjectDeltaCoefficient(DeltaCoefficient &delta_coeff, real_t &integral)
void ProjectDiscCoefficient(VectorCoefficient &coeff, Array< int > &dof_attr)
virtual void ComputeFlux(BilinearFormIntegrator &blfi, GridFunction &flux, bool wcoef=true, int subdomain=-1)
FiniteElementSpace * fes
FE space on which the grid function lives. Owned if fec_owned is not NULL.
virtual real_t ComputeCurlError(VectorCoefficient *excurl, const IntegrationRule *irs[]=NULL) const
Returns ||curl u_ex - curl u_h||_L2 for ND elements.
void GetBdrValuesFrom(const GridFunction &orig_func)
virtual real_t ComputeHDivError(VectorCoefficient *exsol, Coefficient *exdiv, const IntegrationRule *irs[]=NULL) const
Returns the error measured in H(div)-norm for RT elements.
int VectorDim() const
Shortcut for calling FiniteElementSpace::GetVectorDim() on the underlying fes.
virtual real_t ComputeW11Error(Coefficient *exsol, VectorCoefficient *exgrad, int norm_type, const Array< int > *elems=NULL, const IntegrationRule *irs[]=NULL) const
Returns norm (or portions thereof) for H1 or L2 elements.
std::unique_ptr< GridFunction > ProlongateToMaxOrder() const
Return a GridFunction with the values of this, prolongated to the maximum order of all elements in th...
int GetFaceValues(int i, int side, const IntegrationRule &ir, Vector &vals, DenseMatrix &tr, int vdim=1) const
FiniteElementCollection * fec_owned
Used when the grid function is read from a file. It can also be set explicitly, see MakeOwner().
int CurlDim() const
Shortcut for calling FiniteElementSpace::GetCurlDim() on the underlying fes.
void SumFluxAndCount(BilinearFormIntegrator &blfi, GridFunction &flux, Array< int > &counts, bool wcoef, int subdomain)
GridFunction & operator=(const GridFunction &rhs)
Copy assignment. Only the data of the base class Vector is copied.
virtual real_t ComputeDivError(Coefficient *exdiv, const IntegrationRule *irs[]=NULL) const
Returns ||div u_ex - div u_h||_L2 for RT elements.
void GetTrueDofs(Vector &tv) const
Extract the true-dofs from the GridFunction.
void AccumulateAndCountDerivativeValues(int comp, int der_comp, GridFunction &der, Array< int > &zones_per_dof) const
Used for the serial and parallel implementations of the GetDerivative() method; see its documentation...
virtual real_t ComputeGradError(VectorCoefficient *exgrad, const IntegrationRule *irs[]=NULL) const
Returns ||grad u_ex - grad u_h||_L2 for H1 or L2 elements.
void GetNodalValues(int i, Array< real_t > &nval, int vdim=1) const
Returns the values in the vertices of i'th element for dimension vdim.
virtual void GetVectorValue(int i, const IntegrationPoint &ip, Vector &val) const
void RestrictConforming()
real_t GetDivergence(ElementTransformation &tr) const
void AccumulateAndCountZones(Coefficient &coeff, AvgType type, Array< int > &zones_per_vdof)
Accumulates (depending on type) the values of coeff at all shared vdofs and counts in how many zones ...
void ProjectBdrCoefficientNormal(VectorCoefficient &vcoeff, const Array< int > &bdr_attr)
void GetCurl(ElementTransformation &tr, Vector &curl) const
void GetGradient(ElementTransformation &tr, Vector &grad) const
Gradient of a scalar function at a quadrature point.
void GetVectorGradientHat(ElementTransformation &T, DenseMatrix &gh) const
Compute the vector gradient with respect to the reference element variable.
virtual void SetSpace(FiniteElementSpace *f)
Associate a new FiniteElementSpace with the GridFunction.
void GetHessians(int i, const IntegrationRule &ir, DenseMatrix &hess, int vdim=1) const
void GetVectorValues(int i, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr) const
void ProjectGridFunction(const GridFunction &src)
Project the src GridFunction to this GridFunction, both of which must be on the same mesh.
void GetVectorFieldNodalValues(Vector &val, int comp) const
void ProjectBdrCoefficient(Coefficient &coeff, const Array< int > &attr)
Project a Coefficient on the GridFunction, modifying only DOFs on the boundary associated with the bo...
void ReorderByNodes()
For a vector grid function, makes sure that the ordering is byNODES.
Arbitrary order H1-conforming (continuous) finite elements.
Class for integration point with weight.
void Set1w(const real_t x1, const real_t w)
Class for an integration rule - an Array of IntegrationPoint.
int GetNPoints() const
Returns the number of the points in the integration rule.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
void SetRelTol(real_t rtol)
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
void SetMaxIter(int max_it)
void SetAbsTol(real_t atol)
real_t Eval(real_t h, int p) const
Arbitrary order "L2-conforming" discontinuous finite elements.
bool Factor(int m, real_t TOL=0.0) override
Compute the LU factorization of the current matrix.
void Solve(int m, int n, real_t *X) const override
Piecewise-(bi/tri)linear continuous finite elements.
void AssembleElementMatrix(const FiniteElement &el, ElementTransformation &Trans, DenseMatrix &elmat) override
void AssembleElementMatrix2(const FiniteElement &trial_fe, const FiniteElement &test_fe, ElementTransformation &Trans, DenseMatrix &elmat) override
int GetNEdges() const
Return the number of edges.
void GetBdrElementFace(int i, int *f, int *o) const
virtual FaceElementTransformations * GetFaceElementTransformations(int FaceNo, int mask=31)
NURBSExtension * NURBSext
Optional NURBS mesh extension.
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
Geometry::Type GetElementGeometry(int i) const
void GetElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of element i.
bool Nonconforming() const
Return a bool indicating whether this mesh is nonconforming.
ElementTransformation * GetFaceTransformation(int FaceNo)
Returns a pointer to the transformation defining the given face element.
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
ElementTransformation * GetTypicalElementTransformation()
If the local mesh is not empty return GetElementTransformation(0); otherwise, return the identity tra...
real_t GetElementSize(int i, int type=0)
Get the size of the i-th element relative to the perfect reference element.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr) const
Builds the transformation defining the i-th element in ElTr. ElTr must be allocated in advance and wi...
void GetFaceElements(int Face, int *Elem1, int *Elem2) const
bool FaceIsInterior(int FaceNo) const
Return true if the given face is interior.
int SpaceDimension() const
Dimension of the physical space containing the mesh.
FaceElementTransformations * GetBdrFaceTransformations(int BdrElemNo)
Builds the transformation defining the given boundary face.
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
void GetEdgeVertices(int i, Array< int > &vert) const
Returns the indices of the vertices of edge i.
static IntegrationPoint TransformBdrElementToFace(Geometry::Type geom, int o, const IntegrationPoint &ip)
For the vertex (1D), edge (2D), or face (3D) of a boundary element with the orientation o,...
void GetEdgeTransformation(int i, IsoparametricTransformation *EdTr) const
Builds the transformation defining the i-th edge element in EdTr. EdTr must be allocated in advance a...
NCMesh * ncmesh
Optional nonconforming mesh extension.
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
Geometry::Type GetElementBaseGeometry(int i) const
Array< int > attributes
A list of all unique element attributes used by the Mesh.
const real_t * GetVertex(int i) const
Return pointer to vertex i's coordinates.
A class for non-conforming AMR. The class is not used directly by the user, rather it is an extension...
bool IsLegacyLoaded() const
I/O: Return true if the mesh was loaded from the legacy v1.1 format.
virtual void GetBoundaryClosure(const Array< int > &bdr_attr_is_ess, Array< int > &bdr_vertices, Array< int > &bdr_edges, Array< int > &bdr_faces)
Get a list of vertices (2D/3D), edges (3D) and faces (3D) that coincide with boundary elements with t...
void LegacyToNewVertexOrdering(Array< int > &order) const
I/O: Return a map from old (v1.1) vertex indices to new vertex indices.
void PrintSolution(const GridFunction &sol, std::ostream &os) const
Write a GridFunction sol patch-by-patch to stream os.
void MergeGridFunctions(GridFunction *gf_array[], int num_pieces, GridFunction &merged)
Set the DOFs of merged to values from active elements in num_pieces of Gridfunctions gf_array.
void LoadSolution(std::istream &input, GridFunction &sol) const
Read a GridFunction sol from stream input, written patch-by-patch, e.g. with PrintSolution().
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
Matrix-free transfer operator between finite element spaces on the same mesh.
void Mult(const Vector &x, Vector &y) const override
Interpolation or prolongation of a vector x corresponding to the coarse space to the vector y corresp...
Abstract parallel finite element space.
static void CalcLegendre(const int p, const real_t x, real_t *u)
Piecewise-(bi)quadratic continuous finite elements.
void Mult(const Vector &xt, Vector &x) const override
void SetBounds(const Vector &lo_, const Vector &hi_)
void SetLinearConstraint(const Vector &w_, real_t a_)
void Mult(const Vector &x, Vector &y) const override
Matrix vector multiplication.
Base class for vector Coefficients that optionally depend on time and space.
int GetVDim()
Returns dimension of the vector.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
for VectorFiniteElements (Nedelec, Raviart-Thomas)
A general vector function coefficient.
void Print(std::ostream &out=mfem::out, int width=8) const
Prints vector to stream out.
real_t Norml1() const
Returns the l_1 norm of the vector.
void SetSubVector(const Array< int > &dofs, const real_t value)
Set the entries listed in dofs to the given value.
void AddElementVector(const Array< int > &dofs, const Vector &elemvect)
Add elements of the elemvect Vector to the entries listed in dofs. Negative dof values cause the -dof...
void Swap(Vector &other)
Swap the contents of two Vectors.
real_t Norml2() const
Returns the l2 norm of the vector.
void Load(std::istream **in, int np, int *dim)
Reads a vector from multiple files.
void NewMemoryAndSize(const Memory< real_t > &mem, int s, bool own_mem)
Reset the Vector to use the given external Memory mem and size s.
real_t Max() const
Returns the maximal element of the vector.
virtual bool UseDevice() const
Return the device flag of the Memory object used by the Vector.
int Size() const
Returns the size of the vector.
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
real_t Sum() const
Return the sum of the vector entries.
void SetSize(int s)
Resize the vector to size s.
virtual real_t * HostWrite()
Shortcut for mfem::Write(vec.GetMemory(), vec.Size(), false).
void NewDataAndSize(real_t *d, int s)
Set the Vector data and size, deleting the old data, if owned.
real_t * GetData() const
Return a pointer to the beginning of the Vector data.
Vector & operator=(const real_t *v)
Copy Size() entries from v.
virtual real_t * HostReadWrite()
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), false).
real_t Min() const
Returns the minimal element of the vector.
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
Vector & Add(const real_t a, const Vector &Va)
(*this) += a * Va
void MakeRef(Vector &base, int offset, int size)
Reset the Vector to be a reference to a sub-vector of base.
void Save(const GridFunction &grid_function, const std::string &variable_name, const data_type type)
std::ostream & operator<<(std::ostream &os, SparseMatrix const &mat)
void CalcOrtho(const DenseMatrix &J, Vector &n)
void TensorProductLegendre(int dim, int order, const Vector &x_in, const Vector &xmax, const Vector &xmin, Vector &poly, real_t angle, const Vector *midpoint)
Defines the global tensor product polynomial space used by NewZZErorrEstimator.
real_t infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
GridFunction * Extrude1DGridFunction(Mesh *mesh, Mesh *mesh2d, GridFunction *sol, const int ny)
Extrude a scalar 1D GridFunction, after extruding the mesh with Extrude1D.
real_t u(const Vector &xvec)
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
GeometryRefiner GlobGeometryRefiner
void AddMultVVt(const Vector &v, DenseMatrix &VVt)
VVt += v v^t.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
real_t Distance(const real_t *x, const real_t *y, const int n)
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
real_t ZZErrorEstimator(BilinearFormIntegrator &blfi, GridFunction &u, GridFunction &flux, Vector &error_estimates, Array< int > *aniso_flags, int with_subdomains, bool with_coeff)
bool IsIdentityProlongation(const Operator *P)
real_t LSZZErrorEstimator(BilinearFormIntegrator &blfi, GridFunction &u, Vector &error_estimates, bool subdomain_reconstruction, bool with_coeff, real_t tichonov_coeff)
A `‘true’' ZZ error estimator that uses face-based patches for flux reconstruction.
void BoundingBox(const Array< int > &patch, FiniteElementSpace *ufes, int order, Vector &xmin, Vector &xmax, real_t &angle, Vector &midpoint, int iface)
Defines the bounding box for the face patches used by NewZZErorrEstimator.
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
void filter_dos(std::string &line)
Check for, and remove, a trailing '\r' from and std::string.
real_t ComputeElementLpDistance(real_t p, int i, GridFunction &gf1, GridFunction &gf2)
Compute the Lp distance between two grid functions on the given element.
ComplexDenseMatrix * MultAtB(const ComplexDenseMatrix &A, const ComplexDenseMatrix &B)
Multiply the complex conjugate transpose of a matrix A with a matrix B. A^H*B.
std::function< real_t(const Vector &)> f(real_t mass_coeff)
void skip_comment_lines(std::istream &is, const char comment_char)
Check if the stream starts with comment_char. If so skip it.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
real_t p(const Vector &x, real_t t)
Helper struct to convert a C++ type to an MPI type.
void pts(int iphi, int t, real_t x[])