MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
gslib.hpp
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#ifndef MFEM_GSLIB
13#define MFEM_GSLIB
14
15#include <map>
16#include <vector>
17
18#include "../config/config.hpp"
19#ifdef MFEM_USE_MPI
20#include "pgridfunc.hpp"
21#else
22#include "gridfunc.hpp"
23#endif
24
25#ifdef MFEM_USE_GSLIB
26
27/* gslib license and copyright statement for code adapted from gslib:
28
29Copyright (c) 2008-2024, UCHICAGO ARGONNE, LLC.
30
31The UChicago Argonne, LLC as Operator of Argonne National
32Laboratory holds copyright in the Software. The copyright holder
33reserves all rights except those expressly granted to licensees,
34and U.S. Government license rights.
35
36Redistribution and use in source and binary forms, with or without
37modification, are permitted provided that the following conditions
38are met:
39
401. Redistributions of source code must retain the above copyright
41notice, this list of conditions and the disclaimer below.
42
432. Redistributions in binary form must reproduce the above copyright
44notice, this list of conditions and the disclaimer (as noted below)
45in the documentation and/or other materials provided with the
46distribution.
47
483. Neither the name of ANL nor the names of its contributors
49may be used to endorse or promote products derived from this software
50without specific prior written permission.
51
52THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
55FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
56UCHICAGO ARGONNE, LLC, THE U.S. DEPARTMENT OF
57ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
59TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
63OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64*/
65
66namespace gslib
67{
68struct comm;
69struct crystal;
70struct hash_data_3;
71struct hash_data_2;
72struct gs_data;
73}
74
75namespace mfem
76{
77
78/** \brief FindPointsGSLIB can robustly evaluate a GridFunction on an arbitrary
79 * collection of points. See Mittal et al., "General Field Evaluation in
80 * High-Order Meshes on GPUs". (2025). Computers & Fluids. for technical
81 * details.
82 *
83 * There are three key functions in FindPointsGSLIB:
84 *
85 * 1. Setup - constructs the internal data structures of gslib. See \ref Setup.
86 *
87 * 2. FindPoints - for any given arbitrary set of points in physical space,
88 * gslib finds the element number, MPI rank, and the reference space
89 * coordinates inside the element that each point is located in. gslib also
90 * returns a code that indicates whether the point was found inside an
91 * element, on element border, or not found in the domain.
92 * For points returned as found on `element border`, the point is either
93 * on an element edge/face or near the domain boundary, and gslib also
94 * returns a distance to the border. Points near (but outside) the domain
95 * boundary must then be marked as not found using the distance returned
96 * by gslib. See \ref FindPoints.
97 *
98 * 3. Interpolate - Interpolates any grid function at the points found using 2.
99 * For functions in L2 finite element space, use \ref SetL2AvgType to
100 * specify how to interpolate values at points located at element boundaries
101 * where the function might be multi-valued. See \ref Interpolate.
102 *
103 * FindPointsGSLIB also provides interface to use these functions through a
104 * single call.
105 *
106 * For custom interpolation (e.g., evaluating strain rate tensor), we provide
107 * functions that use gslib to send element index and corresponding
108 * reference-space coordinates for each point to the mpi rank that the element
109 * is located on. Then, custom interpolation can be defined locally by the user
110 * before sending the values back to mpi ranks where the query originated from.
111 * See \ref DistributePointInfoToOwningMPIRanks and
112 * \ref DistributeInterpolatedValues.
113 */
115{
116public:
117 enum AvgType {NONE, ARITHMETIC, HARMONIC}; // Average type for L2 functions
118
119protected:
121 Array<Mesh *> mesh_split; // Meshes used to split simplices.
122 // IntegrationRules for simplex->Quad/Hex and to project to p_max in-case of
123 // p-refinement.
125 /// Integration rules built at the field polynomial order (only for surface
126 /// meshes when mesh order is not the same as gridfunction order).
128 /// Order at which #ir_split_sol was built; -1 means not built.
130 Array<FiniteElementSpace *> fes_rst_map; //FESpaces to map Quad/Hex->Simplex
131 Array<GridFunction *> gf_rst_map; // GridFunctions to map Quad/Hex->Simplex
133 void *fdataD;
134 struct gslib::crystal *cr; // gslib's internal data
135 struct gslib::comm *gsl_comm; // gslib's internal data
136 int dim, spacedim, points_cnt; // mesh dimension and number of points
139 Array<unsigned int> recv_proc, recv_index; // data for custom interpolation
140 bool setupflag; // flag to indicate if gslib data has been setup
141 double default_interp_value; // used for points that are not found in the mesh
142 AvgType avgtype; // average type used for L2 functions
145 // Geometry::Type (as int) of the original element for each split quad.
147 int NE_split_total; // total number of elements after mesh splitting
148 int mesh_points_cnt; // number of mesh nodes
149 // Tolerance to ignore points found beyond the mesh boundary.
150 // i.e. if ||x*-x(r)||_2^2 > bdr_tol, we mark point as not found.
151 double bdr_tol;
152 // Use CPU functions for Mesh/GridFunction on device for gslib1.0.7
154 // Check if a point is inside the oriented bounding box of an
155 // element before the Newton iteration.
156 // Note: only used in MFEM implementation (not in gslib) which currently
157 // supports GPU kernels for area meshes in 2D, volume meshes in 3D,
158 // and surface meshes in 1D/2D/3D.
159 bool obb_check = true;
160
161 // Device specific data used for FindPoints
163 {
164 bool setup_device = false;
165 bool find_device = false;
167 double newt_tol; // Tolerance specified during setup for Newton solve
168 struct gslib::crystal *cr;
169 struct gslib::hash_data_3 *hash3;
170 struct gslib::hash_data_2 *hash2;
174 // Tolerance to mark points found on the surface as CODE_INTERNAL
175 // or CODE_BORDER. This is needed because we cannot only use reference
176 // space coordinates to determine if a point is located inside the
177 // element or not.
178 mutable double surf_dist_tol;
180
181 // Helper function to setup and free gslib's crystal router.
182 void SetupCrystal(); // Called inside Setup and SetupSurfBase
183 void FreeCrystal(); // Called inside FreeData
184
185 /// Use GSLIB for communication and interpolation. Updates field_out on
186 /// host.
187 virtual void InterpolateH1(const GridFunction &field_in, Vector &field_out,
188 const int field_out_ordering);
189 /// Uses GSLIB Crystal Router for communication followed by MFEM's
190 /// interpolation functions. Updates field_out on host.
191 virtual void InterpolateGeneral(const GridFunction &field_in,
192 Vector &field_out,
193 const int field_out_ordering);
194
195 /** @brief Since GSLIB is designed to work with quads/hexes, we split every
196 * triangle/tet/prism/pyramid element into quads/hexes. */
197 virtual void SetupSplitMeshes();
198
199 /** @brief Setup integration points that will be used to interpolate the
200 * nodal location at points expected by GSLIB. */
202 IntegrationRule *irule,
203 int order);
204
205 /** @brief Build integration rules at the given @a order for each split mesh
206 * and store them in @a ir_out. Requires that \ref SetupSplitMeshes has
207 * already been called. */
208 virtual void SetupIntegrationRules(const int order,
210
211 /** @brief Helper function that calls \ref SetupSplitMeshes and
212 * \ref SetupIntegrationRules. */
213 virtual void SetupSplitMeshesAndIntegrationRules(const int order);
214
215 /** @brief Get GridFunction value at the points expected by GSLIB.
216 * @param[in] gf_in Grid function to evaluate.
217 * @param[out] node_vals Output values.
218 * @param[in] ir_in If non-null, use these rules instead of #ir_split.
219 * @param[in] by_element If true, output has element-major layout
220 * [nel][vdim][ndofs]; otherwise component-major
221 * layout [vdim][total_pts]. */
222 virtual void GetNodalValues(const GridFunction *gf_in, Vector &node_vals,
223 const Array<IntegrationRule *> *ir_in = nullptr,
224 bool by_element = false) const;
225
226 /** @brief Map {r,s,t} coordinates from [-1,1] to [0,1] for MFEM. For
227 * simplices, find the original element number (that was split into
228 * micro quads/hexes) during the setup phase. */
229 virtual void MapRefPosAndElemIndices();
230
231 /// FindPoints locally on device for 3D.
232 void FindPointsLocal3(const Vector &point_pos, int point_pos_ordering,
233 Array<unsigned int> &gsl_code_dev_l,
234 Array<unsigned int> &gsl_elem_dev_l, Vector &gsl_ref_l,
235 Vector &gsl_dist_l, int npt);
236
237 /// FindPoints locally on device for 2D.
238 void FindPointsLocal2(const Vector &point_pos, int point_pos_ordering,
239 Array<unsigned int> &gsl_code_dev_l,
240 Array<unsigned int> &gsl_elem_dev_l, Vector &gsl_ref_l,
241 Vector &gsl_dist_l, int npt);
242
243 /// FindPoints locally on device for 3D surface elements.
244 void FindPointsSurfLocal3(const Vector &point_pos,
245 int point_pos_ordering,
246 Array<unsigned int> &gsl_code_dev_l,
247 Array<unsigned int> &gsl_elem_dev_l,
248 Vector &gsl_ref_l,
249 Vector &gsl_dist_l,
250 int npt);
251
252 /// FindPoints locally on device for 3D edge elements.
253 void FindPointsEdgeLocal3(const Vector &point_pos,
254 int point_pos_ordering,
255 Array<unsigned int> &gsl_code_dev_l,
256 Array<unsigned int> &gsl_elem_dev_l,
257 Vector &gsl_ref_l,
258 Vector &gsl_dist_l,
259 int npt);
260
261 /// FindPoints locally on device for 2D edge elements.
262 void FindPointsEdgeLocal2(const Vector &point_pos,
263 int point_pos_ordering,
264 Array<unsigned int> &gsl_code_dev_l,
265 Array<unsigned int> &gsl_elem_dev_l,
266 Vector &gsl_ref_l,
267 Vector &gsl_dist_l,
268 int npt);
269
270 /// Interpolate on device for 3D.
271 void InterpolateLocal3(const Vector &field_in,
272 Array<int> &gsl_elem_dev_l,
273 Vector &gsl_ref_l,
274 Vector &field_out,
275 int npt, int ncomp,
276 int dof1dsol);
277
278 /// Interpolate on device for 2D.
279 void InterpolateLocal2(const Vector &field_in,
280 Array<int> &gsl_elem_dev_l,
281 Vector &gsl_ref_l,
282 Vector &field_out,
283 int npt, int ncomp,
284 int dof1dsol);
285
286 /// Interpolate on device for 1D.
287 void InterpolateLocal1(const Vector &field_in,
288 Array<int> &gsl_elem_dev_l,
289 Vector &gsl_ref_l,
290 Vector &field_out,
291 int npt, int ncomp, int dof1dsol);
292
293 /// Prepare data for device execution for volume meshes.
294 void SetupDevice();
295
296 /** @brief Searches positions given in physical space by @a point_pos.
297 These positions can be ordered byNodes: (XXX...,YYY...,ZZZ) or
298 byVDim: (XYZ,XYZ,....XYZ) specified by @a point_pos_ordering. */
299 void FindPointsOnDevice(const Vector &point_pos,
300 const int point_pos_ordering = Ordering::byNODES);
301
302 /** @brief Interpolation of field values at prescribed reference space
303 * positions.
304 * @param[in] field_in_evec E-vector of grid function to be interpolated.
305 * Assumed ordering is NDOFSxVDIMxNEL
306 * @param[in] nel Number of elements in the mesh.
307 * @param[in] ncomp Number of components in the field.
308 * @param[in] dof1dsol Number of degrees of freedom in each reference
309 * space direction.
310 * @param[in] ordering Ordering of the out field values: byNodes/byVDIM
311 *
312 * @param[out] field_out Interpolated values. For points that are not
313 * found the value is set to
314 * #default_interp_value. */
315 void InterpolateOnDevice(const Vector &field_in_evec, Vector &field_out,
316 const int nel, const int ncomp,
317 const int dof1dsol, const int ordering);
318
319 /** @brief Interpolation of field values at prescribed reference space
320 * positions for surface meshes. */
321 void InterpolateSurfBase(const Vector &field_in, Vector &field_out,
322 const int nel, const int ncomp,
323 const int dof1dsol, const int field_out_ordering);
324
325 /// Preprocess 2D surface mesh needed for FindPoints.
326 void FindPointsEdgeSetup2(DevStruct &devs,
327 const double *const elx[2],
328 const unsigned n,
329 const unsigned int nel,
330 const unsigned m,
331 const double bbox_rel_size_inc,
332 const unsigned int local_hash_size,
333 const unsigned int global_hash_size,
334 const Vector *aabb_sz_inc);
335
336 /// Preprocess 3D surface mesh needed for FindPoints.
337 void FindPointsSurfSetup3(DevStruct &devs,
338 const double *const elx[3],
339 const unsigned n,
340 const unsigned int nel,
341 const unsigned m,
342 const double bbox_rel_size_inc,
343 const unsigned int local_hash_size,
344 const unsigned int global_hash_size,
345 const int rD,
346 const Vector *aabb_sz_inc);
347
348 /** @brief Shared implementation for the public surface-setup methods.
349 *
350 * @details Initializes the surface-search data structures, builds the
351 * split-element representation expected by gslib, and constructs the
352 * element bounding boxes used by the MFEM surface kernels.
353 *
354 * If @a aabb_sz_inc is null, the setup stores the default oriented
355 * bounding boxes and uses @a bbox_rel_size_inc as their relative size
356 * increase factor.
357 *
358 * If @a aabb_sz_inc is non-null, the setup stores axis-aligned bounding
359 * boxes only, applies the requested absolute AABB expansion in each
360 * physical direction, and adjusts the tolerance @a bdr_tol so points
361 * found in the expanded region are classified as border points.
362 *
363 * @param[in] m Input surface mesh.
364 * @param[in] bbox_rel_size_inc Relative size increase applied when
365 * expanding each element bounding box during
366 * setup.
367 * @param[in] aabb_sz_inc Optional total absolute AABB expansion
368 * applied to the stored axis-aligned
369 * bounding boxes after construction.
370 * @param[in] newt_tol Newton tolerance for the point-search
371 * kernels.
372 */
373 void SetupSurfBase(Mesh &m,
374 const double bbox_rel_size_inc,
375 const Vector *aabb_sz_inc,
376 const double newt_tol);
377public:
378 /// Serial constructor
380
381 /// Serial constructor + setup with given Mesh (see \ref Setup)
382 FindPointsGSLIB(Mesh &mesh_in, const double bbox_rel_size_inc = 0.1,
383 const double newt_tol = 1.0e-12,
384 const int npt_max = 256);
385
386#ifdef MFEM_USE_MPI
387 /// Constructor for ParMesh
388 FindPointsGSLIB(MPI_Comm comm_);
389
390 /// Constructor + setup with given ParMesh (see \ref Setup)
391 FindPointsGSLIB(ParMesh &mesh_in, const double bbox_rel_size_inc = 0.1,
392 const double newt_tol = 1.0e-12,
393 const int npt_max = 256);
394#endif
395
396 virtual ~FindPointsGSLIB();
399
400 /** @brief Preprocess the internal mesh in gslib.
401
402 @details Initializes the internal mesh in gslib, by sending the
403 positions of the Gauss-Lobatto nodes of the input Mesh object \p m.
404 Note: not tested with periodic (L2).
405 Note: the input mesh \p m must have Nodes set.
406
407 @param[in] m Input mesh.
408 @param[in] bbox_rel_size_inc (Optional) Relative size increase applied
409 when expanding each element bounding box.
410 @param[in] newt_tol (Optional) Newton tolerance for the gslib
411 search methods.
412 @param[in] npt_max (Optional) Number of points for
413 simultaneous iteration. This alters
414 performance and memory footprint.
415 */
416 void Setup(Mesh &m, const double bbox_rel_size_inc = 0.1,
417 const double newt_tol = 1.0e-12,
418 const int npt_max = 256);
419
420 /// Preprocess the surface mesh to compute data for FindPoints.
421 void SetupSurf(Mesh &m,
422 const double bbox_rel_size_inc = 0.1,
423 const double newt_tol = 1.0e-12);
424
425 /** @brief Preprocess the surface mesh to compute data for FindPoints using
426 * absolute AABB expansion.
427 *
428 * @details This method computes only axis-aligned bounding boxes and
429 * increases their total length by a user-specified amount in each
430 * physical direction. The absolute AABB expansion is applied
431 * symmetrically to the lower and upper bounds.
432 *
433 * The size of @a aabb_sz_inc determines how the expansion values are
434 * interpreted:
435 * - `1`: one expansion value used in every direction for every element
436 * - `NElements`: one expansion value per element, reused in x/y/z
437 * directions
438 * - `SpaceDim`: one expansion value per physical direction, reused for
439 * every element
440 * - `NElements*SpaceDim`: one expansion value per element and direction,
441 * ordered as `(dx1,dy1,dz1, ... dxN,dyN,dzN)`
442 *
443 * This method disables the oriented bounding-box precheck because the
444 * stored boxes are modified only in their axis-aligned representation.
445 *
446 * @param[in] m Input surface mesh.
447 * @param[in] aabb_sz_inc Total absolute AABB expansion applied in
448 * each physical direction to the stored
449 * axis-aligned bounding boxes.
450 * @param[in] newt_tol Newton tolerance for the point-search
451 * kernels.
452 *
453 * @note We disable the oriented bounding box check with this setup.
454 * @a bdr_tol is also adjusted so that all points in the AABBs can
455 * be found.
456 */
457 void SetupSurfWithAABBExpansion(Mesh &m, const Vector &aabb_sz_inc,
458 const double newt_tol = 1.0e-12);
459
460
461 /** @brief Searches positions given in physical space by \p point_pos.
462
463 @details These positions can be ordered byNodes: (XXX...,YYY...,ZZZ) or
464 byVDim: (XYZ,XYZ,....XYZ) specified by \p point_pos_ordering.
465
466 This function populates the following member variables:
467 #gsl_code Return codes for each point: inside element (0),
468 element boundary (1), not found (2).
469 #gsl_proc MPI proc ids where the points were found.
470 #gsl_elem Element ids where the points were found.
471 Defaults to 0 for points that were not found.
472 #gsl_mfem_elem Element ids corresponding to MFEM-mesh where the points
473 were found. #gsl_mfem_elem != #gsl_elem for simplices
474 Defaults to 0 for points that were not found.
475 #gsl_ref Reference coordinates of the found point.
476 Ordered by vdim (XYZ,XYZ,XYZ...). Defaults to -1 for
477 points that were not found. Note: the gslib reference
478 frame is [-1,1].
479 #gsl_mfem_ref Reference coordinates #gsl_ref mapped to [0,1].
480 Defaults to 0 for points that were not found.
481 #gsl_dist Distance between the sought and the found point
482 in physical space. */
483 void FindPoints(const Vector &point_pos,
484 int point_pos_ordering = Ordering::byNODES);
485
486 /// Convenience function when point positions are in a ParticleVector
487 void FindPoints(const ParticleVector &point_pos)
488 {
489 FindPoints(point_pos, point_pos.GetOrdering());
490 }
491
492 /** @brief Searches positions given in physical space by \p point_pos on
493 * surface mesh. */
494 void FindPointsSurf(const Vector &point_pos,
495 int point_pos_ordering = Ordering::byNODES);
496
497 /// Convenience function when point positions are in a ParticleVector
498 void FindPointsSurf(const ParticleVector &point_pos)
499 {
500 FindPointsSurf(point_pos, point_pos.GetOrdering());
501 }
502
503 /// Setup FindPoints and search positions
504 void FindPoints(Mesh &m, const Vector &point_pos,
505 const int point_pos_ordering = Ordering::byNODES,
506 const double bbox_rel_size_inc = 0.1,
507 const double newt_tol = 1.0e-12,
508 const int npt_max = 256);
509
510 /** @brief Interpolation of field values at prescribed reference space
511 * positions.
512
513 @param[in] field_in Function values that will be interpolated on the
514 reference positions. Note: it is assumed that
515 \p field_in is in H1 and in the same space as the
516 mesh that was given to Setup().
517 @param[out] field_out Interpolated values. For points that are not found
518 the value is set to #default_interp_value.
519 The output ordering is determined from field_in.
520
521 @note: field_out is moved to device if field_in is on device. Otherwise,
522 field_out memory allocation is not changed.
523 */
524 virtual void Interpolate(const GridFunction &field_in, Vector &field_out);
525
526 /// Interpolation of field values, with output ordering specification.
527 virtual void Interpolate(const GridFunction &field_in, Vector &field_out,
528 const int field_out_ordering);
529
530 /** @brief Same as Interpolate but for surface meshes */
531 virtual void InterpolateSurf(const GridFunction &field_in,
532 Vector &field_out);
533
534 /** @brief Same as Interpolate but for surface meshes with specified output
535 ordering */
536 virtual void InterpolateSurf(const GridFunction &field_in,
537 Vector &field_out,
538 const int field_out_ordering);
539
540 /** @brief Search positions and interpolate.
541 *
542 * @details The ordering (byNODES or byVDIM) of the output values in
543 * \p field_out corresponds to the ordering used in the input
544 * GridFunction \p field_in.
545 */
546 void Interpolate(const Vector &point_pos, const GridFunction &field_in,
547 Vector &field_out,
548 int point_pos_ordering = Ordering::byNODES);
549
550 /// Search positions and interpolate with given point and output ordering.
551 void Interpolate(const Vector &point_pos, const GridFunction &field_in,
552 Vector &field_out, const int point_pos_ordering,
553 const int field_out_ordering);
554
555 /** Setup FindPoints, search positions and interpolate. The ordering (byNODES
556 or byVDIM) of the output values in \p field_out corresponds to the
557 ordering used in the input GridFunction \p field_in. */
558 void Interpolate(Mesh &m, const Vector &point_pos,
559 const GridFunction &field_in, Vector &field_out,
560 const int point_pos_ordering = Ordering::byNODES);
561
562 /** @brief Average type to be used for L2 functions in-case a point is
563 * located at an element boundary where the function might be multi-valued.
564 */
565 virtual void SetL2AvgType(AvgType avgtype_) { avgtype = avgtype_; }
566
567 /** @brief Set the default interpolation value for points that are not found in the mesh. */
568 virtual void SetDefaultInterpolationValue(double interp_value_)
569 {
570 default_interp_value = interp_value_;
571 }
572
573 /** @brief Tolerance for detecting points outside the 'curvilinear' boundary.
574 *
575 * @details When using FindPoints, gslib may return points as found on the
576 * boundary even when they are slightly outside the domain. This tolerance
577 * is used to filter such points based on the distance^2 value and mark them
578 * as not found.
579 *
580 * @note When the SetupSurfWithAABBExpansion method is used for surface
581 * meshes, this tolerance is automatically computed based on the size of
582 * expanded AABBs. Using this method will override that computed tolerance.
583 * */
585 {
586 bdr_tol = bdr_tol_;
587 }
588
589 /** @brief Enable/Disable use of CPU functions for GPU data if the gslib
590 * version is older. */
591 virtual void SetGPUtoCPUFallback(bool mode) { gpu_to_cpu_fallback = mode; }
592
593 /** @brief Cleans up memory allocated internally by gslib.
594
595 @details Note that in parallel, this must be called before MPI_Finalize,
596 as it calls MPI_Comm_free() for internal gslib communicators. FreeData is
597 also called by the class destructor and there are no memory leaks if the
598 destructor is called before MPI_Finalize(). If the destructor is called
599 after MPI_Finalize(), there will be an error because gslib will try to
600 invoke some MPI functions.
601 */
602 virtual void FreeData();
603
604 /** @brief Return code for each point searched by FindPoints:
605 * inside element (0), element boundary (1), or not found (2). */
606 virtual const Array<unsigned int> &GetCode() const { return gsl_code; }
607 /// Return element number for each point found by FindPoints.
608 virtual const Array<unsigned int> &GetElem() const { return gsl_mfem_elem; }
609 /// Return MPI rank on which each point was found by FindPoints.
610 virtual const Array<unsigned int> &GetProc() const { return gsl_proc; }
611 /// Return reference coordinates for each point found by FindPoints.
612 virtual const Vector &GetReferencePosition() const { return gsl_mfem_ref; }
613 /// Return distance between the sought and the found point in physical space.
614 virtual const Vector &GetDist() const { return gsl_dist; }
615
616 /** @brief Return element number for each point found by FindPoints
617 * corresponding to GSLIB mesh. gsl_mfem_elem != gsl_elem for mesh with
618 * simplices. */
619 virtual const Array<unsigned int> &GetGSLIBElem() const { return gsl_elem; }
620 /** @brief Return reference coordinates in [-1,1] (internal range in GSLIB)
621 * for each point found by FindPoints. */
622 virtual const Vector &GetGSLIBReferencePosition() const { return gsl_ref; }
623
624 /// Get array of indices of not-found points.
626
627 /** @name Methods to support a custom interpolation procedure.
628 \brief The physical-space point that the user seeks to interpolate at
629 could be located inside an element on another mpi rank.
630 To enable a custom interpolation procedure (e.g., strain tensor computation)
631 we need a mechanism to first send element indices and reference-space
632 coordinates to the mpi-ranks where each point is found. Then the custom
633 interpolation can be done locally by the user before sending the
634 interpolated values back to the mpi-ranks that the query originated from.
635 Example usage looks something like this:
636
637 FindPoints() -> DistributePointInfoToOwningMPIRanks() -> Computation by
638 user -> DistributeInterpolatedValues().
639 */
640 ///@{
641 /// Distribute element indices in #gsl_mfem_elem, the reference coordinates
642 /// #gsl_mfem_ref, and the code #gsl_code to the corresponding mpi-rank
643 /// #gsl_proc for each point. The received information is provided locally
644 /// in \p recv_elem, \p recv_ref (ordered by vdim), and \p recv_code.
645 /// Note: The user can send empty Array/Vectors to the method as they are
646 /// appropriately sized and filled internally.
648 Array<unsigned int> &recv_elem, Vector &recv_ref,
649 Array<unsigned int> &recv_code);
650 /// Return interpolated values back to the mpi-ranks #recv_proc that had
651 /// sent the element indices and corresponding reference-space coordinates.
652 /// Specify \p vdim and \p ordering (by nodes or by vdim) based on how the
653 /// \p int_vals are structured. The received values are filled in
654 /// \p field_out consistent with the original ordering of the points that
655 /// were used in \ref FindPoints.
656 virtual void DistributeInterpolatedValues(const Vector &int_vals,
657 const int vdim,
658 const int ordering,
659 Vector &field_out) const;
660 ///@}
661
662 /// Return the axis-aligned bounding boxes (AABB) computed during \ref Setup.
663 /// The size of the returned vector is (nel x nverts x dim), where nel is the
664 /// number of elements (after splitting for simplicies), nverts is number of
665 /// vertices (4 in 2D, 8 in 3D), and dim is the spatial dimension.
666 void GetAxisAlignedBoundingBoxes(Vector &aabb) const;
667
668 /// Return the oriented bounding boxes (OBB) computed during \ref Setup.
669 /// Each OBB is represented using the inverse transformation (A^{-1}) and
670 /// its center (x_c), such that a point x is inside the OBB if:
671 /// -1 <= A^{-1}(x-x_c) <= 1.
672 /// The inverse transformation is returned in \p obbA, a DenseTensor of
673 /// size (dim x dim x nel), and the OBB centers are returned in \p obbC,
674 /// a vector of size (nel x dim). The vertices of the OBBs are returned in
675 /// \p obbV, a vector of size (nel x nverts x dim) .
677 Vector &obbV) const;
678
679 /** @brief Return the bounding boxes as a mesh on rank 0.
680 *
681 * @param[in] type Bounding-box type: 0 - AABB, 1 - OBB.
682 *
683 * @return On rank 0, returns a newly allocated mesh containing the
684 * bounding boxes. The caller owns the returned pointer and is responsible
685 * for deleting it. On other ranks, returns nullptr.
686 */
687 Mesh *GetBoundingBoxMesh(int type);
688
689 /// Return the internal vector of mesh node coordinates at the GLL points.
690 virtual const Vector &GetGLLMesh() const { return gsl_mesh; }
691};
692
693/** \brief OversetFindPointsGSLIB enables use of findpts for arbitrary number of
694 overlapping grids.
695
696 The parameters in this class are the same as FindPointsGSLIB with the
697 difference of additional inputs required to account for more than 1 mesh. */
699{
700protected:
702 unsigned int u_meshid;
703 Vector distfint; // Used to store nodal vals of grid func. passed to findpts
704
705public:
708
709#ifdef MFEM_USE_MPI
710 OversetFindPointsGSLIB(MPI_Comm comm_) : FindPointsGSLIB(comm_),
711 overset(true) { }
712#endif
713
714 /** Initializes the internal mesh in gslib, by sending the positions of the
715 Gauss-Lobatto nodes of the input Mesh object \p m.
716 Note: not tested with periodic meshes (L2).
717 Note: the input mesh \p m must have Nodes set.
718
719 @param[in] m Input mesh.
720 @param[in] meshid A unique # for each overlapping mesh.
721 This id is used to make sure that points
722 being searched are not looked for in the
723 mesh that they belong to.
724 @param[in] gfmax (Optional) GridFunction in H1 that is used
725 as a discriminator when one point is
726 located in multiple meshes. The mesh that
727 maximizes gfmax is chosen. For example,
728 using the distance field based on the
729 overlapping boundaries is helpful for
730 convergence during Schwarz iterations.
731 @param[in] bbox_rel_size_inc (Optional) Relative size increase applied
732 when expanding each element bounding box.
733 @param[in] newt_tol (Optional) Newton tolerance for the gslib
734 search methods.
735 @param[in] npt_max (Optional) Number of points for
736 simultaneous iteration. This alters
737 performance and memory footprint.*/
738 void Setup(Mesh &m, const int meshid, GridFunction *gfmax = nullptr,
739 const double bbox_rel_size_inc = 0.1,
740 const double newt_tol = 1.0e-12,
741 const int npt_max = 256);
742
743 /** Searches positions given in physical space by \p point_pos. All output
744 Arrays and Vectors are expected to have the correct size.
745
746 @param[in] point_pos Positions to be found.
747 @param[in] point_id Index of the mesh that the point belongs
748 to (corresponding to \p meshid in Setup).
749 @param[in] point_pos_ordering Ordering of the points:
750 byNodes: (XXX...,YYY...,ZZZ) or
751 byVDim: (XYZ,XYZ,....XYZ) */
752 void FindPoints(const Vector &point_pos,
753 const Array<unsigned int> &point_id,
754 const int point_pos_ordering = Ordering::byNODES);
755
756 /** Search positions and interpolate */
757 void Interpolate(const Vector &point_pos,
758 const Array<unsigned int> &point_id,
759 const GridFunction &field_in, Vector &field_out,
760 const int point_pos_ordering = Ordering::byNODES);
762};
763
764/** \brief Class for gather-scatter (gs) operations on Vectors based on
765 corresponding global identifiers.
766
767 This functionality is useful for gs-ops on DOF values across processor
768 boundary, where the global identifier would be the corresponding true DOF
769 index. Operations currently supported are min, max, sum, and multiplication.
770 Note: identifier 0 does not participate in the gather-scatter operation and
771 a given identifier can be included multiple times on a given rank.
772 For example, consider a vector, v:
773 - v = [0.3, 0.4, 0.25, 0.7] on rank1,
774 - v = [0.6, 0.1] on rank 2,
775 - v = [-0.2, 0.3, 0.7, 0.] on rank 3.
776
777 Consider a corresponding Array<int>, a:
778 - a = [1, 2, 3, 1] on rank 1,
779 - a = [3, 2] on rank 2,
780 - a = [1, 2, 0, 3] on rank 3.
781
782 A gather-scatter "minimum" operation, done as follows:
783 GSOPGSLIB gs = GSOPGSLIB(MPI_COMM_WORLD, a);
784 gs.GS(v, GSOp::MIN);
785 would return into v:
786 - v = [-0.2, 0.1, 0., -0.2] on rank 1,
787 - v = [0., 0.1] on rank 2,
788 - v = [-0.2, 0.1, 0.7, 0.] on rank 3,
789 where the values have been compared across all processors based on the
790 integer identifier. */
792{
793protected:
794 struct gslib::crystal *cr; // gslib's internal data
795 struct gslib::comm *gsl_comm; // gslib's internal data
796 struct gslib::gs_data *gsl_data = nullptr;
798
799public:
801
802#ifdef MFEM_USE_MPI
803 GSOPGSLIB(MPI_Comm comm_, Array<long long> &ids);
804#endif
805
806 virtual ~GSOPGSLIB();
807
808 /// Supported operation types. See class description.
809 enum GSOp {ADD, MUL, MIN, MAX};
810
811 /// Update the identifiers used for the gather-scatter operator.
812 /// Same \p ids get grouped together and id == 0 does not participate.
813 /// See class description.
814 void UpdateIdentifiers(const Array<long long> &ids);
815
816 /// Gather-Scatter operation on senddata. Must match length of unique
817 /// identifiers used in the constructor. See class description.
818 void GS(Vector &senddata, GSOp op);
819};
820
821#if defined(MFEM_USE_MPI)
822/** \brief Class to map a point in physical space to candidate ranks.
823 *
824 * This class builds a Cartesian-aligned tensor grid that covers the entire
825 * domain and precomputes which ranks have elements intersecting each
826 * grid cell. Given a point in physical space, the grid cell containing
827 * the point is determined, and the list of candidate ranks whose
828 * elements intersect that cell is returned. This yields a fast, conservative
829 * point-to-rank candidate query. This is used internally by FindPointsGSLIB
830 * to speed up point searches in parallel.
831 *
832 * See Mittal et al., "General Field Evaluation in High-Order Meshes on GPUs".
833 * (2025). Computers & Fluids. for technical details.
834 *
835 */
837{
838private:
839 struct gslib::crystal *cr = nullptr; // gslib's internal data
840 struct gslib::comm *gsl_comm = nullptr; // gslib's internal data
841 int sdim, n_local_cells, num_procs;
842 Array<int> gmap_n;
843 Vector gmap_bnd_min, gmap_bnd_max;
844 Vector gmap_fac;
845 Array<int> ggrid_map;
846
847 void SetupCrystal(const MPI_Comm &comm);
848public:
849 /// Constructor for a given mesh and number of tensor grid divisions
850 GlobalBBoxTensorGridMap(ParMesh &pmesh, int nx);
851
852 /** @brief Constructor for given element bounds and spatial dimension.
853 *
854 * @details This constructor must be called collectively on \a comm.
855 * Supports spatial dimensions 1, 2, and 3, and accepts nel == 0 on a rank.
856 *
857 * Assumes elmin, elmax Ordering::byNodes:
858 * elmin -> [x_{0,min},x_{1,min},... ,y_{0,min},y_{1,min},..,z_{nel-1,min}]
859 * elmax -> [x_{0,max},x_{1,max},... ,y_{0,max},y_{1,max},..,z_{nel-1,max}]
860 * Note elmin, elmax can be obtained using GridFunction::GetElementBounds()
861 *
862 * When by_max_size=false, n gives the number of tensor-grid divisions in
863 * each direction. When by_max_size=true, n is a per-rank size hint used to
864 * derive a uniform global resolution. The communicator-wide sum of n is
865 * converted to nx = ceil(pow(sum(n), 1./sdim)) in each direction, so n is
866 * not a hard cap on ggrid_map.Size().
867 */
868 GlobalBBoxTensorGridMap(const MPI_Comm &comm, Vector &elmin,
869 Vector &elmax, int nel, int sdim, int n,
870 bool by_max_size);
871
872 /** @brief Constructor for given element bounds, spatial dimension, and
873 * tensor-grid divisions in each direction.
874 *
875 * @details This constructor must be called collectively on \a comm.
876 * Supports spatial dimensions 1, 2, and 3, and accepts nel == 0 on a rank.
877 * Requires nx.Size() == sdim and positive entries in nx.
878 *
879 * Assumes elmin, elmax Ordering::byNodes:
880 * elmin -> [x_{0,min},x_{1,min},... ,y_{0,min},y_{1,min},..,z_{nel-1,min}]
881 * elmax -> [x_{0,max},x_{1,max},... ,y_{0,max},y_{1,max},..,z_{nel-1,max}]
882 * Note elmin, elmax can be obtained using GridFunction::GetElementBounds()
883 */
884 GlobalBBoxTensorGridMap(const MPI_Comm &comm, Vector &elmin,
885 Vector &elmax, int nel, int sdim, Array<int> &nx);
886
888
889 /** @brief Get list of procs corresponding to the list of points.
890 *
891 * @details This method must be called collectively on the communicator
892 * used to construct the map. The input points can be ordered byNodes:
893 * (XXX...,YYY...,ZZZ) or byVDIM: (XYZ,XYZ,...), as specified by
894 * \a ordering.
895 *
896 * The output map contains one entry for each input point, keyed by the
897 * point's local index in \a xyz. Points with no candidate ranks, including
898 * points outside the global bounding box, have an empty list of candidate
899 * ranks.
900 */
901 void MapPointsToProcs(Vector &xyz, int ordering,
902 std::map<int, std::vector<int>> &pt_to_procs) const;
903
904 /// Return this rank's portion of the distributed map from grid cells to
905 /// candidate MPI ranks (CSR data, indexed by rank-local cell index).
906 const Array<int> &GetGridMap() const { return ggrid_map; }
907 /// Return the number of grid cells per unit extent in each direction.
908 const Vector &GetGridFac() const { return gmap_fac; }
909 /// Return the minimum extent of the grid in each direction.
910 const Vector &GetGridMin() const { return gmap_bnd_min; }
911 /// Return the maximum extent of the grid in each direction.
912 const Vector &GetGridMax() const { return gmap_bnd_max; }
913 /// Return the grid resolution (number of cells) in each direction.
914 const Array<int> &GetGridN() const { return gmap_n; }
915
916private:
917 /// Setup the map given element bounds and number of tensor grid divisions.
918 void Setup(const MPI_Comm &comm, Vector &elmin, Vector &elmax,
919 int nel, Array<int> &nx);
920
921 /// Get global hash cell index for a given point.
922 int GetGlobalGridCellFromPoint(Vector &xyz) const;
923
924 /** @brief Get owning proc and local index on that proc for given global
925 * grid cell index. */
926 void GlobalGridCellToProcAndLocalIndex(int i, int &proc, int &idx) const;
927
928 /// Map a point to proc and local index of the corresponding grid cell
929 void GetProcAndLocalIndexFromPoint(Vector &xyz, int &proc, int &idx) const;
930
931 /// Given local cell index, return list of procs saved in the map
932 Array<int> MapCellToProcs(int l_idx) const;
933};
934#endif // MFEM_USE_MPI
935
936} // namespace mfem
937
938#endif // MFEM_USE_GSLIB
939
940#endif // MFEM_GSLIB
Rank 3 tensor (array of matrices)
FindPointsGSLIB can robustly evaluate a GridFunction on an arbitrary collection of points....
Definition gslib.hpp:115
virtual void DistributePointInfoToOwningMPIRanks(Array< unsigned int > &recv_elem, Vector &recv_ref, Array< unsigned int > &recv_code)
Definition gslib.cpp:4258
void GetAxisAlignedBoundingBoxes(Vector &aabb) const
Definition gslib.cpp:4373
virtual ~FindPointsGSLIB()
Definition gslib.cpp:240
void FindPointsSurf(const ParticleVector &point_pos)
Convenience function when point positions are in a ParticleVector.
Definition gslib.hpp:498
void FindPointsEdgeLocal2(const Vector &point_pos, int point_pos_ordering, Array< unsigned int > &gsl_code_dev_l, Array< unsigned int > &gsl_elem_dev_l, Vector &gsl_ref_l, Vector &gsl_dist_l, int npt)
FindPoints locally on device for 2D edge elements.
void FindPointsOnDevice(const Vector &point_pos, const int point_pos_ordering=Ordering::byNODES)
Searches positions given in physical space by point_pos. These positions can be ordered byNodes: (XXX...
Definition gslib.cpp:1634
Array< unsigned int > gsl_code
Definition gslib.hpp:137
Array< Mesh * > mesh_split
Definition gslib.hpp:121
void FindPoints(const ParticleVector &point_pos)
Convenience function when point positions are in a ParticleVector.
Definition gslib.hpp:487
virtual void GetNodalValues(const GridFunction *gf_in, Vector &node_vals, const Array< IntegrationRule * > *ir_in=nullptr, bool by_element=false) const
Get GridFunction value at the points expected by GSLIB.
Definition gslib.cpp:3364
virtual const Vector & GetDist() const
Return distance between the sought and the found point in physical space.
Definition gslib.hpp:614
virtual void InterpolateGeneral(const GridFunction &field_in, Vector &field_out, const int field_out_ordering)
Definition gslib.cpp:4073
virtual void InterpolateH1(const GridFunction &field_in, Vector &field_out, const int field_out_ordering)
Definition gslib.cpp:3993
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
void FindPointsSurfSetup3(DevStruct &devs, const double *const elx[3], const unsigned n, const unsigned int nel, const unsigned m, const double bbox_rel_size_inc, const unsigned int local_hash_size, const unsigned int global_hash_size, const int rD, const Vector *aabb_sz_inc)
Preprocess 3D surface mesh needed for FindPoints.
Definition gslib.cpp:1003
void FindPointsLocal3(const Vector &point_pos, int point_pos_ordering, Array< unsigned int > &gsl_code_dev_l, Array< unsigned int > &gsl_elem_dev_l, Vector &gsl_ref_l, Vector &gsl_dist_l, int npt)
FindPoints locally on device for 3D.
virtual const Vector & GetReferencePosition() const
Return reference coordinates for each point found by FindPoints.
Definition gslib.hpp:612
void SetupSurf(Mesh &m, const double bbox_rel_size_inc=0.1, const double newt_tol=1.0e-12)
Preprocess the surface mesh to compute data for FindPoints.
Definition gslib.cpp:1193
Array< int > split_element_geom
Definition gslib.hpp:146
virtual void Interpolate(const GridFunction &field_in, Vector &field_out)
Interpolation of field values at prescribed reference space positions.
Definition gslib.cpp:3679
Array< FiniteElementSpace * > fes_rst_map
Definition gslib.hpp:130
virtual void SetGPUtoCPUFallback(bool mode)
Enable/Disable use of CPU functions for GPU data if the gslib version is older.
Definition gslib.hpp:591
Mesh * GetBoundingBoxMesh(int type)
Return the bounding boxes as a mesh on rank 0.
Definition gslib.cpp:4474
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
Array< int > split_element_index
Definition gslib.hpp:144
FiniteElementCollection * fec_map_lin
Definition gslib.hpp:132
FindPointsGSLIB()
Serial constructor.
Definition gslib.cpp:200
virtual const Array< unsigned int > & GetElem() const
Return element number for each point found by FindPoints.
Definition gslib.hpp:608
virtual void DistributeInterpolatedValues(const Vector &int_vals, const int vdim, const int ordering, Vector &field_out) const
Definition gslib.cpp:4317
struct gslib::comm * gsl_comm
Definition gslib.hpp:135
Array< unsigned int > gsl_elem
Definition gslib.hpp:137
Array< unsigned int > recv_proc
Definition gslib.hpp:139
virtual const Array< unsigned int > & GetGSLIBElem() const
Return element number for each point found by FindPoints corresponding to GSLIB mesh....
Definition gslib.hpp:619
virtual void SetupSplitMeshesAndIntegrationRules(const int order)
Helper function that calls SetupSplitMeshes and SetupIntegrationRules.
Definition gslib.cpp:3316
Array< unsigned int > gsl_proc
Definition gslib.hpp:137
virtual void SetupIntegrationRuleForSplitMesh(Mesh *mesh, IntegrationRule *irule, int order)
Setup integration points that will be used to interpolate the nodal location at points expected by GS...
Definition gslib.cpp:3222
virtual const Vector & GetGSLIBReferencePosition() const
Return reference coordinates in [-1,1] (internal range in GSLIB) for each point found by FindPoints.
Definition gslib.hpp:622
void InterpolateLocal3(const Vector &field_in, Array< int > &gsl_elem_dev_l, Vector &gsl_ref_l, Vector &field_out, int npt, int ncomp, int dof1dsol)
Interpolate on device for 3D.
Array< unsigned int > gsl_mfem_elem
Definition gslib.hpp:137
Array< IntegrationRule * > ir_split
Definition gslib.hpp:124
void FindPointsEdgeLocal3(const Vector &point_pos, int point_pos_ordering, Array< unsigned int > &gsl_code_dev_l, Array< unsigned int > &gsl_elem_dev_l, Vector &gsl_ref_l, Vector &gsl_dist_l, int npt)
FindPoints locally on device for 3D edge elements.
void GetOrientedBoundingBoxes(DenseTensor &obbA, Vector &obbC, Vector &obbV) const
Definition gslib.cpp:4589
virtual const Vector & GetGLLMesh() const
Return the internal vector of mesh node coordinates at the GLL points.
Definition gslib.hpp:690
double default_interp_value
Definition gslib.hpp:141
void FindPointsEdgeSetup2(DevStruct &devs, const double *const elx[2], const unsigned n, const unsigned int nel, const unsigned m, const double bbox_rel_size_inc, const unsigned int local_hash_size, const unsigned int global_hash_size, const Vector *aabb_sz_inc)
Preprocess 2D surface mesh needed for FindPoints.
Definition gslib.cpp:1093
Array< IntegrationRule * > ir_split_sol
Definition gslib.hpp:127
virtual void SetupSplitMeshes()
Since GSLIB is designed to work with quads/hexes, we split every triangle/tet/prism/pyramid element i...
Definition gslib.cpp:3026
virtual void MapRefPosAndElemIndices()
Map {r,s,t} coordinates from [-1,1] to [0,1] for MFEM. For simplices, find the original element numbe...
Definition gslib.cpp:3502
virtual void FreeData()
Cleans up memory allocated internally by gslib.
Definition gslib.cpp:2984
virtual void InterpolateSurf(const GridFunction &field_in, Vector &field_out)
Same as Interpolate but for surface meshes.
Definition gslib.cpp:3873
virtual void SetDefaultInterpolationValue(double interp_value_)
Set the default interpolation value for points that are not found in the mesh.
Definition gslib.hpp:568
Array< unsigned int > GetPointsNotFoundIndices() const
Get array of indices of not-found points.
Definition gslib.cpp:4244
FindPointsGSLIB & operator=(const FindPointsGSLIB &)=delete
void InterpolateLocal1(const Vector &field_in, Array< int > &gsl_elem_dev_l, Vector &gsl_ref_l, Vector &field_out, int npt, int ncomp, int dof1dsol)
Interpolate on device for 1D.
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
Array< GridFunction * > gf_rst_map
Definition gslib.hpp:131
void FindPointsSurfLocal3(const Vector &point_pos, int point_pos_ordering, Array< unsigned int > &gsl_code_dev_l, Array< unsigned int > &gsl_elem_dev_l, Vector &gsl_ref_l, Vector &gsl_dist_l, int npt)
FindPoints locally on device for 3D surface elements.
virtual void SetL2AvgType(AvgType avgtype_)
Average type to be used for L2 functions in-case a point is located at an element boundary where the ...
Definition gslib.hpp:565
virtual const Array< unsigned int > & GetProc() const
Return MPI rank on which each point was found by FindPoints.
Definition gslib.hpp:610
Array< int > split_element_map
Definition gslib.hpp:143
void SetupSurfBase(Mesh &m, const double bbox_rel_size_inc, const Vector *aabb_sz_inc, const double newt_tol)
Shared implementation for the public surface-setup methods.
Definition gslib.cpp:1207
void FindPointsSurf(const Vector &point_pos, int point_pos_ordering=Ordering::byNODES)
Searches positions given in physical space by point_pos on surface mesh.
Definition gslib.cpp:2235
FindPointsGSLIB(const FindPointsGSLIB &)=delete
void InterpolateOnDevice(const Vector &field_in_evec, Vector &field_out, const int nel, const int ncomp, const int dof1dsol, const int ordering)
Interpolation of field values at prescribed reference space positions.
Definition gslib.cpp:1988
Array< unsigned int > recv_index
Definition gslib.hpp:139
struct mfem::FindPointsGSLIB::DevStruct DEV
int ir_split_sol_order
Order at which ir_split_sol was built; -1 means not built.
Definition gslib.hpp:129
void InterpolateLocal2(const Vector &field_in, Array< int > &gsl_elem_dev_l, Vector &gsl_ref_l, Vector &field_out, int npt, int ncomp, int dof1dsol)
Interpolate on device for 2D.
void FindPointsLocal2(const Vector &point_pos, int point_pos_ordering, Array< unsigned int > &gsl_code_dev_l, Array< unsigned int > &gsl_elem_dev_l, Vector &gsl_ref_l, Vector &gsl_dist_l, int npt)
FindPoints locally on device for 2D.
virtual void SetupIntegrationRules(const int order, Array< IntegrationRule * > &ir_out)
Build integration rules at the given order for each split mesh and store them in ir_out....
Definition gslib.cpp:3273
void SetupDevice()
Prepare data for device execution for volume meshes.
Definition gslib.cpp:1507
virtual void SetDistanceToleranceForPointsFoundOnBoundary(double bdr_tol_)
Tolerance for detecting points outside the 'curvilinear' boundary.
Definition gslib.hpp:584
struct gslib::crystal * cr
Definition gslib.hpp:134
void InterpolateSurfBase(const Vector &field_in, Vector &field_out, const int nel, const int ncomp, const int dof1dsol, const int field_out_ordering)
Interpolation of field values at prescribed reference space positions for surface meshes.
Definition gslib.cpp:2730
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Definition fe_coll.hpp:27
Class for gather-scatter (gs) operations on Vectors based on corresponding global identifiers.
Definition gslib.hpp:792
struct gslib::comm * gsl_comm
Definition gslib.hpp:795
void GS(Vector &senddata, GSOp op)
Definition gslib.cpp:4965
GSOPGSLIB(Array< long long > &ids)
Definition gslib.cpp:4908
virtual ~GSOPGSLIB()
Definition gslib.cpp:4935
GSOp
Supported operation types. See class description.
Definition gslib.hpp:809
struct gslib::crystal * cr
Definition gslib.hpp:794
struct gslib::gs_data * gsl_data
Definition gslib.hpp:796
void UpdateIdentifiers(const Array< long long > &ids)
Definition gslib.cpp:4949
Class to map a point in physical space to candidate ranks.
Definition gslib.hpp:837
const Array< int > & GetGridMap() const
Definition gslib.hpp:906
const Vector & GetGridFac() const
Return the number of grid cells per unit extent in each direction.
Definition gslib.hpp:908
const Vector & GetGridMin() const
Return the minimum extent of the grid in each direction.
Definition gslib.hpp:910
GlobalBBoxTensorGridMap(ParMesh &pmesh, int nx)
Constructor for a given mesh and number of tensor grid divisions.
Definition gslib.cpp:5003
void MapPointsToProcs(Vector &xyz, int ordering, std::map< int, std::vector< int > > &pt_to_procs) const
Get list of procs corresponding to the list of points.
Definition gslib.cpp:5312
const Vector & GetGridMax() const
Return the maximum extent of the grid in each direction.
Definition gslib.hpp:912
const Array< int > & GetGridN() const
Return the grid resolution (number of cells) in each direction.
Definition gslib.hpp:914
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:53
Class for an integration rule - an Array of IntegrationPoint.
Definition intrules.hpp:96
Mesh data type.
Definition mesh.hpp:67
OversetFindPointsGSLIB enables use of findpts for arbitrary number of overlapping grids.
Definition gslib.hpp:699
void Interpolate(const Vector &point_pos, const Array< unsigned int > &point_id, const GridFunction &field_in, Vector &field_out, const int point_pos_ordering=Ordering::byNODES)
Definition gslib.cpp:4898
void Setup(Mesh &m, const int meshid, GridFunction *gfmax=nullptr, const double bbox_rel_size_inc=0.1, const double newt_tol=1.0e-12, const int npt_max=256)
Definition gslib.cpp:4742
void FindPoints(const Vector &point_pos, const Array< unsigned int > &point_id, const int point_pos_ordering=Ordering::byNODES)
Definition gslib.cpp:4818
OversetFindPointsGSLIB(MPI_Comm comm_)
Definition gslib.hpp:710
Class for parallel meshes.
Definition pmesh.hpp:35
ParticleVector carries vector data (of a given vector dimension) for an arbitrary number of particles...
Ordering::Type GetOrdering() const
Get the ordering of data in the ParticleVector.
Vector data type.
Definition vector.hpp:82
struct gslib::hash_data_3 * hash3
Definition gslib.hpp:169
Array< unsigned int > lh_offset
Definition gslib.hpp:172
struct gslib::crystal * cr
Definition gslib.hpp:168
Array< unsigned int > gh_offset
Definition gslib.hpp:172
struct gslib::hash_data_2 * hash2
Definition gslib.hpp:170