56 const char *title,
int locx)
63 for (
int e = 0; e < mesh->
GetNE(); e++)
70 locx, 0, 400, 400,
"RjmAcp");
80 for (
int d = 0; d <
dim; d++) { res += std::pow(x(d),
func_order); }
87 for (
int i = 1; i < F.
Size(); i++) { F(i) = (i+1)*F(0); }
90int main (
int argc,
char *argv[])
93 const char *mesh_file =
"../../data/rt-2d-q3.mesh";
95 int mesh_poly_deg = 3;
97 bool visualization =
true;
100 bool hrefinement =
false;
101 bool prefinement =
false;
102 int point_ordering = 0;
104 bool mesh_prefinement =
false;
108 args.
AddOption(&mesh_file,
"-m",
"--mesh",
109 "Mesh file to use.");
111 "Finite element order (polynomial degree).");
112 args.
AddOption(&mesh_poly_deg,
"-mo",
"--mesh-order",
113 "Polynomial degree of mesh finite element space.");
114 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
115 "Number of times to refine the mesh uniformly in serial.");
116 args.
AddOption(&fieldtype,
"-ft",
"--field-type",
117 "Field type: 0 - H1, 1 - L2, 2 - H(div), 3 - H(curl).");
119 "Number of components for H1 or L2 GridFunctions");
120 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
121 "--no-visualization",
122 "Enable or disable GLVis visualization.");
123 args.
AddOption(&hrefinement,
"-hr",
"--h-refinement",
"-no-hr",
125 "Do random h refinements to mesh (does not work for pyramids).");
126 args.
AddOption(&prefinement,
"-pr",
"--p-refinement",
"-no-pr",
128 "Do random p refinements to solution field (does not work for pyramids).");
129 args.
AddOption(&point_ordering,
"-po",
"--point-ordering",
130 "Ordering of points to be found."
131 "0 (default): byNodes, 1: byVDIM");
132 args.
AddOption(&gf_ordering,
"-fo",
"--fespace-ordering",
133 "Ordering of fespace that will be used for grid function to be interpolated."
134 "0 (default): byNodes, 1: byVDIM");
135 args.
AddOption(&mesh_prefinement,
"-mpr",
"--mesh-p-refinement",
"-no-mpr",
136 "--no-mesh-p-refinement",
137 "Do random p refinements to mesh Nodes.");
150 Mesh mesh(mesh_file, 1, 1,
false);
153 cout <<
"Mesh curvature of the original mesh: ";
155 else { cout <<
"(NONE)"; }
160 MFEM_VERIFY(mesh_poly_deg > 0,
"The order of the mesh must be positive.");
162 if (hrefinement || prefinement || mesh_prefinement) { mesh.
EnsureNCMesh(
true); }
163 cout <<
"--- Generating equidistant point for:\n"
164 <<
"x in [" << pos_min(0) <<
", " << pos_max(0) <<
"]\n"
165 <<
"y in [" << pos_min(1) <<
", " << pos_max(1) <<
"]\n";
168 cout <<
"z in [" << pos_min(2) <<
", " << pos_max(2) <<
"]\n";
180 cout <<
"Mesh curvature of the curved mesh: " << fecm.
Name() << endl;
182 if (mesh_prefinement)
185 for (
int e = 0; e < mesh.
GetNE(); e++)
187 if ((
double) rand() / RAND_MAX < 0.2)
196 MFEM_VERIFY(ncomp > 0,
"Invalid number of components.");
202 cout <<
"H1-GridFunction\n";
204 else if (fieldtype == 1)
207 cout <<
"L2-GridFunction\n";
209 else if (fieldtype == 2)
214 cout <<
"H(div)-GridFunction\n";
216 else if (fieldtype == 3)
221 cout <<
"H(curl)-GridFunction\n";
225 MFEM_ABORT(
"Invalid field type.");
234 for (
int e = 0; e < mesh.
GetNE(); e++)
236 if ((
double) rand() / RAND_MAX < 0.5)
245 std::unique_ptr<GridFunction> mesh_nodes_max;
248 mesh_nodes_max.get() : &Nodes;
250 if (mesh_prefinement && visualization)
257 if (prefinement && visualization)
268 std::unique_ptr<GridFunction> field_vals_max;
271 field_vals_max.get() : &field_vals;
280 0, 0, 400, 400,
"RmjA*****");
287 const int pts_cnt_1D = 25;
288 int pts_cnt = pow(pts_cnt_1D,
dim);
299 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
300 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
304 vxyz(i*
dim + 0) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
305 vxyz(i*
dim + 1) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
318 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
319 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
320 vxyz(2*pts_cnt + i) = pos_min(2) + ip.
z * (pos_max(2)-pos_min(2));
324 vxyz(i*
dim + 0) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
325 vxyz(i*
dim + 1) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
326 vxyz(i*
dim + 2) = pos_min(2) + ip.
z * (pos_max(2)-pos_min(2));
332 Vector interp_vals(pts_cnt*vec_dim);
336 finder.
Interpolate(vxyz, field_vals, interp_vals, point_ordering);
340 int face_pts = 0, not_found = 0, found = 0;
341 double error = 0.0, max_err = 0.0, max_dist = 0.0;
343 for (
int j = 0; j < vec_dim; j++)
345 for (
int i = 0; i < pts_cnt; i++)
349 if (j == 0) { found++; }
350 for (
int d = 0; d <
dim; d++)
353 vxyz(d*pts_cnt + i) :
356 Vector exact_val(vec_dim);
359 fabs(exact_val(j) - interp_vals[i + j*pts_cnt]) :
360 fabs(exact_val(j) - interp_vals[i*vec_dim + j]);
361 max_err = std::max(max_err, error);
362 max_dist = std::max(max_dist, dist_p_out(i));
363 if (code_out[i] == 1 && j == 0) { face_pts++; }
365 else {
if (j == 0) { not_found++; } }
369 cout << setprecision(16)
370 <<
"Searched points: " << pts_cnt
371 <<
"\nFound points: " << found
372 <<
"\nMax interp error: " << max_err
373 <<
"\nMax dist (of found): " << max_dist
374 <<
"\nPoints not found: " << not_found
375 <<
"\nPoints on faces: " << face_pts << endl;
int Append(const T &el)
Append element 'el' to array, resize if necessary.
@ ClosedUniform
Nodes: x_i = i/(n-1), i=0,...,n-1.
FindPointsGSLIB can robustly evaluate a GridFunction on an arbitrary collection of points.
virtual const Vector & GetDist() const
void Setup(Mesh &m, const double bb_t=0.1, const double newt_tol=1.0e-12, const int npt_max=256)
virtual void Interpolate(const GridFunction &field_in, Vector &field_out)
virtual const Array< unsigned int > & GetCode() const
virtual void SetL2AvgType(AvgType avgtype_)
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int GetElementOrder(int i) const
Returns the order of the i'th finite element.
Mesh * GetMesh() const
Returns the mesh.
virtual void PRefineAndUpdate(const Array< pRefinement > &refs, bool want_transfer=true)
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
Class for grid function - Vector with associated FE space.
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
std::unique_ptr< GridFunction > ProlongateToMaxOrder() const
Return a GridFunction with the values of this, prolongated to the maximum order of all elements in th...
Arbitrary order H1-conforming (continuous) finite elements.
const char * Name() const override
Class for integration point with weight.
Class for an integration rule - an Array of IntegrationPoint.
int GetNPoints() const
Returns the number of the points in the integration rule.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
Arbitrary order "L2-conforming" discontinuous finite elements.
Arbitrary order L2 elements in 3D on a cube.
Arbitrary order L2 elements in 2D on a square.
int GetNE() const
Returns number of elements.
void GetBoundingBox(Vector &min, Vector &max, int ref=2)
Returns the minimum and maximum corners of the mesh bounding box.
int Dimension() const
Dimension of the reference space used within the elements.
void RandomRefinement(real_t prob, bool aniso=false, int nonconforming=-1, int nc_limit=0)
Refine each element with given probability. Uses GeneralRefinement.
void SetNodalGridFunction(GridFunction *nodes, bool make_owner=false)
void GetNodes(Vector &node_coord) const
virtual void SetNodalFESpace(FiniteElementSpace *nfes)
void EnsureNCMesh(bool simplices_nonconforming=false)
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Arbitrary order H(curl)-conforming Nedelec finite elements.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
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...
bool Good() const
Return true if the command line options were parsed successfully.
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
A general vector function coefficient.
int Size() const
Returns the size of the vector.
double field_func(const Vector &x)
void F_exact(const Vector &p, Vector &F)
void VisualizeFESpacePolynomialOrder(FiniteElementSpace &fespace, const char *title, int locx)
void VisualizeField(socketstream &sock, const char *vishost, int visport, GridFunction &gf, const char *title, int x, int y, int w, int h, const char *keys, bool vec)
real_t p(const Vector &x, real_t t)