31 const int bufflen = 256;
36 input.getline(buff, bufflen);
37 if (strcmp(buff,
"FiniteElementSpace"))
39 " input stream is not a GridFunction!");
40 input.getline(buff, bufflen,
' ');
42 input.getline(buff, bufflen);
44 input.getline(buff, bufflen,
' ');
46 input.getline(buff, bufflen,
' ');
49 input.getline(buff, bufflen);
77 int g_nddofs = g_ndofs - (g_nvdofs + g_nedofs + g_nfdofs);
79 vi = ei = fi = di = 0;
80 for (
int i = 0; i < num_pieces; i++)
87 int l_nddofs = l_ndofs - (l_nvdofs + l_nedofs + l_nfdofs);
88 const double *l_data = gf_array[i]->
GetData();
89 double *g_data =
data;
92 for (
int d = 0; d < vdim; d++)
94 memcpy(g_data+vi, l_data, l_nvdofs*
sizeof(
double));
97 memcpy(g_data+ei, l_data, l_nedofs*
sizeof(
double));
100 memcpy(g_data+fi, l_data, l_nfdofs*
sizeof(
double));
103 memcpy(g_data+di, l_data, l_nddofs*
sizeof(
double));
110 memcpy(g_data+vdim*vi, l_data, vdim*l_nvdofs*
sizeof(
double));
111 l_data += vdim*l_nvdofs;
112 g_data += vdim*g_nvdofs;
113 memcpy(g_data+vdim*ei, l_data, vdim*l_nedofs*
sizeof(
double));
114 l_data += vdim*l_nedofs;
115 g_data += vdim*g_nedofs;
116 memcpy(g_data+vdim*fi, l_data, vdim*l_nfdofs*
sizeof(
double));
117 l_data += vdim*l_nfdofs;
118 g_data += vdim*g_nfdofs;
119 memcpy(g_data+vdim*di, l_data, vdim*l_nddofs*
sizeof(
double));
120 l_data += vdim*l_nddofs;
121 g_data += vdim*g_nddofs;
151 MFEM_ABORT(
"Error in update sequence. GridFunction needs to be updated "
152 "right after the space is updated.");
199 int nfe = ufes->
GetNE();
207 for (
int i = 0; i < nfe; i++)
209 if (subdomain >= 0 && ufes->
GetAttribute(i) != subdomain)
221 *ffes->
GetFE(i), fl, wcoef);
226 for (
int j = 0; j < fdofs.
Size(); j++)
242 for (
int i = 0; i < count.Size(); i++)
244 if (count[i] != 0) { flux(i) /= count[i]; }
274 int dof = FElem->
GetDof();
284 for (k = 0; k < n; k++)
287 nval[k] = shape * ((
const double *)loc_data + dof * vdim);
294 for (k = 0; k < n; k++)
298 nval[k] = loc_data * (&vshape(0,vdim));
313 return (DofVal * LocVec);
320 int dof = FElem->
GetDof();
331 for (
int k = 0; k < vdim; k++)
333 val(k) = shape * ((
const double *)loc_data + dof * k);
358 int dof = FElem->
GetDof();
359 Vector DofVal(dof), loc_data(dof);
361 for (
int k = 0; k < n; k++)
364 vals(k) = DofVal * loc_data;
434 int dof = FElem->
GetDof();
445 for (
int j = 0; j < nip; j++)
449 for (
int k = 0; k < vdim; k++)
451 vals(k,j) = shape * ((
const double *)loc_data + dof * k);
461 for (
int j = 0; j < nip; j++)
530 Vector shape, loc_values, orig_loc_values;
531 int i, j, d, ne, dof, odof, vdim;
535 for (i = 0; i < ne; i++)
544 loc_values.
SetSize(dof * vdim);
547 for (j = 0; j < dof; j++)
551 for (d = 0; d < vdim; d++)
553 loc_values(d*dof+j) =
554 shape * ((
const double *)orig_loc_values + d * odof) ;
567 Vector shape, loc_values, orig_loc_values;
568 int i, j, d, nbe, dof, odof, vdim;
572 for (i = 0; i < nbe; i++)
581 loc_values.
SetSize(dof * vdim);
584 for (j = 0; j < dof; j++)
588 for (d = 0; d < vdim; d++)
590 loc_values(d*dof+j) =
591 shape * ((
const double *)orig_loc_values + d * odof);
605 int d, j, k, n, sdim, dof, ind;
612 int *dofs = &vdofs[comp*dof];
618 for (k = 0; k < n; k++)
623 for (d = 0; d < sdim; d++)
626 for (j = 0; j < dof; j++)
627 if ( (ind=dofs[j]) >= 0 )
629 a += vshape(j, d) *
data[ind];
633 a -= vshape(j, d) *
data[-1-ind];
650 double *temp =
new double[
size];
653 for (j = 0; j < ndofs; j++)
654 for (i = 0; i < vdim; i++)
656 temp[j+i*ndofs] =
data[k++];
659 for (i = 0; i <
size; i++)
687 val(vertices[k]) += vals(k, comp);
688 overlap[vertices[k]]++;
692 for (i = 0; i < overlap.Size(); i++)
694 val(i) /= overlap[i];
702 int d, i, k, ind, dof, sdim;
711 for (i = 0; i < new_fes->
GetNE(); i++)
718 for (d = 0; d < sdim; d++)
720 for (k = 0; k < dof; k++)
722 if ( (ind=new_vdofs[dof*d+k]) < 0 )
724 ind = -1-ind, vals(k, d) = - vals(k, d);
726 vec_field(ind) += vals(k, d);
732 for (i = 0; i < overlap.Size(); i++)
734 vec_field(i) /= overlap[i];
746 int i, j, k,
dim, dof, der_dof, ind;
749 for (i = 0; i < overlap.Size(); i++)
756 for (i = 0; i < der_fes->
GetNE(); i++)
765 der_dof = der_fe->
GetDof();
771 for (j = 0; j < dof; j++)
772 loc_func(j) = ( (ind=vdofs[comp*dof+j]) >= 0 ) ?
774 for (k = 0; k < der_dof; k++)
782 for (j = 0; j <
dim; j++)
784 a += inv_jac(j, der_comp) * pt_grad(j);
786 der(der_dofs[k]) += a;
787 overlap[der_dofs[k]]++;
791 for (i = 0; i < overlap.Size(); i++)
793 der(i) /= overlap[i];
814 MultAtB(loc_data_mat, dshape, gh);
830 for (
int i = 0; i < Jinv.Width(); i++)
831 for (
int j = 0; j < Jinv.Height(); j++)
833 div_v += grad_hat(i, j) * Jinv(j, i);
844 div_v = (loc_data * divshape) / tr.
Weight();
861 Mult(grad_hat, Jinv, grad);
862 MFEM_ASSERT(grad.Height() == grad.Width(),
"");
863 if (grad.Height() == 3)
866 curl(0) = grad(2,1) - grad(1,2);
867 curl(1) = grad(0,2) - grad(2,0);
868 curl(2) = grad(1,0) - grad(0,1);
870 else if (grad.Height() == 2)
873 curl(0) = grad(1,0) - grad(0,1);
885 curl.
SetSize(curl_shape.Width());
886 if (curl_shape.Width() == 3)
889 curl_shape.MultTranspose(loc_data, curl_hat);
894 curl_shape.MultTranspose(loc_data, curl);
913 dshape.MultTranspose(lval, gh);
934 dshape.MultTranspose(lval, gh);
938 Jinv.MultTranspose(gh, gcol);
951 Mult(grad_hat, Jinv, grad);
959 Vector loc_avgs, loc_this;
964 for (
int i = 0; i <
fes->
GetNE(); i++)
969 avgs.FESpace()->GetElementDofs(i, te_dofs);
972 loc_mass.
Mult(loc_this, loc_avgs);
973 avgs.AddElementVector(te_dofs, loc_avgs);
975 loc_mass.
Mult(loc_this, loc_avgs);
976 int_psi.AddElementVector(te_dofs, loc_avgs);
978 for (
int i = 0; i < avgs.Size(); i++)
980 avgs(i) /= int_psi(i);
999 mfem_error(
"GridFunction::ProjectGridFunction() :"
1000 " incompatible vector dimensions!");
1004 for (
int i = 0; i < mesh->
GetNE(); i++)
1008 for (
int vd = 0; vd < vdim; vd++)
1023 Vector vals, new_vals(size);
1026 MFEM_ASSERT(weights.
Size() ==
size,
"Different # of weights and dofs.");
1027 MFEM_ASSERT(_lo.
Size() ==
size,
"Different # of lower bounds and dofs.");
1028 MFEM_ASSERT(_hi.
Size() ==
size,
"Different # of upper bounds and dofs.");
1031 double tol = 1.e-12;
1039 slbqp.
Mult(vals, new_vals);
1045 double _min,
double _max)
1050 Vector vals, new_vals(size);
1053 double max_val = vals.
Max();
1054 double min_val = vals.
Min();
1056 if (max_val <= _min)
1063 if (_min <= min_val && max_val <= _max)
1068 Vector minv(size), maxv(size);
1069 minv = (_min > min_val) ? _min : min_val;
1070 maxv = (_max < max_val) ? _max : max_val;
1089 for (j = 0; j < vertices.
Size(); j++)
1091 nval(vertices[j]) += values[j];
1092 overlap[vertices[j]]++;
1095 for (i = 0; i < overlap.Size(); i++)
1097 nval(i) /= overlap[i];
1112 const double *center = delta_coeff.
Center();
1113 const double *vert = mesh->
GetVertex(0);
1114 double min_dist, dist;
1118 min_dist =
Distance(center, vert, dim);
1119 for (
int i = 0; i < mesh->
GetNV(); i++)
1122 dist =
Distance(center, vert, dim);
1123 if (dist < min_dist)
1133 if (min_dist >= delta_coeff.
Tol())
1142 Vector vals, loc_mass_vals;
1143 for (
int i = 0; i < mesh->
GetNE(); i++)
1146 for (
int j = 0; j < vertices.
Size(); j++)
1147 if (vertices[j] == v_idx)
1157 loc_mass.Mult(vals, loc_mass_vals);
1158 integral += loc_mass_vals.
Sum();
1168 if (delta_c == NULL)
1173 for (
int i = 0; i <
fes->
GetNE(); i++)
1187 (*this) *= (delta_c->
Scale() / integral);
1198 for (
int i = 0; i < dofs.
Size(); i++)
1211 (*this)(vdof) = coeff.
Eval(*T, ip);
1239 for (
int i = 0; i < dofs.
Size(); i++)
1251 vcoeff.
Eval(val, *T, ip);
1255 (*this)(vdof) = val(vd);
1262 int i, j, fdof, d, ind, vdim;
1276 for (j = 0; j < fdof; j++)
1280 for (d = 0; d < vdim; d++)
1282 val = coeff[d]->
Eval(*transf, ip);
1283 if ( (ind = vdofs[fdof*d+j]) < 0 )
1285 val = -val, ind = -1-ind;
1304 for (
int i = 0; i <
fes->
GetNE(); i++)
1313 for (
int j = 0; j < vdofs.
Size(); j++)
1315 if (attr > dof_attr[vdofs[j]])
1317 (*this)(vdofs[j]) = vals[j];
1318 dof_attr[vdofs[j]] = attr;
1333 int i, j, fdof, d, ind, vdim;
1350 for (j = 0; j < fdof; j++)
1354 for (d = 0; d < vdim; d++)
1356 val = coeff[d]->
Eval(*transf, ip);
1357 if ( (ind = vdofs[fdof*d+j]) < 0 )
1359 val = -val, ind = -1-ind;
1385 for (i = 0; i < bdr_edges.
Size(); i++)
1387 int edge = bdr_edges[i];
1389 if (vdofs.
Size() == 0) {
continue; }
1395 for (d = 0; d < vdim; d++)
1397 fe->
Project(*coeff[d], *transf, vals);
1398 for (
int k = 0; k < vals.
Size(); k++)
1400 (*this)(vdofs[d*vals.
Size()+k]) = vals(k);
1417 Vector vc(dim), nor(dim), lvec, shape;
1437 vcoeff.
Eval(vc, *T, ip);
1440 lvec.
Add(ip.
weight * (vc * nor), shape);
1452 Vector vc(dim), nor(dim), lvec;
1468 vcoeff.
Eval(vc, *T, ip);
1470 lvec(j) = (vc * nor);
1496 fe->
Project(vcoeff, *T, lvec);
1507 for (
int i = 0; i < bdr_edges.
Size(); i++)
1509 int edge = bdr_edges[i];
1511 if (dofs.
Size() == 0) {
continue; }
1517 fe->
Project(vcoeff, *T, lvec);
1526 double error = 0.0, a;
1531 int fdof, d, i, intorder, j, k;
1557 for (k = 0; k < fdof; k++)
1558 if (vdofs[fdof*d+k] >= 0)
1560 a += (*this)(vdofs[fdof*d+k]) * shape(k);
1564 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
1567 a -= exsol[d]->
Eval(*transf, ip);
1575 return -sqrt(-error);
1590 for (
int i = 0; i <
fes->
GetNE(); i++)
1592 if (elems != NULL && (*elems)[i] == 0) {
continue; }
1594 int intorder = 2*fe->
GetOrder() + 1;
1606 exsol.
Eval(exact_vals, *T, *ir);
1609 vals.
Norm2(loc_errs);
1614 error += ip.
weight * T->
Weight() * (loc_errs(j) * loc_errs(j));
1620 return -sqrt(-error);
1627 Coefficient *ell_coeff,
double Nu,
int norm_type)
const
1630 int i, fdof,
dim, intorder, j, k;
1635 Vector e_grad, a_grad, shape, el_dofs, err_val, ell_coeff_val;
1648 for (i = 0; i < mesh->
GetNE(); i++)
1659 for (k = 0; k < fdof; k++)
1662 el_dofs(k) = (*this)(vdofs[k]);
1666 el_dofs(k) = - (*this)(-1-vdofs[k]);
1673 exgrad->
Eval(e_grad, *transf, ip);
1675 Mult(dshape, Jinv, dshapet);
1679 ell_coeff->
Eval(*transf, ip) *
1688 int i1 = face_elem_transf->
Elem1No;
1689 int i2 = face_elem_transf->
Elem2No;
1696 intorder = 2 * intorder;
1702 transf = face_elem_transf->
Elem1;
1708 for (k = 0; k < fdof; k++)
1711 el_dofs(k) = (*this)(vdofs[k]);
1715 el_dofs(k) = - (*this)(-1-vdofs[k]);
1722 ell_coeff_val(j) = ell_coeff->
Eval(*transf, eip);
1723 err_val(j) = exsol->
Eval(*transf, eip) - (shape * el_dofs);
1729 transf = face_elem_transf->
Elem2;
1735 for (k = 0; k < fdof; k++)
1738 el_dofs(k) = (*this)(vdofs[k]);
1742 el_dofs(k) = - (*this)(-1-vdofs[k]);
1749 ell_coeff_val(j) += ell_coeff->
Eval(*transf, eip);
1750 ell_coeff_val(j) *= 0.5;
1751 err_val(j) -= (exsol->
Eval(*transf, eip) - (shape * el_dofs));
1755 transf = face_elem_transf->
Face;
1760 error += (ip.
weight * Nu * ell_coeff_val(j) *
1761 pow(transf->
Weight(), 1.0-1.0/(dim-1)) *
1762 err_val(j) * err_val(j));
1768 return -sqrt(-error);
1776 double error = 0.0, a;
1781 int fdof, d, i, intorder, j, k;
1808 for (k = 0; k < fdof; k++)
1809 if (vdofs[fdof*d+k] >= 0)
1811 a += (*this)(vdofs[fdof*d+k]) * shape(k);
1815 a -= (*this)(-1-vdofs[fdof*d+k]) * shape(k);
1817 a -= exsol[d]->
Eval(*transf, ip);
1835 int i, fdof,
dim, intorder, j, k;
1839 Vector e_grad, a_grad, shape, el_dofs, err_val, ell_coeff_val;
1842 double a, error = 0.0;
1851 for (i = 0; i < mesh->
GetNE(); i++)
1853 if (elems != NULL && (*elems)[i] == 0) {
continue; }
1870 for (k = 0; k < fdof; k++)
1873 el_dofs(k) = (*this)(vdofs[k]);
1877 el_dofs(k) = -(*this)(-1-vdofs[k]);
1884 a = (el_dofs * shape) - (exsol->
Eval(*transf, ip));
1890 for (i = 0; i < mesh->
GetNE(); i++)
1892 if (elems != NULL && (*elems)[i] == 0) {
continue; }
1910 for (k = 0; k < fdof; k++)
1913 el_dofs(k) = (*this)(vdofs[k]);
1917 el_dofs(k) = -(*this)(-1-vdofs[k]);
1924 exgrad->
Eval(e_grad, *transf, ip);
1926 Mult(dshape, Jinv, dshapet);
1945 for (
int i = 0; i <
fes->
GetNE(); i++)
1955 int intorder = 2*fe->
GetOrder() + 1;
1964 double err = fabs(vals(j) - exsol.
Eval(*T, ip));
1965 if (p < numeric_limits<double>::infinity())
1970 err *= weight->
Eval(*T, ip);
1978 err *= weight->
Eval(*T, ip);
1980 error = std::max(error, err);
1985 if (p < numeric_limits<double>::infinity())
1990 error = -pow(-error, 1./p);
1994 error = pow(error, 1./p);
2012 for (
int i = 0; i <
fes->
GetNE(); i++)
2022 int intorder = 2*fe->
GetOrder() + 1;
2027 exsol.
Eval(exact_vals, *T, *ir);
2034 vals.
Norm2(loc_errs);
2038 v_weight->
Eval(exact_vals, *T, *ir);
2041 for (
int j = 0; j < vals.
Width(); j++)
2044 for (
int d = 0; d < vals.
Height(); d++)
2046 err += vals(d,j)*exact_vals(d,j);
2048 loc_errs(j) = fabs(err);
2055 double err = loc_errs(j);
2056 if (p < numeric_limits<double>::infinity())
2061 err *= weight->
Eval(*T, ip);
2069 err *= weight->
Eval(*T, ip);
2071 error = std::max(error, err);
2076 if (p < numeric_limits<double>::infinity())
2081 error = -pow(-error, 1./p);
2085 error = pow(error, 1./p);
2094 for (
int i = 0; i <
size; i++)
2104 for (
int i = 0; i <
size; i++)
2143 out <<
"SCALARS " << field_name <<
" double 1\n"
2144 <<
"LOOKUP_TABLE default\n";
2145 for (
int i = 0; i < mesh->
GetNE(); i++)
2152 for (
int j = 0; j < val.
Size(); j++)
2154 out << val(j) <<
'\n';
2161 out <<
"VECTORS " << field_name <<
" double\n";
2162 for (
int i = 0; i < mesh->
GetNE(); i++)
2169 for (
int j = 0; j < vval.
Width(); j++)
2171 out << vval(0, j) <<
' ' << vval(1, j) <<
' ';
2187 for (
int vd = 0; vd < vec_dim; vd++)
2189 out <<
"SCALARS " << field_name << vd <<
" double 1\n"
2190 <<
"LOOKUP_TABLE default\n";
2191 for (
int i = 0; i < mesh->
GetNE(); i++)
2198 for (
int j = 0; j < val.
Size(); j++)
2200 out << val(j) <<
'\n';
2211 double v1[3] = { p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] };
2212 double v2[3] = { p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2] };
2213 double n[] = { v1[1] * v2[2] - v1[2] * v2[1],
2214 v1[2] * v2[0] - v1[0] * v2[2],
2215 v1[0] * v2[1] - v1[1] * v2[0]
2217 double rl = 1.0 / sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);
2218 n[0] *= rl; n[1] *= rl; n[2] *= rl;
2220 out <<
" facet normal " << n[0] <<
' ' << n[1] <<
' ' << n[2]
2222 <<
"\n vertex " << p1[0] <<
' ' << p1[1] <<
' ' << p1[2]
2223 <<
"\n vertex " << p2[0] <<
' ' << p2[1] <<
' ' << p2[2]
2224 <<
"\n vertex " << p3[0] <<
' ' << p3[1] <<
' ' << p3[2]
2225 <<
"\n endloop\n endfacet\n";
2241 double pts[4][3], bbox[3][2];
2243 out <<
"solid GridFunction\n";
2245 bbox[0][0] = bbox[0][1] = bbox[1][0] = bbox[1][1] =
2246 bbox[2][0] = bbox[2][1] = 0.0;
2247 for (i = 0; i < mesh->
GetNE(); i++)
2254 for (k = 0; k < RG.
Size()/n; k++)
2256 for (j = 0; j < n; j++)
2259 pts[j][0] = pointmat(0,l);
2260 pts[j][1] = pointmat(1,l);
2261 pts[j][2] = values(l);
2277 bbox[0][0] = pointmat(0,0);
2278 bbox[0][1] = pointmat(0,0);
2279 bbox[1][0] = pointmat(1,0);
2280 bbox[1][1] = pointmat(1,0);
2281 bbox[2][0] = values(0);
2282 bbox[2][1] = values(0);
2285 for (j = 0; j < values.
Size(); j++)
2287 if (bbox[0][0] > pointmat(0,j))
2289 bbox[0][0] = pointmat(0,j);
2291 if (bbox[0][1] < pointmat(0,j))
2293 bbox[0][1] = pointmat(0,j);
2295 if (bbox[1][0] > pointmat(1,j))
2297 bbox[1][0] = pointmat(1,j);
2299 if (bbox[1][1] < pointmat(1,j))
2301 bbox[1][1] = pointmat(1,j);
2303 if (bbox[2][0] > values(j))
2305 bbox[2][0] = values(j);
2307 if (bbox[2][1] < values(j))
2309 bbox[2][1] = values(j);
2314 cout <<
"[xmin,xmax] = [" << bbox[0][0] <<
',' << bbox[0][1] <<
"]\n"
2315 <<
"[ymin,ymax] = [" << bbox[1][0] <<
',' << bbox[1][1] <<
"]\n"
2316 <<
"[zmin,zmax] = [" << bbox[2][0] <<
',' << bbox[2][1] <<
']'
2319 out <<
"endsolid GridFunction" << endl;
2334 int with_subdomains)
2336 const int with_coeff = 0;
2342 int nfe = ufes->
GetNE();
2346 Vector ul, fl, fla, d_xyz;
2356 if (with_subdomains)
2358 for (
int i = 0; i < nfe; i++)
2361 if (attr > nsd) { nsd = attr; }
2365 double total_error = 0.0;
2366 for (
int s = 1; s <= nsd; s++)
2369 u.
ComputeFlux(blfi, flux, with_coeff, (with_subdomains ? s : -1));
2371 for (
int i = 0; i < nfe; i++)
2373 if (with_subdomains && ufes->
GetAttribute(i) != s) {
continue; }
2383 *ffes->
GetFE(i), fl, with_coeff);
2388 (aniso_flags ? &d_xyz : NULL));
2390 error_estimates(i) = std::sqrt(err);
2396 for (
int k = 0; k <
dim; k++)
2401 double thresh = 0.15 * 3.0/
dim;
2403 for (
int k = 0; k <
dim; k++)
2405 if (d_xyz[k] / sum > thresh) { flag |= (1 << k); }
2408 (*aniso_flags)[i] = flag;
2413 return std::sqrt(total_error);
2436 for (
int j = 0; j < nip; j++)
2445 double err = val1.
Norml2();
2446 if (p < numeric_limits<double>::infinity())
2453 norm = std::max(norm, err);
2457 if (p < numeric_limits<double>::infinity())
2462 norm = -pow(-norm, 1./p);
2466 norm = pow(norm, 1./p);
2480 return sol_in.
Eval(*T_in, ip);
2491 string cname = name;
2492 if (cname ==
"Linear")
2496 else if (cname ==
"Quadratic")
2500 else if (cname ==
"Cubic")
2504 else if (!strncmp(name,
"H1_", 3))
2508 else if (!strncmp(name,
"L2_T", 4))
2512 else if (!strncmp(name,
"L2_", 3))
2518 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.
int GetDim() const
Returns the space dimension for the finite element.
int GetAttribute(int i) const
int GetNDofs() const
Returns number of degrees of freedom.
Class for integration rule.
const double * GetVertex(int i) const
Return pointer to vertex i's coordinates.
void NewDataAndSize(double *d, int s)
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
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 MakeRef(FiniteElementSpace *f, Vector &v, int v_offset)
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 if the new size is different.
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'.
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)
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
void StealData(double **p)
Changes the ownership of the data; after the call the Vector is empty.
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.
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
IntegrationRules IntRules(0)
A global object with all integration rules (defined in intrules.cpp)
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
void Norm2(double *v) const
Take the 2-norm of the columns of A and store in v.
virtual void GetElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
const IntegrationRule & GetNodes() const
GeometryRefiner GlobGeometryRefiner
ElementTransformation * GetBdrElementTransformation(int i) const
Returns ElementTransformation for the i'th boundary element.
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 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:
int GetLocalDofForDof(int i)
int SpaceDimension() const
int GetElementForDof(int i)
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 degrees of freedom in the FE space.
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)
void SetSize(int nsize)
Change logical size of the array, keep existing entries.
void SetSubVector(const Array< int > &dofs, const Vector &elemvect)
void GetColumnReference(int c, Vector &col)
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &divshape) const
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)
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
virtual void CalcCurlShape(const IntegrationPoint &ip, DenseMatrix &curl_shape) const
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.
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.
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)
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 CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const =0
void Save(std::ostream &out) const
double Sum() const
Return the sum of the vector entries.
void GetValuesFrom(GridFunction &)
static void AdjustVDofs(Array< int > &vdofs)
virtual void ProjectDelta(int vertex, Vector &dofs) const
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
Arbitrary order "L2-conforming" discontinuous finite elements.
void ProjectVectorFieldOn(GridFunction &vec_field, int comp=0)
void DofsToVDofs(Array< int > &dofs, int ndofs=-1) const