MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
mfem::BBoxTensorGridMap Class Reference

Map a point in physical space to candidate elements of a curved mesh. More...

#include <bb_grid_map.hpp>

Public Member Functions

 BBoxTensorGridMap (Mesh &mesh, int nx)
 Constructor for a given mesh and resolution of Cartesian grid.
 
 BBoxTensorGridMap (Vector &elmin, Vector &elmax, int nel, int sdim, Array< int > &nx, bool by_max_size=false)
 Constructor with mesh element bounding boxes and spatial dimension.
 
 BBoxTensorGridMap (Vector &elmin, Vector &elmax, int nel, int sdim, int n, bool by_max_size=false)
 Constructor for given element bounds and spatial dimension.
 
Array< int > MapPointToElements (Vector &xyz) const
 Map a point to possible overlapping elements.
 
int GetGridCellFromPoint (Vector &xyz) const
 Get grid cell index for a given point.
 
Array< int > GridCellToElements (int i) const
 Get list of elements corresponding to a grid cell.
 
const Array< unsigned int > & GetGridMap () const
 
const VectorGetGridFac () const
 Return the number of grid cells per unit extent in each direction.
 
const VectorGetGridMin () const
 Return the minimum extent of the grid in each direction.
 
const VectorGetGridMax () const
 Return the maximum extent of the grid in each direction.
 
const Array< int > & GetGridN () const
 Return the grid resolution (number of cells) in each direction.
 

Static Public Member Functions

static void GetGridRange (const int d, const Array< int > &lh_n, const Vector &lh_fac, const Vector &lh_bnd_min, const real_t &xmin, const real_t &xmax, int &imin, int &imax)
 Get local (1D) indices for cells of tensor grid that intersect with the given bounding box.
 
static void SetGridFac (Vector &lh_fac, const Array< int > &nx, const Vector &lh_bnd_min, const Vector &lh_bnd_max)
 Set grid fac - number of grid cells per unit grid extent.
 
static int GetGridCountAndRange (const Array< int > &lh_n, const Vector &lh_fac, const Vector &lh_bnd_min, const Vector &lh_bnd_max, const Vector &elmin, const Vector &elmax, Array< int > &elmin_h, Array< int > &elmax_h)
 Get grid count and range - total number of grid cells that intersect with all elements of the mesh and get corresponding ranges.
 

Detailed Description

Map a point in physical space to candidate elements of a curved mesh.

This class builds a Cartesian-aligned tensor grid that covers the domain and precomputes, for each grid cell, the set of curved mesh elements whose axis-aligned bounding boxes (AABBs) intersect that cell. Given a point (xyz) in physical coordinates, the Cartesian grid cell containing the point is determined, and the list of candidate element indices whose AABBs are intersecting that cell is returned. This yields a fast, conservative point-to-element candidate query.

The mapping procedure uses a half-open interval convention in each dimension. If an element bounding-box minimum lies exactly on a grid-cell boundary, it is assigned to the cell on the right/high side of that boundary. If an element bounding-box maximum lies exactly on a grid-cell boundary, it is assigned to the cell on the left/low side.

The map itself is stored as a single array CSR structure where the offsets and values are stored in the same array. For a tensor grid with a total of N cells, the first N+1 entries store the offsets and the remaining entries store the values.

The "lgrid_map" looks something like this:

Index: 0 1 ... N N+1 ... Value: [start_0] [start_1] ... [Length(Map)] [elem_A] [elem_B] [elem_C]... | | ^ ^ | |__________________________|_________________| |_____________________________________|

For grid cell index i, the element indices are stored in lgrid_map[j], where lgrid_map[i] <= j < lgrid_map[i+1].

If lgrid_map[i] = lgrid_map[i+1], the grid cell i does not intersect any elements.

See Mittal et al., "General Field Evaluation in High-Order Meshes on GPUs". (2025). Computers & Fluids. for technical details.

Definition at line 103 of file bb_grid_map.hpp.

Constructor & Destructor Documentation

◆ BBoxTensorGridMap() [1/3]

mfem::BBoxTensorGridMap::BBoxTensorGridMap ( Mesh & mesh,
int nx )

Constructor for a given mesh and resolution of Cartesian grid.

Definition at line 63 of file bb_grid_map.cpp.

◆ BBoxTensorGridMap() [2/3]

mfem::BBoxTensorGridMap::BBoxTensorGridMap ( Vector & elmin,
Vector & elmax,
int nel,
int sdim,
Array< int > & nx,
bool by_max_size = false )

Constructor with mesh element bounding boxes and spatial dimension.

When by_max_size=false, nx gives the Cartesian grid resolution in each direction. When by_max_size=true, nx[0] gives the requested maximum size of lgrid_map. If nx[0] < 2 + nel, lgrid_map is resized to the minimum feasible size 2 + nel.

Assumes elmin, elmax Ordering::byNodes: elmin -> [x_{0,min},x_{1,min},... ,y_{0,min},y_{1,min},..,z_{nel-1,min}] elmax -> [x_{0,max},x_{1,max},... ,y_{0,max},y_{1,max},..,z_{nel-1,max}] Note elmin, elmax can be obtained using GridFunction::GetElementBounds()

Definition at line 120 of file bb_grid_map.cpp.

◆ BBoxTensorGridMap() [3/3]

mfem::BBoxTensorGridMap::BBoxTensorGridMap ( Vector & elmin,
Vector & elmax,
int nel,
int sdim,
int n,
bool by_max_size = false )

Constructor for given element bounds and spatial dimension.

The user can either specify the max size of map (by_max_size=true) or the number of divisions (by_max_size=false).

When by_max_size=true, n gives the requested maximum size of lgrid_map. If n >= 2 + nel, then lgrid_map.Size() <= n. Otherwise, lgrid_map is resized to the minimum feasible size 2 + nel.

Assumes elmin, elmax Ordering::byNodes: elmin -> [x_{0,min},x_{1,min},... ,y_{0,min},y_{1,min},..,z_{nel-1,min}] elmax -> [x_{0,max},x_{1,max},... ,y_{0,max},y_{1,max},..,z_{nel-1,max}] Note elmin, elmax can be obtained using GridFunction::GetElementBounds()

Definition at line 100 of file bb_grid_map.cpp.

Member Function Documentation

◆ GetGridCellFromPoint()

int mfem::BBoxTensorGridMap::GetGridCellFromPoint ( Vector & xyz) const

Get grid cell index for a given point.

Definition at line 317 of file bb_grid_map.cpp.

◆ GetGridCountAndRange()

int mfem::BBoxTensorGridMap::GetGridCountAndRange ( const Array< int > & lh_n,
const Vector & lh_fac,
const Vector & lh_bnd_min,
const Vector & lh_bnd_max,
const Vector & elmin,
const Vector & elmax,
Array< int > & elmin_h,
Array< int > & elmax_h )
static

Get grid count and range - total number of grid cells that intersect with all elements of the mesh and get corresponding ranges.

Definition at line 382 of file bb_grid_map.cpp.

◆ GetGridFac()

const Vector & mfem::BBoxTensorGridMap::GetGridFac ( ) const
inline

Return the number of grid cells per unit extent in each direction.

Definition at line 163 of file bb_grid_map.hpp.

◆ GetGridMap()

const Array< unsigned int > & mfem::BBoxTensorGridMap::GetGridMap ( ) const
inline

Return the map from grid cells to candidate elements whose bounding boxes intersect each cell.

Definition at line 161 of file bb_grid_map.hpp.

◆ GetGridMax()

const Vector & mfem::BBoxTensorGridMap::GetGridMax ( ) const
inline

Return the maximum extent of the grid in each direction.

Definition at line 167 of file bb_grid_map.hpp.

◆ GetGridMin()

const Vector & mfem::BBoxTensorGridMap::GetGridMin ( ) const
inline

Return the minimum extent of the grid in each direction.

Definition at line 165 of file bb_grid_map.hpp.

◆ GetGridN()

const Array< int > & mfem::BBoxTensorGridMap::GetGridN ( ) const
inline

Return the grid resolution (number of cells) in each direction.

Definition at line 169 of file bb_grid_map.hpp.

◆ GetGridRange()

void mfem::BBoxTensorGridMap::GetGridRange ( const int d,
const Array< int > & lh_n,
const Vector & lh_fac,
const Vector & lh_bnd_min,
const real_t & xmin,
const real_t & xmax,
int & imin,
int & imax )
static

Get local (1D) indices for cells of tensor grid that intersect with the given bounding box.

Definition at line 347 of file bb_grid_map.cpp.

◆ GridCellToElements()

Array< int > mfem::BBoxTensorGridMap::GridCellToElements ( int i) const

Get list of elements corresponding to a grid cell.

Definition at line 302 of file bb_grid_map.cpp.

◆ MapPointToElements()

Array< int > mfem::BBoxTensorGridMap::MapPointToElements ( Vector & xyz) const

Map a point to possible overlapping elements.

Definition at line 335 of file bb_grid_map.cpp.

◆ SetGridFac()

void mfem::BBoxTensorGridMap::SetGridFac ( Vector & lh_fac,
const Array< int > & nx,
const Vector & lh_bnd_min,
const Vector & lh_bnd_max )
static

Set grid fac - number of grid cells per unit grid extent.

Definition at line 363 of file bb_grid_map.cpp.


The documentation for this class was generated from the following files: