Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
utilities.cc File Reference
#include <core/exceptions.h>
#include <core/revision.h>
#include <core/utilities.h>
#include <core/vector.h>
#include <deal.II/base/mpi.h>
#include <deal.II/base/revision.h>
#include <deal.II/numerics/vector_tools.h>
#include <boost/algorithm/string/replace.hpp>
#include <filesystem>
#include <iostream>
#include <regex>
#include <system_error>
#include <type_traits>
Include dependency graph for utilities.cc:

Go to the source code of this file.

Functions

template<typename T>
TableHandler make_table_scalars_vectors (const std::vector< T > &independent_values, const std::string &independent_column_name, const std::vector< std::vector< double > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template<int dim, typename T>
TableHandler make_table_scalars_tensors (const std::vector< T > &independent_vector, const std::string &independent_column_name, const std::vector< Tensor< 1, dim > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template<int dim, typename T>
TableHandler make_table_scalars_tensors (const std::vector< T > &independent_vector, const std::string &independent_column_name, const std::vector< std::vector< Tensor< 1, dim > > > &dependent_vectors, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template<int dim>
TableHandler make_table_tensors_tensors (const std::vector< Tensor< 1, dim > > &independent_vector, const std::vector< std::string > &independent_column_names, const std::vector< Tensor< 1, dim > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template<int dim>
TableHandler make_table_tensors_scalars (const std::vector< Tensor< 1, dim > > &independent_vector, const std::vector< std::string > &independent_column_names, const std::vector< double > &dependent_vector, const std::string &dependent_column_name, const unsigned int display_precision, const bool display_scientific_notation)
void check_file_exists (const std::string &file_name, const std::string &file_description)
void fill_table_from_file (TableHandler &table, const std::string &file_name, const std::string &delimiter)
void fill_vectors_from_file (std::map< std::string, std::vector< double > > &map, const std::string &file, const std::string &delimiter)
void fill_string_vectors_from_file (std::map< std::string, std::vector< std::string > > &map, const std::string &file, const std::string &delimiter)
void create_output_folder (const std::string &dirname)
void delete_output_folder (const std::string &dirname)
template TableHandler make_table_scalars_vectors (const std::vector< double > &independent_values, const std::string &independent_column_name, const std::vector< std::vector< double > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_vectors (const std::vector< unsigned int > &independent_values, const std::string &independent_column_name, const std::vector< std::vector< double > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_vectors (const std::vector< int > &independent_values, const std::string &independent_column_name, const std::vector< std::vector< double > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_tensors (const std::vector< double > &independent_values, const std::string &independent_column_name, const std::vector< Tensor< 1, 2 > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_tensors (const std::vector< double > &independent_values, const std::string &independent_column_name, const std::vector< Tensor< 1, 3 > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_tensors (const std::vector< double > &independent_values, const std::string &independent_column_name, const std::vector< std::vector< Tensor< 1, 2 > > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_tensors (const std::vector< double > &independent_values, const std::string &independent_column_name, const std::vector< std::vector< Tensor< 1, 3 > > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_tensors (const std::vector< unsigned int > &independent_values, const std::string &independent_column_name, const std::vector< Tensor< 1, 2 > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_tensors (const std::vector< unsigned int > &independent_values, const std::string &independent_column_name, const std::vector< Tensor< 1, 3 > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_tensors (const std::vector< unsigned int > &independent_values, const std::string &independent_column_name, const std::vector< std::vector< Tensor< 1, 2 > > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_tensors (const std::vector< unsigned int > &independent_values, const std::string &independent_column_name, const std::vector< std::vector< Tensor< 1, 3 > > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_tensors (const std::vector< int > &independent_values, const std::string &independent_column_name, const std::vector< Tensor< 1, 2 > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_tensors (const std::vector< int > &independent_values, const std::string &independent_column_name, const std::vector< Tensor< 1, 3 > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_tensors (const std::vector< int > &independent_values, const std::string &independent_column_name, const std::vector< std::vector< Tensor< 1, 2 > > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_scalars_tensors (const std::vector< int > &independent_values, const std::string &independent_column_name, const std::vector< std::vector< Tensor< 1, 3 > > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_tensors_tensors (const std::vector< Tensor< 1, 2 > > &independent_values, const std::vector< std::string > &independent_column_names, const std::vector< Tensor< 1, 2 > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_tensors_tensors (const std::vector< Tensor< 1, 3 > > &independent_values, const std::vector< std::string > &independent_column_names, const std::vector< Tensor< 1, 3 > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_tensors_scalars (const std::vector< Tensor< 1, 2 > > &independent_vector, const std::vector< std::string > &independent_column_names, const std::vector< double > &dependent_values, const std::string &dependent_column_name, const unsigned int display_precision, const bool display_scientific_notation)
template TableHandler make_table_tensors_scalars (const std::vector< Tensor< 1, 3 > > &independent_vector, const std::vector< std::string > &independent_column_names, const std::vector< double > &dependent_values, const std::string &dependent_column_name, const unsigned int display_precision, const bool display_scientific_notation)
std::string get_last_value_of_parameter (const std::string &file_name, const std::string &parameter_name)
int get_max_value_of_parameter (const std::string &file_name, const std::string &parameter_name)
unsigned int get_dimension (const std::string &file_name)
int get_max_subsection_size (const std::string &file_name, const bool require_subsection_size)
std::string concatenate_strings (const int argc, char **argv)
void print_version_info (const ConditionalOStream &pcout)
std::tuple< std::map< std::string, bool >, std::vector< std::string > > parse_args (int argc, char **argv)
void warn_deprecated_parameter_value (const std::string &parameter_name, const std::string &deprecated_value, const std::string &new_value)
void print_parameters_to_output_file (const ConditionalOStream &pcout, const ParameterHandler &prm, const std::string &file_name)
void interpret_escape_sequences (std::string &s)
void print_comment_to_output_file (const ConditionalOStream &pcout, ParameterHandler &prm)
void delete_vtu_and_pvd_files (const std::string &output_path)
template<int dim, typename VectorType>
void evaluate_values_at_points (const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const VectorType &solution_field, const std::vector< Point< dim > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< dim > &remote_point_evaluator, std::vector< double > &evaluated_scalar_values, const unsigned int first_selected_component)
template void evaluate_values_at_points< 2, GlobalVectorType > (const Mapping< 2 > &mapping, const DoFHandler< 2 > &dof_handler, const GlobalVectorType &solution_field, const std::vector< Point< 2 > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< 2 > &remote_point_evaluator, std::vector< double > &evaluated_scalar_values, const unsigned int first_selected_component)
template void evaluate_values_at_points< 3, GlobalVectorType > (const Mapping< 3 > &mapping, const DoFHandler< 3 > &dof_handler, const GlobalVectorType &solution_field, const std::vector< Point< 3 > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< 3 > &remote_point_evaluator, std::vector< double > &evaluated_scalar_values, const unsigned int first_selected_component)
template void evaluate_values_at_points< 2, GlobalBlockVectorType > (const Mapping< 2 > &mapping, const DoFHandler< 2 > &dof_handler, const GlobalBlockVectorType &solution_field, const std::vector< Point< 2 > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< 2 > &remote_point_evaluator, std::vector< double > &evaluated_scalar_values, const unsigned int first_selected_component)
template void evaluate_values_at_points< 3, GlobalBlockVectorType > (const Mapping< 3 > &mapping, const DoFHandler< 3 > &dof_handler, const GlobalBlockVectorType &solution_field, const std::vector< Point< 3 > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< 3 > &remote_point_evaluator, std::vector< double > &evaluated_scalar_values, const unsigned int first_selected_component)
template void evaluate_values_at_points< 2, LinearAlgebra::distributed::Vector< double > > (const Mapping< 2 > &mapping, const DoFHandler< 2 > &dof_handler, const LinearAlgebra::distributed::Vector< double > &solution_field, const std::vector< Point< 2 > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< 2 > &remote_point_evaluator, std::vector< double > &evaluated_scalar_values, const unsigned int first_selected_component)
template void evaluate_values_at_points< 3, LinearAlgebra::distributed::Vector< double > > (const Mapping< 3 > &mapping, const DoFHandler< 3 > &dof_handler, const LinearAlgebra::distributed::Vector< double > &solution_field, const std::vector< Point< 3 > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< 3 > &remote_point_evaluator, std::vector< double > &evaluated_scalar_values, const unsigned int first_selected_component)
template<int n_component, int dim, typename VectorType>
void evaluate_values_at_points (const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const VectorType &solution_field, const std::vector< Point< dim > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< dim > &remote_point_evaluator, std::vector< Tensor< 1, dim, double > > &evaluated_vector_values, const unsigned int first_selected_component)
template void evaluate_values_at_points< 2, 2, GlobalVectorType > (const Mapping< 2 > &mapping, const DoFHandler< 2 > &dof_handler, const GlobalVectorType &solution_field, const std::vector< Point< 2 > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< 2 > &remote_point_evaluator, std::vector< Tensor< 1, 2, double > > &evaluated_vector_values, const unsigned int first_selected_component)
template void evaluate_values_at_points< 3, 3, GlobalVectorType > (const Mapping< 3 > &mapping, const DoFHandler< 3 > &dof_handler, const GlobalVectorType &solution_field, const std::vector< Point< 3 > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< 3 > &remote_point_evaluator, std::vector< Tensor< 1, 3, double > > &evaluated_vector_values, const unsigned int first_selected_component)
template void evaluate_values_at_points< 2, 2, GlobalBlockVectorType > (const Mapping< 2 > &mapping, const DoFHandler< 2 > &dof_handler, const GlobalBlockVectorType &solution_field, const std::vector< Point< 2 > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< 2 > &remote_point_evaluator, std::vector< Tensor< 1, 2, double > > &evaluated_vector_values, const unsigned int first_selected_component)
template void evaluate_values_at_points< 3, 3, GlobalBlockVectorType > (const Mapping< 3 > &mapping, const DoFHandler< 3 > &dof_handler, const GlobalBlockVectorType &solution_field, const std::vector< Point< 3 > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< 3 > &remote_point_evaluator, std::vector< Tensor< 1, 3, double > > &evaluated_vector_values, const unsigned int first_selected_component)
template void evaluate_values_at_points< 2, 2, LinearAlgebra::distributed::Vector< double > > (const Mapping< 2 > &mapping, const DoFHandler< 2 > &dof_handler, const LinearAlgebra::distributed::Vector< double > &solution_field, const std::vector< Point< 2 > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< 2 > &remote_point_evaluator, std::vector< Tensor< 1, 2, double > > &evaluated_vector_values, const unsigned int first_selected_component)
template void evaluate_values_at_points< 3, 3, LinearAlgebra::distributed::Vector< double > > (const Mapping< 3 > &mapping, const DoFHandler< 3 > &dof_handler, const LinearAlgebra::distributed::Vector< double > &solution_field, const std::vector< Point< 3 > > &evaluation_points, Utilities::MPI::RemotePointEvaluation< 3 > &remote_point_evaluator, std::vector< Tensor< 1, 3, double > > &evaluated_vector_values, const unsigned int first_selected_component)

Function Documentation

◆ check_file_exists()

void check_file_exists ( const std::string & file_name,
const std::string & file_description )

Verify that a file that Lethe must read exists and can be opened, and raise an error stated in the user's terms otherwise.

This function is meant to be called right before a file whose path comes from the user, either from the command line or from the parameter file, is opened. It distinguishes a file name that was left empty, a file that does not exist and a file that exists but cannot be read, so that the user is told what to correct instead of facing the error that the reader of the file would raise further down.

Parameters
[in]file_namePath of the file, exactly as it was given by the user.
[in]file_descriptionRole of the file in the simulation. It is used to build the error message and should read naturally after "The", for example "parameter file given to the application" or "gmsh mesh file given by 'subsection mesh' - 'set file name'".

Definition at line 225 of file utilities.cc.

◆ concatenate_strings()

std::string concatenate_strings ( const int argc,
char ** argv )

Concatenate words which are passed from the command line to a main function into a single string in which the words are separated by space.

Concatenate words which are passed from the command line to a main function into a single string in which the words are seperated by space.

Parameters
[in]argcnumber of arguments in C style.
[in]argvarguments themselves in C style.

Definition at line 758 of file utilities.cc.

◆ create_output_folder()

void create_output_folder ( const std::string & dirname)

Creates the simulation output folder.

Parameters
[in]dirnameOutput directory name

Definition at line 401 of file utilities.cc.

◆ delete_output_folder()

void delete_output_folder ( const std::string & dirname)

Delete the output folder and its content.

Parameters
[in]dirnameOutput directory name.

Definition at line 407 of file utilities.cc.

◆ delete_vtu_and_pvd_files()

void delete_vtu_and_pvd_files ( const std::string & output_path)

Delete vtu and pvd files.

Definition at line 917 of file utilities.cc.

◆ evaluate_values_at_points() [1/2]

template<int dim, typename VectorType>
void evaluate_values_at_points ( const Mapping< dim > & mapping,
const DoFHandler< dim > & dof_handler,
const VectorType & solution_field,
const std::vector< Point< dim > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< dim > & remote_point_evaluator,
std::vector< double > & evaluated_scalar_values,
const unsigned int first_selected_component = 0 )

Evaluates the values of a scalar field at remote points of the domain from the mapping, the DoF handler and the solution field.

Template Parameters
dimDenotes the number of spatial dimensions.
VectorTypeVector type of the solution vector.
Parameters
[in]mappingMapping of the domain.
[in]dof_handlerDoF handler associated to the solution field.
[in]solution_fieldVector containing the solution field. For distributed meshes, ghost elements must be updated.
[in]evaluation_pointsVector of points where the values of the solution field are to be evaluated.
[in,out]remote_point_evaluatorUtilities::MPI::RemotePointEvaluation object used to evaluate values of the variable of interest at given points of the domain.
[in,out]evaluated_scalar_valuesVector of evaluated scalar values.
[in]first_selected_componentFirst component of the solution to select if the solution field is a vector field. This is used to extract the correct field when the solution vector contains multiple fields (e.g., velocity and pressure are stored in a same solution vector).
Remarks
If a given evaluation point is not within the simulated domain, an exception is thrown.

Definition at line 930 of file utilities.cc.

References points_are_in_domain().

◆ evaluate_values_at_points() [2/2]

template<int n_component, int dim, typename VectorType>
void evaluate_values_at_points ( const Mapping< dim > & mapping,
const DoFHandler< dim > & dof_handler,
const VectorType & solution_field,
const std::vector< Point< dim > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< dim > & remote_point_evaluator,
std::vector< Tensor< 1, dim, double > > & evaluated_vector_values,
const unsigned int first_selected_component = 0 )

Evaluates the values of a vector field at remote points of the domain from the mapping, the DoF handler and the solution field.

Template Parameters
n_componentNumber of components of the evaluated vector solution.
dimDenotes the number of spatial dimensions.
VectorTypeVector type of the solution vector.
Parameters
[in]mappingMapping of the domain.
[in]dof_handlerDoF handler associated to the solution field.
[in]solution_fieldVector containing the vector solution field.
[in]evaluation_pointsVector of points where the values of the solution field are to be evaluated.
[in,out]remote_point_evaluatorUtilities::MPI::RemotePointEvaluation object used to evaluate values of the variable of interest at given points of the domain.
[in,out]evaluated_vector_valuesVector of evaluated vector values.
[in]first_selected_componentFirst component of the solution to select. This is used to extract the correct fields when the solution vector contains multiple fields (e.g., velocity and pressure are stored in a same solution vector).
Remarks
If a given evaluation point is not within the simulated domain, an exception is thrown.

Definition at line 1027 of file utilities.cc.

References points_are_in_domain().

◆ evaluate_values_at_points< 2, 2, GlobalBlockVectorType >()

template void evaluate_values_at_points< 2, 2, GlobalBlockVectorType > ( const Mapping< 2 > & mapping,
const DoFHandler< 2 > & dof_handler,
const GlobalBlockVectorType & solution_field,
const std::vector< Point< 2 > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< 2 > & remote_point_evaluator,
std::vector< Tensor< 1, 2, double > > & evaluated_vector_values,
const unsigned int first_selected_component )

◆ evaluate_values_at_points< 2, 2, GlobalVectorType >()

template void evaluate_values_at_points< 2, 2, GlobalVectorType > ( const Mapping< 2 > & mapping,
const DoFHandler< 2 > & dof_handler,
const GlobalVectorType & solution_field,
const std::vector< Point< 2 > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< 2 > & remote_point_evaluator,
std::vector< Tensor< 1, 2, double > > & evaluated_vector_values,
const unsigned int first_selected_component )

◆ evaluate_values_at_points< 2, 2, LinearAlgebra::distributed::Vector< double > >()

template void evaluate_values_at_points< 2, 2, LinearAlgebra::distributed::Vector< double > > ( const Mapping< 2 > & mapping,
const DoFHandler< 2 > & dof_handler,
const LinearAlgebra::distributed::Vector< double > & solution_field,
const std::vector< Point< 2 > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< 2 > & remote_point_evaluator,
std::vector< Tensor< 1, 2, double > > & evaluated_vector_values,
const unsigned int first_selected_component )

◆ evaluate_values_at_points< 2, GlobalBlockVectorType >()

template void evaluate_values_at_points< 2, GlobalBlockVectorType > ( const Mapping< 2 > & mapping,
const DoFHandler< 2 > & dof_handler,
const GlobalBlockVectorType & solution_field,
const std::vector< Point< 2 > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< 2 > & remote_point_evaluator,
std::vector< double > & evaluated_scalar_values,
const unsigned int first_selected_component )

◆ evaluate_values_at_points< 2, GlobalVectorType >()

template void evaluate_values_at_points< 2, GlobalVectorType > ( const Mapping< 2 > & mapping,
const DoFHandler< 2 > & dof_handler,
const GlobalVectorType & solution_field,
const std::vector< Point< 2 > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< 2 > & remote_point_evaluator,
std::vector< double > & evaluated_scalar_values,
const unsigned int first_selected_component )

◆ evaluate_values_at_points< 2, LinearAlgebra::distributed::Vector< double > >()

template void evaluate_values_at_points< 2, LinearAlgebra::distributed::Vector< double > > ( const Mapping< 2 > & mapping,
const DoFHandler< 2 > & dof_handler,
const LinearAlgebra::distributed::Vector< double > & solution_field,
const std::vector< Point< 2 > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< 2 > & remote_point_evaluator,
std::vector< double > & evaluated_scalar_values,
const unsigned int first_selected_component )

◆ evaluate_values_at_points< 3, 3, GlobalBlockVectorType >()

template void evaluate_values_at_points< 3, 3, GlobalBlockVectorType > ( const Mapping< 3 > & mapping,
const DoFHandler< 3 > & dof_handler,
const GlobalBlockVectorType & solution_field,
const std::vector< Point< 3 > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< 3 > & remote_point_evaluator,
std::vector< Tensor< 1, 3, double > > & evaluated_vector_values,
const unsigned int first_selected_component )

◆ evaluate_values_at_points< 3, 3, GlobalVectorType >()

template void evaluate_values_at_points< 3, 3, GlobalVectorType > ( const Mapping< 3 > & mapping,
const DoFHandler< 3 > & dof_handler,
const GlobalVectorType & solution_field,
const std::vector< Point< 3 > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< 3 > & remote_point_evaluator,
std::vector< Tensor< 1, 3, double > > & evaluated_vector_values,
const unsigned int first_selected_component )

◆ evaluate_values_at_points< 3, 3, LinearAlgebra::distributed::Vector< double > >()

template void evaluate_values_at_points< 3, 3, LinearAlgebra::distributed::Vector< double > > ( const Mapping< 3 > & mapping,
const DoFHandler< 3 > & dof_handler,
const LinearAlgebra::distributed::Vector< double > & solution_field,
const std::vector< Point< 3 > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< 3 > & remote_point_evaluator,
std::vector< Tensor< 1, 3, double > > & evaluated_vector_values,
const unsigned int first_selected_component )

◆ evaluate_values_at_points< 3, GlobalBlockVectorType >()

template void evaluate_values_at_points< 3, GlobalBlockVectorType > ( const Mapping< 3 > & mapping,
const DoFHandler< 3 > & dof_handler,
const GlobalBlockVectorType & solution_field,
const std::vector< Point< 3 > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< 3 > & remote_point_evaluator,
std::vector< double > & evaluated_scalar_values,
const unsigned int first_selected_component )

◆ evaluate_values_at_points< 3, GlobalVectorType >()

template void evaluate_values_at_points< 3, GlobalVectorType > ( const Mapping< 3 > & mapping,
const DoFHandler< 3 > & dof_handler,
const GlobalVectorType & solution_field,
const std::vector< Point< 3 > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< 3 > & remote_point_evaluator,
std::vector< double > & evaluated_scalar_values,
const unsigned int first_selected_component )

◆ evaluate_values_at_points< 3, LinearAlgebra::distributed::Vector< double > >()

template void evaluate_values_at_points< 3, LinearAlgebra::distributed::Vector< double > > ( const Mapping< 3 > & mapping,
const DoFHandler< 3 > & dof_handler,
const LinearAlgebra::distributed::Vector< double > & solution_field,
const std::vector< Point< 3 > > & evaluation_points,
Utilities::MPI::RemotePointEvaluation< 3 > & remote_point_evaluator,
std::vector< double > & evaluated_scalar_values,
const unsigned int first_selected_component )

◆ fill_string_vectors_from_file()

void fill_string_vectors_from_file ( std::map< std::string, std::vector< std::string > > & map,
const std::string & file_name,
const std::string & delimiter = " " )

Function that read a file that was build from a dealii table and create a map with the key being the column name and the variable the vectors of data.

Parameters
[in,out]mapA map used to store the data based on column names.
[in]file_namePath to the file to read the table from.
[in]delimiterDelimiter used in the file to separate values. Default is a space (" ").

Definition at line 352 of file utilities.cc.

References check_file_exists().

◆ fill_table_from_file()

void fill_table_from_file ( TableHandler & table,
const std::string & file_name,
const std::string & delimiter = " " )

Reads a file generated by a deal.II TableHandler and fills a TableHandler with its data.

This function reads a table from a file and populates the given TableHandler. Warning: If the table already contains data, it will be erased.

Parameters
[in,out]tableThe table to be filled. Existing content will be overwritten.
[in]file_namePath to the file to read the table from.
[in]delimiterDelimiter used in the file to separate values. Default is a space (" ").

Definition at line 253 of file utilities.cc.

References check_file_exists().

◆ fill_vectors_from_file()

void fill_vectors_from_file ( std::map< std::string, std::vector< double > > & map,
const std::string & file_name,
const std::string & delimiter = " " )

function that read a file that was build from a dealii table and fill 2 vectors. The first vector contains all the columns names and the second one contained all the column data.

Parameters
[in,out]mapA map used to store the data based on column names.
[in]file_namePath to the file to read the table from.
[in]delimiterDelimiter used in the file to separate values. Default is a space (" ").

Definition at line 299 of file utilities.cc.

References check_file_exists().

◆ get_dimension()

unsigned int get_dimension ( const std::string & file_name)

Extract the dimension in which to run Lethe from the contents of the parameter file. This is something that we need to do before processing the parameter file since we need to know whether to use the dim=2 or dim=3 instantiation of the main classes.

Parameters
file_name[in]The file name from which dimension is read

Definition at line 670 of file utilities.cc.

References get_last_value_of_parameter().

◆ get_last_value_of_parameter()

std::string get_last_value_of_parameter ( const std::string & file_name,
const std::string & parameter_name )

Retrieves the value of a specific parameter from an input file. Returns an empty string if the parameter is not found. This function is adapted from ASPECT and is mainly used to parse the dimension of the problem before creating the full parameter parser.

Parameters
[in]file_nameFile from which we retrieve the parameter.
[in]parameter_nameName of the parameter to retrieve.
Returns
std::string Value of the parameter, or an empty string if not found.

Definition at line 585 of file utilities.cc.

References check_file_exists().

◆ get_max_subsection_size()

int get_max_subsection_size ( const std::string & file_name,
const bool require_subsection_size = true )

Extract the maximum value between the number of boundary conditions and the number of manifolds from the file. This value is linked to the "number" string defined in the simulation parameter file. It provides an estimate for the amount of parameters or manifolds and is used to determine the size of the vectors that will store boundary conditions and manifold data. This feature will need to be monitored extensively in the future.

Parameters
[in]file_nameThe file name from which the number of boundary conditions is read
[in]require_subsection_sizeIf true, the file must contain at least one "number" entry and an exception is raised otherwise. Solvers for which no variable size subsection is mandatory, such as the DEM solvers whose boundary conditions are declared with a "number of boundary conditions" entry, set this to false. A file without any "number" entry then yields a size of zero.
Returns
The maximum number of boundary conditions or manifolds.

Definition at line 736 of file utilities.cc.

References get_max_value_of_parameter().

◆ get_max_value_of_parameter()

int get_max_value_of_parameter ( const std::string & file_name,
const std::string & parameter_name )

Definition at line 625 of file utilities.cc.

References check_file_exists().

◆ interpret_escape_sequences()

void interpret_escape_sequences ( std::string & s)

Identify escape sequences listed below and apply them to the string.

  • "\n": Newline
  • "\t": Horizontal tab
  • "\r": Carriage return
  • "\b": Backspace
  • "\v": Vertical tab
Parameters
[in,out]sString to be modified if escape sequences are specified.

Definition at line 892 of file utilities.cc.

◆ make_table_scalars_tensors() [1/14]

template TableHandler make_table_scalars_tensors ( const std::vector< double > & independent_values,
const std::string & independent_column_name,
const std::vector< std::vector< Tensor< 1, 2 > > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_tensors() [2/14]

template TableHandler make_table_scalars_tensors ( const std::vector< double > & independent_values,
const std::string & independent_column_name,
const std::vector< std::vector< Tensor< 1, 3 > > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_tensors() [3/14]

template TableHandler make_table_scalars_tensors ( const std::vector< double > & independent_values,
const std::string & independent_column_name,
const std::vector< Tensor< 1, 2 > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_tensors() [4/14]

template TableHandler make_table_scalars_tensors ( const std::vector< double > & independent_values,
const std::string & independent_column_name,
const std::vector< Tensor< 1, 3 > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_tensors() [5/14]

template TableHandler make_table_scalars_tensors ( const std::vector< int > & independent_values,
const std::string & independent_column_name,
const std::vector< std::vector< Tensor< 1, 2 > > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_tensors() [6/14]

template TableHandler make_table_scalars_tensors ( const std::vector< int > & independent_values,
const std::string & independent_column_name,
const std::vector< std::vector< Tensor< 1, 3 > > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_tensors() [7/14]

template TableHandler make_table_scalars_tensors ( const std::vector< int > & independent_values,
const std::string & independent_column_name,
const std::vector< Tensor< 1, 2 > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_tensors() [8/14]

template TableHandler make_table_scalars_tensors ( const std::vector< int > & independent_values,
const std::string & independent_column_name,
const std::vector< Tensor< 1, 3 > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_tensors() [9/14]

template<int dim, typename T>
TableHandler make_table_scalars_tensors ( const std::vector< T > & independent_values,
const std::string & independent_column_name,
const std::vector< std::vector< Tensor< 1, dim > > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation = false )

Generate a table from a vector of scalar (independent variable) and a vector of vectors of Tensor<1,dim> (dependent variables).

Template Parameters
TScalar type of independent variables.
dimInteger that denotes the number of spatial dimensions.
Parameters
[in]independent_valuesVector of scalar values that serve as the independent variable (e.g., time).
[in]independent_column_nameLabel of the independent variable.
[in]dependent_vectorVector of vectors of Tensor<1,dim> containing dependent variables values (e.g., force).
[in]dependent_column_namesVector of strings representing the labels of dependent variables.
[in]display_precisionInteger indicating the precision at which the table is written.
[in]display_scientific_notationBoolean indicating if the values should be displayed in scientific notation (true) or not (false).
Returns
Table with the independent variable values followed by the dependent variables values.

Definition at line 98 of file utilities.cc.

◆ make_table_scalars_tensors() [10/14]

template<int dim, typename T>
TableHandler make_table_scalars_tensors ( const std::vector< T > & independent_values,
const std::string & independent_column_name,
const std::vector< Tensor< 1, dim > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation = false )

Generate a table from a vector of scalars (independent variable) and a vector of Tensor<1,dim> (dependent variables).

Template Parameters
TScalar type of independent variables.
dimInteger that denotes the number of spatial dimensions.
Parameters
[in]independent_valuesVector of scalar values that serve as the independent variable (e.g., time).
[in]independent_column_nameLabel of the independent variable.
[in]dependent_vectorVector of Tensor<1,dim> containing dependent variables values (e.g., force).
[in]dependent_column_namesVector of strings representing the labels of dependent variables.
[in]display_precisionInteger indicating the precision at which the table is written.
[in]display_scientific_notationBoolean indicating if the values should be displayed in scientific notation (true) or not (false).
Returns
Table with the independent variable values followed by the dependent variables values.

Definition at line 59 of file utilities.cc.

◆ make_table_scalars_tensors() [11/14]

template TableHandler make_table_scalars_tensors ( const std::vector< unsigned int > & independent_values,
const std::string & independent_column_name,
const std::vector< std::vector< Tensor< 1, 2 > > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_tensors() [12/14]

template TableHandler make_table_scalars_tensors ( const std::vector< unsigned int > & independent_values,
const std::string & independent_column_name,
const std::vector< std::vector< Tensor< 1, 3 > > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_tensors() [13/14]

template TableHandler make_table_scalars_tensors ( const std::vector< unsigned int > & independent_values,
const std::string & independent_column_name,
const std::vector< Tensor< 1, 2 > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_tensors() [14/14]

template TableHandler make_table_scalars_tensors ( const std::vector< unsigned int > & independent_values,
const std::string & independent_column_name,
const std::vector< Tensor< 1, 3 > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_vectors() [1/4]

template TableHandler make_table_scalars_vectors ( const std::vector< double > & independent_values,
const std::string & independent_column_name,
const std::vector< std::vector< double > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_vectors() [2/4]

template TableHandler make_table_scalars_vectors ( const std::vector< int > & independent_values,
const std::string & independent_column_name,
const std::vector< std::vector< double > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_scalars_vectors() [3/4]

template<typename T>
TableHandler make_table_scalars_vectors ( const std::vector< T > & independent_values,
const std::string & independent_column_name,
const std::vector< std::vector< double > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation = false )

Generate a table from a vector of scalars (independent variable) and a vector of vectors of scalars (dependent variables).

Template Parameters
TScalar type of independent variables.
Parameters
[in]independent_valuesVector of scalar values that serve as the independent variable (e.g., time).
[in]independent_column_nameLabel of the independent variable.
[in]dependent_vectorVector of vectors of scalar values containing dependant variables values.
[in]dependent_column_namesVector of strings representing the labels of dependent variables.
[in]display_precisionInteger indicating the precision at which the table is written.
[in]display_scientific_notationBoolean indicating if the values should be displayed in scientific notation (true) or not (false).
Returns
Table with the independent variable values followed by the dependent variables values.

Definition at line 24 of file utilities.cc.

◆ make_table_scalars_vectors() [4/4]

template TableHandler make_table_scalars_vectors ( const std::vector< unsigned int > & independent_values,
const std::string & independent_column_name,
const std::vector< std::vector< double > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_tensors_scalars() [1/3]

template TableHandler make_table_tensors_scalars ( const std::vector< Tensor< 1, 2 > > & independent_vector,
const std::vector< std::string > & independent_column_names,
const std::vector< double > & dependent_values,
const std::string & dependent_column_name,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_tensors_scalars() [2/3]

template TableHandler make_table_tensors_scalars ( const std::vector< Tensor< 1, 3 > > & independent_vector,
const std::vector< std::string > & independent_column_names,
const std::vector< double > & dependent_values,
const std::string & dependent_column_name,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_tensors_scalars() [3/3]

template<int dim>
TableHandler make_table_tensors_scalars ( const std::vector< Tensor< 1, dim > > & independent_vector,
const std::vector< std::string > & independent_column_names,
const std::vector< double > & dependent_values,
const std::string & dependent_column_name,
const unsigned int display_precision,
const bool display_scientific_notation = false )

Generate a table from a vector of Tensor<1,dim> (independent variables) and a vector of scalars (dependent variable).

Template Parameters
dimInteger that denotes the number of spatial dimensions.
Parameters
[in]independent_vectorVector of Tensor<1,dim> that serves as the independent variable (e.g., position).
[in]independent_column_namesVector of strings representing labels of the independent tensor.
[in]dependent_valuesVector of doubles containing dependent variables values (e.g., force).
[in]dependent_column_nameLabel of the dependent variable.
[in]display_precisionInteger indicating the precision at which the table is written.
[in]display_scientific_notationBoolean indicating if the values should be displayed in scientific notation (true) or not (false).
Returns
Table with the independent variables values followed by the dependent variable values.

Definition at line 189 of file utilities.cc.

◆ make_table_tensors_tensors() [1/3]

template TableHandler make_table_tensors_tensors ( const std::vector< Tensor< 1, 2 > > & independent_values,
const std::vector< std::string > & independent_column_names,
const std::vector< Tensor< 1, 2 > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_tensors_tensors() [2/3]

template TableHandler make_table_tensors_tensors ( const std::vector< Tensor< 1, 3 > > & independent_values,
const std::vector< std::string > & independent_column_names,
const std::vector< Tensor< 1, 3 > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation )

◆ make_table_tensors_tensors() [3/3]

template<int dim>
TableHandler make_table_tensors_tensors ( const std::vector< Tensor< 1, dim > > & independent_vector,
const std::vector< std::string > & independent_column_names,
const std::vector< Tensor< 1, dim > > & dependent_vector,
const std::vector< std::string > & dependent_column_names,
const unsigned int display_precision,
const bool display_scientific_notation = false )

Generate a table from a vector of Tensor<1,dim> (independent variables) and a vector of Tensor<1,dim> (dependent variables).

Template Parameters
dimInteger that denotes the number of spatial dimensions.
Parameters
[in]independent_vectorVector of Tensor<1,dim> that serves as the independent variable (e.g., position).
[in]independent_column_namesVector of strings representing labels of the independent tensor.
[in]dependent_vectorVector of vectors of Tensor<1,dim> containing dependent variables values (e.g., force).
[in]dependent_column_namesVector of strings representing the labels of dependent variables.
[in]display_precisionInteger indicating the precision at which the table is written.
[in]display_scientific_notationBoolean indicating if the values should be displayed in scientific notation (true) or not (false).
Returns
Table with the independent variables values followed by the dependent variables values.

Definition at line 147 of file utilities.cc.

◆ parse_args()

std::tuple< std::map< std::string, bool >, std::vector< std::string > > parse_args ( int argc,
char ** argv )

Parse the arguments given to the application.

Parameters
[in]argcNumber of arguments
[in]argvArray of strings representing the arguments
Returns
Tuple containing a map with the command line flags and a boolean set to 1 for the specific flag; and a vector of strings with the rest of the arguments that are not flags; in Lethe, this corresponds to the parameter file given to the application.

Definition at line 800 of file utilities.cc.

◆ print_comment_to_output_file()

void print_comment_to_output_file ( const ConditionalOStream & pcout,
ParameterHandler & prm )

Print a user comment at the beginning of the simulation on the console output.

Parameters
[in]pcoutParallel console output stream.
[in,out]prmParameterHandler. specified.

Definition at line 902 of file utilities.cc.

References interpret_escape_sequences().

◆ print_parameters_to_output_file()

void print_parameters_to_output_file ( const ConditionalOStream & pcout,
const ParameterHandler & prm,
const std::string & file_name )

Print the parameters given by the parameter file of the application.

Parameters
[in]pcoutParallel output stream
[in]prmObject containing the parameters parsed from the parameter file

Definition at line 865 of file utilities.cc.

References get_last_value_of_parameter().

◆ print_version_info()

void print_version_info ( const ConditionalOStream & pcout)

Print the information of the deal.II and Lethe branches used to run an application in the "git describe" format.

Parameters
[in]pcoutParallel output stream

Definition at line 775 of file utilities.cc.

◆ warn_deprecated_parameter_value()

void warn_deprecated_parameter_value ( const std::string & parameter_name,
const std::string & deprecated_value,
const std::string & new_value )

Print a warning stating that a deprecated value was given to a parameter, along with the value which replaces it. The warning is only printed by the first MPI process.

Parameters
[in]parameter_nameName of the parameter in the parameter file.
[in]deprecated_valueDeprecated value which was given.
[in]new_valueValue which replaces deprecated_value.

Definition at line 839 of file utilities.cc.