source: issm/trunk-jpl/src/c/classes/Materials/Matestar.cpp@ 21381

Last change on this file since 21381 was 21381, checked in by felicity, 8 years ago

CHG: ESTAR in terms of epseff and B

File size: 11.5 KB
Line 
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*/
29Matestar::Matestar(){/*{{{*/
30 this->helement=NULL;
31 this->element=NULL;
32 return;
33}
34/*}}}*/
35Matestar::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/*}}}*/
51Matestar::~Matestar(){/*{{{*/
52 delete helement;
53 return;
54}
55/*}}}*/
56
57/*Object virtual functions definitions:*/
58Object* 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/*}}}*/
74Material* 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/*}}}*/
90void Matestar::DeepEcho(void){/*{{{*/
91
92 _printf_("Matestar:\n");
93 _printf_(" mid: " << mid << "\n");
94 _printf_(" element:\n");
95 helement->Echo();
96}
97/*}}}*/
98void Matestar::Echo(void){/*{{{*/
99
100 _printf_("Matestar:\n");
101 _printf_(" mid: " << mid << "\n");
102 _printf_(" element:\n");
103 helement->Echo();
104}
105/*}}}*/
106int Matestar::Id(void){ return mid; }/*{{{*/
107/*}}}*/
108void Matestar::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
109
110 if(marshall_direction==MARSHALLING_BACKWARD)helement=new Hook();
111
112 MARSHALLING_ENUM(MatestarEnum);
113 MARSHALLING(mid);
114 this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
115 this->element=(Element*)this->helement->delivers();
116
117}
118/*}}}*/
119int Matestar::ObjectEnum(void){/*{{{*/
120
121 return MatestarEnum;
122
123}
124/*}}}*/
125
126/*Matestar management*/
127void 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/*}}}*/
135IssmDouble Matestar::GetA(){/*{{{*/
136 /*
137 * A = 1/B^n
138 */
139
140 IssmDouble B,n;
141
142 element->inputs->GetInputAverage(&B,MaterialsRheologyBEnum);
143 n=this->GetN();
144
145 return pow(B,-n);
146}
147/*}}}*/
148IssmDouble Matestar::GetAbar(){/*{{{*/
149 /*
150 * A = 1/B^n
151 */
152
153 IssmDouble B,n;
154
155 element->inputs->GetInputAverage(&B,MaterialsRheologyBbarEnum);
156 n=this->GetN();
157
158 return pow(B,-n);
159}
160/*}}}*/
161IssmDouble Matestar::GetB(){/*{{{*/
162 /*Output*/
163 IssmDouble B;
164
165 element->inputs->GetInputAverage(&B,MaterialsRheologyBEnum);
166 return B;
167}
168/*}}}*/
169IssmDouble Matestar::GetBbar(){/*{{{*/
170 /*Output*/
171 IssmDouble Bbar;
172
173 element->inputs->GetInputAverage(&Bbar,MaterialsRheologyBbarEnum);
174 return Bbar;
175}
176/*}}}*/
177IssmDouble Matestar::GetD(){/*{{{*/
178 _error_("not implemented yet");
179}
180/*}}}*/
181IssmDouble Matestar::GetDbar(){/*{{{*/
182
183 _error_("not implemented yet");
184}
185/*}}}*/
186IssmDouble Matestar::GetEc(){/*{{{*/
187
188 /*Output*/
189 IssmDouble Ec;
190
191 element->inputs->GetInputAverage(&Ec,MaterialsRheologyEcEnum);
192 return Ec;
193}
194/*}}}*/
195IssmDouble Matestar::GetEs(){/*{{{*/
196
197 /*Output*/
198 IssmDouble Es;
199
200 element->inputs->GetInputAverage(&Es,MaterialsRheologyEsEnum);
201 return Es;
202}
203/*}}}*/
204IssmDouble Matestar::GetN(){/*{{{*/
205 return 3.;
206}
207/*}}}*/
208void Matestar::GetViscosity(IssmDouble* pviscosity,IssmDouble eps_eff){/*{{{*/
209 _error_("not implemented yet");
210 /*From a string tensor and a material object, return viscosity, using Glen's flow law.
211 (1-D) B
212 viscosity= -------------------------
213 2 eps_eff ^[(n-1)/n]
214
215 where viscosity is the viscotiy, B the flow law parameter , eps_eff is the effective strain rate
216 and n the flow law exponent.
217
218 If eps_eff = 0 , it means this is the first time SystemMatrices is being run, and we
219 return 10^14, initial viscosity.
220 */
221
222 /*output: */
223 IssmDouble viscosity;
224
225 /*Intermediary: */
226 IssmDouble B,D=0.,n;
227
228 /*Get B and n*/
229 B=GetB(); _assert_(B>0.);
230 n=GetN(); _assert_(n>0.);
231
232 if (n==1.){
233 /*Linear Viscous behavior (Newtonian fluid) viscosity=B/2: */
234 viscosity=(1.-D)*B/2.;
235 }
236 else{
237
238 /*if no strain rate, return maximum viscosity*/
239 if(eps_eff==0.){
240 viscosity = 1.e+14/2.;
241 //viscosity = B;
242 //viscosity=2.5*pow(10.,17);
243 }
244
245 else{
246 viscosity=(1.-D)*B/(2.*pow(eps_eff,(n-1.)/n));
247 }
248 }
249
250 /*Checks in debugging mode*/
251 if(viscosity<=0) _error_("Negative viscosity");
252
253 /*Return: */
254 *pviscosity=viscosity;
255}
256/*}}}*/
257void Matestar::GetViscosityBar(IssmDouble* pviscosity,IssmDouble eps_eff){/*{{{*/
258 _error_("not implemented yet");
259}
260/*}}}*/
261void Matestar::GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
262 _error_("not implemented yet");
263}
264/*}}}*/
265void Matestar::GetViscosityDComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
266 _error_("not implemented yet");
267}
268/*}}}*/
269void Matestar::GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
270 _error_("not implemented yet");
271}
272/*}}}*/
273IssmDouble Matestar::GetViscosityGeneral(IssmDouble vx,IssmDouble vy,IssmDouble vz,IssmDouble* dvx,IssmDouble* dvy,IssmDouble* dvz){/*{{{*/
274
275 /*Intermediaries*/
276 IssmDouble viscosity;
277 IssmDouble epseff,epsprime_norm;
278 IssmDouble lambdas;
279 IssmDouble vmag,dvmag[3];
280 IssmDouble B,Ec,Es,E;
281
282 /*Calculate velocity magnitude and its derivative*/
283 vmag = sqrt(vx*vx+vy*vy+vz*vz);
284 if(vmag<1e-12){
285 dvmag[0]=0;
286 dvmag[1]=0;
287 dvmag[2]=0;
288 }
289 else{
290 dvmag[0]=1./(2*sqrt(vmag))*(2*vx*dvx[0]+2*vy*dvy[0]+2*vz*dvz[0]);
291 dvmag[1]=1./(2*sqrt(vmag))*(2*vx*dvx[1]+2*vy*dvy[1]+2*vz*dvz[1]);
292 dvmag[2]=1./(2*sqrt(vmag))*(2*vx*dvx[2]+2*vy*dvy[2]+2*vz*dvz[2]);
293 }
294
295 EstarStrainrateQuantities(&epseff,&epsprime_norm,vx,vy,vz,vmag,dvx,dvy,dvz,&dvmag[0]);
296 lambdas=EstarLambdaS(epseff,epsprime_norm);
297
298 /*Get B and enhancement*/
299 B=GetB(); _assert_(B>0.);
300 Ec=GetEc(); _assert_(Ec>=0.);
301 Es=GetEs(); _assert_(Es>=0.);
302
303 /*Get total enhancement factor E(lambdas)*/
304 E = Ec + (Es-Ec)*lambdas*lambdas; _assert_(E>0.);
305
306 /*Compute viscosity*/
307 /*if no strain rate, return maximum viscosity*/
308 if(epseff==0.){
309 viscosity = 1.e+14/2.;
310 //viscosity = B;
311 //viscosity=2.5*pow(10.,17);
312 }
313 else{
314 viscosity = B/(2.*pow(E*epseff*epseff,1./3.));
315 }
316
317 /*Assign output pointer*/
318 return viscosity;
319}
320/*}}}*/
321void Matestar::GetViscosity_B(IssmDouble* pdmudB,IssmDouble eps_eff){/*{{{*/
322 _error_("not implemented yet");
323}
324/*}}}*/
325void Matestar::GetViscosity_D(IssmDouble* pdmudD,IssmDouble eps_eff){/*{{{*/
326 _error_("not implemented yet");
327}
328/*}}}*/
329void Matestar::GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
330 _error_("not implemented yet");
331}
332/*}}}*/
333void Matestar::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
334 /*Nothing updated yet*/
335}
336/*}}}*/
337void Matestar::InputUpdateFromConstant(int constant, int name){/*{{{*/
338 /*Nothing updated yet*/
339}
340/*}}}*/
341void Matestar::InputUpdateFromConstant(bool constant, int name){/*{{{*/
342 /*Nothing updated yet*/
343}
344/*}}}*/
345void Matestar::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols,int name, int type){/*{{{*/
346 /*Nothing updated yet*/
347}
348/*}}}*/
349void Matestar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
350
351}
352/*}}}*/
353void Matestar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
354
355}
356/*}}}*/
357bool Matestar::IsDamage(){/*{{{*/
358
359 _error_("not implemented yet");
360}
361/*}}}*/
362void Matestar::ResetHooks(){/*{{{*/
363
364 this->element=NULL;
365
366 /*Get Element type*/
367 this->helement->reset();
368
369}
370/*}}}*/
371void Matestar::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
372
373}
374/*}}}*/
375void Matestar::ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input){/*{{{*/
376
377 /*Intermediaries*/
378 IssmDouble vx,vy,vz;
379 IssmDouble dvx[3],dvy[3],dvz[3];
380 IssmDouble B,Ec,Es;
381
382 /*Get velocity derivatives in all directions*/
383 _assert_(dim>1);
384 _assert_(vx_input);
385 vx_input->GetInputValue(&vx,gauss);
386 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss);
387 _assert_(vy_input);
388 vy_input->GetInputValue(&vy,gauss);
389 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss);
390 if(dim==3){
391 _assert_(vz_input);
392 vz_input->GetInputValue(&vz,gauss);
393 vz_input->GetInputDerivativeValue(&dvz[0],xyz_list,gauss);
394 }
395 else{
396 vz = 0.;
397 dvz[0] = 0.; dvz[1] = 0.; dvz[2] = 0.;
398 }
399
400 /*Compute viscosity*/
401 *pviscosity=GetViscosityGeneral(vx,vy,vz,&dvx[0],&dvy[0],&dvz[0]);
402}
403/*}}}*/
404void Matestar::ViscosityFSDerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/
405 this->GetViscosityDerivativeEpsSquare(pmu_prime,epsilon);
406}/*}}}*/
407void Matestar::ViscosityHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/
408
409 /*Intermediaries*/
410 IssmDouble vx,vy,vz;
411 IssmDouble dvx[3],dvy[3],dvz[3];
412
413 /*Get velocity derivatives in all directions*/
414 _assert_(dim==2 || dim==3);
415 _assert_(vx_input);
416 vx_input->GetInputValue(&vx,gauss);
417 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss);
418 if(dim==3){
419 _assert_(vy_input);
420 vy_input->GetInputValue(&vy,gauss);
421 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss);
422 }
423 else{
424 dvx[2] = 0.;
425 vy = 0.;
426 dvy[0] = 0.; dvy[1] = 0.; dvy[2] = 0.;
427 }
428 vz = 0.;
429 dvz[0] = 0.; dvz[1] = 0.; dvz[2] = -dvx[0]-dvy[1];
430
431 /*Compute viscosity*/
432 *pviscosity=GetViscosityGeneral(vx,vy,vz,&dvx[0],&dvy[0],&dvz[0]);
433}/*}}}*/
434void Matestar::ViscosityHODerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/
435 _error_("not implemented yet");
436}/*}}}*/
437void Matestar::ViscosityL1L2(IssmDouble* pviscosity,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* surface_input){/*{{{*/
438 _error_("not implemented yet");
439}/*}}}*/
440void Matestar::ViscositySSA(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/
441 /*Intermediaries*/
442 IssmDouble vx,vy,vz;
443 IssmDouble dvx[3],dvy[3],dvz[3];
444 IssmDouble B,Ec,Es;
445
446 /*Get velocity derivatives in all directions*/
447 _assert_(dim==1 || dim==2);
448 _assert_(vx_input);
449 vx_input->GetInputValue(&vx,gauss);
450 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss);
451 if(dim==2){
452 _assert_(vy_input);
453 vy_input->GetInputValue(&vy,gauss);
454 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss);
455 }
456 else{
457 dvx[1] = 0.;
458 dvx[2] = 0.;
459 vy = 0.;
460 dvy[0] = 0.; dvy[1] = 0.; dvy[2] = 0.;
461 }
462 dvx[2] = 0.;
463 dvy[2] = 0.;
464 vz = 0.;
465 dvz[0] = 0.; dvz[1] = 0.; dvz[2] = -dvx[0]-dvy[1];
466
467 /*Compute viscosity*/
468 *pviscosity=GetViscosityGeneral(vx,vy,vz,&dvx[0],&dvy[0],&dvz[0]);
469}/*}}}*/
470void Matestar::ViscositySSADerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/
471 _error_("not implemented yet");
472}/*}}}*/
Note: See TracBrowser for help on using the repository browser.