15 #include "../mesh/nurbs.hpp"
32 const int bufflen = 256;
37 input.getline(buff, bufflen);
38 if (strcmp(buff,
"FiniteElementSpace"))
41 " input stream is not a GridFunction!");
43 input.getline(buff, bufflen,
' ');
45 input.getline(buff, bufflen);
47 input.getline(buff, bufflen,
' ');
49 input.getline(buff, bufflen,
' ');
52 input.getline(buff, bufflen);
80 int g_nddofs = g_ndofs - (g_nvdofs + g_nedofs + g_nfdofs);
82 vi = ei = fi = di = 0;
83 for (
int i = 0; i < num_pieces; i++)
90 int l_nddofs = l_ndofs - (l_nvdofs + l_nedofs + l_nfdofs);
91 const double *l_data = gf_array[i]->
GetData();
92 double *g_data =
data;
95 for (
int d = 0; d < vdim; d++)
97 memcpy(g_data+vi, l_data, l_nvdofs*
sizeof(
double));
100 memcpy(g_data+ei, l_data, l_nedofs*
sizeof(
double));
103 memcpy(g_data+fi, l_data, l_nfdofs*
sizeof(
double));
106 memcpy(g_data+di, l_data, l_nddofs*
sizeof(
double));
113 memcpy(g_data+vdim*vi, l_data, vdim*l_nvdofs*
sizeof(
double));
114 l_data += vdim*l_nvdofs;
115 g_data += vdim*g_nvdofs;
116 memcpy(g_data+vdim*ei, l_data, vdim*l_nedofs*
sizeof(
double));
117 l_data += vdim*l_nedofs;
118 g_data += vdim*g_nedofs;
119 memcpy(g_data+vdim*fi, l_data, vdim*l_nfdofs*
sizeof(
double));
120 l_data += vdim*l_nfdofs;
121 g_data += vdim*g_nfdofs;
122 memcpy(g_data+vdim*di, l_data, vdim*l_nddofs*
sizeof(
double));
123 l_data += vdim*l_nddofs;
124 g_data += vdim*g_nddofs;
154 MFEM_ABORT(
"Error in update sequence. GridFunction needs to be updated "
155 "right after the space is updated.");
210 int nfe = ufes->
GetNE();
218 for (
int i = 0; i < nfe; i++)
220 if (subdomain >= 0 && ufes->
GetAttribute(i) != subdomain)
232 *ffes->
GetFE(i), fl, wcoef);
237 for (
int j = 0; j < fdofs.
Size(); j++)
253 for (
int i = 0; i < count.Size(); i++)
255 if (count[i] != 0) { flux(i) /= count[i]; }
265 static const int geoms[3] =
322 int dof = FElem->
GetDof();
332 "invalid FE map type");
334 for (k = 0; k < n; k++)
337 nval[k] = shape * ((
const double *)loc_data + dof * vdim);
344 for (k = 0; k < n; k++)
348 nval[k] = loc_data * (&vshape(0,vdim));
365 return (DofVal * LocVec);
372 int dof = FElem->
GetDof();
380 "invalid FE map type");
385 for (
int k = 0; k < vdim; k++)
387 val(k) = shape * ((
const double *)loc_data + dof * k);
413 "invalid FE map type");
414 int dof = FElem->
GetDof();
415 Vector DofVal(dof), loc_data(dof);
417 for (
int k = 0; k < n; k++)
420 vals(k) = DofVal * loc_data;
490 int dof = FElem->
GetDof();
499 "invalid FE map type");
503 for (
int j = 0; j < nip; j++)
507 for (
int k = 0; k < vdim; k++)
509 vals(k,j) = shape * ((
const double *)loc_data + dof * k);
519 for (
int j = 0; j < nip; j++)
588 Vector shape, loc_values, orig_loc_values;
589 int i, j, d, ne, dof, odof, vdim;
593 for (i = 0; i < ne; i++)
602 loc_values.
SetSize(dof * vdim);
605 for (j = 0; j < dof; j++)
609 for (d = 0; d < vdim; d++)
611 loc_values(d*dof+j) =
612 shape * ((
const double *)orig_loc_values + d * odof) ;
625 Vector shape, loc_values, orig_loc_values;
626 int i, j, d, nbe, dof, odof, vdim;
630 for (i = 0; i < nbe; i++)
639 loc_values.
SetSize(dof * vdim);
642 for (j = 0; j < dof; j++)
646 for (d = 0; d < vdim; d++)
648 loc_values(d*dof+j) =
649 shape * ((
const double *)orig_loc_values + d * odof);
663 int d, j, k, n, sdim, dof, ind;
670 int *dofs = &vdofs[comp*dof];
676 for (k = 0; k < n; k++)
681 for (d = 0; d < sdim; d++)
684 for (j = 0; j < dof; j++)
685 if ( (ind=dofs[j]) >= 0 )
687 a += vshape(j, d) *
data[ind];
691 a -= vshape(j, d) *
data[-1-ind];
708 double *temp =
new double[
size];
711 for (j = 0; j < ndofs; j++)
712 for (i = 0; i < vdim; i++)
714 temp[j+i*ndofs] =
data[k++];
717 for (i = 0; i <
size; i++)
745 val(vertices[k]) += vals(k, comp);
746 overlap[vertices[k]]++;
750 for (i = 0; i < overlap.Size(); i++)
752 val(i) /= overlap[i];
760 int d, i, k, ind, dof, sdim;
769 for (i = 0; i < new_fes->
GetNE(); i++)
776 for (d = 0; d < sdim; d++)
778 for (k = 0; k < dof; k++)
780 if ( (ind=new_vdofs[dof*d+k]) < 0 )
782 ind = -1-ind, vals(k, d) = - vals(k, d);
784 vec_field(ind) += vals(k, d);
790 for (i = 0; i < overlap.Size(); i++)
792 vec_field(i) /= overlap[i];
804 int i, j, k,
dim, dof, der_dof, ind;
807 for (i = 0; i < overlap.Size(); i++)
814 for (i = 0; i < der_fes->
GetNE(); i++)
823 der_dof = der_fe->
GetDof();
829 for (j = 0; j < dof; j++)
830 loc_func(j) = ( (ind=vdofs[comp*dof+j]) >= 0 ) ?
832 for (k = 0; k < der_dof; k++)
840 for (j = 0; j <
dim; j++)
842 a += inv_jac(j, der_comp) * pt_grad(j);
844 der(der_dofs[k]) += a;
845 overlap[der_dofs[k]]++;
849 for (i = 0; i < overlap.Size(); i++)
851 der(i) /= overlap[i];
872 MultAtB(loc_data_mat, dshape, gh);
883 "invalid FE map type");
890 for (
int i = 0; i < Jinv.Width(); i++)
892 for (
int j = 0; j < Jinv.Height(); j++)
894 div_v += grad_hat(i, j) * Jinv(j, i);
906 div_v = (loc_data * divshape) / tr.
Weight();
918 "invalid FE map type");
925 Mult(grad_hat, Jinv, grad);
926 MFEM_ASSERT(grad.Height() == grad.Width(),
"");
927 if (grad.Height() == 3)
930 curl(0) = grad(2,1) - grad(1,2);
931 curl(1) = grad(0,2) - grad(2,0);
932 curl(2) = grad(1,0) - grad(0,1);
934 else if (grad.Height() == 2)
937 curl(0) = grad(1,0) - grad(0,1);
949 curl.
SetSize(curl_shape.Width());
950 if (curl_shape.Width() == 3)
953 curl_shape.MultTranspose(loc_data, curl_hat);
958 curl_shape.MultTranspose(loc_data, curl);
978 dshape.MultTranspose(lval, gh);
1000 dshape.MultTranspose(lval, gh);
1001 Tr->SetIntPoint(&ip);
1004 Jinv.MultTranspose(gh, gcol);
1012 "invalid FE map type");
1018 grad.
SetSize(grad_hat.Height(), Jinv.Width());
1019 Mult(grad_hat, Jinv, grad);
1027 Vector loc_avgs, loc_this;
1032 for (
int i = 0; i <
fes->
GetNE(); i++)
1037 avgs.FESpace()->GetElementDofs(i, te_dofs);
1040 loc_mass.
Mult(loc_this, loc_avgs);
1041 avgs.AddElementVector(te_dofs, loc_avgs);
1043 loc_mass.
Mult(loc_this, loc_avgs);
1044 int_psi.AddElementVector(te_dofs, loc_avgs);
1046 for (
int i = 0; i < avgs.Size(); i++)
1048 avgs(i) /= int_psi(i);
1067 mfem_error(
"GridFunction::ProjectGridFunction() :"
1068 " incompatible vector dimensions!");
1072 for (
int i = 0; i < mesh->
GetNE(); i++)
1076 for (
int vd = 0; vd < vdim; vd++)
1091 Vector vals, new_vals(size);
1094 MFEM_ASSERT(weights.
Size() ==
size,
"Different # of weights and dofs.");
1095 MFEM_ASSERT(_lo.
Size() ==
size,
"Different # of lower bounds and dofs.");
1096 MFEM_ASSERT(_hi.
Size() ==
size,
"Different # of upper bounds and dofs.");
1099 double tol = 1.e-12;
1107 slbqp.
Mult(vals, new_vals);
1113 double _min,
double _max)
1118 Vector vals, new_vals(size);
1121 double max_val = vals.
Max();
1122 double min_val = vals.
Min();
1124 if (max_val <= _min)
1131 if (_min <= min_val && max_val <= _max)
1136 Vector minv(size), maxv(size);
1137 minv = (_min > min_val) ? _min : min_val;
1138 maxv = (_max < max_val) ? _max : max_val;
1157 for (j = 0; j < vertices.
Size(); j++)
1159 nval(vertices[j]) += values[j];
1160 overlap[vertices[j]]++;
1163 for (i = 0; i < overlap.Size(); i++)
1165 nval(i) /= overlap[i];
1180 const double *center = delta_coeff.
Center();
1181 const double *vert = mesh->
GetVertex(0);
1182 double min_dist, dist;
1186 min_dist =
Distance(center, vert, dim);
1187 for (
int i = 0; i < mesh->
GetNV(); i++)
1190 dist =
Distance(center, vert, dim);
1191 if (dist < min_dist)
1201 if (min_dist >= delta_coeff.
Tol())
1210 Vector vals, loc_mass_vals;
1211 for (
int i = 0; i < mesh->
GetNE(); i++)
1214 for (
int j = 0; j < vertices.
Size(); j++)
1215 if (vertices[j] == v_idx)
1225 loc_mass.Mult(vals, loc_mass_vals);
1226 integral += loc_mass_vals.
Sum();
1236 if (delta_c == NULL)
1241 for (
int i = 0; i <
fes->
GetNE(); i++)
1255 (*this) *= (delta_c->
Scale() / integral);
1266 for (
int i = 0; i < dofs.
Size(); i++)
1279 (*this)(vdof) = coeff.
Eval(*T, ip);
1307 for (
int i = 0; i < dofs.
Size(); i++)
1319 vcoeff.
Eval(val, *T, ip);
1323 (*this)(vdof) = val(vd);
1330 int i, j, fdof, d, ind, vdim;
1344 for (j = 0; j < fdof; j++)
1348 for (d = 0; d < vdim; d++)
1350 val = coeff[d]->
Eval(*transf, ip);
1351 if ( (ind = vdofs[fdof*d+j]) < 0 )
1353 val = -val, ind = -1-ind;
1372 for (
int i = 0; i <
fes->
GetNE(); i++)
1381 for (
int j = 0; j < vdofs.
Size(); j++)
1383 if (attr > dof_attr[vdofs[j]])
1385 (*this)(vdofs[j]) = vals[j];
1386 dof_attr[vdofs[j]] = attr;
1401 int i, j, fdof, d, ind, vdim;
1418 for (j = 0; j < fdof; j++)
1422 for (d = 0; d < vdim; d++)
1424 val = coeff[d]->
Eval(*transf, ip);
1425 if ( (ind = vdofs[fdof*d+j]) < 0 )
1427 val = -val, ind = -1-ind;
1453 for (i = 0; i < bdr_edges.
Size(); i++)
1455 int edge = bdr_edges[i];
1457 if (vdofs.
Size() == 0) {
continue; }
1463 for (d = 0; d < vdim; d++)
1465 fe->
Project(*coeff[d], *transf, vals);
1466 for (
int k = 0; k < vals.
Size(); k++)
1468 (*this)(vdofs[d*vals.
Size()+k]) = vals(k);
1485 Vector vc(dim), nor(dim), lvec, shape;
1505 vcoeff.
Eval(vc, *T, ip);
1508 lvec.
Add(ip.
weight * (vc * nor), shape);
1520 Vector vc(dim), nor(dim), lvec;
1536 vcoeff.
Eval(vc, *T, ip);
1538 lvec(j) = (vc * nor);
1564 fe->
Project(vcoeff, *T, lvec);
1575 for (
int i = 0; i < bdr_edges.
Size(); i++)
1577 int edge = bdr_edges[i];
1579 if (dofs.
Size() == 0) {
continue; }
1585 fe->
Project(vcoeff, *T, lvec);
1594 double error = 0.0, a;
1599 int fdof, d, i, intorder, j, k;
1625 for (k = 0; k < fdof; k++)
1626 if (vdofs[fdof*d+k] >= 0)
1628 a += (*this)(vdofs[fdof*d+k]) * shape(k);
1632 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
1635 a -= exsol[d]->
Eval(*transf, ip);
1643 return -sqrt(-error);
1658 for (
int i = 0; i <
fes->
GetNE(); i++)
1660 if (elems != NULL && (*elems)[i] == 0) {
continue; }
1662 int intorder = 2*fe->
GetOrder() + 1;
1674 exsol.
Eval(exact_vals, *T, *ir);
1677 vals.
Norm2(loc_errs);
1682 error += ip.
weight * T->
Weight() * (loc_errs(j) * loc_errs(j));
1688 return -sqrt(-error);
1695 Coefficient *ell_coeff,
double Nu,
int norm_type)
const
1698 int i, fdof,
dim, intorder, j, k;
1703 Vector e_grad, a_grad, shape, el_dofs, err_val, ell_coeff_val;
1716 for (i = 0; i < mesh->
GetNE(); i++)
1727 for (k = 0; k < fdof; k++)
1730 el_dofs(k) = (*this)(vdofs[k]);
1734 el_dofs(k) = - (*this)(-1-vdofs[k]);
1741 exgrad->
Eval(e_grad, *transf, ip);
1743 Mult(dshape, Jinv, dshapet);
1747 ell_coeff->
Eval(*transf, ip) *
1756 int i1 = face_elem_transf->
Elem1No;
1757 int i2 = face_elem_transf->
Elem2No;
1764 intorder = 2 * intorder;
1770 transf = face_elem_transf->
Elem1;
1776 for (k = 0; k < fdof; k++)
1779 el_dofs(k) = (*this)(vdofs[k]);
1783 el_dofs(k) = - (*this)(-1-vdofs[k]);
1790 ell_coeff_val(j) = ell_coeff->
Eval(*transf, eip);
1791 err_val(j) = exsol->
Eval(*transf, eip) - (shape * el_dofs);
1797 transf = face_elem_transf->
Elem2;
1803 for (k = 0; k < fdof; k++)
1806 el_dofs(k) = (*this)(vdofs[k]);
1810 el_dofs(k) = - (*this)(-1-vdofs[k]);
1817 ell_coeff_val(j) += ell_coeff->
Eval(*transf, eip);
1818 ell_coeff_val(j) *= 0.5;
1819 err_val(j) -= (exsol->
Eval(*transf, eip) - (shape * el_dofs));
1823 transf = face_elem_transf->
Face;
1828 error += (ip.
weight * Nu * ell_coeff_val(j) *
1829 pow(transf->
Weight(), 1.0-1.0/(dim-1)) *
1830 err_val(j) * err_val(j));
1836 return -sqrt(-error);
1844 double error = 0.0, a;
1849 int fdof, d, i, intorder, j, k;
1876 for (k = 0; k < fdof; k++)
1877 if (vdofs[fdof*d+k] >= 0)
1879 a += (*this)(vdofs[fdof*d+k]) * shape(k);
1883 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
1885 a -= exsol[d]->
Eval(*transf, ip);
1903 int i, fdof,
dim, intorder, j, k;
1907 Vector e_grad, a_grad, shape, el_dofs, err_val, ell_coeff_val;
1910 double a, error = 0.0;
1919 for (i = 0; i < mesh->
GetNE(); i++)
1921 if (elems != NULL && (*elems)[i] == 0) {
continue; }
1938 for (k = 0; k < fdof; k++)
1941 el_dofs(k) = (*this)(vdofs[k]);
1945 el_dofs(k) = -(*this)(-1-vdofs[k]);
1952 a = (el_dofs * shape) - (exsol->
Eval(*transf, ip));
1958 for (i = 0; i < mesh->
GetNE(); i++)
1960 if (elems != NULL && (*elems)[i] == 0) {
continue; }
1978 for (k = 0; k < fdof; k++)
1981 el_dofs(k) = (*this)(vdofs[k]);
1985 el_dofs(k) = -(*this)(-1-vdofs[k]);
1992 exgrad->
Eval(e_grad, *transf, ip);
1994 Mult(dshape, Jinv, dshapet);
2013 for (
int i = 0; i <
fes->
GetNE(); i++)
2023 int intorder = 2*fe->
GetOrder() + 1;
2032 double err = fabs(vals(j) - exsol.
Eval(*T, ip));
2033 if (p < numeric_limits<double>::infinity())
2038 err *= weight->
Eval(*T, ip);
2046 err *= weight->
Eval(*T, ip);
2048 error = std::max(error, err);
2053 if (p < numeric_limits<double>::infinity())
2058 error = -pow(-error, 1./p);
2062 error = pow(error, 1./p);
2080 for (
int i = 0; i <
fes->
GetNE(); i++)
2090 int intorder = 2*fe->
GetOrder() + 1;
2095 exsol.
Eval(exact_vals, *T, *ir);
2102 vals.
Norm2(loc_errs);
2106 v_weight->
Eval(exact_vals, *T, *ir);
2109 for (
int j = 0; j < vals.
Width(); j++)
2112 for (
int d = 0; d < vals.
Height(); d++)
2114 err += vals(d,j)*exact_vals(d,j);
2116 loc_errs(j) = fabs(err);
2123 double err = loc_errs(j);
2124 if (p < numeric_limits<double>::infinity())
2129 err *= weight->
Eval(*T, ip);
2137 err *= weight->
Eval(*T, ip);
2139 error = std::max(error, err);
2144 if (p < numeric_limits<double>::infinity())
2149 error = -pow(-error, 1./p);
2153 error = pow(error, 1./p);
2162 for (
int i = 0; i <
size; i++)
2173 for (
int i = 0; i <
size; i++)
2212 out <<
"SCALARS " << field_name <<
" double 1\n"
2213 <<
"LOOKUP_TABLE default\n";
2214 for (
int i = 0; i < mesh->
GetNE(); i++)
2221 for (
int j = 0; j < val.
Size(); j++)
2223 out << val(j) <<
'\n';
2230 out <<
"VECTORS " << field_name <<
" double\n";
2231 for (
int i = 0; i < mesh->
GetNE(); i++)
2238 for (
int j = 0; j < vval.
Width(); j++)
2240 out << vval(0, j) <<
' ' << vval(1, j) <<
' ';
2256 for (
int vd = 0; vd < vec_dim; vd++)
2258 out <<
"SCALARS " << field_name << vd <<
" double 1\n"
2259 <<
"LOOKUP_TABLE default\n";
2260 for (
int i = 0; i < mesh->
GetNE(); i++)
2267 for (
int j = 0; j < val.
Size(); j++)
2269 out << val(j) <<
'\n';
2280 double v1[3] = { p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] };
2281 double v2[3] = { p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2] };
2282 double n[] = { v1[1] * v2[2] - v1[2] * v2[1],
2283 v1[2] * v2[0] - v1[0] * v2[2],
2284 v1[0] * v2[1] - v1[1] * v2[0]
2286 double rl = 1.0 / sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);
2287 n[0] *= rl; n[1] *= rl; n[2] *= rl;
2289 out <<
" facet normal " << n[0] <<
' ' << n[1] <<
' ' << n[2]
2291 <<
"\n vertex " << p1[0] <<
' ' << p1[1] <<
' ' << p1[2]
2292 <<
"\n vertex " << p2[0] <<
' ' << p2[1] <<
' ' << p2[2]
2293 <<
"\n vertex " << p3[0] <<
' ' << p3[1] <<
' ' << p3[2]
2294 <<
"\n endloop\n endfacet\n";
2310 double pts[4][3], bbox[3][2];
2312 out <<
"solid GridFunction\n";
2314 bbox[0][0] = bbox[0][1] = bbox[1][0] = bbox[1][1] =
2315 bbox[2][0] = bbox[2][1] = 0.0;
2316 for (i = 0; i < mesh->
GetNE(); i++)
2323 for (k = 0; k < RG.
Size()/n; k++)
2325 for (j = 0; j < n; j++)
2328 pts[j][0] = pointmat(0,l);
2329 pts[j][1] = pointmat(1,l);
2330 pts[j][2] = values(l);
2346 bbox[0][0] = pointmat(0,0);
2347 bbox[0][1] = pointmat(0,0);
2348 bbox[1][0] = pointmat(1,0);
2349 bbox[1][1] = pointmat(1,0);
2350 bbox[2][0] = values(0);
2351 bbox[2][1] = values(0);
2354 for (j = 0; j < values.
Size(); j++)
2356 if (bbox[0][0] > pointmat(0,j))
2358 bbox[0][0] = pointmat(0,j);
2360 if (bbox[0][1] < pointmat(0,j))
2362 bbox[0][1] = pointmat(0,j);
2364 if (bbox[1][0] > pointmat(1,j))
2366 bbox[1][0] = pointmat(1,j);
2368 if (bbox[1][1] < pointmat(1,j))
2370 bbox[1][1] = pointmat(1,j);
2372 if (bbox[2][0] > values(j))
2374 bbox[2][0] = values(j);
2376 if (bbox[2][1] < values(j))
2378 bbox[2][1] = values(j);
2383 cout <<
"[xmin,xmax] = [" << bbox[0][0] <<
',' << bbox[0][1] <<
"]\n"
2384 <<
"[ymin,ymax] = [" << bbox[1][0] <<
',' << bbox[1][1] <<
"]\n"
2385 <<
"[zmin,zmax] = [" << bbox[2][0] <<
',' << bbox[2][1] <<
']'
2388 out <<
"endsolid GridFunction" << endl;
2400 const char *msg =
"invalid input stream";
2406 in >> ident; MFEM_VERIFY(ident ==
"VDim:", msg);
2415 out <<
"VDim: " <<
vdim <<
'\n'
2432 int with_subdomains)
2434 const int with_coeff = 0;
2440 int nfe = ufes->
GetNE();
2444 Vector ul, fl, fla, d_xyz;
2454 if (with_subdomains)
2456 for (
int i = 0; i < nfe; i++)
2459 if (attr > nsd) { nsd = attr; }
2463 double total_error = 0.0;
2464 for (
int s = 1; s <= nsd; s++)
2467 u.
ComputeFlux(blfi, flux, with_coeff, (with_subdomains ? s : -1));
2469 for (
int i = 0; i < nfe; i++)
2471 if (with_subdomains && ufes->
GetAttribute(i) != s) {
continue; }
2481 *ffes->
GetFE(i), fl, with_coeff);
2486 (aniso_flags ? &d_xyz : NULL));
2488 error_estimates(i) = std::sqrt(err);
2494 for (
int k = 0; k <
dim; k++)
2499 double thresh = 0.15 * 3.0/
dim;
2501 for (
int k = 0; k <
dim; k++)
2503 if (d_xyz[k] / sum > thresh) { flag |= (1 << k); }
2506 (*aniso_flags)[i] = flag;
2511 return std::sqrt(total_error);
2534 for (
int j = 0; j < nip; j++)
2543 double err = val1.
Norml2();
2544 if (p < numeric_limits<double>::infinity())
2551 norm = std::max(norm, err);
2555 if (p < numeric_limits<double>::infinity())
2560 norm = -pow(-norm, 1./p);
2564 norm = pow(norm, 1./p);
2578 return sol_in.
Eval(*T_in, ip);
2589 string cname = name;
2590 if (cname ==
"Linear")
2594 else if (cname ==
"Quadratic")
2598 else if (cname ==
"Cubic")
2602 else if (!strncmp(name,
"H1_", 3))
2606 else if (!strncmp(name,
"H1Pos_", 6))
2611 else if (!strncmp(name,
"L2_T", 4))
2615 else if (!strncmp(name,
"L2_", 3))
2621 cerr <<
"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
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)
void ProjectDeltaCoefficient(DeltaCoefficient &delta_coeff, double &integral)
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
void Print(std::ostream &out=std::cout, int width=8) const
Prints vector to stream out.
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)
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.
void GetElementVertices(int i, Array< int > &dofs) const
Returns the indices of the dofs of element i.
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 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)
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)
double ComputeMaxError(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
void GetDerivative(int comp, int der_comp, GridFunction &der)
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)
double ComputeL2Error(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
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
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 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...
void GetCurl(ElementTransformation &tr, Vector &curl)
const SparseMatrix * GetConformingProlongation()
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.
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)
int GetDof() const
Returns the number of degrees of freedom in the finite element.
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.
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.
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 int GetTrueVSize()
Return the number of vector true (conforming) 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)
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).
void ProjectCoefficient(Coefficient &coeff)
Piecewise-(bi)quadratic continuous finite elements.
void SetSpace(FiniteElementSpace *f)
void ReorderByNodes()
For a vector grid function, makes sure that the ordering is byNODES.
NCMesh * ncmesh
Optional non-conforming mesh extension.
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.
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.
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 &)
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