OGS 6.2.0-244-g47b8a9a9d
MaterialPropertyLib Namespace Reference

Detailed Description

Classes

class  Component
 This class defines components (substances). More...
 
class  Constant
 
struct  ExponentData
 
class  ExponentialProperty
 
struct  IndependentVariable
 
class  LinearProperty
 
class  MaterialSpatialDistributionMap
 
class  Medium
 
class  Phase
 
class  Property
 
struct  Water
 

Typedefs

using PropertyArray = std::array< std::unique_ptr< Property >, PropertyType::number_of_properties >
 
using PropertyDataType = boost::variant< double, Pair, Vector, Tensor2d, SymmTensor, Tensor, std::string >
 
using Pair = std::array< double, 2 >
 
using Vector = std::array< double, 3 >
 
using SymmTensor = std::array< double, 6 >
 
using Tensor2d = std::array< double, 4 >
 Very simple 2d tensor data type for holding tensor components. More...
 
using Tensor = std::array< double, 9 >
 
using VariableType = boost::variant< double, Vector >
 
using VariableArray = std::array< VariableType, static_cast< int >(Variable::number_of_variables)>
 

Enumerations

enum  PropertyDataTypeName {
  nScalar, nPair, nVector, nSymmTensor,
  nTensor
}
 
enum  PropertyType : int {
  acentric_factor, binary_interaction_coefficient, biot_coefficient, brooks_corey_exponent,
  bulk_modulus, critical_density, critical_pressure, critical_temperature,
  compressibility, density, drhodT, effective_stress,
  entry_pressure, fredlund_parameters, heat_capacity, longitudinal_dispersivity,
  molar_mass, mole_fraction, molecular_diffusion, name,
  permeability, phase_velocity, porosity, reference_density,
  reference_temperature, reference_pressure, relative_permeability, residual_gas_saturation,
  residual_liquid_saturation, saturation, specific_heat_capacity, storage,
  thermal_conductivity, thermal_expansivity, thermal_longitudinal_dispersivity, thermal_transversal_dispersivity,
  transversal_dispersivity, viscosity, number_of_properties
}
 
enum  Variable : int {
  Variable::phase_pressure, Variable::capillary_pressure, Variable::density, Variable::temperature,
  Variable::liquid_saturation, Variable::displacement, Variable::number_of_variables
}
 

Functions

std::unique_ptr< ComponentnewComponent (std::string const &component_name, bool &isCustomComponent)
 
std::vector< std::unique_ptr< Component > > createComponents (boost::optional< BaseLib::ConfigTree > const &config)
 
std::unique_ptr< MaterialSpatialDistributionMapcreateMaterialSpatialDistributionMap (std::map< int, std::unique_ptr< Medium >> const &media, MeshLib::Mesh const &mesh)
 
std::unique_ptr< MediumcreateMedium (BaseLib::ConfigTree const &config)
 
std::vector< std::unique_ptr< Phase > > createPhases (boost::optional< BaseLib::ConfigTree > const &config)
 
std::unique_ptr< PropertyArraycreateProperties (boost::optional< BaseLib::ConfigTree > const &config)
 
std::size_t getType (Property const &p)
 
void overwriteExistingProperties (PropertyArray &properties, PropertyArray &new_properties)
 
PropertyType convertStringToProperty (std::string const &inString)
 
Variable convertStringToVariable (std::string const &input)
 
double getScalar (VariableType pv)
 This method returns a value of type double from the variables array. More...
 

Variables

static const std::array< std::string, PropertyType::number_of_properties > property_enum_to_string
 

Typedef Documentation

◆ Pair

using MaterialPropertyLib::Pair = typedef std::array<double, 2>

Very simple vector data type for holding a pair of values.

Definition at line 23 of file VariableType.h.

◆ PropertyArray

typedef std::array< std::unique_ptr< Property >, PropertyType::number_of_properties > MaterialPropertyLib::PropertyArray

This data type is based on a std::array. It can hold pointers to objects of class Property or its inheritors. The size of this array is determined by the number of entries of the PropertyType enumerator.

Definition at line 32 of file CreateProperty.h.

◆ PropertyDataType

using MaterialPropertyLib::PropertyDataType = typedef boost:: variant<double, Pair, Vector, Tensor2d, SymmTensor, Tensor, std::string>

Definition at line 37 of file Property.h.

◆ SymmTensor

using MaterialPropertyLib::SymmTensor = typedef std::array<double, 6>

Simple symmetric tensor data type for holding xx, yy, zz, xy, xz, yz tensor components.

Definition at line 31 of file VariableType.h.

◆ Tensor

using MaterialPropertyLib::Tensor = typedef std::array<double, 9>

Very simple tensor data type for holding tensor components.

Definition at line 38 of file VariableType.h.

◆ Tensor2d

using MaterialPropertyLib::Tensor2d = typedef std::array<double, 4>

Very simple 2d tensor data type for holding tensor components.

Definition at line 34 of file VariableType.h.

◆ VariableArray

using MaterialPropertyLib::VariableArray = typedef std::array<VariableType, static_cast<int>(Variable::number_of_variables)>

The VariableArray is a std::array of fixed size. Its size is determined by the Variable enumerator list. Data type of that array is defined by the VariableType definition.

Definition at line 62 of file VariableType.h.

◆ VariableType

using MaterialPropertyLib::VariableType = typedef boost::variant<double, Vector>

Data type for primary variables, designed to contain both scalar and vector data.

Definition at line 56 of file VariableType.h.

◆ Vector

using MaterialPropertyLib::Vector = typedef std::array<double, 3>

Very simple vector data type for holding vector components.

Definition at line 27 of file VariableType.h.

Enumeration Type Documentation

◆ PropertyDataTypeName

This is a custom data type for arbitrary properties, based on the boost::variant container. It can hold scalars, vectors, tensors, and so forth.

Enumerator
nScalar 
nPair 
nVector 
nSymmTensor 
nTensor 

Definition at line 27 of file Property.h.

◆ PropertyType

PropertyType is an enumerator list of all known properties of a substance. This includes all properties on all scales (i.e. component, phase, and medium scales). It is used as an index for the PropertyArray of the materials. If a necessary property is not in the list, simply add a new one in alphabetical order (of course, except for the last entry). Please note that any of these entries must also appear in below convert functions.

Enumerator
acentric_factor 
binary_interaction_coefficient 
biot_coefficient 
brooks_corey_exponent 
bulk_modulus 
critical_density 
critical_pressure 
critical_temperature 
compressibility 
density 
drhodT 
effective_stress 
entry_pressure 
fredlund_parameters 
heat_capacity 
longitudinal_dispersivity 

used to compute the hydrodynamic dispersion tensor.

molar_mass 
mole_fraction 
molecular_diffusion 

used to compute the hydrodynamic dispersion tensor.

name 
permeability 
phase_velocity 
porosity 
reference_density 
reference_temperature 
reference_pressure 
relative_permeability 
residual_gas_saturation 
residual_liquid_saturation 
saturation 
specific_heat_capacity 
storage 
thermal_conductivity 
thermal_expansivity 
thermal_longitudinal_dispersivity 
thermal_transversal_dispersivity 
transversal_dispersivity 

used to compute the hydrodynamic dispersion tensor.

viscosity 
number_of_properties 

Definition at line 35 of file PropertyType.h.

35  : int
36 {
46  density,
47  drhodT,
54  molar_mass,
58  name,
61  porosity,
68  saturation,
70  storage,
77  viscosity,
79 };
used to compute the hydrodynamic dispersion tensor.
Definition: PropertyType.h:57
used to compute the hydrodynamic dispersion tensor.
Definition: PropertyType.h:53
used to compute the hydrodynamic dispersion tensor.
Definition: PropertyType.h:76

◆ Variable

enum MaterialPropertyLib::Variable : int
strong

Enum Variable is simply a list of all commonly used variables that are used to determine the size of the VariableArray. If the variable of your choice is missing, simply add it somewhere at the list, but above the last entry.

Enumerator
phase_pressure 
capillary_pressure 
density 
temperature 
liquid_saturation 
displacement 
number_of_variables 

Definition at line 43 of file VariableType.h.

Function Documentation

◆ convertStringToProperty()

PropertyType MaterialPropertyLib::convertStringToProperty ( std::string const &  inString)
inline

This function converts a string (e.g. a string from the configuration-tree) into one of the entries of the PropertyType enumerator. To avoid confusion, I suggest that the syntax of the properties in the input-files (i.e. the strings) have to be identical to the syntax of the entries in the enumerator.

Definition at line 86 of file PropertyType.h.

References acentric_factor, binary_interaction_coefficient, biot_coefficient, brooks_corey_exponent, bulk_modulus, compressibility, critical_density, critical_pressure, critical_temperature, density, drhodT, effective_stress, entry_pressure, fredlund_parameters, heat_capacity, longitudinal_dispersivity, molar_mass, mole_fraction, molecular_diffusion, name, number_of_properties, OGS_FATAL, permeability, phase_velocity, porosity, reference_density, reference_pressure, reference_temperature, relative_permeability, residual_gas_saturation, residual_liquid_saturation, saturation, specific_heat_capacity, storage, thermal_conductivity, thermal_expansivity, thermal_longitudinal_dispersivity, thermal_transversal_dispersivity, transversal_dispersivity, and viscosity.

Referenced by createProperties().

87 {
88  if (boost::iequals(inString, "acentric_factor"))
89  {
91  }
92  if (boost::iequals(inString, "binary_interaction_coefficient"))
93  {
95  }
96  if (boost::iequals(inString, "biot_coefficient"))
97  {
99  }
100  if (boost::iequals(inString, "brooks_corey_exponent"))
101  {
103  }
104  if (boost::iequals(inString, "bulk_modulus"))
105  {
107  }
108  if (boost::iequals(inString, "critical_density"))
109  {
111  }
112  if (boost::iequals(inString, "critical_pressure"))
113  {
115  }
116  if (boost::iequals(inString, "critical_temperature"))
117  {
119  }
120  if (boost::iequals(inString, "compressibility"))
121  {
123  }
124  if (boost::iequals(inString, "density"))
125  {
126  return PropertyType::density;
127  }
128  if (boost::iequals(inString, "drhodT"))
129  {
130  return PropertyType::drhodT;
131  }
132  if (boost::iequals(inString, "effective_stress"))
133  {
135  }
136  if (boost::iequals(inString, "entry_pressure"))
137  {
139  }
140  if (boost::iequals(inString, "fredlund_parameters"))
141  {
143  }
144  if (boost::iequals(inString, "heat_capacity"))
145  {
147  }
148  if (boost::iequals(inString, "longitudinal_dispersivity"))
149  {
151  }
152  if (boost::iequals(inString, "molar_mass"))
153  {
155  }
156  if (boost::iequals(inString, "mole_fraction"))
157  {
159  }
160  if (boost::iequals(inString, "molecular_diffusion"))
161  {
163  }
164  if (boost::iequals(inString, "name"))
165  {
166  return PropertyType::name;
167  }
168  if (boost::iequals(inString, "permeability"))
169  {
171  }
172  if (boost::iequals(inString, "porosity"))
173  {
174  return PropertyType::porosity;
175  }
176  if (boost::iequals(inString, "phase_velocity"))
177  {
179  }
180  if (boost::iequals(inString, "reference_density"))
181  {
183  }
184  if (boost::iequals(inString, "reference_temperature"))
185  {
187  }
188  if (boost::iequals(inString, "reference_pressure"))
189  {
191  }
192  if (boost::iequals(inString, "relative_permeability"))
193  {
195  }
196  if (boost::iequals(inString, "residual_gas_saturation"))
197  {
199  }
200  if (boost::iequals(inString, "residual_liquid_saturation"))
201  {
203  }
204  if (boost::iequals(inString, "saturation"))
205  {
207  }
208  if (boost::iequals(inString, "specific_heat_capacity"))
209  {
211  }
212  if (boost::iequals(inString, "storage"))
213  {
214  return PropertyType::storage;
215  }
216  if (boost::iequals(inString, "thermal_conductivity"))
217  {
219  }
220  if (boost::iequals(inString, "thermal_expansivity"))
221  {
223  }
224  if (boost::iequals(inString, "thermal_longitudinal_dispersivity"))
225  {
227  }
228  if (boost::iequals(inString, "thermal_transversal_dispersivity"))
229  {
231  }
232  if (boost::iequals(inString, "transversal_dispersivity"))
233  {
235  }
236  if (boost::iequals(inString, "viscosity"))
237  {
239  }
240 
241  OGS_FATAL(
242  "The property name '%s' does not correspond to any known property",
243  inString.c_str());
244 
245  return PropertyType::number_of_properties; // to avoid the 'no return'
246  // warning
247 }
used to compute the hydrodynamic dispersion tensor.
Definition: PropertyType.h:57
used to compute the hydrodynamic dispersion tensor.
Definition: PropertyType.h:53
used to compute the hydrodynamic dispersion tensor.
Definition: PropertyType.h:76
#define OGS_FATAL(fmt,...)
Definition: Error.h:63

◆ convertStringToVariable()

Variable MaterialPropertyLib::convertStringToVariable ( std::string const &  input)

Definition at line 18 of file VariableType.cpp.

References capillary_pressure, density, displacement, liquid_saturation, number_of_variables, OGS_FATAL, phase_pressure, and temperature.

Referenced by anonymous_namespace{CreateProperty.cpp}::createProperty(), and getScalar().

19 {
20  if (boost::iequals(input, "phase_pressure"))
21  {
22  return Variable::phase_pressure;
23  }
24  if (boost::iequals(input, "capillary_pressure"))
25  {
26  return Variable::capillary_pressure;
27  }
28  if (boost::iequals(input, "density"))
29  {
30  return Variable::density;
31  }
32  if (boost::iequals(input, "temperature"))
33  {
34  return Variable::temperature;
35  }
36  if (boost::iequals(input, "liquid_saturation"))
37  {
38  return Variable::liquid_saturation;
39  }
40  if (boost::iequals(input, "displacement"))
41  {
42  return Variable::displacement;
43  }
44 
45  OGS_FATAL(
46  "The variable name '%s' does not correspond to any known variable",
47  input.c_str());
48 
49  return Variable::number_of_variables; // to avoid the 'no return' warning
50 }
#define OGS_FATAL(fmt,...)
Definition: Error.h:63

◆ createComponents()

std::vector< std::unique_ptr< Component > > MaterialPropertyLib::createComponents ( boost::optional< BaseLib::ConfigTree > const &  config)

The method creates components based on config subtree.

Just like a phase, a component can have a name. But, in this case, the name has an important task. If a name is given, a specific component class referring to that name with corresponding physical material properties is created. Assigning a name is optional; If no name is given, a custom component without predefined properties is created.

Input File Parameter:
prj__media__medium__phases__phase__components__component

Definition at line 66 of file CreateComponent.cpp.

References anonymous_namespace{CreateComponent.cpp}::createComponent(), and OGS_FATAL.

Referenced by anonymous_namespace{CreatePhase.cpp}::createPhase().

68 {
69  if (!config)
70  {
71  return {};
72  }
73 
74  std::vector<std::unique_ptr<Component>> components;
75 
76  // Collect component's names to avoid duplicate components.
77  std::set<std::string> component_names;
78 
79  for (
80  auto const& component_config :
82  config->getConfigSubtreeList("component"))
83  {
84  auto component = createComponent(component_config);
85 
86  bool new_insertion = false;
87  std::tie(std::ignore, new_insertion) =
88  component_names.insert(component->name());
89  if (!new_insertion)
90  {
91  OGS_FATAL("Found duplicates with the same component name tag '%s'.",
92  component->name().c_str());
93  }
94 
95  components.push_back(std::move(component));
96  }
97  return components;
98 }
std::unique_ptr< MaterialPropertyLib::Component > createComponent(BaseLib::ConfigTree const &config)
#define OGS_FATAL(fmt,...)
Definition: Error.h:63

◆ createMaterialSpatialDistributionMap()

std::unique_ptr< MaterialSpatialDistributionMap > MaterialPropertyLib::createMaterialSpatialDistributionMap ( std::map< int, std::unique_ptr< Medium >> const &  media,
MeshLib::Mesh const &  mesh 
)

Definition at line 19 of file CreateMaterialSpatialDistributionMap.cpp.

References MeshLib::materialIDs(), and OGS_FATAL.

Referenced by ProcessLib::ComponentTransport::createComponentTransportProcess(), and ProcessLib::HT::createHTProcess().

22 {
23  auto const material_ids = materialIDs(mesh);
24 
25  int const max_material_id =
26  !material_ids
27  ? 0
28  : *std::max_element(begin(*material_ids), end(*material_ids));
29 
30  if (max_material_id > static_cast<int>(media.size() - 1))
31  {
32  OGS_FATAL(
33  "The maximum value of MaterialIDs in mesh is %d. As the given "
34  "number of porous media definitions in the project file is %d, the "
35  "maximum value of MaterialIDs in mesh must be %d (index starts "
36  "with zero).",
37  max_material_id, media.size(), max_material_id - 1);
38  }
39 
40  if (max_material_id < static_cast<int>(media.size() - 1))
41  WARN(
42  "There are %d porous medium definitions in the project file but "
43  "only %d different values in the MaterialIDs vector/data_array in "
44  "the mesh.",
45  media.size(), max_material_id - 1);
46 
47  return std::make_unique<MaterialSpatialDistributionMap>(media,
48  material_ids);
49 }
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:403
#define OGS_FATAL(fmt,...)
Definition: Error.h:63

◆ createMedium()

std::unique_ptr< Medium > MaterialPropertyLib::createMedium ( BaseLib::ConfigTree const &  config)

This function parses the "phases" and "properties" subtrees of the config tree and calls create methods for the phase vector and the properties array. Medium properties are optional. If not defined, default properties are assigned.

Input File Parameter:
prj__media__medium__phases
Input File Parameter:
prj__media__medium__properties

Definition at line 26 of file CreateMedium.cpp.

References createPhases(), createProperties(), BaseLib::ConfigTree::getConfigSubtreeOptional(), and OGS_FATAL.

Referenced by ProjectData::parseMedia().

27 {
28  // Parsing the phases
29  // Properties of phases may be not required in all the cases.
31  auto&& phases = createPhases(config.getConfigSubtreeOptional("phases"));
32 
33  // Parsing medium properties, overwriting the defaults.
34  auto&& properties =
36  createProperties(config.getConfigSubtreeOptional("properties"));
37 
38  if (phases.empty() && !properties)
39  {
40  OGS_FATAL("Neither tag <phases> nor tag <properties> has been found.");
41  }
42 
43  return std::make_unique<Medium>(std::move(phases), std::move(properties));
44 }
std::unique_ptr< PropertyArray > createProperties(boost::optional< BaseLib::ConfigTree > const &config)
std::vector< std::unique_ptr< Phase > > createPhases(boost::optional< BaseLib::ConfigTree > const &config)
Definition: CreatePhase.cpp:82
#define OGS_FATAL(fmt,...)
Definition: Error.h:63

◆ createPhases()

std::vector< std::unique_ptr< Phase > > MaterialPropertyLib::createPhases ( boost::optional< BaseLib::ConfigTree > const &  config)

A method that parses the phase details and stores them in the private _phases member.

This method creates the phases of the medium. Unlike a medium, a phase may have a name. However, this is silly at the moment since this name still has no effect (except of some benefits in regard of readability). Phase components are required (a phase consists of at least one component). Phase properties are optional. If not given, default properties are assigned. These default properties average the component properties, weighted by mole fraction.

Input File Parameter:
prj__media__medium__phases__phase

Definition at line 82 of file CreatePhase.cpp.

References anonymous_namespace{CreatePhase.cpp}::createPhase(), and OGS_FATAL.

Referenced by createMedium().

84 {
85  if (!config)
86  {
87  return {};
88  }
89 
90  std::vector<std::unique_ptr<Phase>> phases;
91 
92  std::set<std::string> phase_names;
93 
95  for (auto phase_config : config->getConfigSubtreeList("phase"))
96  {
97  auto phase = createPhase(phase_config);
98  bool new_insertion = false;
99  std::tie(std::ignore, new_insertion) =
100  phase_names.insert(phase->name());
101 
102  if (!new_insertion)
103  {
104  OGS_FATAL("Found duplicates with the same phase name tag '%s'.",
105  phase->name().c_str());
106  }
107 
108  phases.push_back(std::move(phase));
109  }
110  return phases;
111 }
std::unique_ptr< MaterialPropertyLib::Phase > createPhase(BaseLib::ConfigTree const &config)
Definition: CreatePhase.cpp:27
#define OGS_FATAL(fmt,...)
Definition: Error.h:63

◆ createProperties()

std::unique_ptr< PropertyArray > MaterialPropertyLib::createProperties ( boost::optional< BaseLib::ConfigTree > const &  config)

The method reads the 'properties' tag in the prj-file and creates component properties accordingly.

First, a new property iy created based on the specified property type. Then, the property name is evaluated and the property is copied into the properties array.

Input File Parameter:
properties__property
Input File Parameter:
properties__property__name

Definition at line 188 of file CreateProperty.cpp.

References convertStringToProperty(), and anonymous_namespace{CreateProperty.cpp}::createProperty().

Referenced by anonymous_namespace{CreateComponent.cpp}::createComponent(), createMedium(), anonymous_namespace{CreatePhase.cpp}::createPhase(), and ProcessLib::LIE::PostProcessTool::getOutputMesh().

190 {
191  if (!config)
192  {
193  return nullptr;
194  }
195 
197  auto const& property_configs = config->getConfigSubtreeList("property");
198  if (property_configs.empty())
199  {
200  return nullptr;
201  }
202 
203  auto properties = std::make_unique<PropertyArray>();
204 
205  for (auto property_config : property_configs)
206  {
207  // Parsing the property name:
208  auto const property_name =
210  property_config.getConfigParameter<std::string>("name");
211  // Create a new property based on the configuration subtree:
212  auto property = createProperty(property_config);
213 
214  // Insert the new property at the right position into the components
215  // private PropertyArray:
216  (*properties)[convertStringToProperty(property_name)] =
217  std::move(property);
218  }
219  return properties;
220 }
std::unique_ptr< MaterialPropertyLib::Property > createProperty(BaseLib::ConfigTree const &config)
PropertyType convertStringToProperty(std::string const &inString)
Definition: PropertyType.h:86

◆ getScalar()

double MaterialPropertyLib::getScalar ( VariableType  pv)
inline

This method returns a value of type double from the variables array.

Definition at line 65 of file VariableType.h.

References convertStringToVariable().

66 {
67  return boost::get<double>(pv);
68 }

◆ getType()

std::size_t MaterialPropertyLib::getType ( Property const &  p)
inline

This method returns the 0-based index of the variant data types. Can be enhanced by using enums.

Definition at line 99 of file Property.h.

References MaterialPropertyLib::Property::value().

Referenced by GeoTreeView::setElementAsCondition(), GeoTreeView::setNameForElement(), and FileIO::XmlPrjInterface::writeCondition().

100 {
101  return p.value().which();
102 }
static const double p

◆ newComponent()

std::unique_ptr<Component> MaterialPropertyLib::newComponent ( std::string const &  component_name,
bool &  isCustomComponent 
)

Method for creating a new component based on the specified component name.

This function creates a new component based on the (optional) component name that is given in the prj-file.

The method evaluates the string in the 'name'-object and calls the constructors of the derived component classes (if found) or that of the base class (if no name is specified).

◆ overwriteExistingProperties()

void MaterialPropertyLib::overwriteExistingProperties ( PropertyArray properties,
PropertyArray new_properties 
)
inline

Definition at line 104 of file Property.h.

Referenced by MaterialPropertyLib::Component::Component(), MaterialPropertyLib::Medium::Medium(), MaterialPropertyLib::Phase::Phase(), and MaterialPropertyLib::Water::Water().

106 {
107  for (std::size_t i = 0; i < properties.size(); ++i)
108  {
109  if (new_properties[i] != nullptr)
110  {
111  properties[i] = std::move(new_properties[i]);
112  }
113  }
114 }

Variable Documentation

◆ property_enum_to_string

const std::array<std::string, PropertyType::number_of_properties> MaterialPropertyLib::property_enum_to_string
static

Definition at line 250 of file PropertyType.h.