15 #include "../mesh/nurbs.hpp"
16 #include "../general/text.hpp"
45 istream::int_type next_char = input.peek();
51 if (buff ==
"NURBS_patches")
54 "NURBS_patches requires NURBS FE space");
59 MFEM_ABORT(
"unknown section: " << buff);
100 int g_nddofs = g_ndofs - (g_nvdofs + g_nedofs + g_nfdofs);
102 vi = ei = fi = di = 0;
103 for (
int i = 0; i < num_pieces; i++)
110 int l_nddofs = l_ndofs - (l_nvdofs + l_nedofs + l_nfdofs);
111 const double *l_data = gf_array[i]->
GetData();
112 double *g_data =
data;
115 for (
int d = 0; d < vdim; d++)
117 memcpy(g_data+vi, l_data, l_nvdofs*
sizeof(
double));
120 memcpy(g_data+ei, l_data, l_nedofs*
sizeof(
double));
123 memcpy(g_data+fi, l_data, l_nfdofs*
sizeof(
double));
126 memcpy(g_data+di, l_data, l_nddofs*
sizeof(
double));
133 memcpy(g_data+vdim*vi, l_data, l_nvdofs*
sizeof(
double)*vdim);
134 l_data += vdim*l_nvdofs;
135 g_data += vdim*g_nvdofs;
136 memcpy(g_data+vdim*ei, l_data, l_nedofs*
sizeof(
double)*vdim);
137 l_data += vdim*l_nedofs;
138 g_data += vdim*g_nedofs;
139 memcpy(g_data+vdim*fi, l_data, l_nfdofs*
sizeof(
double)*vdim);
140 l_data += vdim*l_nfdofs;
141 g_data += vdim*g_nfdofs;
142 memcpy(g_data+vdim*di, l_data, l_nddofs*
sizeof(
double)*vdim);
143 l_data += vdim*l_nddofs;
144 g_data += vdim*g_nddofs;
182 old_data.
Swap(*
this);
185 T->
Mult(old_data, *
this);
264 int nfe = ufes->
GetNE();
272 for (
int i = 0; i < nfe; i++)
274 if (subdomain >= 0 && ufes->
GetAttribute(i) != subdomain)
290 *ffes->
GetFE(i), fl, wcoef);
299 for (
int j = 0; j < fdofs.
Size(); j++)
315 for (
int i = 0; i < count.Size(); i++)
317 if (count[i] != 0) { flux(i) /= count[i]; }
403 int dof = FElem->
GetDof();
417 "invalid FE map type");
419 for (k = 0; k < n; k++)
422 nval[k] = shape * ((
const double *)loc_data + dof * vdim);
429 for (k = 0; k < n; k++)
433 nval[k] = loc_data * (&vshape(0,vdim));
454 fe->CalcPhysShape(*Tr, DofVal);
462 return (DofVal * LocVec);
469 int dof = FElem->
GetDof();
493 for (
int k = 0; k < vdim; k++)
495 val(k) = shape * ((
const double *)loc_data + dof * k);
520 int dof = FElem->
GetDof();
521 Vector DofVal(dof), loc_data(dof);
529 for (
int k = 0; k < n; k++)
532 vals(k) = DofVal * loc_data;
538 for (
int k = 0; k < n; k++)
542 vals(k) = DofVal * loc_data;
571 "invalid FE map type");
573 int dof = FElem->
GetDof();
574 Vector DofLap(dof), loc_data(dof);
576 for (
int k = 0; k < n; k++)
581 laps(k) = DofLap * loc_data;
611 int size = (dim*(dim+1))/2;
614 "invalid FE map type");
616 int dof = FElem->
GetDof();
624 for (
int k = 0; k < n; k++)
630 for (
int j = 0; j <
size; j++)
632 for (
int d = 0; d < dof; d++)
634 hess(k,j) += DofHes(d,j) * loc_data[d];
719 fip.
x = 1.0 - ip.
x - ip.
y;
725 fip.
y = 1.0 - ip.
x - ip.
y;
764 int comp,
Vector *tr)
const
790 MFEM_ABORT(
"GridFunction::GetValue: Field continuity type \""
792 <<
"on mesh edges.");
805 MFEM_ABORT(
"GridFunction::GetValue: Field continuity type \""
807 <<
"on mesh faces.");
859 MFEM_ABORT(
"GridFunction::GetValue: Unsupported element type \""
877 return (DofVal * LocVec);
892 for (
int j = 0; j < nip; j++)
929 MFEM_ABORT(
"GridFunction::GetVectorValue: Field continuity type \""
931 <<
"on mesh edges.");
944 MFEM_ABORT(
"GridFunction::GetVectorValue: Field continuity type \""
946 <<
"on mesh faces.");
998 MFEM_ABORT(
"GridFunction::GetVectorValue: Unsupported element type \""
1000 if (val.
Size() > 0) { val = NAN; }
1025 for (
int k = 0; k < vdim; k++)
1027 val(k) = shape * ((
const double *)loc_data + dof * k);
1033 int vdim = std::max(spaceDim, fe->
GetVDim());
1037 vshape.MultTranspose(loc_data, val);
1052 int dof = FElem->
GetDof();
1070 for (
int j = 0; j < nip; j++)
1076 for (
int k = 0; k < vdim; k++)
1078 vals(k,j) = shape * ((
const double *)loc_data + dof * k);
1085 int vdim = std::max(spaceDim, FElem->
GetVDim());
1091 for (
int j = 0; j < nip; j++)
1098 vshape.MultTranspose(loc_data, val_j);
1154 Vector shape, loc_values, orig_loc_values;
1155 int i, j, d, ne, dof, odof, vdim;
1159 for (i = 0; i < ne; i++)
1171 odof = orig_fe->
GetDof();
1172 loc_values.
SetSize(dof * vdim);
1175 for (j = 0; j < dof; j++)
1179 for (d = 0; d < vdim; d++)
1181 loc_values(d*dof+j) =
1182 shape * ((
const double *)orig_loc_values + d * odof) ;
1201 Vector shape, loc_values, loc_values_t, orig_loc_values, orig_loc_values_t;
1202 int i, j, d, nbe, dof, odof, vdim;
1206 for (i = 0; i < nbe; i++)
1214 odof = orig_fe->
GetDof();
1215 loc_values.
SetSize(dof * vdim);
1218 for (j = 0; j < dof; j++)
1222 for (d = 0; d < vdim; d++)
1224 loc_values(d*dof+j) =
1225 shape * ((
const double *)orig_loc_values + d * odof);
1239 int d, k, n, sdim, dof;
1251 Vector loc_data, val(sdim);
1257 for (k = 0; k < n; k++)
1263 for (d = 0; d < sdim; d++)
1280 double *temp =
new double[
size];
1283 for (j = 0; j < ndofs; j++)
1284 for (i = 0; i < vdim; i++)
1286 temp[j+i*ndofs] =
data[k++];
1289 for (i = 0; i <
size; i++)
1317 val(vertices[k]) += vals(k, comp);
1318 overlap[vertices[k]]++;
1322 for (i = 0; i < overlap.Size(); i++)
1324 val(i) /= overlap[i];
1332 int d, i, k, ind, dof, sdim;
1341 for (i = 0; i < new_fes->
GetNE(); i++)
1348 for (d = 0; d < sdim; d++)
1350 for (k = 0; k < dof; k++)
1352 if ( (ind=new_vdofs[dof*d+k]) < 0 )
1354 ind = -1-ind, vals(k, d) = - vals(k, d);
1356 vec_field(ind) += vals(k, d);
1362 for (i = 0; i < overlap.Size(); i++)
1364 vec_field(i) /= overlap[i];
1377 Vector pt_grad, loc_func;
1378 int i, j, k,
dim, dof, der_dof, ind;
1385 for (i = 0; i < der_fes->
GetNE(); i++)
1394 der_dof = der_fe->
GetDof();
1400 for (j = 0; j < dof; j++)
1401 loc_func(j) = ( (ind=vdofs[comp*dof+j]) >= 0 ) ?
1403 for (k = 0; k < der_dof; k++)
1411 for (j = 0; j <
dim; j++)
1413 a += inv_jac(j, der_comp) * pt_grad(j);
1415 der(der_dofs[k]) +=
a;
1416 zones_per_dof[der_dofs[k]]++;
1426 for (
int i = 0; i < overlap.
Size(); i++)
1428 der(i) /= overlap[i];
1453 MultAtB(loc_data_mat, dshape, gh);
1467 "invalid FE map type");
1472 for (
int i = 0; i < Jinv.
Width(); i++)
1474 for (
int j = 0; j < Jinv.
Height(); j++)
1476 div_v += grad_hat(i, j) * Jinv(j, i);
1493 return (loc_data * divshape) / T.
Weight();
1539 MFEM_ABORT(
"GridFunction::GetDivergence: Unsupported element type \""
1557 "invalid FE map type");
1563 Mult(grad_hat, Jinv, grad);
1564 MFEM_ASSERT(grad.Height() == grad.Width(),
"");
1565 if (grad.Height() == 3)
1568 curl(0) = grad(2,1) - grad(1,2);
1569 curl(1) = grad(0,2) - grad(2,0);
1570 curl(2) = grad(1,0) - grad(0,1);
1572 else if (grad.Height() == 2)
1575 curl(0) = grad(1,0) - grad(0,1);
1591 curl_shape.MultTranspose(loc_data, curl);
1635 MFEM_ABORT(
"GridFunction::GetCurl: Unsupported element type \""
1649 "invalid FE map type");
1703 MFEM_ABORT(
"GridFunction::GetGradient: Unsupported element type \""
1730 dshape.MultTranspose(lval, gh);
1751 Mult(grad_hat, Jinv, grad);
1794 MFEM_ABORT(
"GridFunction::GetVectorGradient: "
1795 "Unsupported element type \"" << T.
ElementType <<
"\"");
1807 Vector loc_avgs, loc_this;
1812 for (
int i = 0; i <
fes->
GetNE(); i++)
1817 te_doftrans = avgs.FESpace()->GetElementDofs(i, te_dofs);
1824 loc_mass.
Mult(loc_this, loc_avgs);
1829 avgs.AddElementVector(te_dofs, loc_avgs);
1831 loc_mass.
Mult(loc_this, loc_avgs);
1832 int_psi.AddElementVector(te_dofs, loc_avgs);
1834 for (
int i = 0; i < avgs.Size(); i++)
1836 avgs(i) /= int_psi(i);
1857 if (!mesh->
GetNE()) {
return; }
1868 MFEM_VERIFY(vdim == src.
fes->
GetVDim(),
"incompatible vector dimensions!");
1873 for (
int i = 0; i < mesh->
GetNE(); i++)
1880 dest_lvec.SetSize(vdim*P.
Height());
1890 for (
int vd = 0; vd < vdim; vd++)
1909 Vector vals, new_vals(size);
1917 MFEM_ASSERT(weights.
Size() ==
size,
"Different # of weights and dofs.");
1918 MFEM_ASSERT(lo_.
Size() ==
size,
"Different # of lower bounds and dofs.");
1919 MFEM_ASSERT(hi_.
Size() ==
size,
"Different # of upper bounds and dofs.");
1922 double tol = 1.e-12;
1930 slbqp.
Mult(vals, new_vals);
1940 double min_,
double max_)
1945 Vector vals, new_vals(size);
1952 double max_val = vals.
Max();
1953 double min_val = vals.
Min();
1955 if (max_val <= min_)
1966 if (min_ <= min_val && max_val <= max_)
1971 Vector minv(size), maxv(size);
1972 minv = (min_ > min_val) ? min_ : min_val;
1973 maxv = (max_ < max_val) ? max_ : max_val;
1986 R->
Mult(*
this, tmp);
1987 P->
Mult(tmp, *
this);
2005 for (j = 0; j < vertices.
Size(); j++)
2007 nval(vertices[j]) += values[j];
2008 overlap[vertices[j]]++;
2011 for (i = 0; i < overlap.Size(); i++)
2013 nval(i) /= overlap[i];
2031 for (
int i = 0; i <
fes->
GetNE(); i++)
2039 for (
int j = 0; j < vdofs.
Size(); j++)
2043 MFEM_VERIFY(vals[j] != 0.0,
2044 "Coefficient has zeros, harmonic avg is undefined!");
2045 (*this)(vdofs[j]) += 1.0 / vals[j];
2049 (*this)(vdofs[j]) += vals[j];
2051 else { MFEM_ABORT(
"Not implemented"); }
2053 zones_per_vdof[vdofs[j]]++;
2072 for (
int i = 0; i <
fes->
GetNE(); i++)
2080 for (
int j = 0; j < vdofs.
Size(); j++)
2097 MFEM_VERIFY(vals[j] != 0.0,
2098 "Coefficient has zeros, harmonic avg is undefined!");
2099 (*this)(ldof) += isign / vals[j];
2103 (*this)(ldof) += isign*vals[j];
2106 else { MFEM_ABORT(
"Not implemented"); }
2108 zones_per_vdof[ldof]++;
2117 int i, j, fdof, d, ind, vdim;
2141 for (j = 0; j < fdof; j++)
2145 if (vcoeff) { vcoeff->
Eval(vc, *transf, ip); }
2146 for (d = 0; d < vdim; d++)
2148 if (!vcoeff && !coeff[d]) {
continue; }
2150 val = vcoeff ? vc(d) : coeff[d]->
Eval(*transf, ip);
2151 if ( (ind = vdofs[fdof*d+j]) < 0 )
2153 val = -val, ind = -1-ind;
2155 if (++values_counter[ind] == 1)
2161 (*this)(ind) += val;
2184 for (i = 0; i < bdr_edges.
Size(); i++)
2186 int edge = bdr_edges[i];
2188 if (vdofs.
Size() == 0) {
continue; }
2196 for (d = 0; d < vdim; d++)
2198 if (!coeff[d]) {
continue; }
2200 fe->
Project(*coeff[d], *transf, vals);
2201 for (
int k = 0; k < vals.
Size(); k++)
2203 ind = vdofs[d*vals.
Size()+k];
2204 if (++values_counter[ind] == 1)
2206 (*this)(ind) = vals(k);
2210 (*this)(ind) += vals(k);
2218 fe->
Project(*vcoeff, *transf, vals);
2219 for (
int k = 0; k < vals.
Size(); k++)
2222 if (++values_counter[ind] == 1)
2224 (*this)(ind) = vals(k);
2228 (*this)(ind) += vals(k);
2239 for (
int i = 0; i < dofs.
Size(); i++)
2242 double val = vals(i);
2243 if (k < 0) { k = -1 - k; val = -val; }
2244 if (++values_counter[k] == 1)
2279 fe->
Project(vcoeff, *T, lvec);
2281 accumulate_dofs(dofs, lvec, *
this, values_counter);
2291 for (
int i = 0; i < bdr_edges.
Size(); i++)
2293 int edge = bdr_edges[i];
2295 if (dofs.
Size() == 0) {
continue; }
2301 fe->
Project(vcoeff, *T, lvec);
2302 accumulate_dofs(dofs, lvec, *
this, values_counter);
2312 for (
int i = 0; i <
size; i++)
2314 const int nz = zones_per_vdof[i];
2315 if (nz) { (*this)(i) /= nz; }
2320 for (
int i = 0; i <
size; i++)
2322 const int nz = zones_per_vdof[i];
2323 if (nz) { (*this)(i) = nz/(*
this)(i); }
2328 MFEM_ABORT(
"invalid AvgType");
2343 const double *center = delta_coeff.
Center();
2344 const double *vert = mesh->
GetVertex(0);
2345 double min_dist, dist;
2349 min_dist =
Distance(center, vert, dim);
2350 for (
int i = 0; i < mesh->
GetNV(); i++)
2353 dist =
Distance(center, vert, dim);
2354 if (dist < min_dist)
2364 if (min_dist >= delta_coeff.
Tol())
2373 Vector vals, loc_mass_vals;
2374 for (
int i = 0; i < mesh->
GetNE(); i++)
2377 for (
int j = 0; j < vertices.
Size(); j++)
2378 if (vertices[j] == v_idx)
2388 loc_mass.Mult(vals, loc_mass_vals);
2389 integral += loc_mass_vals.
Sum();
2400 if (delta_c == NULL)
2405 for (
int i = 0; i <
fes->
GetNE(); i++)
2423 (*this) *= (delta_c->
Scale() / integral);
2436 for (
int i = 0; i < dofs.
Size(); i++)
2449 (*this)(vdof) = coeff.
Eval(*T, ip);
2485 for (
int i = 0; i < dofs.
Size(); i++)
2497 vcoeff.
Eval(val, *T, ip);
2501 (*this)(vdof) = val(vd);
2534 int i, j, fdof, d, ind, vdim;
2550 for (j = 0; j < fdof; j++)
2554 for (d = 0; d < vdim; d++)
2556 if (!coeff[d]) {
continue; }
2558 val = coeff[d]->
Eval(*transf, ip);
2559 if ( (ind = vdofs[fdof*d+j]) < 0 )
2561 val = -val, ind = -1-ind;
2581 for (
int i = 0; i <
fes->
GetNE(); i++)
2590 for (
int j = 0; j < vdofs.
Size(); j++)
2592 if (attr > dof_attr[vdofs[j]])
2594 (*this)(vdofs[j]) = vals[j];
2595 dof_attr[vdofs[j]] = attr;
2637 for (
int i = 0; i < values_counter.
Size(); i++)
2639 MFEM_ASSERT(
bool(values_counter[i]) ==
bool(ess_vdofs_marker[i]),
2655 for (
int i = 0; i < values_counter.
Size(); i++)
2657 MFEM_ASSERT(
bool(values_counter[i]) ==
bool(ess_vdofs_marker[i]),
2673 Vector vc(dim), nor(dim), lvec, shape;
2693 vcoeff.
Eval(vc, *T, ip);
2696 lvec.
Add(ip.
weight * (vc * nor), shape);
2708 Vector vc(dim), nor(dim), lvec;
2724 vcoeff.
Eval(vc, *T, ip);
2726 lvec(j) = (vc * nor);
2743 for (
int i = 0; i < values_counter.
Size(); i++)
2745 MFEM_ASSERT(
bool(values_counter[i]) ==
bool(ess_vdofs_marker[i]),
2754 double error = 0.0,
a;
2759 int fdof, d, i, intorder, j, k;
2785 for (k = 0; k < fdof; k++)
2786 if (vdofs[fdof*d+k] >= 0)
2788 a += (*this)(vdofs[fdof*d+k]) * shape(k);
2792 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
2795 a -= exsol[d]->
Eval(*transf, ip);
2801 return (error < 0.0) ? -
sqrt(-error) :
sqrt(error);
2814 for (
int i = 0; i <
fes->
GetNE(); i++)
2816 if (elems != NULL && (*elems)[i] == 0) {
continue; }
2818 int intorder = 2*fe->
GetOrder() + 3;
2830 exsol.
Eval(exact_vals, *T, *ir);
2833 vals.
Norm2(loc_errs);
2838 error += ip.
weight * T->
Weight() * (loc_errs(j) * loc_errs(j));
2842 return (error < 0.0) ? -
sqrt(-error) :
sqrt(error);
2857 for (
int i = 0; i <
fes->
GetNE(); i++)
2877 exgrad->
Eval(vec,*Tr,ip);
2882 return (error < 0.0) ? -
sqrt(-error) :
sqrt(error);
2897 for (
int i = 0; i <
fes->
GetNE(); i++)
2917 excurl->
Eval(vec,*Tr,ip);
2923 return (error < 0.0) ? -
sqrt(-error) :
sqrt(error);
2929 double error = 0.0,
a;
2935 for (
int i = 0; i <
fes->
GetNE(); i++)
2959 return (error < 0.0) ? -
sqrt(-error) :
sqrt(error);
2967 int fdof, intorder, k;
2972 Vector shape, el_dofs, err_val, ell_coeff_val;
2994 intorder = 2 * intorder;
3008 transf = face_elem_transf->
Elem1;
3014 for (k = 0; k < fdof; k++)
3017 el_dofs(k) = (*this)(vdofs[k]);
3021 el_dofs(k) = - (*this)(-1-vdofs[k]);
3028 ell_coeff_val(j) = ell_coeff->
Eval(*transf, eip);
3029 err_val(j) = exsol->
Eval(*transf, eip) - (shape * el_dofs);
3035 transf = face_elem_transf->
Elem2;
3041 for (k = 0; k < fdof; k++)
3044 el_dofs(k) = (*this)(vdofs[k]);
3048 el_dofs(k) = - (*this)(-1-vdofs[k]);
3055 ell_coeff_val(j) += ell_coeff->
Eval(*transf, eip);
3056 ell_coeff_val(j) *= 0.5;
3057 err_val(j) -= (exsol->
Eval(*transf, eip) - (shape * el_dofs));
3061 transf = face_elem_transf;
3066 double nu = jump_scaling.
Eval(h, p);
3067 error += (ip.
weight * nu * ell_coeff_val(j) *
3069 err_val(j) * err_val(j));
3073 return (error < 0.0) ? -
sqrt(-error) :
sqrt(error);
3088 int norm_type)
const
3090 double error1 = 0.0;
3091 double error2 = 0.0;
3099 return sqrt(error1 * error1 + error2 * error2);
3108 return sqrt(L2error*L2error + GradError*GradError);
3117 return sqrt(L2error*L2error + DivError*DivError);
3126 return sqrt(L2error*L2error + CurlError*CurlError);
3132 double error = 0.0,
a;
3137 int fdof, d, i, intorder, j, k;
3164 for (k = 0; k < fdof; k++)
3165 if (vdofs[fdof*d+k] >= 0)
3167 a += (*this)(vdofs[fdof*d+k]) * shape(k);
3171 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
3173 a -= exsol[d]->
Eval(*transf, ip);
3190 int i, fdof,
dim, intorder, j, k;
3194 Vector e_grad, a_grad, shape, el_dofs, err_val, ell_coeff_val;
3197 double a, error = 0.0;
3206 for (i = 0; i < mesh->
GetNE(); i++)
3208 if (elems != NULL && (*elems)[i] == 0) {
continue; }
3225 for (k = 0; k < fdof; k++)
3228 el_dofs(k) = (*this)(vdofs[k]);
3232 el_dofs(k) = -(*this)(-1-vdofs[k]);
3239 a = (el_dofs * shape) - (exsol->
Eval(*transf, ip));
3245 for (i = 0; i < mesh->
GetNE(); i++)
3247 if (elems != NULL && (*elems)[i] == 0) {
continue; }
3265 for (k = 0; k < fdof; k++)
3268 el_dofs(k) = (*this)(vdofs[k]);
3272 el_dofs(k) = -(*this)(-1-vdofs[k]);
3279 exgrad->
Eval(e_grad, *transf, ip);
3281 Mult(dshape, Jinv, dshapet);
3300 for (
int i = 0; i <
fes->
GetNE(); i++)
3310 int intorder = 2*fe->
GetOrder() + 3;
3319 double diff = fabs(vals(j) - exsol.
Eval(*T, ip));
3322 diff =
pow(diff, p);
3325 diff *= weight->
Eval(*T, ip);
3333 diff *= weight->
Eval(*T, ip);
3335 error = std::max(error, diff);
3345 error = -
pow(-error, 1./p);
3349 error =
pow(error, 1./p);
3362 "Incorrect size for result vector");
3369 for (
int i = 0; i <
fes->
GetNE(); i++)
3379 int intorder = 2*fe->
GetOrder() + 3;
3388 double diff = fabs(vals(j) - exsol.
Eval(*T, ip));
3391 diff =
pow(diff, p);
3394 diff *= weight->
Eval(*T, ip);
3402 diff *= weight->
Eval(*T, ip);
3404 error[i] = std::max(error[i], diff);
3412 error[i] = -
pow(-error[i], 1./p);
3416 error[i] =
pow(error[i], 1./p);
3433 for (
int i = 0; i <
fes->
GetNE(); i++)
3443 int intorder = 2*fe->
GetOrder() + 3;
3448 exsol.
Eval(exact_vals, *T, *ir);
3455 vals.
Norm2(loc_errs);
3459 v_weight->
Eval(exact_vals, *T, *ir);
3462 for (
int j = 0; j < vals.
Width(); j++)
3465 for (
int d = 0; d < vals.
Height(); d++)
3467 errj += vals(d,j)*exact_vals(d,j);
3469 loc_errs(j) = fabs(errj);
3476 double errj = loc_errs(j);
3479 errj =
pow(errj, p);
3482 errj *= weight->
Eval(*T, ip);
3490 errj *= weight->
Eval(*T, ip);
3492 error = std::max(error, errj);
3502 error = -
pow(-error, 1./p);
3506 error =
pow(error, 1./p);
3521 "Incorrect size for result vector");
3529 for (
int i = 0; i <
fes->
GetNE(); i++)
3539 int intorder = 2*fe->
GetOrder() + 3;
3544 exsol.
Eval(exact_vals, *T, *ir);
3551 vals.
Norm2(loc_errs);
3555 v_weight->
Eval(exact_vals, *T, *ir);
3558 for (
int j = 0; j < vals.
Width(); j++)
3561 for (
int d = 0; d < vals.
Height(); d++)
3563 errj += vals(d,j)*exact_vals(d,j);
3565 loc_errs(j) = fabs(errj);
3572 double errj = loc_errs(j);
3575 errj =
pow(errj, p);
3578 errj *= weight->
Eval(*T, ip);
3586 errj *= weight->
Eval(*T, ip);
3588 error[i] = std::max(error[i], errj);
3596 error[i] = -
pow(-error[i], 1./p);
3600 error[i] =
pow(error[i], 1./p);
3627 os <<
"NURBS_patches\n";
3646 ofstream ofs(fname);
3647 ofs.precision(precision);
3651 #ifdef MFEM_USE_ADIOS2
3653 const std::string& variable_name,
3656 os.
Save(*
this, variable_name, type);
3672 os <<
"SCALARS " << field_name <<
" double 1\n"
3673 <<
"LOOKUP_TABLE default\n";
3674 for (
int i = 0; i < mesh->
GetNE(); i++)
3681 for (
int j = 0; j < val.
Size(); j++)
3683 os << val(j) <<
'\n';
3687 else if ( (vec_dim == 2 || vec_dim == 3) && mesh->
SpaceDimension() > 1)
3690 os <<
"VECTORS " << field_name <<
" double\n";
3691 for (
int i = 0; i < mesh->
GetNE(); i++)
3700 for (
int j = 0; j < vval.
Width(); j++)
3702 os << vval(0, j) <<
' ' << vval(1, j) <<
' ';
3718 for (
int vd = 0; vd < vec_dim; vd++)
3720 os <<
"SCALARS " << field_name << vd <<
" double 1\n"
3721 <<
"LOOKUP_TABLE default\n";
3722 for (
int i = 0; i < mesh->
GetNE(); i++)
3729 for (
int j = 0; j < val.
Size(); j++)
3731 os << val(j) <<
'\n';
3742 double v1[3] = { p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] };
3743 double v2[3] = { p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2] };
3744 double n[] = { v1[1] * v2[2] - v1[2] * v2[1],
3745 v1[2] * v2[0] - v1[0] * v2[2],
3746 v1[0] * v2[1] - v1[1] * v2[0]
3748 double rl = 1.0 /
sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);
3749 n[0] *= rl; n[1] *= rl; n[2] *= rl;
3751 os <<
" facet normal " << n[0] <<
' ' << n[1] <<
' ' << n[2]
3753 <<
"\n vertex " << p1[0] <<
' ' << p1[1] <<
' ' << p1[2]
3754 <<
"\n vertex " << p2[0] <<
' ' << p2[1] <<
' ' << p2[2]
3755 <<
"\n vertex " << p3[0] <<
' ' << p3[1] <<
' ' << p3[2]
3756 <<
"\n endloop\n endfacet\n";
3772 double pts[4][3], bbox[3][2];
3774 os <<
"solid GridFunction\n";
3776 bbox[0][0] = bbox[0][1] = bbox[1][0] = bbox[1][1] =
3777 bbox[2][0] = bbox[2][1] = 0.0;
3778 for (i = 0; i < mesh->
GetNE(); i++)
3785 for (k = 0; k < RG.
Size()/n; k++)
3787 for (j = 0; j < n; j++)
3790 pts[j][0] = pointmat(0,l);
3791 pts[j][1] = pointmat(1,l);
3792 pts[j][2] = values(l);
3808 bbox[0][0] = pointmat(0,0);
3809 bbox[0][1] = pointmat(0,0);
3810 bbox[1][0] = pointmat(1,0);
3811 bbox[1][1] = pointmat(1,0);
3812 bbox[2][0] = values(0);
3813 bbox[2][1] = values(0);
3816 for (j = 0; j < values.
Size(); j++)
3818 if (bbox[0][0] > pointmat(0,j))
3820 bbox[0][0] = pointmat(0,j);
3822 if (bbox[0][1] < pointmat(0,j))
3824 bbox[0][1] = pointmat(0,j);
3826 if (bbox[1][0] > pointmat(1,j))
3828 bbox[1][0] = pointmat(1,j);
3830 if (bbox[1][1] < pointmat(1,j))
3832 bbox[1][1] = pointmat(1,j);
3834 if (bbox[2][0] > values(j))
3836 bbox[2][0] = values(j);
3838 if (bbox[2][1] < values(j))
3840 bbox[2][1] = values(j);
3845 mfem::out <<
"[xmin,xmax] = [" << bbox[0][0] <<
',' << bbox[0][1] <<
"]\n"
3846 <<
"[ymin,ymax] = [" << bbox[1][0] <<
',' << bbox[1][1] <<
"]\n"
3847 <<
"[zmin,zmax] = [" << bbox[2][0] <<
',' << bbox[2][1] <<
']'
3850 os <<
"endsolid GridFunction" << endl;
3867 MFEM_ASSERT(new_vertex.Size() == mesh->
GetNV(),
"");
3870 old_vertex.SetSize(new_vertex.Size());
3871 for (
int i = 0; i < new_vertex.Size(); i++)
3873 old_vertex[new_vertex[i]] = i;
3880 for (
int i = 0; i < mesh->
GetNV(); i++)
3885 for (
int j = 0; j < new_vdofs.
Size(); j++)
3887 tmp(new_vdofs[j]) = (*this)(old_vdofs[j]);
3893 for (
int i = 0; i < mesh->
GetNEdges(); i++)
3896 if (old_vertex[ev[0]] > old_vertex[ev[1]])
3901 for (
int k = 0; k < dofs.
Size(); k++)
3903 int new_dof = dofs[k];
3904 int old_dof = dofs[(ind[k] < 0) ? -1-ind[k] : ind[k]];
3911 double sign = (ind[k] < 0) ? -1.0 : 1.0;
3912 tmp(new_vdof) = sign * (*this)(old_vdof);
3924 const char *msg =
"invalid input stream";
3930 in >> ident; MFEM_VERIFY(ident ==
"VDim:", msg);
3957 os <<
"VDim: " <<
vdim <<
'\n'
3970 int compression_level)
const
3972 os << R
"(<VTKFile type="UnstructuredGrid" version="0.1")";
3973 if (compression_level != 0)
3975 os << R
"( compressor="vtkZLibDataCompressor")";
3978 os <<
"<UnstructuredGrid>\n";
3982 std::vector<char> buf;
3990 os <<
"<Piece NumberOfPoints=\"" << np
3991 <<
"\" NumberOfCells=\"" << np <<
"\">\n";
3995 os <<
"<DataArray type=\"" << type_str
3996 <<
"\" NumberOfComponents=\"3\" format=\"" << fmt_str <<
"\">\n";
3999 for (
int i = 0; i < ne; i++)
4003 for (
int j = 0; j < ir.
Size(); j++)
4018 os <<
"</DataArray>\n";
4019 os <<
"</Points>\n";
4024 os << R
"(<DataArray type="Int32" Name="connectivity" format=")"
4025 << fmt_str << "\">\n";
4032 os <<
"</DataArray>\n";
4034 os << R
"(<DataArray type="Int32" Name="offsets" format=")"
4035 << fmt_str << "\">\n";
4041 os <<
"</DataArray>\n";
4043 os << R
"(<DataArray type="UInt8" Name="types" format=")"
4044 << fmt_str << "\">\n";
4045 for (
int i = 0; i < np; i++)
4054 os <<
"</DataArray>\n";
4057 os <<
"<PointData>\n";
4058 os <<
"<DataArray type=\"" << type_str <<
"\" Name=\"u\" format=\""
4059 << fmt_str <<
"\" NumberOfComponents=\"" <<
vdim <<
"\">\n";
4060 for (
int i = 0; i < ne; i++)
4064 for (
int j = 0; j < vals.
Size(); ++j)
4066 for (
int vd = 0; vd <
vdim; ++vd)
4077 os <<
"</DataArray>\n";
4078 os <<
"</PointData>\n";
4081 os <<
"</UnstructuredGrid>\n";
4082 os <<
"</VTKFile>" << std::endl;
4086 int compression_level)
const
4088 std::ofstream
f(filename +
".vtu");
4089 SaveVTU(f, format, compression_level);
4097 int with_subdomains,
4105 int nfe = ufes->
GetNE();
4109 Vector ul, fl, fla, d_xyz;
4119 if (with_subdomains)
4124 double total_error = 0.0;
4125 for (
int s = 1;
s <= nsd;
s++)
4128 u.
ComputeFlux(blfi, flux, with_coeff, (with_subdomains ?
s : -1));
4130 for (
int i = 0; i < nfe; i++)
4132 if (with_subdomains && ufes->
GetAttribute(i) !=
s) {
continue; }
4142 *ffes->
GetFE(i), fl, with_coeff);
4147 (aniso_flags ? &d_xyz : NULL));
4155 for (
int k = 0; k <
dim; k++)
4160 double thresh = 0.15 * 3.0/
dim;
4162 for (
int k = 0; k <
dim; k++)
4164 if (d_xyz[k] / sum > thresh) { flag |= (1 << k); }
4167 (*aniso_flags)[i] = flag;
4175 auto process_local_error = total_error;
4176 MPI_Allreduce(&process_local_error, &total_error, 1, MPI_DOUBLE,
4177 MPI_SUM, pfes->GetComm());
4179 #endif // MFEM_USE_MPI
4203 for (
int j = 0; j < nip; j++)
4212 double errj = val1.
Norml2();
4215 errj =
pow(errj, p);
4220 norm = std::max(norm, errj);
4229 norm = -
pow(-norm, 1./p);
4233 norm =
pow(norm, 1./p);
4247 return sol_in.
Eval(*T_in, ip);
4258 string cname = name;
4259 if (cname ==
"Linear")
4263 else if (cname ==
"Quadratic")
4267 else if (cname ==
"Cubic")
4271 else if (!strncmp(name,
"H1_", 3))
4275 else if (!strncmp(name,
"H1Pos_", 6))
4280 else if (!strncmp(name,
"L2_T", 4))
4284 else if (!strncmp(name,
"L2_", 3))
4290 mfem::err <<
"Extrude1DGridFunction : unknown FE collection : "
int GetNPoints() const
Returns the number of the points in the integration rule.
void SaveSTLTri(std::ostream &out, double p1[], double p2[], double p3[])
Abstract class for all finite elements.
void LegacyToNewVertexOrdering(Array< int > &order) const
I/O: Return a map from old (v1.1) vertex indices to new vertex indices.
int Size() const
For backward compatibility define Size to be synonym of Width()
Ordering::Type GetOrdering() const
Return the ordering method.
int Size() const
Return the logical size of the array.
void SetSubVector(const Array< int > &dofs, const double value)
Set the entries listed in dofs to the given value.
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
void GetVertexVDofs(int i, Array< int > &vdofs) const
int GetDim() const
Returns the reference space dimension for the finite element.
int GetAttribute(int i) const
int GetNDofs() const
Returns number of degrees of freedom.
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 GetElementAverages(GridFunction &avgs) const
void GetVectorValues(int i, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr) const
const double * GetVertex(int i) const
Return pointer to vertex i's coordinates.
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.
int DofToVDof(int dof, int vd, int ndofs=-1) const
const IntegrationRule & GetElementIntRule(int idx) const
Get the IntegrationRule associated with mesh element idx.
const SparseMatrix * GetConformingProlongation() const
The returned SparseMatrix is owned by the FiniteElementSpace.
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...
Class used for extruding scalar GridFunctions.
void SumFluxAndCount(BilinearFormIntegrator &blfi, GridFunction &flux, Array< int > &counts, bool wcoef, int subdomain)
void GetElementVertices(int i, Array< int > &vertices) const
Returns the vertices of element i.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
void GetEdgeVertices(int i, Array< int > &vert) const
Returns the indices of the vertices of edge i.
void MergeGridFunctions(GridFunction *gf_array[], int num_pieces, GridFunction &merged)
Base class for vector Coefficients that optionally depend on time and space.
virtual double ComputeL2Error(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
void ProjectDeltaCoefficient(DeltaCoefficient &delta_coeff, double &integral)
const FiniteElement * GetEdgeElement(int i, int variant=0) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th edge in the ...
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 Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
virtual void ComputeElementLpErrors(const double p, Coefficient &exsol, Vector &error, Coefficient *weight=NULL, const IntegrationRule *irs[]=NULL) 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 ...
virtual double ComputeCurlError(VectorCoefficient *excurl, const IntegrationRule *irs[]=NULL) const
Returns ||curl u_ex - curl u_h||_L2 for ND elements.
virtual int GetContType() const =0
virtual void GetVectorValue(int i, const IntegrationPoint &ip, Vector &val) const
void GetBdrElementFace(int i, int *f, int *o) const
Return the index and the orientation of the face of bdr element i. (3D)
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
void SetSize(int s)
Resize the vector to size s.
void RestrictConforming()
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...
GridFunction * Extrude1DGridFunction(Mesh *mesh, Mesh *mesh2d, GridFunction *sol, const int ny)
Extrude a scalar 1D GridFunction, after extruding the mesh with Extrude1D.
double Scale()
Return the scale factor times the optional time dependent function. Returns with when not set by th...
virtual DofTransformation * GetBdrElementDofs(int bel, Array< int > &dofs) const
Returns indices of degrees of freedom for boundary element 'bel'.
void ProjectDiscCoefficient(VectorCoefficient &coeff, Array< int > &dof_attr)
bool own_qspace
QuadratureSpace ownership flag.
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
int GetSize() const
Return the total number of quadrature points.
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
double Norml2() const
Returns the l2 norm of the vector.
virtual const FiniteElement * FiniteElementForGeometry(Geometry::Type GeomType) const =0
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
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...
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 ...
int Size() const
Returns the size of the vector.
Mesh * GetMesh() const
Returns the mesh.
int GetBdrAttribute(int i) const
int GetNE() const
Returns number of elements.
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...
double Tol()
Return the tolerance used to identify the mesh vertices.
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.
virtual double ComputeHDivError(VectorCoefficient *exsol, Coefficient *exdiv, const IntegrationRule *irs[]=NULL) const
Returns the error measured in H(div)-norm for RT elements.
int vdim
Vector dimension.
void GetVectorGradientHat(ElementTransformation &T, DenseMatrix &gh) const
int GetNV() const
Returns number of vertices in the mesh.
const FiniteElement * GetFaceElement(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th face in the ...
int GetMapType() const
Returns the FiniteElement::MapType of the element describing how reference functions are mapped to ph...
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...
Data arrays will be written in ASCII format.
void ComputeMeans(AvgType type, Array< int > &zones_per_vdof)
double * GetData() const
Return a pointer to the beginning of the Vector data.
void CalcOrtho(const DenseMatrix &J, Vector &n)
void GetNodalValues(int i, Array< double > &nval, int vdim=1) const
Returns the values in the vertices of i'th element for dimension vdim.
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...
virtual FaceElementTransformations * GetFaceElementTransformations(int FaceNo, int mask=31)
Geometry::Type GetElementBaseGeometry(int i) const
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
const IntegrationRule * GetVertices(int GeomType)
Return an IntegrationRule consisting of all vertices of the given Geometry::Type, GeomType...
int GetCurlDim() const
Returns the dimension of the curl for vector-valued finite elements.
void WriteBinaryOrASCII(std::ostream &os, std::vector< char > &buf, const T &val, const char *suffix, VTKFormat format)
Write either ASCII data to the stream or binary data to the buffer depending on the given format...
void skip_comment_lines(std::istream &is, const char comment_char)
Check if the stream starts with comment_char. If so skip it.
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...
DofTransformation * GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th boundary element.
void GetEdgeTransformation(int i, IsoparametricTransformation *EdTr)
void GetVectorFieldNodalValues(Vector &val, int comp) const
void ImposeBounds(int i, const Vector &weights, const Vector &lo_, const Vector &hi_)
Vector & operator=(const double *v)
Copy Size() entries from v.
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
virtual void GetElementDofValues(int el, Vector &dof_vals) const
void Load(std::istream **in, int np, int *dim)
Reads a vector from multiple files.
Piecewise-(bi)cubic continuous finite elements.
int GetNE() const
Returns number of elements in the mesh.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient in the element described by T at the point ip.
int GetNE() const
Returns number of elements in the mesh.
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...
bool Nonconforming() const
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
void ProjectBdrCoefficientNormal(VectorCoefficient &vcoeff, Array< int > &bdr_attr)
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
double f(const Vector &xvec)
void GetHessians(int i, const IntegrationRule &ir, DenseMatrix &hess, int vdim=1) const
double GetElementSize(ElementTransformation *T, int type=0)
int GetNBE() const
Returns number of boundary elements in the mesh.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
void Swap(Vector &other)
Swap the contents of two Vectors.
Mesh * GetMesh() const
Returns the mesh.
void GetVectorFieldValues(int i, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr, int comp=0) const
void PrintSolution(const GridFunction &sol, std::ostream &out) const
Coefficient * Weight()
See SetWeight() for description of the weight Coefficient.
virtual double ComputeH1Error(Coefficient *exsol, VectorCoefficient *exgrad, Coefficient *ell_coef, double Nu, int norm_type) const
void MakeTRef(FiniteElementSpace *f, double *tv)
Associate a new FiniteElementSpace and new true-dof data with the GridFunction.
void SetMaxIter(int max_it)
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 Norm2(double *v) const
Take the 2-norm of the columns of A and store in v.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void SetLinearConstraint(const Vector &w_, double a_)
virtual const Operator * GetProlongationMatrix() const
The returned Operator is owned by the FiniteElementSpace.
int GetElementForDof(int i) const
Return the index of the first element that contains dof i.
QuadratureFunction()
Create an empty QuadratureFunction.
VTKFormat
Data array format for VTK and VTU files.
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
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...
GeometryRefiner GlobGeometryRefiner
ElementTransformation * GetBdrElementTransformation(int i) const
Returns ElementTransformation for the i-th boundary element.
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.
void GetLaplacians(int i, const IntegrationRule &ir, Vector &laps, int vdim=1) const
void GetTrueDofs(Vector &tv) const
Extract the true-dofs from the GridFunction.
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
RefinedGeometry * Refine(Geometry::Type Geom, int Times, int ETimes=1)
void GetValues(int i, const IntegrationRule &ir, Vector &vals, int vdim=1) const
int GetVDim()
Returns dimension of the vector.
int GetVDim() const
Returns vector dimension.
A class for non-conforming AMR. The class is not used directly by the user, rather it is an extension...
void LoadSolution(std::istream &input, GridFunction &sol) const
FaceElementTransformations * GetBdrFaceTransformations(int BdrElemNo)
FiniteElementSpace * FESpace()
GridFunction & operator=(const GridFunction &rhs)
Copy assignment. Only the data of the base class Vector is copied.
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...
virtual double ComputeLpError(const double p, Coefficient &exsol, Coefficient *weight=NULL, const IntegrationRule *irs[]=NULL) const
QuadratureFunction & operator=(double value)
Redefine '=' for QuadratureFunction = constant.
virtual DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'.
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
void SaveVTU(std::ostream &out, VTKFormat format=VTKFormat::ASCII, int compression_level=0) const
Write the QuadratureFunction to out in VTU (ParaView) format.
FDualNumber< tbase > pow(const FDualNumber< tbase > &a, const FDualNumber< tbase > &b)
pow([dual number],[dual number])
int GetVDim() const
Returns the vector dimension for vector-valued finite elements.
int SpaceDimension() const
double Min() const
Returns the minimal element of the vector.
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i-th element.
double Norml1() const
Returns the l_1 norm of the vector.
virtual double ComputeGradError(VectorCoefficient *exgrad, const IntegrationRule *irs[]=NULL) const
Returns ||grad u_ex - grad u_h||_L2 for H1 or L2 elements.
bool FaceIsInterior(int FaceNo) const
Return true if the given face is interior.
bool IsIdentityProlongation(const Operator *P)
bool IsLegacyLoaded() const
I/O: Return true if the mesh was loaded from the legacy v1.1 format.
void GetFaceElements(int Face, int *Elem1, int *Elem2) const
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]...
void SetAbsTol(double atol)
double p(const Vector &x, double t)
void SetRelTol(double rtol)
const NURBSExtension * GetNURBSext() const
double Distance(const double *x, const double *y, const int n)
void Print(std::ostream &out=mfem::out, int width=8) const
Prints vector to stream out.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
int GetLocalDofForDof(int i) const
Return the local dof index in the first element that contains dof i.
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
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...
void ProjectGridFunction(const GridFunction &src)
Project the src GridFunction to this GridFunction, both of which must be on the same mesh...
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 ...
QuadratureSpace * qspace
Associated QuadratureSpace.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
virtual double ComputeMaxError(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
int NumBdr(int GeomType)
Return the number of boundary "faces" of a given Geometry::Type.
void GetColumnReference(int c, Vector &col)
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 Save(std::ostream &out) const
Write the QuadratureSpace to the stream out.
Field is continuous across element interfaces.
FiniteElementCollection * fec
Used when the grid function is read from a file. It can also be set explicitly, see MakeOwner()...
void GetVectorGradient(ElementTransformation &tr, DenseMatrix &grad) const
double GetDivergence(ElementTransformation &tr) const
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.
virtual double ComputeDivError(Coefficient *exdiv, const IntegrationRule *irs[]=NULL) const
Returns ||div u_ex - div u_h||_L2 for RT elements.
int GetFaceVectorValues(int i, int side, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr) 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.
bool Nonconforming() 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.
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
int GetNVDofs() const
Number of all scalar vertex dofs.
virtual const char * Name() const
Vector & Add(const double a, const Vector &Va)
(*this) += a * Va
Class for integration point with weight.
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)
double Max() const
Returns the maximal element of the vector.
FDualNumber< tbase > sqrt(const FDualNumber< tbase > &f)
sqrt([dual number])
void GetEdgeInteriorDofs(int i, Array< int > &dofs) const
const char * VTKByteOrder()
Determine the byte order and return either "BigEndian" or "LittleEndian".
virtual void AssembleElementMatrix2(const FiniteElement &trial_fe, const FiniteElement &test_fe, ElementTransformation &Trans, DenseMatrix &elmat)
void NewMemoryAndSize(const Memory< double > &mem, int s, bool own_mem)
Reset the Vector to use the given external Memory mem and size s.
int GetFaceValues(int i, int side, const IntegrationRule &ir, Vector &vals, DenseMatrix &tr, int vdim=1) const
void GetElementValues(int idx, Vector &values)
Return all values associated with mesh element idx in a Vector.
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
const Operator * GetUpdateOperator()
Get the GridFunction update operator.
void GetGradients(ElementTransformation &tr, const IntegrationRule &ir, DenseMatrix &grad) const
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.
double infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
virtual void Mult(const Vector &xt, Vector &x) const
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
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 GetFaceVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th face element (2D and 3D).
virtual double ComputeW11Error(Coefficient *exsol, VectorCoefficient *exgrad, int norm_type, Array< int > *elems=NULL, const IntegrationRule *irs[]=NULL) const
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
void GetEdgeVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th edge.
int GetNEdges() const
Return the number of edges.
void filter_dos(std::string &line)
Check for, and remove, a trailing '\r' from and std::string.
void MultAtB(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &AtB)
Multiply the transpose of a matrix A with a matrix B: At*B.
void GetCurl(ElementTransformation &tr, Vector &curl) const
const FiniteElementCollection * FEColl() const
void Mult(const double *x, double *y) const
Matrix vector multiplication.
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 bool UseDevice() const
Return the device flag of the Memory object used by the Vector.
virtual void ComputeFlux(BilinearFormIntegrator &blfi, GridFunction &flux, bool wcoef=true, int subdomain=-1)
Arbitrary order H1-conforming (continuous) finite elements.
void pts(int iphi, int t, double x[])
virtual double ComputeDGFaceJumpError(Coefficient *exsol, Coefficient *ell_coeff, class JumpScaling jump_scaling, const IntegrationRule *irs[]=NULL) const
Class representing the storage layout of a QuadratureFunction.
double u(const Vector &xvec)
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th boundary fac...
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
virtual const SparseMatrix * GetRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
void SetBounds(const Vector &lo_, const Vector &hi_)
double Eval(double h, int p) const
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...
int GetRangeType() const
Returns the FiniteElement::RangeType of the element, one of {SCALAR, VECTOR}.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
void Save(std::ostream &out) const
Save finite element space to output stream out.
void BuildDofToArrays()
Initialize internal data that enables the use of the methods GetElementForDof() and GetLocalDofForDof...
double Sum() const
Return the sum of the vector entries.
void WriteBase64WithSizeAndClear(std::ostream &os, std::vector< char > &buf, int compression_level)
Encode in base 64 (and potentially compress) the given data, write it to the output stream (with a he...
Class representing a function through its values (scalar or vector) at quadrature points...
void GetValuesFrom(const GridFunction &orig_func)
int GetNFDofs() const
Number of all scalar face-interior dofs.
int GetNEDofs() const
Number of all scalar edge-interior dofs.
void GetElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of element i.
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 ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
void AccumulateAndCountBdrValues(Coefficient *coeff[], VectorCoefficient *vcoeff, Array< int > &attr, Array< int > &values_counter)
void Save(std::ostream &out) const
Write the QuadratureFunction to the stream out.
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...
virtual double GetValue(int i, const IntegrationPoint &ip, int vdim=1) const
void GetGradient(ElementTransformation &tr, Vector &grad) const
Arbitrary order "L2-conforming" discontinuous finite elements.
void ProjectVectorFieldOn(GridFunction &vec_field, int comp=0)
void DofsToVDofs(Array< int > &dofs, int ndofs=-1) const