54 for (
int i = 0; i < mesh->
GetNE(); i++)
65 else if (fieldtype == 1)
77 for (
int i = 0; i < mesh->
GetNE(); i++)
88 const auto *feInt = fecInt->
GetFE(geom, max_order);
94 I.
Mult(elemvect, vectInt);
107 for (
int d = 0; d <
dim; d++) { res += x(d) * x(d); }
114 for (
int i = 1; i < F.
Size(); i++) { F(i) = (i+1)*F(0); }
117 int main (
int argc,
char *argv[])
120 const char *mesh_file =
"../../data/rt-2d-q3.mesh";
122 int mesh_poly_deg = 3;
124 bool visualization =
true;
127 bool hrefinement =
false;
128 bool prefinement =
false;
132 args.
AddOption(&mesh_file,
"-m",
"--mesh",
133 "Mesh file to use.");
135 "Finite element order (polynomial degree).");
136 args.
AddOption(&mesh_poly_deg,
"-mo",
"--mesh-order",
137 "Polynomial degree of mesh finite element space.");
138 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
139 "Number of times to refine the mesh uniformly in serial.");
140 args.
AddOption(&fieldtype,
"-ft",
"--field-type",
141 "Field type: 0 - H1, 1 - L2, 2 - H(div), 3 - H(curl).");
143 "Number of components for H1 or L2 GridFunctions");
144 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
145 "--no-visualization",
146 "Enable or disable GLVis visualization.");
147 args.
AddOption(&hrefinement,
"-hr",
"--h-refinement",
"-no-hr",
149 "Do random h refinements to mesh.");
150 args.
AddOption(&prefinement,
"-pr",
"--p-refinement",
"-no-pr",
152 "Do random p refinements to solution field.");
163 Mesh mesh(mesh_file, 1, 1,
false);
166 cout <<
"Mesh curvature of the original mesh: ";
168 else { cout <<
"(NONE)"; }
173 MFEM_VERIFY(mesh_poly_deg > 0,
"The order of the mesh must be positive.");
175 if (hrefinement || prefinement) { mesh.
EnsureNCMesh(); }
176 cout <<
"--- Generating equidistant point for:\n"
177 <<
"x in [" << pos_min(0) <<
", " << pos_max(0) <<
"]\n"
178 <<
"y in [" << pos_min(1) <<
", " << pos_max(1) <<
"]\n";
181 cout <<
"z in [" << pos_min(2) <<
", " << pos_max(2) <<
"]\n";
191 cout <<
"Mesh curvature of the curved mesh: " << fecm.
Name() << endl;
193 MFEM_VERIFY(ncomp > 0,
"Invalid number of components.");
199 cout <<
"H1-GridFunction\n";
201 else if (fieldtype == 1)
204 cout <<
"L2-GridFunction\n";
206 else if (fieldtype == 2)
211 cout <<
"H(div)-GridFunction\n";
213 else if (fieldtype == 3)
218 cout <<
"H(curl)-GridFunction\n";
222 MFEM_ABORT(
"Invalid field type.");
230 for (
int e = 0; e < mesh.
GetNE(); e++)
256 sout.
open(vishost, visport);
259 cout <<
"Unable to connect to GLVis server at "
260 << vishost <<
':' << visport << endl;
265 sout <<
"solution\n" << mesh << *field_vals_pref;
266 if (dim == 2) { sout <<
"keys RmjA*****\n"; }
267 if (dim == 3) { sout <<
"keys mA\n"; }
275 const int pts_cnt_1D = 25;
276 int pts_cnt =
pow(pts_cnt_1D, dim);
277 Vector vxyz(pts_cnt * dim);
285 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
286 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
296 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
297 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
298 vxyz(2*pts_cnt + i) = pos_min(2) + ip.
z * (pos_max(2)-pos_min(2));
303 Vector interp_vals(pts_cnt*vec_dim);
311 int face_pts = 0, not_found = 0, found = 0;
312 double max_err = 0.0, max_dist = 0.0;
315 for (
int j = 0; j < vec_dim; j++)
317 for (
int i = 0; i < pts_cnt; i++)
321 if (j == 0) { found++; }
322 for (
int d = 0; d <
dim; d++) { pos(d) = vxyz(d * pts_cnt + i); }
323 Vector exact_val(vec_dim);
325 max_err = std::max(max_err, fabs(exact_val(j) - interp_vals[npt]));
326 max_dist = std::max(max_dist, dist_p_out(i));
327 if (code_out[i] == 1 && j == 0) { face_pts++; }
329 else {
if (j == 0) { not_found++; } }
334 cout << setprecision(16)
335 <<
"Searched points: " << pts_cnt
336 <<
"\nFound points: " << found
337 <<
"\nMax interp error: " << max_err
338 <<
"\nMax dist (of found): " << max_dist
339 <<
"\nPoints not found: " << not_found
340 <<
"\nPoints on faces: " << face_pts << endl;
345 if (prefinement) {
delete field_vals_pref; }
int GetNPoints() const
Returns the number of the points in the integration rule.
virtual void Interpolate(const GridFunction &field_in, Vector &field_out)
int Size() const
Return the logical size of the array.
void SetSubVector(const Array< int > &dofs, const double value)
Set the entries listed in dofs to the given value.
const FiniteElement * GetFE(Geometry::Type geom, int p) const
Variable order version of FiniteElementForGeometry().
Class for an integration rule - an Array of IntegrationPoint.
Class for grid function - Vector with associated FE space.
virtual void Update(bool want_transform=true)
Reflect changes in the mesh: update number of DOFs, etc. Also, calculate GridFunction transformation ...
virtual const Vector & GetDist() const
Arbitrary order L2 elements in 3D on a cube.
void SetSize(int s)
Resize the vector to size s.
void SetElementOrder(int i, int p)
Sets the order of the i'th finite element.
void GetBoundingBox(Vector &min, Vector &max, int ref=2)
Returns the minimum and maximum corners of the mesh bounding box.
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
Data type dense matrix using column-major storage.
int Size() const
Returns the size of the vector.
int GetElementOrder(int i) const
Returns the order of the i'th finite element.
int GetNE() const
Returns number of elements.
void MakeOwner(FiniteElementCollection *fec_)
Make the GridFunction the owner of fec and fes.
double field_func(const Vector &x)
virtual void SetL2AvgType(AvgType avgtype_)
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void EnsureNCMesh(bool simplices_nonconforming=false)
Mesh * GetMesh() const
Returns the mesh.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
GridFunction * ProlongToMaxOrder(const GridFunction *x, const int fieldtype)
void F_exact(const Vector &, Vector &)
void Setup(Mesh &m, const double bb_t=0.1, const double newt_tol=1.0e-12, const int npt_max=256)
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
void RandomRefinement(double prob, bool aniso=false, int nonconforming=-1, int nc_limit=0)
Refine each element with given probability. Uses GeneralRefinement.
virtual const char * Name() const
void SetNodalFESpace(FiniteElementSpace *nfes)
FiniteElementSpace * FESpace()
void PrintUsage(std::ostream &out) const
Print the usage message.
virtual DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'.
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
FDualNumber< tbase > pow(const FDualNumber< tbase > &a, const FDualNumber< tbase > &b)
pow([dual number],[dual number])
A general vector function coefficient.
double p(const Vector &x, double t)
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
Geometry::Type GetElementGeometry(int i) const
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
Class for integration point with weight.
virtual const Array< unsigned int > & GetCode() const
Arbitrary order L2 elements in 2D on a square.
void PrintOptions(std::ostream &out) const
Print the options.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
Arbitrary order H(curl)-conforming Nedelec finite elements.
FindPointsGSLIB can robustly evaluate a GridFunction on an arbitrary collection of points...
const FiniteElementCollection * FEColl() const
void Mult(const double *x, double *y) const
Matrix vector multiplication.
void GetNodes(Vector &node_coord) const
Nodes: x_i = i/(n-1), i=0,...,n-1.
Arbitrary order H1-conforming (continuous) finite elements.
virtual void GetTransferMatrix(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &I) const
Return interpolation matrix, I, which maps dofs from a coarse element, fe, to the fine dofs on this f...
Arbitrary order "L2-conforming" discontinuous finite elements.
bool Good() const
Return true if the command line options were parsed successfully.