49 for (
int d = 0; d <
dim; d++) { res += x(d) * x(d); }
56 for (
int i = 1; i < F.
Size(); i++) { F(i) = (i+1)*F(0); }
59 int main (
int argc,
char *argv[])
62 const char *mesh_file =
"../../data/rt-2d-q3.mesh";
64 int mesh_poly_deg = 3;
66 bool visualization =
true;
72 args.
AddOption(&mesh_file,
"-m",
"--mesh",
75 "Finite element order (polynomial degree).");
76 args.
AddOption(&mesh_poly_deg,
"-mo",
"--mesh-order",
77 "Polynomial degree of mesh finite element space.");
78 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
79 "Number of times to refine the mesh uniformly in serial.");
80 args.
AddOption(&fieldtype,
"-ft",
"--field-type",
81 "Field type: 0 - H1, 1 - L2, 2 - H(div), 3 - H(curl).");
83 "Number of components for H1 or L2 GridFunctions");
84 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
86 "Enable or disable GLVis visualization.");
96 Mesh mesh(mesh_file, 1, 1,
false);
99 cout <<
"Mesh curvature of the original mesh: ";
101 else { cout <<
"(NONE)"; }
106 MFEM_VERIFY(mesh_poly_deg > 0,
"The order of the mesh must be positive.");
108 cout <<
"--- Generating equidistant point for:\n"
109 <<
"x in [" << pos_min(0) <<
", " << pos_max(0) <<
"]\n"
110 <<
"y in [" << pos_min(1) <<
", " << pos_max(1) <<
"]\n";
113 cout <<
"z in [" << pos_min(2) <<
", " << pos_max(2) <<
"]\n";
120 cout <<
"Mesh curvature of the curved mesh: " << fecm.
Name() << endl;
122 MFEM_VERIFY(ncomp > 0,
"Invalid number of components.");
128 cout <<
"H1-GridFunction\n";
130 else if (fieldtype == 1)
133 cout <<
"L2-GridFunction\n";
135 else if (fieldtype == 2)
140 cout <<
"H(div)-GridFunction\n";
142 else if (fieldtype == 3)
147 cout <<
"H(curl)-GridFunction\n";
151 MFEM_ABORT(
"Invalid field type.");
166 sout.
open(vishost, visport);
169 cout <<
"Unable to connect to GLVis server at "
170 << vishost <<
':' << visport << endl;
175 sout <<
"solution\n" << mesh << field_vals;
176 if (dim == 2) { sout <<
"keys RmjA*****\n"; }
177 if (dim == 3) { sout <<
"keys mA\n"; }
185 const int pts_cnt_1D = 25;
186 int pts_cnt = pow(pts_cnt_1D, dim);
187 Vector vxyz(pts_cnt * dim);
195 vxyz(i) = 100*pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
196 vxyz(pts_cnt + i) = 100*pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
206 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
207 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
208 vxyz(2*pts_cnt + i) = pos_min(2) + ip.
z * (pos_max(2)-pos_min(2));
213 Vector interp_vals(pts_cnt*vec_dim);
221 int face_pts = 0, not_found = 0, found = 0;
222 double max_err = 0.0, max_dist = 0.0;
225 for (
int j = 0; j < vec_dim; j++)
227 for (
int i = 0; i < pts_cnt; i++)
231 if (j == 0) { found++; }
232 for (
int d = 0; d <
dim; d++) { pos(d) = vxyz(d * pts_cnt + i); }
233 Vector exact_val(vec_dim);
235 max_err = std::max(max_err, fabs(exact_val(j) - interp_vals[npt]));
236 max_dist = std::max(max_dist, dist_p_out(i));
237 if (code_out[i] == 1 && j == 0) { face_pts++; }
239 else {
if (j == 0) { not_found++; } }
244 cout << setprecision(16)
245 <<
"Searched points: " << pts_cnt
246 <<
"\nFound points: " << found
247 <<
"\nMax interp error: " << max_err
248 <<
"\nMax dist (of found): " << max_dist
249 <<
"\nPoints not found: " << not_found
250 <<
"\nPoints on faces: " << face_pts << endl;
int GetNPoints() const
Returns the number of the points in the integration rule.
void Interpolate(const GridFunction &field_in, Vector &field_out)
Class for an integration rule - an Array of IntegrationPoint.
Class for grid function - Vector with associated FE space.
const Vector & GetDist() const
void SetL2AvgType(AvgType avgtype_)
Arbitrary order L2 elements in 3D on a cube.
void GetBoundingBox(Vector &min, Vector &max, int ref=2)
Returns the minimum and maximum corners of the mesh bounding box.
int Size() const
Returns the size of the vector.
const Array< unsigned int > & GetCode() const
int main(int argc, char *argv[])
Nodes: x_i = i/(n-1), i=0,...,n-1.
double field_func(const Vector &x)
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 UniformRefinement(int i, const DSTable &, int *, int *, int *)
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.
virtual const char * Name() const
void SetNodalFESpace(FiniteElementSpace *nfes)
void PrintUsage(std::ostream &out) const
Print the usage message.
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...
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...
Class for integration point with weight.
Arbitrary order L2 elements in 2D on a square.
void PrintOptions(std::ostream &out) const
Print the options.
virtual void ProjectCoefficient(Coefficient &coeff)
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...
void GetNodes(Vector &node_coord) const
Arbitrary order H1-conforming (continuous) finite elements.
Arbitrary order "L2-conforming" discontinuous finite elements.
bool Good() const
Return true if the command line options were parsed successfully.