51 for (
int d = 0; d <
dim; d++) { res += x(d) * x(d); }
58 for (
int i = 1; i < F.
Size(); i++) { F(i) = (i+1)*F(0); }
61 int main (
int argc,
char *argv[])
70 const char *mesh_file =
"../../data/rt-2d-q3.mesh";
72 int mesh_poly_deg = 3;
75 bool visualization =
true;
78 bool search_on_rank_0 =
false;
79 bool hrefinement =
false;
83 args.
AddOption(&mesh_file,
"-m",
"--mesh",
86 "Finite element order (polynomial degree).");
87 args.
AddOption(&mesh_poly_deg,
"-mo",
"--mesh-order",
88 "Polynomial degree of mesh finite element space.");
89 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
90 "Number of times to refine the mesh uniformly in serial.");
91 args.
AddOption(&rp_levels,
"-rp",
"--refine-parallel",
92 "Number of times to refine the mesh uniformly in parallel.");
93 args.
AddOption(&fieldtype,
"-ft",
"--field-type",
94 "Field type: 0 - H1, 1 - L2, 2 - H(div), 3 - H(curl).");
96 "Number of components for H1 or L2 GridFunctions");
97 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
99 "Enable or disable GLVis visualization.");
100 args.
AddOption(&search_on_rank_0,
"-sr0",
"--search-on-r0",
"-no-sr0",
102 "Enable search only on rank 0 (disable to search points on all tasks).");
103 args.
AddOption(&hrefinement,
"-hr",
"--h-refinement",
"-no-hr",
105 "Do random h refinements to mesh.");
116 Mesh *mesh =
new Mesh(mesh_file, 1, 1,
false);
121 cout <<
"Mesh curvature of the original mesh: ";
123 else { cout <<
"(NONE)"; }
129 MFEM_VERIFY(mesh_poly_deg > 0,
"The order of the mesh must be positive.");
133 cout <<
"--- Generating equidistant point for:\n"
134 <<
"x in [" << pos_min(0) <<
", " << pos_max(0) <<
"]\n"
135 <<
"y in [" << pos_min(1) <<
", " << pos_max(1) <<
"]\n";
138 cout <<
"z in [" << pos_min(2) <<
", " << pos_max(2) <<
"]\n";
144 ParMesh pmesh(MPI_COMM_WORLD, *mesh);
157 cout <<
"Mesh curvature of the curved mesh: " << fecm.
Name() << endl;
160 MFEM_VERIFY(ncomp > 0,
"Invalid number of components.");
166 if (myid == 0) { cout <<
"H1-GridFunction\n"; }
168 else if (fieldtype == 1)
171 if (myid == 0) { cout <<
"L2-GridFunction\n"; }
173 else if (fieldtype == 2)
178 if (myid == 0) { cout <<
"H(div)-GridFunction\n"; }
180 else if (fieldtype == 3)
185 if (myid == 0) { cout <<
"H(curl)-GridFunction\n"; }
189 if (myid == 0) { MFEM_ABORT(
"Invalid FECollection type."); }
204 sout.
open(vishost, visport);
209 cout <<
"Unable to connect to GLVis server at "
210 << vishost <<
':' << visport << endl;
215 sout <<
"parallel " << num_procs <<
" " << myid <<
"\n";
217 sout <<
"solution\n" << pmesh << field_vals;
218 if (dim == 2) { sout <<
"keys RmjA*****\n"; }
219 if (dim == 3) { sout <<
"keys mA\n"; }
227 const int pts_cnt_1D = 10;
228 int pts_cnt =
pow(pts_cnt_1D, dim);
229 Vector vxyz(pts_cnt * dim);
237 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
238 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
248 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
249 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
250 vxyz(2*pts_cnt + i) = pos_min(2) + ip.
z * (pos_max(2)-pos_min(2));
254 if ( (myid != 0) && (search_on_rank_0) )
261 Vector interp_vals(pts_cnt*vec_dim);
273 int face_pts = 0, not_found = 0, found_loc = 0, found_away = 0;
274 double max_err = 0.0, max_dist = 0.0;
277 for (
int j = 0; j < vec_dim; j++)
279 for (
int i = 0; i < pts_cnt; i++)
283 (task_id_out[i] == (unsigned)myid) ? found_loc++ : found_away++;
288 for (
int d = 0; d <
dim; d++) { pos(d) = vxyz(d * pts_cnt + i); }
289 Vector exact_val(vec_dim);
291 max_err = std::max(max_err, fabs(exact_val(j) - interp_vals(npt)));
292 max_dist = std::max(max_dist, dist_p_out(i));
293 if (code_out[i] == 1 && j == 0) { face_pts++; }
295 else {
if (j == 0) { not_found++; } }
300 cout << setprecision(16)
301 <<
"Searched unique points: " << pts_cnt
302 <<
"\nFound on local mesh: " << found_loc
303 <<
"\nFound on other tasks: " << found_away
304 <<
"\nMax interp error: " << max_err
305 <<
"\nMax dist (of found): " << max_dist
306 <<
"\nPoints not found: " << not_found
307 <<
"\nPoints on faces: " << face_pts << endl;
int GetNPoints() const
Returns the number of the points in the integration rule.
virtual void Interpolate(const GridFunction &field_in, Vector &field_out)
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.
Class for an integration rule - an Array of IntegrationPoint.
virtual const Vector & GetDist() const
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.
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.
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 EnsureNCMesh(bool simplices_nonconforming=false)
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.
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();.
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.
FDualNumber< tbase > pow(const FDualNumber< tbase > &a, const FDualNumber< tbase > &b)
pow([dual number],[dual number])
A general vector function coefficient.
double p(const Vector &x, double t)
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...
virtual const Array< unsigned int > & GetProc() const
Return MPI rank on which each point was found by FindPoints.
Class for integration point with weight.
virtual const Array< unsigned int > & GetCode() const
Arbitrary order L2 elements in 2D on a square.
void Destroy()
Destroy a vector.
void PrintOptions(std::ostream &out) const
Print the options.
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.
FindPointsGSLIB can robustly evaluate a GridFunction on an arbitrary collection of points...
void GetNodes(Vector &node_coord) const
Nodes: x_i = i/(n-1), i=0,...,n-1.
Arbitrary order H1-conforming (continuous) finite elements.
Class for parallel grid function.
Class for parallel meshes.
Arbitrary order "L2-conforming" discontinuous finite elements.
bool Good() const
Return true if the command line options were parsed successfully.