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); }
71 int 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 err = 0.0, max_err = 0.0, max_dist = 0.0;
314 for (
int j = 0; j < vec_dim; j++)
316 for (
int i = 0; i < pts_cnt; i++)
320 (task_id_out[i] == (unsigned)myid) ? found_loc++ : found_away++;
325 for (
int d = 0; d <
dim; d++)
328 vxyz(d*pts_cnt + i) :
331 Vector exact_val(vec_dim);
334 fabs(exact_val(j) - interp_vals[i + j*pts_cnt]) :
335 fabs(exact_val(j) - interp_vals[i*vec_dim + j]);
336 max_err = std::max(max_err,
err);
337 max_dist = std::max(max_dist, dist_p_out(i));
338 if (code_out[i] == 1 && j == 0) { face_pts++; }
340 else {
if (j == 0) { not_found++; } }
345 cout << setprecision(16)
346 <<
"Searched unique points: " << pts_cnt
347 <<
"\nFound on local mesh: " << found_loc
348 <<
"\nFound on other tasks: " << found_away
349 <<
"\nMax interp error: " << max_err
350 <<
"\nMax dist (of found): " << max_dist
351 <<
"\nPoints not found: " << not_found
352 <<
"\nPoints on faces: " << face_pts << endl;
virtual void Interpolate(const GridFunction &field_in, Vector &field_out)
virtual const Array< unsigned int > & GetProc() const
Return MPI rank on which each point was found by FindPoints.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(), hypre will be finalized automatically at program exit.
int GetNPoints() const
Returns the number of the points in the integration rule.
double field_func(const Vector &x)
Class for an integration rule - an Array of IntegrationPoint.
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
void PrintOptions(std::ostream &out) const
Print the options.
Arbitrary order L2 elements in 3D on a cube.
void PrintUsage(std::ostream &out) const
Print the usage message.
void GetBoundingBox(Vector &min, Vector &max, int ref=2)
Returns the minimum and maximum corners of the mesh bounding box.
void F_exact(const Vector &p, Vector &F)
int Size() const
Returns the size of the vector.
bool Good() const
Return true if the command line options were parsed successfully.
Abstract parallel finite element space.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
static int WorldSize()
Return the size of MPI_COMM_WORLD.
int main(int argc, char *argv[])
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 EnsureNCMesh(bool simplices_nonconforming=false)
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void Setup(Mesh &m, const double bb_t=0.1, const double newt_tol=1.0e-12, const int npt_max=256)
void RandomRefinement(double prob, bool aniso=false, int nonconforming=-1, int nc_limit=0)
Refine each element with given probability. Uses GeneralRefinement.
static void Init()
Singleton creation with Mpi::Init();.
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
A general vector function coefficient.
double p(const Vector &x, double t)
virtual const char * Name() const
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.
virtual const Vector & GetDist() const
Arbitrary order L2 elements in 2D on a square.
void Destroy()
Destroy a vector.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
Arbitrary order H(curl)-conforming Nedelec finite elements.
Nodes: x_i = i/(n-1), i=0,...,n-1.
FindPointsGSLIB can robustly evaluate a GridFunction on an arbitrary collection of points...
void SetNodalFESpace(FiniteElementSpace *nfes) override
Arbitrary order H1-conforming (continuous) finite elements.
void GetNodes(Vector &node_coord) const
Class for parallel grid function.
virtual const Array< unsigned int > & GetCode() const
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
Class for parallel meshes.
Arbitrary order "L2-conforming" discontinuous finite elements.