MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
pfindpts.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2026, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11//
12// ----------------------------------------------------------------------
13// Parallel Find Points Miniapp: Evaluate grid function in physical space
14// ----------------------------------------------------------------------
15//
16// This miniapp demonstrates the interpolation of a high-order grid function on
17// a set of points in physical-space. The miniapp is based on GSLIB-FindPoints,
18// which provides two key functionalities. First, for a given set of points in
19// the physical-space, it determines the computational coordinates (element
20// number, reference-space coordinates inside the element, and processor number
21// [in parallel]) for each point. Second, based on computational coordinates, it
22// interpolates a grid function in the given points. Inside GSLIB, computation
23// of the coordinates requires use of a Hash Table to identify the candidate
24// processor and element for each point, followed by the Newton's method to
25// determine the reference-space coordinates inside the candidate element.
26//
27// Compile with: make pfindpts
28//
29// Sample runs:
30// mpirun -np 2 pfindpts -m ../../data/rt-2d-p4-tri.mesh -o 8 -mo 4
31// mpirun -np 2 pfindpts -m ../../data/inline-tri.mesh -o 3
32// mpirun -np 2 pfindpts -m ../../data/inline-quad.mesh -o 3
33// mpirun -np 2 pfindpts -m ../../data/inline-quad.mesh -o 3 -po 1
34// mpirun -np 2 pfindpts -m ../../data/inline-quad.mesh -o 3 -po 1 -gfo 1 -nc 2
35// mpirun -np 2 pfindpts -m ../../data/inline-quad.mesh -o 3 -hr
36// mpirun -np 2 pfindpts -m ../../data/inline-tet.mesh -o 3
37// mpirun -np 2 pfindpts -m ../../data/inline-hex.mesh -o 3
38// mpirun -np 2 pfindpts -m ../../data/inline-wedge.mesh -o 3
39// mpirun -np 2 pfindpts -m ../../data/amr-quad.mesh -o 2
40// mpirun -np 2 pfindpts -m ../../data/rt-2d-q3.mesh -o 8 -mo 4 -ft 2
41// mpirun -np 2 pfindpts -m ../../data/inline-quad.mesh -ft 1 -sr0
42// mpirun -np 2 pfindpts -m ../../data/square-mixed.mesh -o 2 -mo 2
43// mpirun -np 2 pfindpts -m ../../data/square-mixed.mesh -o 2 -mo 2 -hr
44// mpirun -np 2 pfindpts -m ../../data/square-mixed.mesh -o 2 -mo 3 -ft 2
45// mpirun -np 2 pfindpts -m ../../data/fichera-mixed.mesh -o 3 -mo 2
46// mpirun -np 2 pfindpts -m ../../data/inline-pyramid.mesh -o 1 -mo 1
47// mpirun -np 2 pfindpts -m ../../data/tinyzoo-3d.mesh -o 1 -mo 1
48// Device runs:
49// mpirun -np 2 pfindpts -m ../../data/inline-quad.mesh -o 3 -mo 2 -random 1 -d debug
50// mpirun -np 2 pfindpts -m ../../data/amr-quad.mesh -rs 1 -o 4 -mo 2 -random 1 -npt 100 -d debug
51// mpirun -np 2 pfindpts -m ../../data/inline-hex.mesh -o 3 -mo 2 -random 1 -d debug -ft 1
52// Surface meshes:
53// mpirun -np 4 pfindpts -m ../../data/square-disc-p2.mesh -o 4 -mo 2 -vis -random 1 -surf
54// mpirun -np 4 pfindpts -m ../../data/star-q3.mesh -o 6 -mo 3 -vis -random 1 -surf
55// mpirun -np 4 pfindpts -m ../../data/fichera-q2.mesh -o 6 -mo 3 -vis -random 1 -surf
56// Surface meshes + bounding box size increase:
57// mpirun -np 4 pfindpts -m ../../data/square-disc-p2.mesh -o 4 -mo 2 -vis -random 1 -surf -sabs 0.1
58// mpirun -np 4 pfindpts -m ../../data/tinyzoo-3d.mesh -o 4 -mo 2 -vis -random 1 -surf -sabs 0.1
59
60#include "mfem.hpp"
62
63using namespace mfem;
64using namespace std;
65
67
68// Scalar function to project
69double field_func(const Vector &x)
70{
71 const int dim = x.Size();
72 double res = 0.0;
73 for (int d = 0; d < dim; d++) { res += std::pow(x(d), func_order); }
74 return res;
75}
76
77void F_exact(const Vector &p, Vector &F)
78{
79 F(0) = field_func(p);
80 for (int i = 1; i < F.Size(); i++) { F(i) = (i+1)*F(0); }
81}
82
83int main (int argc, char *argv[])
84{
85 // Initialize MPI and HYPRE.
86 Mpi::Init(argc, argv);
87 int num_procs = Mpi::WorldSize();
88 int myid = Mpi::WorldRank();
90
91 // Set the method's default parameters.
92 const char *mesh_file = "../../data/rt-2d-q3.mesh";
93 int order = 3;
94 int mesh_poly_deg = 3;
95 int rs_levels = 0;
96 int rp_levels = 0;
97 bool visualization = false;
98 int fieldtype = 0;
99 int ncomp = 1;
100 bool search_on_rank_0 = false;
101 bool hrefinement = false;
102 int point_ordering = 0;
103 int gf_ordering = 0;
104 const char *devopt = "cpu";
105 int randomization = 0;
106 int npt = 100; //points per proc
107 bool surface = false;
108 double surf_aabb_sz_inc = 0.0;
109
110 // Parse command-line options.
111 OptionsParser args(argc, argv);
112 args.AddOption(&mesh_file, "-m", "--mesh",
113 "Mesh file to use.");
114 args.AddOption(&order, "-o", "--order",
115 "Finite element order (polynomial degree).");
116 args.AddOption(&mesh_poly_deg, "-mo", "--mesh-order",
117 "Polynomial degree of mesh finite element space.");
118 args.AddOption(&rs_levels, "-rs", "--refine-serial",
119 "Number of times to refine the mesh uniformly in serial.");
120 args.AddOption(&rp_levels, "-rp", "--refine-parallel",
121 "Number of times to refine the mesh uniformly in parallel.");
122 args.AddOption(&fieldtype, "-ft", "--field-type",
123 "Field type: 0 - H1, 1 - L2, 2 - H(div), 3 - H(curl).");
124 args.AddOption(&ncomp, "-nc", "--ncomp",
125 "Number of components for H1 or L2 GridFunctions");
126 args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
127 "--no-visualization",
128 "Enable or disable GLVis visualization.");
129 args.AddOption(&search_on_rank_0, "-sr0", "--search-on-r0", "-no-sr0",
130 "--no-search-on-r0",
131 "Enable search only on rank 0 (disable to search points on all tasks). "
132 "All points added by other procs are ignored.");
133 args.AddOption(&hrefinement, "-hr", "--h-refinement", "-no-hr",
134 "--no-h-refinement",
135 "Do random h refinements to mesh (does not work for pyramids).");
136 args.AddOption(&point_ordering, "-po", "--point-ordering",
137 "Ordering of points to be found."
138 "0 (default): byNodes, 1: byVDIM");
139 args.AddOption(&gf_ordering, "-gfo", "--gridfunc-ordering",
140 "Ordering of fespace that will be used for grid function to be interpolated. "
141 "0 (default): byNodes, 1: byVDIM");
142 args.AddOption(&devopt, "-d", "--device",
143 "Device configuration string, see Device::Configure().");
144 args.AddOption(&randomization, "-random", "--random",
145 "0: generate points randomly in the bounding box of domain, "
146 "1: generate points randomly inside each element in mesh.");
147 args.AddOption(&npt, "-npt", "--npt",
148 "# points / rank initialized on entire mesh (random = 0) or every element (random = 1).");
149 args.AddOption(&surface, "-surf", "--surface", "-no-surf",
150 "--no-surface",
151 "Extract surface mesh from volume mesh.");
152 args.AddOption(&surf_aabb_sz_inc, "-sabs", "--surface-aabb-size-inc",
153 "Absolute AABB expansion applied to surface-search "
154 "axis-aligned bounding boxes in FindPointsGSLIB surface meshes.");
155 args.Parse();
156 if (!args.Good())
157 {
158 args.PrintUsage(cout);
159 return 1;
160 }
161 if (myid == 0) { args.PrintOptions(cout); }
162
163 bool cpu_mode = strcmp(devopt,"cpu")==0;
164 Device device(devopt);
165 if (myid == 0) { device.Print();}
166
167 func_order = std::min(order, 2);
168
169 // Initialize and extract surface mesh if requested.
170 Mesh *input_mesh = new Mesh(mesh_file, 1, 1, false);
171 Mesh *mesh = surface ? nullptr : input_mesh;
172 if (surface)
173 {
174 MFEM_VERIFY(input_mesh->bdr_attributes.Size() > 0,
175 "--surface requires a mesh with boundary attributes.");
176 mesh = new Mesh(SubMesh::CreateFromBoundary(*input_mesh,
177 input_mesh->bdr_attributes));
178 }
179 for (int lev = 0; lev < rs_levels; lev++) { mesh->UniformRefinement(); }
180 const int dim = mesh->Dimension(),
181 sdim = mesh->SpaceDimension();
182
183 if (myid == 0)
184 {
185 cout << "Mesh curvature of the original mesh: ";
186 if (mesh->GetNodes()) { cout << mesh->GetNodes()->OwnFEC()->Name(); }
187 else { cout << "(NONE)"; }
188 cout << endl;
189 }
190
191 // Mesh bounding box (for the full serial mesh).
192 Vector pos_min, pos_max;
193 MFEM_VERIFY(mesh_poly_deg > 0, "The order of the mesh must be positive.");
194 mesh->GetBoundingBox(pos_min, pos_max, mesh_poly_deg);
195 if (myid == 0)
196 {
197 cout << "--- Generating points for:\n"
198 << "x in [" << pos_min(0) << ", " << pos_max(0) << "]\n";
199 if (sdim >= 2)
200 {
201 cout << "y in [" << pos_min(1) << ", " << pos_max(1) << "]" << std::endl;
202 }
203 if (sdim == 3)
204 {
205 cout << "z in [" << pos_min(2) << ", " << pos_max(2) << "]" << std::endl;
206 }
207 }
208
209 // Distribute the mesh.
210 if (hrefinement) { mesh->EnsureNCMesh(); }
211 ParMesh pmesh(MPI_COMM_WORLD, *mesh, nullptr,
212 (dim == 1 && sdim == 3) ? 0 : 1);
213 if (randomization == 0)
214 {
215 delete mesh;
216 if (surface) { delete input_mesh; }
217 }
218 else
219 {
220 // we will need mesh nodal space later
221 if (mesh->GetNodes() == NULL) { mesh->SetCurvature(1); }
222 }
223 for (int lev = 0; lev < rp_levels; lev++) { pmesh.UniformRefinement(); }
224
225 // Random h-refinements to mesh
226 if (hrefinement) { pmesh.RandomRefinement(0.5); }
227
228 // Curve the mesh based on the chosen polynomial degree.
229 H1_FECollection fecm(mesh_poly_deg, dim);
230 ParFiniteElementSpace pfespace(&pmesh, &fecm, sdim);
231 pmesh.SetNodalFESpace(&pfespace);
232 ParGridFunction x(&pfespace);
233 pmesh.SetNodalGridFunction(&x);
234 if (myid == 0)
235 {
236 cout << "Mesh curvature of the curved mesh: " << fecm.Name() << endl;
237 }
238
239 int nelemglob = pmesh.GetGlobalNE();
240
241 MFEM_VERIFY(ncomp > 0, "Invalid number of components.");
242 int vec_dim = ncomp;
243 FiniteElementCollection *fec = NULL;
244 if (fieldtype == 0)
245 {
246 fec = new H1_FECollection(order, dim);
247 if (myid == 0) { cout << "H1-GridFunction" << std::endl; }
248 }
249 else if (fieldtype == 1)
250 {
251 fec = new L2_FECollection(order, dim);
252 if (myid == 0) { cout << "L2-GridFunction" << std::endl; }
253 }
254 else if (fieldtype == 2)
255 {
256 fec = new RT_FECollection(order, dim);
257 ncomp = 1;
258 vec_dim = sdim;
259 if (myid == 0) { cout << "H(div)-GridFunction" << std::endl; }
260 }
261 else if (fieldtype == 3)
262 {
263 fec = new ND_FECollection(order, dim);
264 ncomp = 1;
265 vec_dim = sdim;
266 if (myid == 0) { cout << "H(curl)-GridFunction" << std::endl; }
267 }
268 else
269 {
270 if (myid == 0) { MFEM_ABORT("Invalid FECollection type."); }
271 }
272 ParFiniteElementSpace sc_fes(&pmesh, fec, ncomp, gf_ordering);
273 ParGridFunction field_vals(&sc_fes);
274
275 // Project the GridFunction using VectorFunctionCoefficient.
277 field_vals.ProjectCoefficient(F);
278
279 // Display the mesh and the field through glvis.
280 if (visualization)
281 {
282 char vishost[] = "localhost";
283 socketstream sout;
284 sout.open(vishost, 19916);
285 if (!sout)
286 {
287 if (myid == 0)
288 {
289 cout << "Unable to connect to GLVis server at "
290 << vishost << ':' << 19916 << endl;
291 }
292 }
293 else
294 {
295 sout << "parallel " << num_procs << " " << myid << "\n";
296 sout.precision(8);
297 sout << "solution\n" << pmesh << field_vals;
298 if (sdim == 2) { sout << "keys RmjA*****\n"; }
299 if (sdim == 3) { sout << "keys mA\n"; }
300 sout << "window_title 'Solution'\n"
301 << "window_geometry "
302 << 0 << " " << 0 << " " << 400 << " " << 400 << "\n";
303 sout << flush;
304 }
305 }
306
307 // Generate random points in physical coordinates over the whole mesh.
308 // Note that some points might be outside if the mesh is not a box.
309 int pts_cnt = npt;
310 Vector vxyz;
311 vxyz.UseDevice(!cpu_mode);
312 int npt_face_per_elem = 4; // number of pts on faces when randomization != 0
313 int npt_total_face = 0;
314 if (randomization == 0)
315 {
316 vxyz.SetSize(pts_cnt * sdim);
317 vxyz.Randomize(myid+1);
318
319 // Scale based on min/max dimensions
320 for (int i = 0; i < pts_cnt; i++)
321 {
322 for (int d = 0; d < sdim; d++)
323 {
324 if (point_ordering == Ordering::byNODES)
325 {
326 vxyz(i + d*pts_cnt) =
327 pos_min(d) + vxyz(i + d*pts_cnt) * (pos_max(d) - pos_min(d));
328 }
329 else
330 {
331 vxyz(i*sdim + d) =
332 pos_min(d) + vxyz(i*sdim + d) * (pos_max(d) - pos_min(d));
333 }
334 }
335 }
336 }
337 else // randomization == 1
338 {
339 pts_cnt = npt*nelemglob;
340 vxyz.SetSize(pts_cnt * sdim);
341 for (int i=0; i<mesh->GetNE(); i++)
342 {
343 const FiniteElementSpace *s_fespace = mesh->GetNodalFESpace();
344 ElementTransformation *transf = s_fespace->GetElementTransformation(i);
345 const Geometry::Type geom = mesh->GetElementGeometry(i);
346 for (int j=0; j<npt; j++)
347 {
349 Geometry::GetRandomPoint(geom, ip);
350 if (j < npt_face_per_elem)
351 {
352 ip.x = 0.0; // force point to be on a face
353 npt_total_face++;
354 }
355 Vector pos_i(sdim);
356 transf->Transform(ip, pos_i);
357 for (int d=0; d<sdim; d++)
358 {
359 if (point_ordering == Ordering::byNODES)
360 {
361 vxyz(j + npt*i + d*npt*nelemglob) = pos_i(d);
362 }
363 else
364 {
365 vxyz((j + npt*i)*sdim + d) = pos_i(d);
366 }
367 }
368 }
369 }
370 }
371 if ( (myid != 0) && (search_on_rank_0) )
372 {
373 pts_cnt = 0;
374 vxyz.Destroy();
375 npt_total_face = 0;
376 }
377 MPI_Allreduce(MPI_IN_PLACE, &npt_total_face, 1, MPI_INT, MPI_SUM,
378 pmesh.GetComm());
379
380 // Find and Interpolate FE function values on the desired points.
381 Vector interp_vals(pts_cnt*vec_dim);
382 FindPointsGSLIB finder;
383 if (surface && surf_aabb_sz_inc > 0.0)
384 {
385 Vector bb_size({surf_aabb_sz_inc});
386 finder.SetupSurfWithAABBExpansion(pmesh, bb_size);
387 }
388 else
389 {
390 finder.Setup(pmesh);
391 }
392 // finder.SetDistanceToleranceForPointsFoundOnBoundary(1e-10);
393 // Enable GPU to CPU fallback for GPUData only if you are using an older
394 // version of GSLIB.
395 // finder.SetGPUtoCPUFallback(true);
396 finder.FindPoints(vxyz, point_ordering);
397
398 finder.Interpolate(field_vals, interp_vals);
399 if (interp_vals.UseDevice())
400 {
401 interp_vals.HostReadWrite();
402 }
403 vxyz.HostReadWrite();
404
405 Array<unsigned int> code_out = finder.GetCode();
406 Array<unsigned int> task_id_out = finder.GetProc();
407 Vector dist_p_out = finder.GetDist();
408
409 auto h_code_out = code_out.HostRead();
410 auto h_task_id_out = task_id_out.HostRead();
411 auto h_dist_p_out = dist_p_out.HostRead();
412
413 int face_pts = 0, not_found = 0, found_loc = 0, found_away = 0;
414 double error = 0.0, max_error = 0.0, max_dist = 0.0;
415
416 Vector pos(sdim);
417 for (int j = 0; j < vec_dim; j++)
418 {
419 for (int i = 0; i < pts_cnt; i++)
420 {
421 if (j == 0)
422 {
423 (h_task_id_out[i] == (unsigned)myid) ? found_loc++ : found_away++;
424 }
425
426 if (h_code_out[i] < 2)
427 {
428 for (int d = 0; d < sdim; d++)
429 {
430 pos(d) = point_ordering == Ordering::byNODES ?
431 vxyz(d*pts_cnt + i) :
432 vxyz(i*sdim + d);
433 }
434 Vector exact_val(vec_dim);
435 F_exact(pos, exact_val);
436 error = gf_ordering == Ordering::byNODES ?
437 fabs(exact_val(j) - interp_vals[i + j*pts_cnt]) :
438 fabs(exact_val(j) - interp_vals[i*vec_dim + j]);
439 max_error = std::max(max_error, error);
440 max_dist = std::max(max_dist, h_dist_p_out[i]);
441 if (h_code_out[i] == 1 && j == 0) { face_pts++; }
442 }
443 else { if (j == 0) { not_found++; } }
444 }
445 }
446
447 MPI_Allreduce(MPI_IN_PLACE, &found_loc, 1, MPI_INT, MPI_SUM,
448 pfespace.GetComm());
449 MPI_Allreduce(MPI_IN_PLACE, &found_away, 1, MPI_INT, MPI_SUM,
450 pfespace.GetComm());
451 MPI_Allreduce(MPI_IN_PLACE, &face_pts, 1, MPI_INT, MPI_SUM, pfespace.GetComm());
452 MPI_Allreduce(MPI_IN_PLACE, &not_found, 1, MPI_INT, MPI_SUM,
453 pfespace.GetComm());
454 MPI_Allreduce(MPI_IN_PLACE, &max_error, 1, MPI_DOUBLE, MPI_MAX,
455 pfespace.GetComm());
456 MPI_Allreduce(MPI_IN_PLACE, &max_dist, 1, MPI_DOUBLE, MPI_MAX,
457 pfespace.GetComm());
458 MPI_Allreduce(MPI_IN_PLACE, &error, 1, MPI_DOUBLE, MPI_SUM, pfespace.GetComm());
459
460
461 if (myid == 0)
462 {
463 cout << setprecision(16)
464 << "Total number of elements: " << nelemglob
465 << "\nTotal number of procs: " << num_procs
466 << "\nSearched total points: " << (search_on_rank_0 ? pts_cnt :
467 pts_cnt*num_procs)
468 << "\nFound locally on ranks: " << found_loc
469 << "\nFound on other tasks: " << found_away
470 << "\nPoints not found: " << not_found
471 << "\nPoints on faces: " << face_pts << " out of "
472 << npt_total_face
473 << "\nMax interp error: " << max_error
474 << "\nMax dist^2 (of found): " << max_dist
475 << endl;
476 }
477
478
479 delete fec;
480
481 if (randomization != 0)
482 {
483 delete mesh;
484 if (surface) { delete input_mesh; }
485 }
486
487 return 0;
488}
const T * HostRead() const
Shortcut for mfem::Read(a.GetMemory(), a.Size(), false).
Definition array.hpp:414
int Size() const
Return the logical size of the array.
Definition array.hpp:192
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
Definition device.hpp:129
void Print(std::ostream &os=mfem::out)
Print the configuration of the MFEM virtual device object.
Definition device.cpp:319
virtual void Transform(const IntegrationPoint &, Vector &)=0
Transform integration point from reference coordinates to physical coordinates and store them in the ...
FindPointsGSLIB can robustly evaluate a GridFunction on an arbitrary collection of points....
Definition gslib.hpp:115
virtual const Vector & GetDist() const
Return distance between the sought and the found point in physical space.
Definition gslib.hpp:614
void FindPoints(const Vector &point_pos, int point_pos_ordering=Ordering::byNODES)
Searches positions given in physical space by point_pos.
Definition gslib.cpp:1372
void Setup(Mesh &m, const double bbox_rel_size_inc=0.1, const double newt_tol=1.0e-12, const int npt_max=256)
Preprocess the internal mesh in gslib.
Definition gslib.cpp:321
virtual void Interpolate(const GridFunction &field_in, Vector &field_out)
Interpolation of field values at prescribed reference space positions.
Definition gslib.cpp:3679
virtual const Array< unsigned int > & GetCode() const
Return code for each point searched by FindPoints: inside element (0), element boundary (1),...
Definition gslib.hpp:606
void SetupSurfWithAABBExpansion(Mesh &m, const Vector &aabb_sz_inc, const double newt_tol=1.0e-12)
Preprocess the surface mesh to compute data for FindPoints using absolute AABB expansion.
Definition gslib.cpp:1200
virtual const Array< unsigned int > & GetProc() const
Return MPI rank on which each point was found by FindPoints.
Definition gslib.hpp:610
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Definition fe_coll.hpp:27
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:210
ElementTransformation * GetElementTransformation(int i) const
Definition fespace.hpp:903
static void GetRandomPoint(int GeomType, IntegrationPoint &ip)
Get a random point in the reference element specified by GeomType.
Definition geom.cpp:314
Arbitrary order H1-conforming (continuous) finite elements.
Definition fe_coll.hpp:291
const char * Name() const override
Definition fe_coll.hpp:313
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
Definition hypre.cpp:33
Class for integration point with weight.
Definition intrules.hpp:35
Arbitrary order "L2-conforming" discontinuous finite elements.
Definition fe_coll.hpp:369
Mesh data type.
Definition mesh.hpp:67
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
Definition mesh.hpp:309
Geometry::Type GetElementGeometry(int i) const
Definition mesh.hpp:1548
const FiniteElementSpace * GetNodalFESpace() const
Definition mesh.cpp:7206
int GetNE() const
Returns number of elements.
Definition mesh.hpp:1390
void GetBoundingBox(Vector &min, Vector &max, int ref=2)
Returns the minimum and maximum corners of the mesh bounding box.
Definition mesh.cpp:142
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1314
void RandomRefinement(real_t prob, bool aniso=false, int nonconforming=-1, int nc_limit=0)
Refine each element with given probability. Uses GeneralRefinement.
Definition mesh.cpp:11805
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1, int pyr_type=1)
Set the curvature of the mesh nodes using the given polynomial degree.
Definition mesh.cpp:7211
int SpaceDimension() const
Dimension of the physical space containing the mesh.
Definition mesh.hpp:1317
void SetNodalGridFunction(GridFunction *nodes, bool make_owner=false)
Definition mesh.cpp:7200
void GetNodes(Vector &node_coord) const
Definition mesh.cpp:10112
long long GetGlobalNE() const
Return the total (global) number of elements.
Definition mesh.hpp:1419
void EnsureNCMesh(bool simplices_nonconforming=false)
Definition mesh.cpp:11781
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Definition mesh.cpp:12125
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.
Definition fe_coll.hpp:526
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...
Definition optparser.hpp:82
bool Good() const
Return true if the command line options were parsed successfully.
Abstract parallel finite element space.
Definition pfespace.hpp:31
MPI_Comm GetComm() const
Definition pfespace.hpp:337
Class for parallel grid function.
Definition pgridfunc.hpp:50
void ProjectCoefficient(Coefficient &coeff, ProjectType type=ProjectType::DEFAULT) override
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
Class for parallel meshes.
Definition pmesh.hpp:35
MPI_Comm GetComm() const
Definition pmesh.hpp:403
void SetNodalFESpace(FiniteElementSpace *nfes) override
Definition pmesh.cpp:2057
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
Definition fe_coll.hpp:430
static SubMesh CreateFromBoundary(const Mesh &parent, const Array< int > &boundary_attributes)
Create a surface SubMesh from its parent.
Definition submesh.cpp:27
A general vector function coefficient.
Vector data type.
Definition vector.hpp:82
void Randomize(int seed=0)
Set random values in the vector.
Definition vector.cpp:955
virtual const real_t * HostRead() const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), false).
Definition vector.hpp:524
void Destroy()
Destroy a vector.
Definition vector.hpp:722
int Size() const
Returns the size of the vector.
Definition vector.hpp:234
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
Definition vector.hpp:145
void SetSize(int s)
Resize the vector to size s.
Definition vector.hpp:633
virtual real_t * HostReadWrite()
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), false).
Definition vector.hpp:540
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
int dim
Definition ex24.cpp:53
int main()
const char vishost[]
STL namespace.
real_t p(const Vector &x, real_t t)
double field_func(const Vector &x)
Definition pfindpts.cpp:69
double func_order
Definition pfindpts.cpp:66
void F_exact(const Vector &p, Vector &F)
Definition pfindpts.cpp:77