4#ifndef lethe_rheological_model_h
5#define lethe_rheological_model_h
33 static std::shared_ptr<RheologicalModel>
99 const std::map<field, double> &field_values)
const = 0;
110 const double &p_density_ref,
111 const std::map<
field, std::vector<double>> &field_vectors,
112 std::vector<double> &property_vector) = 0;
121 const std::map<field, double> &field_values)
123 return value(field_values);
134 const std::map<
field, std::vector<double>> &field_vectors,
135 std::vector<double> &property_vector)
148 const double &p_density_ref,
149 const std::map<field, double> &field_values)
163 const double &p_density_ref,
164 const std::map<
field, std::vector<double>> &field_vectors,
165 std::vector<double> &property_vector)
223 value([[maybe_unused]]
const std::map<field, double> &field_values)
override;
234 [[maybe_unused]]
const std::map<
field, std::vector<double>> &field_vectors,
235 std::vector<double> &property_vector)
override
253 jacobian([[maybe_unused]]
const std::map<field, double> &field_values,
254 [[maybe_unused]]
field id)
override
272 [[maybe_unused]]
const std::map<
field, std::vector<double>> &field_vectors,
273 [[maybe_unused]]
const field id,
274 std::vector<double> &jacobian_vector)
override
276 std::ranges::fill(jacobian_vector, 0);
317 [[maybe_unused]]
const double &p_density_ref,
318 [[maybe_unused]]
const std::map<field, double> &field_values)
const override
336 [[maybe_unused]]
const double &p_density_ref,
337 [[maybe_unused]]
const std::map<
field, std::vector<double>> &field_vectors,
338 std::vector<double> &property_vector)
override
379 value(
const std::map<field, double> &field_values)
override;
390 [[maybe_unused]]
const std::map<
field, std::vector<double>> &field_vectors,
391 std::vector<double> &property_vector)
override;
405 jacobian(
const std::map<field, double> &field_values,
406 [[maybe_unused]]
field id)
override;
421 [[maybe_unused]]
const std::map<
field, std::vector<double>> &field_vectors,
422 [[maybe_unused]]
const field id,
423 std::vector<double> &jacobian_vector)
override;
453 K = p_kinematic_viscosity;
466 const double &p_density_ref,
467 const std::map<field, double> &field_values)
const override
470 PhysicialPropertyModelFieldUndefined(
"PowerLaw",
"shear_rate"));
484 const double &p_density_ref,
485 const std::map<
field, std::vector<double>> &field_vectors,
486 std::vector<double> &property_vector)
override
489 PhysicialPropertyModelFieldUndefined(
"PowerLaw",
"shear_rate"));
490 const std::vector<double> &shear_rate_magnitude =
493 for (
unsigned int i = 0; i < property_vector.size(); ++i)
503 K * std::pow(shear_rate_magnitude,
n - 1) :
511 (
n - 1) *
K * std::pow(shear_rate_magnitude,
n - 2) :
533 const double p_kinematic_viscosity_inf,
534 const double p_lambda,
559 value(
const std::map<field, double> &field_values)
override;
569 std::vector<double> &property_vector)
override;
582 jacobian(
const std::map<field, double> &field_values,
field id)
override;
598 std::vector<double> &jacobian_vector)
override;
623 std::pow(1.0 + std::pow(1.0 *
lambda,
a), (
n - 1) /
a);
634 const double &p_density_ref,
635 const std::map<field, double> &field_values)
const override
638 PhysicialPropertyModelFieldUndefined(
"Carreau",
"shear_rate"));
652 const double &p_density_ref,
653 const std::map<
field, std::vector<double>> &field_vectors,
654 std::vector<double> &property_vector)
override
657 PhysicialPropertyModelFieldUndefined(
"Carreau",
"shear_rate"));
658 const std::vector<double> &shear_rate_magnitude =
661 for (
unsigned int i = 0; i < property_vector.size(); ++i)
672 std::pow(1.0 + std::pow(shear_rate_magnitude *
lambda,
a),
692 double shear_rate_magnitude = 0;
693 for (
int i = 0; i < dim; ++i)
695 for (
int j = 0; j < dim; ++j)
700 shear_rate_magnitude = sqrt(0.5 * shear_rate_magnitude);
701 return shear_rate_magnitude;
715 :
param(p_phase_change_parameters)
730 value(
const std::map<field, double> &field_values)
override;
741 std::vector<double> &property_vector)
override;
755 jacobian(
const std::map<field, double> &field_values,
field id)
override;
771 std::vector<double> &jacobian_vector)
override;
779 return param.kinematic_viscosity_l;
784 const double &p_density_ref,
785 const std::map<field, double> &field_values)
const override
788 PhysicialPropertyModelFieldUndefined(
"PhaseChangeRheology",
803 const double &p_density_ref,
804 const std::map<
field, std::vector<double>> &field_vectors,
805 std::vector<double> &property_vector)
override
808 PhysicialPropertyModelFieldUndefined(
"PhaseChangeRheology",
813 for (
unsigned int i = 0; i < property_vector.size(); ++i)
824 const std::map<field, double> &field_values)
override;
834 const std::map<
field, std::vector<double>> &field_vectors,
835 std::vector<double> &property_vector)
override;
845 const double &p_density_ref,
846 [[maybe_unused]]
const std::map<field, double> &field_values)
override;
857 const double &p_density_ref,
858 [[maybe_unused]]
const std::map<
field, std::vector<double>> &field_vectors,
859 std::vector<double> &property_vector)
override;
873 const double l_frac =
874 std::min(std::max((T -
param.T_solidus) /
879 return param.kinematic_viscosity_l * l_frac +
880 param.kinematic_viscosity_s * (1. - l_frac);
Carreau(const double p_kinematic_viscosity_0, const double p_kinematic_viscosity_inf, const double p_lambda, const double p_a, const double p_n)
Parameter constructor.
void vector_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector) override
vector_jacobian Calculate the derivative of the with respect to a field
double kinematic_viscosity_0
void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
vector_value Calculates the vector values of the viscosity.
double get_kinematic_viscosity() const override
Returns the value of the kinematic viscosity, if the model has one.
void set_kinematic_viscosity(const double &p_kinematic_viscosity) override
Sets a new kinematic viscosity value, if the models has one.
void get_dynamic_viscosity_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the vector values of the dynamic viscosity.
void set_n(const double &p_n) override
Sets a new value to the n parameter, if the models has one.
double get_kinematic_viscosity_scale() const override
Returns the kinematic viscosity scale. This is used to get the kinematic viscosity scale in the probl...
double get_dynamic_viscosity(const double &p_density_ref, const std::map< field, double > &field_values) const override
Calculates the dynamic viscosity, if a kinematic viscosity and a reference density value is specified...
double get_n() const override
Returns the value of the n parameters of the model, if the model has one.
double kinematic_viscosity_inf
double jacobian(const std::map< field, double > &field_values, field id) override
jacobian Calculates the jacobian (the partial derivative) of the viscosity with respect to a field
double value(const std::map< field, double > &field_values) override
Returns the non-Newtonian viscosity.
double calculate_kinematic_viscosity(const double shear_rate_magnitude) const
double get_kinematic_viscosity() const override
Returns the value of the kinematic viscosity, if the model has one.
void get_dynamic_viscosity_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the vector values of the dynamic viscosity.
Newtonian(const double &p_kinematic_viscosity)
Parameter constructor.
void set_dynamic_viscosity(const double &p_density_ref) override
Sets a new dynamic viscosity value, if the models has a constant dynamic viscosity value.
void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
vector_value Calculates the vector values of the kinematic viscosity.
double get_dynamic_viscosity(const double &p_density_ref, const std::map< field, double > &field_values) const override
Calculates the dynamic viscosity, if a kinematic viscosity and a reference density value is specified...
void set_kinematic_viscosity(const double &p_kinematic_viscosity) override
Sets a new kinematic viscosity value, if the models has one.
double get_kinematic_viscosity_scale() const override
Returns the kinematic viscosity scale. This is used to get the kinematic viscosity scale in the probl...
void vector_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector) override
vector_jacobian Calculate the derivative of the with respect to a field
double jacobian(const std::map< field, double > &field_values, field id) override
jacobian Calculates the jacobian (the partial derivative) of the kinematic viscosity with respect to ...
double value(const std::map< field, double > &field_values) override
Returns the kinematic viscosity.
double kinematic_viscosity
Material - Class that defines the physical property of a material. Generally a material will be a flu...
double jacobian(const std::map< field, double > &field_values, field id) override
jacobian Calculates the jacobian (the partial derivative) of the kinematic viscosity with respect to ...
PhaseChangeRheology(const Parameters::PhaseChange &p_phase_change_parameters)
Parameter constructor.
virtual void get_dynamic_viscosity_for_stabilization_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the vector values of the dynamic viscosity used in PSPG and SUPG stabilization terms.
Parameters::PhaseChange param
void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
vector_value Calculates the vector values of the kinematic viscosity.
double kinematic_viscosity(const double T) const
kinematic_viscosity Calculates the kinematic viscosity from the temperature using the liquid fraction
double get_kinematic_viscosity_for_stabilization(const std::map< field, double > &field_values) override
Calculates the kinematic viscosity used in PSPG and SUPG stabilization terms.
void get_dynamic_viscosity_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the vector values of the dynamic viscosity.
double get_kinematic_viscosity_scale() const override
Returns the kinematic viscosity scale.
void vector_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector) override
vector_jacobian Calculate the derivative of the with respect to a field
void get_kinematic_viscosity_for_stabilization_vector(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the vector values of the kinematic viscosity used in PSPG and SUPG stabilization terms.
double get_dynamic_viscosity(const double &p_density_ref, const std::map< field, double > &field_values) const override
Calculates the dynamic viscosity, if a kinematic viscosity and a reference density value is specified...
virtual double get_dynamic_viscosity_for_stabilization(const double &p_density_ref, const std::map< field, double > &field_values) override
Calculates the dynamic viscosity used in PSPG and SUPG stabilization terms.
double value(const std::map< field, double > &field_values) override
Returns the kinematic viscosity.
virtual double value(const std::map< field, double > &fields_value)=0
value Calculates the value of a physical property.
PhysicalPropertyModel()
Default constructor. Set the model_depends_on to false for all variables.
virtual void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector)=0
vector_value Calculates the values of a physical property for multiple points
std::map< field, bool > model_depends_on
double calculate_kinematic_viscosity(const double shear_rate_magnitude) const
void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
vector_value Calculates the vector values of the kinematic viscosity.
void set_kinematic_viscosity(const double &p_kinematic_viscosity) override
Sets a new kinematic viscosity value, if the models has one.
void get_dynamic_viscosity_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the vector values of the dynamic viscosity.
PowerLaw(const double K, const double n, const double shear_rate_min)
Parameter constructor.
double jacobian(const std::map< field, double > &field_values, field id) override
jacobian Calculates the jacobian (the partial derivative) of the kinematic viscosity with respect to ...
double calculate_derivative(const double shear_rate_magnitude) const
double get_n() const override
Returns the value of the n parameters of the model, if the model has one.
double get_kinematic_viscosity_scale() const override
Returns the kinematic viscosity scale. This is used to get the kinematic viscosity scale in the probl...
double get_kinematic_viscosity() const override
Returns the value of the kinematic viscosity, if the model has one.
void set_n(const double &p_n) override
Sets a new value to the n parameter, if the models has one.
double value(const std::map< field, double > &field_values) override
Returns the non-Newtonian kinematic viscosity.
double get_dynamic_viscosity(const double &p_density_ref, const std::map< field, double > &field_values) const override
Calculates the dynamic viscosity, if a kinematic viscosity and a reference density value is specified...
void vector_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector) override
vector_jacobian Calculate the derivative of the with respect to a field
const double shear_rate_min
virtual double get_dynamic_viscosity(const double &p_density_ref, const std::map< field, double > &field_values) const =0
Calculates the dynamic viscosity, if a kinematic viscosity and a reference density value is specified...
virtual void get_dynamic_viscosity_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector)=0
Calculates the vector values of the dynamic viscosity.
virtual double get_dynamic_viscosity_for_stabilization(const double &p_density_ref, const std::map< field, double > &field_values)
Calculates the dynamic viscosity used in PSPG and SUPG stabilization terms.
bool is_phase_change_rheological_model() const
Returns a boolean indicating if the model is a phase change rheological model.
bool phase_change_rheological_model
Boolean to indicate if the rheological model is a phase change model.
bool non_newtonian_rheological_model
Boolean to indicate if the rheological model is a non-Newtonian model.
virtual double get_n() const
Returns the value of the n parameters of the model, if the model has one.
virtual double get_kinematic_viscosity_for_stabilization(const std::map< field, double > &field_values)
Calculates the kinematic viscosity used in PSPG and SUPG stabilization terms.
virtual void get_dynamic_viscosity_for_stabilization_vector(const double &p_density_ref, const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector)
Calculates the vector values of the dynamic viscosity used in PSPG and SUPG stabilization terms.
bool is_non_newtonian_rheological_model() const
is_non_newtonian_rheological_model Returns a boolean indicating if the model is a non-Newtonian rheol...
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...
virtual void get_kinematic_viscosity_for_stabilization_vector(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector)
Calculates the vector values of the kinematic viscosity used in PSPG and SUPG stabilization terms.
virtual void set_dynamic_viscosity(const double &p_density_ref)
Sets a new dynamic viscosity value, if the models has a constant dynamic viscosity value.
virtual void set_n(const double &)
Sets a new value to the n parameter, if the models has one.
virtual double get_kinematic_viscosity_scale() const
Returns the kinematic viscosity scale. This is used to get the kinematic viscosity scale in the probl...
virtual double get_kinematic_viscosity() const
Returns the value of the kinematic viscosity, if the model has one.
virtual void set_kinematic_viscosity(const double &p_kinematic_viscosity)
Sets a new kinematic viscosity value, if the models has one.
RheologicalModel()=default
Default constructor.
@ temperature
Temperature scalar field from heat transfer.
double calculate_shear_rate_magnitude(const Tensor< 2, dim > shear_rate)
Calculates the magnitude of the shear rate tensor given as input.
Phase change model for melting/freezing liquids The model assumes that the phase change occurs betwee...