43 for (
int d = 0; d <
dim; d++) { res += x(d) * x(d); }
47 int main (
int argc,
char *argv[])
51 MPI_Init(&argc, &argv);
52 MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
53 MPI_Comm_rank(MPI_COMM_WORLD, &myid);
56 const char *mesh_file =
"../../data/rt-2d-q3.mesh";
57 int mesh_poly_deg = 3;
60 bool visualization =
true;
64 args.
AddOption(&mesh_file,
"-m",
"--mesh",
66 args.
AddOption(&mesh_poly_deg,
"-o",
"--mesh-order",
67 "Polynomial degree of mesh finite element space.");
68 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
69 "Number of times to refine the mesh uniformly in serial.");
70 args.
AddOption(&rp_levels,
"-rp",
"--refine-parallel",
71 "Number of times to refine the mesh uniformly in parallel.");
72 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
74 "Enable or disable GLVis visualization.");
84 Mesh *mesh =
new Mesh(mesh_file, 1, 1,
false);
89 cout <<
"Mesh curvature of the original mesh: ";
91 else { cout <<
"(NONE)"; }
97 MFEM_VERIFY(mesh_poly_deg > 0,
"The order of the mesh must be positive.");
101 cout <<
"--- Generating equidistant point for:\n"
102 <<
"x in [" << pos_min(0) <<
", " << pos_max(0) <<
"]\n"
103 <<
"y in [" << pos_min(1) <<
", " << pos_max(1) <<
"]\n";
106 cout <<
"z in [" << pos_min(2) <<
", " << pos_max(2) <<
"]\n";
111 ParMesh pmesh(MPI_COMM_WORLD, *mesh);
121 cout <<
"Mesh curvature of the curved mesh: " << fec.
Name() << endl;
133 char vishost[] =
"localhost";
136 sout.
open(vishost, visport);
141 cout <<
"Unable to connect to GLVis server at "
142 << vishost <<
':' << visport << endl;
147 sout <<
"parallel " << num_procs <<
" " << myid <<
"\n";
149 sout <<
"solution\n" << pmesh << field_vals;
150 if (dim == 2) { sout <<
"keys RmjA*****\n"; }
151 if (dim == 3) { sout <<
"keys mA\n"; }
158 const double rel_bbox_el = 0.05;
159 const double newton_tol = 1.0e-12;
160 const int npts_at_once = 256;
161 finder.
Setup(pmesh, rel_bbox_el, newton_tol, npts_at_once);
166 const int pts_cnt_1D = 5;
167 const int pts_cnt = pow(pts_cnt_1D, dim);
168 Vector vxyz(pts_cnt * dim);
176 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
177 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
187 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
188 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
189 vxyz(2*pts_cnt + i) = pos_min(2) + ip.
z * (pos_max(2)-pos_min(2));
194 task_id_out(pts_cnt);
195 Vector pos_r_out(pts_cnt * dim), dist_p_out(pts_cnt);
198 finder.
FindPoints(vxyz, code_out, task_id_out,
199 el_id_out, pos_r_out, dist_p_out);
202 Vector interp_vals(pts_cnt);
203 finder.
Interpolate(code_out, task_id_out, el_id_out,
204 pos_r_out, field_vals, interp_vals);
209 int face_pts = 0, not_found = 0, found_loc = 0, found_away = 0;
210 double max_err = 0.0, max_dist = 0.0;
212 for (
int i = 0; i < pts_cnt; i++)
214 (task_id_out[i] == (unsigned)myid) ? found_loc++ : found_away++;
218 for (
int d = 0; d <
dim; d++) { pos(d) = vxyz(d * pts_cnt + i); }
221 max_err = std::max(max_err, fabs(exact_val - interp_vals[i]));
222 max_dist = std::max(max_dist, dist_p_out(i));
223 if (code_out[i] == 1) { face_pts++; }
225 else { not_found++; }
232 cout << setprecision(16) <<
"--- Task " << myid <<
": "
233 <<
"\nSearched points: " << pts_cnt
234 <<
"\nFound on local mesh: " << found_loc
235 <<
"\nFound on other tasks: " << found_away
236 <<
"\nMax interp error: " << max_err
237 <<
"\nMax dist (of found): " << max_dist
238 <<
"\nPoints not found: " << not_found
239 <<
"\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.
Abstract parallel finite element space.
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
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.
Class for parallel meshes.