Changeset 25262
- Timestamp:
- 07/10/20 20:49:27 (5 years ago)
- Location:
- issm/trunk-jpl/src/c/analyses
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/analyses/BalancethicknessAnalysis.cpp
r25118 r25262 264 264 /*Initialize Element vector and other vectors*/ 265 265 ElementMatrix* Ke = element->NewElementMatrix(); 266 IssmDouble* B = xNew<IssmDouble>(2*numnodes);267 IssmDouble* Bprime= xNew<IssmDouble>(2*numnodes);266 IssmDouble* basis = xNew<IssmDouble>(numnodes); 267 IssmDouble* dbasis = xNew<IssmDouble>(2*numnodes); 268 268 IssmDouble D[2][2]; 269 269 … … 288 288 289 289 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 290 element->NodalFunctions(basis,gauss); 291 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 290 292 vxaverage_input->GetInputValue(&vx,gauss); 291 293 vyaverage_input->GetInputValue(&vy,gauss); … … 294 296 D_scalar=gauss->weight*Jdet; 295 297 296 /*WARNING: B and Bprime are inverted compared to CG*/ 297 GetB(Bprime,element,xyz_list,gauss); 298 GetBprime(B,element,xyz_list,gauss); 299 298 /*WARNING: inverted compared to CG*/ 300 299 D_scalar = - gauss->weight*Jdet; 301 300 D[0][0] = D_scalar*vx; … … 303 302 D[1][0] = 0.; 304 303 D[1][1] = D_scalar*vy; 305 TripleMultiply(B,2,numnodes,1, 306 &D[0][0],2,2,0, 307 Bprime,2,numnodes,0, 308 &Ke->values[0],1); 309 304 for(int i=0;i<numnodes;i++){ 305 for(int j=0;j<numnodes;j++){ 306 Ke->values[i*numnodes+j] += D_scalar*basis[i]*basis[j]*(dvxdx+dvydy); 307 Ke->values[i*numnodes+j] += D_scalar*basis[j]*(vx*dbasis[0*numnodes+i] + vy*dbasis[1*numnodes+i]); 308 } 309 } 310 310 } 311 311 312 312 /*Clean up and return*/ 313 313 xDelete<IssmDouble>(xyz_list); 314 xDelete<IssmDouble>( B);315 xDelete<IssmDouble>( Bprime);314 xDelete<IssmDouble>(basis); 315 xDelete<IssmDouble>(dbasis); 316 316 delete gauss; 317 317 return Ke; … … 420 420 delete gauss; 421 421 return pe; 422 }/*}}}*/423 void BalancethicknessAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/424 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*2.425 * For node i, Bi can be expressed in the actual coordinate system426 * by:427 * Bi=[ N ]428 * [ N ]429 * where N is the finiteelement function for node i.430 *431 * We assume B_prog has been allocated already, of size: 2x(1*numnodes)432 */433 434 /*Fetch number of nodes for this finite element*/435 int numnodes = element->GetNumberOfNodes();436 437 /*Get nodal functions*/438 IssmDouble* basis=xNew<IssmDouble>(numnodes);439 element->NodalFunctions(basis,gauss);440 441 /*Build B: */442 for(int i=0;i<numnodes;i++){443 B[numnodes*0+i] = basis[i];444 B[numnodes*1+i] = basis[i];445 }446 447 /*Clean-up*/448 xDelete<IssmDouble>(basis);449 }/*}}}*/450 void BalancethicknessAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/451 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*2.452 * For node i, Bi' can be expressed in the actual coordinate system453 * by:454 * Bi_prime=[ dN/dx ]455 * [ dN/dy ]456 * where N is the finiteelement function for node i.457 *458 * We assume B' has been allocated already, of size: 3x(2*numnodes)459 */460 461 /*Fetch number of nodes for this finite element*/462 int numnodes = element->GetNumberOfNodes();463 464 /*Get nodal functions derivatives*/465 IssmDouble* dbasis=xNew<IssmDouble>(2*numnodes);466 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss);467 468 /*Build B': */469 for(int i=0;i<numnodes;i++){470 Bprime[numnodes*0+i] = dbasis[0*numnodes+i];471 Bprime[numnodes*1+i] = dbasis[1*numnodes+i];472 }473 474 /*Clean-up*/475 xDelete<IssmDouble>(dbasis);476 477 422 }/*}}}*/ 478 423 void BalancethicknessAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ -
issm/trunk-jpl/src/c/analyses/BalancethicknessAnalysis.h
r24335 r25262 30 30 ElementVector* CreatePVectorCG(Element* element); 31 31 ElementVector* CreatePVectorDG(Element* element); 32 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss);33 void GetBprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss);34 32 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 35 33 void GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index); -
issm/trunk-jpl/src/c/analyses/GLheightadvectionAnalysis.cpp
r25237 r25262 109 109 basalelement->NodalFunctions(basis,gauss); 110 110 basalelement->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 111 GetBprime(Bprime,basalelement,dim,xyz_list,gauss);112 111 113 112 /*Get velocity*/ … … 161 160 D[0][0]=D_scalar*h/(2.*vel)*fabs(vx*vx); D[0][1]=D_scalar*h/(2.*vel)*fabs(vx*vy); 162 161 D[1][0]=D_scalar*h/(2.*vel)*fabs(vy*vx); D[1][1]=D_scalar*h/(2.*vel)*fabs(vy*vy); 163 TripleMultiply(Bprime,dim,numnodes,1, 164 &D[0][0],2,2,0, 165 Bprime,dim,numnodes,0, 166 &Ke->values[0],1); 162 for(int i=0;i<numnodes;i++){ 163 for(int j=0;j<numnodes;j++){ 164 Ke->values[i*numnodes+j] += ( 165 dbasis[0*numnodes+i] *(D[0][0]*dbasis[0*numnodes+j] + D[0][1]*dbasis[1*numnodes+j]) + 166 dbasis[1*numnodes+i] *(D[1][0]*dbasis[0*numnodes+j] + D[1][1]*dbasis[1*numnodes+j]) 167 ); 168 } 169 } 167 170 } 168 171 } … … 172 175 xDelete<IssmDouble>(basis); 173 176 xDelete<IssmDouble>(dbasis); 174 xDelete<IssmDouble>(Bprime);175 177 delete gauss; 176 178 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; … … 235 237 return; 236 238 }/*}}}*/ 237 238 void GLheightadvectionAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/239 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*2.240 * For node i, Bi can be expressed in the actual coordinate system241 * by:242 * Bi=[ N ]243 * [ N ]244 * where N is the finiteelement function for node i.245 *246 * We assume B_prog has been allocated already, of size: 2x(1*numnodes)247 */248 249 /*Fetch number of nodes for this finite element*/250 int numnodes = element->GetNumberOfNodes();251 252 /*Get nodal functions*/253 IssmDouble* basis=xNew<IssmDouble>(numnodes);254 element->NodalFunctions(basis,gauss);255 256 /*Build B: */257 for(int i=0;i<numnodes;i++){258 for(int j=0;j<dim;j++){259 B[numnodes*j+i] = basis[i];260 }261 }262 263 /*Clean-up*/264 xDelete<IssmDouble>(basis);265 }/*}}}*/266 void GLheightadvectionAnalysis::GetBprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/267 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*2.268 * For node i, Bi' can be expressed in the actual coordinate system269 * by:270 * Bi_prime=[ dN/dx ]271 * [ dN/dy ]272 * where N is the finiteelement function for node i.273 *274 * We assume B' has been allocated already, of size: 3x(2*numnodes)275 */276 277 /*Fetch number of nodes for this finite element*/278 int numnodes = element->GetNumberOfNodes();279 280 /*Get nodal functions derivatives*/281 IssmDouble* dbasis=xNew<IssmDouble>(dim*numnodes);282 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss);283 284 /*Build B': */285 for(int i=0;i<numnodes;i++){286 for(int j=0;j<dim;j++){287 Bprime[numnodes*j+i] = dbasis[j*numnodes+i];288 }289 }290 291 /*Clean-up*/292 xDelete<IssmDouble>(dbasis);293 294 }/*}}}*/ -
issm/trunk-jpl/src/c/analyses/GLheightadvectionAnalysis.h
r24335 r25262 30 30 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 31 31 void UpdateConstraints(FemModel* femmodel); 32 33 void GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss);34 void GetBprime(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss);35 32 }; 36 33 #endif
Note:
See TracChangeset
for help on using the changeset viewer.