GenericDataOut< dim, number > Class Template Reference

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

A generic utility for managing simulation output data in the MeltPoolDG context. More...

#include <generic_data_out.hpp>

Public Types

using VectorType = dealii::LinearAlgebra::distributed::Vector< number >
 The distributed vector type used for parallel computations. Used for DoF output vectors.
 
using ElementWiseVectorType = dealii::Vector< number >
 The element-wise (non-distributed) vector type. Used for element-wise output vectors.
 

Public Member Functions

 GenericDataOut (const dealii::Mapping< dim > &mapping, const number current_time, const std::vector< std::string > &req_vars_in={"all"})
 Constructor.
 
void add_data_vector (const dealii::DoFHandler< dim > &dof_handler, const VectorType &data, const std::vector< std::string > &names, const std::vector< dealii::DataComponentInterpretation::DataComponentInterpretation > &data_component_interpretation=std::vector< dealii::DataComponentInterpretation::DataComponentInterpretation >(), const bool force_output=false)
 Add a distributed vector with multiple components and custom interpretations.
 
void add_data_vector (const dealii::DoFHandler< dim > &dof_handler, const VectorType &data, const std::string &name, const bool force_output=false)
 Add a distributed vector with a single scalar component.
 
void add_data_vector (const dealii::DoFHandler< dim > *dof_handler, const VectorType *data, const dealii::DataPostprocessor< dim > *data_postprocessor, const bool force_output=false)
 
void add_element_wise_data_vector (const ElementWiseVectorType &data, const std::string &name, const bool force_output=false)
 Add an element-wise vector.
 
const VectorTypeget_vector (const std::string &name) const
 
const dealii::DataPostprocessor< dim > & get_data_postprocessor (const std::string &name) const
 
const dealii::DoFHandler< dim > & get_dof_handler (const std::string &name) const
 Retrieve the DoFHandler associated with a named distributed vector.
 
const dealii::Mapping< dim > & get_mapping () const
 Access the stored Mapping used in the constructor.
 
const number & get_time () const
 Get the time value associated with this output.
 
bool is_requested (const std::string &var) const
 Determine if a variable has been requested for output.
 
std::vector< unsigned int > get_indices_data_request (const std::vector< std::string > &req_var) const
 Retrieve the entry indices of requested variables.
 

Public Attributes

std::vector< std::tuple< const dealii::DoFHandler< dim > *, const VectorType *, const ElementWiseVectorType *, const std::vector< std::string >, std::vector< dealii::DataComponentInterpretation::DataComponentInterpretation > > > entries
 Storage of registered data entries.
 
std::vector< std::tuple< const dealii::DoFHandler< dim > *, const VectorType *, const dealii::DataPostprocessor< dim > * > > data_postprocessor_entries
 

Private Attributes

std::map< std::string, unsigned int > entry_id
 Maps variable names to their entry index.
 
const dealii::Mapping< dim > & mapping
 Mapping object reference.
 
number current_time
 Time associated with the current output.
 
const std::vector< std::string > req_vars
 List of requested variable names.
 
std::map< std::string, bool > req_vars_info
 Caching mechanism to store whether a variable is requested.
 
const bool req_all = false
 Flag indicating if all variables are requested.
 

Detailed Description

template<int dim, typename number>
class MeltPoolDG::GenericDataOut< dim, number >

A generic utility for managing simulation output data in the MeltPoolDG context.

This class provides a structured interface to collect and access simulation data vectors, either from degrees of freedom (DoF) based structures or from element-wise results. It allows for filtered output based on a list of requested variables and supports scalar and interpreted component data. The class also verifies correct usage and provides meaningful diagnostics.

Template Parameters
dimSpatial dimension (1D, 2D, or 3D).
numberNumeric type of the underlying data (e.g., float, double).

Member Typedef Documentation

◆ ElementWiseVectorType

template<int dim, typename number >
using MeltPoolDG::GenericDataOut< dim, number >::ElementWiseVectorType = dealii::Vector<number>

The element-wise (non-distributed) vector type. Used for element-wise output vectors.

◆ VectorType

template<int dim, typename number >
using MeltPoolDG::GenericDataOut< dim, number >::VectorType = dealii::LinearAlgebra::distributed::Vector<number>

The distributed vector type used for parallel computations. Used for DoF output vectors.

Constructor & Destructor Documentation

◆ GenericDataOut()

template<int dim, typename number >
MeltPoolDG::GenericDataOut< dim, number >::GenericDataOut ( const dealii::Mapping< dim > &  mapping,
const number  current_time,
const std::vector< std::string > &  req_vars_in = {"all"} 
)

Constructor.

Parameters
mappingReference to the mapping object used for geometry transformation.
current_timeThe time value associated with the output.
req_vars_inList of requested variable names (defaults to {"all"}).

Member Function Documentation

◆ add_data_vector() [1/3]

template<int dim, typename number >
void MeltPoolDG::GenericDataOut< dim, number >::add_data_vector ( const dealii::DoFHandler< dim > &  dof_handler,
const VectorType data,
const std::string &  name,
const bool  force_output = false 
)

Add a distributed vector with a single scalar component.

Parameters
dof_handlerThe associated DoFHandler.
dataThe distributed vector.
nameThe name of the variable.
force_outputIf true, forces the data to be added regardless of request filtering.

◆ add_data_vector() [2/3]

template<int dim, typename number >
void MeltPoolDG::GenericDataOut< dim, number >::add_data_vector ( const dealii::DoFHandler< dim > &  dof_handler,
const VectorType data,
const std::vector< std::string > &  names,
const std::vector< dealii::DataComponentInterpretation::DataComponentInterpretation > &  data_component_interpretation = std::vector< dealii::DataComponentInterpretation::DataComponentInterpretation >(),
const bool  force_output = false 
)

Add a distributed vector with multiple components and custom interpretations.

Only adds the data if the first component name is among the requested variables or if force_output is true.

Parameters
dof_handlerThe associated DoFHandler.
dataThe distributed vector.
namesComponent names.
data_component_interpretationInterpretations of each component (optional).
force_outputIf true, forces the addition even if not requested.

◆ add_data_vector() [3/3]

template<int dim, typename number >
void MeltPoolDG::GenericDataOut< dim, number >::add_data_vector ( const dealii::DoFHandler< dim > *  dof_handler,
const VectorType data,
const dealii::DataPostprocessor< dim > *  data_postprocessor,
const bool  force_output = false 
)

Add a data postprocessor with an associated vector and dof handler.

Parameters
dof_handlerThe associated DoFHandler.
dataThe distributed vector.
data_postprocessorThe data postprocessor that defines the output variables.

◆ add_element_wise_data_vector()

template<int dim, typename number >
void MeltPoolDG::GenericDataOut< dim, number >::add_element_wise_data_vector ( const ElementWiseVectorType data,
const std::string &  name,
const bool  force_output = false 
)

Add an element-wise vector.

These are typically used for cell-wise scalar quantities not tied to a DoFHandler.

Parameters
dataThe element-wise vector.
nameThe name of the output variable.
force_outputIf true, forces the data to be added regardless of request filtering.

◆ get_data_postprocessor()

template<int dim, typename number >
const dealii::DataPostprocessor< dim > & MeltPoolDG::GenericDataOut< dim, number >::get_data_postprocessor ( const std::string &  name) const

Retrieve the data postprocessor who has the provided name among its output variables.

Parameters
nameThe name of the variable.
Returns
Reference to the associated data postprocessor.
Exceptions
Ifno matching data postprocessor is found, an exception is thrown.

◆ get_dof_handler()

template<int dim, typename number >
const DoFHandler< dim > & MeltPoolDG::GenericDataOut< dim, number >::get_dof_handler ( const std::string &  name) const

Retrieve the DoFHandler associated with a named distributed vector.

Throws if the variable name is not found or if it corresponds to element-wise data.

Parameters
nameThe name of the variable.
Returns
Reference to the associated DoFHandler.

◆ get_indices_data_request()

template<int dim, typename number >
std::vector< unsigned int > MeltPoolDG::GenericDataOut< dim, number >::get_indices_data_request ( const std::vector< std::string > &  req_var) const

Retrieve the entry indices of requested variables.

Validates consistency of the request. If the request is ambiguous or no match is found, an exception with diagnostics is thrown.

Parameters
req_varThe list of requested variable names.
Returns
Indices of valid entries in the internal storage.

◆ get_mapping()

template<int dim, typename number >
const Mapping< dim > & MeltPoolDG::GenericDataOut< dim, number >::get_mapping ( ) const

Access the stored Mapping used in the constructor.

Returns
The mapping reference.

◆ get_time()

template<int dim, typename number >
const number & MeltPoolDG::GenericDataOut< dim, number >::get_time ( ) const

Get the time value associated with this output.

Returns
The current simulation time.

◆ get_vector()

template<int dim, typename number >
const GenericDataOut< dim, number >::VectorType & MeltPoolDG::GenericDataOut< dim, number >::get_vector ( const std::string &  name) const

Retrieve a previously added distributed vector by name. This can also include vectors associated with a previously added data postprocessor.

Throws if the variable name is not found or if it is an element-wise vector.

Parameters
nameThe name of the vector.
Returns
A reference to the vector.

◆ is_requested()

template<int dim, typename number >
bool MeltPoolDG::GenericDataOut< dim, number >::is_requested ( const std::string &  var) const

Determine if a variable has been requested for output.

The logic caches lookup results for performance and returns true if either req_vars = {"all"} or if the specific variable was listed.

Parameters
nameName of the variable.
Returns
True if the variable is to be output.

Member Data Documentation

◆ current_time

template<int dim, typename number >
number MeltPoolDG::GenericDataOut< dim, number >::current_time
private

Time associated with the current output.

◆ data_postprocessor_entries

template<int dim, typename number >
std::vector<std::tuple<const dealii::DoFHandler<dim> * , const VectorType *, const dealii::DataPostprocessor<dim> *> > MeltPoolDG::GenericDataOut< dim, number >::data_postprocessor_entries

Storage of registered data postprocessor entries. Each entry contains:

  • a pointer to the DoFHandler (or nullptr if not applicable),
  • a pointer to the distributed vector (or nullptr if not applicable),
  • a pointer to the data postprocessor defining and computing the output variables.

◆ entries

template<int dim, typename number >
std::vector< std::tuple<const dealii::DoFHandler<dim> * , const VectorType *, const ElementWiseVectorType * , const std::vector<std::string>, std::vector<dealii::DataComponentInterpretation::DataComponentInterpretation> > > MeltPoolDG::GenericDataOut< dim, number >::entries

Storage of registered data entries.

Each entry contains:

  • a pointer to the DoFHandler (or nullptr for element-wise),
  • a pointer to the distributed vector (or nullptr for element-wise),
  • a pointer to the element-wise vector (or nullptr for DoF-based data),
  • a list of variable/component names,
  • the component interpretations.

◆ entry_id

template<int dim, typename number >
std::map<std::string, unsigned int> MeltPoolDG::GenericDataOut< dim, number >::entry_id
private

Maps variable names to their entry index.

◆ mapping

template<int dim, typename number >
const dealii::Mapping<dim>& MeltPoolDG::GenericDataOut< dim, number >::mapping
private

Mapping object reference.

◆ req_all

template<int dim, typename number >
const bool MeltPoolDG::GenericDataOut< dim, number >::req_all = false
private

Flag indicating if all variables are requested.

◆ req_vars

template<int dim, typename number >
const std::vector<std::string> MeltPoolDG::GenericDataOut< dim, number >::req_vars
private

List of requested variable names.

◆ req_vars_info

template<int dim, typename number >
std::map<std::string, bool> MeltPoolDG::GenericDataOut< dim, number >::req_vars_info
mutableprivate

Caching mechanism to store whether a variable is requested.


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