[20687] | 1 | /*!\file Matestar.c
|
---|
| 2 | * \brief: implementation of the Matestar object
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | #ifdef HAVE_CONFIG_H
|
---|
| 6 | #include <config.h>
|
---|
| 7 | #else
|
---|
| 8 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 9 | #endif
|
---|
| 10 |
|
---|
| 11 | #include "./Matestar.h"
|
---|
| 12 | #include "./Materials.h"
|
---|
| 13 | #include "../Inputs/Input.h"
|
---|
| 14 | #include "../Inputs/Inputs.h"
|
---|
| 15 | #include "../Inputs/TriaInput.h"
|
---|
| 16 | #include "../Inputs/PentaInput.h"
|
---|
| 17 | #include "../Inputs/ControlInput.h"
|
---|
| 18 | #include "../Elements/Element.h"
|
---|
| 19 | #include "../Elements/Tria.h"
|
---|
| 20 | #include "../Elements/Penta.h"
|
---|
| 21 | #include "../Params/Parameters.h"
|
---|
| 22 | #include "../Vertex.h"
|
---|
| 23 | #include "../Hook.h"
|
---|
| 24 | #include "../Node.h"
|
---|
| 25 | #include "../IoModel.h"
|
---|
| 26 | #include "../../shared/shared.h"
|
---|
| 27 |
|
---|
| 28 | /*Matestar constructors and destructor*/
|
---|
| 29 | Matestar::Matestar(){/*{{{*/
|
---|
| 30 | this->helement=NULL;
|
---|
| 31 | this->element=NULL;
|
---|
| 32 | return;
|
---|
| 33 | }
|
---|
| 34 | /*}}}*/
|
---|
| 35 | Matestar::Matestar(int matestar_mid,int index, IoModel* iomodel){/*{{{*/
|
---|
| 36 |
|
---|
| 37 | /*Intermediaries:*/
|
---|
| 38 | int matestar_eid;
|
---|
| 39 |
|
---|
| 40 | /*Initialize id*/
|
---|
| 41 | this->mid=matestar_mid;
|
---|
| 42 |
|
---|
| 43 | /*Hooks: */
|
---|
| 44 | matestar_eid=index+1;
|
---|
| 45 | this->helement=new Hook(&matestar_eid,1);
|
---|
| 46 | this->element=NULL;
|
---|
| 47 |
|
---|
| 48 | return;
|
---|
| 49 | }
|
---|
| 50 | /*}}}*/
|
---|
| 51 | Matestar::~Matestar(){/*{{{*/
|
---|
| 52 | delete helement;
|
---|
| 53 | return;
|
---|
| 54 | }
|
---|
| 55 | /*}}}*/
|
---|
| 56 |
|
---|
| 57 | /*Object virtual functions definitions:*/
|
---|
| 58 | Object* Matestar::copy() {/*{{{*/
|
---|
| 59 |
|
---|
| 60 | /*Output*/
|
---|
| 61 | Matestar* matestar=NULL;
|
---|
| 62 |
|
---|
| 63 | /*Initialize output*/
|
---|
| 64 | matestar=new Matestar();
|
---|
| 65 |
|
---|
| 66 | /*copy fields: */
|
---|
| 67 | matestar->mid=this->mid;
|
---|
| 68 | matestar->helement=(Hook*)this->helement->copy();
|
---|
| 69 | matestar->element =(Element*)this->helement->delivers();
|
---|
| 70 |
|
---|
| 71 | return matestar;
|
---|
| 72 | }
|
---|
| 73 | /*}}}*/
|
---|
| 74 | Material* Matestar::copy2(Element* element_in) {/*{{{*/
|
---|
| 75 |
|
---|
| 76 | /*Output*/
|
---|
| 77 | Matestar* matestar=NULL;
|
---|
| 78 |
|
---|
| 79 | /*Initialize output*/
|
---|
| 80 | matestar=new Matestar();
|
---|
| 81 |
|
---|
| 82 | /*copy fields: */
|
---|
| 83 | matestar->mid=this->mid;
|
---|
| 84 | matestar->helement=(Hook*)this->helement->copy();
|
---|
| 85 | matestar->element =element_in;
|
---|
| 86 |
|
---|
| 87 | return matestar;
|
---|
| 88 | }
|
---|
| 89 | /*}}}*/
|
---|
| 90 | void Matestar::DeepEcho(void){/*{{{*/
|
---|
| 91 |
|
---|
| 92 | _printf_("Matestar:\n");
|
---|
| 93 | _printf_(" mid: " << mid << "\n");
|
---|
| 94 | _printf_(" element:\n");
|
---|
| 95 | helement->Echo();
|
---|
| 96 | }
|
---|
| 97 | /*}}}*/
|
---|
| 98 | void Matestar::Echo(void){/*{{{*/
|
---|
| 99 |
|
---|
| 100 | _printf_("Matestar:\n");
|
---|
| 101 | _printf_(" mid: " << mid << "\n");
|
---|
| 102 | _printf_(" element:\n");
|
---|
| 103 | helement->Echo();
|
---|
| 104 | }
|
---|
| 105 | /*}}}*/
|
---|
| 106 | int Matestar::Id(void){ return mid; }/*{{{*/
|
---|
| 107 | /*}}}*/
|
---|
| 108 | int Matestar::ObjectEnum(void){/*{{{*/
|
---|
| 109 |
|
---|
| 110 | return MatestarEnum;
|
---|
| 111 |
|
---|
| 112 | }
|
---|
| 113 | /*}}}*/
|
---|
| 114 | void Matestar::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
|
---|
| 115 |
|
---|
| 116 | if(marshall_direction==MARSHALLING_BACKWARD)helement=new Hook();
|
---|
| 117 |
|
---|
| 118 | MARSHALLING_ENUM(MatestarEnum);
|
---|
| 119 | MARSHALLING(mid);
|
---|
| 120 | this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
|
---|
| 121 | this->element=(Element*)this->helement->delivers();
|
---|
| 122 |
|
---|
| 123 | }
|
---|
| 124 | /*}}}*/
|
---|
| 125 |
|
---|
| 126 | /*Matestar management*/
|
---|
| 127 | void Matestar::Configure(Elements* elementsin){/*{{{*/
|
---|
| 128 |
|
---|
| 129 | /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
|
---|
| 130 | * datasets, using internal ids and offsets hidden in hooks: */
|
---|
| 131 | helement->configure((DataSet*)elementsin);
|
---|
| 132 | this->element = (Element*)helement->delivers();
|
---|
| 133 | }
|
---|
| 134 | /*}}}*/
|
---|
| 135 | void Matestar::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
|
---|
| 136 |
|
---|
| 137 | }
|
---|
| 138 | /*}}}*/
|
---|
| 139 | IssmDouble Matestar::GetA(){/*{{{*/
|
---|
| 140 | _error_("not implemented yet");
|
---|
| 141 | }
|
---|
| 142 | /*}}}*/
|
---|
| 143 | IssmDouble Matestar::GetAbar(){/*{{{*/
|
---|
| 144 | _error_("not implemented yet");
|
---|
| 145 | }
|
---|
| 146 | /*}}}*/
|
---|
| 147 | IssmDouble Matestar::GetB(){/*{{{*/
|
---|
| 148 | _error_("not implemented yet");
|
---|
| 149 | }
|
---|
| 150 | /*}}}*/
|
---|
| 151 | IssmDouble Matestar::GetBbar(){/*{{{*/
|
---|
| 152 |
|
---|
| 153 | _error_("not implemented yet");
|
---|
| 154 | }
|
---|
| 155 | /*}}}*/
|
---|
| 156 | IssmDouble Matestar::GetN(){/*{{{*/
|
---|
| 157 | _error_("not implemented yet");
|
---|
| 158 | }
|
---|
| 159 | /*}}}*/
|
---|
| 160 | IssmDouble Matestar::GetD(){/*{{{*/
|
---|
| 161 | _error_("not implemented yet");
|
---|
| 162 | }
|
---|
| 163 | /*}}}*/
|
---|
| 164 | IssmDouble Matestar::GetDbar(){/*{{{*/
|
---|
| 165 |
|
---|
| 166 | _error_("not implemented yet");
|
---|
| 167 | }
|
---|
| 168 | /*}}}*/
|
---|
| 169 | bool Matestar::IsDamage(){/*{{{*/
|
---|
| 170 |
|
---|
| 171 | _error_("not implemented yet");
|
---|
| 172 | }
|
---|
| 173 | /*}}}*/
|
---|
| 174 | void Matestar::GetViscosity(IssmDouble* pviscosity,IssmDouble eps_eff){/*{{{*/
|
---|
| 175 | _error_("not implemented yet");
|
---|
| 176 | /*From a string tensor and a material object, return viscosity, using Glen's flow law.
|
---|
| 177 | (1-D) B
|
---|
| 178 | viscosity= -------------------------
|
---|
| 179 | 2 eps_eff ^[(n-1)/n]
|
---|
| 180 |
|
---|
| 181 | where viscosity is the viscotiy, B the flow law parameter , eps_eff is the effective strain rate
|
---|
| 182 | and n the flow law exponent.
|
---|
| 183 |
|
---|
| 184 | If eps_eff = 0 , it means this is the first time SystemMatrices is being run, and we
|
---|
| 185 | return 10^14, initial viscosity.
|
---|
| 186 | */
|
---|
| 187 |
|
---|
| 188 | /*output: */
|
---|
| 189 | IssmDouble viscosity;
|
---|
| 190 |
|
---|
| 191 | /*Intermediary: */
|
---|
| 192 | IssmDouble B,D=0.,n;
|
---|
| 193 |
|
---|
| 194 | /*Get B and n*/
|
---|
| 195 | B=GetB(); _assert_(B>0.);
|
---|
| 196 | n=GetN(); _assert_(n>0.);
|
---|
| 197 |
|
---|
| 198 | if (n==1.){
|
---|
| 199 | /*Linear Viscous behavior (Newtonian fluid) viscosity=B/2: */
|
---|
| 200 | viscosity=(1.-D)*B/2.;
|
---|
| 201 | }
|
---|
| 202 | else{
|
---|
| 203 |
|
---|
| 204 | /*if no strain rate, return maximum viscosity*/
|
---|
| 205 | if(eps_eff==0.){
|
---|
| 206 | viscosity = 1.e+14/2.;
|
---|
| 207 | //viscosity = B;
|
---|
| 208 | //viscosity=2.5*pow(10.,17);
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 | else{
|
---|
| 212 | viscosity=(1.-D)*B/(2.*pow(eps_eff,(n-1.)/n));
|
---|
| 213 | }
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | /*Checks in debugging mode*/
|
---|
| 217 | if(viscosity<=0) _error_("Negative viscosity");
|
---|
| 218 |
|
---|
| 219 | /*Return: */
|
---|
| 220 | *pviscosity=viscosity;
|
---|
| 221 | }
|
---|
| 222 | /*}}}*/
|
---|
| 223 | void Matestar::GetViscosity_B(IssmDouble* pdmudB,IssmDouble eps_eff){/*{{{*/
|
---|
| 224 | _error_("not implemented yet");
|
---|
| 225 | }
|
---|
| 226 | /*}}}*/
|
---|
| 227 | void Matestar::GetViscosity_D(IssmDouble* pdmudD,IssmDouble eps_eff){/*{{{*/
|
---|
| 228 | _error_("not implemented yet");
|
---|
| 229 | }
|
---|
| 230 | /*}}}*/
|
---|
| 231 | void Matestar::GetViscosityBar(IssmDouble* pviscosity,IssmDouble eps_eff){/*{{{*/
|
---|
| 232 | _error_("not implemented yet");
|
---|
| 233 | }
|
---|
| 234 | /*}}}*/
|
---|
| 235 | void Matestar::GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
|
---|
| 236 | _error_("not implemented yet");
|
---|
| 237 | }
|
---|
| 238 | /*}}}*/
|
---|
| 239 | void Matestar::GetViscosityDComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
|
---|
| 240 | _error_("not implemented yet");
|
---|
| 241 | }
|
---|
| 242 | /*}}}*/
|
---|
| 243 | void Matestar::GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
|
---|
| 244 | _error_("not implemented yet");
|
---|
| 245 | }
|
---|
| 246 | /*}}}*/
|
---|
| 247 | void Matestar::GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
|
---|
| 248 | _error_("not implemented yet");
|
---|
| 249 | }
|
---|
| 250 | /*}}}*/
|
---|
| 251 | void Matestar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
|
---|
| 252 |
|
---|
| 253 | }
|
---|
| 254 | /*}}}*/
|
---|
| 255 | void Matestar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
|
---|
| 256 |
|
---|
| 257 | }
|
---|
| 258 | /*}}}*/
|
---|
| 259 | void Matestar::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols,int name, int type){/*{{{*/
|
---|
| 260 | /*Nothing updated yet*/
|
---|
| 261 | }
|
---|
| 262 | /*}}}*/
|
---|
| 263 | void Matestar::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
|
---|
| 264 | /*Nothing updated yet*/
|
---|
| 265 | }
|
---|
| 266 | /*}}}*/
|
---|
| 267 | void Matestar::InputUpdateFromConstant(int constant, int name){/*{{{*/
|
---|
| 268 | /*Nothing updated yet*/
|
---|
| 269 | }
|
---|
| 270 | /*}}}*/
|
---|
| 271 | void Matestar::InputUpdateFromConstant(bool constant, int name){/*{{{*/
|
---|
| 272 | /*Nothing updated yet*/
|
---|
| 273 | }
|
---|
| 274 | /*}}}*/
|
---|
| 275 | void Matestar::ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input){/*{{{*/
|
---|
| 276 |
|
---|
| 277 | /*Intermediaries*/
|
---|
| 278 | IssmDouble vx,vy,vz;
|
---|
| 279 | IssmDouble dvx[3],dvy[3],dvz[3];
|
---|
| 280 | IssmDouble ko,Ec,Es;
|
---|
| 281 |
|
---|
| 282 | /*Get velocity derivatives in all directions*/
|
---|
| 283 | _assert_(dim>1);
|
---|
| 284 | _assert_(vx_input);
|
---|
| 285 | vx_input->GetInputValue(&vx,gauss);
|
---|
| 286 | vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss);
|
---|
| 287 | _assert_(vy_input);
|
---|
| 288 | vy_input->GetInputValue(&vy,gauss);
|
---|
| 289 | vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss);
|
---|
| 290 | if(dim==3){
|
---|
| 291 | _assert_(vz_input);
|
---|
| 292 | vz_input->GetInputValue(&vz,gauss);
|
---|
| 293 | vz_input->GetInputDerivativeValue(&dvz[0],xyz_list,gauss);
|
---|
| 294 | }
|
---|
| 295 | else{
|
---|
| 296 | vz = 0.;
|
---|
| 297 | dvz[0] = 0.; dvz[1] = 0.; dvz[2] = 0.;
|
---|
| 298 | }
|
---|
| 299 |
|
---|
| 300 | /*Get enhancement factors and ko*/
|
---|
| 301 | Input* ec_input = element->inputs->GetInput(MaterialsRheologyEcEnum); _assert_(ec_input);
|
---|
| 302 | Input* es_input = element->inputs->GetInput(MaterialsRheologyEsEnum); _assert_(es_input);
|
---|
| 303 | Input* ko_input = element->inputs->GetInput(MaterialsRheologyKoEnum); _assert_(ko_input);
|
---|
| 304 | ec_input->GetInputValue(&Ec,gauss);
|
---|
| 305 | es_input->GetInputValue(&Es,gauss);
|
---|
| 306 | ko_input->GetInputValue(&ko,gauss);
|
---|
| 307 |
|
---|
| 308 | /*Compute viscosity*/
|
---|
| 309 | *pviscosity=GetViscosityGeneral(ko,Ec,Es,vx,vy,vz,&dvx[0],&dvy[0],&dvz[0]);
|
---|
| 310 | }
|
---|
| 311 | /*}}}*/
|
---|
| 312 | void Matestar::ViscosityFSDerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/
|
---|
| 313 | this->GetViscosityDerivativeEpsSquare(pmu_prime,epsilon);
|
---|
| 314 | }/*}}}*/
|
---|
| 315 | void Matestar::ViscosityHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/
|
---|
| 316 |
|
---|
| 317 | /*Intermediaries*/
|
---|
| 318 | IssmDouble vx,vy,vz;
|
---|
| 319 | IssmDouble dvx[3],dvy[3],dvz[3];
|
---|
| 320 | IssmDouble ko,Ec,Es;
|
---|
| 321 |
|
---|
| 322 | /*Get velocity derivatives in all directions*/
|
---|
| 323 | _assert_(dim==2 || dim==3);
|
---|
| 324 | _assert_(vx_input);
|
---|
| 325 | vx_input->GetInputValue(&vx,gauss);
|
---|
| 326 | vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss);
|
---|
| 327 | if(dim==3){
|
---|
| 328 | _assert_(vy_input);
|
---|
| 329 | vy_input->GetInputValue(&vy,gauss);
|
---|
| 330 | vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss);
|
---|
| 331 | }
|
---|
| 332 | else{
|
---|
| 333 | dvx[2] = 0.;
|
---|
| 334 | vy = 0.;
|
---|
| 335 | dvy[0] = 0.; dvy[1] = 0.; dvy[2] = 0.;
|
---|
| 336 | }
|
---|
| 337 | vz = 0.;
|
---|
| 338 | dvz[0] = 0.; dvz[1] = 0.; dvz[2] = -dvx[0]-dvy[1];
|
---|
| 339 |
|
---|
| 340 | /*Get enhancement factors and ko*/
|
---|
| 341 | Input* ec_input = element->inputs->GetInput(MaterialsRheologyEcEnum); _assert_(ec_input);
|
---|
| 342 | Input* es_input = element->inputs->GetInput(MaterialsRheologyEsEnum); _assert_(es_input);
|
---|
| 343 | Input* ko_input = element->inputs->GetInput(MaterialsRheologyKoEnum); _assert_(ko_input);
|
---|
| 344 | ec_input->GetInputValue(&Ec,gauss);
|
---|
| 345 | es_input->GetInputValue(&Es,gauss);
|
---|
| 346 | ko_input->GetInputValue(&ko,gauss);
|
---|
| 347 |
|
---|
| 348 | /*Compute viscosity*/
|
---|
| 349 | *pviscosity=GetViscosityGeneral(ko,Ec,Es,vx,vy,vz,&dvx[0],&dvy[0],&dvz[0]);
|
---|
| 350 | }/*}}}*/
|
---|
| 351 | void Matestar::ViscosityHODerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/
|
---|
| 352 | _error_("not implemented yet");
|
---|
| 353 | }/*}}}*/
|
---|
| 354 | void Matestar::ViscosityL1L2(IssmDouble* pviscosity,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* surface_input){/*{{{*/
|
---|
| 355 | _error_("not implemented yet");
|
---|
| 356 | }/*}}}*/
|
---|
| 357 | void Matestar::ViscositySSA(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/
|
---|
| 358 | /*Intermediaries*/
|
---|
| 359 | IssmDouble vx,vy,vz;
|
---|
| 360 | IssmDouble dvx[3],dvy[3],dvz[3];
|
---|
| 361 | IssmDouble ko,Ec,Es;
|
---|
| 362 |
|
---|
| 363 | /*Get velocity derivatives in all directions*/
|
---|
| 364 | _assert_(dim==1 || dim==2);
|
---|
| 365 | _assert_(vx_input);
|
---|
| 366 | vx_input->GetInputValue(&vx,gauss);
|
---|
| 367 | vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss);
|
---|
| 368 | if(dim==2){
|
---|
| 369 | _assert_(vy_input);
|
---|
| 370 | vy_input->GetInputValue(&vy,gauss);
|
---|
| 371 | vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss);
|
---|
| 372 | }
|
---|
| 373 | else{
|
---|
| 374 | dvx[1] = 0.;
|
---|
| 375 | dvx[2] = 0.;
|
---|
| 376 | vy = 0.;
|
---|
| 377 | dvy[0] = 0.; dvy[1] = 0.; dvy[2] = 0.;
|
---|
| 378 | }
|
---|
| 379 | vz = 0.;
|
---|
| 380 | dvz[0] = 0.; dvz[1] = 0.; dvz[2] = -dvx[0]-dvy[1];
|
---|
| 381 |
|
---|
| 382 | /*Get enhancement factors and ko*/
|
---|
| 383 | Input* ec_input = element->inputs->GetInput(MaterialsRheologyEcbarEnum); _assert_(ec_input);
|
---|
| 384 | Input* es_input = element->inputs->GetInput(MaterialsRheologyEsbarEnum); _assert_(es_input);
|
---|
| 385 | Input* ko_input = element->inputs->GetInput(MaterialsRheologyKobarEnum); _assert_(ko_input);
|
---|
| 386 | ec_input->GetInputValue(&Ec,gauss);
|
---|
| 387 | es_input->GetInputValue(&Es,gauss);
|
---|
| 388 | ko_input->GetInputValue(&ko,gauss);
|
---|
| 389 |
|
---|
| 390 | /*Compute viscosity*/
|
---|
| 391 | *pviscosity=GetViscosityGeneral(ko,Ec,Es,vx,vy,vz,&dvx[0],&dvy[0],&dvz[0]);
|
---|
| 392 | }/*}}}*/
|
---|
| 393 | void Matestar::ViscositySSADerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/
|
---|
| 394 | _error_("not implemented yet");
|
---|
| 395 | }/*}}}*/
|
---|
| 396 | void Matestar::ResetHooks(){/*{{{*/
|
---|
| 397 |
|
---|
| 398 | this->element=NULL;
|
---|
| 399 |
|
---|
| 400 | /*Get Element type*/
|
---|
| 401 | this->helement->reset();
|
---|
| 402 |
|
---|
| 403 | }
|
---|
| 404 | /*}}}*/
|
---|
| 405 | IssmDouble Matestar::GetViscosityGeneral(IssmDouble ko,IssmDouble Ec, IssmDouble Es,IssmDouble vx,IssmDouble vy,IssmDouble vz,IssmDouble* dvx,IssmDouble* dvy,IssmDouble* dvz){/*{{{*/
|
---|
| 406 |
|
---|
| 407 | /*Intermediaries*/
|
---|
| 408 | IssmDouble viscosity;
|
---|
| 409 | IssmDouble E,lambdas;
|
---|
| 410 | IssmDouble epso,epsprime_norm;
|
---|
| 411 | IssmDouble vmag,dvmag[3];
|
---|
| 412 |
|
---|
| 413 | /*Calculate velocity magnitude and its derivative*/
|
---|
| 414 | vmag = sqrt(vx*vx+vy*vy+vz*vz);
|
---|
| 415 | if(vmag<1e-12){
|
---|
| 416 | dvmag[0]=0;
|
---|
| 417 | dvmag[1]=0;
|
---|
| 418 | dvmag[2]=0;
|
---|
| 419 | }
|
---|
| 420 | else{
|
---|
| 421 | dvmag[0]=1./(2*sqrt(vmag))*(2*vx*dvx[0]+2*vy*dvy[0]+2*vz*dvz[0]);
|
---|
| 422 | dvmag[1]=1./(2*sqrt(vmag))*(2*vx*dvx[1]+2*vy*dvy[1]+2*vz*dvz[1]);
|
---|
| 423 | dvmag[2]=1./(2*sqrt(vmag))*(2*vx*dvx[2]+2*vy*dvy[2]+2*vz*dvz[2]);
|
---|
| 424 | }
|
---|
| 425 |
|
---|
| 426 | EstarStrainrateQuantities(&epso,&epsprime_norm,vx,vy,vz,vmag,dvx,dvy,dvz,&dvmag[0]);
|
---|
| 427 | lambdas=EstarLambdaS(epso,epsprime_norm);
|
---|
| 428 |
|
---|
| 429 | /*Get total enhancement factor E(lambdas)*/
|
---|
| 430 | E = Ec + (Es-Ec)*lambdas*lambdas;
|
---|
| 431 |
|
---|
| 432 | /*Compute viscosity*/
|
---|
| 433 | _assert_(E>0.);
|
---|
| 434 | _assert_(ko>0.);
|
---|
| 435 | _assert_(epso>0.);
|
---|
| 436 | viscosity = 1./(2*pow(ko*E*epso*epso,1./3.));
|
---|
| 437 |
|
---|
| 438 | /*Assign output pointer*/
|
---|
| 439 | return viscosity;
|
---|
| 440 | }
|
---|
| 441 | /*}}}*/
|
---|