61 for (
int d = 0; d <
dim; d++) { res += std::pow(x(d),
func_order); }
68 for (
int i = 1; i < F.
Size(); i++) { F(i) = (i+1)*F(0); }
71int main (
int argc,
char *argv[])
80 const char *mesh_file =
"../../data/rt-2d-q3.mesh";
82 int mesh_poly_deg = 3;
85 bool visualization =
true;
88 bool search_on_rank_0 =
false;
89 bool hrefinement =
false;
90 int point_ordering = 0;
95 args.
AddOption(&mesh_file,
"-m",
"--mesh",
98 "Finite element order (polynomial degree).");
99 args.
AddOption(&mesh_poly_deg,
"-mo",
"--mesh-order",
100 "Polynomial degree of mesh finite element space.");
101 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
102 "Number of times to refine the mesh uniformly in serial.");
103 args.
AddOption(&rp_levels,
"-rp",
"--refine-parallel",
104 "Number of times to refine the mesh uniformly in parallel.");
105 args.
AddOption(&fieldtype,
"-ft",
"--field-type",
106 "Field type: 0 - H1, 1 - L2, 2 - H(div), 3 - H(curl).");
108 "Number of components for H1 or L2 GridFunctions");
109 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
110 "--no-visualization",
111 "Enable or disable GLVis visualization.");
112 args.
AddOption(&search_on_rank_0,
"-sr0",
"--search-on-r0",
"-no-sr0",
114 "Enable search only on rank 0 (disable to search points on all tasks).");
115 args.
AddOption(&hrefinement,
"-hr",
"--h-refinement",
"-no-hr",
117 "Do random h refinements to mesh (does not work for pyramids).");
118 args.
AddOption(&point_ordering,
"-po",
"--point-ordering",
119 "Ordering of points to be found."
120 "0 (default): byNodes, 1: byVDIM");
121 args.
AddOption(&gf_ordering,
"-gfo",
"--gridfunc-ordering",
122 "Ordering of fespace that will be used for gridfunction to be interpolated."
123 "0 (default): byNodes, 1: byVDIM");
136 Mesh *mesh =
new Mesh(mesh_file, 1, 1,
false);
141 cout <<
"Mesh curvature of the original mesh: ";
143 else { cout <<
"(NONE)"; }
149 MFEM_VERIFY(mesh_poly_deg > 0,
"The order of the mesh must be positive.");
153 cout <<
"--- Generating equidistant point for:\n"
154 <<
"x in [" << pos_min(0) <<
", " << pos_max(0) <<
"]\n"
155 <<
"y in [" << pos_min(1) <<
", " << pos_max(1) <<
"]\n";
158 cout <<
"z in [" << pos_min(2) <<
", " << pos_max(2) <<
"]\n";
164 ParMesh pmesh(MPI_COMM_WORLD, *mesh);
177 cout <<
"Mesh curvature of the curved mesh: " << fecm.
Name() << endl;
180 MFEM_VERIFY(ncomp > 0,
"Invalid number of components.");
186 if (myid == 0) { cout <<
"H1-GridFunction\n"; }
188 else if (fieldtype == 1)
191 if (myid == 0) { cout <<
"L2-GridFunction\n"; }
193 else if (fieldtype == 2)
198 if (myid == 0) { cout <<
"H(div)-GridFunction\n"; }
200 else if (fieldtype == 3)
205 if (myid == 0) { cout <<
"H(curl)-GridFunction\n"; }
209 if (myid == 0) { MFEM_ABORT(
"Invalid FECollection type."); }
229 cout <<
"Unable to connect to GLVis server at "
235 sout <<
"parallel " << num_procs <<
" " << myid <<
"\n";
237 sout <<
"solution\n" << pmesh << field_vals;
238 if (
dim == 2) { sout <<
"keys RmjA*****\n"; }
239 if (
dim == 3) { sout <<
"keys mA\n"; }
247 const int pts_cnt_1D = 25;
248 int pts_cnt = pow(pts_cnt_1D,
dim);
259 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
260 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
264 vxyz(i*
dim + 0) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
265 vxyz(i*
dim + 1) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
278 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
279 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
280 vxyz(2*pts_cnt + i) = pos_min(2) + ip.
z * (pos_max(2)-pos_min(2));
284 vxyz(i*
dim + 0) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
285 vxyz(i*
dim + 1) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
286 vxyz(i*
dim + 2) = pos_min(2) + ip.
z * (pos_max(2)-pos_min(2));
291 if ( (myid != 0) && (search_on_rank_0) )
298 Vector interp_vals(pts_cnt*vec_dim);
301 finder.
Interpolate(vxyz, field_vals, interp_vals, point_ordering);
310 int face_pts = 0, not_found = 0, found_loc = 0, found_away = 0;
311 double error = 0.0, max_err = 0.0, max_dist = 0.0;
313 for (
int j = 0; j < vec_dim; j++)
315 for (
int i = 0; i < pts_cnt; i++)
319 (task_id_out[i] == (unsigned)myid) ? found_loc++ : found_away++;
324 for (
int d = 0; d <
dim; d++)
327 vxyz(d*pts_cnt + i) :
330 Vector exact_val(vec_dim);
333 fabs(exact_val(j) - interp_vals[i + j*pts_cnt]) :
334 fabs(exact_val(j) - interp_vals[i*vec_dim + j]);
335 max_err = std::max(max_err, error);
336 max_dist = std::max(max_dist, dist_p_out(i));
337 if (code_out[i] == 1 && j == 0) { face_pts++; }
339 else {
if (j == 0) { not_found++; } }
343 cout << setprecision(16)
344 <<
"Searched unique points: " << pts_cnt
345 <<
"\nFound on local mesh: " << found_loc
346 <<
"\nFound on other tasks: " << found_away
347 <<
"\nMax interp error: " << max_err
348 <<
"\nMax dist (of found): " << max_dist
349 <<
"\nPoints not found: " << not_found
350 <<
"\nPoints on faces: " << face_pts << endl;
@ 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 const Array< unsigned int > & GetProc() const
Return MPI rank on which each point was found by FindPoints.
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
Arbitrary order H1-conforming (continuous) finite elements.
const char * Name() const override
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
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.
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 GetNodes(Vector &node_coord) const
void EnsureNCMesh(bool simplices_nonconforming=false)
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
static int WorldSize()
Return the size of MPI_COMM_WORLD.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
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.
Abstract parallel finite element space.
Class for parallel grid function.
void ProjectCoefficient(Coefficient &coeff) override
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
Class for parallel meshes.
void SetNodalFESpace(FiniteElementSpace *nfes) override
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
A general vector function coefficient.
void Destroy()
Destroy a vector.
int Size() const
Returns the size of the vector.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
real_t p(const Vector &x, real_t t)
double field_func(const Vector &x)
void F_exact(const Vector &p, Vector &F)