Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
physical_properties_manager.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2022-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
5
6void
9{
10 // Loop through the map. The use of or (||) is there to ensure
11 // that if a field is already required, it won't be erased.
12 for (auto &f : required_fields)
13 {
14 f.second = f.second || model.depends_on(f.first);
15 }
16}
17
18void
21{
22 // Loop through the map. The use of or (||) is there to ensure
23 // that if a field is already required, it won't be erased.
24 for (auto &f : required_fields)
25 {
26 f.second = f.second || model.depends_on(f.first);
27 }
28}
29
30void
32 Parameters::PhysicalProperties physical_properties)
33{
34 // Keep a copy of the physical properties used to build the physical property
35 // manager
36 physical_properties_parameters = physical_properties;
37
38 is_initialized = true;
39
40 number_of_fluids = physical_properties.number_of_fluids;
41 number_of_solids = physical_properties.number_of_solids;
43 physical_properties.number_of_material_interactions;
49 physical_properties
51 reference_temperature = physical_properties.reference_temperature;
52
53 non_newtonian_flow = false;
54 phase_change = false;
55 constant_density = true;
57
67
68 // For each fluid, declare the physical properties
69 for (unsigned int f = 0; f < number_of_fluids; ++f)
70 {
71 density.push_back(
72 DensityModel::model_cast(physical_properties.fluids[f]));
74
75 // Store an indicator for the density to indicate if it is not constant
76 // This indicator is used elsewhere in the code to throw assertions
77 // if non-constant density is not implemented in a post-processing utility
78 if (!density.back()->is_constant_density_model())
79 constant_density = false;
80
81 specific_heat.push_back(
82 SpecificHeatModel::model_cast(physical_properties.fluids[f]));
84
85 // Store an indicator that a phase change model is present
87 physical_properties.fluids[f].specific_heat_model ==
89 physical_properties.fluids[f].rheological_model ==
91
92 thermal_conductivity.push_back(
93 ThermalConductivityModel::model_cast(physical_properties.fluids[f]));
95
96 rheology.push_back(
97 RheologicalModel::model_cast(physical_properties.fluids[f]));
99 rheology[f]->set_dynamic_viscosity(density[f]->get_density_ref());
100
101 tracer_diffusivity.push_back(
102 TracerDiffusivityModel::model_cast(physical_properties.fluids[f]));
104
107 physical_properties.fluids[f]));
109
110 tracer_reaction_order.push_back(
111 physical_properties.fluids[f].tracer_reaction_order);
112
113 thermal_expansion.push_back(
114 ThermalExpansionModel::model_cast(physical_properties.fluids[f]));
116
117 phase_change_parameters.push_back(
118 physical_properties.fluids[f].phase_change_parameters);
119
120 if (rheology.back()->is_non_newtonian_rheological_model())
121 non_newtonian_flow = true;
122
123 electric_conductivity.push_back(
124 ElectricConductivityModel::model_cast(physical_properties.fluids[f]));
125
128 physical_properties.fluids[f]));
131 physical_properties.fluids[f]));
132
135 physical_properties.fluids[f]));
138 physical_properties.fluids[f]));
139 }
140
141 // For each solid, append the physical properties
142 for (unsigned int s = 0; s < number_of_solids; ++s)
143 {
144 density.push_back(
145 DensityModel::model_cast(physical_properties.solids[s]));
147
148 // Store an indicator for the density to indicate if it is not constant
149 // This indicator is used elsewhere in the code to throw assertions
150 // if non-constant density is not implemented in a post-processing utility
151 if (!density.back()->is_constant_density_model())
152 constant_density = false;
153
154 specific_heat.push_back(
155 SpecificHeatModel::model_cast(physical_properties.solids[s]));
157
158 thermal_conductivity.push_back(
159 ThermalConductivityModel::model_cast(physical_properties.solids[s]));
162
163 rheology.push_back(
164 RheologicalModel::model_cast(physical_properties.solids[s]));
166 rheology.back()->set_dynamic_viscosity(density.back()->get_density_ref());
167
168 tracer_diffusivity.push_back(
169 TracerDiffusivityModel::model_cast(physical_properties.solids[s]));
172
175 physical_properties.solids[s]));
178
179 tracer_reaction_order.push_back(
180 physical_properties.fluids[s].tracer_reaction_order);
181
182 thermal_expansion.push_back(
183 ThermalExpansionModel::model_cast(physical_properties.solids[s]));
186
187 electric_conductivity.push_back(
188 ElectricConductivityModel::model_cast(physical_properties.solids[s]));
189
192 physical_properties.solids[s]));
195 physical_properties.solids[s]));
196
199 physical_properties.solids[s]));
202 physical_properties.solids[s]));
203 }
204
205 // The effective medium models are indexed by the material interaction id.
206 // The interactions that do not define a mixture keep an empty entry.
211
213 false);
214
215 // For each pair of interacting materials (fluid-fluid, fluid-solid or
216 // fluid-dispersed phase), append physical properties
217 for (unsigned int i = 0; i < number_of_material_interactions; ++i)
218 {
220 physical_properties.material_interactions[i]));
222 if (!surface_tension.back()->is_constant_surface_tension_model())
224
226 physical_properties.material_interactions[i]));
228
229 // A fluid-dispersed phase interaction defines a mixture whose properties
230 // are given by effective medium models.
231 if (physical_properties.material_interactions[i]
232 .material_interaction_type ==
235 {
238 physical_properties,
239 i,
242
245 physical_properties,
246 i,
249
252 physical_properties,
253 i,
256
259 physical_properties,
260 i,
263
264 // Here we also initialize the interaction container using the first
265 // material of the interaction, as it is the host of the dispersed
266 // phase. It's the only one that carries a global id.
268 [physical_properties.material_interactions[i]
269 .fluid_dispersed_phase_interaction_with_material_interaction_id
270 .first.first] = true;
271 }
272 }
273}
static std::shared_ptr< DensityModel > model_cast(const Parameters::Material &material_properties)
Instantiate and return a pointer to a DensityModel object by casting it to the proper child class.
static std::shared_ptr< EffectiveMediumModel > model_cast(const Parameters::PhysicalProperties &physical_properties, const unsigned int material_interaction_id, const EffectiveMediumProperty &property, const ComplexComponent &complex_component)
Creates the model of a mixture property, with the mixing law given by the material interaction.
static std::shared_ptr< ElectricConductivityModel > model_cast(const Parameters::Material &material_properties)
Instantiates and returns a pointer to an ElectricConductivityModel object by casting it to the proper...
static std::shared_ptr< ElectricPermittivityModel > model_cast_imag(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a ElectricPermittivityModel object by casting it to the proper ...
static std::shared_ptr< ElectricPermittivityModel > model_cast_real(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a ElectricPermittivityModel object by casting it to the proper ...
Abstract class that defines the interface for a interface property model. Interface property model pr...
bool depends_on(const field &id)
Returns true if the InterfacePropertyModel depends on a field, false if not.
static std::shared_ptr< MagneticPermeabilityModel > model_cast_imag(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a MagneticPermeabilityModel object by casting it to the proper ...
static std::shared_ptr< MagneticPermeabilityModel > model_cast_real(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a MagneticPermeabilityModel object by casting it to the proper ...
static std::shared_ptr< MobilityCahnHilliardModel > model_cast(const Parameters::MaterialInteractions &material_interaction_parameters)
Instantiate and return a pointer to a MobilityCahnHilliardModel object by casting it to the proper ch...
PhysicalProperties - Define the possible physical properties. All continuum equations share the same ...
Definition parameters.h:839
std::map< std::pair< unsigned int, unsigned int >, unsigned int > fluid_dispersed_phase_interactions_with_material_interaction_ids
Definition parameters.h:869
std::map< std::pair< unsigned int, unsigned int >, unsigned int > fluid_solid_interactions_with_material_interaction_ids
Definition parameters.h:867
std::vector< Material > fluids
Definition parameters.h:844
std::vector< Material > solids
Definition parameters.h:849
unsigned int number_of_material_interactions
Definition parameters.h:862
std::map< std::pair< unsigned int, unsigned int >, unsigned int > fluid_fluid_interactions_with_material_interaction_ids
Definition parameters.h:865
std::vector< MaterialInteractions > material_interactions
Definition parameters.h:861
std::vector< std::shared_ptr< ElectricConductivityModel > > electric_conductivity
std::vector< std::shared_ptr< EffectiveMediumModel > > effective_magnetic_permeability_real
std::vector< bool > material_is_effective_medium
std::map< std::pair< unsigned int, unsigned int >, unsigned int > fluid_fluid_interactions_with_material_interaction_ids
std::vector< Parameters::PhaseChange > phase_change_parameters
std::vector< std::shared_ptr< ThermalExpansionModel > > thermal_expansion
std::map< std::pair< unsigned int, unsigned int >, unsigned int > fluid_solid_interactions_with_material_interaction_ids
std::vector< double > tracer_reaction_order
std::vector< std::shared_ptr< ElectricPermittivityModel > > electric_permittivity_real
std::vector< std::shared_ptr< RheologicalModel > > rheology
std::map< field, bool > required_fields
std::map< std::pair< unsigned int, unsigned int >, unsigned int > fluid_dispersed_phase_interactions_with_material_interaction_ids
std::vector< std::shared_ptr< ElectricPermittivityModel > > electric_permittivity_imag
void initialize(Parameters::PhysicalProperties physical_properties)
initialize Initializes the physical properties using the parameters
std::vector< std::shared_ptr< MagneticPermeabilityModel > > magnetic_permeability_imag
std::vector< std::shared_ptr< DensityModel > > density
std::vector< std::shared_ptr< EffectiveMediumModel > > effective_magnetic_permeability_imag
std::vector< std::shared_ptr< SurfaceTensionModel > > surface_tension
std::vector< std::shared_ptr< MobilityCahnHilliardModel > > mobility_cahn_hilliard
Parameters::PhysicalProperties physical_properties_parameters
std::vector< std::shared_ptr< EffectiveMediumModel > > effective_electric_permittivity_real
std::vector< std::shared_ptr< TracerReactionPrefactorModel > > tracer_reaction_prefactor
void establish_fields_required_by_model(PhysicalPropertyModel &model)
std::vector< std::shared_ptr< MagneticPermeabilityModel > > magnetic_permeability_real
std::vector< std::shared_ptr< TracerDiffusivityModel > > tracer_diffusivity
std::vector< std::shared_ptr< EffectiveMediumModel > > effective_electric_permittivity_imag
std::vector< std::shared_ptr< SpecificHeatModel > > specific_heat
std::vector< std::shared_ptr< ThermalConductivityModel > > thermal_conductivity
Abstract class that defines the interface for a physical property model Physical property model provi...
bool depends_on(const field &id)
Returns true if the PhysicalPropertyModel depends on a field, false if not.
static std::shared_ptr< RheologicalModel > model_cast(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a RheologicalModel object by casting it to the proper child cla...
static std::shared_ptr< SpecificHeatModel > model_cast(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a SpecificHeatModel object by casting it to the proper child cl...
static std::shared_ptr< SurfaceTensionModel > model_cast(const Parameters::MaterialInteractions &material_interaction_parameters)
Instantiates and returns a pointer to a SurfaceTensionModel object by casting it to the proper child ...
static std::shared_ptr< ThermalConductivityModel > model_cast(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a ThermalConductivityModel object by casting it to the proper c...
static std::shared_ptr< ThermalExpansionModel > model_cast(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a ThermalExpansionModel object by casting it to the proper chil...
static std::shared_ptr< TracerDiffusivityModel > model_cast(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a TracerDiffusivityModel object by casting it to the proper chi...
static std::shared_ptr< TracerReactionPrefactorModel > model_cast(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a TracerReactionPrefactorModel object by casting it to the prop...