ObstacleField< dim, number, ObstacleType > Class Template Reference

Developer Documentation: MeltPoolDG::ObstacleField< dim, number, ObstacleType > Class Template Reference
Developer Documentation
MeltPoolDG::ObstacleField< dim, number, ObstacleType > Class Template Reference

#include <obstacle_field.hpp>

Public Member Functions

 ObstacleField (const ObstacleData< number > &data, const dealii::Triangulation< dim > &triangulation, const dealii::Mapping< dim > &mapping)
 Constructor. Initializes the obstacle field and supporting data structures.
 
 ObstacleField (const ObstacleData< number > &data, const dealii::Triangulation< dim > &triangulation, const dealii::Mapping< dim > &mapping, const std::vector< dealii::Point< dim, number > > &obstacle_locations, const std::vector< std::vector< number > > &obstacle_properties)
 Constructor. Initializes the obstacle field and supporting data structures.
 
void advance_time (const number time_step)
 Advances the state of all obstacles in time by a single time step.
 
void compute_loads_on_obstacles ()
 Computes and applies the total load acting on each obstacle in the field. This includes both forces and torques.
 
template<typename ObstacleLoadType >
requires (!std::is_lvalue_reference_v<ObstacleLoadType>)
void add_load_type (ObstacleLoadType &&obstacle_load)
 Adds a new obstacle load to the list of loads acting on obstacles.
 
template<typename ObstacleContainer >
void get_obstacles_in_cell (const dealii::TriaIterator< dealii::CellAccessor< dim > > &cell, ObstacleContainer &particles)
 
boost::container::small_vector< DEMParticleAccessor< dim, number >, 3 *dim > find_particles_in_neighborhood (const DEMParticleAccessor< dim, number > &particle, const number relative_tolerance)
 
void compress ()
 
void print_accumulated_obstacle_force_norm (const dealii::ConditionalOStream pout) const
 
void deserialize ()
 Performs the objects deserialization.
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 Serializes the internal state of the class.
 
void prepare_for_serialization ()
 Prepares this object for serialization.
 
std::vector< AMR::AMRRegion< dim, number > > get_refinement_regions () const
 Return the AMR regions relevant for the obstacle field in region-based refinement.
 
void prepare_for_coarsening_and_refinement ()
 
void unpack_after_coarsening_and_refinement ()
 
void register_particle_output (Postprocessor< dim, number > &postprocessor) const
 
void insert_obstacles (const dealii::Triangulation< dim > &triangulation, const std::vector< dealii::Point< dim, number > > &obstacle_locations, const std::vector< std::vector< number > > &obstacle_properties)
 Insert obstacles into the particle handler based on provided locations and properties.
 
std::ranges::subrange< ParticleIterator< dim, number > > locally_owned_particle_range () const
 
std::ranges::subrange< ParticleIterator< dim, number > > ghost_particle_range () const
 
std::ranges::subrange< ParticleIterator< dim, number > > particles_in_cell (typename dealii::Triangulation< dim >::active_cell_iterator cell) const
 
unsigned int n_global_particles () const
 
void subscribe_to_data_structure (std::function< void(CellListParticleHandler< dim, number, ObstacleType > &, const typename CellListParticleHandler< dim, number, ObstacleType >::NotifyEvent &)> callback)
 

Private Attributes

const ObstacleData< number > & data
 Struct holding configuration data for obstacles.
 
std::vector< ObstacleLoad< dim, number, ObstacleType > > loads
 Vector of load objects representing all loads acting on the obstacles.
 
CellListParticleHandler< dim, number, ObstacleType > obstacle_data_structure
 Obstacle search utility for locating relevant obstacles within a given cell or batch.
 
MPI_Comm mpi_communicator
 MPI communicator used for parallel operations on the obstacle field.
 

Constructor & Destructor Documentation

◆ ObstacleField() [1/2]

template<int dim, typename number , typename ObstacleType >
MeltPoolDG::ObstacleField< dim, number, ObstacleType >::ObstacleField ( const ObstacleData< number > &  data,
const dealii::Triangulation< dim > &  triangulation,
const dealii::Mapping< dim > &  mapping 
)

Constructor. Initializes the obstacle field and supporting data structures.

This constructor reads obstacle input from file, initializes the internal particle handler, and prepares the obstacle field for simulation. After construction, the obstacle field is ready for further computations.

Note
Currently, only stationary obstacles are supported. A runtime assertion checks this condition.
Parameters
dataObstacle-related configuration data.
triangulationThe triangulation on which the obstacles are placed.
mappingMapping used to interpret geometry on the given triangulation.

◆ ObstacleField() [2/2]

template<int dim, typename number , typename ObstacleType >
MeltPoolDG::ObstacleField< dim, number, ObstacleType >::ObstacleField ( const ObstacleData< number > &  data,
const dealii::Triangulation< dim > &  triangulation,
const dealii::Mapping< dim > &  mapping,
const std::vector< dealii::Point< dim, number > > &  obstacle_locations,
const std::vector< std::vector< number > > &  obstacle_properties 
)

Constructor. Initializes the obstacle field and supporting data structures.

This constructor initializes the internal particle handler with the provided obstacle locations and properties, preparing the obstacle field for simulation. After construction, the obstacle field is ready for further computations.

Parameters
dataObstacle-related configuration data.
triangulationThe triangulation on which the obstacles are placed.
mappingMapping used to interpret geometry on the given triangulation.
obstacle_locationsVector of obstacle center locations.
obstacle_propertiesVector of obstacle properties corresponding to each location.

Member Function Documentation

◆ add_load_type()

template<int dim, typename number , typename ObstacleType >
template<typename ObstacleLoadType >
requires (!std::is_lvalue_reference_v<ObstacleLoadType>)
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::add_load_type ( ObstacleLoadType &&  obstacle_load)
inline

Adds a new obstacle load to the list of loads acting on obstacles.

This method appends the given load object to the internal list of load that are applied when computing the total load on an obstacle – this includes forces and torques.

Parameters
obstacle_loadThe load object to be added. It is forwarded and stored via type erasure.

◆ advance_time()

template<int dim, typename number , typename ObstacleType >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::advance_time ( const number  time_step)

Advances the state of all obstacles in time by a single time step.

Parameters
time_stepThe size of the time step to advance.

◆ compress()

template<int dim, typename number , typename ObstacleType >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::compress ( )

This function compresses the forces and torques of the ghost particles by sending them to the owning rank of the particles and summing them up there.

Note
After a call to this function, the compressed value is exclusively available on the owning rank of the particle. The force and torque values on the ghost particles are not updated and should be considered invalid.

◆ compute_loads_on_obstacles()

template<int dim, typename number , typename ObstacleType >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::compute_loads_on_obstacles ( )

Computes and applies the total load acting on each obstacle in the field. This includes both forces and torques.

This method iterates over all registered loads in the loads vector and computes the cumulative load for each obstacle by summing the contributions of all individual load models. The resulting total load (force and torque) is then stored in the obstacle’s properties using the appropriate setter defined by ObstacleType.

◆ deserialize()

template<int dim, typename number , typename ObstacleType >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::deserialize ( )

Performs the objects deserialization.

This function forwards the call to dealii::ParticleHandler::deserialize(). See the documentation of that function for further details.

◆ find_particles_in_neighborhood()

template<int dim, typename number , typename ObstacleType >
boost::container::small_vector< MeltPoolDG::DEMParticleAccessor< dim, number >, 3 *dim > MeltPoolDG::ObstacleField< dim, number, ObstacleType >::find_particles_in_neighborhood ( const DEMParticleAccessor< dim, number > &  particle,
const number  relative_tolerance 
)

This functions returns a vector of particles that are located within the influence area of a given particle. The neighborhood radius is defined as:

r_neighborhood = particle.radius() * (1 + relative_tolerance)

This captures two categories of neighbors:

  • Contact neighbors: particles whose surfaces overlap or touch.
  • Influence neighbors: particles close enough to exert non-contact interactions (e.g. van der Waals or lubrication forces).
Parameters
particleThe particle around which the neighborhood is constructed.
relative_toleranceA non-negative scaling factor applied to the particle's radius to define the neighborhood extent. A value of 0 restricts the search to overlapping (contact) particles only.
Returns
All particles within the influence neighborhood of particle, excluding particle itself.

◆ get_obstacles_in_cell()

template<int dim, typename number , typename ObstacleType >
template<typename ObstacleContainer >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::get_obstacles_in_cell ( const dealii::TriaIterator< dealii::CellAccessor< dim > > &  cell,
ObstacleContainer &  particles 
)

Identify obstacles that likely at least partially occupy the specified cell. Note, that the returned particles are not guaranteed to be located within the cell, but they are guaranteed to include all particles that are located within the cell.

Parameters
cellThe cell of interest. The iterator must point to a cell within the triangulation that was used to initialize this object.
particlesDestination container where the properties of the identified obstacles will be added. If the container already contains particles, the function will append new particles to it, ensuring that no duplicates are added.
Returns
Vector containing the handles of the newly registered obstacles in dst.

◆ get_refinement_regions()

template<int dim, typename number , typename ObstacleType >
std::vector< MeltPoolDG::AMR::AMRRegion< dim, number > > MeltPoolDG::ObstacleField< dim, number, ObstacleType >::get_refinement_regions ( ) const

Return the AMR regions relevant for the obstacle field in region-based refinement.

This function computes and returns a vector of AMR regions corresponding to all particles in the obstacle field. Each particle contributes a spherical shell region, with the shell size determined by the parameters stored in the obstacle data structure associated with the object's obstacle field.

Returns
A vector of AMR regions for all particles in the field.
Note
The returned vector contains regions for all global particles, not just those local to the current process or subdomain.

◆ ghost_particle_range()

template<int dim, typename number , typename ObstacleType >
std::ranges::subrange< MeltPoolDG::ParticleIterator< dim, number > > MeltPoolDG::ObstacleField< dim, number, ObstacleType >::ghost_particle_range ( ) const

Returns a range over all ghost obstacle particles on the current MPI process.

Returns
An iterable subrange representing all ghost particles.

◆ insert_obstacles()

template<int dim, typename number , typename ObstacleType >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::insert_obstacles ( const dealii::Triangulation< dim > &  triangulation,
const std::vector< dealii::Point< dim, number > > &  obstacle_locations,
const std::vector< std::vector< number > > &  obstacle_properties 
)

Insert obstacles into the particle handler based on provided locations and properties.

This function takes a set of obstacle locations and their corresponding properties, and inserts them into the internal particle handler. It ensures that the obstacles are properly initialized and ready for simulation.

Parameters
triangulationThe triangulation on which the obstacles are placed.
obstacle_locationsA vector of points representing the locations of the obstacles.
obstacle_propertiesA vector of vectors, where each inner vector contains the properties associated with the corresponding obstacle location.

◆ locally_owned_particle_range()

template<int dim, typename number , typename ObstacleType >
std::ranges::subrange< MeltPoolDG::ParticleIterator< dim, number > > MeltPoolDG::ObstacleField< dim, number, ObstacleType >::locally_owned_particle_range ( ) const

Returns a subrange for iterating over particles that are owned locally.

Returns
An iterable subrange representing the local particles.

◆ n_global_particles()

template<int dim, typename number , typename ObstacleType >
unsigned int MeltPoolDG::ObstacleField< dim, number, ObstacleType >::n_global_particles ( ) const

Return the number of global particles, i.e., the total number of particles across all MPI ranks.

◆ particles_in_cell()

template<int dim, typename number , typename ObstacleType >
std::ranges::subrange< MeltPoolDG::ParticleIterator< dim, number > > MeltPoolDG::ObstacleField< dim, number, ObstacleType >::particles_in_cell ( typename dealii::Triangulation< dim >::active_cell_iterator  cell) const

Returns a subrange for iterating over particles for which the particle center location is contained in the specified active cell.

Parameters
cellThe active cell for which to retrieve particles.
Returns
An iterable subrange representing the particles in the cell.

◆ prepare_for_coarsening_and_refinement()

template<int dim, typename number , typename ObstacleType >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::prepare_for_coarsening_and_refinement ( )

Prepares the obstacle data structure for coarsening and refinement of the underlying triangulation. This call is necessary to ensure that the obstacle data structure remains consistent with the mesh after coarsening and refinement operations.

◆ prepare_for_serialization()

template<int dim, typename number , typename ObstacleType >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::prepare_for_serialization ( )

Prepares this object for serialization.

This function forwards the call to dealii::ParticleHandler::prepare_for_serialization(). See the documentation of that function for further details.

◆ print_accumulated_obstacle_force_norm()

template<int dim, typename number , typename ObstacleType >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::print_accumulated_obstacle_force_norm ( const dealii::ConditionalOStream  pout) const

Computes the sum of all particle forces and prints the corresponding norm to the console.

Note
This function is intended to be used for testing purposes.

◆ register_particle_output()

template<int dim, typename number , typename ObstacleType >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::register_particle_output ( Postprocessor< dim, number > &  postprocessor) const

Registers the obstacle handler for particle output.

Parameters
postprocessorThe postprocessor to which the particles are registered for output.

◆ serialize()

template<int dim, typename number , typename ObstacleType >
template<class Archive >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::serialize ( Archive &  ar,
const unsigned int  version 
)

Serializes the internal state of the class.

This function forwards the call to dealii::ParticleHandler::serialize(). See the documentation of that function for further details.

Parameters
arThe archive used for serialization or deserialization.
versionThe serialization version.

◆ subscribe_to_data_structure()

template<int dim, typename number , typename ObstacleType >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::subscribe_to_data_structure ( std::function< void(CellListParticleHandler< dim, number, ObstacleType > &, const typename CellListParticleHandler< dim, number, ObstacleType >::NotifyEvent &)>  callback)

Registers a callback function to be notified whenever the obstacle data structure is updated.

Parameters
callbackA callable that takes a reference to the obstacle data structure and the event type that triggered the update. The callable will be invoked whenever the obstacle data structure is updated, allowing the subscriber to react accordingly.

◆ unpack_after_coarsening_and_refinement()

template<int dim, typename number , typename ObstacleType >
void MeltPoolDG::ObstacleField< dim, number, ObstacleType >::unpack_after_coarsening_and_refinement ( )

Unpacks the obstacle data structure after coarsening and refinement operations. This call is necessary to ensure that the obstacle data structure remains consistent with the mesh after coarsening and refinement operations.

Note
It is required that prepare_for_coarsening_and_refinement() has been called before the triangulation was coarsened and refined.

Member Data Documentation

◆ data

template<int dim, typename number , typename ObstacleType >
const ObstacleData<number>& MeltPoolDG::ObstacleField< dim, number, ObstacleType >::data
private

Struct holding configuration data for obstacles.

◆ loads

template<int dim, typename number , typename ObstacleType >
std::vector<ObstacleLoad<dim, number, ObstacleType> > MeltPoolDG::ObstacleField< dim, number, ObstacleType >::loads
private

Vector of load objects representing all loads acting on the obstacles.

◆ mpi_communicator

template<int dim, typename number , typename ObstacleType >
MPI_Comm MeltPoolDG::ObstacleField< dim, number, ObstacleType >::mpi_communicator
private

MPI communicator used for parallel operations on the obstacle field.

◆ obstacle_data_structure

template<int dim, typename number , typename ObstacleType >
CellListParticleHandler<dim, number, ObstacleType> MeltPoolDG::ObstacleField< dim, number, ObstacleType >::obstacle_data_structure
private

Obstacle search utility for locating relevant obstacles within a given cell or batch.


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