15 #include "../mesh/nurbs.hpp"
16 #include "../general/text.hpp"
40 istream::int_type next_char = input.peek();
46 if (buff ==
"NURBS_patches")
49 "NURBS_patches requires NURBS FE space");
54 MFEM_ABORT(
"unknown section: " << buff);
88 int g_nddofs = g_ndofs - (g_nvdofs + g_nedofs + g_nfdofs);
90 vi = ei = fi = di = 0;
91 for (
int i = 0; i < num_pieces; i++)
98 int l_nddofs = l_ndofs - (l_nvdofs + l_nedofs + l_nfdofs);
99 const double *l_data = gf_array[i]->
GetData();
100 double *g_data =
data;
103 for (
int d = 0; d < vdim; d++)
105 memcpy(g_data+vi, l_data, l_nvdofs*
sizeof(
double));
108 memcpy(g_data+ei, l_data, l_nedofs*
sizeof(
double));
111 memcpy(g_data+fi, l_data, l_nfdofs*
sizeof(
double));
114 memcpy(g_data+di, l_data, l_nddofs*
sizeof(
double));
121 memcpy(g_data+vdim*vi, l_data, vdim*l_nvdofs*
sizeof(
double));
122 l_data += vdim*l_nvdofs;
123 g_data += vdim*g_nvdofs;
124 memcpy(g_data+vdim*ei, l_data, vdim*l_nedofs*
sizeof(
double));
125 l_data += vdim*l_nedofs;
126 g_data += vdim*g_nedofs;
127 memcpy(g_data+vdim*fi, l_data, vdim*l_nfdofs*
sizeof(
double));
128 l_data += vdim*l_nfdofs;
129 g_data += vdim*g_nfdofs;
130 memcpy(g_data+vdim*di, l_data, vdim*l_nddofs*
sizeof(
double));
131 l_data += vdim*l_nddofs;
132 g_data += vdim*g_nddofs;
160 MFEM_ABORT(
"Error in update sequence. GridFunction needs to be updated "
161 "right after the space is updated.");
169 old_data.
Swap(*
this);
172 T->
Mult(old_data, *
this);
253 int nfe = ufes->
GetNE();
261 for (
int i = 0; i < nfe; i++)
263 if (subdomain >= 0 && ufes->
GetAttribute(i) != subdomain)
275 *ffes->
GetFE(i), fl, wcoef);
280 for (
int j = 0; j < fdofs.
Size(); j++)
296 for (
int i = 0; i < count.Size(); i++)
298 if (count[i] != 0) { flux(i) /= count[i]; }
365 int dof = FElem->
GetDof();
375 "invalid FE map type");
377 for (k = 0; k < n; k++)
380 nval[k] = shape * ((
const double *)loc_data + dof * vdim);
387 for (k = 0; k < n; k++)
391 nval[k] = loc_data * (&vshape(0,vdim));
408 return (DofVal * LocVec);
415 int dof = FElem->
GetDof();
423 "invalid FE map type");
428 for (
int k = 0; k < vdim; k++)
430 val(k) = shape * ((
const double *)loc_data + dof * k);
456 "invalid FE map type");
457 int dof = FElem->
GetDof();
458 Vector DofVal(dof), loc_data(dof);
460 for (
int k = 0; k < n; k++)
463 vals(k) = DofVal * loc_data;
533 int dof = FElem->
GetDof();
542 "invalid FE map type");
546 for (
int j = 0; j < nip; j++)
550 for (
int k = 0; k < vdim; k++)
552 vals(k,j) = shape * ((
const double *)loc_data + dof * k);
562 for (
int j = 0; j < nip; j++)
631 Vector shape, loc_values, orig_loc_values;
632 int i, j, d, ne, dof, odof, vdim;
636 for (i = 0; i < ne; i++)
645 loc_values.
SetSize(dof * vdim);
648 for (j = 0; j < dof; j++)
652 for (d = 0; d < vdim; d++)
654 loc_values(d*dof+j) =
655 shape * ((
const double *)orig_loc_values + d * odof) ;
668 Vector shape, loc_values, orig_loc_values;
669 int i, j, d, nbe, dof, odof, vdim;
673 for (i = 0; i < nbe; i++)
682 loc_values.
SetSize(dof * vdim);
685 for (j = 0; j < dof; j++)
689 for (d = 0; d < vdim; d++)
691 loc_values(d*dof+j) =
692 shape * ((
const double *)orig_loc_values + d * odof);
706 int d, j, k, n, sdim, dof, ind;
713 int *dofs = &vdofs[comp*dof];
719 for (k = 0; k < n; k++)
724 for (d = 0; d < sdim; d++)
727 for (j = 0; j < dof; j++)
728 if ( (ind=dofs[j]) >= 0 )
730 a += vshape(j, d) *
data[ind];
734 a -= vshape(j, d) *
data[-1-ind];
751 double *temp =
new double[
size];
754 for (j = 0; j < ndofs; j++)
755 for (i = 0; i < vdim; i++)
757 temp[j+i*ndofs] =
data[k++];
760 for (i = 0; i <
size; i++)
788 val(vertices[k]) += vals(k, comp);
789 overlap[vertices[k]]++;
793 for (i = 0; i < overlap.Size(); i++)
795 val(i) /= overlap[i];
803 int d, i, k, ind, dof, sdim;
812 for (i = 0; i < new_fes->
GetNE(); i++)
819 for (d = 0; d < sdim; d++)
821 for (k = 0; k < dof; k++)
823 if ( (ind=new_vdofs[dof*d+k]) < 0 )
825 ind = -1-ind, vals(k, d) = - vals(k, d);
827 vec_field(ind) += vals(k, d);
833 for (i = 0; i < overlap.Size(); i++)
835 vec_field(i) /= overlap[i];
847 int i, j, k,
dim, dof, der_dof, ind;
850 for (i = 0; i < overlap.Size(); i++)
857 for (i = 0; i < der_fes->
GetNE(); i++)
866 der_dof = der_fe->
GetDof();
872 for (j = 0; j < dof; j++)
873 loc_func(j) = ( (ind=vdofs[comp*dof+j]) >= 0 ) ?
875 for (k = 0; k < der_dof; k++)
883 for (j = 0; j <
dim; j++)
885 a += inv_jac(j, der_comp) * pt_grad(j);
887 der(der_dofs[k]) += a;
888 overlap[der_dofs[k]]++;
892 for (i = 0; i < overlap.Size(); i++)
894 der(i) /= overlap[i];
915 MultAtB(loc_data_mat, dshape, gh);
926 "invalid FE map type");
931 for (
int i = 0; i < Jinv.
Width(); i++)
933 for (
int j = 0; j < Jinv.
Height(); j++)
935 div_v += grad_hat(i, j) * Jinv(j, i);
947 div_v = (loc_data * divshape) / tr.
Weight();
959 "invalid FE map type");
964 Mult(grad_hat, Jinv, grad);
965 MFEM_ASSERT(grad.Height() == grad.Width(),
"");
966 if (grad.Height() == 3)
969 curl(0) = grad(2,1) - grad(1,2);
970 curl(1) = grad(0,2) - grad(2,0);
971 curl(2) = grad(1,0) - grad(0,1);
973 else if (grad.Height() == 2)
976 curl(0) = grad(1,0) - grad(0,1);
988 curl.
SetSize(curl_shape.Width());
989 if (curl_shape.Width() == 3)
992 curl_shape.MultTranspose(loc_data, curl_hat);
997 curl_shape.MultTranspose(loc_data, curl);
1038 dshape.MultTranspose(lval, gh);
1050 "invalid FE map type");
1055 Mult(grad_hat, Jinv, grad);
1063 Vector loc_avgs, loc_this;
1068 for (
int i = 0; i <
fes->
GetNE(); i++)
1073 avgs.FESpace()->GetElementDofs(i, te_dofs);
1076 loc_mass.
Mult(loc_this, loc_avgs);
1077 avgs.AddElementVector(te_dofs, loc_avgs);
1079 loc_mass.
Mult(loc_this, loc_avgs);
1080 int_psi.AddElementVector(te_dofs, loc_avgs);
1082 for (
int i = 0; i < avgs.Size(); i++)
1084 avgs(i) /= int_psi(i);
1094 if (!mesh->
GetNE()) {
return; }
1105 MFEM_VERIFY(vdim == src.
fes->
GetVDim(),
"incompatible vector dimensions!");
1110 for (
int i = 0; i < mesh->
GetNE(); i++)
1117 dest_lvec.SetSize(vdim*P.
Height());
1123 for (
int vd = 0; vd < vdim; vd++)
1138 Vector vals, new_vals(size);
1141 MFEM_ASSERT(weights.
Size() ==
size,
"Different # of weights and dofs.");
1142 MFEM_ASSERT(_lo.
Size() ==
size,
"Different # of lower bounds and dofs.");
1143 MFEM_ASSERT(_hi.
Size() ==
size,
"Different # of upper bounds and dofs.");
1146 double tol = 1.e-12;
1154 slbqp.
Mult(vals, new_vals);
1160 double _min,
double _max)
1165 Vector vals, new_vals(size);
1168 double max_val = vals.
Max();
1169 double min_val = vals.
Min();
1171 if (max_val <= _min)
1178 if (_min <= min_val && max_val <= _max)
1183 Vector minv(size), maxv(size);
1184 minv = (_min > min_val) ? _min : min_val;
1185 maxv = (_max < max_val) ? _max : max_val;
1204 for (j = 0; j < vertices.
Size(); j++)
1206 nval(vertices[j]) += values[j];
1207 overlap[vertices[j]]++;
1210 for (i = 0; i < overlap.Size(); i++)
1212 nval(i) /= overlap[i];
1227 for (
int i = 0; i <
fes->
GetNE(); i++)
1235 for (
int j = 0; j < vdofs.
Size(); j++)
1239 MFEM_VERIFY(vals[j] != 0.0,
1240 "Coefficient has zeros, harmonic avg is undefined!");
1241 (*this)(vdofs[j]) += 1.0 / vals[j];
1245 (*this)(vdofs[j]) += vals[j];
1247 else { MFEM_ABORT(
"Not implemented"); }
1249 zones_per_vdof[vdofs[j]]++;
1265 for (
int i = 0; i <
fes->
GetNE(); i++)
1273 for (
int j = 0; j < vdofs.
Size(); j++)
1290 MFEM_VERIFY(vals[j] != 0.0,
1291 "Coefficient has zeros, harmonic avg is undefined!");
1292 (*this)(ldof) += isign / vals[j];
1296 (*this)(ldof) += isign*vals[j];
1299 else { MFEM_ABORT(
"Not implemented"); }
1301 zones_per_vdof[ldof]++;
1310 int i, j, fdof, d, ind, vdim;
1331 for (j = 0; j < fdof; j++)
1335 if (vcoeff) { vcoeff->
Eval(vc, *transf, ip); }
1336 for (d = 0; d < vdim; d++)
1338 if (!vcoeff && !coeff[d]) {
continue; }
1340 val = vcoeff ? vc(d) : coeff[d]->
Eval(*transf, ip);
1341 if ( (ind = vdofs[fdof*d+j]) < 0 )
1343 val = -val, ind = -1-ind;
1345 if (++values_counter[ind] == 1)
1351 (*this)(ind) += val;
1374 for (i = 0; i < bdr_edges.
Size(); i++)
1376 int edge = bdr_edges[i];
1378 if (vdofs.
Size() == 0) {
continue; }
1386 for (d = 0; d < vdim; d++)
1388 if (!coeff[d]) {
continue; }
1390 fe->
Project(*coeff[d], *transf, vals);
1391 for (
int k = 0; k < vals.
Size(); k++)
1393 ind = vdofs[d*vals.
Size()+k];
1394 if (++values_counter[ind] == 1)
1396 (*this)(ind) = vals(k);
1400 (*this)(ind) += vals(k);
1408 fe->
Project(*vcoeff, *transf, vals);
1409 for (
int k = 0; k < vals.
Size(); k++)
1412 if (++values_counter[ind] == 1)
1414 (*this)(ind) = vals(k);
1418 (*this)(ind) += vals(k);
1429 for (
int i = 0; i < dofs.
Size(); i++)
1432 double val = vals(i);
1433 if (k < 0) { k = -1 - k; val = -val; }
1434 if (++values_counter[k] == 1)
1467 fe->
Project(vcoeff, *T, lvec);
1468 accumulate_dofs(dofs, lvec, *
this, values_counter);
1478 for (
int i = 0; i < bdr_edges.
Size(); i++)
1480 int edge = bdr_edges[i];
1482 if (dofs.
Size() == 0) {
continue; }
1488 fe->
Project(vcoeff, *T, lvec);
1489 accumulate_dofs(dofs, lvec, *
this, values_counter);
1499 for (
int i = 0; i <
size; i++)
1501 const int nz = zones_per_vdof[i];
1502 if (nz) { (*this)(i) /= nz; }
1507 for (
int i = 0; i <
size; i++)
1509 const int nz = zones_per_vdof[i];
1510 if (nz) { (*this)(i) = nz/(*
this)(i); }
1515 MFEM_ABORT(
"invalud AvgType");
1530 const double *center = delta_coeff.
Center();
1531 const double *vert = mesh->
GetVertex(0);
1532 double min_dist, dist;
1536 min_dist =
Distance(center, vert, dim);
1537 for (
int i = 0; i < mesh->
GetNV(); i++)
1540 dist =
Distance(center, vert, dim);
1541 if (dist < min_dist)
1551 if (min_dist >= delta_coeff.
Tol())
1560 Vector vals, loc_mass_vals;
1561 for (
int i = 0; i < mesh->
GetNE(); i++)
1564 for (
int j = 0; j < vertices.
Size(); j++)
1565 if (vertices[j] == v_idx)
1575 loc_mass.Mult(vals, loc_mass_vals);
1576 integral += loc_mass_vals.
Sum();
1586 if (delta_c == NULL)
1591 for (
int i = 0; i <
fes->
GetNE(); i++)
1605 (*this) *= (delta_c->
Scale() / integral);
1616 for (
int i = 0; i < dofs.
Size(); i++)
1629 (*this)(vdof) = coeff.
Eval(*T, ip);
1657 for (
int i = 0; i < dofs.
Size(); i++)
1669 vcoeff.
Eval(val, *T, ip);
1673 (*this)(vdof) = val(vd);
1680 int i, j, fdof, d, ind, vdim;
1694 for (j = 0; j < fdof; j++)
1698 for (d = 0; d < vdim; d++)
1700 if (!coeff[d]) {
continue; }
1702 val = coeff[d]->
Eval(*transf, ip);
1703 if ( (ind = vdofs[fdof*d+j]) < 0 )
1705 val = -val, ind = -1-ind;
1724 for (
int i = 0; i <
fes->
GetNE(); i++)
1733 for (
int j = 0; j < vdofs.
Size(); j++)
1735 if (attr > dof_attr[vdofs[j]])
1737 (*this)(vdofs[j]) = vals[j];
1738 dof_attr[vdofs[j]] = attr;
1779 for (
int i = 0; i < values_counter.
Size(); i++)
1781 MFEM_ASSERT(
bool(values_counter[i]) ==
bool(ess_vdofs_marker[i]),
1796 for (
int i = 0; i < values_counter.
Size(); i++)
1798 MFEM_ASSERT(
bool(values_counter[i]) ==
bool(ess_vdofs_marker[i]),
1814 Vector vc(dim), nor(dim), lvec, shape;
1834 vcoeff.
Eval(vc, *T, ip);
1837 lvec.
Add(ip.
weight * (vc * nor), shape);
1849 Vector vc(dim), nor(dim), lvec;
1865 vcoeff.
Eval(vc, *T, ip);
1867 lvec(j) = (vc * nor);
1884 for (
int i = 0; i < values_counter.
Size(); i++)
1886 MFEM_ASSERT(
bool(values_counter[i]) ==
bool(ess_vdofs_marker[i]),
1895 double error = 0.0, a;
1900 int fdof, d, i, intorder, j, k;
1926 for (k = 0; k < fdof; k++)
1927 if (vdofs[fdof*d+k] >= 0)
1929 a += (*this)(vdofs[fdof*d+k]) * shape(k);
1933 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
1936 a -= exsol[d]->
Eval(*transf, ip);
1944 return -sqrt(-error);
1959 for (
int i = 0; i <
fes->
GetNE(); i++)
1961 if (elems != NULL && (*elems)[i] == 0) {
continue; }
1963 int intorder = 2*fe->
GetOrder() + 1;
1975 exsol.
Eval(exact_vals, *T, *ir);
1978 vals.
Norm2(loc_errs);
1983 error += ip.
weight * T->
Weight() * (loc_errs(j) * loc_errs(j));
1989 return -sqrt(-error);
1996 Coefficient *ell_coeff,
double Nu,
int norm_type)
const
1999 int i, fdof,
dim, intorder, j, k;
2004 Vector e_grad, a_grad, shape, el_dofs, err_val, ell_coeff_val;
2017 for (i = 0; i < mesh->
GetNE(); i++)
2028 for (k = 0; k < fdof; k++)
2031 el_dofs(k) = (*this)(vdofs[k]);
2035 el_dofs(k) = - (*this)(-1-vdofs[k]);
2042 exgrad->
Eval(e_grad, *transf, ip);
2044 Mult(dshape, Jinv, dshapet);
2048 ell_coeff->
Eval(*transf, ip) *
2057 int i1 = face_elem_transf->
Elem1No;
2058 int i2 = face_elem_transf->
Elem2No;
2065 intorder = 2 * intorder;
2071 transf = face_elem_transf->
Elem1;
2077 for (k = 0; k < fdof; k++)
2080 el_dofs(k) = (*this)(vdofs[k]);
2084 el_dofs(k) = - (*this)(-1-vdofs[k]);
2091 ell_coeff_val(j) = ell_coeff->
Eval(*transf, eip);
2092 err_val(j) = exsol->
Eval(*transf, eip) - (shape * el_dofs);
2098 transf = face_elem_transf->
Elem2;
2104 for (k = 0; k < fdof; k++)
2107 el_dofs(k) = (*this)(vdofs[k]);
2111 el_dofs(k) = - (*this)(-1-vdofs[k]);
2118 ell_coeff_val(j) += ell_coeff->
Eval(*transf, eip);
2119 ell_coeff_val(j) *= 0.5;
2120 err_val(j) -= (exsol->
Eval(*transf, eip) - (shape * el_dofs));
2124 transf = face_elem_transf->
Face;
2129 error += (ip.
weight * Nu * ell_coeff_val(j) *
2130 pow(transf->
Weight(), 1.0-1.0/(dim-1)) *
2131 err_val(j) * err_val(j));
2137 return -sqrt(-error);
2145 double error = 0.0, a;
2150 int fdof, d, i, intorder, j, k;
2177 for (k = 0; k < fdof; k++)
2178 if (vdofs[fdof*d+k] >= 0)
2180 a += (*this)(vdofs[fdof*d+k]) * shape(k);
2184 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
2186 a -= exsol[d]->
Eval(*transf, ip);
2204 int i, fdof,
dim, intorder, j, k;
2208 Vector e_grad, a_grad, shape, el_dofs, err_val, ell_coeff_val;
2211 double a, error = 0.0;
2220 for (i = 0; i < mesh->
GetNE(); i++)
2222 if (elems != NULL && (*elems)[i] == 0) {
continue; }
2239 for (k = 0; k < fdof; k++)
2242 el_dofs(k) = (*this)(vdofs[k]);
2246 el_dofs(k) = -(*this)(-1-vdofs[k]);
2253 a = (el_dofs * shape) - (exsol->
Eval(*transf, ip));
2259 for (i = 0; i < mesh->
GetNE(); i++)
2261 if (elems != NULL && (*elems)[i] == 0) {
continue; }
2279 for (k = 0; k < fdof; k++)
2282 el_dofs(k) = (*this)(vdofs[k]);
2286 el_dofs(k) = -(*this)(-1-vdofs[k]);
2293 exgrad->
Eval(e_grad, *transf, ip);
2295 Mult(dshape, Jinv, dshapet);
2314 for (
int i = 0; i <
fes->
GetNE(); i++)
2324 int intorder = 2*fe->
GetOrder() + 1;
2333 double err = fabs(vals(j) - exsol.
Eval(*T, ip));
2339 err *= weight->
Eval(*T, ip);
2347 err *= weight->
Eval(*T, ip);
2349 error = std::max(error, err);
2359 error = -pow(-error, 1./p);
2363 error = pow(error, 1./p);
2380 for (
int i = 0; i <
fes->
GetNE(); i++)
2390 int intorder = 2*fe->
GetOrder() + 1;
2399 double err = fabs(vals(j) - exsol.
Eval(*T, ip));
2405 err *= weight->
Eval(*T, ip);
2413 err *= weight->
Eval(*T, ip);
2415 error[i] = std::max(error[i], err);
2423 error[i] = -pow(-error[i], 1./p);
2427 error[i] = pow(error[i], 1./p);
2444 for (
int i = 0; i <
fes->
GetNE(); i++)
2454 int intorder = 2*fe->
GetOrder() + 1;
2459 exsol.
Eval(exact_vals, *T, *ir);
2466 vals.
Norm2(loc_errs);
2470 v_weight->
Eval(exact_vals, *T, *ir);
2473 for (
int j = 0; j < vals.
Width(); j++)
2476 for (
int d = 0; d < vals.
Height(); d++)
2478 err += vals(d,j)*exact_vals(d,j);
2480 loc_errs(j) = fabs(err);
2487 double err = loc_errs(j);
2493 err *= weight->
Eval(*T, ip);
2501 err *= weight->
Eval(*T, ip);
2503 error = std::max(error, err);
2513 error = -pow(-error, 1./p);
2517 error = pow(error, 1./p);
2537 for (
int i = 0; i <
fes->
GetNE(); i++)
2547 int intorder = 2*fe->
GetOrder() + 1;
2552 exsol.
Eval(exact_vals, *T, *ir);
2559 vals.
Norm2(loc_errs);
2563 v_weight->
Eval(exact_vals, *T, *ir);
2566 for (
int j = 0; j < vals.
Width(); j++)
2569 for (
int d = 0; d < vals.
Height(); d++)
2571 err += vals(d,j)*exact_vals(d,j);
2573 loc_errs(j) = fabs(err);
2580 double err = loc_errs(j);
2586 err *= weight->
Eval(*T, ip);
2594 err *= weight->
Eval(*T, ip);
2596 error[i] = std::max(error[i], err);
2604 error[i] = -pow(-error[i], 1./p);
2608 error[i] = pow(error[i], 1./p);
2635 out <<
"NURBS_patches\n";
2664 out <<
"SCALARS " << field_name <<
" double 1\n"
2665 <<
"LOOKUP_TABLE default\n";
2666 for (
int i = 0; i < mesh->
GetNE(); i++)
2673 for (
int j = 0; j < val.
Size(); j++)
2675 out << val(j) <<
'\n';
2679 else if ( (vec_dim == 2 || vec_dim == 3) && mesh->
SpaceDimension() > 1)
2682 out <<
"VECTORS " << field_name <<
" double\n";
2683 for (
int i = 0; i < mesh->
GetNE(); i++)
2690 for (
int j = 0; j < vval.
Width(); j++)
2692 out << vval(0, j) <<
' ' << vval(1, j) <<
' ';
2708 for (
int vd = 0; vd < vec_dim; vd++)
2710 out <<
"SCALARS " << field_name << vd <<
" double 1\n"
2711 <<
"LOOKUP_TABLE default\n";
2712 for (
int i = 0; i < mesh->
GetNE(); i++)
2719 for (
int j = 0; j < val.
Size(); j++)
2721 out << val(j) <<
'\n';
2732 double v1[3] = { p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] };
2733 double v2[3] = { p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2] };
2734 double n[] = { v1[1] * v2[2] - v1[2] * v2[1],
2735 v1[2] * v2[0] - v1[0] * v2[2],
2736 v1[0] * v2[1] - v1[1] * v2[0]
2738 double rl = 1.0 / sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);
2739 n[0] *= rl; n[1] *= rl; n[2] *= rl;
2741 out <<
" facet normal " << n[0] <<
' ' << n[1] <<
' ' << n[2]
2743 <<
"\n vertex " << p1[0] <<
' ' << p1[1] <<
' ' << p1[2]
2744 <<
"\n vertex " << p2[0] <<
' ' << p2[1] <<
' ' << p2[2]
2745 <<
"\n vertex " << p3[0] <<
' ' << p3[1] <<
' ' << p3[2]
2746 <<
"\n endloop\n endfacet\n";
2762 double pts[4][3], bbox[3][2];
2764 out <<
"solid GridFunction\n";
2766 bbox[0][0] = bbox[0][1] = bbox[1][0] = bbox[1][1] =
2767 bbox[2][0] = bbox[2][1] = 0.0;
2768 for (i = 0; i < mesh->
GetNE(); i++)
2775 for (k = 0; k < RG.
Size()/n; k++)
2777 for (j = 0; j < n; j++)
2780 pts[j][0] = pointmat(0,l);
2781 pts[j][1] = pointmat(1,l);
2782 pts[j][2] = values(l);
2798 bbox[0][0] = pointmat(0,0);
2799 bbox[0][1] = pointmat(0,0);
2800 bbox[1][0] = pointmat(1,0);
2801 bbox[1][1] = pointmat(1,0);
2802 bbox[2][0] = values(0);
2803 bbox[2][1] = values(0);
2806 for (j = 0; j < values.
Size(); j++)
2808 if (bbox[0][0] > pointmat(0,j))
2810 bbox[0][0] = pointmat(0,j);
2812 if (bbox[0][1] < pointmat(0,j))
2814 bbox[0][1] = pointmat(0,j);
2816 if (bbox[1][0] > pointmat(1,j))
2818 bbox[1][0] = pointmat(1,j);
2820 if (bbox[1][1] < pointmat(1,j))
2822 bbox[1][1] = pointmat(1,j);
2824 if (bbox[2][0] > values(j))
2826 bbox[2][0] = values(j);
2828 if (bbox[2][1] < values(j))
2830 bbox[2][1] = values(j);
2835 mfem::out <<
"[xmin,xmax] = [" << bbox[0][0] <<
',' << bbox[0][1] <<
"]\n"
2836 <<
"[ymin,ymax] = [" << bbox[1][0] <<
',' << bbox[1][1] <<
"]\n"
2837 <<
"[zmin,zmax] = [" << bbox[2][0] <<
',' << bbox[2][1] <<
']'
2840 out <<
"endsolid GridFunction" << endl;
2852 const char *msg =
"invalid input stream";
2858 in >> ident; MFEM_VERIFY(ident ==
"VDim:", msg);
2885 out <<
"VDim: " <<
vdim <<
'\n'
2902 int with_subdomains)
2904 const int with_coeff = 0;
2910 int nfe = ufes->
GetNE();
2914 Vector ul, fl, fla, d_xyz;
2924 if (with_subdomains)
2929 double total_error = 0.0;
2930 for (
int s = 1; s <= nsd; s++)
2933 u.
ComputeFlux(blfi, flux, with_coeff, (with_subdomains ? s : -1));
2935 for (
int i = 0; i < nfe; i++)
2937 if (with_subdomains && ufes->
GetAttribute(i) != s) {
continue; }
2947 *ffes->
GetFE(i), fl, with_coeff);
2952 (aniso_flags ? &d_xyz : NULL));
2954 error_estimates(i) = std::sqrt(err);
2960 for (
int k = 0; k <
dim; k++)
2965 double thresh = 0.15 * 3.0/
dim;
2967 for (
int k = 0; k <
dim; k++)
2969 if (d_xyz[k] / sum > thresh) { flag |= (1 << k); }
2972 (*aniso_flags)[i] = flag;
2977 return std::sqrt(total_error);
3000 for (
int j = 0; j < nip; j++)
3017 norm = std::max(norm, err);
3026 norm = -pow(-norm, 1./p);
3030 norm = pow(norm, 1./p);
3044 return sol_in.
Eval(*T_in, ip);
3055 string cname = name;
3056 if (cname ==
"Linear")
3060 else if (cname ==
"Quadratic")
3064 else if (cname ==
"Cubic")
3068 else if (!strncmp(name,
"H1_", 3))
3072 else if (!strncmp(name,
"H1Pos_", 6))
3077 else if (!strncmp(name,
"L2_T", 4))
3081 else if (!strncmp(name,
"L2_", 3))
3087 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 GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
double * HostReadWrite()
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), false).
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.
void GetElementAverages(GridFunction &avgs) 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 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
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
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
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 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.
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 GetSize() const
Return the total number of quadrature points.
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
double Norml2() const
Returns the l2 norm of the vector.
void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
virtual const FiniteElement * FiniteElementForGeometry(Geometry::Type GeomType) const =0
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
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
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).
void AccumulateAndCountBdrTangentValues(VectorCoefficient &vcoeff, Array< int > &bdr_attr, Array< int > &values_counter)
int vdim
Vector dimension.
void GetVectorGradientHat(ElementTransformation &T, DenseMatrix &gh) const
int GetNV() const
Returns number of vertices in the mesh.
FiniteElementCollection * Load(Mesh *m, std::istream &input)
Read a FiniteElementSpace from a stream. The returned FiniteElementCollection is owned by the caller...
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.
FaceElementTransformations * GetFaceElementTransformations(int FaceNo, int mask=31)
Geometry::Type GetElementBaseGeometry(int i) const
const IntegrationRule * GetVertices(int GeomType)
Return an IntegrationRule consisting of all vertices of the given Geometry::Type, GeomType...
Memory< double > & GetMemory()
Return a reference to the Memory object used by the Vector.
void skip_comment_lines(std::istream &is, const char comment_char)
void GetEdgeTransformation(int i, IsoparametricTransformation *EdTr)
void GetVectorFieldNodalValues(Vector &val, int comp) const
Vector & operator=(const double *v)
Copy Size() entries from v.
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.
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)
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)
const FiniteElement * GetEdgeElement(int i) const
void SetPrintLevel(int print_lvl)
bool UseDevice() const
Return the device flag of the Memory object used by the Vector.
int GetNBE() const
Returns number of boundary elements in the mesh.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
void Swap(Vector &other)
Swap the contents of two Vectors.
Mesh * GetMesh() const
Returns the mesh.
void GetVectorFieldValues(int i, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr, int comp=0) const
void PrintSolution(const GridFunction &sol, std::ostream &out) const
Coefficient * Weight()
See SetWeight() for description of the weight Coefficient.
virtual double ComputeH1Error(Coefficient *exsol, VectorCoefficient *exgrad, Coefficient *ell_coef, double Nu, int norm_type) const
void MakeTRef(FiniteElementSpace *f, double *tv)
Associate a new FiniteElementSpace and new true-dof data with the GridFunction.
void SetMaxIter(int max_it)
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const =0
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
void Norm2(double *v) const
Take the 2-norm of the columns of A and store in v.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
virtual const Operator * GetProlongationMatrix() const
The returned Operator is owned by the FiniteElementSpace.
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.
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 on higher-order hexahedral, quadrilateral or triangular meshes...
void LoadSolution(std::istream &input, GridFunction &sol) const
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 (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
QuadratureFunction & operator=(double value)
Redefine '=' for QuadratureFunction = constant.
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
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)
const NURBSExtension * GetNURBSext() const
double Distance(const double *x, const double *y, const int n)
void Print(std::ostream &out=mfem::out, int width=8) const
Prints vector to stream out.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
int GetLocalDofForDof(int i) const
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 the grid function lives. Owned if fec is not NULL.
void ProjectGridFunction(const GridFunction &src)
Project the src GridFunction to this GridFunction, both of which must be on the same mesh...
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. It can also be set explicitly, see MakeOwner()...
void GetVectorGradient(ElementTransformation &tr, DenseMatrix &grad) const
double GetDivergence(ElementTransformation &tr) const
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
double ComputeElementLpDistance(double p, int i, GridFunction &gf1, GridFunction &gf2)
Compute the Lp distance between two grid functions on the given element.
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...
int GetNVDofs() const
Number of all scalar vertex dofs.
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)
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 void ComputeElementLpErrors(const double p, Coefficient &exsol, GridFunction &error, Coefficient *weight=NULL, const IntegrationRule *irs[]=NULL) const
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement associated with i'th element.
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 GetVectorValues(ElementTransformation &T, const IntegrationRule &ir, DenseMatrix &vals) const
double infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
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
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.
void filter_dos(std::string &line)
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.
void GetCurl(ElementTransformation &tr, Vector &curl) const
const FiniteElementCollection * FEColl() const
void Mult(const double *x, double *y) const
Matrix vector multiplication.
For scalar fields; preserves point values.
Arbitrary order H1-conforming (continuous) finite elements.
void pts(int iphi, int t, double x[])
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...
virtual const SparseMatrix * GetRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
long GetSequence() const
Return update counter (see Mesh::sequence)
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(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.
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
void AccumulateAndCountBdrValues(Coefficient *coeff[], VectorCoefficient *vcoeff, Array< int > &attr, Array< int > &values_counter)
void Save(std::ostream &out) const
Write the QuadratureFunction to the stream out.
void SaveVTK(std::ostream &out, const std::string &field_name, int ref)
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