OGS
ParameterLib::RasterParameter Struct Referencefinal

Detailed Description

Definition at line 18 of file RasterParameter.h.

#include <RasterParameter.h>

Inheritance diagram for ParameterLib::RasterParameter:
[legend]
Collaboration diagram for ParameterLib::RasterParameter:
[legend]

Public Member Functions

 RasterParameter (std::string const &name_, GeoLib::NamedRaster const &named_raster)
 
bool isTimeDependent () const override
 
int getNumberOfGlobalComponents () const override
 
std::vector< double > operator() (double const, SpatialPosition const &pos) const override
 Returns the parameter value at the given time and position.
 
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > getNodalValuesOnElement (MeshLib::Element const &element, double const t) const override
 Returns a matrix of values for all nodes of the given element.
 
- Public Member Functions inherited from ParameterLib::Parameter< double >
 ~Parameter () override=default
 
 ParameterBase (std::string name_, MeshLib::Mesh const *mesh=nullptr)
 
- Public Member Functions inherited from ParameterLib::ParameterBase
 ParameterBase (std::string name_, MeshLib::Mesh const *mesh=nullptr)
 
virtual ~ParameterBase ()=default
 
void setCoordinateSystem (CoordinateSystem const &coordinate_system)
 
virtual void initialize (std::vector< std::unique_ptr< ParameterBase > > const &)
 
MeshLib::Mesh const * mesh () const
 

Private Attributes

GeoLib::NamedRaster const & _named_raster
 

Additional Inherited Members

- Public Attributes inherited from ParameterLib::ParameterBase
std::string const name
 
- Protected Member Functions inherited from ParameterLib::ParameterBase
std::vector< double > rotateWithCoordinateSystem (std::vector< double > const &values, SpatialPosition const &pos) const
 
- Protected Attributes inherited from ParameterLib::ParameterBase
std::optional< CoordinateSystem_coordinate_system
 
MeshLib::Mesh const * _mesh
 

Constructor & Destructor Documentation

◆ RasterParameter()

ParameterLib::RasterParameter::RasterParameter ( std::string const & name_,
GeoLib::NamedRaster const & named_raster )
inlineexplicit

Definition at line 20 of file RasterParameter.h.

22 : Parameter<double>(name_), _named_raster(named_raster)
23 {
24 }
GeoLib::NamedRaster const & _named_raster

Member Function Documentation

◆ getNodalValuesOnElement()

Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > ParameterLib::RasterParameter::getNodalValuesOnElement ( MeshLib::Element const & element,
double const t ) const
inlineoverridevirtual

Returns a matrix of values for all nodes of the given element.

Reimplemented from ParameterLib::Parameter< double >.

Definition at line 43 of file RasterParameter.h.

45 {
46 auto const n_nodes = element.getNumberOfNodes();
47 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> result(
49
50 SpatialPosition position;
51 auto const nodes = element.getNodes();
52 for (unsigned i = 0; i < n_nodes; ++i)
53 {
54 position.setCoordinates(*(nodes[i]));
55 auto const& values = this->operator()(t, position);
56 result.row(i) =
57 Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, 1> const>(
58 values.data(), values.size());
59 }
60
61 return result;
62 }
std::vector< double > operator()(double const, SpatialPosition const &pos) const override
Returns the parameter value at the given time and position.
int getNumberOfGlobalComponents() const override

References MeshLib::Element::getNodes(), getNumberOfGlobalComponents(), MeshLib::Element::getNumberOfNodes(), operator()(), and ParameterLib::SpatialPosition::setCoordinates().

◆ getNumberOfGlobalComponents()

int ParameterLib::RasterParameter::getNumberOfGlobalComponents ( ) const
inlineoverridevirtual

Returns the number of components this Parameter has at every position and point in time.

Implements ParameterLib::Parameter< double >.

Definition at line 28 of file RasterParameter.h.

28{ return 1; }

Referenced by getNodalValuesOnElement().

◆ isTimeDependent()

bool ParameterLib::RasterParameter::isTimeDependent ( ) const
inlineoverridevirtual

Implements ParameterLib::ParameterBase.

Definition at line 26 of file RasterParameter.h.

26{ return false; }

◆ operator()()

std::vector< double > ParameterLib::RasterParameter::operator() ( double const t,
SpatialPosition const & pos ) const
inlineoverridevirtual

Returns the parameter value at the given time and position.

Implements ParameterLib::Parameter< double >.

Definition at line 30 of file RasterParameter.h.

32 {
33 auto const& coordinates = pos.getCoordinates();
34 if (!coordinates)
35 {
36 OGS_FATAL("RasterParameter::operator(): couldn't get coordinates.");
37 }
38 auto const value = _named_raster.raster->getValueAtPoint(*coordinates);
39 return {value};
40 }
#define OGS_FATAL(...)
Definition Error.h:26
std::unique_ptr< GeoLib::Raster > raster
Definition Raster.h:157

References _named_raster, ParameterLib::SpatialPosition::getCoordinates(), OGS_FATAL, and GeoLib::NamedRaster::raster.

Referenced by getNodalValuesOnElement().

Member Data Documentation

◆ _named_raster

GeoLib::NamedRaster const& ParameterLib::RasterParameter::_named_raster
private

Definition at line 65 of file RasterParameter.h.

Referenced by operator()().


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