Skip to content
Snippets Groups Projects
Commit eed3eae2 authored by wenqing's avatar wenqing
Browse files

[FL] Removed the buffer member of a class that could

cause problem in multithreads
parent 7d22cc5d
No related branches found
No related tags found
No related merge requests found
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
#include "BaseLib/ConfigTree.h" #include "BaseLib/ConfigTree.h"
#include "FluidProperties.h"
#include "PrimaryVariableDependentFluidProperties.h"
#include "FluidPropertiesWithDensityDependentModels.h"
#include "MaterialLib/Fluid/FluidPropertyHeaders.h" #include "MaterialLib/Fluid/FluidPropertyHeaders.h"
#include "MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.h" #include "MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.h"
#include "MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.h" #include "MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.h"
#include "FluidProperties.h"
#include "PrimaryVariableDependentFluidProperties.h"
#include "FluidPropertiesWithDensityDependentModels.h"
namespace MaterialLib namespace MaterialLib
{ {
namespace Fluid namespace Fluid
...@@ -39,9 +39,7 @@ std::unique_ptr<FluidProperties> createFluidProperties( ...@@ -39,9 +39,7 @@ std::unique_ptr<FluidProperties> createFluidProperties(
auto const& mu_conf = config.getConfigSubtree("viscosity"); auto const& mu_conf = config.getConfigSubtree("viscosity");
auto viscosity = MaterialLib::Fluid::createViscosityModel(mu_conf); auto viscosity = MaterialLib::Fluid::createViscosityModel(mu_conf);
const bool is_mu_density_dependent = const bool is_mu_density_dependent =
(viscosity->getName().find("density dependent") != std::string::npos) (viscosity->getName().find("density dependent") != std::string::npos);
? true
: false;
bool is_cp_density_dependent = false; bool is_cp_density_dependent = false;
std::unique_ptr<MaterialLib::Fluid::FluidProperty> specific_heat_capacity = std::unique_ptr<MaterialLib::Fluid::FluidProperty> specific_heat_capacity =
...@@ -56,9 +54,7 @@ std::unique_ptr<FluidProperties> createFluidProperties( ...@@ -56,9 +54,7 @@ std::unique_ptr<FluidProperties> createFluidProperties(
createSpecificFluidHeatCapacityModel(heat_capacity_conf); createSpecificFluidHeatCapacityModel(heat_capacity_conf);
is_cp_density_dependent = is_cp_density_dependent =
(specific_heat_capacity->getName().find("density dependent") != (specific_heat_capacity->getName().find("density dependent") !=
std::string::npos) std::string::npos);
? true
: false;
} }
bool is_KT_density_dependent = false; bool is_KT_density_dependent = false;
...@@ -69,15 +65,13 @@ std::unique_ptr<FluidProperties> createFluidProperties( ...@@ -69,15 +65,13 @@ std::unique_ptr<FluidProperties> createFluidProperties(
config.getConfigSubtreeOptional("thermal_conductivity"); config.getConfigSubtreeOptional("thermal_conductivity");
if (thermal_conductivity_opt_conf) if (thermal_conductivity_opt_conf)
{ {
auto& thermal_conductivity_conf = *thermal_conductivity_opt_conf; auto const& thermal_conductivity_conf = *thermal_conductivity_opt_conf;
thermal_conductivity = thermal_conductivity =
MaterialLib::Fluid::createFluidThermalConductivityModel( MaterialLib::Fluid::createFluidThermalConductivityModel(
thermal_conductivity_conf); thermal_conductivity_conf);
is_KT_density_dependent = is_KT_density_dependent =
(specific_heat_capacity->getName().find("density dependent") != (specific_heat_capacity->getName().find("density dependent") !=
std::string::npos) std::string::npos);
? true
: false;
} }
if (is_mu_density_dependent || is_cp_density_dependent || if (is_mu_density_dependent || is_cp_density_dependent ||
......
...@@ -48,13 +48,25 @@ public: ...@@ -48,13 +48,25 @@ public:
std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& heat_capacity, std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& heat_capacity,
std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& std::unique_ptr<MaterialLib::Fluid::FluidProperty>&&
thermal_conductivity) thermal_conductivity)
: _property_models{{std::move(density), std::move(viscosity), /* Will use this if MS visual studio compiler supports
std::move(heat_capacity), : _property_models{{std::move(density), std::move(viscosity),
std::move(thermal_conductivity)}} std::move(heat_capacity),
std::move(thermal_conductivity)}}
*/
{ {
// Move to the initialization list if MS visual studio compiler supports
_property_models[static_cast<unsigned>(FluidPropertyType::Density)] =
std::move(density);
_property_models[static_cast<unsigned>(FluidPropertyType::Vicosity)] =
std::move(viscosity);
_property_models[static_cast<unsigned>(
FluidPropertyType::HeatCapacity)] = std::move(heat_capacity);
_property_models[static_cast<unsigned>(
FluidPropertyType::ThermalConductivity)] =
std::move(thermal_conductivity);
} }
virtual ~FluidProperties(){}; virtual ~FluidProperties() = default;
/** /**
* Get the value of a Property. * Get the value of a Property.
......
...@@ -47,17 +47,18 @@ double FluidPropertiesWithDensityDependentModels::getValue( ...@@ -47,17 +47,18 @@ double FluidPropertiesWithDensityDependentModels::getValue(
switch (property_type) switch (property_type)
{ {
case FluidPropertyType::Density: case FluidPropertyType::Density:
_density_value = return _property_models[static_cast<unsigned>(property_type)]
_property_models[static_cast<unsigned>(property_type)] ->getValue(variable_values);
->getValue(variable_values);
return _density_value;
default: default:
{ {
ArrayType var_vals = variable_values; ArrayType var_vals = variable_values;
if (_is_density_depedent[static_cast<unsigned>(property_type)]) if (_is_density_depedent[static_cast<unsigned>(property_type)])
{ {
var_vals[static_cast<unsigned>(PropertyVariableType::rho)] = var_vals[static_cast<unsigned>(PropertyVariableType::rho)] =
_density_value; _property_models[static_cast<unsigned>(
FluidPropertyType::Density)]
->getValue(variable_values);
;
} }
return _property_models[static_cast<unsigned>(property_type)] return _property_models[static_cast<unsigned>(property_type)]
->getValue(var_vals); ->getValue(var_vals);
...@@ -79,14 +80,19 @@ double FluidPropertiesWithDensityDependentModels::getdValue( ...@@ -79,14 +80,19 @@ double FluidPropertiesWithDensityDependentModels::getdValue(
{ {
if (_is_density_depedent[static_cast<unsigned>(property_type)]) if (_is_density_depedent[static_cast<unsigned>(property_type)])
{ {
const double density_value =
_property_models[static_cast<unsigned>(
FluidPropertyType::Density)]
->getValue(variable_values);
;
if (variable_type == PropertyVariableType::T) if (variable_type == PropertyVariableType::T)
{ {
compute_df_drho_drho_dT(_density_value, property_type, compute_df_drho_drho_dT(density_value, property_type,
variable_values); variable_values);
} }
else if (variable_type == PropertyVariableType::p) else if (variable_type == PropertyVariableType::p)
{ {
compute_df_drho_drho_dp(_density_value, property_type, compute_df_drho_drho_dp(density_value, property_type,
variable_values); variable_values);
} }
} }
...@@ -111,10 +117,11 @@ double FluidPropertiesWithDensityDependentModels::compute_df_drho_drho_dT( ...@@ -111,10 +117,11 @@ double FluidPropertiesWithDensityDependentModels::compute_df_drho_drho_dT(
variable_values, PropertyVariableType::T); variable_values, PropertyVariableType::T);
ArrayType var_vals = variable_values; ArrayType var_vals = variable_values;
var_vals[static_cast<unsigned>(PropertyVariableType::rho)] = density_value; var_vals[static_cast<unsigned>(PropertyVariableType::rho)] = density_value;
// return d()/dT + d ()/drho * drho/dT
const auto& fluid_property_model = const auto& fluid_property_model =
_property_models[static_cast<unsigned>(property_type)]; _property_models[static_cast<unsigned>(property_type)];
// return d()/dT + d ()/drho * drho/dT
return fluid_property_model->getdValue(var_vals, PropertyVariableType::T) + return fluid_property_model->getdValue(var_vals, PropertyVariableType::T) +
fluid_property_model->getdValue(var_vals, fluid_property_model->getdValue(var_vals,
PropertyVariableType::rho) * PropertyVariableType::rho) *
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#ifndef OGS_FLUID_PROPERTIES_WITH_DENSITY_DEPENDENT_MODELS_H #ifndef OGS_FLUID_PROPERTIES_WITH_DENSITY_DEPENDENT_MODELS_H
#define OGS_FLUID_PROPERTIES_WITH_DENSITY_DEPENDENT_MODELS_H #define OGS_FLUID_PROPERTIES_WITH_DENSITY_DEPENDENT_MODELS_H
#include <atomic>
#include "FluidProperties.h" #include "FluidProperties.h"
namespace MaterialLib namespace MaterialLib
...@@ -68,8 +70,6 @@ public: ...@@ -68,8 +70,6 @@ public:
const PropertyVariableType variable_type) const override; const PropertyVariableType variable_type) const override;
private: private:
mutable double _density_value = 0.;
/// Compute df/dT for f(T, rho) with rho(T, p) /// Compute df/dT for f(T, rho) with rho(T, p)
double compute_df_drho_drho_dT(const double density_value, double compute_df_drho_drho_dT(const double density_value,
const FluidPropertyType property_type, const FluidPropertyType property_type,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment