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