Caribou
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
SofaCaribou::topology::FictitiousGrid< DataTypes > Class Template Reference
Inheritance diagram for SofaCaribou::topology::FictitiousGrid< DataTypes >:

Classes

struct  Cell
 A region is a cluster of cells sharing the same type and surrounded by either a boundary region or the outside of the grid. More...
 
struct  CellData
 The Cell structure contains the quadtree (resp. octree) data of a given cell or subcell. More...
 
struct  Region
 

Public Types

enum  Type : INTEGER_TYPE { Undefined = std::numeric_limits<INTEGER_TYPE>::lowest(), Inside = (unsigned) 1 << (unsigned) 0, Outside = (unsigned) 1 << (unsigned) 1, Boundary = (unsigned) 1 << (unsigned) 2 }
 
using Index = std::size_t
 
using Int = INTEGER_TYPE
 
using Float = FLOATING_POINT_TYPE
 
using SofaFloat = typename DataTypes::Real
 
using SofaVecInt = sofa::defaulttype::Vec< Dimension, UNSIGNED_INTEGER_TYPE >
 
using SofaVecFloat = sofa::defaulttype::Vec< Dimension, SofaFloat >
 
using Coord = typename DataTypes::Coord
 
using SofaVecCoord = sofa::helper::vector< Coord >
 
using ElementId = sofa::Index
 
using VecElementId = sofa::helper::vector< ElementId >
 
using SofaHexahedron = sofa::core::topology::BaseMeshTopology::Hexahedron
 
using SofaQuad = sofa::core::topology::BaseMeshTopology::Quad
 
using SofaTriangle = sofa::core::topology::BaseMeshTopology::Triangle
 
using SofaEdge = sofa::core::topology::BaseMeshTopology::Edge
 
using GridType = caribou::topology::Grid< Dimension >
 
using NodeIndex = typename GridType::NodeIndex
 
using CellIndex = typename GridType::CellIndex
 
using Dimensions = typename GridType::Dimensions
 
using Subdivisions = typename GridType::Subdivisions
 
using LocalCoordinates = typename GridType::LocalCoordinates
 
using WorldCoordinates = typename GridType::WorldCoordinates
 
using GridCoordinates = typename GridType::GridCoordinates
 
using CellSet = typename GridType::CellSet
 
using CellElement = typename GridType::Element
 
template<typename ObjectType >
using Link = SingleLink< FictitiousGrid< DataTypes >, ObjectType, BaseLink::FLAG_STRONGLINK >
 

Public Member Functions

 SOFA_CLASS (SOFA_TEMPLATE(FictitiousGrid, DataTypes), BaseObject)
 
virtual void create_grid ()
 Initialization of the grid. More...
 
UNSIGNED_INTEGER_TYPE number_of_cells () const
 Get the number of sparse cells in the grid.
 
UNSIGNED_INTEGER_TYPE number_of_nodes () const
 Get the number of sparse nodes in the grid.
 
UNSIGNED_INTEGER_TYPE number_of_subdivisions () const
 Get the number of subdivisions in the grid.
 
std::vector< Cell * > get_neighbors (const Cell *cell) const
 Get neighbors cells around a given cell. More...
 
std::vector< Cell * > get_neighbors (const Cell *cell, UNSIGNED_INTEGER_TYPE axis, INTEGER_TYPE direction) const
 Get cells neighbors in a given axis (x=0, y=1, z=2) and direction (-1, 1) of a given cell. More...
 
std::vector< std::pair< LocalCoordinates, FLOATING_POINT_TYPE > > get_gauss_nodes_of_cell (const CellIndex &sparse_cell_index) const
 Get the list of gauss nodes coordinates and their respective weight inside a cell. More...
 
std::vector< std::pair< LocalCoordinates, FLOATING_POINT_TYPE > > get_gauss_nodes_of_cell (const CellIndex &sparse_cell_index, const UNSIGNED_INTEGER_TYPE level) const
 Similar to get_gauss_nodes_of_cell(const CellIndex & index), but here only the gauss nodes of inner cells up to the subdivision level given are returned. More...
 
CellElement get_cell_element (const CellIndex &sparse_cell_index) const
 Get the element of a cell from its index in the sparse grid.
 
const SofaHexahedron & get_node_indices_of (const CellIndex &sparse_cell_index) const
 Get the node indices of a cell from its index in the sparse grid.
 
Type get_type_at (const WorldCoordinates &p) const
 Get the type (inside, outside, boundary or undefined) of a given point in space.
 
std::map< FLOATING_POINT_TYPE, std::vector< CellIndex > > cell_volume_ratio_distribution (UNSIGNED_INTEGER_TYPE number_of_decimals=0) const
 Compute the distribution of volume ratios of the top level cells of the grid. More...
 
void init () override
 
void draw (const sofa::core::visual::VisualParams *vparams) override
 
void computeBBox (const sofa::core::ExecParams *, bool onlyVisible) override
 
std::string getTemplateName () const override
 

Static Public Member Functions

static std::string templateName (const FictitiousGrid< DataTypes > *=nullptr)
 

Static Public Attributes

static constexpr unsigned char Dimension = DataTypes::spatial_dimensions
 

Class Documentation

◆ SofaCaribou::topology::FictitiousGrid::Region

struct SofaCaribou::topology::FictitiousGrid::Region
Class Members
vector< Cell * > cells
Type type

Member Function Documentation

◆ cell_volume_ratio_distribution()

template<typename DataTypes >
auto SofaCaribou::topology::FictitiousGrid< DataTypes >::cell_volume_ratio_distribution ( UNSIGNED_INTEGER_TYPE  number_of_decimals = 0) const
inline

Compute the distribution of volume ratios of the top level cells of the grid.

The volume ratio is the ratio of actual volume of a cell over the total volume of the cell. Hence, the ratio of a cell outside the boundaries is 0, the ratio of a cell inside is 1, and the ratio of boundary cells are between 0 and 1.

Parameters
number_of_decimalsRound the volume ratio to the given number of decimals. For example, setting this value to 2 will generate a distribution of maximum 100 entries (0.00, 0.01, 0.02, ..., 0.99, 1.00).

Setting a value at zero deactivate the rounding of volume ratio. Default is 0 which means no rounding.

Returns
A sorted map where the keys are the percentage of volume inside the cell, and the value is a vector containing the ids of all cells having this volume percentage.

◆ create_grid()

template<typename DataTypes >
void SofaCaribou::topology::FictitiousGrid< DataTypes >::create_grid
virtual

Initialization of the grid.

This must be called before anything else.

◆ get_gauss_nodes_of_cell() [1/2]

template<typename DataTypes >
std::vector< std::pair< typename FictitiousGrid< DataTypes >::LocalCoordinates, FLOATING_POINT_TYPE > > SofaCaribou::topology::FictitiousGrid< DataTypes >::get_gauss_nodes_of_cell ( const CellIndex &  sparse_cell_index) const

Get the list of gauss nodes coordinates and their respective weight inside a cell.

Here, all the gauss nodes of the leafs cells that are within (or onto) the boundary are given. The coordinates are given with respect of the local frame of the cell (local coordinates).

  • Parameters
    sparse_cell_indexThe index of the cell in the sparse grid

◆ get_gauss_nodes_of_cell() [2/2]

template<typename DataTypes >
std::vector< std::pair< typename FictitiousGrid< DataTypes >::LocalCoordinates, FLOATING_POINT_TYPE > > SofaCaribou::topology::FictitiousGrid< DataTypes >::get_gauss_nodes_of_cell ( const CellIndex &  sparse_cell_index,
const UNSIGNED_INTEGER_TYPE  level 
) const

Similar to get_gauss_nodes_of_cell(const CellIndex & index), but here only the gauss nodes of inner cells up to the subdivision level given are returned.

Leafs cells bellow the given level are only used to compute the weight of a gauss node.

For example, if the grid's subdivision level is 3, calling this function with level = 0 will give the standard 4 gauss nodes in 2D (8 gauss nodes in 3D), but where each gauss nodes will use their underlying quad tree (resp. octree in 3D) to compute their weight.

Parameters
sparse_cell_indexThe index of the cell in the sparse grid

◆ get_neighbors() [1/2]

template<typename DataTypes >
std::vector< typename FictitiousGrid< DataTypes >::Cell * > SofaCaribou::topology::FictitiousGrid< DataTypes >::get_neighbors ( const Cell cell) const

Get neighbors cells around a given cell.

A cell is neighbor to another one if they both have a face in common, or if a face contains one of the face of the other. Neighbors outside of the surface boundary are excluded.

◆ get_neighbors() [2/2]

template<typename DataTypes >
std::vector< typename FictitiousGrid< DataTypes >::Cell * > SofaCaribou::topology::FictitiousGrid< DataTypes >::get_neighbors ( const Cell cell,
UNSIGNED_INTEGER_TYPE  axis,
INTEGER_TYPE  direction 
) const

Get cells neighbors in a given axis (x=0, y=1, z=2) and direction (-1, 1) of a given cell.

For example, to get the neighbors cells that are on the top of the given cell (in the y direction), axis would be 1 and direction would be 1. Neighbors outside of the surface boundary are excluded.


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