Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
PowerLaw_def.hpp
1#ifndef POWERLAW_DEF_hpp
2#define POWERLAW_DEF_hpp
3
4namespace FEDD {
5
6template <class SC, class LO, class GO, class NO>
7PowerLaw<SC,LO,GO,NO>::PowerLaw(ParameterListPtr_Type params):
8DifferentiableFuncClass<SC,LO,GO,NO>(params)
9{
10 this->params_=params;
11 // Reading through parameterlist
12 shearThinningModel_ = this->params_->sublist("Material").get("ShearThinningModel","");
13 powerlaw_constant_K = this->params_->sublist("Material").get("PowerLawParameter K",0.); // corresponds to K in the formulas in the literature
14 powerlaw_index_n = this->params_->sublist("Material").get("PowerLaw index n",1.); // corresponds to n in the formulas being the power-law index
15 nu_zero = this->params_->sublist("Material").get("Numerical_ZeroShearRateViscosity",1.);
16 nu_infty = this->params_->sublist("Material").get("Numerical_InftyShearRateViscosity",1.);
17 shear_rate_limitZero= this->params_->sublist("Material").get("Numerical_ZeroValue_ShearRate",1e-8);
18 viscosity_ = 0.;
19 // TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error, "No discretisation Information for Velocity in Navier Stokes Element." )
20
21
22}
23/*In power-law fluid model the problem may arise if the local
24strain-rate produces very small number or even zero, this only happen when n <1 because the
25local viscosity will grow up into very huge number and then we get inaccuracy results.
26*/
27template <class SC, class LO, class GO, class NO>
28void PowerLaw<SC,LO,GO,NO>::evaluateMapping(ParameterListPtr_Type params, double shearRate, double &viscosity) {
29
30
31 viscosity = this->powerlaw_constant_K*std::pow(shearRate, this->powerlaw_index_n-1.0);
32
33 // Check bounds for viscosity
34 if (viscosity < nu_infty) // If viscosity value is smaller than the infinity shear rate viscosity set viscsoity to limit value nu_infty
35 {
36 viscosity = nu_infty;
37 }
38 else if (std::abs(viscosity) > nu_zero) // If viscosity value is greater than the zero shear rate viscosity set viscsoity to limit value nu_zero
39 {
40 viscosity = nu_zero;
41 }
42
43
44 this-> viscosity_ = viscosity;
45}
46
47
48template <class SC, class LO, class GO, class NO>
49void PowerLaw<SC,LO,GO,NO>::evaluateDerivative(ParameterListPtr_Type params, double shearRate, double &res) {
50
51// The function is composed of d_eta/ d_GammaDot * d_GammaDot/ D_Tau while d_GammaDot * d_GammaDot/ D_Tau= - 2/GammaDot
52// So a problematic case is if shear rate is in the denominator 0 because we may get inf values.
53// Therefore we have to check these cases and catch them
54// double epsilon = 1e-8;
55if ( std::abs(shearRate) <= shear_rate_limitZero) //How to choose epsilon?
56 {
57 shearRate = shear_rate_limitZero;
58 }
59
60res = (-2.0)*this->powerlaw_constant_K*(this->powerlaw_index_n-1.0)*std::pow(shearRate, this->powerlaw_index_n-3.0);
61
62
63}
64
65
66template <class SC, class LO, class GO, class NO>
67void PowerLaw<SC,LO,GO,NO>::setParams(ParameterListPtr_Type params){
68 this->params_=params;
69 // Reading through parameterlist
70 shearThinningModel_ = this->params_->sublist("Material").get("ShearThinningModel","");
71 powerlaw_constant_K = this->params_->sublist("Material").get("PowerLawParameter K",0.); // corresponds to K in the formulas in the literature
72 powerlaw_index_n = this->params_->sublist("Material").get("PowerLaw index n",1.); // corresponds to n in the formulas being the power-law index
73 nu_zero = this->params_->sublist("Material").get("Numerical_ZeroShearRateViscosity",1.);
74 nu_infty = this->params_->sublist("Material").get("Numerical_InftyShearRateViscosity",1.);
75 shear_rate_limitZero= this->params_->sublist("Material").get("Numerical_ZeroValue_ShearRate",1e-8);
76
77 }
78
79
80
81
82template <class SC, class LO, class GO, class NO>
84 std::cout << "************************************************************ " <<std::endl;
85 std::cout << "-- Chosen material model ..." << this->shearThinningModel_ << " --- " <<std::endl;
86 std::cout << "-- Specified material parameters:" <<std::endl;
87 std::cout << "-- PowerLaw index n:" << this->powerlaw_index_n << std::endl;
88 std::cout << "-- PowerLaw constant K:" << this->powerlaw_constant_K <<std::endl;
89 std::cout << "************************************************************ " <<std::endl;
90 }
91
92
93
94
95}
96#endif
97
DifferentiableFuncClass(ParameterListPtr_Type parameters)
Definition DifferentiableFuncClass_def.hpp:8
PowerLaw(ParameterListPtr_Type parameters)
Constructor for CarreauYasuda.
Definition PowerLaw_def.hpp:7
void evaluateMapping(ParameterListPtr_Type params, double shearRate, double &viscosity) override
Update the viscosity according to a chosen shear thinning generalized newtonian constitutive equation...
Definition PowerLaw_def.hpp:28
void echoInformationMapping() override
Print parameter values used in model at runtime.
Definition PowerLaw_def.hpp:83
void setParams(ParameterListPtr_Type params) override
Each constitutive model includes different material parameters which will be specified in parametersP...
Definition PowerLaw_def.hpp:67
void evaluateDerivative(ParameterListPtr_Type params, double shearRate, double &res) override
For Newton method and NOX we need additional term in Jacobian considering directional derivative of o...
Definition PowerLaw_def.hpp:49
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36