source: issm/trunk-jpl/src/c/objects/Loads/Penpair.cpp@ 12472

Last change on this file since 12472 was 12472, checked in by utke, 13 years ago

type renames

File size: 10.6 KB
Line 
1/*!\file Penpair.c
2 * \brief: implementation of the Penpair object
3 */
4
5/*Headers*/
6/*{{{*/
7#ifdef HAVE_CONFIG_H
8#include <config.h>
9#else
10#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
11#endif
12
13#include <stdio.h>
14#include <string.h>
15#include "../objects.h"
16#include "../../EnumDefinitions/EnumDefinitions.h"
17#include "../../include/include.h"
18#include "../../shared/shared.h"
19/*}}}*/
20
21/*Element macros*/
22#define NUMVERTICES 2
23
24/*Penpair constructors and destructor*/
25/*FUNCTION Penpair::constructor {{{*/
26Penpair::Penpair(){
27
28 this->hnodes=NULL;
29 this->nodes=NULL;
30 this->parameters=NULL;
31 return;
32}
33/*}}}*/
34/*FUNCTION Penpair::creation {{{*/
35Penpair::Penpair(int penpair_id, int* penpair_node_ids,int in_analysis_type){
36
37 this->id=penpair_id;
38 this->analysis_type=in_analysis_type;
39 this->hnodes=new Hook(penpair_node_ids,2);
40 this->parameters=NULL;
41 this->nodes=NULL;
42
43 return;
44}
45/*}}}*/
46/*FUNCTION Penpair::destructor {{{*/
47Penpair::~Penpair(){
48 delete hnodes;
49 return;
50}
51/*}}}*/
52
53/*Object virtual functions definitions:*/
54/*FUNCTION Penpair::Echo {{{*/
55void Penpair::Echo(void){
56
57 int i;
58
59 printf("Penpair:\n");
60 printf(" id: %i\n",id);
61 printf(" analysis_type: %s\n",EnumToStringx(analysis_type));
62 hnodes->Echo();
63
64 return;
65}
66/*}}}*/
67/*FUNCTION Penpair::DeepEcho {{{*/
68void Penpair::DeepEcho(void){
69
70 printf("Penpair:\n");
71 printf(" id: %i\n",id);
72 printf(" analysis_type: %s\n",EnumToStringx(analysis_type));
73 hnodes->DeepEcho();
74
75 return;
76}
77/*}}}*/
78/*FUNCTION Penpair::Id {{{*/
79int Penpair::Id(void){ return id; }
80/*}}}*/
81/*FUNCTION Penpair::MyRank {{{*/
82int Penpair::MyRank(void){
83 extern int my_rank;
84 return my_rank;
85}
86/*}}}*/
87/*FUNCTION Penpair::ObjectEnum{{{*/
88int Penpair::ObjectEnum(void){
89
90 return PenpairEnum;
91}
92/*}}}*/
93/*FUNCTION Penpair::copy {{{*/
94Object* Penpair::copy() {
95
96 Penpair* penpair=NULL;
97
98 penpair=new Penpair();
99
100 /*copy fields: */
101 penpair->id=this->id;
102 penpair->analysis_type=this->analysis_type;
103
104 /*now deal with hooks and objects: */
105 penpair->hnodes=(Hook*)this->hnodes->copy();
106 penpair->nodes =(Node**)penpair->hnodes->deliverp();
107
108 /*point parameters: */
109 penpair->parameters=this->parameters;
110
111 return penpair;
112
113}
114/*}}}*/
115
116/*Load virtual functions definitions:*/
117/*FUNCTION Penpair::Configure {{{*/
118void Penpair::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
119
120 /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
121 * datasets, using internal ids and offsets hidden in hooks: */
122 hnodes->configure(nodesin);
123
124 /*Initialize hooked fields*/
125 this->nodes =(Node**)hnodes->deliverp();
126
127 /*point parameters to real dataset: */
128 this->parameters=parametersin;
129
130}
131/*}}}*/
132/*FUNCTION Penpair::SetCurrentConfiguration {{{*/
133void Penpair::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
134
135}
136/*}}}*/
137/*FUNCTION Penpair::CreateKMatrix {{{*/
138void Penpair::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
139 /*If you code this piece, don't forget that a penalty will be inactive if it is dealing with clone nodes*/
140 /*No loads applied, do nothing: */
141 return;
142
143}
144/*}}}*/
145/*FUNCTION Penpair::CreatePVector {{{*/
146void Penpair::CreatePVector(Vector* pf){
147
148 /*No loads applied, do nothing: */
149 return;
150
151}
152/*}}}*/
153/*FUNCTION Penpair::CreateJacobianMatrix{{{*/
154void Penpair::CreateJacobianMatrix(Matrix* Jff){
155 this->CreateKMatrix(Jff,NULL);
156}
157/*}}}*/
158/*FUNCTION Penpair::PenaltyCreateKMatrix {{{*/
159void Penpair::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,IssmDouble kmax){
160
161 /*Retrieve parameters: */
162 ElementMatrix* Ke=NULL;
163 int analysis_type;
164 this->parameters->FindParam(&analysis_type,AnalysisTypeEnum);
165
166 switch(analysis_type){
167 case DiagnosticHorizAnalysisEnum:
168 Ke=PenaltyCreateKMatrixDiagnosticHoriz(kmax);
169 break;
170 case PrognosticAnalysisEnum:
171 Ke=PenaltyCreateKMatrixPrognostic(kmax);
172 break;
173 default:
174 _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
175 }
176
177 /*Add to global Vector*/
178 if(Ke){
179 Ke->AddToGlobal(Kff,Kfs);
180 delete Ke;
181 }
182}
183/*}}}*/
184/*FUNCTION Penpair::PenaltyCreatePVector {{{*/
185void Penpair::PenaltyCreatePVector(Vector* pf,IssmDouble kmax){
186 /*No loads applied, do nothing: */
187 return;
188}
189/*}}}*/
190/*FUNCTION Penpair::PenaltyCreateJacobianMatrix{{{*/
191void Penpair::PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax){
192 this->PenaltyCreateKMatrix(Jff,NULL,kmax);
193}
194/*}}}*/
195/*FUNCTION Penpair::InAnalysis{{{*/
196bool Penpair::InAnalysis(int in_analysis_type){
197 if (in_analysis_type==this->analysis_type)return true;
198 else return false;
199}
200/*}}}*/
201
202/*Update virtual functions definitions:*/
203/*FUNCTION Penpair::InputUpdateFromConstant(IssmDouble constant, int name) {{{*/
204void Penpair::InputUpdateFromConstant(IssmDouble constant, int name){
205 /*Nothing updated yet*/
206}
207/*}}}*/
208/*FUNCTION Penpair::InputUpdateFromConstant(int constant, int name) {{{*/
209void Penpair::InputUpdateFromConstant(int constant, int name){
210 /*Nothing updated yet*/
211}
212/*}}}*/
213/*FUNCTION Penpair::InputUpdateFromConstant(bool constant, int name) {{{*/
214void Penpair::InputUpdateFromConstant(bool constant, int name){
215 /*Nothing updated yet*/
216}
217/*}}}*/
218/*FUNCTION Penpair::InputUpdateFromVector(IssmDouble* vector, int name, int type) {{{*/
219void Penpair::InputUpdateFromVector(IssmDouble* vector, int name, int type){
220 /*Nothing updated yet*/
221}
222/*}}}*/
223/*FUNCTION Penpair::InputUpdateFromVector(int* vector, int name, int type) {{{*/
224void Penpair::InputUpdateFromVector(int* vector, int name, int type){
225 /*Nothing updated yet*/
226}
227/*}}}*/
228/*FUNCTION Penpair::InputUpdateFromVector(bool* vector, int name, int type) {{{*/
229void Penpair::InputUpdateFromVector(bool* vector, int name, int type){
230 /*Nothing updated yet*/
231}
232/*}}}*/
233
234/*Penpair management:*/
235/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticHoriz{{{*/
236ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticHoriz(IssmDouble kmax){
237
238 int approximation0=nodes[0]->GetApproximation();
239 int approximation1=nodes[1]->GetApproximation();
240
241 switch(approximation0){
242 case MacAyealApproximationEnum:
243 switch(approximation1){
244 case MacAyealApproximationEnum: return PenaltyCreateKMatrixDiagnosticMacAyealPattyn(kmax);
245 case PattynApproximationEnum: return PenaltyCreateKMatrixDiagnosticMacAyealPattyn(kmax);
246 default: _error_("not supported yet");
247 }
248 case PattynApproximationEnum:
249 switch(approximation1){
250 case MacAyealApproximationEnum: return PenaltyCreateKMatrixDiagnosticMacAyealPattyn(kmax);
251 case PattynApproximationEnum: return PenaltyCreateKMatrixDiagnosticMacAyealPattyn(kmax);
252 default: _error_("not supported yet");
253 }
254 case StokesApproximationEnum:
255 switch(approximation1){
256 case StokesApproximationEnum: return PenaltyCreateKMatrixDiagnosticStokes(kmax);
257 case NoneApproximationEnum: return PenaltyCreateKMatrixDiagnosticStokes(kmax);
258 default: _error_("not supported yet");
259 }
260 case NoneApproximationEnum:
261 switch(approximation1){
262 case StokesApproximationEnum: return PenaltyCreateKMatrixDiagnosticStokes(kmax);
263 case NoneApproximationEnum: return PenaltyCreateKMatrixDiagnosticStokes(kmax);
264 default: _error_("not supported yet");
265 }
266 default: _error_("not supported yet");
267 }
268}
269/*}}}*/
270/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn {{{*/
271ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn(IssmDouble kmax){
272
273 const int numdof=NUMVERTICES*NDOF2;
274 IssmDouble penalty_offset;
275
276 /*Initialize Element vector and return if necessary*/
277 ElementMatrix* Ke=new ElementMatrix(nodes,NUMVERTICES,this->parameters);
278
279 /*recover parameters: */
280 parameters->FindParam(&penalty_offset,DiagnosticPenaltyFactorEnum);
281
282 //Create elementary matrix: add penalty to
283 Ke->values[0*numdof+0]=+kmax*pow((IssmDouble)10.0,penalty_offset);
284 Ke->values[0*numdof+2]=-kmax*pow((IssmDouble)10.0,penalty_offset);
285 Ke->values[2*numdof+0]=-kmax*pow((IssmDouble)10.0,penalty_offset);
286 Ke->values[2*numdof+2]=+kmax*pow((IssmDouble)10.0,penalty_offset);
287
288 Ke->values[1*numdof+1]=+kmax*pow((IssmDouble)10.0,penalty_offset);
289 Ke->values[1*numdof+3]=-kmax*pow((IssmDouble)10.0,penalty_offset);
290 Ke->values[3*numdof+1]=-kmax*pow((IssmDouble)10.0,penalty_offset);
291 Ke->values[3*numdof+3]=+kmax*pow((IssmDouble)10.0,penalty_offset);
292
293 /*Clean up and return*/
294 return Ke;
295}
296/*}}}*/
297/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticStokes {{{*/
298ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax){
299
300 const int numdof=NUMVERTICES*NDOF4;
301 IssmDouble penalty_offset;
302
303 /*Initialize Element vector and return if necessary*/
304 ElementMatrix* Ke=new ElementMatrix(nodes,NUMVERTICES,this->parameters);
305
306 /*recover parameters: */
307 parameters->FindParam(&penalty_offset,DiagnosticPenaltyFactorEnum);
308
309 //Create elementary matrix: add penalty to
310 Ke->values[0*numdof+0]=+kmax*pow((IssmDouble)10.0,penalty_offset);
311 Ke->values[0*numdof+4]=-kmax*pow((IssmDouble)10.0,penalty_offset);
312 Ke->values[4*numdof+0]=-kmax*pow((IssmDouble)10.0,penalty_offset);
313 Ke->values[4*numdof+4]=+kmax*pow((IssmDouble)10.0,penalty_offset);
314
315 Ke->values[1*numdof+1]=+kmax*pow((IssmDouble)10.0,penalty_offset);
316 Ke->values[1*numdof+5]=-kmax*pow((IssmDouble)10.0,penalty_offset);
317 Ke->values[5*numdof+1]=-kmax*pow((IssmDouble)10.0,penalty_offset);
318 Ke->values[5*numdof+5]=+kmax*pow((IssmDouble)10.0,penalty_offset);
319
320 Ke->values[2*numdof+2]=+kmax*pow((IssmDouble)10.0,penalty_offset);
321 Ke->values[2*numdof+6]=-kmax*pow((IssmDouble)10.0,penalty_offset);
322 Ke->values[6*numdof+2]=-kmax*pow((IssmDouble)10.0,penalty_offset);
323 Ke->values[6*numdof+6]=+kmax*pow((IssmDouble)10.0,penalty_offset);
324
325 Ke->values[3*numdof+3]=+kmax*pow((IssmDouble)10.0,penalty_offset);
326 Ke->values[3*numdof+7]=-kmax*pow((IssmDouble)10.0,penalty_offset);
327 Ke->values[7*numdof+3]=-kmax*pow((IssmDouble)10.0,penalty_offset);
328 Ke->values[7*numdof+7]=+kmax*pow((IssmDouble)10.0,penalty_offset);
329
330 /*Clean up and return*/
331 return Ke;
332}
333/*}}}*/
334/*FUNCTION Penpair::PenaltyCreateKMatrixPrognostic {{{*/
335ElementMatrix* Penpair::PenaltyCreateKMatrixPrognostic(IssmDouble kmax){
336
337 const int numdof=NUMVERTICES*NDOF1;
338 IssmDouble penalty_factor;
339
340 /*Initialize Element vector and return if necessary*/
341 ElementMatrix* Ke=new ElementMatrix(nodes,NUMVERTICES,this->parameters);
342
343 /*recover parameters: */
344 parameters->FindParam(&penalty_factor,PrognosticPenaltyFactorEnum);
345
346 //Create elementary matrix: add penalty to
347 Ke->values[0*numdof+0]=+kmax*pow((IssmDouble)10.0,penalty_factor);
348 Ke->values[0*numdof+1]=-kmax*pow((IssmDouble)10.0,penalty_factor);
349 Ke->values[1*numdof+0]=-kmax*pow((IssmDouble)10.0,penalty_factor);
350 Ke->values[1*numdof+1]=+kmax*pow((IssmDouble)10.0,penalty_factor);
351
352 /*Clean up and return*/
353 return Ke;
354}
355/*}}}*/
Note: See TracBrowser for help on using the repository browser.