ASPECT
Public Member Functions | Private Member Functions | Private Attributes | List of all members
aspect::Utilities::AsciiDataLookup< dim > Class Template Reference

Public Member Functions

 AsciiDataLookup (const unsigned int components, const double scale_factor)
 
 AsciiDataLookup (const double scale_factor)
 
void load_file (const std::string &filename, const MPI_Comm &communicator)
 
double get_data (const Point< dim > &position, const unsigned int component) const
 
std::vector< std::string > get_column_names () const
 
bool has_equidistant_coordinates () const
 
unsigned int get_column_index_from_name (const std::string &column_name) const
 
std::string get_column_name_from_index (const unsigned int column_index) const
 
double get_maximum_component_value (const unsigned int component) const
 

Private Member Functions

TableIndices< dim > compute_table_indices (const unsigned int i) const
 

Private Attributes

unsigned int components
 
std::vector< std::string > data_component_names
 
std::vector< std::unique_ptr< Function< dim > > > data
 
std::array< std::vector< double >, dim > coordinate_values
 
std::vector< double > maximum_component_value
 
std::array< std::pair< double, double >, dim > grid_extent
 
TableIndices< dim > table_points
 
const double scale_factor
 
bool coordinate_values_are_equidistant
 

Detailed Description

template<int dim>
class aspect::Utilities::AsciiDataLookup< dim >

AsciiDataLookup reads in files containing input data in ascii format. Note the required format of the input data: The first lines may contain any number of comments if they begin with '#', but one of these lines needs to contain the number of grid points in each dimension as for example '# POINTS: 3 3'. The comments can optionally be followed by a single line, which does not start with '#', containing the names of the data columns. The order of the following data columns has to be 'coordinates data' with dim coordinate columns and components data columns. Note that the data in the input files need to be sorted in a specific order: the first coordinate needs to ascend first, followed by the second and so on in order to assign the correct data to the prescribed coordinates. The coordinates do not need to be equidistant.

Definition at line 544 of file utilities.h.

Constructor & Destructor Documentation

§ AsciiDataLookup() [1/2]

template<int dim>
aspect::Utilities::AsciiDataLookup< dim >::AsciiDataLookup ( const unsigned int  components,
const double  scale_factor 
)

Constructor that explicitly prescribes the number of data columns in the data file. If a list of data components is provided in the data file it is checked that the length of this list is consistent with this number of components. This constructor is mostly provided for backwards compatibility. Not prescribing the number of components and instead reading them from the input file allows for more flexible files.

§ AsciiDataLookup() [2/2]

template<int dim>
aspect::Utilities::AsciiDataLookup< dim >::AsciiDataLookup ( const double  scale_factor)

This constructor relies on the list of column names at the beginning of the model file to determine the number of data components, therefore when using this constructor it is necessary to provide this list in the first uncommented line of the data file.

Member Function Documentation

§ load_file()

template<int dim>
void aspect::Utilities::AsciiDataLookup< dim >::load_file ( const std::string &  filename,
const MPI_Comm &  communicator 
)

Loads a data text file. Throws an exception if the file does not exist, if the data file format is incorrect or if the file grid changes over model runtime.

§ get_data()

template<int dim>
double aspect::Utilities::AsciiDataLookup< dim >::get_data ( const Point< dim > &  position,
const unsigned int  component 
) const

Returns the computed data (velocity, temperature, etc. - according to the used plugin) in Cartesian coordinates.

Parameters
positionThe current position to compute the data (velocity, temperature, etc.)
componentThe index of the data column to be returned.

§ get_column_names()

template<int dim>
std::vector<std::string> aspect::Utilities::AsciiDataLookup< dim >::get_column_names ( ) const

Returns a vector that contains the names of all data columns in the order of their appearance in the data file (and their order in the memory data table). Returns an empty vector if no names are provided or the file is not read in yet.

§ has_equidistant_coordinates()

template<int dim>
bool aspect::Utilities::AsciiDataLookup< dim >::has_equidistant_coordinates ( ) const

Returns whether the stored coordinates are equidistant. If coordinates are equidistant the lookup is more efficient. Returns false if no coordinates are loaded at the moment.

§ get_column_index_from_name()

template<int dim>
unsigned int aspect::Utilities::AsciiDataLookup< dim >::get_column_index_from_name ( const std::string &  column_name) const

Returns the column index of a column with the given name column_name. Throws an exception if no such column exists or no names were provided in the file.

§ get_column_name_from_index()

template<int dim>
std::string aspect::Utilities::AsciiDataLookup< dim >::get_column_name_from_index ( const unsigned int  column_index) const

Returns a string that contains the name of the column with index column_index. Throws an exception if no such column exists or no name was provided in the file.

§ get_maximum_component_value()

template<int dim>
double aspect::Utilities::AsciiDataLookup< dim >::get_maximum_component_value ( const unsigned int  component) const

Return the maximum value of the component values.

§ compute_table_indices()

template<int dim>
TableIndices<dim> aspect::Utilities::AsciiDataLookup< dim >::compute_table_indices ( const unsigned int  i) const
private

Computes the table indices of each entry in the input data file. The index depends on dim, grid_dim and the number of components.

Member Data Documentation

§ components

template<int dim>
unsigned int aspect::Utilities::AsciiDataLookup< dim >::components
private

The number of data components read in (=columns in the data file).

Definition at line 630 of file utilities.h.

§ data_component_names

template<int dim>
std::vector<std::string> aspect::Utilities::AsciiDataLookup< dim >::data_component_names
private

The names of the data components in the columns of the read file. Does not contain any strings if none are provided in the first uncommented line of the file.

Definition at line 637 of file utilities.h.

§ data

template<int dim>
std::vector<std::unique_ptr<Function<dim> > > aspect::Utilities::AsciiDataLookup< dim >::data
private

Interpolation functions to access the data. Either InterpolatedUniformGridData or InterpolatedTensorProductGridData; the type is determined from the grid specified in the data file.

Definition at line 644 of file utilities.h.

§ coordinate_values

template<int dim>
std::array<std::vector<double>,dim> aspect::Utilities::AsciiDataLookup< dim >::coordinate_values
private

The coordinate values in each direction as specified in the data file.

Definition at line 649 of file utilities.h.

§ maximum_component_value

template<int dim>
std::vector<double> aspect::Utilities::AsciiDataLookup< dim >::maximum_component_value
private

The maximum value of each component

Definition at line 654 of file utilities.h.

§ grid_extent

template<int dim>
std::array<std::pair<double,double>,dim> aspect::Utilities::AsciiDataLookup< dim >::grid_extent
private

The min and max of the coordinates in the data file.

Definition at line 659 of file utilities.h.

§ table_points

template<int dim>
TableIndices<dim> aspect::Utilities::AsciiDataLookup< dim >::table_points
private

Number of points in the data grid as specified in the data file.

Definition at line 664 of file utilities.h.

§ scale_factor

template<int dim>
const double aspect::Utilities::AsciiDataLookup< dim >::scale_factor
private

Scales the data boundary condition by a scalar factor. Can be used to transform the unit of the data.

Definition at line 670 of file utilities.h.

§ coordinate_values_are_equidistant

template<int dim>
bool aspect::Utilities::AsciiDataLookup< dim >::coordinate_values_are_equidistant
private

Stores whether the coordinate values are equidistant or not, this determines the type of data function stored.

Definition at line 676 of file utilities.h.


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