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

Last change on this file since 20827 was 20827, checked in by agscott1, 9 years ago

CHG: Alphabetized all function names under classes

File size: 11.9 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 _error_("not implemented yet");
137}
138/*}}}*/
139IssmDouble Matestar::GetAbar(){/*{{{*/
140 _error_("not implemented yet");
141}
142/*}}}*/
143IssmDouble Matestar::GetB(){/*{{{*/
144 _error_("not implemented yet");
145}
146/*}}}*/
147IssmDouble Matestar::GetBbar(){/*{{{*/
148
149 _error_("not implemented yet");
150}
151/*}}}*/
152IssmDouble Matestar::GetD(){/*{{{*/
153 _error_("not implemented yet");
154}
155/*}}}*/
156IssmDouble Matestar::GetDbar(){/*{{{*/
157
158 _error_("not implemented yet");
159}
160/*}}}*/
161IssmDouble Matestar::GetN(){/*{{{*/
162 _error_("not implemented yet");
163}
164/*}}}*/
165void Matestar::GetViscosity(IssmDouble* pviscosity,IssmDouble eps_eff){/*{{{*/
166 _error_("not implemented yet");
167 /*From a string tensor and a material object, return viscosity, using Glen's flow law.
168 (1-D) B
169 viscosity= -------------------------
170 2 eps_eff ^[(n-1)/n]
171
172 where viscosity is the viscotiy, B the flow law parameter , eps_eff is the effective strain rate
173 and n the flow law exponent.
174
175 If eps_eff = 0 , it means this is the first time SystemMatrices is being run, and we
176 return 10^14, initial viscosity.
177 */
178
179 /*output: */
180 IssmDouble viscosity;
181
182 /*Intermediary: */
183 IssmDouble B,D=0.,n;
184
185 /*Get B and n*/
186 B=GetB(); _assert_(B>0.);
187 n=GetN(); _assert_(n>0.);
188
189 if (n==1.){
190 /*Linear Viscous behavior (Newtonian fluid) viscosity=B/2: */
191 viscosity=(1.-D)*B/2.;
192 }
193 else{
194
195 /*if no strain rate, return maximum viscosity*/
196 if(eps_eff==0.){
197 viscosity = 1.e+14/2.;
198 //viscosity = B;
199 //viscosity=2.5*pow(10.,17);
200 }
201
202 else{
203 viscosity=(1.-D)*B/(2.*pow(eps_eff,(n-1.)/n));
204 }
205 }
206
207 /*Checks in debugging mode*/
208 if(viscosity<=0) _error_("Negative viscosity");
209
210 /*Return: */
211 *pviscosity=viscosity;
212}
213/*}}}*/
214void Matestar::GetViscosityBar(IssmDouble* pviscosity,IssmDouble eps_eff){/*{{{*/
215 _error_("not implemented yet");
216}
217/*}}}*/
218void Matestar::GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
219 _error_("not implemented yet");
220}
221/*}}}*/
222void Matestar::GetViscosityDComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
223 _error_("not implemented yet");
224}
225/*}}}*/
226void Matestar::GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
227 _error_("not implemented yet");
228}
229/*}}}*/
230IssmDouble Matestar::GetViscosityGeneral(IssmDouble ko,IssmDouble Ec, IssmDouble Es,IssmDouble vx,IssmDouble vy,IssmDouble vz,IssmDouble* dvx,IssmDouble* dvy,IssmDouble* dvz){/*{{{*/
231
232 /*Intermediaries*/
233 IssmDouble viscosity;
234 IssmDouble E,lambdas;
235 IssmDouble epso,epsprime_norm;
236 IssmDouble vmag,dvmag[3];
237
238 /*Calculate velocity magnitude and its derivative*/
239 vmag = sqrt(vx*vx+vy*vy+vz*vz);
240 if(vmag<1e-12){
241 dvmag[0]=0;
242 dvmag[1]=0;
243 dvmag[2]=0;
244 }
245 else{
246 dvmag[0]=1./(2*sqrt(vmag))*(2*vx*dvx[0]+2*vy*dvy[0]+2*vz*dvz[0]);
247 dvmag[1]=1./(2*sqrt(vmag))*(2*vx*dvx[1]+2*vy*dvy[1]+2*vz*dvz[1]);
248 dvmag[2]=1./(2*sqrt(vmag))*(2*vx*dvx[2]+2*vy*dvy[2]+2*vz*dvz[2]);
249 }
250
251 EstarStrainrateQuantities(&epso,&epsprime_norm,vx,vy,vz,vmag,dvx,dvy,dvz,&dvmag[0]);
252 lambdas=EstarLambdaS(epso,epsprime_norm);
253
254 /*Get total enhancement factor E(lambdas)*/
255 E = Ec + (Es-Ec)*lambdas*lambdas;
256
257 /*Compute viscosity*/
258 _assert_(E>0.);
259 _assert_(ko>0.);
260 _assert_(epso>0.);
261 viscosity = 1./(2*pow(ko*E*epso*epso,1./3.));
262
263 /*Assign output pointer*/
264 return viscosity;
265}
266/*}}}*/
267void Matestar::GetViscosity_B(IssmDouble* pdmudB,IssmDouble eps_eff){/*{{{*/
268 _error_("not implemented yet");
269}
270/*}}}*/
271void Matestar::GetViscosity_D(IssmDouble* pdmudD,IssmDouble eps_eff){/*{{{*/
272 _error_("not implemented yet");
273}
274/*}}}*/
275void Matestar::GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
276 _error_("not implemented yet");
277}
278/*}}}*/
279void Matestar::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
280 /*Nothing updated yet*/
281}
282/*}}}*/
283void Matestar::InputUpdateFromConstant(int constant, int name){/*{{{*/
284 /*Nothing updated yet*/
285}
286/*}}}*/
287void Matestar::InputUpdateFromConstant(bool constant, int name){/*{{{*/
288 /*Nothing updated yet*/
289}
290/*}}}*/
291void Matestar::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols,int name, int type){/*{{{*/
292 /*Nothing updated yet*/
293}
294/*}}}*/
295void Matestar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
296
297}
298/*}}}*/
299void Matestar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
300
301}
302/*}}}*/
303bool Matestar::IsDamage(){/*{{{*/
304
305 _error_("not implemented yet");
306}
307/*}}}*/
308void Matestar::ResetHooks(){/*{{{*/
309
310 this->element=NULL;
311
312 /*Get Element type*/
313 this->helement->reset();
314
315}
316/*}}}*/
317void Matestar::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
318
319}
320/*}}}*/
321void Matestar::ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input){/*{{{*/
322
323 /*Intermediaries*/
324 IssmDouble vx,vy,vz;
325 IssmDouble dvx[3],dvy[3],dvz[3];
326 IssmDouble ko,Ec,Es;
327
328 /*Get velocity derivatives in all directions*/
329 _assert_(dim>1);
330 _assert_(vx_input);
331 vx_input->GetInputValue(&vx,gauss);
332 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss);
333 _assert_(vy_input);
334 vy_input->GetInputValue(&vy,gauss);
335 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss);
336 if(dim==3){
337 _assert_(vz_input);
338 vz_input->GetInputValue(&vz,gauss);
339 vz_input->GetInputDerivativeValue(&dvz[0],xyz_list,gauss);
340 }
341 else{
342 vz = 0.;
343 dvz[0] = 0.; dvz[1] = 0.; dvz[2] = 0.;
344 }
345
346 /*Get enhancement factors and ko*/
347 Input* ec_input = element->inputs->GetInput(MaterialsRheologyEcEnum); _assert_(ec_input);
348 Input* es_input = element->inputs->GetInput(MaterialsRheologyEsEnum); _assert_(es_input);
349 Input* ko_input = element->inputs->GetInput(MaterialsRheologyKoEnum); _assert_(ko_input);
350 ec_input->GetInputValue(&Ec,gauss);
351 es_input->GetInputValue(&Es,gauss);
352 ko_input->GetInputValue(&ko,gauss);
353
354 /*Compute viscosity*/
355 *pviscosity=GetViscosityGeneral(ko,Ec,Es,vx,vy,vz,&dvx[0],&dvy[0],&dvz[0]);
356}
357/*}}}*/
358void Matestar::ViscosityFSDerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/
359 this->GetViscosityDerivativeEpsSquare(pmu_prime,epsilon);
360}/*}}}*/
361void Matestar::ViscosityHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/
362
363 /*Intermediaries*/
364 IssmDouble vx,vy,vz;
365 IssmDouble dvx[3],dvy[3],dvz[3];
366 IssmDouble ko,Ec,Es;
367
368 /*Get velocity derivatives in all directions*/
369 _assert_(dim==2 || dim==3);
370 _assert_(vx_input);
371 vx_input->GetInputValue(&vx,gauss);
372 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss);
373 if(dim==3){
374 _assert_(vy_input);
375 vy_input->GetInputValue(&vy,gauss);
376 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss);
377 }
378 else{
379 dvx[2] = 0.;
380 vy = 0.;
381 dvy[0] = 0.; dvy[1] = 0.; dvy[2] = 0.;
382 }
383 vz = 0.;
384 dvz[0] = 0.; dvz[1] = 0.; dvz[2] = -dvx[0]-dvy[1];
385
386 /*Get enhancement factors and ko*/
387 Input* ec_input = element->inputs->GetInput(MaterialsRheologyEcEnum); _assert_(ec_input);
388 Input* es_input = element->inputs->GetInput(MaterialsRheologyEsEnum); _assert_(es_input);
389 Input* ko_input = element->inputs->GetInput(MaterialsRheologyKoEnum); _assert_(ko_input);
390 ec_input->GetInputValue(&Ec,gauss);
391 es_input->GetInputValue(&Es,gauss);
392 ko_input->GetInputValue(&ko,gauss);
393
394 /*Compute viscosity*/
395 *pviscosity=GetViscosityGeneral(ko,Ec,Es,vx,vy,vz,&dvx[0],&dvy[0],&dvz[0]);
396}/*}}}*/
397void Matestar::ViscosityHODerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/
398 _error_("not implemented yet");
399}/*}}}*/
400void Matestar::ViscosityL1L2(IssmDouble* pviscosity,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* surface_input){/*{{{*/
401 _error_("not implemented yet");
402}/*}}}*/
403void Matestar::ViscositySSA(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){/*{{{*/
404 /*Intermediaries*/
405 IssmDouble vx,vy,vz;
406 IssmDouble dvx[3],dvy[3],dvz[3];
407 IssmDouble ko,Ec,Es;
408
409 /*Get velocity derivatives in all directions*/
410 _assert_(dim==1 || dim==2);
411 _assert_(vx_input);
412 vx_input->GetInputValue(&vx,gauss);
413 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss);
414 if(dim==2){
415 _assert_(vy_input);
416 vy_input->GetInputValue(&vy,gauss);
417 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss);
418 }
419 else{
420 dvx[1] = 0.;
421 dvx[2] = 0.;
422 vy = 0.;
423 dvy[0] = 0.; dvy[1] = 0.; dvy[2] = 0.;
424 }
425 vz = 0.;
426 dvz[0] = 0.; dvz[1] = 0.; dvz[2] = -dvx[0]-dvy[1];
427
428 /*Get enhancement factors and ko*/
429 Input* ec_input = element->inputs->GetInput(MaterialsRheologyEcbarEnum); _assert_(ec_input);
430 Input* es_input = element->inputs->GetInput(MaterialsRheologyEsbarEnum); _assert_(es_input);
431 Input* ko_input = element->inputs->GetInput(MaterialsRheologyKobarEnum); _assert_(ko_input);
432 ec_input->GetInputValue(&Ec,gauss);
433 es_input->GetInputValue(&Es,gauss);
434 ko_input->GetInputValue(&ko,gauss);
435
436 /*Compute viscosity*/
437 *pviscosity=GetViscosityGeneral(ko,Ec,Es,vx,vy,vz,&dvx[0],&dvy[0],&dvz[0]);
438}/*}}}*/
439void Matestar::ViscositySSADerivativeEpsSquare(IssmDouble* pmu_prime,IssmDouble* epsilon){/*{{{*/
440 _error_("not implemented yet");
441}/*}}}*/
Note: See TracBrowser for help on using the repository browser.