15 #include "../mesh/nurbs.hpp"
16 #include "../general/text.hpp"
39 if (buff !=
"FiniteElementSpace")
42 " input stream is not a GridFunction!");
44 getline(input, buff,
' ');
49 getline(input, buff,
' ');
51 getline(input, buff,
' ');
82 int g_nddofs = g_ndofs - (g_nvdofs + g_nedofs + g_nfdofs);
84 vi = ei = fi = di = 0;
85 for (
int i = 0; i < num_pieces; i++)
92 int l_nddofs = l_ndofs - (l_nvdofs + l_nedofs + l_nfdofs);
93 const double *l_data = gf_array[i]->
GetData();
94 double *g_data =
data;
97 for (
int d = 0; d < vdim; d++)
99 memcpy(g_data+vi, l_data, l_nvdofs*
sizeof(
double));
102 memcpy(g_data+ei, l_data, l_nedofs*
sizeof(
double));
105 memcpy(g_data+fi, l_data, l_nfdofs*
sizeof(
double));
108 memcpy(g_data+di, l_data, l_nddofs*
sizeof(
double));
115 memcpy(g_data+vdim*vi, l_data, vdim*l_nvdofs*
sizeof(
double));
116 l_data += vdim*l_nvdofs;
117 g_data += vdim*g_nvdofs;
118 memcpy(g_data+vdim*ei, l_data, vdim*l_nedofs*
sizeof(
double));
119 l_data += vdim*l_nedofs;
120 g_data += vdim*g_nedofs;
121 memcpy(g_data+vdim*fi, l_data, vdim*l_nfdofs*
sizeof(
double));
122 l_data += vdim*l_nfdofs;
123 g_data += vdim*g_nfdofs;
124 memcpy(g_data+vdim*di, l_data, vdim*l_nddofs*
sizeof(
double));
125 l_data += vdim*l_nddofs;
126 g_data += vdim*g_nddofs;
156 MFEM_ABORT(
"Error in update sequence. GridFunction needs to be updated "
157 "right after the space is updated.");
212 int nfe = ufes->
GetNE();
220 for (
int i = 0; i < nfe; i++)
222 if (subdomain >= 0 && ufes->
GetAttribute(i) != subdomain)
234 *ffes->
GetFE(i), fl, wcoef);
239 for (
int j = 0; j < fdofs.
Size(); j++)
255 for (
int i = 0; i < count.Size(); i++)
257 if (count[i] != 0) { flux(i) /= count[i]; }
267 static const int geoms[3] =
324 int dof = FElem->
GetDof();
334 "invalid FE map type");
336 for (k = 0; k < n; k++)
339 nval[k] = shape * ((
const double *)loc_data + dof * vdim);
346 for (k = 0; k < n; k++)
350 nval[k] = loc_data * (&vshape(0,vdim));
367 return (DofVal * LocVec);
374 int dof = FElem->
GetDof();
382 "invalid FE map type");
387 for (
int k = 0; k < vdim; k++)
389 val(k) = shape * ((
const double *)loc_data + dof * k);
415 "invalid FE map type");
416 int dof = FElem->
GetDof();
417 Vector DofVal(dof), loc_data(dof);
419 for (
int k = 0; k < n; k++)
422 vals(k) = DofVal * loc_data;
492 int dof = FElem->
GetDof();
501 "invalid FE map type");
505 for (
int j = 0; j < nip; j++)
509 for (
int k = 0; k < vdim; k++)
511 vals(k,j) = shape * ((
const double *)loc_data + dof * k);
521 for (
int j = 0; j < nip; j++)
590 Vector shape, loc_values, orig_loc_values;
591 int i, j, d, ne, dof, odof, vdim;
595 for (i = 0; i < ne; i++)
604 loc_values.
SetSize(dof * vdim);
607 for (j = 0; j < dof; j++)
611 for (d = 0; d < vdim; d++)
613 loc_values(d*dof+j) =
614 shape * ((
const double *)orig_loc_values + d * odof) ;
627 Vector shape, loc_values, orig_loc_values;
628 int i, j, d, nbe, dof, odof, vdim;
632 for (i = 0; i < nbe; i++)
641 loc_values.
SetSize(dof * vdim);
644 for (j = 0; j < dof; j++)
648 for (d = 0; d < vdim; d++)
650 loc_values(d*dof+j) =
651 shape * ((
const double *)orig_loc_values + d * odof);
665 int d, j, k, n, sdim, dof, ind;
672 int *dofs = &vdofs[comp*dof];
678 for (k = 0; k < n; k++)
683 for (d = 0; d < sdim; d++)
686 for (j = 0; j < dof; j++)
687 if ( (ind=dofs[j]) >= 0 )
689 a += vshape(j, d) *
data[ind];
693 a -= vshape(j, d) *
data[-1-ind];
710 double *temp =
new double[
size];
713 for (j = 0; j < ndofs; j++)
714 for (i = 0; i < vdim; i++)
716 temp[j+i*ndofs] =
data[k++];
719 for (i = 0; i <
size; i++)
747 val(vertices[k]) += vals(k, comp);
748 overlap[vertices[k]]++;
752 for (i = 0; i < overlap.Size(); i++)
754 val(i) /= overlap[i];
762 int d, i, k, ind, dof, sdim;
771 for (i = 0; i < new_fes->
GetNE(); i++)
778 for (d = 0; d < sdim; d++)
780 for (k = 0; k < dof; k++)
782 if ( (ind=new_vdofs[dof*d+k]) < 0 )
784 ind = -1-ind, vals(k, d) = - vals(k, d);
786 vec_field(ind) += vals(k, d);
792 for (i = 0; i < overlap.Size(); i++)
794 vec_field(i) /= overlap[i];
806 int i, j, k,
dim, dof, der_dof, ind;
809 for (i = 0; i < overlap.Size(); i++)
816 for (i = 0; i < der_fes->
GetNE(); i++)
825 der_dof = der_fe->
GetDof();
831 for (j = 0; j < dof; j++)
832 loc_func(j) = ( (ind=vdofs[comp*dof+j]) >= 0 ) ?
834 for (k = 0; k < der_dof; k++)
842 for (j = 0; j <
dim; j++)
844 a += inv_jac(j, der_comp) * pt_grad(j);
846 der(der_dofs[k]) += a;
847 overlap[der_dofs[k]]++;
851 for (i = 0; i < overlap.Size(); i++)
853 der(i) /= overlap[i];
874 MultAtB(loc_data_mat, dshape, gh);
885 "invalid FE map type");
892 for (
int i = 0; i < Jinv.Width(); i++)
894 for (
int j = 0; j < Jinv.Height(); j++)
896 div_v += grad_hat(i, j) * Jinv(j, i);
908 div_v = (loc_data * divshape) / tr.
Weight();
920 "invalid FE map type");
927 Mult(grad_hat, Jinv, grad);
928 MFEM_ASSERT(grad.Height() == grad.Width(),
"");
929 if (grad.Height() == 3)
932 curl(0) = grad(2,1) - grad(1,2);
933 curl(1) = grad(0,2) - grad(2,0);
934 curl(2) = grad(1,0) - grad(0,1);
936 else if (grad.Height() == 2)
939 curl(0) = grad(1,0) - grad(0,1);
951 curl.
SetSize(curl_shape.Width());
952 if (curl_shape.Width() == 3)
955 curl_shape.MultTranspose(loc_data, curl_hat);
960 curl_shape.MultTranspose(loc_data, curl);
980 dshape.MultTranspose(lval, gh);
1002 dshape.MultTranspose(lval, gh);
1003 Tr->SetIntPoint(&ip);
1006 Jinv.MultTranspose(gh, gcol);
1014 "invalid FE map type");
1020 grad.
SetSize(grad_hat.Height(), Jinv.Width());
1021 Mult(grad_hat, Jinv, grad);
1029 Vector loc_avgs, loc_this;
1034 for (
int i = 0; i <
fes->
GetNE(); i++)
1039 avgs.FESpace()->GetElementDofs(i, te_dofs);
1042 loc_mass.
Mult(loc_this, loc_avgs);
1043 avgs.AddElementVector(te_dofs, loc_avgs);
1045 loc_mass.
Mult(loc_this, loc_avgs);
1046 int_psi.AddElementVector(te_dofs, loc_avgs);
1048 for (
int i = 0; i < avgs.Size(); i++)
1050 avgs(i) /= int_psi(i);
1069 mfem_error(
"GridFunction::ProjectGridFunction() :"
1070 " incompatible vector dimensions!");
1074 for (
int i = 0; i < mesh->
GetNE(); i++)
1078 for (
int vd = 0; vd < vdim; vd++)
1093 Vector vals, new_vals(size);
1096 MFEM_ASSERT(weights.
Size() ==
size,
"Different # of weights and dofs.");
1097 MFEM_ASSERT(_lo.
Size() ==
size,
"Different # of lower bounds and dofs.");
1098 MFEM_ASSERT(_hi.
Size() ==
size,
"Different # of upper bounds and dofs.");
1101 double tol = 1.e-12;
1109 slbqp.
Mult(vals, new_vals);
1115 double _min,
double _max)
1120 Vector vals, new_vals(size);
1123 double max_val = vals.
Max();
1124 double min_val = vals.
Min();
1126 if (max_val <= _min)
1133 if (_min <= min_val && max_val <= _max)
1138 Vector minv(size), maxv(size);
1139 minv = (_min > min_val) ? _min : min_val;
1140 maxv = (_max < max_val) ? _max : max_val;
1159 for (j = 0; j < vertices.
Size(); j++)
1161 nval(vertices[j]) += values[j];
1162 overlap[vertices[j]]++;
1165 for (i = 0; i < overlap.Size(); i++)
1167 nval(i) /= overlap[i];
1182 for (
int i = 0; i <
fes->
GetNE(); i++)
1190 for (
int j = 0; j < vdofs.
Size(); j++)
1194 MFEM_VERIFY(vals[j] != 0.0,
1195 "Coefficient has zeros, harmonic avg is undefined!");
1196 (*this)(vdofs[j]) += 1.0 / vals[j];
1200 (*this)(vdofs[j]) += vals[j];
1202 else { MFEM_ABORT(
"Not implemented"); }
1204 zones_per_vdof[vdofs[j]]++;
1214 for (
int i = 0; i <
size; i++)
1216 (*this)(i) /= zones_per_vdof[i];
1221 for (
int i = 0; i <
size; i++)
1223 (*this)(i) = zones_per_vdof[i]/(*
this)(i);
1228 MFEM_ABORT(
"invalud AvgType");
1243 const double *center = delta_coeff.
Center();
1244 const double *vert = mesh->
GetVertex(0);
1245 double min_dist, dist;
1249 min_dist =
Distance(center, vert, dim);
1250 for (
int i = 0; i < mesh->
GetNV(); i++)
1253 dist =
Distance(center, vert, dim);
1254 if (dist < min_dist)
1264 if (min_dist >= delta_coeff.
Tol())
1273 Vector vals, loc_mass_vals;
1274 for (
int i = 0; i < mesh->
GetNE(); i++)
1277 for (
int j = 0; j < vertices.
Size(); j++)
1278 if (vertices[j] == v_idx)
1288 loc_mass.Mult(vals, loc_mass_vals);
1289 integral += loc_mass_vals.
Sum();
1299 if (delta_c == NULL)
1304 for (
int i = 0; i <
fes->
GetNE(); i++)
1318 (*this) *= (delta_c->
Scale() / integral);
1329 for (
int i = 0; i < dofs.
Size(); i++)
1342 (*this)(vdof) = coeff.
Eval(*T, ip);
1370 for (
int i = 0; i < dofs.
Size(); i++)
1382 vcoeff.
Eval(val, *T, ip);
1386 (*this)(vdof) = val(vd);
1393 int i, j, fdof, d, ind, vdim;
1407 for (j = 0; j < fdof; j++)
1411 for (d = 0; d < vdim; d++)
1413 val = coeff[d]->
Eval(*transf, ip);
1414 if ( (ind = vdofs[fdof*d+j]) < 0 )
1416 val = -val, ind = -1-ind;
1435 for (
int i = 0; i <
fes->
GetNE(); i++)
1444 for (
int j = 0; j < vdofs.
Size(); j++)
1446 if (attr > dof_attr[vdofs[j]])
1448 (*this)(vdofs[j]) = vals[j];
1449 dof_attr[vdofs[j]] = attr;
1475 int i, j, fdof, d, ind, vdim;
1492 for (j = 0; j < fdof; j++)
1496 for (d = 0; d < vdim; d++)
1498 val = coeff[d]->
Eval(*transf, ip);
1499 if ( (ind = vdofs[fdof*d+j]) < 0 )
1501 val = -val, ind = -1-ind;
1527 for (i = 0; i < bdr_edges.
Size(); i++)
1529 int edge = bdr_edges[i];
1531 if (vdofs.
Size() == 0) {
continue; }
1537 for (d = 0; d < vdim; d++)
1539 fe->
Project(*coeff[d], *transf, vals);
1540 for (
int k = 0; k < vals.
Size(); k++)
1542 (*this)(vdofs[d*vals.
Size()+k]) = vals(k);
1559 Vector vc(dim), nor(dim), lvec, shape;
1579 vcoeff.
Eval(vc, *T, ip);
1582 lvec.
Add(ip.
weight * (vc * nor), shape);
1594 Vector vc(dim), nor(dim), lvec;
1610 vcoeff.
Eval(vc, *T, ip);
1612 lvec(j) = (vc * nor);
1638 fe->
Project(vcoeff, *T, lvec);
1649 for (
int i = 0; i < bdr_edges.
Size(); i++)
1651 int edge = bdr_edges[i];
1653 if (dofs.
Size() == 0) {
continue; }
1659 fe->
Project(vcoeff, *T, lvec);
1668 double error = 0.0, a;
1673 int fdof, d, i, intorder, j, k;
1699 for (k = 0; k < fdof; k++)
1700 if (vdofs[fdof*d+k] >= 0)
1702 a += (*this)(vdofs[fdof*d+k]) * shape(k);
1706 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
1709 a -= exsol[d]->
Eval(*transf, ip);
1717 return -sqrt(-error);
1732 for (
int i = 0; i <
fes->
GetNE(); i++)
1734 if (elems != NULL && (*elems)[i] == 0) {
continue; }
1736 int intorder = 2*fe->
GetOrder() + 1;
1748 exsol.
Eval(exact_vals, *T, *ir);
1751 vals.
Norm2(loc_errs);
1756 error += ip.
weight * T->
Weight() * (loc_errs(j) * loc_errs(j));
1762 return -sqrt(-error);
1769 Coefficient *ell_coeff,
double Nu,
int norm_type)
const
1772 int i, fdof,
dim, intorder, j, k;
1777 Vector e_grad, a_grad, shape, el_dofs, err_val, ell_coeff_val;
1790 for (i = 0; i < mesh->
GetNE(); i++)
1801 for (k = 0; k < fdof; k++)
1804 el_dofs(k) = (*this)(vdofs[k]);
1808 el_dofs(k) = - (*this)(-1-vdofs[k]);
1815 exgrad->
Eval(e_grad, *transf, ip);
1817 Mult(dshape, Jinv, dshapet);
1821 ell_coeff->
Eval(*transf, ip) *
1830 int i1 = face_elem_transf->
Elem1No;
1831 int i2 = face_elem_transf->
Elem2No;
1838 intorder = 2 * intorder;
1844 transf = face_elem_transf->
Elem1;
1850 for (k = 0; k < fdof; k++)
1853 el_dofs(k) = (*this)(vdofs[k]);
1857 el_dofs(k) = - (*this)(-1-vdofs[k]);
1864 ell_coeff_val(j) = ell_coeff->
Eval(*transf, eip);
1865 err_val(j) = exsol->
Eval(*transf, eip) - (shape * el_dofs);
1871 transf = face_elem_transf->
Elem2;
1877 for (k = 0; k < fdof; k++)
1880 el_dofs(k) = (*this)(vdofs[k]);
1884 el_dofs(k) = - (*this)(-1-vdofs[k]);
1891 ell_coeff_val(j) += ell_coeff->
Eval(*transf, eip);
1892 ell_coeff_val(j) *= 0.5;
1893 err_val(j) -= (exsol->
Eval(*transf, eip) - (shape * el_dofs));
1897 transf = face_elem_transf->
Face;
1902 error += (ip.
weight * Nu * ell_coeff_val(j) *
1903 pow(transf->
Weight(), 1.0-1.0/(dim-1)) *
1904 err_val(j) * err_val(j));
1910 return -sqrt(-error);
1918 double error = 0.0, a;
1923 int fdof, d, i, intorder, j, k;
1950 for (k = 0; k < fdof; k++)
1951 if (vdofs[fdof*d+k] >= 0)
1953 a += (*this)(vdofs[fdof*d+k]) * shape(k);
1957 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
1959 a -= exsol[d]->
Eval(*transf, ip);
1977 int i, fdof,
dim, intorder, j, k;
1981 Vector e_grad, a_grad, shape, el_dofs, err_val, ell_coeff_val;
1984 double a, error = 0.0;
1993 for (i = 0; i < mesh->
GetNE(); i++)
1995 if (elems != NULL && (*elems)[i] == 0) {
continue; }
2012 for (k = 0; k < fdof; k++)
2015 el_dofs(k) = (*this)(vdofs[k]);
2019 el_dofs(k) = -(*this)(-1-vdofs[k]);
2026 a = (el_dofs * shape) - (exsol->
Eval(*transf, ip));
2032 for (i = 0; i < mesh->
GetNE(); i++)
2034 if (elems != NULL && (*elems)[i] == 0) {
continue; }
2052 for (k = 0; k < fdof; k++)
2055 el_dofs(k) = (*this)(vdofs[k]);
2059 el_dofs(k) = -(*this)(-1-vdofs[k]);
2066 exgrad->
Eval(e_grad, *transf, ip);
2068 Mult(dshape, Jinv, dshapet);
2087 for (
int i = 0; i <
fes->
GetNE(); i++)
2097 int intorder = 2*fe->
GetOrder() + 1;
2106 double err = fabs(vals(j) - exsol.
Eval(*T, ip));
2107 if (p < numeric_limits<double>::infinity())
2112 err *= weight->
Eval(*T, ip);
2120 err *= weight->
Eval(*T, ip);
2122 error = std::max(error, err);
2127 if (p < numeric_limits<double>::infinity())
2132 error = -pow(-error, 1./p);
2136 error = pow(error, 1./p);
2154 for (
int i = 0; i <
fes->
GetNE(); i++)
2164 int intorder = 2*fe->
GetOrder() + 1;
2169 exsol.
Eval(exact_vals, *T, *ir);
2176 vals.
Norm2(loc_errs);
2180 v_weight->
Eval(exact_vals, *T, *ir);
2183 for (
int j = 0; j < vals.
Width(); j++)
2186 for (
int d = 0; d < vals.
Height(); d++)
2188 err += vals(d,j)*exact_vals(d,j);
2190 loc_errs(j) = fabs(err);
2197 double err = loc_errs(j);
2198 if (p < numeric_limits<double>::infinity())
2203 err *= weight->
Eval(*T, ip);
2211 err *= weight->
Eval(*T, ip);
2213 error = std::max(error, err);
2218 if (p < numeric_limits<double>::infinity())
2223 error = -pow(-error, 1./p);
2227 error = pow(error, 1./p);
2236 for (
int i = 0; i <
size; i++)
2247 for (
int i = 0; i <
size; i++)
2286 out <<
"SCALARS " << field_name <<
" double 1\n"
2287 <<
"LOOKUP_TABLE default\n";
2288 for (
int i = 0; i < mesh->
GetNE(); i++)
2295 for (
int j = 0; j < val.
Size(); j++)
2297 out << val(j) <<
'\n';
2304 out <<
"VECTORS " << field_name <<
" double\n";
2305 for (
int i = 0; i < mesh->
GetNE(); i++)
2312 for (
int j = 0; j < vval.
Width(); j++)
2314 out << vval(0, j) <<
' ' << vval(1, j) <<
' ';
2330 for (
int vd = 0; vd < vec_dim; vd++)
2332 out <<
"SCALARS " << field_name << vd <<
" double 1\n"
2333 <<
"LOOKUP_TABLE default\n";
2334 for (
int i = 0; i < mesh->
GetNE(); i++)
2341 for (
int j = 0; j < val.
Size(); j++)
2343 out << val(j) <<
'\n';
2354 double v1[3] = { p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] };
2355 double v2[3] = { p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2] };
2356 double n[] = { v1[1] * v2[2] - v1[2] * v2[1],
2357 v1[2] * v2[0] - v1[0] * v2[2],
2358 v1[0] * v2[1] - v1[1] * v2[0]
2360 double rl = 1.0 / sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);
2361 n[0] *= rl; n[1] *= rl; n[2] *= rl;
2363 out <<
" facet normal " << n[0] <<
' ' << n[1] <<
' ' << n[2]
2365 <<
"\n vertex " << p1[0] <<
' ' << p1[1] <<
' ' << p1[2]
2366 <<
"\n vertex " << p2[0] <<
' ' << p2[1] <<
' ' << p2[2]
2367 <<
"\n vertex " << p3[0] <<
' ' << p3[1] <<
' ' << p3[2]
2368 <<
"\n endloop\n endfacet\n";
2384 double pts[4][3], bbox[3][2];
2386 out <<
"solid GridFunction\n";
2388 bbox[0][0] = bbox[0][1] = bbox[1][0] = bbox[1][1] =
2389 bbox[2][0] = bbox[2][1] = 0.0;
2390 for (i = 0; i < mesh->
GetNE(); i++)
2397 for (k = 0; k < RG.
Size()/n; k++)
2399 for (j = 0; j < n; j++)
2402 pts[j][0] = pointmat(0,l);
2403 pts[j][1] = pointmat(1,l);
2404 pts[j][2] = values(l);
2420 bbox[0][0] = pointmat(0,0);
2421 bbox[0][1] = pointmat(0,0);
2422 bbox[1][0] = pointmat(1,0);
2423 bbox[1][1] = pointmat(1,0);
2424 bbox[2][0] = values(0);
2425 bbox[2][1] = values(0);
2428 for (j = 0; j < values.
Size(); j++)
2430 if (bbox[0][0] > pointmat(0,j))
2432 bbox[0][0] = pointmat(0,j);
2434 if (bbox[0][1] < pointmat(0,j))
2436 bbox[0][1] = pointmat(0,j);
2438 if (bbox[1][0] > pointmat(1,j))
2440 bbox[1][0] = pointmat(1,j);
2442 if (bbox[1][1] < pointmat(1,j))
2444 bbox[1][1] = pointmat(1,j);
2446 if (bbox[2][0] > values(j))
2448 bbox[2][0] = values(j);
2450 if (bbox[2][1] < values(j))
2452 bbox[2][1] = values(j);
2457 mfem::out <<
"[xmin,xmax] = [" << bbox[0][0] <<
',' << bbox[0][1] <<
"]\n"
2458 <<
"[ymin,ymax] = [" << bbox[1][0] <<
',' << bbox[1][1] <<
"]\n"
2459 <<
"[zmin,zmax] = [" << bbox[2][0] <<
',' << bbox[2][1] <<
']'
2462 out <<
"endsolid GridFunction" << endl;
2474 const char *msg =
"invalid input stream";
2480 in >> ident; MFEM_VERIFY(ident ==
"VDim:", msg);
2489 out <<
"VDim: " <<
vdim <<
'\n'
2506 int with_subdomains)
2508 const int with_coeff = 0;
2514 int nfe = ufes->
GetNE();
2518 Vector ul, fl, fla, d_xyz;
2528 if (with_subdomains)
2530 for (
int i = 0; i < nfe; i++)
2533 if (attr > nsd) { nsd = attr; }
2537 double total_error = 0.0;
2538 for (
int s = 1; s <= nsd; s++)
2541 u.
ComputeFlux(blfi, flux, with_coeff, (with_subdomains ? s : -1));
2543 for (
int i = 0; i < nfe; i++)
2545 if (with_subdomains && ufes->
GetAttribute(i) != s) {
continue; }
2555 *ffes->
GetFE(i), fl, with_coeff);
2560 (aniso_flags ? &d_xyz : NULL));
2562 error_estimates(i) = std::sqrt(err);
2568 for (
int k = 0; k <
dim; k++)
2573 double thresh = 0.15 * 3.0/
dim;
2575 for (
int k = 0; k <
dim; k++)
2577 if (d_xyz[k] / sum > thresh) { flag |= (1 << k); }
2580 (*aniso_flags)[i] = flag;
2585 return std::sqrt(total_error);
2608 for (
int j = 0; j < nip; j++)
2618 if (p < numeric_limits<double>::infinity())
2625 norm = std::max(norm, err);
2629 if (p < numeric_limits<double>::infinity())
2634 norm = -pow(-norm, 1./p);
2638 norm = pow(norm, 1./p);
2652 return sol_in.
Eval(*T_in, ip);
2663 string cname = name;
2664 if (cname ==
"Linear")
2668 else if (cname ==
"Quadratic")
2672 else if (cname ==
"Cubic")
2676 else if (!strncmp(name,
"H1_", 3))
2680 else if (!strncmp(name,
"H1Pos_", 6))
2685 else if (!strncmp(name,
"L2_T", 4))
2689 else if (!strncmp(name,
"L2_", 3))
2695 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 Finite Elements.
std::ostream & operator<<(std::ostream &out, const Mesh &mesh)
Ordering::Type GetOrdering() const
Return the ordering method.
int Size() const
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 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.
Class for an integration rule - an Array of IntegrationPoint.
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
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 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 MergeGridFunctions(GridFunction *gf_array[], int num_pieces, GridFunction &merged)
virtual double ComputeL2Error(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
void ProjectDeltaCoefficient(DeltaCoefficient &delta_coeff, double &integral)
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)=0
double ZZErrorEstimator(BilinearFormIntegrator &blfi, GridFunction &u, GridFunction &flux, Vector &error_estimates, Array< int > *aniso_flags, int with_subdomains)
void GetVectorValue(int i, const IntegrationPoint &ip, Vector &val) const
void SetSize(int s)
Resize the vector to size s.
void GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
GridFunction * Extrude1DGridFunction(Mesh *mesh, Mesh *mesh2d, GridFunction *sol, const int ny)
Extrude a scalar 1D GridFunction, after extruding the mesh with Extrude1D.
void MakeOwner(FiniteElementCollection *_fec)
Make the GridFunction the owner of 'fec' and 'fes'.
int GetSize()
Return the total number of quadrature points.
void GetVectorGradientHat(ElementTransformation &T, DenseMatrix &gh)
double Scale()
Return the scale set by SetScale() multiplied by the time-dependent function specified by SetFunction...
virtual void ComputeFlux(BilinearFormIntegrator &blfi, GridFunction &flux, int wcoef=1, int subdomain=-1)
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 Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
double Norml2() const
Returns the l2 norm of the vector.
void GetBdrValuesFrom(GridFunction &)
void GetGradient(ElementTransformation &tr, Vector &grad)
RefinedGeometry * Refine(int Geom, int Times, int ETimes=1)
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
int GetOrder() const
Returns the order of the finite element.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
Piecewise-(bi)linear continuous finite elements.
Data type dense matrix using column-major storage.
Delta function coefficient.
void ImposeBounds(int i, const Vector &weights, const Vector &_lo, const Vector &_hi)
int Size() const
Returns the size of the vector.
int GetBdrAttribute(int i) const
int GetNE() const
Returns number of elements.
double Tol()
See SetTol() for description of the tolerance parameter.
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
int vdim
Vector dimension.
int GetNV() const
Returns number of nodes in the mesh.
void ComputeMeans(AvgType type, Array< int > &zones_per_vdof)
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.
FaceElementTransformations * GetFaceElementTransformations(int FaceNo, int mask=31)
const IntegrationRule * GetVertices(int GeomType)
Return an IntegrationRule consisting of all vertices of the given Geometry::Type, GeomType...
void GetEdgeTransformation(int i, IsoparametricTransformation *EdTr)
void GetVectorFieldNodalValues(Vector &val, int comp) const
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
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)
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
void GetDerivative(int comp, int der_comp, GridFunction &der)
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
void ProjectBdrCoefficientNormal(VectorCoefficient &vcoeff, Array< int > &bdr_attr)
void SumFluxAndCount(BilinearFormIntegrator &blfi, GridFunction &flux, Array< int > &counts, int wcoef, int subdomain)
void SetLinearConstraint(const Vector &_w, double _a)
double GetDivergence(ElementTransformation &tr)
const FiniteElement * GetEdgeElement(int i) const
void SetPrintLevel(int print_lvl)
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().
Mesh * GetMesh() const
Returns the mesh.
void GetVectorFieldValues(int i, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr, int comp=0) 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 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.
For scalar fields; preserves point values.
virtual void GetElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
int GetElementForDof(int i) const
QuadratureFunction()
Create an empty QuadratureFunction.
const IntegrationRule & GetNodes() const
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 GetTrueDofs(Vector &tv) const
Extract the true-dofs from the GridFunction. If all dofs are true, then tv will be set to point to th...
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
void GetCurl(ElementTransformation &tr, Vector &curl)
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 on higher-order hexahedral, quadrilateral or triangular meshes...
FiniteElementSpace * FESpace()
virtual const SparseMatrix * GetRestrictionMatrix()
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 (element) subvector to the vector.
virtual double ComputeLpError(const double p, Coefficient &exsol, Coefficient *weight=NULL, const IntegrationRule *irs[]=NULL) const
void GetEdgeDofs(int i, Array< int > &dofs) const
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
int GetGeomType() const
Returns the Geometry::Type of the reference element.
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.
bool FaceIsInterior(int FaceNo) const
Return true if the given face is interior.
void SetAbsTol(double atol)
void SetRelTol(double rtol)
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.
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
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
Base class Coefficient that may optionally depend on time.
FiniteElementSpace * fes
FE space on which grid function lives.
void ProjectGridFunction(const GridFunction &src)
void mfem_error(const char *msg)
QuadratureSpace * qspace
Associated QuadratureSpace.
void SetSize(int nsize)
Change 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.
FiniteElementCollection * fec
Used when the grid function is read from a file.
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
double ComputeElementLpDistance(double p, int i, GridFunction &gf1, GridFunction &gf2)
Compute the Lp distance between two grid functions on the given element.
int GetElementBaseGeometry(int i=0) const
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...
void SetBounds(const Vector &_lo, const Vector &_hi)
bool Nonconforming() const
virtual void GetBdrElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom for i'th boundary element.
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...
virtual void CalcCurlShape(const IntegrationPoint &ip, DenseMatrix &curl_shape) const
Evaluate the curl of all shape functions of a vector finite element in reference space at the given p...
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)
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
double Max() const
Returns the maximal element of the vector.
virtual void AssembleElementMatrix2(const FiniteElement &trial_fe, const FiniteElement &test_fe, ElementTransformation &Trans, DenseMatrix &elmat)
int GetFaceValues(int i, int side, const IntegrationRule &ir, Vector &vals, DenseMatrix &tr, int vdim=1) const
void GetElementAverages(GridFunction &avgs)
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement associated with i'th element.
const Operator * GetUpdateOperator()
Get the GridFunction update matrix.
void ProjectBdrCoefficientTangent(VectorCoefficient &vcoeff, Array< int > &bdr_attr)
void GetVectorValues(ElementTransformation &T, const IntegrationRule &ir, DenseMatrix &vals) const
virtual void Mult(const Vector &xt, Vector &x) const
Operator application: y=A(x).
virtual void ProjectCoefficient(Coefficient &coeff)
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.
NCMesh * ncmesh
Optional non-conforming mesh extension.
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
void GetEdgeVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th edge.
void filter_dos(std::string &line)
GridFunction & operator=(double value)
Redefine '=' for GridFunction = constant.
int GetNFaces() const
Return the number of faces in a 3D mesh.
void MultAtB(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &AtB)
Multiply the transpose of a matrix A with a matrix B: At*B.
const FiniteElementCollection * FEColl() const
void Mult(const double *x, double *y) const
Matrix vector multiplication.
Arbitrary order H1-conforming (continuous) finite elements.
void GetGradients(const int elem, const IntegrationRule &ir, DenseMatrix &grad)
Class representing the storage layout of a QuadratureFunction.
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement for the i'th boundary element.
void GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th boundary element.
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...
long GetSequence() const
Return update counter (see Mesh::sequence)
void GetVectorGradient(ElementTransformation &tr, DenseMatrix &grad)
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...
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
void Save(std::ostream &out) const
double Sum() const
Return the sum of the vector entries.
Class representing a function through its values (scalar or vector) at quadrature points...
void GetValuesFrom(GridFunction &)
void GetElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of element i.
static void AdjustVDofs(Array< int > &vdofs)
virtual void ProjectDelta(int vertex, Vector &dofs) const
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)
void ProjectBdrCoefficient(Coefficient &coeff, Array< int > &attr)
virtual double GetValue(int i, const IntegrationPoint &ip, int vdim=1) const
virtual const FiniteElement * FiniteElementForGeometry(int GeomType) const =0
Arbitrary order "L2-conforming" discontinuous finite elements.
void ProjectVectorFieldOn(GridFunction &vec_field, int comp=0)
void DofsToVDofs(Array< int > &dofs, int ndofs=-1) const