Changeset 17472
- Timestamp:
- 03/18/14 22:44:50 (11 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 2 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Makefile.am
r17457 r17472 446 446 ./classes/Inputs/PentaInput.h\ 447 447 ./classes/Inputs/PentaInput.cpp\ 448 ./classes/Inputs/TetraInput.h\ 449 ./classes/Inputs/TetraInput.cpp\ 448 450 #}}} 449 451 #DAKOTA sources {{{ -
issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp
r17463 r17472 20 20 switch(meshtype){ 21 21 case Mesh3DEnum: numdofs=2; break; 22 case Mesh3DtetrasEnum: numdofs=2; break; 22 23 case Mesh2DhorizontalEnum: numdofs=2; break; 23 24 case Mesh2DverticalEnum: numdofs=1; break; … … 29 30 switch(meshtype){ 30 31 case Mesh3DEnum: numdofs=2; break; 32 case Mesh3DtetrasEnum: numdofs=2; break; 31 33 case Mesh2DverticalEnum: numdofs=1; break; 32 34 default: _error_("mesh type not supported yet"); … … 37 39 switch(meshtype){ 38 40 case Mesh3DEnum: numdofs=3; break; 41 case Mesh3DtetrasEnum: numdofs=3; break; 39 42 case Mesh2DverticalEnum: numdofs=2; break; 40 43 default: _error_("mesh type not supported yet"); … … 45 48 switch(meshtype){ 46 49 case Mesh3DEnum: numdofs=4; break; 50 case Mesh3DtetrasEnum: numdofs=4; break; 47 51 case Mesh2DverticalEnum: numdofs=3; break; 48 52 default: _error_("mesh type not supported yet"); … … 215 219 if(dakota_analysis)elements->InputDuplicate(VzEnum,QmuVzEnum); 216 220 } 221 if(iomodel->meshtype==Mesh3DtetrasEnum){ 222 iomodel->FetchDataToInput(elements,MeshVertexonbedEnum); 223 iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum); 224 iomodel->FetchDataToInput(elements,BasalforcingsMeltingRateEnum); 225 iomodel->FetchDataToInput(elements,LoadingforceZEnum); 226 iomodel->FetchDataToInput(elements,VzEnum,0.); 227 if(dakota_analysis)elements->InputDuplicate(VzEnum,QmuVzEnum); 228 } 217 229 if(iomodel->meshtype==Mesh2DverticalEnum){ 218 230 iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum); 219 231 } 220 232 if(isFS){ … … 963 975 case Mesh2DverticalEnum: dim = 2; dofpernode = 1; break; 964 976 case Mesh3DEnum: dim = 3; dofpernode = 2; break; 977 case Mesh3DtetrasEnum: dim = 3; dofpernode = 2; break; 965 978 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 966 979 } … … 1180 1193 case Mesh2DhorizontalEnum: dim = 2;break; 1181 1194 case Mesh3DEnum: dim = 2;break; 1195 case Mesh3DtetrasEnum: dim = 2;break; 1182 1196 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 1183 1197 } … … 1265 1279 case Mesh2DhorizontalEnum: dim = 2; bsize = 3; break; 1266 1280 case Mesh3DEnum: dim = 2; bsize = 3; break; 1281 case Mesh3DtetrasEnum: dim = 2; bsize = 3; break; 1267 1282 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 1268 1283 } … … 1377 1392 case Mesh2DhorizontalEnum: dim = 2;break; 1378 1393 case Mesh3DEnum: dim = 2;break; 1394 case Mesh3DtetrasEnum: dim = 2;break; 1379 1395 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 1380 1396 } … … 1442 1458 case Mesh2DhorizontalEnum: dim = 2;break; 1443 1459 case Mesh3DEnum: dim = 2;break; 1460 case Mesh3DtetrasEnum: dim = 2;break; 1444 1461 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 1445 1462 } … … 2140 2157 case Mesh2DverticalEnum: dim = 2; bsize = 2; break; 2141 2158 case Mesh3DEnum: dim = 3; bsize = 5; break; 2159 case Mesh3DtetrasEnum: dim = 3; bsize = 5; break; 2142 2160 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 2143 2161 } … … 2219 2237 case Mesh2DverticalEnum: dim = 2; break; 2220 2238 case Mesh3DEnum: dim = 3; break; 2239 case Mesh3DtetrasEnum: dim = 3; break; 2221 2240 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 2222 2241 } … … 2304 2323 case Mesh2DverticalEnum: dim = 2; break; 2305 2324 case Mesh3DEnum: dim = 3; break; 2325 case Mesh3DtetrasEnum: dim = 3; break; 2306 2326 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 2307 2327 } … … 2380 2400 case Mesh2DverticalEnum: dim = 2; break; 2381 2401 case Mesh3DEnum: dim = 3; break; 2402 case Mesh3DtetrasEnum: dim = 3; break; 2382 2403 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 2383 2404 } … … 2441 2462 case Mesh2DverticalEnum: dim = 2; break; 2442 2463 case Mesh3DEnum: dim = 3; break; 2464 case Mesh3DtetrasEnum: dim = 3; break; 2443 2465 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 2444 2466 } … … 2639 2661 case Mesh2DverticalEnum: dim = 2; break; 2640 2662 case Mesh3DEnum: dim = 3; break; 2663 case Mesh3DtetrasEnum: dim = 3; break; 2641 2664 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 2642 2665 } … … 2726 2749 case Mesh2DverticalEnum: dim = 2; break; 2727 2750 case Mesh3DEnum: dim = 3; break; 2751 case Mesh3DtetrasEnum: dim = 3; break; 2728 2752 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 2729 2753 } … … 2857 2881 case Mesh2DverticalEnum: dim = 2; epssize = 3; break; 2858 2882 case Mesh3DEnum: dim = 3; epssize = 6; break; 2883 case Mesh3DtetrasEnum: dim = 3; epssize = 6; break; 2859 2884 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 2860 2885 } … … 2940 2965 case Mesh2DverticalEnum: dim = 2;break; 2941 2966 case Mesh3DEnum: dim = 3;break; 2967 case Mesh3DtetrasEnum: dim = 3;break; 2942 2968 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 2943 2969 } … … 3034 3060 case Mesh2DverticalEnum: dim = 2;break; 3035 3061 case Mesh3DEnum: dim = 3;break; 3062 case Mesh3DtetrasEnum: dim = 3;break; 3036 3063 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 3037 3064 } … … 3092 3119 element->FindParam(&meshtype,MeshTypeEnum); 3093 3120 switch(meshtype){ 3121 case Mesh2DverticalEnum: dim = 2; break; 3094 3122 case Mesh3DEnum: dim = 3; break; 3095 case Mesh 2DverticalEnum: dim = 2; break;3123 case Mesh3DtetrasEnum: dim = 3; break; 3096 3124 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 3097 3125 } … … 3176 3204 case Mesh2DverticalEnum: dim = 2; break; 3177 3205 case Mesh3DEnum: dim = 3; break; 3206 case Mesh3DtetrasEnum: dim = 3; break; 3178 3207 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 3179 3208 } … … 3254 3283 case Mesh2DverticalEnum: dim = 2; break; 3255 3284 case Mesh3DEnum: dim = 3; break; 3285 case Mesh3DtetrasEnum: dim = 3; break; 3256 3286 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 3257 3287 } … … 3330 3360 case Mesh2DverticalEnum: dim = 2; break; 3331 3361 case Mesh3DEnum: dim = 3; break; 3362 case Mesh3DtetrasEnum: dim = 3; break; 3332 3363 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 3333 3364 } … … 3682 3713 case Mesh2DverticalEnum: dim = 2; break; 3683 3714 case Mesh3DEnum: dim = 3; break; 3715 case Mesh3DtetrasEnum: dim = 3; break; 3684 3716 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 3685 3717 } … … 3749 3781 case Mesh2DverticalEnum: dim = 2; break; 3750 3782 case Mesh3DEnum: dim = 3; break; 3783 case Mesh3DtetrasEnum: dim = 3; break; 3751 3784 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 3752 3785 } -
issm/trunk-jpl/src/c/classes/Elements/Element.cpp
r17394 r17472 429 429 430 430 }/*}}}*/ 431 void Element::GetNodesSidList(int* sidlist){/*{{{*/ 432 433 _assert_(sidlist); 434 _assert_(nodes); 435 int numnodes = this->GetNumberOfNodes(); 436 for(int i=0;i<numnodes;i++){ 437 sidlist[i]=nodes[i]->Sid(); 438 } 439 } 440 /*}}}*/ 441 void Element::GetNodesLidList(int* lidlist){/*{{{*/ 442 443 _assert_(lidlist); 444 _assert_(nodes); 445 int numnodes = this->GetNumberOfNodes(); 446 for(int i=0;i<numnodes;i++){ 447 lidlist[i]=nodes[i]->Lid(); 448 } 449 } 450 /*}}}*/ 451 void Element::GetVerticesCoordinates(IssmDouble** pxyz_list){/*{{{*/ 452 453 int numvertices = this->GetNumberOfVertices(); 454 IssmDouble* xyz_list = xNew<IssmDouble>(numvertices*3); 455 ::GetVerticesCoordinates(xyz_list,this->vertices,numvertices); 456 457 *pxyz_list = xyz_list; 458 459 }/*}}}*/ 431 460 void Element::GetVerticesSidList(int* sidlist){/*{{{*/ 432 461 … … 439 468 int numvertices = this->GetNumberOfVertices(); 440 469 for(int i=0;i<numvertices;i++) connectivity[i]=this->vertices[i]->Connectivity(); 470 } 471 /*}}}*/ 472 void Element::InputChangeName(int original_enum,int new_enum){/*{{{*/ 473 this->inputs->ChangeEnum(original_enum,new_enum); 474 } 475 /*}}}*/ 476 void Element::InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){/*{{{*/ 477 478 /*Intermediaries*/ 479 int i,t,row; 480 IssmDouble time; 481 482 /*Branch on type of vector: nodal or elementary: */ 483 if(vector_type==1){ //nodal vector 484 485 int numvertices = this->GetNumberOfVertices(); 486 int *vertexids = xNew<int>(numvertices); 487 IssmDouble *values = xNew<IssmDouble>(numvertices); 488 489 /*Recover vertices ids needed to initialize inputs*/ 490 _assert_(iomodel->elements); 491 for(i=0;i<numvertices;i++){ 492 vertexids[i]=reCast<int>(iomodel->elements[numvertices*this->Sid()+i]); //ids for vertices are in the elements array from Matlab 493 } 494 495 /*Are we in transient or static? */ 496 if(M==iomodel->numberofvertices){ 497 for(i=0;i<numvertices;i++) values[i]=vector[vertexids[i]-1]; 498 this->AddInput(vector_enum,values,P1Enum); 499 } 500 else if(M==iomodel->numberofvertices+1){ 501 /*create transient input: */ 502 IssmDouble* times = xNew<IssmDouble>(N); 503 for(t=0;t<N;t++) times[t] = vector[(M-1)*N+t]; 504 TransientInput* transientinput=new TransientInput(vector_enum,times,N); 505 for(t=0;t<N;t++){ 506 for(i=0;i<numvertices;i++) values[i]=vector[N*(vertexids[i]-1)+t]; 507 switch(this->ObjectEnum()){ 508 case TriaEnum: transientinput->AddTimeInput(new TriaInput( vector_enum,values,P1Enum)); break; 509 case PentaEnum: transientinput->AddTimeInput(new PentaInput(vector_enum,values,P1Enum)); break; 510 case TetraEnum: transientinput->AddTimeInput(new TetraInput(vector_enum,values,P1Enum)); break; 511 default: _error_("Not implemented yet"); 512 } 513 } 514 this->inputs->AddInput(transientinput); 515 xDelete<IssmDouble>(times); 516 } 517 else _error_("nodal vector is either numberofvertices or numberofvertices+1 long. Field provided (" << EnumToStringx(vector_enum) << ") is " << M << " long"); 518 519 xDelete<IssmDouble>(values); 520 xDelete<int>(vertexids); 521 } 522 else if(vector_type==2){ //element vector 523 /*Are we in transient or static? */ 524 if(M==iomodel->numberofelements){ 525 if (code==5){ //boolean 526 this->inputs->AddInput(new BoolInput(vector_enum,reCast<bool>(vector[this->Sid()]))); 527 } 528 else if (code==6){ //integer 529 this->inputs->AddInput(new IntInput(vector_enum,reCast<int>(vector[this->Sid()]))); 530 } 531 else if (code==7){ //IssmDouble 532 this->inputs->AddInput(new DoubleInput(vector_enum,vector[this->Sid()])); 533 } 534 else _error_("could not recognize nature of vector from code " << code); 535 } 536 else { 537 _error_("transient element inputs not supported yet!"); 538 } 539 } 540 else{ 541 _error_("Cannot add input for vector type " << vector_type << " (not supported)"); 542 } 543 }/*}}}*/ 544 void Element::InputUpdateFromConstant(int constant, int name){/*{{{*/ 545 546 /*Check that name is an element input*/ 547 if(!IsInput(name)) return; 548 549 /*update input*/ 550 this->inputs->AddInput(new IntInput(name,constant)); 551 } 552 /*}}}*/ 553 void Element::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/ 554 555 /*Check that name is an element input*/ 556 if(!IsInput(name)) return; 557 558 /*update input*/ 559 this->inputs->AddInput(new DoubleInput(name,constant)); 560 } 561 /*}}}*/ 562 void Element::InputUpdateFromConstant(bool constant, int name){/*{{{*/ 563 564 /*Check that name is an element input*/ 565 if(!IsInput(name)) return; 566 567 /*update input*/ 568 this->inputs->AddInput(new BoolInput(name,constant)); 441 569 } 442 570 /*}}}*/ … … 535 663 } 536 664 /*}}}*/ 665 ElementVector* Element::NewElementVector(int approximation_enum){/*{{{*/ 666 return new ElementVector(nodes,this->GetNumberOfNodes(),this->parameters,approximation_enum); 667 } 668 /*}}}*/ 669 ElementMatrix* Element::NewElementMatrix(int approximation_enum){/*{{{*/ 670 return new ElementMatrix(nodes,this->GetNumberOfNodes(),this->parameters,approximation_enum); 671 } 672 /*}}}*/ 673 ElementMatrix* Element::NewElementMatrixCoupling(int number_nodes,int approximation_enum){/*{{{*/ 674 return new ElementMatrix(nodes,number_nodes,this->parameters,approximation_enum); 675 } 676 /*}}}*/ 537 677 void Element::ResultInterpolation(int* pinterpolation,int* pnodesperelement,int output_enum){/*{{{*/ 538 678 -
issm/trunk-jpl/src/c/classes/Elements/Element.h
r17394 r17472 75 75 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,int enum_type); 76 76 IssmDouble GetMaterialParameter(int enum_in); 77 void GetNodesSidList(int* sidlist); 78 void GetNodesLidList(int* lidlist); 77 79 void GetPhi(IssmDouble* phi, IssmDouble* epsilon, IssmDouble viscosity); 80 void GetVerticesCoordinates(IssmDouble** xyz_list); 78 81 void GetVerticesSidList(int* sidlist); 79 82 void GetVerticesConnectivityList(int* connectivitylist); 83 void InputChangeName(int enum_type,int enum_type_old); 84 void InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code); 85 void InputUpdateFromConstant(IssmDouble constant, int name); 86 void InputUpdateFromConstant(int constant, int name); 87 void InputUpdateFromConstant(bool constant, int name); 80 88 bool IsInput(int name); 81 89 bool IsFloating(); 90 ElementVector* NewElementVector(int approximation_enum=NoneApproximationEnum); 91 ElementMatrix* NewElementMatrix(int approximation_enum=NoneApproximationEnum); 92 ElementMatrix* NewElementMatrixCoupling(int number_nodes,int approximation_enum=NoneApproximationEnum); 82 93 void ResultInterpolation(int* pinterpolation,int*nodesperelement,int output_enum); 83 94 void ResultToVector(Vector<IssmDouble>* vector,int output_enum); … … 161 172 virtual int GetNumberOfNodesPressure(void)=0; 162 173 virtual int GetNumberOfVertices(void)=0; 163 virtual void GetNodesSidList(int* sidlist)=0;164 virtual void GetNodesLidList(int* sidlist)=0;165 174 166 175 virtual int Id()=0; … … 174 183 virtual void GetInputValue(IssmDouble* pvalue,Node* node,int enumtype)=0; 175 184 virtual Node* GetNode(int node_number)=0; 176 virtual void GetVerticesCoordinates(IssmDouble** xyz_list)=0;177 185 virtual void GetVerticesCoordinatesBase(IssmDouble** xyz_list)=0; 178 186 virtual void GetVerticesCoordinatesTop(IssmDouble** xyz_list)=0; … … 184 192 virtual IssmDouble SurfaceArea(void)=0; 185 193 virtual void InputDepthAverageAtBase(int enum_type,int average_enum_type)=0; 186 virtual void InputChangeName(int enum_type,int enum_type_old)=0;187 194 virtual void ComputeBasalStress(Vector<IssmDouble>* sigma_b)=0; 188 195 virtual void ComputeStrainRate(Vector<IssmDouble>* eps)=0; … … 191 198 virtual void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finite_element)=0; 192 199 virtual void InputDuplicate(int original_enum,int new_enum)=0; 193 virtual void InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code)=0;194 200 virtual void InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solution,int inputenum)=0; 195 201 virtual void InputUpdateFromSolutionOneDof(IssmDouble* solution,int inputenum)=0; … … 206 212 virtual Gauss* NewGaussLine(int vertex1,int vertex2,int order)=0; 207 213 virtual Gauss* NewGaussTop(int order)=0; 208 virtual ElementVector* NewElementVector(int approximation_enum=NoneApproximationEnum)=0; 209 virtual ElementMatrix* NewElementMatrix(int approximation_enum=NoneApproximationEnum)=0; 210 virtual ElementMatrix* NewElementMatrixCoupling(int number_nodes,int approximation_enum=NoneApproximationEnum)=0; 214 211 215 virtual void InputScale(int enum_type,IssmDouble scale_factor)=0; 212 216 virtual void GetVectorFromInputs(Vector<IssmDouble>* vector, int name_enum)=0; -
issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
r17463 r17472 28 28 Penta::Penta(int penta_id, int penta_sid, int index, IoModel* iomodel,int nummodels) 29 29 :PentaRef(nummodels) 30 ,ElementHook(nummodels,index+1, 6,iomodel){30 ,ElementHook(nummodels,index+1,NUMVERTICES,iomodel){ 31 31 32 32 int penta_elements_ids[2]; … … 843 843 } 844 844 /*}}}*/ 845 /*FUNCTION Penta::GetNodesSidList{{{*/846 void Penta::GetNodesSidList(int* sidlist){847 848 _assert_(sidlist);849 _assert_(nodes);850 int numnodes = this->NumberofNodes();851 852 for(int i=0;i<numnodes;i++){853 sidlist[i]=nodes[i]->Sid();854 }855 }856 /*}}}*/857 /*FUNCTION Penta::GetNodesLidList{{{*/858 void Penta::GetNodesLidList(int* lidlist){859 860 _assert_(lidlist);861 _assert_(nodes);862 int numnodes = this->NumberofNodes();863 864 for(int i=0;i<numnodes;i++){865 lidlist[i]=nodes[i]->Lid();866 }867 }868 /*}}}*/869 845 /*FUNCTION Penta::GetNumberOfNodes;{{{*/ 870 846 int Penta::GetNumberOfNodes(void){ … … 907 883 } 908 884 /*}}}*/ 909 /*FUNCTION Penta::GetVerticesCoordinates(IssmDouble** pxyz_list){{{*/910 void Penta::GetVerticesCoordinates(IssmDouble** pxyz_list){911 912 IssmDouble* xyz_list = xNew<IssmDouble>(NUMVERTICES*3);913 ::GetVerticesCoordinates(xyz_list,this->vertices,NUMVERTICES);914 915 /*Assign output pointer*/916 *pxyz_list = xyz_list;917 918 }/*}}}*/919 885 /*FUNCTION Penta::GetVerticesCoordinatesBase(IssmDouble** pxyz_list){{{*/ 920 886 void Penta::GetVerticesCoordinatesBase(IssmDouble** pxyz_list){ … … 953 919 954 920 cross(normal,AB,AC); 955 norm=sqrt( pow(normal[0],2.0)+pow(normal[1],2.0)+pow(normal[2],2.0));921 norm=sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); 956 922 957 923 for(int i=0;i<3;i++) normal[i]=normal[i]/norm; … … 1206 1172 int Penta::Id(void){ 1207 1173 return id; 1208 }1209 /*}}}*/1210 /*FUNCTION Penta::InputChangeName{{{*/1211 void Penta::InputChangeName(int original_enum,int new_enum){1212 1213 /*Call inputs method*/1214 this->inputs->ChangeEnum(original_enum,new_enum);1215 }1216 /*}}}*/1217 /*FUNCTION Penta::InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){{{*/1218 void Penta::InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){1219 1220 /*Intermediaries*/1221 int i,t;1222 int penta_vertex_ids[6];1223 int row;1224 IssmDouble nodeinputs[6];1225 IssmDouble time;1226 TransientInput *transientinput = NULL;1227 1228 /*Branch on type of vector: nodal or elementary: */1229 if(vector_type==1){ //nodal vector1230 1231 /*Recover vertices ids needed to initialize inputs*/1232 for(i=0;i<6;i++){1233 _assert_(iomodel->elements);1234 penta_vertex_ids[i]=iomodel->elements[6*this->sid+i]; //ids for vertices are in the elements array from Matlab1235 }1236 1237 /*Are we in transient or static? */1238 if(M==iomodel->numberofvertices){1239 1240 /*create input values: */1241 for(i=0;i<6;i++)nodeinputs[i]=(IssmDouble)vector[penta_vertex_ids[i]-1];1242 1243 /*create static input: */1244 this->inputs->AddInput(new PentaInput(vector_enum,nodeinputs,P1Enum));1245 }1246 else if(M==iomodel->numberofvertices+1){1247 /*create transient input: */1248 IssmDouble* times = xNew<IssmDouble>(N);1249 for(t=0;t<N;t++) times[t] = vector[(M-1)*N+t];1250 transientinput=new TransientInput(vector_enum,times,N);1251 for(t=0;t<N;t++){1252 for(i=0;i<NUMVERTICES;i++) nodeinputs[i]=vector[N*(penta_vertex_ids[i]-1)+t];1253 transientinput->AddTimeInput(new PentaInput(vector_enum,nodeinputs,P1Enum));1254 }1255 this->inputs->AddInput(transientinput);1256 xDelete<IssmDouble>(times);1257 }1258 else _error_("nodal vector is either numberofvertices (" << iomodel->numberofvertices << "), or numberofvertices+1 long. Field provided is " << M << " long. Enum " << EnumToStringx(vector_enum));1259 }1260 else if(vector_type==2){ //element vector1261 /*Are we in transient or static? */1262 if(M==iomodel->numberofelements){1263 1264 /*static mode: create an input out of the element value: */1265 1266 if (code==5){ //boolean1267 this->inputs->AddInput(new BoolInput(vector_enum,reCast<bool,IssmDouble>(vector[this->sid])));1268 }1269 else if (code==6){ //integer1270 this->inputs->AddInput(new IntInput(vector_enum,reCast<int,IssmDouble>(vector[this->sid])));1271 }1272 else if (code==7){ //IssmDouble1273 this->inputs->AddInput(new DoubleInput(vector_enum,vector[this->sid]));1274 }1275 else _error_("could not recognize nature of vector from code " << code);1276 }1277 else {1278 _error_("transient elementary inputs not supported yet!");1279 }1280 }1281 else{1282 _error_("Cannot add input for vector type " << vector_type << " (not supported)");1283 }1284 1285 1174 } 1286 1175 /*}}}*/ … … 1452 1341 } 1453 1342 /*}}}*/ 1454 /*FUNCTION Penta::InputUpdateFromConstant(bool value, int name);{{{*/1455 void Penta::InputUpdateFromConstant(bool constant, int name){1456 1457 /*Check that name is an element input*/1458 if (!IsInput(name)) return;1459 1460 /*update input*/1461 this->inputs->AddInput(new BoolInput(name,constant));1462 }1463 /*}}}*/1464 /*FUNCTION Penta::InputUpdateFromConstant(IssmDouble value, int name);{{{*/1465 void Penta::InputUpdateFromConstant(IssmDouble constant, int name){1466 /*Check that name is an element input*/1467 if (!IsInput(name)) return;1468 1469 /*update input*/1470 this->inputs->AddInput(new DoubleInput(name,constant));1471 }1472 /*}}}*/1473 /*FUNCTION Penta::InputUpdateFromConstant(int value, int name);{{{*/1474 void Penta::InputUpdateFromConstant(int constant, int name){1475 /*Check that name is an element input*/1476 if (!IsInput(name)) return;1477 1478 /*update input*/1479 this->inputs->AddInput(new IntInput(name,constant));1480 }1481 /*}}}*/1482 1343 /*FUNCTION Penta::InputUpdateFromIoModel {{{*/ 1483 1344 void Penta::InputUpdateFromIoModel(int index,IoModel* iomodel){ 1484 1345 1485 1346 /*Intermediaries*/ 1486 IssmInti,j;1487 int penta_vertex_ids[6];1488 IssmDouble nodeinputs[ 6];1489 IssmDouble cmmininputs[ 6];1490 IssmDouble cmmaxinputs[ 6];1347 int i,j; 1348 int penta_vertex_ids[NUMVERTICES]; 1349 IssmDouble nodeinputs[NUMVERTICES]; 1350 IssmDouble cmmininputs[NUMVERTICES]; 1351 IssmDouble cmmaxinputs[NUMVERTICES]; 1491 1352 1492 1353 IssmDouble yts; … … 1500 1361 if(control_analysis) iomodel->Constant(&num_responses,InversionNumCostFunctionsEnum); 1501 1362 1502 /*Checks if debuging*/ 1503 /*{{{*/ 1363 /*Recover vertices ids needed to initialize inputs*/ 1504 1364 _assert_(iomodel->elements); 1505 /*}}}*/ 1506 1507 /*Recover vertices ids needed to initialize inputs*/ 1508 for(i=0;i<6;i++){ 1509 penta_vertex_ids[i]=iomodel->elements[6*index+i]; //ids for vertices are in the elements array from Matlab 1365 for(i=0;i<NUMVERTICES;i++){ 1366 penta_vertex_ids[i]=iomodel->elements[NUMVERTICES*index+i]; //ids for vertices are in the elements array from Matlab 1510 1367 } 1511 1368 … … 1516 1373 case BalancethicknessThickeningRateEnum: 1517 1374 if (iomodel->Data(BalancethicknessThickeningRateEnum)){ 1518 for(j=0;j< 6;j++)nodeinputs[j]=iomodel->Data(BalancethicknessThickeningRateEnum)[penta_vertex_ids[j]-1]/yts;1519 for(j=0;j< 6;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts;1520 for(j=0;j< 6;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts;1375 for(j=0;j<NUMVERTICES;j++)nodeinputs[j]=iomodel->Data(BalancethicknessThickeningRateEnum)[penta_vertex_ids[j]-1]/yts; 1376 for(j=0;j<NUMVERTICES;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts; 1377 for(j=0;j<NUMVERTICES;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts; 1521 1378 this->inputs->AddInput(new ControlInput(BalancethicknessThickeningRateEnum,PentaInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 1522 1379 } … … 1524 1381 case VxEnum: 1525 1382 if (iomodel->Data(VxEnum)){ 1526 for(j=0;j< 6;j++)nodeinputs[j]=iomodel->Data(VxEnum)[penta_vertex_ids[j]-1]/yts;1527 for(j=0;j< 6;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts;1528 for(j=0;j< 6;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts;1383 for(j=0;j<NUMVERTICES;j++)nodeinputs[j]=iomodel->Data(VxEnum)[penta_vertex_ids[j]-1]/yts; 1384 for(j=0;j<NUMVERTICES;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts; 1385 for(j=0;j<NUMVERTICES;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts; 1529 1386 this->inputs->AddInput(new ControlInput(VxEnum,PentaInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 1530 1387 } … … 1532 1389 case VyEnum: 1533 1390 if (iomodel->Data(VyEnum)){ 1534 for(j=0;j< 6;j++)nodeinputs[j]=iomodel->Data(VyEnum)[penta_vertex_ids[j]-1]/yts;1535 for(j=0;j< 6;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts;1536 for(j=0;j< 6;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts;1391 for(j=0;j<NUMVERTICES;j++)nodeinputs[j]=iomodel->Data(VyEnum)[penta_vertex_ids[j]-1]/yts; 1392 for(j=0;j<NUMVERTICES;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts; 1393 for(j=0;j<NUMVERTICES;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]/yts; 1537 1394 this->inputs->AddInput(new ControlInput(VyEnum,PentaInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 1538 1395 } … … 1540 1397 case FrictionCoefficientEnum: 1541 1398 if (iomodel->Data(FrictionCoefficientEnum)){ 1542 for(j=0;j< 6;j++)nodeinputs[j]=iomodel->Data(FrictionCoefficientEnum)[penta_vertex_ids[j]-1];1543 for(j=0;j< 6;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i];1544 for(j=0;j< 6;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i];1399 for(j=0;j<NUMVERTICES;j++)nodeinputs[j]=iomodel->Data(FrictionCoefficientEnum)[penta_vertex_ids[j]-1]; 1400 for(j=0;j<NUMVERTICES;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]; 1401 for(j=0;j<NUMVERTICES;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]; 1545 1402 this->inputs->AddInput(new ControlInput(FrictionCoefficientEnum,PentaInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 1546 1403 } … … 1548 1405 case MaterialsRheologyBbarEnum: 1549 1406 if(iomodel->Data(MaterialsRheologyBEnum)){ 1550 for(j=0;j< 6;j++) nodeinputs[j]=iomodel->Data(MaterialsRheologyBEnum)[penta_vertex_ids[j]-1];1551 for(j=0;j< 6;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i];1552 for(j=0;j< 6;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i];1407 for(j=0;j<NUMVERTICES;j++) nodeinputs[j]=iomodel->Data(MaterialsRheologyBEnum)[penta_vertex_ids[j]-1]; 1408 for(j=0;j<NUMVERTICES;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]; 1409 for(j=0;j<NUMVERTICES;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]; 1553 1410 this->inputs->AddInput(new ControlInput(MaterialsRheologyBEnum,PentaInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 1554 1411 } … … 1556 1413 case DamageDbarEnum: 1557 1414 if(iomodel->Data(DamageDEnum)){ 1558 for(j=0;j< 6;j++) nodeinputs[j]=iomodel->Data(DamageDEnum)[penta_vertex_ids[j]-1];1559 for(j=0;j< 6;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i];1560 for(j=0;j< 6;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i];1415 for(j=0;j<NUMVERTICES;j++) nodeinputs[j]=iomodel->Data(DamageDEnum)[penta_vertex_ids[j]-1]; 1416 for(j=0;j<NUMVERTICES;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]; 1417 for(j=0;j<NUMVERTICES;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(penta_vertex_ids[j]-1)*num_control_type+i]; 1561 1418 this->inputs->AddInput(new ControlInput(DamageDEnum,PentaInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 1562 1419 } … … 1579 1436 DatasetInput* datasetinput=new DatasetInput(InversionCostFunctionsCoefficientsEnum); 1580 1437 for(i=0;i<num_responses;i++){ 1581 for(j=0;j< 6;j++)nodeinputs[j]=iomodel->Data(InversionCostFunctionsCoefficientsEnum)[(penta_vertex_ids[j]-1)*num_responses+i];1438 for(j=0;j<NUMVERTICES;j++)nodeinputs[j]=iomodel->Data(InversionCostFunctionsCoefficientsEnum)[(penta_vertex_ids[j]-1)*num_responses+i]; 1582 1439 datasetinput->AddInput(new PentaInput(InversionCostFunctionsCoefficientsEnum,nodeinputs,P1Enum),reCast<int>(iomodel->Data(InversionCostFunctionsEnum)[i])); 1583 1440 } … … 1887 1744 Gauss* Penta::NewGaussTop(int order){ 1888 1745 return new GaussPenta(3,4,5,order); 1889 }1890 /*}}}*/1891 /*FUNCTION Penta::NewElementVector{{{*/1892 ElementVector* Penta::NewElementVector(int approximation_enum){1893 return new ElementVector(nodes,this->NumberofNodes(),this->parameters,approximation_enum);1894 }1895 /*}}}*/1896 /*FUNCTION Penta::NewElementMatrix{{{*/1897 ElementMatrix* Penta::NewElementMatrix(int approximation_enum){1898 return new ElementMatrix(nodes,this->NumberofNodes(),this->parameters,approximation_enum);1899 }1900 /*}}}*/1901 /*FUNCTION Penta::NewElementMatrixCoupling{{{*/1902 ElementMatrix* Penta::NewElementMatrixCoupling(int number_nodes,int approximation_enum){1903 return new ElementMatrix(nodes,number_nodes,this->parameters,approximation_enum);1904 1746 } 1905 1747 /*}}}*/ … … 2212 2054 void Penta::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, Nodes* nodesin, Materials* materialsin, Parameters* parametersin){ 2213 2055 2056 /*go into parameters and get the analysis_counter: */ 2214 2057 int analysis_counter; 2215 2216 /*go into parameters and get the analysis_counter: */2217 2058 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum); 2218 2059 … … 2220 2061 this->element_type=this->element_type_list[analysis_counter]; 2221 2062 2222 /*Pick up nodes 2223 if 2063 /*Pick up nodes*/ 2064 if(this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp(); 2224 2065 else this->nodes=NULL; 2066 2225 2067 } 2226 2068 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Elements/Penta.h
r17372 r17472 50 50 /*}}}*/ 51 51 /*Update virtual functions definitions: {{{*/ 52 void InputUpdateFromConstant(bool constant, int name);53 void InputUpdateFromConstant(IssmDouble constant, int name);54 void InputUpdateFromConstant(int constant, int name);55 52 void InputUpdateFromVector(IssmDouble* vector, int name, int type); 56 53 #ifdef _HAVE_DAKOTA_ … … 85 82 IssmDouble GetGroundedPortion(IssmDouble* xyz_list); 86 83 int GetNodeIndex(Node* node); 87 void GetNodesSidList(int* sidlist);88 void GetNodesLidList(int* lidlist);89 84 int GetNumberOfNodes(void); 90 85 int GetNumberOfNodesPressure(void); … … 96 91 IssmDouble GetZcoord(Gauss* gauss); 97 92 void GetVectorFromInputs(Vector<IssmDouble>* vector,int name_enum); 98 void GetVerticesCoordinates(IssmDouble** pxyz_list);99 93 void GetVerticesCoordinatesBase(IssmDouble** pxyz_list); 100 94 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list); 101 95 102 96 int Sid(); 103 void InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code);104 97 void InputDepthAverageAtBase(int enum_type,int average_enum_type); 105 98 void InputDuplicate(int original_enum,int new_enum); … … 204 197 void GetInputValue(IssmDouble* pvalue,Node* node,int enumtype); 205 198 Node* GetNode(int node_number); 206 void InputChangeName(int input_enum, int enum_type_old);207 199 void InputExtrude(int enum_type); 208 200 void InputUpdateFromSolutionOneDof(IssmDouble* solutiong,int enum_type); … … 225 217 Gauss* NewGaussLine(int vertex1,int vertex2,int order); 226 218 Gauss* NewGaussTop(int order); 227 ElementVector* NewElementVector(int approximation_enum);228 ElementMatrix* NewElementMatrix(int approximation_enum);229 ElementMatrix* NewElementMatrixCoupling(int number_nodes,int approximation_enum);230 219 void NodalFunctions(IssmDouble* basis,Gauss* gauss); 231 220 void NodalFunctionsP1(IssmDouble* basis,Gauss* gauss); -
issm/trunk-jpl/src/c/classes/Elements/Seg.cpp
r17347 r17472 21 21 /*FUNCTION Seg::Seg(int id, int sid,int index, IoModel* iomodel,int nummodels){{{*/ 22 22 Seg::Seg(int seg_id, int seg_sid, int index, IoModel* iomodel,int nummodels) 23 :SegRef(nummodels),ElementHook(nummodels,index+1, 2,iomodel){23 :SegRef(nummodels),ElementHook(nummodels,index+1,NUMVERTICES,iomodel){ 24 24 25 25 /*id: */ … … 263 263 } 264 264 /*}}}*/ 265 /*FUNCTION Seg::NewElementVector{{{*/266 ElementVector* Seg::NewElementVector(int approximation_enum){267 return new ElementVector(nodes,this->NumberofNodes(),this->parameters,approximation_enum);268 }269 /*}}}*/270 /*FUNCTION Seg::NewElementMatrix{{{*/271 ElementMatrix* Seg::NewElementMatrix(int approximation_enum){272 return new ElementMatrix(nodes,this->NumberofNodes(),this->parameters,approximation_enum);273 }274 /*}}}*/275 265 /*FUNCTION Seg::NodalFunctions{{{*/ 276 266 void Seg::NodalFunctions(IssmDouble* basis, Gauss* gauss){ -
issm/trunk-jpl/src/c/classes/Elements/Seg.h
r17375 r17472 53 53 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");}; 54 54 #endif 55 void InputUpdateFromConstant(IssmDouble constant, int name){_error_("not implemented yet");};56 void InputUpdateFromConstant(int constant, int name){_error_("not implemented yet");};57 void InputUpdateFromConstant(bool constant, int name){_error_("not implemented yet");};58 55 void InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");}; 59 56 /*}}}*/ … … 80 77 Element* GetBasalElement(void){_error_("not implemented yet");}; 81 78 int GetNodeIndex(Node* node){_error_("not implemented yet");}; 82 void GetNodesSidList(int* sidlist){_error_("not implemented yet");};83 void GetNodesLidList(int* lidlist){_error_("not implemented yet");};84 79 int GetNumberOfNodes(void); 85 80 int GetNumberOfNodesVelocity(void){_error_("not implemented yet");}; … … 90 85 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list){_error_("not implemented yet");}; 91 86 int Sid(){_error_("not implemented yet");}; 92 void InputChangeName(int input_enum, int enum_type_old){_error_("not implemented yet");};93 87 bool IsOnBed(){_error_("not implemented yet");}; 94 88 bool IsOnSurface(){_error_("not implemented yet");}; … … 138 132 Gauss* NewGaussLine(int vertex1,int vertex2,int order){_error_("not implemented yet");}; 139 133 Gauss* NewGaussTop(int order){_error_("not implemented yet");}; 140 ElementVector* NewElementVector(int approximation_enum);141 ElementMatrix* NewElementMatrix(int approximation_enum);142 ElementMatrix* NewElementMatrixCoupling(int number_nodes,int approximation_enum){_error_("not implemented yet");};143 134 int VertexConnectivity(int vertexindex){_error_("not implemented yet");}; 144 135 void VerticalSegmentIndices(int** pindices,int* pnumseg){_error_("not implemented yet");}; … … 152 143 void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type){_error_("not implemented yet");}; 153 144 void GetVectorFromInputs(Vector<IssmDouble>* vector, int name_enum){_error_("not implemented yet");}; 154 void InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){_error_("not implemented yet");};155 145 void InputDepthAverageAtBase(int enum_type,int average_enum_type){_error_("not implemented yet");}; 156 146 void InputDuplicate(int original_enum,int new_enum){_error_("not implemented yet");}; -
issm/trunk-jpl/src/c/classes/Elements/Tetra.cpp
r17398 r17472 22 22 /*FUNCTION Tetra::Tetra(int id, int sid,int index, IoModel* iomodel,int nummodels){{{*/ 23 23 Tetra::Tetra(int seg_id, int seg_sid, int index, IoModel* iomodel,int nummodels) 24 :TetraRef(nummodels),ElementHook(nummodels,index+1, 2,iomodel){24 :TetraRef(nummodels),ElementHook(nummodels,index+1,NUMVERTICES,iomodel){ 25 25 26 26 /*id: */ … … 127 127 /*}}}*/ 128 128 129 /*FUNCTION Tetra::AddInput{{{*/ 130 void Tetra::AddInput(int input_enum,IssmDouble* values, int interpolation_enum){ 131 132 /*Call inputs method*/ 133 _assert_(this->inputs); 134 this->inputs->AddInput(new TetraInput(input_enum,values,interpolation_enum)); 135 } 136 /*}}}*/ 137 /*FUNCTION Tetra::Configure {{{*/ 138 void Tetra::Configure(Elements* elementsin, Loads* loadsin, Nodes* nodesin,Vertices* verticesin, Materials* materialsin, Parameters* parametersin){ 139 140 int analysis_counter; 141 142 /*go into parameters and get the analysis_counter: */ 143 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum); 144 145 /*Get Element type*/ 146 this->element_type=this->element_type_list[analysis_counter]; 147 148 /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 149 * datasets, using internal ids and offsets hidden in hooks: */ 150 if (this->hnodes[analysis_counter]) this->hnodes[analysis_counter]->configure(nodesin); 151 this->hvertices->configure(verticesin); 152 this->hmaterial->configure(materialsin); 153 this->hmatpar->configure(materialsin); 154 155 /*Now, go pick up the objects inside the hooks: */ 156 if (this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp(); 157 else this->nodes=NULL; 158 this->vertices = (Vertex**)this->hvertices->deliverp(); 159 this->material = (Material*)this->hmaterial->delivers(); 160 this->matpar = (Matpar*)this->hmatpar->delivers(); 161 162 /*point parameters to real dataset: */ 163 this->parameters=parametersin; 164 165 /*get inputs configured too: */ 166 this->inputs->Configure(parameters); 167 } 168 /*}}}*/ 169 /*FUNCTION Tetra::FaceOnBedIndices{{{*/ 170 void Tetra::FaceOnBedIndices(int* pindex1,int* pindex2,int* pindex3){ 171 172 IssmDouble values[NUMVERTICES]; 173 int indices[4][3] = {{0,1,2},{0,1,3},{1,2,3},{2,0,3}}; 174 175 /*Retrieve all inputs and parameters*/ 176 GetInputListOnVertices(&values[0],MeshVertexonbedEnum); 177 178 for(int i=0;i<4;i++){ 179 if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1. && values[indices[i][2]] == 1.){ 180 *pindex1 = indices[i][0]; 181 *pindex2 = indices[i][1]; 182 *pindex3 = indices[i][2]; 183 return; 184 } 185 } 186 187 _error_("Could not find 3 vertices on bed"); 188 } 189 /*}}}*/ 190 /*FUNCTION Tetra::FaceOnSurfaceIndices{{{*/ 191 void Tetra::FaceOnSurfaceIndices(int* pindex1,int* pindex2,int* pindex3){ 192 193 IssmDouble values[NUMVERTICES]; 194 int indices[4][3] = {{0,1,2},{0,1,3},{1,2,3},{2,0,3}}; 195 196 /*Retrieve all inputs and parameters*/ 197 GetInputListOnVertices(&values[0],MeshVertexonsurfaceEnum); 198 199 for(int i=0;i<4;i++){ 200 if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1. && values[indices[i][2]] == 1.){ 201 *pindex1 = indices[i][0]; 202 *pindex2 = indices[i][1]; 203 *pindex3 = indices[i][2]; 204 return; 205 } 206 } 207 208 _error_("Could not find 3 vertices on bed"); 209 } 210 /*}}}*/ 211 /*FUNCTION Tetra::FaceOnFranceIndices{{{*/ 212 void Tetra::FaceOnFrontIndices(int* pindex1,int* pindex2,int* pindex3){ 213 214 IssmDouble values[NUMVERTICES]; 215 int indices[4][3] = {{0,1,2},{0,1,3},{1,2,3},{2,0,3}}; 216 217 /*Retrieve all inputs and parameters*/ 218 GetInputListOnVertices(&values[0],MaskIceLevelsetEnum); 219 220 for(int i=0;i<4;i++){ 221 if(values[indices[i][0]] == 0. && values[indices[i][1]] == 0. && values[indices[i][2]] == 0.){ 222 *pindex1 = indices[i][0]; 223 *pindex2 = indices[i][1]; 224 *pindex3 = indices[i][2]; 225 return; 226 } 227 } 228 229 _error_("Could not find 3 vertices on bed"); 230 } 231 /*}}}*/ 129 232 /*FUNCTION Tetra::GetNumberOfNodes;{{{*/ 130 233 int Tetra::GetNumberOfNodes(void){ … … 137 240 } 138 241 /*}}}*/ 139 /*FUNCTION Tetra::GetVerticesCoordinates(IssmDouble** pxyz_list) THIS ONE{{{*/ 140 void Tetra::GetVerticesCoordinates(IssmDouble** pxyz_list){ 141 142 IssmDouble* xyz_list = xNew<IssmDouble>(NUMVERTICES*3); 143 ::GetVerticesCoordinates(xyz_list,this->vertices,NUMVERTICES); 242 /*FUNCTION Tetra::GetVerticesCoordinatesBase(IssmDouble** pxyz_list){{{*/ 243 void Tetra::GetVerticesCoordinatesBase(IssmDouble** pxyz_list){ 244 245 int indices[3]; 246 IssmDouble xyz_list[NUMVERTICES][3]; 247 248 /*Element XYZ list*/ 249 ::GetVerticesCoordinates(&xyz_list[0][0],this->vertices,NUMVERTICES); 250 251 /*Allocate Output*/ 252 IssmDouble* xyz_list_edge = xNew<IssmDouble>(3*3); 253 this->FaceOnBedIndices(&indices[0],&indices[1],&indices[2]); 254 for(int i=0;i<3;i++) for(int j=0;j<3;j++) xyz_list_edge[i*3+j]=xyz_list[indices[i]][j]; 144 255 145 256 /*Assign output pointer*/ 146 *pxyz_list = xyz_list ;257 *pxyz_list = xyz_list_edge; 147 258 148 259 }/*}}}*/ 149 /*FUNCTION Tetra::IsIceInElement {{{*/ 260 /*FUNCTION Tetra::GetVerticesCoordinatesTop(IssmDouble** pxyz_list){{{*/ 261 void Tetra::GetVerticesCoordinatesTop(IssmDouble** pxyz_list){ 262 263 int indices[3]; 264 IssmDouble xyz_list[NUMVERTICES][3]; 265 266 /*Element XYZ list*/ 267 ::GetVerticesCoordinates(&xyz_list[0][0],this->vertices,NUMVERTICES); 268 269 /*Allocate Output*/ 270 IssmDouble* xyz_list_edge = xNew<IssmDouble>(3*3); 271 this->FaceOnSurfaceIndices(&indices[0],&indices[1],&indices[2]); 272 for(int i=0;i<3;i++) for(int j=0;j<3;j++) xyz_list_edge[i*3+j]=xyz_list[indices[i]][j]; 273 274 /*Assign output pointer*/ 275 *pxyz_list = xyz_list_edge; 276 277 }/*}}}*/ 278 /*FUNCTION Tetra::GetZcoord {{{*/ 279 IssmDouble Tetra::GetZcoord(Gauss* gauss){ 280 281 int i; 282 IssmDouble z; 283 IssmDouble xyz_list[NUMVERTICES][3]; 284 IssmDouble z_list[NUMVERTICES]; 285 286 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 287 for(i=0;i<NUMVERTICES;i++) z_list[i]=xyz_list[i][2]; 288 TetraRef::GetInputValue(&z,&z_list[0],(GaussTetra*)gauss,P1Enum); 289 290 return z; 291 } 292 /*}}}*/ 293 /*FUNCTION Tetra::HasFaceOnBed{{{*/ 294 bool Tetra::HasFaceOnBed(){ 295 296 IssmDouble values[NUMVERTICES]; 297 IssmDouble sum; 298 299 /*Retrieve all inputs and parameters*/ 300 GetInputListOnVertices(&values[0],MeshVertexonbedEnum); 301 sum = values[0]+values[1]+values[2]+values[3]; 302 303 _assert_(sum==0. || sum==1. || sum==2. || sum==3.); 304 305 if(sum==3){ 306 return true; 307 } 308 else{ 309 return false; 310 } 311 } 312 /*}}}*/ 313 /*FUNCTION Tetra::HasFaceOnSurface{{{*/ 314 bool Tetra::HasFaceOnSurface(){ 315 316 IssmDouble values[NUMVERTICES]; 317 IssmDouble sum; 318 319 /*Retrieve all inputs and parameters*/ 320 GetInputListOnVertices(&values[0],MeshVertexonsurfaceEnum); 321 sum = values[0]+values[1]+values[2]+values[3]; 322 323 _assert_(sum==0. || sum==1. || sum==2. || sum==3.); 324 325 if(sum==3){ 326 return true; 327 } 328 else{ 329 return false; 330 } 331 } 332 /*}}}*/ 333 /*FUNCTION Tetra::InputUpdateFromIoModel {{{*/ 334 void Tetra::InputUpdateFromIoModel(int index,IoModel* iomodel){ 335 336 /*Intermediaries*/ 337 int i,j; 338 int tetra_vertex_ids[NUMVERTICES]; 339 IssmDouble nodeinputs[NUMVERTICES]; 340 IssmDouble cmmininputs[NUMVERTICES]; 341 IssmDouble cmmaxinputs[NUMVERTICES]; 342 343 IssmDouble yts; 344 bool control_analysis; 345 int num_control_type,num_responses; 346 347 /*Fetch parameters: */ 348 iomodel->Constant(&yts,ConstantsYtsEnum); 349 iomodel->Constant(&control_analysis,InversionIscontrolEnum); 350 if(control_analysis) iomodel->Constant(&num_control_type,InversionNumControlParametersEnum); 351 if(control_analysis) iomodel->Constant(&num_responses,InversionNumCostFunctionsEnum); 352 353 /*Recover vertices ids needed to initialize inputs*/ 354 _assert_(iomodel->elements); 355 for(i=0;i<NUMVERTICES;i++){ 356 tetra_vertex_ids[i]=iomodel->elements[NUMVERTICES*index+i]; //ids for vertices are in the elements array from Matlab 357 } 358 359 /*Control Inputs*/ 360 if (control_analysis && iomodel->Data(InversionControlParametersEnum)){ 361 for(i=0;i<num_control_type;i++){ 362 switch(reCast<int,IssmDouble>(iomodel->Data(InversionControlParametersEnum)[i])){ 363 case BalancethicknessThickeningRateEnum: 364 if (iomodel->Data(BalancethicknessThickeningRateEnum)){ 365 for(j=0;j<NUMVERTICES;j++)nodeinputs[j]=iomodel->Data(BalancethicknessThickeningRateEnum)[tetra_vertex_ids[j]-1]/yts; 366 for(j=0;j<NUMVERTICES;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(tetra_vertex_ids[j]-1)*num_control_type+i]/yts; 367 for(j=0;j<NUMVERTICES;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(tetra_vertex_ids[j]-1)*num_control_type+i]/yts; 368 this->inputs->AddInput(new ControlInput(BalancethicknessThickeningRateEnum,TetraInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 369 } 370 break; 371 case VxEnum: 372 if (iomodel->Data(VxEnum)){ 373 for(j=0;j<NUMVERTICES;j++)nodeinputs[j]=iomodel->Data(VxEnum)[tetra_vertex_ids[j]-1]/yts; 374 for(j=0;j<NUMVERTICES;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(tetra_vertex_ids[j]-1)*num_control_type+i]/yts; 375 for(j=0;j<NUMVERTICES;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(tetra_vertex_ids[j]-1)*num_control_type+i]/yts; 376 this->inputs->AddInput(new ControlInput(VxEnum,TetraInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 377 } 378 break; 379 case VyEnum: 380 if (iomodel->Data(VyEnum)){ 381 for(j=0;j<NUMVERTICES;j++)nodeinputs[j]=iomodel->Data(VyEnum)[tetra_vertex_ids[j]-1]/yts; 382 for(j=0;j<NUMVERTICES;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(tetra_vertex_ids[j]-1)*num_control_type+i]/yts; 383 for(j=0;j<NUMVERTICES;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(tetra_vertex_ids[j]-1)*num_control_type+i]/yts; 384 this->inputs->AddInput(new ControlInput(VyEnum,TetraInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 385 } 386 break; 387 case FrictionCoefficientEnum: 388 if (iomodel->Data(FrictionCoefficientEnum)){ 389 for(j=0;j<NUMVERTICES;j++)nodeinputs[j]=iomodel->Data(FrictionCoefficientEnum)[tetra_vertex_ids[j]-1]; 390 for(j=0;j<NUMVERTICES;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(tetra_vertex_ids[j]-1)*num_control_type+i]; 391 for(j=0;j<NUMVERTICES;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(tetra_vertex_ids[j]-1)*num_control_type+i]; 392 this->inputs->AddInput(new ControlInput(FrictionCoefficientEnum,TetraInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 393 } 394 break; 395 case MaterialsRheologyBbarEnum: 396 if(iomodel->Data(MaterialsRheologyBEnum)){ 397 for(j=0;j<NUMVERTICES;j++) nodeinputs[j]=iomodel->Data(MaterialsRheologyBEnum)[tetra_vertex_ids[j]-1]; 398 for(j=0;j<NUMVERTICES;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(tetra_vertex_ids[j]-1)*num_control_type+i]; 399 for(j=0;j<NUMVERTICES;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(tetra_vertex_ids[j]-1)*num_control_type+i]; 400 this->inputs->AddInput(new ControlInput(MaterialsRheologyBEnum,TetraInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 401 } 402 break; 403 case DamageDbarEnum: 404 if(iomodel->Data(DamageDEnum)){ 405 for(j=0;j<NUMVERTICES;j++) nodeinputs[j]=iomodel->Data(DamageDEnum)[tetra_vertex_ids[j]-1]; 406 for(j=0;j<NUMVERTICES;j++)cmmininputs[j]=iomodel->Data(InversionMinParametersEnum)[(tetra_vertex_ids[j]-1)*num_control_type+i]; 407 for(j=0;j<NUMVERTICES;j++)cmmaxinputs[j]=iomodel->Data(InversionMaxParametersEnum)[(tetra_vertex_ids[j]-1)*num_control_type+i]; 408 this->inputs->AddInput(new ControlInput(DamageDEnum,TetraInputEnum,nodeinputs,cmmininputs,cmmaxinputs,i+1)); 409 } 410 break; 411 default: 412 _error_("Control " << EnumToStringx(reCast<int,IssmDouble>(iomodel->Data(InversionControlParametersEnum)[i])) << " not implemented yet"); 413 } 414 } 415 } 416 417 /*Need to know the type of approximation for this element*/ 418 if(iomodel->Data(FlowequationElementEquationEnum)){ 419 this->inputs->AddInput(new IntInput(ApproximationEnum,reCast<int>(iomodel->Data(FlowequationElementEquationEnum)[index]))); 420 } 421 422 /*DatasetInputs*/ 423 if (control_analysis && iomodel->Data(InversionCostFunctionsCoefficientsEnum)) { 424 425 /*Create inputs and add to DataSetInput*/ 426 DatasetInput* datasetinput=new DatasetInput(InversionCostFunctionsCoefficientsEnum); 427 for(i=0;i<num_responses;i++){ 428 for(j=0;j<NUMVERTICES;j++)nodeinputs[j]=iomodel->Data(InversionCostFunctionsCoefficientsEnum)[(tetra_vertex_ids[j]-1)*num_responses+i]; 429 datasetinput->AddInput(new TetraInput(InversionCostFunctionsCoefficientsEnum,nodeinputs,P1Enum),reCast<int>(iomodel->Data(InversionCostFunctionsEnum)[i])); 430 } 431 432 /*Add datasetinput to element inputs*/ 433 this->inputs->AddInput(datasetinput); 434 } 435 } 436 /*}}}*/ 437 /*FUNCTION Tetra::IsIceInElement THIS ONE{{{*/ 150 438 bool Tetra::IsIceInElement(){ 151 439 152 _error_("not implemented yet"); 440 /*Get levelset*/ 441 IssmDouble ls[NUMVERTICES]; 442 GetInputListOnVertices(&ls[0],MaskIceLevelsetEnum); 443 444 /*If the level set on one of the nodes is <0, ice is present in this element*/ 445 for(int i=0;i<NUMVERTICES;i++){ 446 if(ls[i]<0.) return true; 447 } 448 449 return false; 450 } 451 /*}}}*/ 452 /*FUNCTION Tetra::IsOnBed {{{*/ 453 bool Tetra::IsOnBed(){ 454 return HasFaceOnBed(); 455 } 456 /*}}}*/ 457 /*FUNCTION Tetra::IsOnSurface {{{*/ 458 bool Tetra::IsOnSurface(){ 459 return HasFaceOnSurface(); 153 460 } 154 461 /*}}}*/ 155 462 bool Tetra::IsIcefront(void){/*{{{*/ 156 463 157 _error_("not implemented yet"); 464 /*Retrieve all inputs and parameters*/ 465 IssmDouble ls[NUMVERTICES]; 466 GetInputListOnVertices(&ls[0],MaskIceLevelsetEnum); 467 468 /* If only one vertex has ice, there is an ice front here */ 469 if(IsIceInElement()){ 470 int nrice=0; 471 for(int i=0;i<NUMVERTICES;i++) if(ls[i]<0.) nrice++; 472 if(nrice==1) return true; 473 } 474 return false; 158 475 }/*}}}*/ 159 476 /*FUNCTION Tetra::JacobianDeterminant{{{*/ … … 168 485 void Tetra::JacobianDeterminantSurface(IssmDouble* pJdet,IssmDouble* xyz_list,Gauss* gauss){ 169 486 170 _error_("not implemented yet"); 487 _assert_(gauss->Enum()==GaussTetraEnum); 488 this->GetJacobianDeterminantFace(pJdet,xyz_list,(GaussTetra*)gauss); 489 490 } 491 /*}}}*/ 492 /*FUNCTION Tetra::JacobianDeterminantBase{{{*/ 493 void Tetra::JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss){ 494 495 _assert_(gauss->Enum()==GaussTetraEnum); 496 this->GetJacobianDeterminantFace(pJdet,xyz_list_base,(GaussTetra*)gauss); 497 498 } 499 /*}}}*/ 500 /*FUNCTION Tetra::JacobianDeterminantTop{{{*/ 501 void Tetra::JacobianDeterminantTop(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss){ 502 503 _assert_(gauss->Enum()==GaussTetraEnum); 504 this->GetJacobianDeterminantFace(pJdet,xyz_list_base,(GaussTetra*)gauss); 171 505 172 506 } … … 182 516 } 183 517 /*}}}*/ 184 /*FUNCTION Tetra::NewElementVector THIS ONE{{{*/ 185 ElementVector* Tetra::NewElementVector(int approximation_enum){ 186 return new ElementVector(nodes,this->NumberofNodes(),this->parameters,approximation_enum); 187 } 188 /*}}}*/ 189 /*FUNCTION Tetra::NewElementMatrix THIS ONE{{{*/ 190 ElementMatrix* Tetra::NewElementMatrix(int approximation_enum){ 191 return new ElementMatrix(nodes,this->NumberofNodes(),this->parameters,approximation_enum); 518 /*FUNCTION Tetra::NewGauss(IssmDouble* xyz_list, IssmDouble* xyz_list_front,int order_horiz,int order_vert){{{*/ 519 Gauss* Tetra::NewGauss(IssmDouble* xyz_list, IssmDouble* xyz_list_front,int order_horiz,int order_vert){ 520 /*FIXME: this is messed up, should provide indices and not xyz_list!*/ 521 int indices[3]; 522 this->FaceOnFrontIndices(&indices[0],&indices[1],&indices[2]); 523 return new GaussTetra(indices[0],indices[1],indices[2],max(order_horiz,order_vert)); 524 } 525 /*}}}*/ 526 /*FUNCTION Tetra::NewGaussBase(int order){{{*/ 527 Gauss* Tetra::NewGaussBase(int order){ 528 529 int indices[3]; 530 this->FaceOnBedIndices(&indices[0],&indices[1],&indices[2]); 531 return new GaussTetra(indices[0],indices[1],indices[2],order); 532 } 533 /*}}}*/ 534 /*FUNCTION Tetra::NewGaussTop(int order){{{*/ 535 Gauss* Tetra::NewGaussTop(int order){ 536 537 int indices[3]; 538 this->FaceOnSurfaceIndices(&indices[0],&indices[1],&indices[2]); 539 return new GaussTetra(indices[0],indices[1],indices[2],order); 192 540 } 193 541 /*}}}*/ … … 209 557 /*}}}*/ 210 558 /*FUNCTION Tetra::NormalSection{{{*/ 211 void Tetra::NormalSection(IssmDouble* normal,IssmDouble* xyz_list_front){ 212 213 _error_("Not implemented yet"); 214 } 215 /*}}}*/ 559 void Tetra::NormalSection(IssmDouble* normal,IssmDouble* xyz_list){ 560 561 /*Build unit outward pointing vector*/ 562 IssmDouble AB[3]; 563 IssmDouble AC[3]; 564 IssmDouble norm; 565 566 AB[0]=xyz_list[1*3+0] - xyz_list[0*3+0]; 567 AB[1]=xyz_list[1*3+1] - xyz_list[0*3+1]; 568 AB[2]=xyz_list[1*3+2] - xyz_list[0*3+2]; 569 AC[0]=xyz_list[2*3+0] - xyz_list[0*3+0]; 570 AC[1]=xyz_list[2*3+1] - xyz_list[0*3+1]; 571 AC[2]=xyz_list[2*3+2] - xyz_list[0*3+2]; 572 573 cross(normal,AB,AC); 574 norm=sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); 575 576 for(int i=0;i<3;i++) normal[i]=normal[i]/norm; 577 } 578 /*}}}*/ 579 /*FUNCTION Tetra::ReduceMatrices{{{*/ 580 void Tetra::ReduceMatrices(ElementMatrix* Ke,ElementVector* pe){ 581 582 int analysis_type; 583 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 584 585 if(pe){ 586 if(analysis_type==StressbalanceAnalysisEnum){ 587 if(this->element_type==MINIcondensedEnum){ 588 int approximation; 589 inputs->GetInputValue(&approximation,ApproximationEnum); 590 if(approximation==HOFSApproximationEnum || approximation==SSAFSApproximationEnum){ 591 //Do nothing, condensation already done in PVectorCoupling 592 } 593 else{ 594 _error_("Not implemented"); 595 } 596 } 597 else if(this->element_type==P1bubblecondensedEnum){ 598 _error_("Not implemented"); 599 } 600 } 601 } 602 603 if(Ke){ 604 if(analysis_type==StressbalanceAnalysisEnum){ 605 int approximation; 606 inputs->GetInputValue(&approximation,ApproximationEnum); 607 if(approximation==HOFSApproximationEnum || approximation==SSAFSApproximationEnum){ 608 //Do nothing condensatino already done for Stokes part 609 } 610 else{ 611 if(this->element_type==MINIcondensedEnum){ 612 _error_("Not implemented"); 613 } 614 else if(this->element_type==P1bubblecondensedEnum){ 615 _error_("Not implemented"); 616 } 617 } 618 } 619 } 620 } 621 /*}}}*/ 622 /*FUNCTION Tetra::SetCurrentConfiguration {{{*/ 623 void Tetra::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, Nodes* nodesin, Materials* materialsin, Parameters* parametersin){ 624 625 /*go into parameters and get the analysis_counter: */ 626 int analysis_counter; 627 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum); 628 629 /*Get Element type*/ 630 this->element_type=this->element_type_list[analysis_counter]; 631 632 /*Pick up nodes*/ 633 if(this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp(); 634 else this->nodes=NULL; 635 636 } 637 /*}}}*/ 638 /*FUNCTION Tetra::SetwiseNodeConnectivity THIS ONE (take from Penta.cpp){{{*/ 639 void Tetra::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum){ 640 641 /*Intermediaries*/ 642 const int numnodes = this->NumberofNodes(); 643 644 /*Output */ 645 int d_nz = 0; 646 int o_nz = 0; 647 648 /*Loop over all nodes*/ 649 for(int i=0;i<numnodes;i++){ 650 651 if(!flags[this->nodes[i]->Lid()]){ 652 653 /*flag current node so that no other element processes it*/ 654 flags[this->nodes[i]->Lid()]=true; 655 656 int counter=0; 657 while(flagsindices[counter]>=0) counter++; 658 flagsindices[counter]=this->nodes[i]->Lid(); 659 660 /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/ 661 switch(set2_enum){ 662 case FsetEnum: 663 if(nodes[i]->indexing.fsize){ 664 if(this->nodes[i]->IsClone()) 665 o_nz += 1; 666 else 667 d_nz += 1; 668 } 669 break; 670 case GsetEnum: 671 if(nodes[i]->indexing.gsize){ 672 if(this->nodes[i]->IsClone()) 673 o_nz += 1; 674 else 675 d_nz += 1; 676 } 677 break; 678 case SsetEnum: 679 if(nodes[i]->indexing.ssize){ 680 if(this->nodes[i]->IsClone()) 681 o_nz += 1; 682 else 683 d_nz += 1; 684 } 685 break; 686 default: _error_("not supported"); 687 } 688 } 689 } 690 691 /*Assign output pointers: */ 692 *pd_nz=d_nz; 693 *po_nz=o_nz; 694 } 695 /*}}}*/ 696 /*FUNCTION Tetra::Sid THIS ONE{{{*/ 697 int Tetra::Sid(){ 698 699 return sid; 700 701 } 702 /*}}}*/ 703 /*FUNCTION Tetra::Update {{{*/ 704 void Tetra::Update(int index,IoModel* iomodel,int analysis_counter,int analysis_type,int finiteelement_type){ 705 706 /*Intermediaries*/ 707 int i; 708 int tetra_vertex_ids[6]; 709 IssmDouble nodeinputs[6]; 710 IssmDouble yts; 711 bool dakota_analysis; 712 bool isFS; 713 int numnodes; 714 int* tetra_node_ids = NULL; 715 716 /*Fetch parameters: */ 717 iomodel->Constant(&yts,ConstantsYtsEnum); 718 iomodel->Constant(&dakota_analysis,QmuIsdakotaEnum); 719 iomodel->Constant(&isFS,FlowequationIsFSEnum); 720 721 /*Checks if debuging*/ 722 _assert_(iomodel->elements); 723 724 /*Recover element type*/ 725 this->SetElementType(finiteelement_type,analysis_counter); 726 727 /*Recover vertices ids needed to initialize inputs*/ 728 for(i=0;i<6;i++) tetra_vertex_ids[i]=iomodel->elements[6*index+i]; //ids for vertices are in the elements array from Matlab 729 730 /*Recover nodes ids needed to initialize the node hook.*/ 731 switch(finiteelement_type){ 732 case P1Enum: 733 numnodes = 4; 734 tetra_node_ids = xNew<int>(numnodes); 735 tetra_node_ids[0]=iomodel->nodecounter+iomodel->elements[4*index+0]; 736 tetra_node_ids[1]=iomodel->nodecounter+iomodel->elements[4*index+1]; 737 tetra_node_ids[2]=iomodel->nodecounter+iomodel->elements[4*index+2]; 738 tetra_node_ids[3]=iomodel->nodecounter+iomodel->elements[4*index+3]; 739 break; 740 default: 741 _error_("Finite element "<<EnumToStringx(finiteelement_type)<<" not supported yet"); 742 } 743 744 /*hooks: */ 745 this->SetHookNodes(tetra_node_ids,numnodes,analysis_counter); this->nodes=NULL; 746 xDelete<int>(tetra_node_ids); 747 748 /*Fill with IoModel*/ 749 this->InputUpdateFromIoModel(index,iomodel); 750 } 751 /*}}}*/ 752 /*FUNCTION Tetra::ZeroLevelsetCoordinates{{{*/ 753 void Tetra::ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum){ 754 /*Compute portion of the element that is grounded*/ 755 756 IssmDouble levelset[NUMVERTICES]; 757 IssmDouble* xyz_zero = xNew<IssmDouble>(3*3); 758 759 /*Recover parameters and values*/ 760 GetInputListOnVertices(&levelset[0],levelsetenum); 761 762 if(levelset[0]==0. && levelset[1]==0. && levelset[2]==0.){ 763 xyz_zero[3*0+0]=xyz_list[0*3+0]; 764 xyz_zero[3*0+1]=xyz_list[0*3+1]; 765 xyz_zero[3*0+2]=xyz_list[0*3+2]; 766 767 /*New point 2*/ 768 xyz_zero[3*1+0]=xyz_list[1*3+0]; 769 xyz_zero[3*1+1]=xyz_list[1*3+1]; 770 xyz_zero[3*1+2]=xyz_list[1*3+2]; 771 772 /*New point 3*/ 773 xyz_zero[3*2+0]=xyz_list[2*3+0]; 774 xyz_zero[3*2+1]=xyz_list[2*3+1]; 775 xyz_zero[3*2+2]=xyz_list[2*3+2]; 776 } 777 else if(levelset[0]==0. && levelset[1]==0. && levelset[3]==0.){ 778 xyz_zero[3*0+0]=xyz_list[0*3+0]; 779 xyz_zero[3*0+1]=xyz_list[0*3+1]; 780 xyz_zero[3*0+2]=xyz_list[0*3+2]; 781 782 /*New point 2*/ 783 xyz_zero[3*1+0]=xyz_list[1*3+0]; 784 xyz_zero[3*1+1]=xyz_list[1*3+1]; 785 xyz_zero[3*1+2]=xyz_list[1*3+2]; 786 787 /*New point 3*/ 788 xyz_zero[3*2+0]=xyz_list[3*3+0]; 789 xyz_zero[3*2+1]=xyz_list[3*3+1]; 790 xyz_zero[3*2+2]=xyz_list[3*3+2]; 791 } 792 else if(levelset[1]==0. && levelset[2]==0. && levelset[3]==0.){ 793 xyz_zero[3*0+0]=xyz_list[1*3+0]; 794 xyz_zero[3*0+1]=xyz_list[1*3+1]; 795 xyz_zero[3*0+2]=xyz_list[1*3+2]; 796 797 /*New point 2*/ 798 xyz_zero[3*1+0]=xyz_list[2*3+0]; 799 xyz_zero[3*1+1]=xyz_list[2*3+1]; 800 xyz_zero[3*1+2]=xyz_list[2*3+2]; 801 802 /*New point 3*/ 803 xyz_zero[3*2+0]=xyz_list[3*3+0]; 804 xyz_zero[3*2+1]=xyz_list[3*3+1]; 805 xyz_zero[3*2+2]=xyz_list[3*3+2]; 806 } 807 else if(levelset[2]==0. && levelset[0]==0. && levelset[3]==0.){ 808 xyz_zero[3*0+0]=xyz_list[2*3+0]; 809 xyz_zero[3*0+1]=xyz_list[2*3+1]; 810 xyz_zero[3*0+2]=xyz_list[2*3+2]; 811 812 /*New point 2*/ 813 xyz_zero[3*1+0]=xyz_list[0*3+0]; 814 xyz_zero[3*1+1]=xyz_list[0*3+1]; 815 xyz_zero[3*1+2]=xyz_list[0*3+2]; 816 817 /*New point 3*/ 818 xyz_zero[3*2+0]=xyz_list[3*3+0]; 819 xyz_zero[3*2+1]=xyz_list[3*3+1]; 820 xyz_zero[3*2+2]=xyz_list[3*3+2]; 821 } 822 else _error_("Case not covered"); 823 824 /*Assign output pointer*/ 825 *pxyz_zero= xyz_zero; 826 } 827 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Elements/Tetra.h
r17398 r17472 53 53 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");}; 54 54 #endif 55 void InputUpdateFromConstant(IssmDouble constant, int name){_error_("not implemented yet");}; 56 void InputUpdateFromConstant(int constant, int name){_error_("not implemented yet");}; 57 void InputUpdateFromConstant(bool constant, int name){_error_("not implemented yet");}; 58 void InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");}; 55 void InputUpdateFromIoModel(int index, IoModel* iomodel); 59 56 /*}}}*/ 60 57 /*Element virtual functions definitions: {{{*/ 61 58 void AddBasalInput(int input_enum, IssmDouble* values, int interpolation_enum){_error_("not implemented yet");}; 62 void AddInput(int input_enum, IssmDouble* values, int interpolation_enum) {_error_("not implemented yet");};59 void AddInput(int input_enum, IssmDouble* values, int interpolation_enum); 63 60 IssmDouble CharacteristicLength(void){_error_("not implemented yet");}; 64 61 void ComputeBasalStress(Vector<IssmDouble>* sigma_b){_error_("not implemented yet");}; 65 62 void ComputeStrainRate(Vector<IssmDouble>* eps){_error_("not implemented yet");}; 66 63 void ComputeStressTensor(){_error_("not implemented yet");}; 67 void Configure(Elements* elements,Loads* loads,Nodes* nodesin,Vertices* verticesin,Materials* materials,Parameters* parameters) {_error_("not implemented yet");};68 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters) {_error_("not implemented yet");};69 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum) {_error_("not implemented yet");};64 void Configure(Elements* elements,Loads* loads,Nodes* nodesin,Vertices* verticesin,Materials* materials,Parameters* parameters); 65 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters); 66 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum); 70 67 void Delta18oParameterization(void){_error_("not implemented yet");}; 71 68 void ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz){_error_("not implemented yet");}; … … 74 71 IssmDouble EnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure){_error_("not implemented");}; 75 72 IssmDouble EnthalpyDiffusionParameterVolume(int numvertices,IssmDouble* enthalpy,IssmDouble* pressure){_error_("not implemented");}; 73 void FaceOnFrontIndices(int* pindex1,int* pindex2,int* pindex3); 74 void FaceOnBedIndices(int* pindex1,int* pindex2,int* pindex3); 75 void FaceOnSurfaceIndices(int* pindex1,int* pindex2,int* pindex3); 76 76 int FiniteElement(void); 77 77 Element* GetUpperElement(void){_error_("not implemented yet");}; … … 80 80 Element* GetBasalElement(void){_error_("not implemented yet");}; 81 81 int GetNodeIndex(Node* node){_error_("not implemented yet");}; 82 void GetNodesSidList(int* sidlist){_error_("not implemented yet");};83 void GetNodesLidList(int* lidlist){_error_("not implemented yet");};84 82 int GetNumberOfNodes(void); 85 83 int GetNumberOfNodesVelocity(void){_error_("not implemented yet");}; 86 84 int GetNumberOfNodesPressure(void){_error_("not implemented yet");}; 87 85 int GetNumberOfVertices(void); 88 void GetVerticesCoordinates (IssmDouble** pxyz_list);89 void GetVerticesCoordinates Base(IssmDouble** pxyz_list){_error_("not implemented yet");};90 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list){_error_("not implemented yet");};91 int Sid(){_error_("not implemented yet");};92 void InputChangeName(int input_enum, int enum_type_old){_error_("not implemented yet");};93 bool IsOnBed() {_error_("not implemented yet");};94 bool IsOnSurface() {_error_("not implemented yet");};86 void GetVerticesCoordinatesBase(IssmDouble** pxyz_list); 87 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list); 88 bool HasFaceOnBed(); 89 bool HasFaceOnSurface(); 90 int Sid(); 91 bool IsOnBed(); 92 bool IsOnSurface(); 95 93 bool IsNodeOnShelfFromFlags(IssmDouble* flags){_error_("not implemented yet");}; 96 94 void JacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 97 95 void JacobianDeterminantLine(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 98 96 void JacobianDeterminantSurface(IssmDouble* pJdet, IssmDouble* xyz_list,Gauss* gauss); 99 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss) {_error_("not implemented yet");};100 void JacobianDeterminantTop(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss) {_error_("not implemented yet");};97 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss); 98 void JacobianDeterminantTop(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss); 101 99 IssmDouble MinEdgeLength(IssmDouble* xyz_list){_error_("not implemented yet");}; 102 100 void NodalFunctions(IssmDouble* basis,Gauss* gauss); … … 128 126 IssmDouble GetXcoord(Gauss* gauss){_error_("Not implemented");}; 129 127 IssmDouble GetYcoord(Gauss* gauss){_error_("Not implemented");}; 130 IssmDouble GetZcoord(Gauss* gauss) {_error_("not implemented yet");};128 IssmDouble GetZcoord(Gauss* gauss); 131 129 int GetElementType(void){_error_("not implemented yet");}; 132 130 Gauss* NewGauss(void); 133 131 Gauss* NewGauss(int order); 134 132 Gauss* NewGauss(IssmDouble* xyz_list, IssmDouble* xyz_list_front,int order){_error_("not implemented yet");}; 135 Gauss* NewGauss(IssmDouble* xyz_list, IssmDouble* xyz_list_front,int order_horiz,int order_vert) {_error_("not implemented yet");};133 Gauss* NewGauss(IssmDouble* xyz_list, IssmDouble* xyz_list_front,int order_horiz,int order_vert); 136 134 Gauss* NewGauss(int point1,IssmDouble fraction1,IssmDouble fraction2,bool mainlyfloating,int order){_error_("not implemented yet");}; 137 Gauss* NewGaussBase(int order) {_error_("not implemented yet");};135 Gauss* NewGaussBase(int order); 138 136 Gauss* NewGaussLine(int vertex1,int vertex2,int order){_error_("not implemented yet");}; 139 Gauss* NewGaussTop(int order){_error_("not implemented yet");}; 140 ElementVector* NewElementVector(int approximation_enum); 141 ElementMatrix* NewElementMatrix(int approximation_enum); 142 ElementMatrix* NewElementMatrixCoupling(int number_nodes,int approximation_enum){_error_("not implemented yet");}; 137 Gauss* NewGaussTop(int order); 143 138 int VertexConnectivity(int vertexindex){_error_("not implemented yet");}; 144 139 void VerticalSegmentIndices(int** pindices,int* pnumseg){_error_("not implemented yet");}; … … 146 141 bool IsZeroLevelset(int levelset_enum){_error_("not implemented");}; 147 142 bool IsIcefront(void); 148 void ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum) {_error_("not implemented");};143 void ZeroLevelsetCoordinates(IssmDouble** pxyz_zero,IssmDouble* xyz_list,int levelsetenum); 149 144 void GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){_error_("not implemented yet");}; 150 145 void GetNormalFromLSF(IssmDouble *pnormal){_error_("not implemented yet");}; … … 152 147 void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type){_error_("not implemented yet");}; 153 148 void GetVectorFromInputs(Vector<IssmDouble>* vector, int name_enum){_error_("not implemented yet");}; 154 void InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){_error_("not implemented yet");};155 149 void InputDepthAverageAtBase(int enum_type,int average_enum_type){_error_("not implemented yet");}; 156 150 void InputDuplicate(int original_enum,int new_enum){_error_("not implemented yet");}; … … 160 154 void PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm){_error_("not implemented yet");}; 161 155 void ResetFSBasalBoundaryCondition(void){_error_("not implemented yet");}; 162 void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe) {_error_("not implemented yet");};156 void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe); 163 157 void SetTemporaryElementType(int element_type_in){_error_("not implemented yet");}; 164 158 void SmbGradients(){_error_("not implemented yet");}; 165 159 IssmDouble SurfaceArea(void){_error_("not implemented yet");}; 166 void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement) {_error_("not implemented yet");};160 void Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement); 167 161 IssmDouble TimeAdapt(){_error_("not implemented yet");}; 168 162 void UpdateConstraintsExtrudeFromBase(){_error_("not implemented");}; -
issm/trunk-jpl/src/c/classes/Elements/TetraRef.cpp
r17406 r17472 329 329 } 330 330 /*}}}*/ 331 /*FUNCTION TetraRef::GetJacobianDeterminantFace{{{*/ 332 void TetraRef::GetJacobianDeterminantFace(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTetra* gauss){ 333 /*The Jacobian determinant is constant over the element, discard the gaussian points. 334 * J is assumed to have been allocated of size NDOF2xNDOF2.*/ 335 336 IssmDouble x1=xyz_list[3*0+0]; 337 IssmDouble y1=xyz_list[3*0+1]; 338 IssmDouble z1=xyz_list[3*0+2]; 339 IssmDouble x2=xyz_list[3*1+0]; 340 IssmDouble y2=xyz_list[3*1+1]; 341 IssmDouble z2=xyz_list[3*1+2]; 342 IssmDouble x3=xyz_list[3*2+0]; 343 IssmDouble y3=xyz_list[3*2+1]; 344 IssmDouble z3=xyz_list[3*2+2]; 345 346 /*Jdet = norm( AB ^ AC ) / (2 * area of the reference triangle), with areaRef=sqrt(3) */ 347 *Jdet=SQRT3/6.*pow(pow(((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1)),2)+pow(((z2-z1)*(x3-x1)-(x2-x1)*(z3-z1)),2)+pow(((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)),2),0.5); 348 if(*Jdet<0) _error_("negative jacobian determinant!"); 349 } 350 /*}}}*/ 331 351 /*FUNCTION TetraRef::GetJacobianInvert {{{*/ 332 352 void TetraRef::GetJacobianInvert(IssmDouble* Jinv, IssmDouble* xyz_list,GaussTetra* gauss){ -
issm/trunk-jpl/src/c/classes/Elements/TetraRef.h
r17398 r17472 25 25 void GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussTetra* gauss); 26 26 void GetJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTetra* gauss); 27 void GetJacobianDeterminantFace(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTetra* gauss); 27 28 void GetJacobianInvert(IssmDouble* Jinv, IssmDouble* xyz_list,GaussTetra* gauss); 28 29 void GetNodalFunctions(IssmDouble* basis,GaussTetra* gauss); -
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r17463 r17472 26 26 /*FUNCTION Tria::Tria(int id, int sid,int index, IoModel* iomodel,int nummodels){{{*/ 27 27 Tria::Tria(int tria_id, int tria_sid, int index, IoModel* iomodel,int nummodels) 28 :TriaRef(nummodels),ElementHook(nummodels,index+1, 3,iomodel){28 :TriaRef(nummodels),ElementHook(nummodels,index+1,NUMVERTICES,iomodel){ 29 29 30 30 /*id: */ … … 687 687 } 688 688 /*}}}*/ 689 /*FUNCTION Tria::GetVerticesCoordinates(IssmDouble** pxyz_list){{{*/690 void Tria::GetVerticesCoordinates(IssmDouble** pxyz_list){691 692 IssmDouble* xyz_list = xNew<IssmDouble>(NUMVERTICES*3);693 ::GetVerticesCoordinates(xyz_list,this->vertices,NUMVERTICES);694 695 /*Assign output pointer*/696 *pxyz_list = xyz_list;697 698 }/*}}}*/699 689 /*FUNCTION Tria::GetVerticesCoordinatesBase(IssmDouble** pxyz_list){{{*/ 700 690 void Tria::GetVerticesCoordinatesBase(IssmDouble** pxyz_list){ … … 927 917 } 928 918 /*}}}*/ 929 /*FUNCTION Tria::GetNodesSidList{{{*/930 void Tria::GetNodesSidList(int* sidlist){931 932 _assert_(sidlist);933 _assert_(nodes);934 int numnodes = this->NumberofNodes();935 936 for(int i=0;i<numnodes;i++){937 sidlist[i]=nodes[i]->Sid();938 }939 }940 /*}}}*/941 /*FUNCTION Tria::GetNodesLidList{{{*/942 void Tria::GetNodesLidList(int* lidlist){943 944 _assert_(lidlist);945 _assert_(nodes);946 int numnodes = this->NumberofNodes();947 948 for(int i=0;i<numnodes;i++){949 lidlist[i]=nodes[i]->Lid();950 }951 }952 /*}}}*/953 919 /*FUNCTION Tria::GetNumberOfNodes;{{{*/ 954 920 int Tria::GetNumberOfNodes(void){ … … 1086 1052 } 1087 1053 /*}}}*/ 1088 /*FUNCTION Tria::InputChangeName{{{*/1089 void Tria::InputChangeName(int original_enum,int new_enum){1090 1091 /*Call inputs method*/1092 this->inputs->ChangeEnum(original_enum,new_enum);1093 }1094 /*}}}*/1095 1054 /*FUNCTION Tria::InputScale{{{*/ 1096 1055 void Tria::InputScale(int enum_type,IssmDouble scale_factor){ … … 1104 1063 /*Scale: */ 1105 1064 input->Scale(scale_factor); 1106 }1107 /*}}}*/1108 /*FUNCTION Tria::InputUpdateFromConstant(int value, int name);{{{*/1109 void Tria::InputUpdateFromConstant(int constant, int name){1110 1111 /*Check that name is an element input*/1112 if(!IsInput(name)) return;1113 1114 /*update input*/1115 this->inputs->AddInput(new IntInput(name,constant));1116 }1117 /*}}}*/1118 /*FUNCTION Tria::InputUpdateFromConstant(IssmDouble value, int name);{{{*/1119 void Tria::InputUpdateFromConstant(IssmDouble constant, int name){1120 1121 /*Check that name is an element input*/1122 if(!IsInput(name)) return;1123 1124 /*update input*/1125 this->inputs->AddInput(new DoubleInput(name,constant));1126 }1127 /*}}}*/1128 /*FUNCTION Tria::InputUpdateFromConstant(bool value, int name);{{{*/1129 void Tria::InputUpdateFromConstant(bool constant, int name){1130 1131 /*Check that name is an element input*/1132 if(!IsInput(name)) return;1133 1134 /*update input*/1135 this->inputs->AddInput(new BoolInput(name,constant));1136 1065 } 1137 1066 /*}}}*/ … … 1340 1269 } 1341 1270 /*}}}*/ 1342 /*FUNCTION Tria::InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){{{*/1343 void Tria::InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){1344 1345 /*Intermediaries*/1346 int i,t;1347 int tria_vertex_ids[3];1348 int row;1349 IssmDouble nodeinputs[3];1350 IssmDouble time;1351 TransientInput* transientinput=NULL;1352 1353 /*Branch on type of vector: nodal or elementary: */1354 if(vector_type==1){ //nodal vector1355 1356 /*Recover vertices ids needed to initialize inputs*/1357 for(i=0;i<3;i++){1358 _assert_(iomodel->elements);1359 tria_vertex_ids[i]=reCast<int>(iomodel->elements[3*this->sid+i]); //ids for vertices are in the elements array from Matlab1360 }1361 1362 /*Are we in transient or static? */1363 if(M==iomodel->numberofvertices){1364 1365 /*create input values: */1366 for(i=0;i<3;i++)nodeinputs[i]=vector[tria_vertex_ids[i]-1];1367 1368 /*create static input: */1369 this->inputs->AddInput(new TriaInput(vector_enum,nodeinputs,P1Enum));1370 }1371 else if(M==iomodel->numberofvertices+1){1372 /*create transient input: */1373 IssmDouble* times = xNew<IssmDouble>(N);1374 for(t=0;t<N;t++) times[t] = vector[(M-1)*N+t];1375 transientinput=new TransientInput(vector_enum,times,N);1376 for(t=0;t<N;t++){1377 for(i=0;i<NUMVERTICES;i++) nodeinputs[i]=vector[N*(tria_vertex_ids[i]-1)+t];1378 transientinput->AddTimeInput(new TriaInput(vector_enum,nodeinputs,P1Enum));1379 }1380 this->inputs->AddInput(transientinput);1381 xDelete<IssmDouble>(times);1382 }1383 else _error_("nodal vector is either numberofvertices or numberofvertices+1 long. Field provided (" << EnumToStringx(vector_enum) << ") is " << M << " long");1384 }1385 else if(vector_type==2){ //element vector1386 /*Are we in transient or static? */1387 if(M==iomodel->numberofelements){1388 1389 /*static mode: create an input out of the element value: */1390 1391 if (code==5){ //boolean1392 this->inputs->AddInput(new BoolInput(vector_enum,reCast<bool>(vector[this->sid])));1393 }1394 else if (code==6){ //integer1395 this->inputs->AddInput(new IntInput(vector_enum,reCast<int>(vector[this->sid])));1396 }1397 else if (code==7){ //IssmDouble1398 this->inputs->AddInput(new DoubleInput(vector_enum,vector[this->sid]));1399 }1400 else _error_("could not recognize nature of vector from code " << code);1401 }1402 else {1403 _error_("transient element inputs not supported yet!");1404 }1405 }1406 else{1407 _error_("Cannot add input for vector type " << vector_type << " (not supported)");1408 }1409 1410 }1411 /*}}}*/1412 1271 /*FUNCTION Tria::IsOnBed {{{*/ 1413 1272 bool Tria::IsOnBed(){ … … 1681 1540 this->EdgeOnSurfaceIndices(&indices[0],&indices[1]); 1682 1541 return new GaussTria(indices[0],indices[1],order); 1683 }1684 /*}}}*/1685 /*FUNCTION Tria::NewElementVector{{{*/1686 ElementVector* Tria::NewElementVector(int approximation_enum){1687 return new ElementVector(nodes,this->NumberofNodes(),this->parameters,approximation_enum);1688 }1689 /*}}}*/1690 /*FUNCTION Tria::NewElementMatrix{{{*/1691 ElementMatrix* Tria::NewElementMatrix(int approximation_enum){1692 return new ElementMatrix(nodes,this->NumberofNodes(),this->parameters,approximation_enum);1693 1542 } 1694 1543 /*}}}*/ … … 2024 1873 } 2025 1874 /*}}}*/ 2026 /*FUNCTION Tria::SetCurrentConfiguration {{{*/2027 void Tria::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, Nodes* nodesin, Materials* materialsin, Parameters* parametersin){2028 2029 /*go into parameters and get the analysis_counter: */2030 int analysis_counter;2031 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum);2032 2033 /*Get Element type*/2034 this->element_type=this->element_type_list[analysis_counter];2035 2036 /*Pick up nodes*/2037 if(this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp();2038 else this->nodes=NULL;2039 2040 }2041 /*}}}*/2042 1875 /*FUNCTION Tria::SpawnSeg {{{*/ 2043 1876 Seg* Tria::SpawnSeg(int index1,int index2){ … … 2104 1937 _error_("not implemented yet"); 2105 1938 } 1939 } 1940 /*}}}*/ 1941 /*FUNCTION Tria::SetCurrentConfiguration {{{*/ 1942 void Tria::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, Nodes* nodesin, Materials* materialsin, Parameters* parametersin){ 1943 1944 /*go into parameters and get the analysis_counter: */ 1945 int analysis_counter; 1946 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum); 1947 1948 /*Get Element type*/ 1949 this->element_type=this->element_type_list[analysis_counter]; 1950 1951 /*Pick up nodes*/ 1952 if(this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp(); 1953 else this->nodes=NULL; 1954 2106 1955 } 2107 1956 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Elements/Tria.h
r17372 r17472 53 53 void InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type); 54 54 #endif 55 void InputUpdateFromConstant(IssmDouble constant, int name);56 void InputUpdateFromConstant(int constant, int name);57 void InputUpdateFromConstant(bool constant, int name);58 55 void InputUpdateFromIoModel(int index, IoModel* iomodel); 59 56 /*}}}*/ … … 79 76 IssmDouble GetGroundedPortion(IssmDouble* xyz_list); 80 77 int GetNodeIndex(Node* node); 81 void GetNodesSidList(int* sidlist);82 void GetNodesLidList(int* lidlist);83 78 int GetNumberOfNodes(void); 84 79 int GetNumberOfNodesPressure(void); … … 102 97 void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type); 103 98 void GetVectorFromInputs(Vector<IssmDouble>* vector, int name_enum); 104 void GetVerticesCoordinates(IssmDouble** pxyz_list);105 99 void GetVerticesCoordinatesBase(IssmDouble** pxyz_list); 106 100 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list); 107 void InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code);108 101 void InputDepthAverageAtBase(int enum_type,int average_enum_type); 109 102 void InputDuplicate(int original_enum,int new_enum); … … 215 208 void GetMaterialInputValue(IssmDouble* pvalue,Node* node,int enumtype); 216 209 Node* GetNode(int node_number); 217 void InputChangeName(int enum_type,int enum_type_old);218 210 void InputUpdateFromSolutionOneDof(IssmDouble* solution,int enum_type); 219 211 void InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solution,int enum_type){_error_("not implemented yet");}; … … 232 224 Gauss* NewGaussLine(int vertex1,int vertex2,int order){_error_("not implemented yet");}; 233 225 Gauss* NewGaussTop(int order); 234 ElementVector* NewElementVector(int approximation_enum);235 ElementMatrix* NewElementMatrix(int approximation_enum);236 ElementMatrix* NewElementMatrixCoupling(int number_nodes,int approximation_enum){_error_("not implemented yet");};237 226 void NodalFunctions(IssmDouble* basis,Gauss* gauss); 238 227 void NodalFunctionsP1(IssmDouble* basis,Gauss* gauss){_error_("not implemented yet");}; -
issm/trunk-jpl/src/c/classes/classes.h
r17398 r17472 61 61 #include "./Inputs/DoubleInput.h" 62 62 #include "./Inputs/IntInput.h" 63 #include "./Inputs/TetraInput.h" 63 64 #include "./Inputs/PentaInput.h" 64 65 #include "./Inputs/TriaInput.h" -
issm/trunk-jpl/src/c/classes/gauss/GaussTetra.cpp
r17398 r17472 3 3 */ 4 4 5 #include <math.h> 5 6 #include "./GaussTetra.h" 6 7 #include "../../shared/io/Print/Print.h" … … 32 33 /*FUNCTION GaussTetra::GaussTetra(int order) {{{*/ 33 34 GaussTetra::GaussTetra(int order){ 34 _error_("not implemented yet"); 35 /*Get gauss points*/ 36 GaussLegendreTetra(&numgauss,&coords1,&coords2,&coords3,&coords4,&weights,order); 37 for(int i=0;i<numgauss;i++) this->weights[i]=this->weights[i]*sqrt(2.)/6.; //FIXME: double check that 38 39 /*Initialize static fields as undefinite*/ 40 weight=UNDEF; 41 coord1=UNDEF; 42 coord2=UNDEF; 43 coord3=UNDEF; 44 } 45 /*}}}*/ 46 /*FUNCTION GaussTetra::GaussTetra(int index1,int index2,int index3,int order) {{{*/ 47 GaussTetra::GaussTetra(int index1,int index2,int index3,int order){ 48 49 /*Basal Tria*/ 50 if(index1==0 && index2==1 && index3==2){ 51 GaussLegendreTria(&numgauss,&coords1,&coords2,&coords3,&weights,order); 52 coords4=xNew<IssmDouble>(numgauss); 53 for(int i=0;i<numgauss;i++) coords4[i]=0.; 54 } 55 else if(index1==0 && index2==1 && index3==3){ 56 GaussLegendreTria(&numgauss,&coords1,&coords2,&coords4,&weights,order); 57 coords3=xNew<IssmDouble>(numgauss); 58 for(int i=0;i<numgauss;i++) coords3[i]=0.; 59 } 60 else if(index1==1 && index2==2 && index3==3){ 61 GaussLegendreTria(&numgauss,&coords2,&coords3,&coords4,&weights,order); 62 coords1=xNew<IssmDouble>(numgauss); 63 for(int i=0;i<numgauss;i++) coords1[i]=0.; 64 } 65 else if(index1==2 && index2==0 && index3==3){ 66 GaussLegendreTria(&numgauss,&coords1,&coords3,&coords4,&weights,order); 67 coords2=xNew<IssmDouble>(numgauss); 68 for(int i=0;i<numgauss;i++) coords2[i]=0.; 69 } 70 else{ 71 _error_(index1 <<" "<<index2 <<" "<<index3 <<" Not supported yet"); 72 } 35 73 } 36 74 /*}}}*/ … … 119 157 /*update static arrays*/ 120 158 switch(iv){ 121 default: _error_("vertex index should be in [0 5]"); 159 case 0: coord1=1.; coord2=0.; coord3=0.; coord4=0.; break; 160 case 1: coord1=0.; coord2=1.; coord3=0.; coord4=0.; break; 161 case 2: coord1=0.; coord2=0.; coord3=1.; coord4=0.; break; 162 case 3: coord1=0.; coord2=0.; coord3=0.; coord4=1.; break; 163 default: _error_("vertex index should be in [0 3]"); 122 164 123 165 } … … 133 175 /*update static arrays*/ 134 176 switch(finiteelement){ 177 case P1Enum: case P1DGEnum: 178 switch(iv){ 179 case 0: coord1=1.; coord2=0.; coord3=0.; coord4=0.; break; 180 case 1: coord1=0.; coord2=1.; coord3=0.; coord4=0.; break; 181 case 2: coord1=0.; coord2=0.; coord3=1.; coord4=0.; break; 182 case 3: coord1=0.; coord2=0.; coord3=0.; coord4=1.; break; 183 default: _error_("node index should be in [0 3]"); 184 } 185 break; 135 186 default: _error_("Finite element "<<EnumToStringx(finiteelement)<<" not supported"); 136 187 } -
issm/trunk-jpl/src/c/classes/gauss/GaussTetra.h
r17398 r17472 31 31 GaussTetra(); 32 32 GaussTetra(int order); 33 GaussTetra(int index1,int index2,int index3,int order); 33 34 ~GaussTetra(); 34 35 -
issm/trunk-jpl/src/c/modules/MeshPartitionx/MeshPartitionx.h
r16328 r17472 33 33 switch(meshtype){ 34 34 case Mesh2DhorizontalEnum: 35 epart=xNew<int>(numberofelements);36 npart=xNew<int>(numberofnodes);37 index=xNew<int>(elements_width*numberofelements);38 for (i=0;i<numberofelements;i++){39 for (j=0;j<elements_width;j++){40 *(index+elements_width*i+j)=(*(elements+elements_width*i+j))-1; //-1 for C indexing in Metis41 }42 }43 44 /*Partition using Metis:*/45 if (num_procs>1){46 #ifdef _HAVE_METIS_47 METIS_PartMeshNodalPatch(&numberofelements,&numberofnodes, index, &etype, &numflag, &num_procs, &edgecut, epart, npart);48 #else49 _error_("metis has not beed installed. Cannot run with more than 1 cpu");50 #endif51 }52 else if (num_procs==1){53 /*METIS does not know how to deal with one cpu only!*/54 for (i=0;i<numberofelements;i++) epart[i]=0;55 for (i=0;i<numberofnodes;i++) npart[i]=0;56 }57 else _error_("At least one processor is required");58 break;59 35 case Mesh2DverticalEnum: 36 case Mesh3DtetrasEnum: 60 37 epart=xNew<int>(numberofelements); 61 38 npart=xNew<int>(numberofnodes); -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp
r17309 r17472 37 37 } 38 38 break; 39 case Mesh3DtetrasEnum: 40 for(i=0;i<iomodel->numberofelements;i++){ 41 if(iomodel->my_elements[i]) elements->AddObject(new Tetra(i+1,i,i,iomodel,nummodels)); 42 } 43 break; 39 44 case Mesh3DEnum: 40 45 iomodel->FetchData(2,MeshUpperelementsEnum,MeshLowerelementsEnum); … … 60 65 if(dakota_analysis) elements->InputDuplicate(MaterialsRheologyBbarEnum,QmuMaterialsRheologyBEnum); 61 66 break; 62 case Mesh3DEnum: 67 case Mesh3DEnum: case Mesh3DtetrasEnum: 63 68 if(dakota_analysis) elements->InputDuplicate(MaterialsRheologyBEnum,QmuMaterialsRheologyBEnum); 64 69 break; -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateNumberNodeToElementConnectivity.cpp
r16336 r17472 39 39 case Mesh2DhorizontalEnum: elementswidth=3; break; 40 40 case Mesh2DverticalEnum: elementswidth=3; break; 41 case Mesh3DtetrasEnum: elementswidth=4; break; 41 42 case Mesh3DEnum: elementswidth=6; break; 42 43 default: _error_("mesh not supported yet"); -
issm/trunk-jpl/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
r16539 r17472 60 60 case Mesh2DverticalEnum: 61 61 elements_width=3; 62 numberofelements2d = 0; 63 numberofvertices2d = 0; 64 numlayers = 0; 65 break; 66 case Mesh3DtetrasEnum: 67 elements_width=4; //penta elements 62 68 numberofelements2d = 0; 63 69 numberofvertices2d = 0; -
issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
r17459 r17472 215 215 Mesh2DverticalEnum, 216 216 Mesh3DEnum, 217 Mesh3DtetrasEnum, 217 218 MiscellaneousNameEnum, //FIXME: only used by qmu, should not be marshalled (already in queueing script) 218 219 MasstransportHydrostaticAdjustmentEnum, -
issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp
r17459 r17472 223 223 case Mesh2DverticalEnum : return "Mesh2Dvertical"; 224 224 case Mesh3DEnum : return "Mesh3D"; 225 case Mesh3DtetrasEnum : return "Mesh3Dtetras"; 225 226 case MiscellaneousNameEnum : return "MiscellaneousName"; 226 227 case MasstransportHydrostaticAdjustmentEnum : return "MasstransportHydrostaticAdjustment"; -
issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp
r17459 r17472 226 226 else if (strcmp(name,"Mesh2Dvertical")==0) return Mesh2DverticalEnum; 227 227 else if (strcmp(name,"Mesh3D")==0) return Mesh3DEnum; 228 else if (strcmp(name,"Mesh3Dtetras")==0) return Mesh3DtetrasEnum; 228 229 else if (strcmp(name,"MiscellaneousName")==0) return MiscellaneousNameEnum; 229 230 else if (strcmp(name,"MasstransportHydrostaticAdjustment")==0) return MasstransportHydrostaticAdjustmentEnum; … … 259 260 else if (strcmp(name,"ProfilingSolutionTime")==0) return ProfilingSolutionTimeEnum; 260 261 else if (strcmp(name,"MaxIterationConvergenceFlag")==0) return MaxIterationConvergenceFlagEnum; 261 else if (strcmp(name,"SteadystateMaxiter")==0) return SteadystateMaxiterEnum;262 262 else stage=3; 263 263 } 264 264 if(stage==3){ 265 if (strcmp(name,"SteadystateNumRequestedOutputs")==0) return SteadystateNumRequestedOutputsEnum; 265 if (strcmp(name,"SteadystateMaxiter")==0) return SteadystateMaxiterEnum; 266 else if (strcmp(name,"SteadystateNumRequestedOutputs")==0) return SteadystateNumRequestedOutputsEnum; 266 267 else if (strcmp(name,"SteadystateReltol")==0) return SteadystateReltolEnum; 267 268 else if (strcmp(name,"SteadystateRequestedOutputs")==0) return SteadystateRequestedOutputsEnum; … … 382 383 else if (strcmp(name,"Materials")==0) return MaterialsEnum; 383 384 else if (strcmp(name,"Nodes")==0) return NodesEnum; 384 else if (strcmp(name,"Contours")==0) return ContoursEnum;385 385 else stage=4; 386 386 } 387 387 if(stage==4){ 388 if (strcmp(name,"Parameters")==0) return ParametersEnum; 388 if (strcmp(name,"Contours")==0) return ContoursEnum; 389 else if (strcmp(name,"Parameters")==0) return ParametersEnum; 389 390 else if (strcmp(name,"Vertices")==0) return VerticesEnum; 390 391 else if (strcmp(name,"Results")==0) return ResultsEnum; … … 505 506 else if (strcmp(name,"Vz")==0) return VzEnum; 506 507 else if (strcmp(name,"VzSSA")==0) return VzSSAEnum; 507 else if (strcmp(name,"VzHO")==0) return VzHOEnum;508 508 else stage=5; 509 509 } 510 510 if(stage==5){ 511 if (strcmp(name,"VzPicard")==0) return VzPicardEnum; 511 if (strcmp(name,"VzHO")==0) return VzHOEnum; 512 else if (strcmp(name,"VzPicard")==0) return VzPicardEnum; 512 513 else if (strcmp(name,"VzFS")==0) return VzFSEnum; 513 514 else if (strcmp(name,"VxMesh")==0) return VxMeshEnum; … … 628 629 else if (strcmp(name,"LockFileName")==0) return LockFileNameEnum; 629 630 else if (strcmp(name,"ToolkitsOptionsAnalyses")==0) return ToolkitsOptionsAnalysesEnum; 630 else if (strcmp(name,"ToolkitsOptionsStrings")==0) return ToolkitsOptionsStringsEnum;631 631 else stage=6; 632 632 } 633 633 if(stage==6){ 634 if (strcmp(name,"QmuErrName")==0) return QmuErrNameEnum; 634 if (strcmp(name,"ToolkitsOptionsStrings")==0) return ToolkitsOptionsStringsEnum; 635 else if (strcmp(name,"QmuErrName")==0) return QmuErrNameEnum; 635 636 else if (strcmp(name,"QmuInName")==0) return QmuInNameEnum; 636 637 else if (strcmp(name,"QmuOutName")==0) return QmuOutNameEnum;
Note:
See TracChangeset
for help on using the changeset viewer.