Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Public Member Functions | List of all members
shamrock::patch::SimulationBoxInfo Class Reference

Store the information related to the size of the simulation box to convert patch integer coordinates to floating point ones. More...

#include <shamrock/include/shamrock/patch/SimBox.hpp>

Public Member Functions

 SimulationBoxInfo (PatchDataLayerLayout &pdl, PatchCoord< dim > patch_coord_bounding_box)
 
void set_patch_coord_bounding_box (PatchCoord< dim > new_patch_coord_box)
 
template<class T >
std::tuple< T, T > get_bounding_box () const
 Get the stored bounding box of the domain.
 
template<class T >
get_bounding_box_size () const
 Get the size of the stored bounding box of the domain.
 
template<class T >
void set_bounding_box (shammath::CoordRange< T > new_box)
 Override the stored bounding box by the one given in new_box.
 
template<class T >
void allreduce_set_bounding_box (shammath::CoordRange< T > new_box)
 Set the stored bounding box after an all-reduce operation on the supplied bounds.
 
template<class T >
PatchCoordTransform< T > get_patch_transform () const
 Get a PatchCoordTransform object that describes the conversion between patch coordinates and domain coordinates.
 
template<class T >
std::tuple< T, T > patch_coord_to_domain (const Patch &p) const
 get the patch coordinates on the domain
 
void reset_box_size ()
 Reset the bounding box of the simulation domain to the maximum extents of the main field.
 
template<class primtype >
void clean_box (primtype tol)
 
template<>
void clean_box (f32 tol)
 
template<>
void clean_box (f64 tol)
 
template<class primtype >
std::tuple< sycl::vec< primtype, 3 >, sycl::vec< primtype, 3 > > get_box (Patch &p)
 
template<class T >
PatchCoordTransform< T > get_transform ()
 
void to_json (nlohmann::json &j)
 Serializes a SimulationBoxInfo object to a JSON object.
 
void from_json (const nlohmann::json &j)
 Deserializes a JSON object into a SimulationBoxInfo object.
 

Detailed Description

Store the information related to the size of the simulation box to convert patch integer coordinates to floating point ones.

Definition at line 35 of file SimBox.hpp.

Constructor & Destructor Documentation

◆ SimulationBoxInfo()

shamrock::patch::SimulationBoxInfo::SimulationBoxInfo ( PatchDataLayerLayout pdl,
PatchCoord< dim >  patch_coord_bounding_box 
)
inline

Definition at line 47 of file SimBox.hpp.

Member Function Documentation

◆ allreduce_set_bounding_box()

template<class T >
void shamrock::patch::SimulationBoxInfo::allreduce_set_bounding_box ( shammath::CoordRange< T >  new_box)
inline

Set the stored bounding box after an all-reduce operation on the supplied bounds.

This function is used in the context of a distributed simulation. It will all-reduce the bounding box of the domain over all the MPI ranks. The all-reduce operation is done with the shamalgs::collective::allreduce_bounds function.

Template Parameters
Ttype of position vector
Parameters
new_boxthe new bounding box to be all_reduced across ranks

Definition at line 113 of file SimBox.hpp.

◆ clean_box() [1/3]

template<>
void shamrock::patch::SimulationBoxInfo::clean_box ( f32  tol)
inline

Definition at line 181 of file SimBox.hpp.

◆ clean_box() [2/3]

template<>
void shamrock::patch::SimulationBoxInfo::clean_box ( f64  tol)
inline

Definition at line 198 of file SimBox.hpp.

◆ clean_box() [3/3]

template<class primtype >
void shamrock::patch::SimulationBoxInfo::clean_box ( primtype  tol)
Todo:
replace vectype primtype in the code by primtype and sycl::vec<primtype,3> for the others

◆ from_json()

void shamrock::patch::SimulationBoxInfo::from_json ( const nlohmann::json &  j)

Deserializes a JSON object into a SimulationBoxInfo object.

Parameters
jThe JSON object to deserialize from.
pThe SimulationBoxInfo object to deserialize into.

Definition at line 71 of file SimBox.cpp.

+ Here is the call graph for this function:

◆ get_bounding_box()

template<class T >
std::tuple< T, T > shamrock::patch::SimulationBoxInfo::get_bounding_box ( ) const
inline

Get the stored bounding box of the domain.

Template Parameters
Ttype of position vector
Returns
std::tuple<T, T> return [low bound, high bound[

Definition at line 247 of file SimBox.hpp.

+ Here is the call graph for this function:

◆ get_bounding_box_size()

template<class T >
T shamrock::patch::SimulationBoxInfo::get_bounding_box_size ( ) const
inline

Get the size of the stored bounding box of the domain.

Template Parameters
Ttype of position vector
Returns
T the size of the bounding box

Definition at line 87 of file SimBox.hpp.

◆ get_box()

template<class primtype >
std::tuple< sycl::vec< primtype, 3 >, sycl::vec< primtype, 3 > > shamrock::patch::SimulationBoxInfo::get_box ( Patch p)
inline

Definition at line 214 of file SimBox.hpp.

◆ get_patch_transform()

template<class T >
PatchCoordTransform< T > shamrock::patch::SimulationBoxInfo::get_patch_transform ( ) const

Get a PatchCoordTransform object that describes the conversion between patch coordinates and domain coordinates.

This function returns a PatchCoordTransform object that can be used to convert between patch coordinates and domain coordinates. The PatchCoordTransform object is templated on the type of position vector used by the domain.

Template Parameters
TType of position vector
Returns
PatchCoordTransform<T> A PatchCoordTransform object that can be used to transform between patch coordinates and domain coordinates.

Definition at line 285 of file SimBox.hpp.

+ Here is the call graph for this function:

◆ get_transform()

template<class T >
PatchCoordTransform< T > shamrock::patch::SimulationBoxInfo::get_transform ( )
inline

Definition at line 219 of file SimBox.hpp.

◆ patch_coord_to_domain()

template<class T >
std::tuple< T, T > shamrock::patch::SimulationBoxInfo::patch_coord_to_domain ( const Patch p) const
inline

get the patch coordinates on the domain

Template Parameters
Ttype of position vector
Parameters
pthe patch
Returns
std::tuple<T,T> the [low bound, high bound[ coordinate of the patch in the domain

Definition at line 300 of file SimBox.hpp.

◆ reset_box_size()

void shamrock::patch::SimulationBoxInfo::reset_box_size ( )
inline

Reset the bounding box of the simulation domain to the maximum extents of the main field.

This function resets the bounding box of the simulation domain to the maximum extents of the main field. The bounding box is defined by the PatchDataLayerLayout object used to initialize the SimulationBoxInfo object. The bounding box is a shammath::CoordRange object that contains the coordinate range of the simulation domain.

This function is called by the constructor of the SimulationBoxInfo class, but it can also be called manually to reset the bounding box after changing the main field.

The bounding box is reset based on the type of the main field. If the main field is of type f32_3, f64_3, u32_3, u64_3, or i64_3, the bounding box is set to the maximum range of the corresponding type. If the main field is of any other type, a std::runtime_error exception is thrown.

Exceptions
std::runtime_errorif the main field type is not one of the types listed above.

Definition at line 309 of file SimBox.hpp.

+ Here is the call graph for this function:

◆ set_bounding_box()

template<class T >
void shamrock::patch::SimulationBoxInfo::set_bounding_box ( shammath::CoordRange< T >  new_box)
inline

Override the stored bounding box by the one given in new_box.

Template Parameters
Ttype of position vector
Parameters
new_boxthe new bounding box

Definition at line 272 of file SimBox.hpp.

+ Here is the call graph for this function:

◆ set_patch_coord_bounding_box()

void shamrock::patch::SimulationBoxInfo::set_patch_coord_bounding_box ( PatchCoord< dim >  new_patch_coord_box)
inline

Definition at line 55 of file SimBox.hpp.

◆ to_json()

void shamrock::patch::SimulationBoxInfo::to_json ( nlohmann::json &  j)

Serializes a SimulationBoxInfo object to a JSON object.

Parameters
jThe JSON object to serialize to.
pThe SimulationBoxInfo object to serialize.

Definition at line 31 of file SimBox.cpp.

+ Here is the call graph for this function:

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