43 for (
int d = 0; d <
dim; d++) { res += x(d) * x(d); }
47 int main (
int argc,
char *argv[])
50 const char *mesh_file =
"../../data/rt-2d-q3.mesh";
51 int mesh_poly_deg = 3;
53 bool visualization =
true;
57 args.
AddOption(&mesh_file,
"-m",
"--mesh",
59 args.
AddOption(&mesh_poly_deg,
"-o",
"--mesh-order",
60 "Polynomial degree of mesh finite element space.");
61 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
62 "Number of times to refine the mesh uniformly in serial.");
63 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
65 "Enable or disable GLVis visualization.");
75 Mesh mesh(mesh_file, 1, 1,
false);
78 cout <<
"Mesh curvature of the original mesh: ";
80 else { cout <<
"(NONE)"; }
85 MFEM_VERIFY(mesh_poly_deg > 0,
"The order of the mesh must be positive.");
87 cout <<
"--- Generating equidistant point for:\n"
88 <<
"x in [" << pos_min(0) <<
", " << pos_max(0) <<
"]\n"
89 <<
"y in [" << pos_min(1) <<
", " << pos_max(1) <<
"]\n";
92 cout <<
"z in [" << pos_min(2) <<
", " << pos_max(2) <<
"]\n";
99 cout <<
"Mesh curvature of the curved mesh: " << fec.
Name() << endl;
110 char vishost[] =
"localhost";
113 sout.
open(vishost, visport);
116 cout <<
"Unable to connect to GLVis server at "
117 << vishost <<
':' << visport << endl;
122 sout <<
"solution\n" << mesh << field_vals;
123 if (dim == 2) { sout <<
"keys RmjA*****\n"; }
124 if (dim == 3) { sout <<
"keys mA\n"; }
131 const double rel_bbox_el = 0.05;
132 const double newton_tol = 1.0e-12;
133 const int npts_at_once = 256;
134 finder.
Setup(mesh, rel_bbox_el, newton_tol, npts_at_once);
139 const int pts_cnt_1D = 5;
140 const int pts_cnt = pow(pts_cnt_1D, dim);
141 Vector vxyz(pts_cnt * dim);
149 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
150 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
160 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
161 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
162 vxyz(2*pts_cnt + i) = pos_min(2) + ip.
z * (pos_max(2)-pos_min(2));
167 task_id_out(pts_cnt);
168 Vector pos_r_out(pts_cnt * dim), dist_p_out(pts_cnt);
171 finder.
FindPoints(vxyz, code_out, task_id_out,
172 el_id_out, pos_r_out, dist_p_out);
175 Vector interp_vals(pts_cnt);
176 finder.
Interpolate(code_out, task_id_out, el_id_out,
177 pos_r_out, field_vals, interp_vals);
182 int face_pts = 0, not_found = 0, found = 0;
183 double max_err = 0.0, max_dist = 0.0;
185 for (
int i = 0; i < pts_cnt; i++)
190 for (
int d = 0; d <
dim; d++) { pos(d) = vxyz(d * pts_cnt + i); }
193 max_err = std::max(max_err, fabs(exact_val - interp_vals[i]));
194 max_dist = std::max(max_dist, dist_p_out(i));
195 if (code_out[i] == 1) { face_pts++; }
197 else { not_found++; }
200 cout << setprecision(16)
201 <<
"Searched points: " << pts_cnt
202 <<
"\nFound points: " << found
203 <<
"\nMax interp error: " << max_err
204 <<
"\nMax dist (of found): " << max_dist
205 <<
"\nPoints not found: " << not_found
206 <<
"\nPoints on faces: " << face_pts << endl;
int GetNPoints() const
Returns the number of the points in the integration rule.
void FindPoints(Vector &point_pos, Array< unsigned int > &codes, Array< unsigned int > &proc_ids, Array< unsigned int > &elem_ids, Vector &ref_pos, Vector &dist)
Class for an integration rule - an Array of IntegrationPoint.
Class for grid function - Vector with associated FE space.
void Setup(Mesh &m, double bb_t, double newt_tol, int npt_max)
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.
int main(int argc, char *argv[])
double field_func(const Vector &x)
void Interpolate(Array< unsigned int > &codes, Array< unsigned int > &proc_ids, Array< unsigned int > &elem_ids, Vector &ref_pos, const GridFunction &field_in, Vector &field_out)
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
const IntegrationRule & GetNodes() const
virtual const char * Name() const
void SetNodalFESpace(FiniteElementSpace *nfes)
Nodes: x_i = i/(n-1), i=0,...,n-1.
void PrintUsage(std::ostream &out) const
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
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)
Class for integration point with weight.
void PrintOptions(std::ostream &out) const
virtual void ProjectCoefficient(Coefficient &coeff)
int open(const char hostname[], int port)
class for C-function coefficient
void GetNodes(Vector &node_coord) const
Arbitrary order H1-conforming (continuous) finite elements.