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);
267 int nfe = ufes->
GetNE();
275 for (
int i = 0; i < nfe; i++)
277 if (subdomain >= 0 && ufes->
GetAttribute(i) != subdomain)
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();
420 "invalid FE map type");
422 for (k = 0; k < n; k++)
425 nval[k] = shape * ((
const double *)loc_data + dof * vdim);
432 for (k = 0; k < n; k++)
436 nval[k] = loc_data * (&vshape(0,vdim));
457 fe->CalcPhysShape(*Tr, DofVal);
465 return (DofVal * LocVec);
472 int dof = FElem->
GetDof();
496 for (
int k = 0; k < vdim; k++)
498 val(k) = shape * ((
const double *)loc_data + dof * k);
523 int dof = FElem->
GetDof();
524 Vector DofVal(dof), loc_data(dof);
532 for (
int k = 0; k < n; k++)
535 vals(k) = DofVal * loc_data;
541 for (
int k = 0; k < n; k++)
545 vals(k) = DofVal * loc_data;
574 "invalid FE map type");
576 int dof = FElem->
GetDof();
577 Vector DofLap(dof), loc_data(dof);
579 for (
int k = 0; k < n; k++)
584 laps(k) = DofLap * loc_data;
614 int size = (dim*(dim+1))/2;
617 "invalid FE map type");
619 int dof = FElem->
GetDof();
627 for (
int k = 0; k < n; k++)
633 for (
int j = 0; j <
size; j++)
635 for (
int d = 0; d < dof; d++)
637 hess(k,j) += DofHes(d,j) * loc_data[d];
722 fip.
x = 1.0 - ip.
x - ip.
y;
728 fip.
y = 1.0 - ip.
x - ip.
y;
767 int comp,
Vector *tr)
const
793 MFEM_ABORT(
"GridFunction::GetValue: Field continuity type \""
795 <<
"on mesh edges.");
808 MFEM_ABORT(
"GridFunction::GetValue: Field continuity type \""
810 <<
"on mesh faces.");
862 MFEM_ABORT(
"GridFunction::GetValue: Unsupported element type \""
880 return (DofVal * LocVec);
895 for (
int j = 0; j < nip; j++)
932 MFEM_ABORT(
"GridFunction::GetVectorValue: Field continuity type \""
934 <<
"on mesh edges.");
947 MFEM_ABORT(
"GridFunction::GetVectorValue: Field continuity type \""
949 <<
"on mesh faces.");
1001 MFEM_ABORT(
"GridFunction::GetVectorValue: Unsupported element type \""
1003 if (val.
Size() > 0) { val = NAN; }
1028 for (
int k = 0; k < vdim; k++)
1030 val(k) = shape * ((
const double *)loc_data + dof * k);
1036 int vdim = std::max(spaceDim, fe->
GetVDim());
1040 vshape.MultTranspose(loc_data, val);
1055 int dof = FElem->
GetDof();
1073 for (
int j = 0; j < nip; j++)
1079 for (
int k = 0; k < vdim; k++)
1081 vals(k,j) = shape * ((
const double *)loc_data + dof * k);
1088 int vdim = std::max(spaceDim, FElem->
GetVDim());
1094 for (
int j = 0; j < nip; j++)
1101 vshape.MultTranspose(loc_data, val_j);
1157 Vector shape, loc_values, orig_loc_values;
1158 int i, j, d, ne, dof, odof, vdim;
1162 for (i = 0; i < ne; i++)
1174 odof = orig_fe->
GetDof();
1175 loc_values.
SetSize(dof * vdim);
1178 for (j = 0; j < dof; j++)
1182 for (d = 0; d < vdim; d++)
1184 loc_values(d*dof+j) =
1185 shape * ((
const double *)orig_loc_values + d * odof) ;
1204 Vector shape, loc_values, loc_values_t, orig_loc_values, orig_loc_values_t;
1205 int i, j, d, nbe, dof, odof, vdim;
1209 for (i = 0; i < nbe; i++)
1217 odof = orig_fe->
GetDof();
1218 loc_values.
SetSize(dof * vdim);
1221 for (j = 0; j < dof; j++)
1225 for (d = 0; d < vdim; d++)
1227 loc_values(d*dof+j) =
1228 shape * ((
const double *)orig_loc_values + d * odof);
1242 int d, k, n, sdim, dof;
1254 Vector loc_data, val(sdim);
1260 for (k = 0; k < n; k++)
1266 for (d = 0; d < sdim; d++)
1283 double *temp =
new double[
size];
1286 for (j = 0; j < ndofs; j++)
1287 for (i = 0; i < vdim; i++)
1289 temp[j+i*ndofs] =
data[k++];
1292 for (i = 0; i <
size; i++)
1320 val(vertices[k]) += vals(k, comp);
1321 overlap[vertices[k]]++;
1325 for (i = 0; i < overlap.Size(); i++)
1327 val(i) /= overlap[i];
1335 int d, i, k, ind, dof, sdim;
1344 for (i = 0; i < new_fes->
GetNE(); i++)
1351 for (d = 0; d < sdim; d++)
1353 for (k = 0; k < dof; k++)
1355 if ( (ind=new_vdofs[dof*d+k]) < 0 )
1357 ind = -1-ind, vals(k, d) = - vals(k, d);
1359 vec_field(ind) += vals(k, d);
1365 for (i = 0; i < overlap.Size(); i++)
1367 vec_field(i) /= overlap[i];
1380 Vector pt_grad, loc_func;
1381 int i, j, k,
dim, dof, der_dof, ind;
1388 for (i = 0; i < der_fes->
GetNE(); i++)
1397 der_dof = der_fe->
GetDof();
1403 for (j = 0; j < dof; j++)
1404 loc_func(j) = ( (ind=vdofs[comp*dof+j]) >= 0 ) ?
1406 for (k = 0; k < der_dof; k++)
1414 for (j = 0; j <
dim; j++)
1416 a += inv_jac(j, der_comp) * pt_grad(j);
1418 der(der_dofs[k]) +=
a;
1419 zones_per_dof[der_dofs[k]]++;
1429 for (
int i = 0; i < overlap.
Size(); i++)
1431 der(i) /= overlap[i];
1456 MultAtB(loc_data_mat, dshape, gh);
1470 "invalid FE map type");
1475 for (
int i = 0; i < Jinv.
Width(); i++)
1477 for (
int j = 0; j < Jinv.
Height(); j++)
1479 div_v += grad_hat(i, j) * Jinv(j, i);
1496 return (loc_data * divshape) / T.
Weight();
1542 MFEM_ABORT(
"GridFunction::GetDivergence: Unsupported element type \""
1560 "invalid FE map type");
1566 Mult(grad_hat, Jinv, grad);
1567 MFEM_ASSERT(grad.Height() == grad.Width(),
"");
1568 if (grad.Height() == 3)
1571 curl(0) = grad(2,1) - grad(1,2);
1572 curl(1) = grad(0,2) - grad(2,0);
1573 curl(2) = grad(1,0) - grad(0,1);
1575 else if (grad.Height() == 2)
1578 curl(0) = grad(1,0) - grad(0,1);
1593 curl.
SetSize(curl_shape.Width());
1595 curl_shape.MultTranspose(loc_data, curl);
1639 MFEM_ABORT(
"GridFunction::GetCurl: Unsupported element type \""
1653 "invalid FE map type");
1707 MFEM_ABORT(
"GridFunction::GetGradient: Unsupported element type \""
1734 dshape.MultTranspose(lval, gh);
1755 Mult(grad_hat, Jinv, grad);
1798 MFEM_ABORT(
"GridFunction::GetVectorGradient: "
1799 "Unsupported element type \"" << T.
ElementType <<
"\"");
1811 Vector loc_avgs, loc_this;
1816 for (
int i = 0; i <
fes->
GetNE(); i++)
1821 te_doftrans = avgs.FESpace()->GetElementDofs(i, te_dofs);
1828 loc_mass.
Mult(loc_this, loc_avgs);
1833 avgs.AddElementVector(te_dofs, loc_avgs);
1835 loc_mass.
Mult(loc_this, loc_avgs);
1836 int_psi.AddElementVector(te_dofs, loc_avgs);
1838 for (
int i = 0; i < avgs.Size(); i++)
1840 avgs(i) /= int_psi(i);
1861 if (!mesh->
GetNE()) {
return; }
1872 MFEM_VERIFY(vdim == src.
fes->
GetVDim(),
"incompatible vector dimensions!");
1877 for (
int i = 0; i < mesh->
GetNE(); i++)
1884 dest_lvec.SetSize(vdim*P.
Height());
1894 for (
int vd = 0; vd < vdim; vd++)
1913 Vector vals, new_vals(size);
1921 MFEM_ASSERT(weights.
Size() ==
size,
"Different # of weights and dofs.");
1922 MFEM_ASSERT(lo_.
Size() ==
size,
"Different # of lower bounds and dofs.");
1923 MFEM_ASSERT(hi_.
Size() ==
size,
"Different # of upper bounds and dofs.");
1926 double tol = 1.e-12;
1934 slbqp.
Mult(vals, new_vals);
1944 double min_,
double max_)
1949 Vector vals, new_vals(size);
1956 double max_val = vals.
Max();
1957 double min_val = vals.
Min();
1959 if (max_val <= min_)
1970 if (min_ <= min_val && max_val <= max_)
1975 Vector minv(size), maxv(size);
1976 minv = (min_ > min_val) ? min_ : min_val;
1977 maxv = (max_ < max_val) ? max_ : max_val;
1990 R->
Mult(*
this, tmp);
1991 P->
Mult(tmp, *
this);
2009 for (j = 0; j < vertices.
Size(); j++)
2011 nval(vertices[j]) += values[j];
2012 overlap[vertices[j]]++;
2015 for (i = 0; i < overlap.Size(); i++)
2017 nval(i) /= overlap[i];
2035 for (
int i = 0; i <
fes->
GetNE(); i++)
2043 for (
int j = 0; j < vdofs.
Size(); j++)
2047 MFEM_VERIFY(vals[j] != 0.0,
2048 "Coefficient has zeros, harmonic avg is undefined!");
2049 (*this)(vdofs[j]) += 1.0 / vals[j];
2053 (*this)(vdofs[j]) += vals[j];
2055 else { MFEM_ABORT(
"Not implemented"); }
2057 zones_per_vdof[vdofs[j]]++;
2076 for (
int i = 0; i <
fes->
GetNE(); i++)
2084 for (
int j = 0; j < vdofs.
Size(); j++)
2101 MFEM_VERIFY(vals[j] != 0.0,
2102 "Coefficient has zeros, harmonic avg is undefined!");
2103 (*this)(ldof) += isign / vals[j];
2107 (*this)(ldof) += isign*vals[j];
2110 else { MFEM_ABORT(
"Not implemented"); }
2112 zones_per_vdof[ldof]++;
2121 int i, j, fdof, d, ind, vdim;
2145 for (j = 0; j < fdof; j++)
2149 if (vcoeff) { vcoeff->
Eval(vc, *transf, ip); }
2150 for (d = 0; d < vdim; d++)
2152 if (!vcoeff && !coeff[d]) {
continue; }
2154 val = vcoeff ? vc(d) : coeff[d]->
Eval(*transf, ip);
2155 if ( (ind = vdofs[fdof*d+j]) < 0 )
2157 val = -val, ind = -1-ind;
2159 if (++values_counter[ind] == 1)
2165 (*this)(ind) += val;
2188 for (i = 0; i < bdr_edges.
Size(); i++)
2190 int edge = bdr_edges[i];
2192 if (vdofs.
Size() == 0) {
continue; }
2200 for (d = 0; d < vdim; d++)
2202 if (!coeff[d]) {
continue; }
2204 fe->
Project(*coeff[d], *transf, vals);
2205 for (
int k = 0; k < vals.
Size(); k++)
2207 ind = vdofs[d*vals.
Size()+k];
2208 if (++values_counter[ind] == 1)
2210 (*this)(ind) = vals(k);
2214 (*this)(ind) += vals(k);
2222 fe->
Project(*vcoeff, *transf, vals);
2223 for (
int k = 0; k < vals.
Size(); k++)
2226 if (++values_counter[ind] == 1)
2228 (*this)(ind) = vals(k);
2232 (*this)(ind) += vals(k);
2243 for (
int i = 0; i < dofs.
Size(); i++)
2246 double val = vals(i);
2247 if (k < 0) { k = -1 - k; val = -val; }
2248 if (++values_counter[k] == 1)
2283 fe->
Project(vcoeff, *T, lvec);
2285 accumulate_dofs(dofs, lvec, *
this, values_counter);
2295 for (
int i = 0; i < bdr_edges.
Size(); i++)
2297 int edge = bdr_edges[i];
2299 if (dofs.
Size() == 0) {
continue; }
2305 fe->
Project(vcoeff, *T, lvec);
2306 accumulate_dofs(dofs, lvec, *
this, values_counter);
2316 for (
int i = 0; i <
size; i++)
2318 const int nz = zones_per_vdof[i];
2319 if (nz) { (*this)(i) /= nz; }
2324 for (
int i = 0; i <
size; i++)
2326 const int nz = zones_per_vdof[i];
2327 if (nz) { (*this)(i) = nz/(*
this)(i); }
2332 MFEM_ABORT(
"invalid AvgType");
2347 const double *center = delta_coeff.
Center();
2348 const double *vert = mesh->
GetVertex(0);
2349 double min_dist, dist;
2353 min_dist =
Distance(center, vert, dim);
2354 for (
int i = 0; i < mesh->
GetNV(); i++)
2357 dist =
Distance(center, vert, dim);
2358 if (dist < min_dist)
2368 if (min_dist >= delta_coeff.
Tol())
2377 Vector vals, loc_mass_vals;
2378 for (
int i = 0; i < mesh->
GetNE(); i++)
2381 for (
int j = 0; j < vertices.
Size(); j++)
2382 if (vertices[j] == v_idx)
2392 loc_mass.Mult(vals, loc_mass_vals);
2393 integral += loc_mass_vals.
Sum();
2404 if (delta_c == NULL)
2409 for (
int i = 0; i <
fes->
GetNE(); i++)
2427 (*this) *= (delta_c->
Scale() / integral);
2440 for (
int i = 0; i < dofs.
Size(); i++)
2453 (*this)(vdof) = coeff.
Eval(*T, ip);
2489 for (
int i = 0; i < dofs.
Size(); i++)
2501 vcoeff.
Eval(val, *T, ip);
2505 (*this)(vdof) = val(vd);
2538 int i, j, fdof, d, ind, vdim;
2554 for (j = 0; j < fdof; j++)
2558 for (d = 0; d < vdim; d++)
2560 if (!coeff[d]) {
continue; }
2562 val = coeff[d]->
Eval(*transf, ip);
2563 if ( (ind = vdofs[fdof*d+j]) < 0 )
2565 val = -val, ind = -1-ind;
2585 for (
int i = 0; i <
fes->
GetNE(); i++)
2594 for (
int j = 0; j < vdofs.
Size(); j++)
2596 if (attr > dof_attr[vdofs[j]])
2598 (*this)(vdofs[j]) = vals[j];
2599 dof_attr[vdofs[j]] = attr;
2641 for (
int i = 0; i < values_counter.
Size(); i++)
2643 MFEM_ASSERT(
bool(values_counter[i]) ==
bool(ess_vdofs_marker[i]),
2658 ess_vdofs_marker = 0;
2662 if (!coeff[i]) {
continue; }
2664 for (
int j = 0; j<
Size(); j++)
2666 ess_vdofs_marker[j] = bool(ess_vdofs_marker[j]) ||
2667 bool(component_dof_marker[j]);
2670 for (
int i = 0; i < values_counter.
Size(); i++)
2672 MFEM_ASSERT(
bool(values_counter[i]) == ess_vdofs_marker[i],
2688 Vector vc(dim), nor(dim), lvec, shape;
2708 vcoeff.
Eval(vc, *T, ip);
2711 lvec.
Add(ip.
weight * (vc * nor), shape);
2723 Vector vc(dim), nor(dim), lvec;
2739 vcoeff.
Eval(vc, *T, ip);
2741 lvec(j) = (vc * nor);
2758 for (
int i = 0; i < values_counter.
Size(); i++)
2760 MFEM_ASSERT(
bool(values_counter[i]) ==
bool(ess_vdofs_marker[i]),
2770 double error = 0.0,
a;
2775 int fdof, d, i, intorder, j, k;
2779 if (elems != NULL && (*elems)[i] == 0) {
continue; }
2802 for (k = 0; k < fdof; k++)
2803 if (vdofs[fdof*d+k] >= 0)
2805 a += (*this)(vdofs[fdof*d+k]) * shape(k);
2809 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
2812 a -= exsol[d]->
Eval(*transf, ip);
2818 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
2831 for (
int i = 0; i <
fes->
GetNE(); i++)
2833 if (elems != NULL && (*elems)[i] == 0) {
continue; }
2835 int intorder = 2*fe->
GetOrder() + 3;
2847 exsol.
Eval(exact_vals, *T, *ir);
2850 vals.
Norm2(loc_errs);
2855 error += ip.
weight * T->
Weight() * (loc_errs(j) * loc_errs(j));
2859 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
2893 exgrad->
Eval(vec,*Tr,ip);
2897 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
2912 for (
int i = 0; i <
fes->
GetNE(); i++)
2932 exgrad->
Eval(vec,*Tr,ip);
2937 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
2952 for (
int i = 0; i <
fes->
GetNE(); i++)
2972 excurl->
Eval(vec,*Tr,ip);
2978 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
2984 double error = 0.0,
a;
2990 for (
int i = 0; i <
fes->
GetNE(); i++)
3014 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
3022 int fdof, intorder, k;
3027 Vector shape, el_dofs, err_val, ell_coeff_val;
3049 intorder = 2 * intorder;
3063 transf = face_elem_transf->
Elem1;
3069 for (k = 0; k < fdof; k++)
3072 el_dofs(k) = (*this)(vdofs[k]);
3076 el_dofs(k) = - (*this)(-1-vdofs[k]);
3083 ell_coeff_val(j) = ell_coeff->
Eval(*transf, eip);
3084 err_val(j) = exsol->
Eval(*transf, eip) - (shape * el_dofs);
3090 transf = face_elem_transf->
Elem2;
3096 for (k = 0; k < fdof; k++)
3099 el_dofs(k) = (*this)(vdofs[k]);
3103 el_dofs(k) = - (*this)(-1-vdofs[k]);
3110 ell_coeff_val(j) += ell_coeff->
Eval(*transf, eip);
3111 ell_coeff_val(j) *= 0.5;
3112 err_val(j) -= (exsol->
Eval(*transf, eip) - (shape * el_dofs));
3116 transf = face_elem_transf;
3121 double nu = jump_scaling.
Eval(h, p);
3122 error += (ip.
weight * nu * ell_coeff_val(j) *
3124 err_val(j) * err_val(j));
3128 return (error < 0.0) ? -sqrt(-error) : sqrt(error);
3143 int norm_type)
const
3145 double error1 = 0.0;
3146 double error2 = 0.0;
3154 return sqrt(error1 * error1 + error2 * error2);
3163 return sqrt(L2error*L2error + GradError*GradError);
3172 return sqrt(L2error*L2error + DivError*DivError);
3181 return sqrt(L2error*L2error + CurlError*CurlError);
3187 double error = 0.0,
a;
3192 int fdof, d, i, intorder, j, k;
3219 for (k = 0; k < fdof; k++)
3220 if (vdofs[fdof*d+k] >= 0)
3222 a += (*this)(vdofs[fdof*d+k]) * shape(k);
3226 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
3228 a -= exsol[d]->
Eval(*transf, ip);
3245 int i, fdof,
dim, intorder, j, k;
3249 Vector e_grad, a_grad, shape, el_dofs, err_val, ell_coeff_val;
3252 double a, error = 0.0;
3261 for (i = 0; i < mesh->
GetNE(); i++)
3263 if (elems != NULL && (*elems)[i] == 0) {
continue; }
3280 for (k = 0; k < fdof; k++)
3283 el_dofs(k) = (*this)(vdofs[k]);
3287 el_dofs(k) = -(*this)(-1-vdofs[k]);
3294 a = (el_dofs * shape) - (exsol->
Eval(*transf, ip));
3300 for (i = 0; i < mesh->
GetNE(); i++)
3302 if (elems != NULL && (*elems)[i] == 0) {
continue; }
3320 for (k = 0; k < fdof; k++)
3323 el_dofs(k) = (*this)(vdofs[k]);
3327 el_dofs(k) = -(*this)(-1-vdofs[k]);
3334 exgrad->
Eval(e_grad, *transf, ip);
3336 Mult(dshape, Jinv, dshapet);
3356 for (
int i = 0; i <
fes->
GetNE(); i++)
3358 if (elems != NULL && (*elems)[i] == 0) {
continue; }
3367 int intorder = 2*fe->
GetOrder() + 3;
3376 double diff = fabs(vals(j) - exsol.
Eval(*T, ip));
3379 diff = pow(diff, p);
3382 diff *= weight->
Eval(*T, ip);
3390 diff *= weight->
Eval(*T, ip);
3392 error = std::max(error, diff);
3402 error = -pow(-error, 1./p);
3406 error = pow(error, 1./p);
3419 "Incorrect size for result vector");
3426 for (
int i = 0; i <
fes->
GetNE(); i++)
3436 int intorder = 2*fe->
GetOrder() + 3;
3445 double diff = fabs(vals(j) - exsol.
Eval(*T, ip));
3448 diff = pow(diff, p);
3451 diff *= weight->
Eval(*T, ip);
3459 diff *= weight->
Eval(*T, ip);
3461 error[i] = std::max(error[i], diff);
3469 error[i] = -pow(-error[i], 1./p);
3473 error[i] = pow(error[i], 1./p);
3490 for (
int i = 0; i <
fes->
GetNE(); i++)
3500 int intorder = 2*fe->
GetOrder() + 3;
3505 exsol.
Eval(exact_vals, *T, *ir);
3512 vals.
Norm2(loc_errs);
3516 v_weight->
Eval(exact_vals, *T, *ir);
3519 for (
int j = 0; j < vals.
Width(); j++)
3522 for (
int d = 0; d < vals.
Height(); d++)
3524 errj += vals(d,j)*exact_vals(d,j);
3526 loc_errs(j) = fabs(errj);
3533 double errj = loc_errs(j);
3536 errj = pow(errj, p);
3539 errj *= weight->
Eval(*T, ip);
3547 errj *= weight->
Eval(*T, ip);
3549 error = std::max(error, errj);
3559 error = -pow(-error, 1./p);
3563 error = pow(error, 1./p);
3578 "Incorrect size for result vector");
3586 for (
int i = 0; i <
fes->
GetNE(); i++)
3596 int intorder = 2*fe->
GetOrder() + 3;
3601 exsol.
Eval(exact_vals, *T, *ir);
3608 vals.
Norm2(loc_errs);
3612 v_weight->
Eval(exact_vals, *T, *ir);
3615 for (
int j = 0; j < vals.
Width(); j++)
3618 for (
int d = 0; d < vals.
Height(); d++)
3620 errj += vals(d,j)*exact_vals(d,j);
3622 loc_errs(j) = fabs(errj);
3629 double errj = loc_errs(j);
3632 errj = pow(errj, p);
3635 errj *= weight->
Eval(*T, ip);
3643 errj *= weight->
Eval(*T, ip);
3645 error[i] = std::max(error[i], errj);
3653 error[i] = -pow(-error[i], 1./p);
3657 error[i] = pow(error[i], 1./p);
3684 os <<
"NURBS_patches\n";
3703 ofstream ofs(fname);
3704 ofs.precision(precision);
3708 #ifdef MFEM_USE_ADIOS2
3710 const std::string& variable_name,
3713 os.
Save(*
this, variable_name, type);
3729 os <<
"SCALARS " << field_name <<
" double 1\n"
3730 <<
"LOOKUP_TABLE default\n";
3731 for (
int i = 0; i < mesh->
GetNE(); i++)
3738 for (
int j = 0; j < val.
Size(); j++)
3740 os << val(j) <<
'\n';
3744 else if ( (vec_dim == 2 || vec_dim == 3) && mesh->
SpaceDimension() > 1)
3747 os <<
"VECTORS " << field_name <<
" double\n";
3748 for (
int i = 0; i < mesh->
GetNE(); i++)
3757 for (
int j = 0; j < vval.
Width(); j++)
3759 os << vval(0, j) <<
' ' << vval(1, j) <<
' ';
3775 for (
int vd = 0; vd < vec_dim; vd++)
3777 os <<
"SCALARS " << field_name << vd <<
" double 1\n"
3778 <<
"LOOKUP_TABLE default\n";
3779 for (
int i = 0; i < mesh->
GetNE(); i++)
3786 for (
int j = 0; j < val.
Size(); j++)
3788 os << val(j) <<
'\n';
3799 double v1[3] = { p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] };
3800 double v2[3] = { p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2] };
3801 double n[] = { v1[1] * v2[2] - v1[2] * v2[1],
3802 v1[2] * v2[0] - v1[0] * v2[2],
3803 v1[0] * v2[1] - v1[1] * v2[0]
3805 double rl = 1.0 / sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);
3806 n[0] *= rl; n[1] *= rl; n[2] *= rl;
3808 os <<
" facet normal " << n[0] <<
' ' << n[1] <<
' ' << n[2]
3810 <<
"\n vertex " << p1[0] <<
' ' << p1[1] <<
' ' << p1[2]
3811 <<
"\n vertex " << p2[0] <<
' ' << p2[1] <<
' ' << p2[2]
3812 <<
"\n vertex " << p3[0] <<
' ' << p3[1] <<
' ' << p3[2]
3813 <<
"\n endloop\n endfacet\n";
3829 double pts[4][3], bbox[3][2];
3831 os <<
"solid GridFunction\n";
3833 bbox[0][0] = bbox[0][1] = bbox[1][0] = bbox[1][1] =
3834 bbox[2][0] = bbox[2][1] = 0.0;
3835 for (i = 0; i < mesh->
GetNE(); i++)
3842 for (k = 0; k < RG.
Size()/n; k++)
3844 for (j = 0; j < n; j++)
3847 pts[j][0] = pointmat(0,l);
3848 pts[j][1] = pointmat(1,l);
3849 pts[j][2] = values(l);
3865 bbox[0][0] = pointmat(0,0);
3866 bbox[0][1] = pointmat(0,0);
3867 bbox[1][0] = pointmat(1,0);
3868 bbox[1][1] = pointmat(1,0);
3869 bbox[2][0] = values(0);
3870 bbox[2][1] = values(0);
3873 for (j = 0; j < values.
Size(); j++)
3875 if (bbox[0][0] > pointmat(0,j))
3877 bbox[0][0] = pointmat(0,j);
3879 if (bbox[0][1] < pointmat(0,j))
3881 bbox[0][1] = pointmat(0,j);
3883 if (bbox[1][0] > pointmat(1,j))
3885 bbox[1][0] = pointmat(1,j);
3887 if (bbox[1][1] < pointmat(1,j))
3889 bbox[1][1] = pointmat(1,j);
3891 if (bbox[2][0] > values(j))
3893 bbox[2][0] = values(j);
3895 if (bbox[2][1] < values(j))
3897 bbox[2][1] = values(j);
3902 mfem::out <<
"[xmin,xmax] = [" << bbox[0][0] <<
',' << bbox[0][1] <<
"]\n"
3903 <<
"[ymin,ymax] = [" << bbox[1][0] <<
',' << bbox[1][1] <<
"]\n"
3904 <<
"[zmin,zmax] = [" << bbox[2][0] <<
',' << bbox[2][1] <<
']'
3907 os <<
"endsolid GridFunction" << endl;
3924 MFEM_ASSERT(new_vertex.Size() == mesh->
GetNV(),
"");
3927 old_vertex.SetSize(new_vertex.Size());
3928 for (
int i = 0; i < new_vertex.Size(); i++)
3930 old_vertex[new_vertex[i]] = i;
3937 for (
int i = 0; i < mesh->
GetNV(); i++)
3942 for (
int j = 0; j < new_vdofs.
Size(); j++)
3944 tmp(new_vdofs[j]) = (*this)(old_vdofs[j]);
3950 for (
int i = 0; i < mesh->
GetNEdges(); i++)
3953 if (old_vertex[ev[0]] > old_vertex[ev[1]])
3958 for (
int k = 0; k < dofs.
Size(); k++)
3960 int new_dof = dofs[k];
3961 int old_dof = dofs[(ind[k] < 0) ? -1-ind[k] : ind[k]];
3968 double sign = (ind[k] < 0) ? -1.0 : 1.0;
3969 tmp(new_vdof) = sign * (*this)(old_vdof);
3982 int with_subdomains,
3990 int nfe = ufes->
GetNE();
3994 Vector ul, fl, fla, d_xyz;
4004 if (with_subdomains)
4009 double total_error = 0.0;
4010 for (
int s = 1;
s <= nsd;
s++)
4013 u.
ComputeFlux(blfi, flux, with_coeff, (with_subdomains ?
s : -1));
4015 for (
int i = 0; i < nfe; i++)
4017 if (with_subdomains && ufes->
GetAttribute(i) !=
s) {
continue; }
4027 *ffes->
GetFE(i), fl, with_coeff);
4032 (aniso_flags ? &d_xyz : NULL));
4034 error_estimates(i) = std::sqrt(eng);
4040 for (
int k = 0; k <
dim; k++)
4045 double thresh = 0.15 * 3.0/
dim;
4047 for (
int k = 0; k <
dim; k++)
4049 if (d_xyz[k] / sum > thresh) { flag |= (1 << k); }
4052 (*aniso_flags)[i] = flag;
4060 auto process_local_error = total_error;
4061 MPI_Allreduce(&process_local_error, &total_error, 1, MPI_DOUBLE,
4062 MPI_SUM, pfes->GetComm());
4064 #endif // MFEM_USE_MPI
4065 return std::sqrt(total_error);
4077 MFEM_VERIFY(dim >= 1,
"dim must be positive");
4078 MFEM_VERIFY(dim <= 3,
"dim cannot be greater than 3");
4079 MFEM_VERIFY(order >= 0,
"order cannot be negative");
4081 bool rotate = (angle != 0.0) || (midpoint->
Norml2() != 0.0);
4084 if (rotate && dim == 2)
4090 x[0] = tmp[0]*cos(-angle) - tmp[1]*sin(-angle);
4091 x[1] = tmp[0]*sin(-angle) + tmp[1]*cos(-angle);
4100 double x1 = (x(0) - xmin(0))/(xmax(0)-xmin(0)), x2, x3;
4101 Vector poly_x(order+1), poly_y(order+1), poly_z(order+1);
4105 x2 = (x(1)-xmin(1))/(xmax(1)-xmin(1));
4110 x3 = (x(2)-xmin(2))/(xmax(2)-xmin(2));
4114 int basis_dimension =
static_cast<int>(pow(order+1,dim));
4115 poly.
SetSize(basis_dimension);
4120 for (
int i = 0; i <= order; i++)
4122 poly(i) = poly_x(i);
4128 for (
int j = 0; j <= order; j++)
4130 for (
int i = 0; i <= order; i++)
4132 int cnt = i + (order+1) * j;
4133 poly(cnt) = poly_x(i) * poly_y(j);
4140 for (
int k = 0; k <= order; k++)
4142 for (
int j = 0; j <= order; j++)
4144 for (
int i = 0; i <= order; i++)
4146 int cnt = i + (order+1) * j + (order+1) * (order+1) * k;
4147 poly(cnt) = poly_x(i) * poly_y(j) * poly_z(k);
4155 MFEM_ABORT(
"TensorProductLegendre: invalid value of dim");
4171 int num_elems = patch.
Size();
4178 bool rotate = (dim == 2);
4181 if (rotate && iface >= 0)
4187 physical_diff = 0.0;
4190 for (
int i = 0; i < 2; i++)
4192 reference_pt.
Set1w((
double)i, 0.0);
4193 Tr.
Transform(reference_pt, physical_pt);
4194 midpoint += physical_pt;
4195 physical_pt *= pow(-1.0,i);
4196 physical_diff += physical_pt;
4199 angle = atan2(physical_diff(1),physical_diff(0));
4202 for (
int i = 0; i < num_elems; i++)
4204 int ielem = patch[i];
4215 transip -= midpoint;
4218 transip[0] = tmp[0]*cos(-angle) - tmp[1]*sin(-angle);
4219 transip[1] = tmp[0]*sin(-angle) + tmp[1]*cos(-angle);
4221 for (
int d = 0; d <
dim; d++) { xmax(d) = max(xmax(d), transip(d)); }
4222 for (
int d = 0; d <
dim; d++) { xmin(d) = min(xmin(d), transip(d)); }
4230 bool subdomain_reconstruction,
4232 double tichonov_coeff)
4234 MFEM_VERIFY(tichonov_coeff >= 0.0,
"tichonov_coeff cannot be negative");
4241 int nfe = ufes->
GetNE();
4242 int nfaces = ufes->
GetNF();
4249 error_estimates = 0.0;
4260 if (subdomain_reconstruction)
4265 double total_error = 0.0;
4266 for (
int iface = 0; iface < nfaces; iface++)
4273 patch[0] = el1; patch[1] = el2;
4276 if (el1 == -1 || el2 == -1)
4287 if (el1_attr != el2_attr) {
continue; }
4296 int num_basis_functions =
static_cast<int>(pow(patch_order+1,dim));
4297 int flux_order = 2*patch_order + 1;
4306 xmin, xmax, angle, midpoint, iface);
4311 for (
int i = 0; i < patch.
Size(); i++)
4313 int ielem = patch[i];
4323 *dummy, fl, with_coeff, ir);
4327 for (
int k = 0; k < num_integration_pts; k++)
4339 for (
int l = 0; l < num_basis_functions; l++)
4342 for (
int n = 0; n < sdim; n++)
4344 b[l + n * num_basis_functions] +=
p(l) * fl(k + n * num_integration_pts);
4356 for (
int i = 0; i < num_basis_functions; i++)
4358 A(i,i) += tichonov_coeff;
4365 if (!lu.Factor(num_basis_functions,TOL))
4368 mfem::out <<
"LSZZErrorEstimator: Matrix A is singular.\t"
4369 <<
"Consider increasing tichonov_coeff." << endl;
4370 for (
int i = 0; i < num_basis_functions; i++)
4374 lu.Factor(num_basis_functions,TOL);
4376 lu.Solve(num_basis_functions, sdim, b);
4384 for (
int i = 0; i < num_basis_functions; i++)
4386 for (
int j = 0; j < sdim; j++)
4388 f(j) += b[i + j * num_basis_functions] *
p(i);
4395 double element_error = 0.0;
4396 double patch_error = 0.0;
4397 for (
int i = 0; i < patch.
Size(); i++)
4399 int ielem = patch[i];
4401 element_error *= element_error;
4402 patch_error += element_error;
4403 error_estimates(ielem) += element_error;
4407 total_error += patch_error;
4415 for (
int ielem = 0; ielem < nfe; ielem++)
4417 if (counters[ielem] == 0)
4419 error_estimates(ielem) =
infinity();
4423 error_estimates(ielem) /= counters[ielem]/2.0;
4424 error_estimates(ielem) = sqrt(error_estimates(ielem));
4427 return std::sqrt(total_error/dim);
4449 for (
int j = 0; j < nip; j++)
4458 double errj = val1.
Norml2();
4461 errj = pow(errj, p);
4466 norm = std::max(norm, errj);
4475 norm = -pow(-norm, 1./p);
4479 norm = pow(norm, 1./p);
4493 return sol_in.
Eval(*T_in, ip);
4504 string cname = name;
4505 if (cname ==
"Linear")
4509 else if (cname ==
"Quadratic")
4513 else if (cname ==
"Cubic")
4517 else if (!strncmp(name,
"H1_", 3))
4521 else if (!strncmp(name,
"H1Pos_", 6))
4526 else if (!strncmp(name,
"L2_T", 4))
4530 else if (!strncmp(name,
"L2_", 3))
4536 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.
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 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.
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 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.
void ProjectDiscCoefficient(VectorCoefficient &coeff, Array< int > &dof_attr)
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
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.
int GetElementOrder(int i) const
Returns the order of the i'th finite element.
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.
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...
static void CalcLegendre(const int p, const double x, double *u)
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 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.
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)
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
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.
void GetFaceTransformation(int i, IsoparametricTransformation *FTr)
Returns the transformation defining the given face element in a user-defined variable.
virtual double ComputeH1Error(Coefficient *exsol, VectorCoefficient *exgrad, Coefficient *ell_coef, double Nu, int norm_type) const
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.
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.
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...
void AddMultVVt(const Vector &v, DenseMatrix &VVt)
VVt += v v^t.
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)
int GetNF() const
Returns number of faces (i.e. co-dimension 1 entities) in the mesh.
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 DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'.
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
int GetVDim() const
Returns the vector dimension for vector-valued finite elements.
A general vector function coefficient.
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
double * Data() const
Returns the matrix data array.
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
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)
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 ...
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...
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
virtual double ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const
Geometry::Type GetElementGeometry(int i) 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.
virtual double ComputeLpError(const double p, Coefficient &exsol, Coefficient *weight=NULL, const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) 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 GetEdgeInteriorDofs(int i, Array< int > &dofs) const
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
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.
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.
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 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 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.
virtual double ComputeW11Error(Coefficient *exsol, VectorCoefficient *exgrad, int norm_type, const Array< int > *elems=NULL, const IntegrationRule *irs[]=NULL) const
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
Field is continuous across element interfaces.
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 Set1w(const double x1, const double w)
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 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