16 #include "../mesh/nurbs.hpp" 17 #include "../general/text.hpp" 46 istream::int_type next_char = input.peek();
52 if (buff ==
"NURBS_patches")
55 "NURBS_patches requires NURBS FE space");
60 MFEM_ABORT(
"unknown section: " << buff);
101 int g_nddofs = g_ndofs - (g_nvdofs + g_nedofs + g_nfdofs);
103 vi = ei = fi = di = 0;
104 for (
int i = 0; i < num_pieces; i++)
111 int l_nddofs = l_ndofs - (l_nvdofs + l_nedofs + l_nfdofs);
112 const double *l_data = gf_array[i]->
GetData();
113 double *g_data =
data;
116 for (
int d = 0; d < vdim; d++)
118 memcpy(g_data+vi, l_data, l_nvdofs*
sizeof(
double));
121 memcpy(g_data+ei, l_data, l_nedofs*
sizeof(
double));
124 memcpy(g_data+fi, l_data, l_nfdofs*
sizeof(
double));
127 memcpy(g_data+di, l_data, l_nddofs*
sizeof(
double));
134 memcpy(g_data+vdim*vi, l_data, l_nvdofs*
sizeof(
double)*vdim);
135 l_data += vdim*l_nvdofs;
136 g_data += vdim*g_nvdofs;
137 memcpy(g_data+vdim*ei, l_data, l_nedofs*
sizeof(
double)*vdim);
138 l_data += vdim*l_nedofs;
139 g_data += vdim*g_nedofs;
140 memcpy(g_data+vdim*fi, l_data, l_nfdofs*
sizeof(
double)*vdim);
141 l_data += vdim*l_nfdofs;
142 g_data += vdim*g_nfdofs;
143 memcpy(g_data+vdim*di, l_data, l_nddofs*
sizeof(
double)*vdim);
144 l_data += vdim*l_nddofs;
145 g_data += vdim*g_nddofs;
183 old_data.
Swap(*
this);
186 T->Mult(old_data, *
this);
214 MFEM_ASSERT(v.
Size() >= v_offset +
f->GetVSize(),
"");
246 MFEM_ASSERT(tv.
Size() >= tv_offset +
f->GetTrueVSize(),
"");
267 int nfe = ufes->
GetNE();
275 for (
int i = 0; i < nfe; i++)
277 if (subdomain >= 0 && ufes->
GetAttribute(i) != subdomain)
285 u.GetSubVector(udofs, ul);
293 *ffes->
GetFE(i), fl, wcoef);
302 for (
int j = 0; j < fdofs.
Size(); j++)
318 for (
int i = 0; i < count.Size(); i++)
320 if (count[i] != 0) { flux(i) /= count[i]; }
406 int dof = FElem->
GetDof();
422 for (k = 0; k < n; k++)
425 nval[k] = shape * (&loc_data[dof * vdim]);
431 for (k = 0; k < n; k++)
435 nval[k] = shape * (&loc_data[dof * vdim]);
443 for (k = 0; k < n; k++)
447 nval[k] = loc_data * (&vshape(0,vdim));
468 fe->CalcPhysShape(*Tr, DofVal);
476 return (DofVal * LocVec);
483 int dof = FElem->
GetDof();
507 for (
int k = 0; k < vdim; k++)
509 val(k) = shape * (&loc_data[dof * k]);
534 int dof = FElem->
GetDof();
535 Vector DofVal(dof), loc_data(dof);
543 for (
int k = 0; k < n; k++)
546 vals(k) = DofVal * loc_data;
552 for (
int k = 0; k < n; k++)
556 vals(k) = DofVal * loc_data;
585 "invalid FE map type");
587 int dof = FElem->
GetDof();
588 Vector DofLap(dof), loc_data(dof);
590 for (
int k = 0; k < n; k++)
595 laps(k) = DofLap * loc_data;
628 "invalid FE map type");
630 int dof = FElem->
GetDof();
638 for (
int k = 0; k < n; k++)
644 for (
int j = 0; j <
size; j++)
646 for (
int d = 0; d < dof; d++)
648 hess(k,j) += DofHes(d,j) * loc_data[d];
733 fip.
x = 1.0 - ip.
x - ip.
y;
739 fip.
y = 1.0 - ip.
x - ip.
y;
778 int comp,
Vector *tr)
const 783 T.Transform(ip, *tr);
789 switch (T.ElementType)
804 MFEM_ABORT(
"GridFunction::GetValue: Field continuity type \"" 806 <<
"on mesh edges.");
819 MFEM_ABORT(
"GridFunction::GetValue: Field continuity type \"" 821 <<
"on mesh faces.");
873 MFEM_ABORT(
"GridFunction::GetValue: Unsupported element type \"" 874 << T.ElementType <<
"\"");
891 return (DofVal * LocVec);
901 T.Transform(ir, *tr);
906 for (
int j = 0; j < nip; j++)
921 T.Transform(ip, *tr);
928 switch (T.ElementType)
943 MFEM_ABORT(
"GridFunction::GetVectorValue: Field continuity type \"" 945 <<
"on mesh edges.");
958 MFEM_ABORT(
"GridFunction::GetVectorValue: Field continuity type \"" 960 <<
"on mesh faces.");
1012 MFEM_ABORT(
"GridFunction::GetVectorValue: Unsupported element type \"" 1013 << T.ElementType <<
"\"");
1014 if (val.
Size() > 0) { val = NAN; }
1039 for (
int k = 0; k < vdim; k++)
1041 val(k) = shape * (&loc_data[dof * k]);
1047 int vdim = std::max(spaceDim, fe->
GetVDim());
1051 vshape.MultTranspose(loc_data, val);
1062 T.Transform(ir, *tr);
1066 int dof = FElem->
GetDof();
1084 for (
int j = 0; j < nip; j++)
1090 for (
int k = 0; k < vdim; k++)
1092 vals(k,j) = shape * (&loc_data[dof * k]);
1099 int vdim = std::max(spaceDim, FElem->
GetVDim());
1105 for (
int j = 0; j < nip; j++)
1112 vshape.MultTranspose(loc_data, val_j);
1168 Vector shape, loc_values, orig_loc_values;
1169 int i, j, d, ne, dof, odof, vdim;
1173 for (i = 0; i < ne; i++)
1185 odof = orig_fe->
GetDof();
1186 loc_values.
SetSize(dof * vdim);
1189 for (j = 0; j < dof; j++)
1193 for (d = 0; d < vdim; d++)
1195 loc_values(d*dof+j) = shape * (&orig_loc_values[d * odof]);
1214 Vector shape, loc_values, loc_values_t, orig_loc_values, orig_loc_values_t;
1215 int i, j, d, nbe, dof, odof, vdim;
1219 for (i = 0; i < nbe; i++)
1227 odof = orig_fe->
GetDof();
1228 loc_values.
SetSize(dof * vdim);
1231 for (j = 0; j < dof; j++)
1235 for (d = 0; d < vdim; d++)
1237 loc_values(d*dof+j) = shape * (&orig_loc_values[d * odof]);
1251 int d, k, n, sdim, dof;
1263 Vector loc_data, val(sdim);
1269 for (k = 0; k < n; k++)
1275 for (d = 0; d < sdim; d++)
1292 double *temp =
new double[
size];
1295 for (j = 0; j < ndofs; j++)
1296 for (i = 0; i < vdim; i++)
1298 temp[j+i*ndofs] =
data[k++];
1301 for (i = 0; i <
size; i++)
1329 val(vertices[k]) += vals(k, comp);
1330 overlap[vertices[k]]++;
1334 for (i = 0; i < overlap.Size(); i++)
1336 val(i) /= overlap[i];
1344 int d, i, k, ind, dof, sdim;
1353 for (i = 0; i < new_fes->
GetNE(); i++)
1360 for (d = 0; d < sdim; d++)
1362 for (k = 0; k < dof; k++)
1364 if ( (ind=new_vdofs[dof*d+k]) < 0 )
1366 ind = -1-ind, vals(k, d) = - vals(k, d);
1368 vec_field(ind) += vals(k, d);
1374 for (i = 0; i < overlap.Size(); i++)
1376 vec_field(i) /= overlap[i];
1389 Vector pt_grad, loc_func;
1390 int i, j, k,
dim, dof, der_dof, ind;
1397 for (i = 0; i < der_fes->
GetNE(); i++)
1406 der_dof = der_fe->
GetDof();
1412 for (j = 0; j < dof; j++)
1413 loc_func(j) = ( (ind=vdofs[comp*dof+j]) >= 0 ) ?
1415 for (k = 0; k < der_dof; k++)
1423 for (j = 0; j <
dim; j++)
1425 a += inv_jac(j, der_comp) * pt_grad(j);
1427 der(der_dofs[k]) +=
a;
1428 zones_per_dof[der_dofs[k]]++;
1438 for (
int i = 0; i < overlap.
Size(); i++)
1440 der(i) /= overlap[i];
1457 MultAtB(loc_data_mat, dshape, gh);
1462 switch (T.ElementType)
1466 int elNo = T.ElementNo;
1471 "invalid FE map type");
1476 for (
int i = 0; i < Jinv.
Width(); i++)
1478 for (
int j = 0; j < Jinv.
Height(); j++)
1480 div_v += grad_hat(i, j) * Jinv(j, i);
1497 return (loc_data * divshape) / T.Weight();
1543 MFEM_ABORT(
"GridFunction::GetDivergence: Unsupported element type \"" 1544 << T.ElementType <<
"\"");
1552 switch (T.ElementType)
1556 int elNo = T.ElementNo;
1561 "invalid FE map type");
1567 Mult(grad_hat, Jinv, grad);
1568 MFEM_ASSERT(grad.Height() == grad.Width(),
"");
1569 if (grad.Height() == 3)
1572 curl(0) = grad(2,1) - grad(1,2);
1573 curl(1) = grad(0,2) - grad(2,0);
1574 curl(2) = grad(1,0) - grad(0,1);
1576 else if (grad.Height() == 2)
1579 curl(0) = grad(1,0) - grad(0,1);
1594 curl.
SetSize(curl_shape.Width());
1596 curl_shape.MultTranspose(loc_data, curl);
1640 MFEM_ABORT(
"GridFunction::GetCurl: Unsupported element type \"" 1641 << T.ElementType <<
"\"");
1648 switch (T.ElementType)
1654 "invalid FE map type");
1655 MFEM_ASSERT(
fes->
GetVDim() == 1,
"Defined for scalar functions.");
1665 T.InverseJacobian().MultTranspose(gh, grad);
1709 MFEM_ABORT(
"GridFunction::GetGradient: Unsupported element type \"" 1710 << T.ElementType <<
"\"");
1731 dshape.MultTranspose(lval, gh);
1742 switch (T.ElementType)
1752 Mult(grad_hat, Jinv, grad);
1795 MFEM_ABORT(
"GridFunction::GetVectorGradient: " 1796 "Unsupported element type \"" << T.ElementType <<
"\"");
1808 Vector loc_avgs, loc_this;
1813 for (
int i = 0; i <
fes->
GetNE(); i++)
1818 te_doftrans = avgs.FESpace()->GetElementDofs(i, te_dofs);
1825 loc_mass.
Mult(loc_this, loc_avgs);
1830 avgs.AddElementVector(te_dofs, loc_avgs);
1832 loc_mass.
Mult(loc_this, loc_avgs);
1833 int_psi.AddElementVector(te_dofs, loc_avgs);
1835 for (
int i = 0; i < avgs.Size(); i++)
1837 avgs(i) /= int_psi(i);
1858 if (!mesh->
GetNE()) {
return; }
1869 MFEM_VERIFY(vdim == src.
fes->
GetVDim(),
"incompatible vector dimensions!");
1874 for (
int i = 0; i < mesh->
GetNE(); i++)
1881 dest_lvec.SetSize(vdim*P.
Height());
1891 for (
int vd = 0; vd < vdim; vd++)
1918 MFEM_ASSERT(weights.
Size() ==
size,
"Different # of weights and dofs.");
1919 MFEM_ASSERT(lo_.
Size() ==
size,
"Different # of lower bounds and dofs.");
1920 MFEM_ASSERT(hi_.
Size() ==
size,
"Different # of upper bounds and dofs.");
1923 double tol = 1.e-12;
1931 slbqp.
Mult(vals, new_vals);
1941 double min_,
double max_)
1953 double max_val = vals.
Max();
1954 double min_val = vals.
Min();
1956 if (max_val <= min_)
1967 if (min_ <= min_val && max_val <= max_)
1973 minv = (min_ > min_val) ? min_ : min_val;
1974 maxv = (max_ < max_val) ? max_ : max_val;
1987 R->
Mult(*
this, tmp);
1988 P->
Mult(tmp, *
this);
2006 for (j = 0; j < vertices.
Size(); j++)
2008 nval(vertices[j]) += values[j];
2009 overlap[vertices[j]]++;
2012 for (i = 0; i < overlap.Size(); i++)
2014 nval(i) /= overlap[i];
2032 for (
int i = 0; i <
fes->
GetNE(); i++)
2040 for (
int j = 0; j < vdofs.
Size(); j++)
2044 MFEM_VERIFY(vals[j] != 0.0,
2045 "Coefficient has zeros, harmonic avg is undefined!");
2046 (*this)(vdofs[j]) += 1.0 / vals[j];
2050 (*this)(vdofs[j]) += vals[j];
2052 else { MFEM_ABORT(
"Not implemented"); }
2054 zones_per_vdof[vdofs[j]]++;
2073 for (
int i = 0; i <
fes->
GetNE(); i++)
2081 for (
int j = 0; j < vdofs.
Size(); j++)
2098 MFEM_VERIFY(vals[j] != 0.0,
2099 "Coefficient has zeros, harmonic avg is undefined!");
2100 (*this)(ldof) += isign / vals[j];
2104 (*this)(ldof) += isign*vals[j];
2107 else { MFEM_ABORT(
"Not implemented"); }
2109 zones_per_vdof[ldof]++;
2118 int i, j, fdof, d, ind, vdim;
2142 for (j = 0; j < fdof; j++)
2146 if (vcoeff) { vcoeff->
Eval(vc, *transf, ip); }
2147 for (d = 0; d < vdim; d++)
2149 if (!vcoeff && !coeff[d]) {
continue; }
2151 val = vcoeff ? vc(d) : coeff[d]->
Eval(*transf, ip);
2152 if ( (ind = vdofs[fdof*d+j]) < 0 )
2154 val = -val, ind = -1-ind;
2156 if (++values_counter[ind] == 1)
2162 (*this)(ind) += val;
2185 for (i = 0; i < bdr_edges.
Size(); i++)
2187 int edge = bdr_edges[i];
2189 if (vdofs.
Size() == 0) {
continue; }
2197 for (d = 0; d < vdim; d++)
2199 if (!coeff[d]) {
continue; }
2201 fe->
Project(*coeff[d], *transf, vals);
2202 for (
int k = 0; k < vals.
Size(); k++)
2204 ind = vdofs[d*vals.
Size()+k];
2205 if (++values_counter[ind] == 1)
2207 (*this)(ind) = vals(k);
2211 (*this)(ind) += vals(k);
2219 fe->
Project(*vcoeff, *transf, vals);
2220 for (
int k = 0; k < vals.
Size(); k++)
2223 if (++values_counter[ind] == 1)
2225 (*this)(ind) = vals(k);
2229 (*this)(ind) += vals(k);
2240 for (
int i = 0; i < dofs.
Size(); i++)
2243 double val = vals(i);
2244 if (k < 0) { k = -1 - k; val = -val; }
2245 if (++values_counter[k] == 1)
2280 fe->
Project(vcoeff, *T, lvec);
2282 accumulate_dofs(dofs, lvec, *
this, values_counter);
2292 for (
int i = 0; i < bdr_edges.
Size(); i++)
2294 int edge = bdr_edges[i];
2296 if (dofs.
Size() == 0) {
continue; }
2302 fe->
Project(vcoeff, *T, lvec);
2303 accumulate_dofs(dofs, lvec, *
this, values_counter);
2313 for (
int i = 0; i <
size; i++)
2315 const int nz = zones_per_vdof[i];
2316 if (nz) { (*this)(i) /= nz; }
2321 for (
int i = 0; i <
size; i++)
2323 const int nz = zones_per_vdof[i];
2324 if (nz) { (*this)(i) = nz/(*
this)(i); }
2329 MFEM_ABORT(
"invalid AvgType");
2344 const double *center = delta_coeff.
Center();
2345 const double *vert = mesh->
GetVertex(0);
2346 double min_dist, dist;
2351 for (
int i = 0; i < mesh->
GetNV(); i++)
2355 if (dist < min_dist)
2365 if (min_dist >= delta_coeff.
Tol())
2374 Vector vals, loc_mass_vals;
2375 for (
int i = 0; i < mesh->
GetNE(); i++)
2378 for (
int j = 0; j < vertices.
Size(); j++)
2379 if (vertices[j] == v_idx)
2389 loc_mass.Mult(vals, loc_mass_vals);
2390 integral += loc_mass_vals.
Sum();
2401 if (delta_c == NULL)
2406 for (
int i = 0; i <
fes->
GetNE(); i++)
2424 (*this) *= (delta_c->
Scale() / integral);
2437 for (
int i = 0; i < dofs.
Size(); i++)
2449 T->SetIntPoint(&ip);
2450 (*this)(vdof) = coeff.
Eval(*T, ip);
2486 for (
int i = 0; i < dofs.
Size(); i++)
2497 T->SetIntPoint(&ip);
2498 vcoeff.
Eval(val, *T, ip);
2502 (*this)(vdof) = val(vd);
2535 int i, j, fdof, d, ind, vdim;
2551 for (j = 0; j < fdof; j++)
2555 for (d = 0; d < vdim; d++)
2557 if (!coeff[d]) {
continue; }
2559 val = coeff[d]->
Eval(*transf, ip);
2560 if ( (ind = vdofs[fdof*d+j]) < 0 )
2562 val = -val, ind = -1-ind;
2582 for (
int i = 0; i <
fes->
GetNE(); i++)
2591 for (
int j = 0; j < vdofs.
Size(); j++)
2593 if (attr > dof_attr[vdofs[j]])
2595 (*this)(vdofs[j]) = vals[j];
2596 dof_attr[vdofs[j]] = attr;
2638 for (
int i = 0; i < values_counter.
Size(); i++)
2640 MFEM_ASSERT(
bool(values_counter[i]) ==
bool(ess_vdofs_marker[i]),
2655 ess_vdofs_marker = 0;
2659 if (!coeff[i]) {
continue; }
2661 for (
int j = 0; j<
Size(); j++)
2663 ess_vdofs_marker[j] = bool(ess_vdofs_marker[j]) ||
2664 bool(component_dof_marker[j]);
2667 for (
int i = 0; i < values_counter.
Size(); i++)
2669 MFEM_ASSERT(
bool(values_counter[i]) == ess_vdofs_marker[i],
2704 T->SetIntPoint(&ip);
2705 vcoeff.
Eval(vc, *T, ip);
2708 lvec.
Add(ip.
weight * (vc * nor), shape);
2735 T->SetIntPoint(&ip);
2736 vcoeff.
Eval(vc, *T, ip);
2738 lvec(j) = (vc * nor);
2755 for (
int i = 0; i < values_counter.
Size(); i++)
2757 MFEM_ASSERT(
bool(values_counter[i]) ==
bool(ess_vdofs_marker[i]),
2767 double error = 0.0,
a;
2772 int fdof, d, i, intorder, j, k;
2776 if (elems != NULL && (*elems)[i] == 0) {
continue; }
2799 for (k = 0; k < fdof; k++)
2800 if (vdofs[fdof*d+k] >= 0)
2802 a += (*this)(vdofs[fdof*d+k]) * shape(k);
2806 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
2809 a -= exsol[d]->
Eval(*transf, ip);
2815 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
2828 for (
int i = 0; i <
fes->
GetNE(); i++)
2830 if (elems != NULL && (*elems)[i] == 0) {
continue; }
2832 int intorder = 2*fe->
GetOrder() + 3;
2844 exsol.
Eval(exact_vals, *T, *ir);
2847 vals.
Norm2(loc_errs);
2851 T->SetIntPoint(&ip);
2852 error += ip.
weight * T->Weight() * (loc_errs(j) * loc_errs(j));
2856 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
2890 exgrad->
Eval(vec,*Tr,ip);
2894 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
2909 for (
int i = 0; i <
fes->
GetNE(); i++)
2929 exgrad->
Eval(vec,*Tr,ip);
2934 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
2949 for (
int i = 0; i <
fes->
GetNE(); i++)
2969 excurl->
Eval(vec,*Tr,ip);
2975 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
2981 double error = 0.0,
a;
2987 for (
int i = 0; i <
fes->
GetNE(); i++)
3011 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
3019 int fdof, intorder, k;
3024 Vector shape, el_dofs, err_val, ell_coeff_val;
3046 intorder = 2 * intorder;
3060 transf = face_elem_transf->
Elem1;
3066 for (k = 0; k < fdof; k++)
3069 el_dofs(k) = (*this)(vdofs[k]);
3073 el_dofs(k) = - (*this)(-1-vdofs[k]);
3080 ell_coeff_val(j) = ell_coeff->
Eval(*transf, eip);
3081 err_val(j) = exsol->
Eval(*transf, eip) - (shape * el_dofs);
3087 transf = face_elem_transf->
Elem2;
3093 for (k = 0; k < fdof; k++)
3096 el_dofs(k) = (*this)(vdofs[k]);
3100 el_dofs(k) = - (*this)(-1-vdofs[k]);
3107 ell_coeff_val(j) += ell_coeff->
Eval(*transf, eip);
3108 ell_coeff_val(j) *= 0.5;
3109 err_val(j) -= (exsol->
Eval(*transf, eip) - (shape * el_dofs));
3113 transf = face_elem_transf;
3118 double nu = jump_scaling.
Eval(h,
p);
3119 error += (ip.
weight * nu * ell_coeff_val(j) *
3121 err_val(j) * err_val(j));
3125 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
3140 int norm_type)
const 3142 double error1 = 0.0;
3143 double error2 = 0.0;
3151 return sqrt(error1 * error1 + error2 * error2);
3160 return sqrt(L2error*L2error + GradError*GradError);
3169 return sqrt(L2error*L2error + DivError*DivError);
3178 return sqrt(L2error*L2error + CurlError*CurlError);
3184 double error = 0.0,
a;
3189 int fdof, d, i, intorder, j, k;
3216 for (k = 0; k < fdof; k++)
3217 if (vdofs[fdof*d+k] >= 0)
3219 a += (*this)(vdofs[fdof*d+k]) * shape(k);
3223 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
3225 a -= exsol[d]->
Eval(*transf, ip);
3242 int i, fdof,
dim, intorder, j, k;
3246 Vector e_grad, a_grad, shape, el_dofs, err_val, ell_coeff_val;
3249 double a, error = 0.0;
3258 for (i = 0; i < mesh->
GetNE(); i++)
3260 if (elems != NULL && (*elems)[i] == 0) {
continue; }
3277 for (k = 0; k < fdof; k++)
3280 el_dofs(k) = (*this)(vdofs[k]);
3284 el_dofs(k) = -(*this)(-1-vdofs[k]);
3291 a = (el_dofs * shape) - (exsol->
Eval(*transf, ip));
3297 for (i = 0; i < mesh->
GetNE(); i++)
3299 if (elems != NULL && (*elems)[i] == 0) {
continue; }
3317 for (k = 0; k < fdof; k++)
3320 el_dofs(k) = (*this)(vdofs[k]);
3324 el_dofs(k) = -(*this)(-1-vdofs[k]);
3331 exgrad->
Eval(e_grad, *transf, ip);
3333 Mult(dshape, Jinv, dshapet);
3353 for (
int i = 0; i <
fes->
GetNE(); i++)
3355 if (elems != NULL && (*elems)[i] == 0) {
continue; }
3364 int intorder = 2*fe->
GetOrder() + 3;
3372 T->SetIntPoint(&ip);
3373 double diff = fabs(vals(j) - exsol.
Eval(*T, ip));
3376 diff = pow(diff,
p);
3379 diff *= weight->
Eval(*T, ip);
3381 error += ip.
weight * T->Weight() * diff;
3387 diff *= weight->
Eval(*T, ip);
3389 error = std::max(error, diff);
3399 error = -pow(-error, 1./
p);
3403 error = pow(error, 1./
p);
3416 "Incorrect size for result vector");
3423 for (
int i = 0; i <
fes->
GetNE(); i++)
3433 int intorder = 2*fe->
GetOrder() + 3;
3441 T->SetIntPoint(&ip);
3442 double diff = fabs(vals(j) - exsol.
Eval(*T, ip));
3445 diff = pow(diff,
p);
3448 diff *= weight->
Eval(*T, ip);
3450 error[i] += ip.
weight * T->Weight() * diff;
3456 diff *= weight->
Eval(*T, ip);
3458 error[i] = std::max(error[i], diff);
3466 error[i] = -pow(-error[i], 1./
p);
3470 error[i] = pow(error[i], 1./
p);
3487 for (
int i = 0; i <
fes->
GetNE(); i++)
3497 int intorder = 2*fe->
GetOrder() + 3;
3502 exsol.
Eval(exact_vals, *T, *ir);
3509 vals.
Norm2(loc_errs);
3513 v_weight->
Eval(exact_vals, *T, *ir);
3516 for (
int j = 0; j < vals.
Width(); j++)
3519 for (
int d = 0; d < vals.
Height(); d++)
3521 errj += vals(d,j)*exact_vals(d,j);
3523 loc_errs(j) = fabs(errj);
3529 T->SetIntPoint(&ip);
3530 double errj = loc_errs(j);
3533 errj = pow(errj,
p);
3536 errj *= weight->
Eval(*T, ip);
3538 error += ip.
weight * T->Weight() * errj;
3544 errj *= weight->
Eval(*T, ip);
3546 error = std::max(error, errj);
3556 error = -pow(-error, 1./
p);
3560 error = pow(error, 1./
p);
3575 "Incorrect size for result vector");
3583 for (
int i = 0; i <
fes->
GetNE(); i++)
3593 int intorder = 2*fe->
GetOrder() + 3;
3598 exsol.
Eval(exact_vals, *T, *ir);
3605 vals.
Norm2(loc_errs);
3609 v_weight->
Eval(exact_vals, *T, *ir);
3612 for (
int j = 0; j < vals.
Width(); j++)
3615 for (
int d = 0; d < vals.
Height(); d++)
3617 errj += vals(d,j)*exact_vals(d,j);
3619 loc_errs(j) = fabs(errj);
3625 T->SetIntPoint(&ip);
3626 double errj = loc_errs(j);
3629 errj = pow(errj,
p);
3632 errj *= weight->
Eval(*T, ip);
3634 error[i] += ip.
weight * T->Weight() * errj;
3640 errj *= weight->
Eval(*T, ip);
3642 error[i] = std::max(error[i], errj);
3650 error[i] = -pow(-error[i], 1./
p);
3654 error[i] = pow(error[i], 1./
p);
3681 os <<
"NURBS_patches\n";
3700 ofstream ofs(fname);
3701 ofs.precision(precision);
3705 #ifdef MFEM_USE_ADIOS2 3707 const std::string& variable_name,
3710 os.
Save(*
this, variable_name, type);
3726 os <<
"SCALARS " << field_name <<
" double 1\n" 3727 <<
"LOOKUP_TABLE default\n";
3728 for (
int i = 0; i < mesh->
GetNE(); i++)
3735 for (
int j = 0; j < val.
Size(); j++)
3737 os << val(j) <<
'\n';
3741 else if ( (vec_dim == 2 || vec_dim == 3) && mesh->
SpaceDimension() > 1)
3744 os <<
"VECTORS " << field_name <<
" double\n";
3745 for (
int i = 0; i < mesh->
GetNE(); i++)
3754 for (
int j = 0; j < vval.
Width(); j++)
3756 os << vval(0, j) <<
' ' << vval(1, j) <<
' ';
3772 for (
int vd = 0; vd < vec_dim; vd++)
3774 os <<
"SCALARS " << field_name << vd <<
" double 1\n" 3775 <<
"LOOKUP_TABLE default\n";
3776 for (
int i = 0; i < mesh->
GetNE(); i++)
3783 for (
int j = 0; j < val.
Size(); j++)
3785 os << val(j) <<
'\n';
3796 double v1[3] = { p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] };
3797 double v2[3] = { p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2] };
3798 double n[] = { v1[1] * v2[2] - v1[2] * v2[1],
3799 v1[2] * v2[0] - v1[0] * v2[2],
3800 v1[0] * v2[1] - v1[1] * v2[0]
3802 double rl = 1.0 / sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);
3803 n[0] *= rl; n[1] *= rl; n[2] *= rl;
3805 os <<
" facet normal " << n[0] <<
' ' << n[1] <<
' ' << n[2]
3807 <<
"\n vertex " << p1[0] <<
' ' << p1[1] <<
' ' << p1[2]
3808 <<
"\n vertex " << p2[0] <<
' ' << p2[1] <<
' ' << p2[2]
3809 <<
"\n vertex " << p3[0] <<
' ' << p3[1] <<
' ' << p3[2]
3810 <<
"\n endloop\n endfacet\n";
3826 double pts[4][3], bbox[3][2];
3828 os <<
"solid GridFunction\n";
3830 bbox[0][0] = bbox[0][1] = bbox[1][0] = bbox[1][1] =
3831 bbox[2][0] = bbox[2][1] = 0.0;
3832 for (i = 0; i < mesh->
GetNE(); i++)
3839 for (k = 0; k < RG.
Size()/n; k++)
3841 for (j = 0; j < n; j++)
3844 pts[j][0] = pointmat(0,l);
3845 pts[j][1] = pointmat(1,l);
3846 pts[j][2] = values(l);
3862 bbox[0][0] = pointmat(0,0);
3863 bbox[0][1] = pointmat(0,0);
3864 bbox[1][0] = pointmat(1,0);
3865 bbox[1][1] = pointmat(1,0);
3866 bbox[2][0] = values(0);
3867 bbox[2][1] = values(0);
3870 for (j = 0; j < values.
Size(); j++)
3872 if (bbox[0][0] > pointmat(0,j))
3874 bbox[0][0] = pointmat(0,j);
3876 if (bbox[0][1] < pointmat(0,j))
3878 bbox[0][1] = pointmat(0,j);
3880 if (bbox[1][0] > pointmat(1,j))
3882 bbox[1][0] = pointmat(1,j);
3884 if (bbox[1][1] < pointmat(1,j))
3886 bbox[1][1] = pointmat(1,j);
3888 if (bbox[2][0] > values(j))
3890 bbox[2][0] = values(j);
3892 if (bbox[2][1] < values(j))
3894 bbox[2][1] = values(j);
3899 mfem::out <<
"[xmin,xmax] = [" << bbox[0][0] <<
',' << bbox[0][1] <<
"]\n" 3900 <<
"[ymin,ymax] = [" << bbox[1][0] <<
',' << bbox[1][1] <<
"]\n" 3901 <<
"[zmin,zmax] = [" << bbox[2][0] <<
',' << bbox[2][1] <<
']' 3904 os <<
"endsolid GridFunction" << endl;
3921 MFEM_ASSERT(new_vertex.Size() == mesh->
GetNV(),
"");
3924 old_vertex.SetSize(new_vertex.Size());
3925 for (
int i = 0; i < new_vertex.Size(); i++)
3927 old_vertex[new_vertex[i]] = i;
3934 for (
int i = 0; i < mesh->
GetNV(); i++)
3939 for (
int j = 0; j < new_vdofs.
Size(); j++)
3941 tmp(new_vdofs[j]) = (*this)(old_vdofs[j]);
3947 for (
int i = 0; i < mesh->
GetNEdges(); i++)
3950 if (old_vertex[ev[0]] > old_vertex[ev[1]])
3955 for (
int k = 0; k < dofs.
Size(); k++)
3957 int new_dof = dofs[k];
3958 int old_dof = dofs[(ind[k] < 0) ? -1-ind[k] : ind[k]];
3965 double sign = (ind[k] < 0) ? -1.0 : 1.0;
3966 tmp(new_vdof) = sign * (*this)(old_vdof);
3979 int with_subdomains,
3987 int nfe = ufes->
GetNE();
3991 Vector ul, fl, fla, d_xyz;
4001 if (with_subdomains)
4006 double total_error = 0.0;
4007 for (
int s = 1;
s <= nsd;
s++)
4010 u.ComputeFlux(blfi, flux, with_coeff, (with_subdomains ?
s : -1));
4012 for (
int i = 0; i < nfe; i++)
4014 if (with_subdomains && ufes->
GetAttribute(i) !=
s) {
continue; }
4019 u.GetSubVector(udofs, ul);
4024 *ffes->
GetFE(i), fl, with_coeff);
4029 (aniso_flags ? &d_xyz : NULL));
4031 error_estimates(i) = std::sqrt(eng);
4037 for (
int k = 0; k <
dim; k++)
4042 double thresh = 0.15 * 3.0/
dim;
4044 for (
int k = 0; k <
dim; k++)
4046 if (d_xyz[k] / sum > thresh) { flag |= (1 << k); }
4049 (*aniso_flags)[i] = flag;
4057 auto process_local_error = total_error;
4058 MPI_Allreduce(&process_local_error, &total_error, 1, MPI_DOUBLE,
4059 MPI_SUM, pfes->GetComm());
4061 #endif // MFEM_USE_MPI 4062 return std::sqrt(total_error);
4074 MFEM_VERIFY(
dim >= 1,
"dim must be positive");
4075 MFEM_VERIFY(
dim <= 3,
"dim cannot be greater than 3");
4076 MFEM_VERIFY(order >= 0,
"order cannot be negative");
4078 bool rotate = (angle != 0.0) || (midpoint->
Norml2() != 0.0);
4087 x[0] = tmp[0]*cos(-angle) - tmp[1]*sin(-angle);
4088 x[1] = tmp[0]*sin(-angle) + tmp[1]*cos(-angle);
4097 double x1 = (x(0) - xmin(0))/(xmax(0)-xmin(0)), x2, x3;
4098 Vector poly_x(order+1), poly_y(order+1), poly_z(order+1);
4102 x2 = (x(1)-xmin(1))/(xmax(1)-xmin(1));
4107 x3 = (x(2)-xmin(2))/(xmax(2)-xmin(2));
4111 int basis_dimension =
static_cast<int>(pow(order+1,
dim));
4112 poly.
SetSize(basis_dimension);
4117 for (
int i = 0; i <= order; i++)
4119 poly(i) = poly_x(i);
4125 for (
int j = 0; j <= order; j++)
4127 for (
int i = 0; i <= order; i++)
4129 int cnt = i + (order+1) * j;
4130 poly(cnt) = poly_x(i) * poly_y(j);
4137 for (
int k = 0; k <= order; k++)
4139 for (
int j = 0; j <= order; j++)
4141 for (
int i = 0; i <= order; i++)
4143 int cnt = i + (order+1) * j + (order+1) * (order+1) * k;
4144 poly(cnt) = poly_x(i) * poly_y(j) * poly_z(k);
4152 MFEM_ABORT(
"TensorProductLegendre: invalid value of dim");
4168 int num_elems = patch.
Size();
4178 if (
rotate && iface >= 0)
4184 physical_diff = 0.0;
4187 for (
int i = 0; i < 2; i++)
4189 reference_pt.
Set1w((
double)i, 0.0);
4190 Tr.
Transform(reference_pt, physical_pt);
4191 midpoint += physical_pt;
4192 physical_pt *= pow(-1.0,i);
4193 physical_diff += physical_pt;
4196 angle = atan2(physical_diff(1),physical_diff(0));
4199 for (
int i = 0; i < num_elems; i++)
4201 int ielem = patch[i];
4212 transip -= midpoint;
4215 transip[0] = tmp[0]*cos(-angle) - tmp[1]*sin(-angle);
4216 transip[1] = tmp[0]*sin(-angle) + tmp[1]*cos(-angle);
4218 for (
int d = 0; d <
dim; d++) { xmax(d) = max(xmax(d), transip(d)); }
4219 for (
int d = 0; d <
dim; d++) { xmin(d) = min(xmin(d), transip(d)); }
4227 bool subdomain_reconstruction,
4229 double tichonov_coeff)
4231 MFEM_VERIFY(tichonov_coeff >= 0.0,
"tichonov_coeff cannot be negative");
4238 int nfe = ufes->
GetNE();
4239 int nfaces = ufes->
GetNF();
4246 error_estimates = 0.0;
4257 if (subdomain_reconstruction)
4262 double total_error = 0.0;
4263 for (
int iface = 0; iface < nfaces; iface++)
4270 patch[0] = el1; patch[1] = el2;
4273 if (el1 == -1 || el2 == -1)
4284 if (el1_attr != el2_attr) {
continue; }
4293 int num_basis_functions =
static_cast<int>(pow(patch_order+1,
dim));
4294 int flux_order = 2*patch_order + 1;
4303 xmin, xmax, angle, midpoint, iface);
4308 for (
int i = 0; i < patch.
Size(); i++)
4310 int ielem = patch[i];
4316 u.GetSubVector(udofs, ul);
4320 *dummy, fl, with_coeff, ir);
4324 for (
int k = 0; k < num_integration_pts; k++)
4336 for (
int l = 0; l < num_basis_functions; l++)
4339 for (
int n = 0; n < sdim; n++)
4341 b[l + n * num_basis_functions] +=
p(l) * fl(k + n * num_integration_pts);
4353 for (
int i = 0; i < num_basis_functions; i++)
4355 A(i,i) += tichonov_coeff;
4362 if (!lu.Factor(num_basis_functions,TOL))
4365 mfem::out <<
"LSZZErrorEstimator: Matrix A is singular.\t" 4366 <<
"Consider increasing tichonov_coeff." << endl;
4367 for (
int i = 0; i < num_basis_functions; i++)
4371 lu.Factor(num_basis_functions,TOL);
4373 lu.Solve(num_basis_functions, sdim,
b);
4381 for (
int i = 0; i < num_basis_functions; i++)
4383 for (
int j = 0; j < sdim; j++)
4385 f(j) +=
b[i + j * num_basis_functions] *
p(i);
4392 double element_error = 0.0;
4393 double patch_error = 0.0;
4394 for (
int i = 0; i < patch.
Size(); i++)
4396 int ielem = patch[i];
4397 element_error =
u.ComputeElementGradError(ielem, &global_poly);
4398 element_error *= element_error;
4399 patch_error += element_error;
4400 error_estimates(ielem) += element_error;
4404 total_error += patch_error;
4412 for (
int ielem = 0; ielem < nfe; ielem++)
4414 if (counters[ielem] == 0)
4416 error_estimates(ielem) =
infinity();
4420 error_estimates(ielem) /= counters[ielem]/2.0;
4421 error_estimates(ielem) = sqrt(error_estimates(ielem));
4424 return std::sqrt(total_error/
dim);
4446 for (
int j = 0; j < nip; j++)
4449 T->SetIntPoint(&ip);
4455 double errj = val1.
Norml2();
4458 errj = pow(errj,
p);
4459 norm += ip.
weight * T->Weight() * errj;
4463 norm = std::max(norm, errj);
4472 norm = -pow(-norm, 1./
p);
4476 norm = pow(norm, 1./
p);
4490 return sol_in.
Eval(*T_in, ip);
4501 string cname = name;
4502 if (cname ==
"Linear")
4506 else if (cname ==
"Quadratic")
4510 else if (cname ==
"Cubic")
4514 else if (!strncmp(name,
"H1_", 3))
4518 else if (!strncmp(name,
"H1Pos_", 6))
4523 else if (!strncmp(name,
"L2_T", 4))
4527 else if (!strncmp(name,
"L2_", 3))
4533 mfem::err <<
"Extrude1DGridFunction : unknown FE collection : " void SaveSTLTri(std::ostream &out, double p1[], double p2[], double p3[])
Abstract class for all finite elements.
virtual double ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const
void GetEdgeInteriorDofs(int i, Array< int > &dofs) const
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
virtual double ComputeGradError(VectorCoefficient *exgrad, const IntegrationRule *irs[]=NULL) const
Returns ||grad u_ex - grad u_h||_L2 for H1 or L2 elements.
void SetSubVector(const Array< int > &dofs, const double value)
Set the entries listed in dofs to the given value.
bool IsLegacyLoaded() const
I/O: Return true if the mesh was loaded from the legacy v1.1 format.
int GetNPoints() const
Returns the number of the points in the integration rule.
void Save(const GridFunction &grid_function, const std::string &variable_name, const data_type type)
Class for an integration rule - an Array of IntegrationPoint.
void NewDataAndSize(double *d, int s)
Set the Vector data and size, deleting the old data, if owned.
Class for grid function - Vector with associated FE space.
Class used for extruding scalar GridFunctions.
virtual void GetVectorValue(int i, const IntegrationPoint &ip, Vector &val) const
void SumFluxAndCount(BilinearFormIntegrator &blfi, GridFunction &flux, Array< int > &counts, bool wcoef, int subdomain)
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
void MergeGridFunctions(GridFunction *gf_array[], int num_pieces, GridFunction &merged)
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
Base class for vector Coefficients that optionally depend on time and space.
void ProjectDeltaCoefficient(DeltaCoefficient &delta_coeff, double &integral)
void PrintSolution(const GridFunction &sol, std::ostream &out) const
Geometry::Type GetElementBaseGeometry(int i) const
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 ...
bool Nonconforming() const
virtual int GetContType() const =0
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
void SetSize(int s)
Resize the vector to size s.
void RestrictConforming()
GridFunction * Extrude1DGridFunction(Mesh *mesh, Mesh *mesh2d, GridFunction *sol, const int ny)
Extrude a scalar 1D GridFunction, after extruding the mesh with Extrude1D.
void GetVectorGradient(ElementTransformation &tr, DenseMatrix &grad) const
Compute the vector gradient with respect to the physical element variable.
void LegacyToNewVertexOrdering(Array< int > &order) const
I/O: Return a map from old (v1.1) vertex indices to new vertex indices.
double Scale()
Return the scale factor times the optional time dependent function. Returns with when not set by th...
void GetVertexVDofs(int i, Array< int > &vdofs) const
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
void ProjectDiscCoefficient(VectorCoefficient &coeff, Array< int > &dof_attr)
void GetFaceVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th face element (2D and 3D).
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
void Print(std::ostream &out=mfem::out, int width=8) const
Prints vector to stream out.
virtual void ComputeElementLpErrors(const double p, Coefficient &exsol, Vector &error, Coefficient *weight=NULL, const IntegrationRule *irs[]=NULL) const
bool FaceIsInterior(int FaceNo) const
Return true if the given face is interior.
void GetGradient(ElementTransformation &tr, Vector &grad) const
Gradient of a scalar function at a quadrature point.
int GetCurlDim() const
Returns the dimension of the curl for vector-valued finite elements.
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
virtual const FiniteElement * FiniteElementForGeometry(Geometry::Type GeomType) const =0
virtual DofTransformation * GetBdrElementDofs(int bel, Array< int > &dofs) const
Returns indices of degrees of freedom for boundary element 'bel'.
virtual void CalcPhysLaplacian(ElementTransformation &Trans, Vector &Laplacian) const
Evaluate the Laplacian of all shape functions of a scalar finite element in reference space at the gi...
bool Nonconforming() const
int Size() const
Returns the size of the vector.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void GetElementAverages(GridFunction &avgs) const
Piecewise-(bi/tri)linear continuous finite elements.
Data type dense matrix using column-major storage.
virtual double * HostWrite()
Shortcut for mfem::Write(vec.GetMemory(), vec.Size(), false).
Delta function coefficient optionally multiplied by a weight coefficient and a scaled time dependent ...
const NURBSExtension * GetNURBSext() const
double * Data() const
Returns the matrix data array.
int GetNDofs() const
Returns number of degrees of freedom.
double Tol()
Return the tolerance used to identify the mesh vertices.
int GetNEdges() const
Return the number of edges.
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
void AccumulateAndCountBdrTangentValues(VectorCoefficient &vcoeff, Array< int > &bdr_attr, Array< int > &values_counter)
Abstract parallel finite element space.
void LoadSolution(std::istream &input, GridFunction &sol) const
void MakeOwner(FiniteElementCollection *fec_)
Make the GridFunction the owner of fec and fes.
FiniteElementCollection * Load(Mesh *m, std::istream &input)
Read a FiniteElementSpace from a stream. The returned FiniteElementCollection is owned by the caller...
double Eval(double h, int p) const
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
static void CalcLegendre(const int p, const double x, double *u)
void ComputeMeans(AvgType type, Array< int > &zones_per_vdof)
void CalcOrtho(const DenseMatrix &J, Vector &n)
void GetHessians(int i, const IntegrationRule &ir, DenseMatrix &hess, int vdim=1) const
virtual FaceElementTransformations * GetFaceElementTransformations(int FaceNo, int mask=31)
const IntegrationRule * GetVertices(int GeomType)
Return an IntegrationRule consisting of all vertices of the given Geometry::Type, GeomType...
virtual double GetValue(int i, const IntegrationPoint &ip, int vdim=1) const
void skip_comment_lines(std::istream &is, const char comment_char)
Check if the stream starts with comment_char. If so skip it.
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
void GetEdgeTransformation(int i, IsoparametricTransformation *EdTr)
void GetFaceElements(int Face, int *Elem1, int *Elem2) const
const FiniteElement * GetFaceElement(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th face in the ...
void ImposeBounds(int i, const Vector &weights, const Vector &lo_, const Vector &hi_)
Vector & operator=(const double *v)
Copy Size() entries from v.
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
void Load(std::istream **in, int np, int *dim)
Reads a vector from multiple files.
Piecewise-(bi)cubic continuous finite elements.
int GetNEDofs() const
Number of all scalar edge-interior dofs.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient in the element described by T at the point ip.
virtual double ComputeMaxError(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
void GetDerivative(int comp, int der_comp, GridFunction &der)
Compute a certain derivative of a function's component. Derivatives of the function are computed at t...
void GetTrueDofs(Vector &tv) const
Extract the true-dofs from the GridFunction.
void GetBdrElementFace(int i, int *f, int *o) const
Return the index and the orientation of the face of bdr element i. (3D)
void ProjectBdrCoefficientNormal(VectorCoefficient &vcoeff, Array< int > &bdr_attr)
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
void GetCurl(ElementTransformation &tr, Vector &curl) const
GeometryRefiner GlobGeometryRefiner
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
void GetValues(int i, const IntegrationRule &ir, Vector &vals, int vdim=1) const
double f(const Vector &xvec)
double GetElementSize(ElementTransformation *T, int type=0)
void Norm2(double *v) const
Take the 2-norm of the columns of A and store in v.
void Swap(Vector &other)
Swap the contents of two Vectors.
const FiniteElementCollection * FEColl() const
ElementTransformation * GetBdrElementTransformation(int i) const
Returns ElementTransformation for the i-th boundary element.
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
Coefficient * Weight()
See SetWeight() for description of the weight Coefficient.
void GetFaceTransformation(int i, IsoparametricTransformation *FTr)
virtual const SparseMatrix * GetRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
void MakeTRef(FiniteElementSpace *f, double *tv)
Associate a new FiniteElementSpace and new true-dof data with the GridFunction.
void SetMaxIter(int max_it)
void GetEdgeVertices(int i, Array< int > &vert) const
Returns the indices of the vertices of edge i.
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...
void BoundingBox(const Array< int > &patch, FiniteElementSpace *ufes, int order, Vector &xmin, Vector &xmax, double &angle, Vector &midpoint, int iface)
Defines the bounding box for the face patches used by NewZZErorrEstimator.
virtual double ComputeHDivError(VectorCoefficient *exsol, Coefficient *exdiv, const IntegrationRule *irs[]=NULL) const
Returns the error measured in H(div)-norm for RT elements.
void SetLinearConstraint(const Vector &w_, double a_)
double Sum() const
Return the sum of the vector entries.
virtual double ComputeCurlError(VectorCoefficient *excurl, const IntegrationRule *irs[]=NULL) const
Returns ||curl u_ex - curl u_h||_L2 for ND elements.
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...
const double * GetVertex(int i) const
Return pointer to vertex i's coordinates.
virtual const char * Name() const
double LSZZErrorEstimator(BilinearFormIntegrator &blfi, GridFunction &u, Vector &error_estimates, bool subdomain_reconstruction, bool with_coeff, double tichonov_coeff)
A ‘‘true’’ ZZ error estimator that uses face-based patches for flux reconstruction.
void GetElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of element i.
void AccumulateAndCountDerivativeValues(int comp, int der_comp, GridFunction &der, Array< int > &zones_per_dof)
Used for the serial and parallel implementations of the GetDerivative() method; see its documentation...
const SparseMatrix * GetConformingProlongation() const
The returned SparseMatrix is owned by the FiniteElementSpace.
void AddMultVVt(const Vector &v, DenseMatrix &VVt)
VVt += v v^t.
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 ...
virtual void MakeRef(FiniteElementSpace *f, double *v)
Make the GridFunction reference external data on a new FiniteElementSpace.
RefinedGeometry * Refine(Geometry::Type Geom, int Times, int ETimes=1)
double GetDivergence(ElementTransformation &tr) const
int GetVDim()
Returns dimension of the vector.
A class for non-conforming AMR. The class is not used directly by the user, rather it is an extension...
FaceElementTransformations * GetBdrFaceTransformations(int BdrElemNo)
FiniteElementSpace * FESpace()
GridFunction & operator=(const GridFunction &rhs)
Copy assignment. Only the data of the base class Vector is copied.
void Mult(const double *x, double *y) const
Matrix vector multiplication.
int GetNE() const
Returns number of elements in the mesh.
virtual double ComputeW11Error(Coefficient *exsol, VectorCoefficient *exgrad, int norm_type, const Array< int > *elems=NULL, const IntegrationRule *irs[]=NULL) const
virtual void GetBoundaryClosure(const Array< int > &bdr_attr_is_ess, Array< int > &bdr_vertices, Array< int > &bdr_edges)
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 GetNodalValues(int i, Array< double > &nval, int vdim=1) const
Returns the values in the vertices of i'th element for dimension vdim.
double * GetData() const
Return a pointer to the beginning of the Vector data.
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
int GetVDim() const
Returns vector dimension.
A general vector function coefficient.
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
Geometry::Type GetElementGeometry(int i) const
virtual void GetElementDofValues(int el, Vector &dof_vals) const
int GetNF() const
Returns number of faces (i.e. co-dimension 1 entities) in the mesh.
bool IsIdentityProlongation(const Operator *P)
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
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]...
Mesh * GetMesh() const
Returns the mesh.
void SetAbsTol(double atol)
double p(const Vector &x, double t)
void SetRelTol(double rtol)
int GetDim() const
Returns the reference space dimension for the finite 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.
double Distance(const double *x, const double *y, const int n)
virtual double 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.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
virtual double ComputeDGFaceJumpError(Coefficient *exsol, Coefficient *ell_coeff, class JumpScaling jump_scaling, const IntegrationRule *irs[]=NULL) const
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
FiniteElementSpace * fes
FE space on which the grid function lives. Owned if fec is not NULL.
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
virtual double ComputeH1Error(Coefficient *exsol, VectorCoefficient *exgrad, Coefficient *ell_coef, double Nu, int norm_type) const
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
void ProjectGridFunction(const GridFunction &src)
Project the src GridFunction to this GridFunction, both of which must be on the same mesh...
virtual double ComputeDivError(Coefficient *exdiv, const IntegrationRule *irs[]=NULL) const
Returns ||div u_ex - div u_h||_L2 for RT elements.
double Min() const
Returns the minimal element of the vector.
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...
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int GetElementForDof(int i) const
Return the index of the first element that contains dof i.
void GetVectorFieldNodalValues(Vector &val, int comp) const
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...
int NumBdr(int GeomType)
Return the number of boundary "faces" of a given Geometry::Type.
void GetColumnReference(int c, Vector &col)
FiniteElementCollection * fec
Used when the grid function is read from a file. It can also be set explicitly, see MakeOwner()...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
void GetElementVertices(int i, Array< int > &vertices) const
Returns the vertices of element i.
void GetVectorGradientHat(ElementTransformation &T, DenseMatrix &gh) const
Compute the vector gradient with respect to the reference element variable.
void TensorProductLegendre(int dim, int order, const Vector &x_in, const Vector &xmax, const Vector &xmin, Vector &poly, double angle, const Vector *midpoint)
Defines the global tensor product polynomial space used by NewZZErorrEstimator.
virtual DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'.
double Max() const
Returns the maximal element of the vector.
int GetNVDofs() const
Number of all scalar vertex dofs.
double Norml1() const
Returns the l_1 norm of the vector.
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
double ComputeElementLpDistance(double p, int i, GridFunction &gf1, GridFunction &gf2)
Compute the Lp distance between two grid functions on the given element.
int SpaceDimension() const
int GetAttribute(int i) const
static FiniteElementCollection * New(const char *name)
Factory method: return a newly allocated FiniteElementCollection according to the given name...
virtual double ComputeHCurlError(VectorCoefficient *exsol, VectorCoefficient *excurl, const IntegrationRule *irs[]=NULL) const
Returns the error measured in H(curl)-norm for ND elements.
int GetNE() const
Returns number of elements.
virtual double ComputeLpError(const double p, Coefficient &exsol, Coefficient *weight=NULL, const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const
double ZZErrorEstimator(BilinearFormIntegrator &blfi, GridFunction &u, GridFunction &flux, Vector &error_estimates, Array< int > *aniso_flags, int with_subdomains, bool with_coeff)
NURBSExtension * NURBSext
Optional NURBS mesh extension.
virtual const Operator * GetProlongationMatrix() const
The returned Operator is owned by the FiniteElementSpace.
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 ...
Vector & Add(const double a, const Vector &Va)
(*this) += a * Va
Class for integration point with weight.
int GetElementOrder(int i) const
Returns the order of the i'th finite element.
virtual void Mult(const Vector &xt, Vector &x) const
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...
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
int GetVDim() const
Returns the vector dimension for vector-valued finite elements.
int GetBdrAttribute(int i) const
Ordering::Type GetOrdering() const
Return the ordering method.
DofTransformation * GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th boundary element.
void Save(std::ostream &out) const
Save finite element space to output stream out.
virtual void AssembleElementMatrix2(const FiniteElement &trial_fe, const FiniteElement &test_fe, ElementTransformation &Trans, DenseMatrix &elmat)
void GetVectorFieldValues(int i, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr, int comp=0) const
void NewMemoryAndSize(const Memory< double > &mem, int s, bool own_mem)
Reset the Vector to use the given external Memory mem and size s.
void GetGradients(ElementTransformation &tr, const IntegrationRule &ir, DenseMatrix &grad) const
Extension of GetGradient(...) for a collection of IntegrationPoints.
void GetEdgeVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th edge.
int GetNBE() const
Returns number of boundary elements in the mesh.
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...
const Operator * GetUpdateOperator()
Get the GridFunction update operator.
virtual void ProjectBdrCoefficientTangent(VectorCoefficient &vcoeff, Array< int > &bdr_attr)
Project the tangential components of the given VectorCoefficient on the boundary. Only boundary attri...
void LegacyNCReorder()
Loading helper.
int GetFaceValues(int i, int side, const IntegrationRule &ir, Vector &vals, DenseMatrix &tr, int vdim=1) const
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
int GetMapType() const
Returns the FiniteElement::MapType of the element describing how reference functions are mapped to ph...
double infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
int GetFaceVectorValues(int i, int side, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr) const
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
double Norml2() const
Returns the l2 norm of the vector.
Piecewise-(bi)quadratic continuous finite elements.
virtual void SetSpace(FiniteElementSpace *f)
Associate a new FiniteElementSpace with the GridFunction.
void ReorderByNodes()
For a vector grid function, makes sure that the ordering is byNODES.
std::ostream & operator<<(std::ostream &os, SparseMatrix const &mat)
NCMesh * ncmesh
Optional nonconforming mesh extension.
void GetVectorValues(int i, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr) const
void GetLaplacians(int i, const IntegrationRule &ir, Vector &laps, int vdim=1) const
int Size() const
Return the logical size of the array.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
void filter_dos(std::string &line)
Check for, and remove, a trailing '\r' from and std::string.
virtual bool UseDevice() const
Return the device flag of the Memory object used by the Vector.
int DofToVDof(int dof, int vd, int ndofs=-1) const
int GetNV() const
Returns number of vertices in the mesh.
void be_to_bfe(Geometry::Type geom, int o, const IntegrationPoint &ip, IntegrationPoint &fip)
void MakeRef(Vector &base, int offset, int size)
Reset the Vector to be a reference to a sub-vector of base.
virtual void ComputeFlux(BilinearFormIntegrator &blfi, GridFunction &flux, bool wcoef=true, int subdomain=-1)
int GetRangeType() const
Returns the FiniteElement::RangeType of the element, one of {SCALAR, VECTOR}.
Arbitrary order H1-conforming (continuous) finite elements.
void pts(int iphi, int t, double x[])
Field is continuous across element interfaces.
double u(const Vector &xvec)
const FiniteElement * GetEdgeElement(int i, int variant=0) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th edge in the ...
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
virtual void CalcPhysHessian(ElementTransformation &Trans, DenseMatrix &Hessian) const
Evaluate the Hessian of all shape functions of a scalar finite element in reference space at the give...
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
void SetBounds(const Vector &lo_, const Vector &hi_)
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
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...
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...
void BuildDofToArrays()
Initialize internal data that enables the use of the methods GetElementForDof() and GetLocalDofForDof...
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th boundary fac...
void Set1w(const double x1, const double w)
int GetNFDofs() const
Number of all scalar face-interior dofs.
void GetValuesFrom(const GridFunction &orig_func)
int GetLocalDofForDof(int i) const
Return the local dof index in the first element that contains dof i.
void DofsToVDofs(Array< int > &dofs, int ndofs=-1) const
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
virtual double * HostReadWrite()
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), false).
void GetBdrValuesFrom(const GridFunction &orig_func)
static void AdjustVDofs(Array< int > &vdofs)
Array< int > attributes
A list of all unique element attributes used by the Mesh.
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...
void AccumulateAndCountBdrValues(Coefficient *coeff[], VectorCoefficient *vcoeff, Array< int > &attr, Array< int > &values_counter)
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. The parameter ref > 0 must match the one used in Mesh::PrintVTK.
void ProjectBdrCoefficient(Coefficient &coeff, Array< int > &attr)
Project a Coefficient on the GridFunction, modifying only DOFs on the boundary associated with the bo...
Arbitrary order "L2-conforming" discontinuous finite elements.
void ProjectVectorFieldOn(GridFunction &vec_field, int comp=0)
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i-th element.