62 for (
int i = 0; i < mesh->
GetNE(); i++)
73 else if (fieldtype == 1)
85 for (
int i = 0; i < mesh->
GetNE(); i++)
96 const auto *feInt = fecInt->
GetFE(geom, max_order);
102 I.
Mult(elemvect, vectInt);
117 for (
int d = 0; d <
dim; d++) { res += std::pow(x(d),
func_order); }
124 for (
int i = 1; i < F.
Size(); i++) { F(i) = (i+1)*F(0); }
127 int main (
int argc,
char *argv[])
130 const char *mesh_file =
"../../data/rt-2d-q3.mesh";
132 int mesh_poly_deg = 3;
134 bool visualization =
true;
137 bool hrefinement =
false;
138 bool prefinement =
false;
139 int point_ordering = 0;
144 args.
AddOption(&mesh_file,
"-m",
"--mesh",
145 "Mesh file to use.");
147 "Finite element order (polynomial degree).");
148 args.
AddOption(&mesh_poly_deg,
"-mo",
"--mesh-order",
149 "Polynomial degree of mesh finite element space.");
150 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
151 "Number of times to refine the mesh uniformly in serial.");
152 args.
AddOption(&fieldtype,
"-ft",
"--field-type",
153 "Field type: 0 - H1, 1 - L2, 2 - H(div), 3 - H(curl).");
155 "Number of components for H1 or L2 GridFunctions");
156 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
157 "--no-visualization",
158 "Enable or disable GLVis visualization.");
159 args.
AddOption(&hrefinement,
"-hr",
"--h-refinement",
"-no-hr",
161 "Do random h refinements to mesh (does not work for pyramids).");
162 args.
AddOption(&prefinement,
"-pr",
"--p-refinement",
"-no-pr",
164 "Do random p refinements to solution field (does not work for pyramids).");
165 args.
AddOption(&point_ordering,
"-po",
"--point-ordering",
166 "Ordering of points to be found."
167 "0 (default): byNodes, 1: byVDIM");
168 args.
AddOption(&gf_ordering,
"-fo",
"--fespace-ordering",
169 "Ordering of fespace that will be used for gridfunction to be interpolated."
170 "0 (default): byNodes, 1: byVDIM");
183 Mesh mesh(mesh_file, 1, 1,
false);
186 cout <<
"Mesh curvature of the original mesh: ";
188 else { cout <<
"(NONE)"; }
193 MFEM_VERIFY(mesh_poly_deg > 0,
"The order of the mesh must be positive.");
195 if (hrefinement || prefinement) { mesh.
EnsureNCMesh(); }
196 cout <<
"--- Generating equidistant point for:\n"
197 <<
"x in [" << pos_min(0) <<
", " << pos_max(0) <<
"]\n"
198 <<
"y in [" << pos_min(1) <<
", " << pos_max(1) <<
"]\n";
201 cout <<
"z in [" << pos_min(2) <<
", " << pos_max(2) <<
"]\n";
211 cout <<
"Mesh curvature of the curved mesh: " << fecm.
Name() << endl;
213 MFEM_VERIFY(ncomp > 0,
"Invalid number of components.");
219 cout <<
"H1-GridFunction\n";
221 else if (fieldtype == 1)
224 cout <<
"L2-GridFunction\n";
226 else if (fieldtype == 2)
231 cout <<
"H(div)-GridFunction\n";
233 else if (fieldtype == 3)
238 cout <<
"H(curl)-GridFunction\n";
242 MFEM_ABORT(
"Invalid field type.");
250 for (
int e = 0; e < mesh.
GetNE(); e++)
276 sout.
open(vishost, visport);
279 cout <<
"Unable to connect to GLVis server at "
280 << vishost <<
':' << visport << endl;
285 sout <<
"solution\n" << mesh << *field_vals_pref;
286 if (dim == 2) { sout <<
"keys RmjA*****\n"; }
287 if (dim == 3) { sout <<
"keys mA\n"; }
295 const int pts_cnt_1D = 25;
296 int pts_cnt = pow(pts_cnt_1D, dim);
297 Vector vxyz(pts_cnt * dim);
307 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
308 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
312 vxyz(i*dim + 0) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
313 vxyz(i*dim + 1) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
326 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
327 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
328 vxyz(2*pts_cnt + i) = pos_min(2) + ip.
z * (pos_max(2)-pos_min(2));
332 vxyz(i*dim + 0) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
333 vxyz(i*dim + 1) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
334 vxyz(i*dim + 2) = pos_min(2) + ip.
z * (pos_max(2)-pos_min(2));
340 Vector interp_vals(pts_cnt*vec_dim);
344 finder.
Interpolate(vxyz, field_vals, interp_vals, point_ordering);
348 int face_pts = 0, not_found = 0, found = 0;
349 double err = 0.0, max_err = 0.0, max_dist = 0.0;
352 for (
int j = 0; j < vec_dim; j++)
354 for (
int i = 0; i < pts_cnt; i++)
358 if (j == 0) { found++; }
359 for (
int d = 0; d <
dim; d++)
362 vxyz(d*pts_cnt + i) :
365 Vector exact_val(vec_dim);
368 fabs(exact_val(j) - interp_vals[i + j*pts_cnt]) :
369 fabs(exact_val(j) - interp_vals[i*vec_dim + j]);
370 max_err = std::max(max_err, err);
371 max_dist = std::max(max_dist, dist_p_out(i));
372 if (code_out[i] == 1 && j == 0) { face_pts++; }
374 else {
if (j == 0) { not_found++; } }
379 cout << setprecision(16)
380 <<
"Searched points: " << pts_cnt
381 <<
"\nFound points: " << found
382 <<
"\nMax interp error: " << max_err
383 <<
"\nMax dist (of found): " << max_dist
384 <<
"\nPoints not found: " << not_found
385 <<
"\nPoints on faces: " << face_pts << endl;
390 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
virtual 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.
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...
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
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.
Nodes: x_i = i/(n-1), i=0,...,n-1.
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
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.