Changeset 16827
- Timestamp:
- 11/19/13 08:30:16 (11 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp
r16818 r16827 844 844 845 845 /*compute all stiffness matrices for this element*/ 846 ElementMatrix* Ke1=CreateKMatrixSSAViscous( element);847 ElementMatrix* Ke2=CreateKMatrixSSAFriction( element);846 ElementMatrix* Ke1=CreateKMatrixSSAViscous(basalelement); 847 ElementMatrix* Ke2=CreateKMatrixSSAFriction(basalelement); 848 848 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2); 849 849 -
issm/trunk-jpl/src/c/analyses/StressbalanceVerticalAnalysis.cpp
r16804 r16827 97 97 /*Finite Element Analysis*/ 98 98 ElementMatrix* StressbalanceVerticalAnalysis::CreateKMatrix(Element* element){/*{{{*/ 99 _error_("not implemented yet"); 99 100 /*compute all stiffness matrices for this element*/ 101 ElementMatrix* Ke1=CreateKMatrixVolume(element); 102 ElementMatrix* Ke2=CreateKMatrixSurface(element); 103 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2); 104 //Ke1->Echo(); 105 //Ke2->Echo(); 106 //Ke=element->CreateKMatrix(); 107 //_error_("S"); 108 109 /*clean-up and return*/ 110 delete Ke1; 111 delete Ke2; 112 return Ke; 113 114 }/*}}}*/ 115 ElementMatrix* StressbalanceVerticalAnalysis::CreateKMatrixVolume(Element* element){/*{{{*/ 116 117 /*Intermediaries*/ 118 IssmDouble D,Jdet; 119 IssmDouble *xyz_list = NULL; 120 121 /*Fetch number of nodes and dof for this finite element*/ 122 int numnodes = element->GetNumberOfNodes(); 123 124 /*Initialize Element matrix and vectors*/ 125 ElementMatrix* Ke = element->NewElementMatrix(NoneApproximationEnum); 126 IssmDouble* B = xNew<IssmDouble>(numnodes); 127 IssmDouble* Bprime = xNew<IssmDouble>(numnodes); 128 129 /*Retrieve all inputs and parameters*/ 130 element->GetVerticesCoordinates(&xyz_list); 131 132 /* Start looping on the number of gaussian points: */ 133 Gauss* gauss = element->NewGauss(2); 134 for(int ig=gauss->begin();ig<gauss->end();ig++){ 135 gauss->GaussPoint(ig); 136 137 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 138 this->GetB(B,element,xyz_list,gauss); 139 this->GetBprime(Bprime,element,xyz_list,gauss); 140 D=gauss->weight*Jdet; 141 142 TripleMultiply(B,1,numnodes,1, 143 &D,1,1,0, 144 Bprime,1,numnodes,0, 145 &Ke->values[0],1); 146 } 147 148 /*Clean up and return*/ 149 delete gauss; 150 xDelete<IssmDouble>(xyz_list); 151 xDelete<IssmDouble>(Bprime); 152 xDelete<IssmDouble>(B); 153 return Ke; 154 155 }/*}}}*/ 156 ElementMatrix* StressbalanceVerticalAnalysis::CreateKMatrixSurface(Element* element){/*{{{*/ 157 158 159 if(!element->IsOnSurface()) return NULL; 160 161 /*Intermediaries*/ 162 IssmDouble D,Jdet,normal[3]; 163 IssmDouble *xyz_list = NULL; 164 165 /*Fetch number of nodes and dof for this finite element*/ 166 int numnodes = element->GetNumberOfNodes(); 167 168 /*Initialize Element matrix and vectors*/ 169 ElementMatrix* Ke = element->NewElementMatrix(NoneApproximationEnum); 170 IssmDouble* basis = xNew<IssmDouble>(numnodes); 171 172 /*Retrieve all inputs and parameters*/ 173 element->GetVerticesCoordinatesTop(&xyz_list); 174 175 /* Start looping on the number of gaussian points: */ 176 Gauss* gauss = element->NewGaussTop(2); 177 element->NormalTop(&normal[0],xyz_list); 178 for(int ig=gauss->begin();ig<gauss->end();ig++){ 179 gauss->GaussPoint(ig); 180 181 element->JacobianDeterminantTop(&Jdet,xyz_list,gauss); 182 element->NodalFunctions(basis,gauss); 183 D = -gauss->weight*Jdet*normal[2]; 184 185 TripleMultiply( basis,1,numnodes,1, 186 &D,1,1,0, 187 basis,1,numnodes,0, 188 &Ke->values[0],1); 189 } 190 191 /*Clean up and return*/ 192 delete gauss; 193 xDelete<IssmDouble>(xyz_list); 194 xDelete<IssmDouble>(basis); 195 return Ke; 100 196 }/*}}}*/ 101 197 ElementVector* StressbalanceVerticalAnalysis::CreatePVector(Element* element){/*{{{*/ … … 221 317 xDelete<IssmDouble>(xyz_list_base); 222 318 return pe; 319 }/*}}}*/ 320 void StressbalanceVerticalAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 321 /* Compute B matrix. B=[dh1/dz dh2/dz dh3/dz dh4/dz dh5/dz dh6/dz]; 322 where hi is the interpolation function for node i.*/ 323 324 /*Fetch number of nodes for this finite element*/ 325 int numnodes = element->GetNumberOfNodes(); 326 327 /*Get nodal functions derivatives*/ 328 IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes); 329 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 330 331 /*Build B: */ 332 for(int i=0;i<numnodes;i++){ 333 B[i] = dbasis[2*numnodes+i]; 334 } 335 336 /*Clean-up*/ 337 xDelete<IssmDouble>(dbasis); 338 }/*}}}*/ 339 void StressbalanceVerticalAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 340 341 element->NodalFunctions(Bprime,gauss); 342 223 343 }/*}}}*/ 224 344 void StressbalanceVerticalAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ -
issm/trunk-jpl/src/c/analyses/StressbalanceVerticalAnalysis.h
r16803 r16827 22 22 /*Finite element Analysis*/ 23 23 ElementMatrix* CreateKMatrix(Element* element); 24 ElementMatrix* CreateKMatrixVolume(Element* element); 25 ElementMatrix* CreateKMatrixSurface(Element* element); 24 26 ElementVector* CreatePVector(Element* element); 25 27 ElementVector* CreatePVectorVolume(Element* element); 26 28 ElementVector* CreatePVectorBase(Element* element); 29 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 30 void GetBprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 27 31 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 28 32 void InputUpdateFromSolution(IssmDouble* solution,Element* element); -
issm/trunk-jpl/src/c/classes/Elements/Element.h
r16818 r16827 61 61 virtual void NodalFunctionsPressure(IssmDouble* basis,Gauss* gauss)=0; 62 62 virtual void NormalBase(IssmDouble* normal,IssmDouble* xyz_list)=0; 63 virtual void NormalTop(IssmDouble* normal,IssmDouble* xyz_list)=0; 63 64 virtual IssmDouble PureIceEnthalpy(IssmDouble pressure)=0; 64 65 virtual void TransformLoadVectorCoord(ElementVector* pe,int transformenum)=0; … … 80 81 virtual void JacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss)=0; 81 82 virtual void JacobianDeterminantBase(IssmDouble* Jdet,IssmDouble* xyz_list_base,Gauss* gauss)=0; 83 virtual void JacobianDeterminantTop(IssmDouble* Jdet,IssmDouble* xyz_list_base,Gauss* gauss)=0; 82 84 virtual void GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int solutionenum)=0; 83 85 virtual int GetNodeIndex(Node* node)=0; … … 93 95 virtual bool IsNodeOnShelfFromFlags(IssmDouble* flags)=0; 94 96 virtual bool IsOnBed()=0; 97 virtual bool IsOnSurface()=0; 95 98 virtual void GetInputListOnNodes(IssmDouble* pvalue,int enumtype)=0; 96 99 virtual void GetInputListOnNodes(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue)=0; … … 104 107 virtual void GetVerticesCoordinates(IssmDouble** xyz_list)=0; 105 108 virtual void GetVerticesCoordinatesBase(IssmDouble** xyz_list)=0; 109 virtual void GetVerticesCoordinatesTop(IssmDouble** xyz_list)=0; 106 110 virtual void GetMaterialInputValue(IssmDouble* pvalue,Node* node,int enumtype)=0; 107 111 … … 125 129 virtual Gauss* NewGauss(int order)=0; 126 130 virtual Gauss* NewGaussBase(int order)=0; 131 virtual Gauss* NewGaussTop(int order)=0; 127 132 virtual ElementVector* NewElementVector(int approximation_enum=NoneApproximationEnum)=0; 128 133 virtual ElementMatrix* NewElementMatrix(int approximation_enum=NoneApproximationEnum)=0; -
issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
r16826 r16827 162 162 /*}}}*/ 163 163 164 /*FUNCTION Penta::NormalBase {{{*/165 void Penta::NormalBase(IssmDouble* bed_normal,IssmDouble* xyz_list){166 167 int i;168 IssmDouble v13[3],v23[3];169 IssmDouble normal[3];170 IssmDouble normal_norm;171 172 for (i=0;i<3;i++){173 v13[i]=xyz_list[0*3+i]-xyz_list[2*3+i];174 v23[i]=xyz_list[1*3+i]-xyz_list[2*3+i];175 }176 177 normal[0]=v13[1]*v23[2]-v13[2]*v23[1];178 normal[1]=v13[2]*v23[0]-v13[0]*v23[2];179 normal[2]=v13[0]*v23[1]-v13[1]*v23[0];180 normal_norm=sqrt( pow(normal[0],2)+pow(normal[1],2)+pow(normal[2],2) );181 182 /*Bed normal is opposite to surface normal*/183 bed_normal[0]=-normal[0]/normal_norm;184 bed_normal[1]=-normal[1]/normal_norm;185 bed_normal[2]=-normal[2]/normal_norm;186 }187 /*}}}*/188 164 /*FUNCTION Penta::BasalFrictionCreateInput {{{*/ 189 165 void Penta::BasalFrictionCreateInput(void){ … … 1466 1442 1467 1443 }/*}}}*/ 1444 /*FUNCTION Penta::GetVerticesCoordinatesTop(IssmDouble** pxyz_list){{{*/ 1445 void Penta::GetVerticesCoordinatesTop(IssmDouble** pxyz_list){ 1446 1447 IssmDouble* xyz_list = xNew<IssmDouble>(NUMVERTICES2D*3); 1448 ::GetVerticesCoordinates(xyz_list,&this->vertices[3],NUMVERTICES2D); 1449 1450 /*Assign output pointer*/ 1451 *pxyz_list = xyz_list; 1452 1453 }/*}}}*/ 1468 1454 /*FUNCTION Penta::GetMaterialInputValue(IssmDouble* pvalue,Node* node,int enumtype) {{{*/ 1469 1455 void Penta::GetMaterialInputValue(IssmDouble* pvalue,Node* node,int enumtype){ … … 2334 2320 inputs->GetInputValue(&onbed,MeshElementonbedEnum); 2335 2321 return onbed; 2322 } 2323 /*}}}*/ 2324 /*FUNCTION Penta::IsOnSurface{{{*/ 2325 bool Penta::IsOnSurface(void){ 2326 2327 bool onsurface; 2328 inputs->GetInputValue(&onsurface,MeshElementonsurfaceEnum); 2329 return onsurface; 2336 2330 } 2337 2331 /*}}}*/ … … 2436 2430 } 2437 2431 /*}}}*/ 2438 /*FUNCTION Penta::IsOnSurface{{{*/2439 bool Penta::IsOnSurface(void){2440 2441 bool onsurface;2442 inputs->GetInputValue(&onsurface,MeshElementonsurfaceEnum);2443 return onsurface;2444 }2445 /*}}}*/2446 2432 /*FUNCTION Penta::JacobianDeterminant{{{*/ 2447 2433 void Penta::JacobianDeterminant(IssmDouble* pJdet,IssmDouble* xyz_list,Gauss* gauss){ … … 2457 2443 _assert_(gauss->Enum()==GaussPentaEnum); 2458 2444 this->GetTriaJacobianDeterminant(pJdet,xyz_list_base,(GaussPenta*)gauss); 2445 2446 } 2447 /*}}}*/ 2448 /*FUNCTION Penta::JacobianDeterminantTop{{{*/ 2449 void Penta::JacobianDeterminantTop(IssmDouble* pJdet,IssmDouble* xyz_list_top,Gauss* gauss){ 2450 2451 _assert_(gauss->Enum()==GaussPentaEnum); 2452 this->GetTriaJacobianDeterminant(pJdet,xyz_list_top,(GaussPenta*)gauss); 2459 2453 2460 2454 } … … 2543 2537 } 2544 2538 /*}}}*/ 2539 /*FUNCTION Penta::NewGaussTop(int order){{{*/ 2540 Gauss* Penta::NewGaussTop(int order){ 2541 return new GaussPenta(3,4,5,order); 2542 } 2543 /*}}}*/ 2545 2544 /*FUNCTION Penta::NewElementVector{{{*/ 2546 2545 ElementVector* Penta::NewElementVector(int approximation_enum){ … … 2583 2582 this->GetNodalFunctionsPressure(basis,(GaussPenta*)gauss); 2584 2583 2584 } 2585 /*}}}*/ 2586 /*FUNCTION Penta::NormalBase {{{*/ 2587 void Penta::NormalBase(IssmDouble* bed_normal,IssmDouble* xyz_list){ 2588 2589 int i; 2590 IssmDouble v13[3],v23[3]; 2591 IssmDouble normal[3]; 2592 IssmDouble normal_norm; 2593 2594 for (i=0;i<3;i++){ 2595 v13[i]=xyz_list[0*3+i]-xyz_list[2*3+i]; 2596 v23[i]=xyz_list[1*3+i]-xyz_list[2*3+i]; 2597 } 2598 2599 normal[0]=v13[1]*v23[2]-v13[2]*v23[1]; 2600 normal[1]=v13[2]*v23[0]-v13[0]*v23[2]; 2601 normal[2]=v13[0]*v23[1]-v13[1]*v23[0]; 2602 normal_norm=sqrt( pow(normal[0],2)+pow(normal[1],2)+pow(normal[2],2) ); 2603 2604 /*Bed normal is opposite to surface normal*/ 2605 bed_normal[0]=-normal[0]/normal_norm; 2606 bed_normal[1]=-normal[1]/normal_norm; 2607 bed_normal[2]=-normal[2]/normal_norm; 2608 } 2609 /*}}}*/ 2610 /*FUNCTION Penta::NormalTop {{{*/ 2611 void Penta::NormalTop(IssmDouble* top_normal,IssmDouble* xyz_list){ 2612 2613 int i; 2614 IssmDouble v13[3],v23[3]; 2615 IssmDouble normal[3]; 2616 IssmDouble normal_norm; 2617 2618 for (i=0;i<3;i++){ 2619 v13[i]=xyz_list[0*3+i]-xyz_list[2*3+i]; 2620 v23[i]=xyz_list[1*3+i]-xyz_list[2*3+i]; 2621 } 2622 2623 normal[0]=v13[1]*v23[2]-v13[2]*v23[1]; 2624 normal[1]=v13[2]*v23[0]-v13[0]*v23[2]; 2625 normal[2]=v13[0]*v23[1]-v13[1]*v23[0]; 2626 normal_norm=sqrt(normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2]); 2627 2628 top_normal[0]=normal[0]/normal_norm; 2629 top_normal[1]=normal[1]/normal_norm; 2630 top_normal[2]=normal[2]/normal_norm; 2585 2631 } 2586 2632 /*}}}*/ … … 2954 3000 2955 3001 _assert_(this->IsOnBed()); 3002 3003 this->InputDepthAverageAtBase(MaterialsRheologyBEnum,MaterialsRheologyBbarEnum,MaterialsEnum); 3004 this->InputDepthAverageAtBase(DamageDEnum,DamageDbarEnum,MaterialsEnum); 2956 3005 Tria* tria=(Tria*)SpawnTria(0); //lower face is 0, upper face is 1. 3006 this->material->inputs->DeleteInput(MaterialsRheologyBbarEnum); 3007 this->material->inputs->DeleteInput(DamageDbarEnum); 3008 2957 3009 return tria; 2958 3010 } -
issm/trunk-jpl/src/c/classes/Elements/Penta.h
r16818 r16827 100 100 void GetVerticesCoordinates(IssmDouble** pxyz_list); 101 101 void GetVerticesCoordinatesBase(IssmDouble** pxyz_list); 102 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list); 102 103 103 104 int Sid(); … … 195 196 void AddMaterialInput(int input_enum, IssmDouble* values, int interpolation_enum); 196 197 void NormalBase(IssmDouble* bed_normal, IssmDouble* xyz_list); 198 void NormalTop(IssmDouble* bed_normal, IssmDouble* xyz_list); 197 199 ElementMatrix* CreateBasalMassMatrix(void); 198 200 ElementMatrix* CreateKMatrix(void); … … 244 246 void JacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss); 245 247 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss); 248 void JacobianDeterminantTop(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss); 246 249 bool NoIceInElement(void); 247 250 Gauss* NewGauss(void); 248 251 Gauss* NewGauss(int order); 249 252 Gauss* NewGaussBase(int order); 253 Gauss* NewGaussTop(int order); 250 254 ElementVector* NewElementVector(int approximation_enum); 251 255 ElementMatrix* NewElementMatrix(int approximation_enum); -
issm/trunk-jpl/src/c/classes/Elements/Seg.h
r16818 r16827 105 105 void GetVerticesCoordinates(IssmDouble** pxyz_list){_error_("not implemented yet");}; 106 106 void GetVerticesCoordinatesBase(IssmDouble** pxyz_list){_error_("not implemented yet");}; 107 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list){_error_("not implemented yet");}; 107 108 int Sid(){_error_("not implemented yet");}; 108 109 void InputChangeName(int input_enum, int enum_type_old){_error_("not implemented yet");}; 109 110 bool IsOnBed(){_error_("not implemented yet");}; 111 bool IsOnSurface(){_error_("not implemented yet");}; 110 112 bool IsFloating(){_error_("not implemented yet");}; 111 113 bool IsNodeOnShelfFromFlags(IssmDouble* flags){_error_("not implemented yet");}; 112 114 void JacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");}; 113 115 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss){_error_("not implemented yet");}; 116 void JacobianDeterminantTop(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss){_error_("not implemented yet");}; 114 117 IssmDouble MinEdgeLength(IssmDouble* xyz_list){_error_("not implemented yet");}; 115 118 void NodalFunctions(IssmDouble* basis,Gauss* gauss){_error_("not implemented yet");}; … … 119 122 bool NoIceInElement(){_error_("not implemented yet");}; 120 123 void NormalBase(IssmDouble* normal,IssmDouble* xyz_list){_error_("not implemented yet");}; 124 void NormalTop(IssmDouble* normal,IssmDouble* xyz_list){_error_("not implemented yet");}; 121 125 int NumberofNodesVelocity(void){_error_("not implemented yet");}; 122 126 int NumberofNodesPressure(void){_error_("not implemented yet");}; … … 137 141 Gauss* NewGauss(int order){_error_("not implemented yet");}; 138 142 Gauss* NewGaussBase(int order){_error_("not implemented yet");}; 143 Gauss* NewGaussTop(int order){_error_("not implemented yet");}; 139 144 ElementVector* NewElementVector(int approximation_enum){_error_("not implemented yet");}; 140 145 ElementMatrix* NewElementMatrix(int approximation_enum){_error_("not implemented yet");}; -
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r16824 r16827 1980 1980 case Mesh2DverticalEnum: 1981 1981 return HasEdgeOnBed(); 1982 case Mesh2DhorizontalEnum: 1983 return true; 1984 default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet"); 1985 } 1986 } 1987 /*}}}*/ 1988 /*FUNCTION Tria::IsOnSurface {{{*/ 1989 bool Tria::IsOnSurface(){ 1990 1991 int meshtype; 1992 this->parameters->FindParam(&meshtype,MeshTypeEnum); 1993 switch(meshtype){ 1994 case Mesh2DverticalEnum: 1995 return HasEdgeOnSurface(); 1982 1996 case Mesh2DhorizontalEnum: 1983 1997 return true; -
issm/trunk-jpl/src/c/classes/Elements/Tria.h
r16818 r16827 95 95 int Sid(); 96 96 bool IsOnBed(); 97 bool IsOnSurface(); 97 98 bool HasEdgeOnBed(); 98 99 bool HasNodeOnBed(); … … 112 113 void GetVerticesCoordinates(IssmDouble** pxyz_list); 113 114 void GetVerticesCoordinatesBase(IssmDouble** pxyz_list){_error_("not implemented yet");}; 115 void GetVerticesCoordinatesTop(IssmDouble** pxyz_list){_error_("not implemented yet");}; 114 116 void InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code); 115 117 void InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum=MeshElementsEnum); … … 253 255 IssmDouble GetGroundedPortion(IssmDouble* xyz_list); 254 256 void NormalBase(IssmDouble* normal,IssmDouble* xyz_list); 257 void NormalTop(IssmDouble* normal,IssmDouble* xyz_list){_error_("not implemented yet");}; 255 258 IssmDouble GetMaterialParameter(int enum_in); 256 259 void GetZeroLevelsetCoordinates(IssmDouble* xyz_zero,IssmDouble xyz_list[3][3],int levelsetenum); … … 273 276 void JacobianDeterminant(IssmDouble* pJdet, IssmDouble* xyz_list,Gauss* gauss); 274 277 void JacobianDeterminantBase(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss){_error_("not implemented yet");}; 278 void JacobianDeterminantTop(IssmDouble* pJdet,IssmDouble* xyz_list_base,Gauss* gauss){_error_("not implemented yet");}; 275 279 IssmDouble MinEdgeLength(IssmDouble* xyz_list){_error_("not implemented yet");}; 276 280 Gauss* NewGauss(void); 277 281 Gauss* NewGauss(int order); 278 282 Gauss* NewGaussBase(int order){_error_("not implemented yet");}; 283 Gauss* NewGaussTop(int order){_error_("not implemented yet");}; 279 284 ElementVector* NewElementVector(int approximation_enum); 280 285 ElementMatrix* NewElementMatrix(int approximation_enum);
Note:
See TracChangeset
for help on using the changeset viewer.