Changeset 27035 for issm/trunk/src
- Timestamp:
- 06/01/22 05:01:48 (3 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 deleted
- 215 edited
- 17 copied
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:mergeinfo changed
/issm/trunk-jpl merged: 26745-26955,26957-27031
- Property svn:mergeinfo changed
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/c/Makefile.am
r26744 r27035 1 AM_CPPFLAGS = @NEOPZINCL@ @DAKOTAINCL@ @SHAPELIBINCL@ @TRIANGLEINCL@ @PETSCINCL@ @SLEPCINCL@ @AMPIINCL@ @ADJOINTMPIINCL@ @MEDIPACKINCL@ @MPIINCL@ @PARMETISINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @CODIPACKINCL@ @GSLINCL@ @BOOSTINCL@ @ANDROID_NDKINCL@ @METEOIOINCL@ @SNOWPACKINCL@ @PROJINCL@ @ESMFINCL@ @PROJINCL@ 1 AM_CPPFLAGS = @NEOPZINCL@ @DAKOTAINCL@ @SHAPELIBINCL@ @TRIANGLEINCL@ @PETSCINCL@ @SLEPCINCL@ @AMPIINCL@ @ADJOINTMPIINCL@ @MEDIPACKINCL@ @MPIINCL@ @PARMETISINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @CODIPACKINCL@ @GSLINCL@ @BOOSTINCL@ @ANDROID_NDKINCL@ @METEOIOINCL@ @SNOWPACKINCL@ @PROJINCL@ @ESMFINCL@ @PROJINCL@ @MPLAPACKINCL@ 2 2 AM_FCFLAGS = @SEMICINCL@ 3 3 … … 273 273 ./classes/RiftStruct.cpp \ 274 274 ./modules/ModelProcessorx/Transient/UpdateElementsTransient.cpp \ 275 ./modules/ModelProcessorx/Transient/UpdateParametersTransient.cpp \ 275 276 ./cores/transient_core.cpp \ 276 277 ./cores/steadystate_core.cpp \ … … 714 715 if !WINDOWS 715 716 if !STANDALONE_LIBRARIES 716 libISSMCore_la_LIBADD = $(CHACOLIB) $(DAKOTALIB) $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(HDF5LIB) $(TAOLIB) $(M1QN3LIB) $(SEMICLIB) $(PLAPACKLIB) $( SUPERLULIB) $(SPOOLESLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(SCOTCHLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(ADOLCLIB) $(AMPILIB) $(ADJOINTMPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(PROJLIB) $(OSLIBS)717 libISSMCore_la_LIBADD = $(CHACOLIB) $(DAKOTALIB) $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(HDF5LIB) $(TAOLIB) $(M1QN3LIB) $(SEMICLIB) $(PLAPACKLIB) $(MPLAPACKLIB) $(SUPERLULIB) $(SPOOLESLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(SCOTCHLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(ADOLCLIB) $(AMPILIB) $(ADJOINTMPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(PROJLIB) $(OSLIBS) 717 718 if FORTRAN 718 719 libISSMCore_la_LIBADD += $(FLIBS) $(FORTRANLIB) … … 830 831 831 832 # External packages 832 LDADD += $(CHACOLIB) $(DAKOTALIB) $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(NEOPZLIB) $(TAOLIB) $(M1QN3LIB) $(SEMICLIB) $(PLAPACKLIB) $( SUPERLULIB) $(SPOOLESLIB) $(BLACSLIB) $(HDF5LIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(SCOTCHLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(AMPILIB) $(ADJOINTMPILIB) $(ADOLCLIB) $(MPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(PROJLIB) $(ESMFLIB) $(OSLIBS)833 LDADD += $(CHACOLIB) $(DAKOTALIB) $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(NEOPZLIB) $(TAOLIB) $(M1QN3LIB) $(SEMICLIB) $(PLAPACKLIB) $(MPLAPACKLIB) $(SUPERLULIB) $(SPOOLESLIB) $(BLACSLIB) $(HDF5LIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(SCOTCHLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(AMPILIB) $(ADJOINTMPILIB) $(ADOLCLIB) $(MPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(PROJLIB) $(ESMFLIB) $(OSLIBS) 833 834 834 835 if FORTRAN -
issm/trunk/src/c/analyses/AdjointHorizAnalysis.cpp
r26744 r27035 52 52 case FSApproximationEnum: 53 53 return CreateKMatrixFS(element); 54 case M LHOApproximationEnum:54 case MOLHOApproximationEnum: 55 55 // a more accurate option, but integrate in the vertical direction numerically. 56 // return CreateKMatrixM LHOVerticalIntergrated(element);57 return CreateKMatrixM LHO(element);56 // return CreateKMatrixMOLHOVerticalIntergrated(element); 57 return CreateKMatrixMOLHO(element); 58 58 case NoneApproximationEnum: 59 59 return NULL; … … 220 220 return Ke; 221 221 }/*}}}*/ 222 ElementMatrix* AdjointHorizAnalysis::CreateKMatrixM LHO(Element* element){/*{{{*/222 ElementMatrix* AdjointHorizAnalysis::CreateKMatrixMOLHO(Element* element){/*{{{*/ 223 223 224 224 /* Check if ice in element */ … … 226 226 227 227 /*Intermediaries */ 228 bool incomplete_adjoint;229 228 IssmDouble Jdet,mu_prime,n,thickness,mu,effmu; 230 229 IssmDouble *xyz_list = NULL; … … 238 237 IssmDouble vxshear, vyshear; 239 238 240 Element* basalelement; 239 /*Get basal element*/ 240 Element* basalelement = NULL; 241 element->FindParam(&domaintype,DomainTypeEnum); 242 switch(domaintype){ 243 case Domain2DhorizontalEnum: 244 basalelement = element; 245 break; 246 case Domain3DEnum: case Domain2DverticalEnum: 247 _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 248 break; 249 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 250 } 251 252 /*Initialize Jacobian with regular HO (first part of the Gateau derivative)*/ 253 bool incomplete_adjoint; 254 element->FindParam(&incomplete_adjoint,InversionIncompleteAdjointEnum); 255 StressbalanceAnalysis* analysis = new StressbalanceAnalysis(); 256 ElementMatrix* Ke=analysis->CreateKMatrix(basalelement); 257 delete analysis; 258 if(incomplete_adjoint) return Ke; 259 260 /*Second part of the Gateau derivative if requested*/ 261 262 /*Fetch number of nodes and dof for this finite element*/ 263 int numnodes = basalelement->GetNumberOfNodes(); 264 IssmDouble* dbasis = xNew<IssmDouble>(2*numnodes); // like SSA 265 IssmDouble* basis = xNew<IssmDouble>(numnodes); // like SSA 266 267 /*Retrieve all inputs and parameters*/ 268 element->GetVerticesCoordinates(&xyz_list); 269 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); //vertically integrated vx 270 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); //vertically integrated vy 271 Input* vxbase_input = element->GetInput(VxBaseEnum); _assert_(vxbase_input); 272 Input* vybase_input = element->GetInput(VyBaseEnum); _assert_(vybase_input); 273 Input* vxshear_input = element->GetInput(VxShearEnum); _assert_(vxshear_input); 274 Input* vyshear_input = element->GetInput(VyShearEnum); _assert_(vyshear_input); 275 Input* thickness_input= element->GetInput(ThicknessEnum); _assert_(thickness_input); 276 Input* n_input = element->GetInput(MaterialsRheologyNEnum); _assert_(n_input); 277 278 /* Start looping on the number of gaussian points: */ 279 Gauss* gauss = element->NewGauss(5); 280 Gauss* gauss_base = basalelement->NewGauss(); 281 while(gauss->next()){ 282 gauss->SynchronizeGaussBase(gauss_base); 283 284 element->JacobianDeterminant(&Jdet,xyz_list,gauss_base); 285 basalelement->NodalFunctionsDerivatives(dbasis,xyz_list,gauss_base); 286 basalelement->NodalFunctions(basis, gauss_base); 287 288 thickness_input->GetInputValue(&thickness, gauss); 289 n_input->GetInputValue(&n,gauss); 290 291 vxshear_input->GetInputValue(&vxshear,gauss); 292 vyshear_input->GetInputValue(&vyshear,gauss); 293 294 element->material->ViscosityMOLHOAdjoint(&viscosity[0],dim,xyz_list,gauss,vxbase_input,vybase_input,vxshear_input,vyshear_input,thickness_input,n_input); 295 296 effmu = 2.0*(1-n)/2.0/n; 297 298 element->StrainRateHO(&epsilonbase[0],xyz_list,gauss,vxbase_input, vybase_input); 299 element->StrainRateHO(&epsilonshear[0],xyz_list,gauss,vxshear_input, vyshear_input); 300 301 e1b[0] = 2*epsilonbase[0]+epsilonbase[1]; e1b[1] = epsilonbase[2]; 302 e2b[1] = epsilonbase[0]+2*epsilonbase[1]; e2b[0] = epsilonbase[2]; 303 304 e1sh[0] = 2*epsilonshear[0]+epsilonshear[1]; e1sh[1] = epsilonshear[2]; 305 e2sh[1] = epsilonshear[0]+2*epsilonshear[1]; e2sh[0] = epsilonshear[2]; 306 307 for(int i=0;i<numnodes;i++){ 308 for(int j=0;j<numnodes;j++){ 309 eb1i = e1b[0]*dbasis[0*numnodes+i]+e1b[1]*dbasis[1*numnodes+i]; 310 eb1j = e1b[0]*dbasis[0*numnodes+j]+e1b[1]*dbasis[1*numnodes+j]; 311 eb2i = e2b[0]*dbasis[0*numnodes+i]+e2b[1]*dbasis[1*numnodes+i]; 312 eb2j = e2b[0]*dbasis[0*numnodes+j]+e2b[1]*dbasis[1*numnodes+j]; 313 esh1i = e1sh[0]*dbasis[0*numnodes+i]+e1sh[1]*dbasis[1*numnodes+i]; 314 esh1j = e1sh[0]*dbasis[0*numnodes+j]+e1sh[1]*dbasis[1*numnodes+j]; 315 esh2i = e2sh[0]*dbasis[0*numnodes+i]+e2sh[1]*dbasis[1*numnodes+i]; 316 esh2j = e2sh[0]*dbasis[0*numnodes+j]+e2sh[1]*dbasis[1*numnodes+j]; 317 318 Ke->values[4*numnodes*(4*i+0)+4*j+0]+=gauss->weight*Jdet*effmu*(viscosity[0]*eb1j*eb1i+viscosity[1]*(esh1j*eb1i+eb1j*esh1i)+viscosity[2]*esh1j*esh1i); 319 Ke->values[4*numnodes*(4*i+1)+4*j+0]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb1j*eb1i+viscosity[2]*(esh1j*eb1i+eb1j*esh1i)+viscosity[4]*esh1j*esh1i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*eb1j*basis[i]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*esh1j*basis[i]); 320 Ke->values[4*numnodes*(4*i+2)+4*j+0]+=gauss->weight*Jdet*effmu*(viscosity[0]*eb1j*eb2i+viscosity[1]*(esh1j*eb2i+eb1j*esh2i)+viscosity[2]*esh1j*esh2i); 321 Ke->values[4*numnodes*(4*i+3)+4*j+0]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb1j*eb2i+viscosity[2]*(esh1j*eb2i+eb1j*esh2i)+viscosity[4]*esh1j*esh2i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*eb1j*basis[i]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*esh1j*basis[i]); 322 323 Ke->values[4*numnodes*(4*i+0)+4*j+1]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb1j*eb1i+viscosity[2]*(esh1j*eb1i+eb1j*esh1i)+viscosity[4]*esh1j*esh1i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*eb1i*basis[j]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*esh1i*basis[j]); 324 Ke->values[4*numnodes*(4*i+1)+4*j+1]+=gauss->weight*Jdet*effmu*(viscosity[2]*eb1j*eb1i+viscosity[4]*(esh1j*eb1i+eb1j*esh1i)+viscosity[5]*esh1j*esh1i+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*(eb1i*basis[j]+eb1j*basis[i])+viscosity[7]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*(esh1i*basis[j]+esh1j*basis[i])+viscosity[8]*(n+1)*(n+1)*(n+1)*(n+1)/4.0/thickness/thickness/thickness/thickness*vxshear*vxshear*basis[j]*basis[i]); 325 Ke->values[4*numnodes*(4*i+2)+4*j+1]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb1j*eb2i+viscosity[2]*(esh1j*eb2i+eb1j*esh2i)+viscosity[4]*esh1j*esh2i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*eb2i*basis[j]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*esh2i*basis[j]); 326 Ke->values[4*numnodes*(4*i+3)+4*j+1]+=gauss->weight*Jdet*effmu*(viscosity[2]*eb1j*eb2i+viscosity[4]*(esh1j*eb2i+eb1j*esh2i)+viscosity[5]*esh1j*esh2i+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*(vxshear*eb2i*basis[j]+vyshear*eb1j*basis[i])+viscosity[7]*(n+1)*(n+1)/2.0/thickness/thickness*(vxshear*esh2i*basis[j]+vyshear*esh1j*basis[i])+viscosity[8]*(n+1)*(n+1)*(n+1)*(n+1)/4.0/thickness/thickness/thickness/thickness*vxshear*vyshear*basis[j]*basis[i]); 327 328 329 Ke->values[4*numnodes*(4*i+0)+4*j+2]+=gauss->weight*Jdet*effmu*(viscosity[0]*eb2j*eb1i+viscosity[1]*(esh2j*eb1i+eb2j*esh1i)+viscosity[2]*esh2j*esh1i); 330 Ke->values[4*numnodes*(4*i+1)+4*j+2]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb2j*eb1i+viscosity[2]*(esh2j*eb1i+eb2j*esh1i)+viscosity[4]*esh2j*esh1i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*eb2j*basis[i]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*esh2j*basis[i]); 331 Ke->values[4*numnodes*(4*i+2)+4*j+2]+=gauss->weight*Jdet*effmu*(viscosity[0]*eb2j*eb2i+viscosity[1]*(esh2j*eb2i+eb2j*esh2i)+viscosity[2]*esh2j*esh2i); 332 Ke->values[4*numnodes*(4*i+3)+4*j+2]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb2j*eb2i+viscosity[2]*(esh2j*eb2i+eb2j*esh2i)+viscosity[4]*esh2j*esh2i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*eb2j*basis[i]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*esh2j*basis[i]); 333 334 335 Ke->values[4*numnodes*(4*i+0)+4*j+3]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb2j*eb1i+viscosity[2]*(esh2j*eb1i+eb2j*esh1i)+viscosity[4]*esh2j*esh1i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*eb1i*basis[j]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*esh1i*basis[j]); 336 Ke->values[4*numnodes*(4*i+1)+4*j+3]+=gauss->weight*Jdet*effmu*(viscosity[2]*eb2j*eb1i+viscosity[4]*(esh2j*eb1i+eb2j*esh1i)+viscosity[5]*esh2j*esh1i+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*(vyshear*eb1i*basis[j]+vxshear*eb2j*basis[i])+viscosity[7]*(n+1)*(n+1)/2.0/thickness/thickness*(vxshear*esh2j*basis[i]+vyshear*esh1i*basis[j])+viscosity[8]*(n+1)*(n+1)*(n+1)*(n+1)/4.0/thickness/thickness/thickness/thickness*vxshear*vxshear*basis[j]*basis[i]); 337 Ke->values[4*numnodes*(4*i+2)+4*j+3]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb2j*eb2i+viscosity[2]*(esh2j*eb2i+eb2j*esh2i)+viscosity[4]*esh2j*esh2i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*eb2i*basis[j]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*esh2i*basis[j]); 338 Ke->values[4*numnodes*(4*i+3)+4*j+3]+=gauss->weight*Jdet*effmu*(viscosity[2]*eb2j*eb2i+viscosity[4]*(esh2j*eb2i+eb2j*esh2i)+viscosity[5]*esh2j*esh2i+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*(eb2i*basis[j]+eb1j*basis[i])+viscosity[7]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*(esh2i*basis[j]+esh1j*basis[i])+viscosity[8]*(n+1)*(n+1)*(n+1)*(n+1)/4.0/thickness/thickness/thickness/thickness*vyshear*vyshear*basis[j]*basis[i]); 339 } 340 } 341 } 342 343 /*Transform Coordinate System*/ 344 /*element->TransformStiffnessMatrixCoord(Ke,XYEnum);*/ 345 346 /*Clean up and return*/ 347 delete gauss; 348 delete gauss_base; 349 if(basalelement->IsSpawnedElement()){basalelement->DeleteMaterials(); delete basalelement;}; 350 xDelete<IssmDouble>(xyz_list); 351 xDelete<IssmDouble>(dbasis); 352 xDelete<IssmDouble>(basis); 353 return Ke; 354 }/*}}}*/ 355 ElementMatrix* AdjointHorizAnalysis::CreateKMatrixMOLHOVerticalIntergrated(Element* element){/*{{{*/ 356 357 /* Check if ice in element */ 358 if(!element->IsIceInElement()) return NULL; 359 360 /*Intermediaries */ 361 IssmDouble Jdet,mu_prime,n,thickness,mu,effmu; 362 IssmDouble *xyz_list = NULL; 363 IssmDouble zeta, epsilon_eff; 364 int domaintype; 365 int dim=2; 366 367 IssmDouble e1phi1i, e1phi1j, e2phi1i, e2phi1j, e1phi2i, e1phi2j, e2phi2i, e2phi2j; 368 IssmDouble epsilon[5];/* epsilon=[exx,eyy,exy,exz,eyz];*/ 369 IssmDouble e1[3],e2[3]; 370 371 Element* basalelement = NULL; 241 372 242 373 /*Get basal element*/ … … 251 382 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 252 383 } 253 /*Fetch number of nodes and dof for this finite element*/254 int numnodes = basalelement->GetNumberOfNodes();255 IssmDouble* dbasis = xNew<IssmDouble>(2*numnodes); // like SSA256 IssmDouble* basis = xNew<IssmDouble>(numnodes); // like SSA257 384 258 385 /*Initialize Jacobian with regular HO (first part of the Gateau derivative)*/ 386 bool incomplete_adjoint; 259 387 element->FindParam(&incomplete_adjoint,InversionIncompleteAdjointEnum); 260 388 StressbalanceAnalysis* analysis = new StressbalanceAnalysis(); … … 263 391 if(incomplete_adjoint) return Ke; 264 392 265 /*Retrieve all inputs and parameters*/ 266 element->GetVerticesCoordinates(&xyz_list); 267 Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input); //vertically integrated vx 268 Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input); //vertically integrated vy 269 Input* vxbase_input = element->GetInput(VxBaseEnum); _assert_(vxbase_input); 270 Input* vybase_input = element->GetInput(VyBaseEnum); _assert_(vybase_input); 271 Input* vxshear_input = element->GetInput(VxShearEnum); _assert_(vxshear_input); 272 Input* vyshear_input = element->GetInput(VyShearEnum); _assert_(vyshear_input); 273 Input* thickness_input= element->GetInput(ThicknessEnum); _assert_(thickness_input); 274 Input* n_input = element->GetInput(MaterialsRheologyNEnum); _assert_(n_input); 275 276 /* Start looping on the number of gaussian points: */ 277 Gauss* gauss = element->NewGauss(5); 278 Gauss* gauss_base = basalelement->NewGauss(); 279 while(gauss->next()){ 280 gauss->SynchronizeGaussBase(gauss_base); 281 282 element->JacobianDeterminant(&Jdet,xyz_list,gauss_base); 283 basalelement->NodalFunctionsDerivatives(dbasis,xyz_list,gauss_base); 284 basalelement->NodalFunctions(basis, gauss_base); 285 286 thickness_input->GetInputValue(&thickness, gauss); 287 n_input->GetInputValue(&n,gauss); 288 289 vxshear_input->GetInputValue(&vxshear,gauss); 290 vyshear_input->GetInputValue(&vyshear,gauss); 291 292 element->material->ViscosityMLHOAdjoint(&viscosity[0],dim,xyz_list,gauss,vxbase_input,vybase_input,vxshear_input,vyshear_input,thickness_input,n_input); 293 294 effmu = 2.0*(1-n)/2.0/n; 295 296 element->StrainRateHO(&epsilonbase[0],xyz_list,gauss,vxbase_input, vybase_input); 297 element->StrainRateHO(&epsilonshear[0],xyz_list,gauss,vxshear_input, vyshear_input); 298 299 e1b[0] = 2*epsilonbase[0]+epsilonbase[1]; e1b[1] = epsilonbase[2]; 300 e2b[1] = epsilonbase[0]+2*epsilonbase[1]; e2b[0] = epsilonbase[2]; 301 302 e1sh[0] = 2*epsilonshear[0]+epsilonshear[1]; e1sh[1] = epsilonshear[2]; 303 e2sh[1] = epsilonshear[0]+2*epsilonshear[1]; e2sh[0] = epsilonshear[2]; 304 305 for(int i=0;i<numnodes;i++){ 306 for(int j=0;j<numnodes;j++){ 307 eb1i = e1b[0]*dbasis[0*numnodes+i]+e1b[1]*dbasis[1*numnodes+i]; 308 eb1j = e1b[0]*dbasis[0*numnodes+j]+e1b[1]*dbasis[1*numnodes+j]; 309 eb2i = e2b[0]*dbasis[0*numnodes+i]+e2b[1]*dbasis[1*numnodes+i]; 310 eb2j = e2b[0]*dbasis[0*numnodes+j]+e2b[1]*dbasis[1*numnodes+j]; 311 esh1i = e1sh[0]*dbasis[0*numnodes+i]+e1sh[1]*dbasis[1*numnodes+i]; 312 esh1j = e1sh[0]*dbasis[0*numnodes+j]+e1sh[1]*dbasis[1*numnodes+j]; 313 esh2i = e2sh[0]*dbasis[0*numnodes+i]+e2sh[1]*dbasis[1*numnodes+i]; 314 esh2j = e2sh[0]*dbasis[0*numnodes+j]+e2sh[1]*dbasis[1*numnodes+j]; 315 316 Ke->values[4*numnodes*(4*i+0)+4*j+0]+=gauss->weight*Jdet*effmu*(viscosity[0]*eb1j*eb1i+viscosity[1]*(esh1j*eb1i+eb1j*esh1i)+viscosity[2]*esh1j*esh1i); 317 Ke->values[4*numnodes*(4*i+1)+4*j+0]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb1j*eb1i+viscosity[2]*(esh1j*eb1i+eb1j*esh1i)+viscosity[4]*esh1j*esh1i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*eb1j*basis[i]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*esh1j*basis[i]); 318 Ke->values[4*numnodes*(4*i+2)+4*j+0]+=gauss->weight*Jdet*effmu*(viscosity[0]*eb1j*eb2i+viscosity[1]*(esh1j*eb2i+eb1j*esh2i)+viscosity[2]*esh1j*esh2i); 319 Ke->values[4*numnodes*(4*i+3)+4*j+0]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb1j*eb2i+viscosity[2]*(esh1j*eb2i+eb1j*esh2i)+viscosity[4]*esh1j*esh2i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*eb1j*basis[i]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*esh1j*basis[i]); 320 321 Ke->values[4*numnodes*(4*i+0)+4*j+1]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb1j*eb1i+viscosity[2]*(esh1j*eb1i+eb1j*esh1i)+viscosity[4]*esh1j*esh1i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*eb1i*basis[j]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*esh1i*basis[j]); 322 Ke->values[4*numnodes*(4*i+1)+4*j+1]+=gauss->weight*Jdet*effmu*(viscosity[2]*eb1j*eb1i+viscosity[4]*(esh1j*eb1i+eb1j*esh1i)+viscosity[5]*esh1j*esh1i+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*(eb1i*basis[j]+eb1j*basis[i])+viscosity[7]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*(esh1i*basis[j]+esh1j*basis[i])+viscosity[8]*(n+1)*(n+1)*(n+1)*(n+1)/4.0/thickness/thickness/thickness/thickness*vxshear*vxshear*basis[j]*basis[i]); 323 Ke->values[4*numnodes*(4*i+2)+4*j+1]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb1j*eb2i+viscosity[2]*(esh1j*eb2i+eb1j*esh2i)+viscosity[4]*esh1j*esh2i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*eb2i*basis[j]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*esh2i*basis[j]); 324 Ke->values[4*numnodes*(4*i+3)+4*j+1]+=gauss->weight*Jdet*effmu*(viscosity[2]*eb1j*eb2i+viscosity[4]*(esh1j*eb2i+eb1j*esh2i)+viscosity[5]*esh1j*esh2i+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*(vxshear*eb2i*basis[j]+vyshear*eb1j*basis[i])+viscosity[7]*(n+1)*(n+1)/2.0/thickness/thickness*(vxshear*esh2i*basis[j]+vyshear*esh1j*basis[i])+viscosity[8]*(n+1)*(n+1)*(n+1)*(n+1)/4.0/thickness/thickness/thickness/thickness*vxshear*vyshear*basis[j]*basis[i]); 325 326 327 Ke->values[4*numnodes*(4*i+0)+4*j+2]+=gauss->weight*Jdet*effmu*(viscosity[0]*eb2j*eb1i+viscosity[1]*(esh2j*eb1i+eb2j*esh1i)+viscosity[2]*esh2j*esh1i); 328 Ke->values[4*numnodes*(4*i+1)+4*j+2]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb2j*eb1i+viscosity[2]*(esh2j*eb1i+eb2j*esh1i)+viscosity[4]*esh2j*esh1i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*eb2j*basis[i]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vxshear*esh2j*basis[i]); 329 Ke->values[4*numnodes*(4*i+2)+4*j+2]+=gauss->weight*Jdet*effmu*(viscosity[0]*eb2j*eb2i+viscosity[1]*(esh2j*eb2i+eb2j*esh2i)+viscosity[2]*esh2j*esh2i); 330 Ke->values[4*numnodes*(4*i+3)+4*j+2]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb2j*eb2i+viscosity[2]*(esh2j*eb2i+eb2j*esh2i)+viscosity[4]*esh2j*esh2i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*eb2j*basis[i]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*esh2j*basis[i]); 331 332 333 Ke->values[4*numnodes*(4*i+0)+4*j+3]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb2j*eb1i+viscosity[2]*(esh2j*eb1i+eb2j*esh1i)+viscosity[4]*esh2j*esh1i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*eb1i*basis[j]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*esh1i*basis[j]); 334 Ke->values[4*numnodes*(4*i+1)+4*j+3]+=gauss->weight*Jdet*effmu*(viscosity[2]*eb2j*eb1i+viscosity[4]*(esh2j*eb1i+eb2j*esh1i)+viscosity[5]*esh2j*esh1i+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*(vyshear*eb1i*basis[j]+vxshear*eb2j*basis[i])+viscosity[7]*(n+1)*(n+1)/2.0/thickness/thickness*(vxshear*esh2j*basis[i]+vyshear*esh1i*basis[j])+viscosity[8]*(n+1)*(n+1)*(n+1)*(n+1)/4.0/thickness/thickness/thickness/thickness*vxshear*vxshear*basis[j]*basis[i]); 335 Ke->values[4*numnodes*(4*i+2)+4*j+3]+=gauss->weight*Jdet*effmu*(viscosity[1]*eb2j*eb2i+viscosity[2]*(esh2j*eb2i+eb2j*esh2i)+viscosity[4]*esh2j*esh2i+viscosity[3]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*eb2i*basis[j]+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*esh2i*basis[j]); 336 Ke->values[4*numnodes*(4*i+3)+4*j+3]+=gauss->weight*Jdet*effmu*(viscosity[2]*eb2j*eb2i+viscosity[4]*(esh2j*eb2i+eb2j*esh2i)+viscosity[5]*esh2j*esh2i+viscosity[6]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*(eb2i*basis[j]+eb1j*basis[i])+viscosity[7]*(n+1)*(n+1)/2.0/thickness/thickness*vyshear*(esh2i*basis[j]+esh1j*basis[i])+viscosity[8]*(n+1)*(n+1)*(n+1)*(n+1)/4.0/thickness/thickness/thickness/thickness*vyshear*vyshear*basis[j]*basis[i]); 337 } 338 } 339 } 340 341 /*Transform Coordinate System*/ 342 /*element->TransformStiffnessMatrixCoord(Ke,XYEnum);*/ 343 344 /*Clean up and return*/ 345 delete gauss; 346 delete gauss_base; 347 if(basalelement->IsSpawnedElement()){basalelement->DeleteMaterials(); delete basalelement;}; 348 xDelete<IssmDouble>(xyz_list); 349 xDelete<IssmDouble>(dbasis); 350 xDelete<IssmDouble>(basis); 351 return Ke; 352 }/*}}}*/ 353 ElementMatrix* AdjointHorizAnalysis::CreateKMatrixMLHOVerticalIntergrated(Element* element){/*{{{*/ 354 355 /* Check if ice in element */ 356 if(!element->IsIceInElement()) return NULL; 357 358 /*Intermediaries */ 359 bool incomplete_adjoint; 360 IssmDouble Jdet,mu_prime,n,thickness,mu,effmu; 361 IssmDouble *xyz_list = NULL; 362 IssmDouble zeta, epsilon_eff; 363 int domaintype; 364 int dim=2; 365 366 IssmDouble e1phi1i, e1phi1j, e2phi1i, e2phi1j, e1phi2i, e1phi2j, e2phi2i, e2phi2j; 367 IssmDouble epsilon[5];/* epsilon=[exx,eyy,exy,exz,eyz];*/ 368 IssmDouble e1[3],e2[3]; 369 370 Element* basalelement; 371 372 /*Get basal element*/ 373 element->FindParam(&domaintype,DomainTypeEnum); 374 switch(domaintype){ 375 case Domain2DhorizontalEnum: 376 basalelement = element; 377 break; 378 case Domain3DEnum: case Domain2DverticalEnum: 379 _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 380 break; 381 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 382 } 393 /*Second part of the Gateau derivative if requested*/ 394 395 383 396 /*Fetch number of nodes and dof for this finite element*/ 384 397 int numnodes = basalelement->GetNumberOfNodes(); 385 398 IssmDouble* dbasis = xNew<IssmDouble>(2*numnodes); // like SSA 386 399 IssmDouble* basis = xNew<IssmDouble>(numnodes); // like SSA 387 388 /*Initialize Jacobian with regular HO (first part of the Gateau derivative)*/389 element->FindParam(&incomplete_adjoint,InversionIncompleteAdjointEnum);390 StressbalanceAnalysis* analysis = new StressbalanceAnalysis();391 ElementMatrix* Ke=analysis->CreateKMatrix(basalelement);392 delete analysis;393 if(incomplete_adjoint) return Ke;394 400 395 401 /*Retrieve all inputs and parameters*/ … … 427 433 428 434 /* eps_eff^2 = exx^2 + eyy^2 + exy^2 + exz^2 + eyz^2 + exx*eyy (for a given zeta)*/ 429 element->StrainRateM LHO(&epsilon[0],xyz_list,gauss,435 element->StrainRateMOLHO(&epsilon[0],xyz_list,gauss, 430 436 vxbase_input,vybase_input,vxshear_input,vyshear_input,thickness_input,n_input,zeta); 431 437 epsilon_eff=sqrt(epsilon[0]*epsilon[0] + epsilon[1]*epsilon[1] + epsilon[2]*epsilon[2] … … 612 618 case FSApproximationEnum: 613 619 return CreatePVectorFS(element); 614 case M LHOApproximationEnum:615 return CreatePVectorM LHO(element);620 case MOLHOApproximationEnum: 621 return CreatePVectorMOLHO(element); 616 622 case NoneApproximationEnum: 617 623 return NULL; … … 1099 1105 1100 1106 }/*}}}*/ 1101 ElementVector* AdjointHorizAnalysis::CreatePVectorM LHO(Element* element){/*{{{*/1107 ElementVector* AdjointHorizAnalysis::CreatePVectorMOLHO(Element* element){/*{{{*/ 1102 1108 1103 1109 /*Intermediaries*/ … … 1137 1143 1138 1144 /*Initialize Element vector and vectors*/ 1139 ElementVector* pe = basalelement->NewElementVector(M LHOApproximationEnum);1145 ElementVector* pe = basalelement->NewElementVector(MOLHOApproximationEnum); 1140 1146 IssmDouble* basis = xNew<IssmDouble>(numnodes); 1141 1147 … … 1206 1212 } 1207 1213 else { 1208 _error_("2D vertical is not implemented for M LHO");1214 _error_("2D vertical is not implemented for MOLHO"); 1209 1215 } 1210 1216 } … … 1234 1240 } 1235 1241 else{ 1236 _error_("2D vertical is not implemented for M LHO");1242 _error_("2D vertical is not implemented for MOLHO"); 1237 1243 } 1238 1244 } … … 1263 1269 } 1264 1270 else{ 1265 _error_("2D vertical is not implemented for M LHO");1271 _error_("2D vertical is not implemented for MOLHO"); 1266 1272 } 1267 1273 } … … 1289 1295 } 1290 1296 else{ 1291 _error_("2D vertical is not implemented for M LHO");1297 _error_("2D vertical is not implemented for MOLHO"); 1292 1298 } 1293 1299 } … … 1313 1319 } 1314 1320 else{ 1315 _error_("2D vertical is not implemented for M LHO");1321 _error_("2D vertical is not implemented for MOLHO"); 1316 1322 } 1317 1323 } … … 1663 1669 case L1L2ApproximationEnum:GradientJDragL1L2(element,gradient,control_interp,control_index); break; 1664 1670 case HOApproximationEnum: GradientJDragHO( element,gradient,control_interp,control_index); break; 1665 case M LHOApproximationEnum: GradientJDragMLHO( element,gradient,control_interp,control_index); break;1671 case MOLHOApproximationEnum: GradientJDragMOLHO( element,gradient,control_interp,control_index); break; 1666 1672 case FSApproximationEnum: GradientJDragFS( element,gradient,control_interp,control_index); break; 1667 1673 case NoneApproximationEnum: /*Gradient is 0*/ break; … … 1684 1690 case L1L2ApproximationEnum:GradientJBbarL1L2(element,gradient,control_interp,control_index); break; 1685 1691 case HOApproximationEnum: GradientJBbarHO( element,gradient,control_interp,control_index); break; 1686 case M LHOApproximationEnum: GradientJBbarMLHO( element,gradient,control_interp,control_index); break;1692 case MOLHOApproximationEnum: GradientJBbarMOLHO( element,gradient,control_interp,control_index); break; 1687 1693 case FSApproximationEnum: GradientJBbarFS( element,gradient,control_interp,control_index); break; 1688 1694 case NoneApproximationEnum: /*Gradient is 0*/ break; … … 1694 1700 case SSAApproximationEnum: GradientJBSSA(element,gradient,control_interp,control_index); break; 1695 1701 case HOApproximationEnum: GradientJBHO( element,gradient,control_interp,control_index); break; 1696 // case M LHOApproximationEnum: GradientJBMLHO( element,gradient,control_interp,control_index); break;1702 // case MOLHOApproximationEnum: GradientJBMOLHO( element,gradient,control_interp,control_index); break; 1697 1703 case FSApproximationEnum: GradientJBFS( element,gradient,control_interp,control_index); break; 1698 1704 case NoneApproximationEnum: /*Gradient is 0*/ break; … … 1804 1810 this->GradientJBbarSSA(element,gradient,control_interp,control_index); 1805 1811 }/*}}}*/ 1806 void AdjointHorizAnalysis::GradientJBbarM LHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index){/*{{{*/1812 void AdjointHorizAnalysis::GradientJBbarMOLHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index){/*{{{*/ 1807 1813 1808 1814 if(control_interp!=P1Enum) _error_("not implemented yet..."); … … 1887 1893 zeta=0.5*(gauss_seg->coord1+1); 1888 1894 1889 basalelement->StrainRateM LHO(&epsilon[0],xyz_list,gauss,1895 basalelement->StrainRateMOLHO(&epsilon[0],xyz_list,gauss, 1890 1896 vxbase_input,vybase_input,vxshear_input,vyshear_input,thickness_input,n_input,zeta); 1891 1897 1892 basalelement->dViscositydBM LHO(&dmudB,dim,xyz_list,gauss,vxbase_input,vybase_input,vxshear_input,vyshear_input,thickness_input,n_input,zeta);1898 basalelement->dViscositydBMOLHO(&dmudB,dim,xyz_list,gauss,vxbase_input,vybase_input,vxshear_input,vyshear_input,thickness_input,n_input,zeta); 1893 1899 1894 1900 e1[0] = 2.0*epsilon[0]+epsilon[1]; … … 2245 2251 delete gauss; 2246 2252 }/*}}}*/ 2247 void AdjointHorizAnalysis::GradientJBM LHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index){/*{{{*/2253 void AdjointHorizAnalysis::GradientJBMOLHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index){/*{{{*/ 2248 2254 _error_("not implemented yet..."); 2249 2255 }/*}}}*/ … … 2645 2651 delete friction; 2646 2652 }/*}}}*/ 2647 void AdjointHorizAnalysis::GradientJDragM LHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index){/*{{{*/2653 void AdjointHorizAnalysis::GradientJDragMOLHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index){/*{{{*/ 2648 2654 2649 2655 /*return if floating (gradient is 0)*/ … … 3266 3272 InputUpdateFromSolutionFS(solution,element); 3267 3273 } 3268 else if (approximation==M LHOApproximationEnum) {3269 InputUpdateFromSolutionM LHO(solution, element);3274 else if (approximation==MOLHOApproximationEnum) { 3275 InputUpdateFromSolutionMOLHO(solution, element); 3270 3276 } 3271 3277 else{ … … 3414 3420 xDelete<int>(doflist); 3415 3421 }/*}}}*/ 3416 void AdjointHorizAnalysis::InputUpdateFromSolutionM LHO(IssmDouble* solution,Element* element){/*{{{*/3422 void AdjointHorizAnalysis::InputUpdateFromSolutionMOLHO(IssmDouble* solution,Element* element){/*{{{*/ 3417 3423 int i; 3418 3424 int* doflist=NULL; … … 3427 3433 3428 3434 /*Fetch dof list and allocate solution vectors*/ 3429 element->GetDofListLocal(&doflist,M LHOApproximationEnum,GsetEnum);3430 IssmDouble* values = xNew<IssmDouble>(numdof);3431 IssmDouble* lambdax = xNew<IssmDouble>(numnodes);3432 IssmDouble* lambday = xNew<IssmDouble>(numnodes);3433 IssmDouble* lambdabx = xNew<IssmDouble>(numnodes);3434 IssmDouble* lambdaby = xNew<IssmDouble>(numnodes);3435 element->GetDofListLocal(&doflist,MOLHOApproximationEnum,GsetEnum); 3436 IssmDouble* values = xNew<IssmDouble>(numdof); 3437 IssmDouble* lambdax = xNew<IssmDouble>(numnodes); 3438 IssmDouble* lambday = xNew<IssmDouble>(numnodes); 3439 IssmDouble* lambdabx = xNew<IssmDouble>(numnodes); 3440 IssmDouble* lambdaby = xNew<IssmDouble>(numnodes); 3435 3441 IssmDouble* lambdashx = xNew<IssmDouble>(numnodes); 3436 3442 IssmDouble* lambdashy = xNew<IssmDouble>(numnodes); 3437 IssmDouble* n 3443 IssmDouble* n = xNew<IssmDouble>(numnodes); 3438 3444 3439 3445 /*Use the dof list to index into the solution vector: */ … … 3485 3491 xDelete<IssmDouble>(lambdashx); 3486 3492 xDelete<IssmDouble>(lambdashy); 3493 xDelete<IssmDouble>(n); 3487 3494 xDelete<int>(doflist); 3488 3495 }/*}}}*/ -
issm/trunk/src/c/analyses/AdjointHorizAnalysis.h
r26744 r27035 28 28 ElementMatrix* CreateKMatrixFS(Element* element); 29 29 ElementMatrix* CreateKMatrixHO(Element* element); 30 ElementMatrix* CreateKMatrixM LHO(Element* element);31 ElementMatrix* CreateKMatrixM LHOVerticalIntergrated(Element* element);30 ElementMatrix* CreateKMatrixMOLHO(Element* element); 31 ElementMatrix* CreateKMatrixMOLHOVerticalIntergrated(Element* element); 32 32 ElementMatrix* CreateKMatrixL1L2(Element* element); 33 33 ElementMatrix* CreateKMatrixSSA(Element* element); … … 36 36 ElementVector* CreatePVectorL1L2(Element* element); 37 37 ElementVector* CreatePVectorHO(Element* element); 38 ElementVector* CreatePVectorM LHO(Element* element);38 ElementVector* CreatePVectorMOLHO(Element* element); 39 39 ElementVector* CreatePVectorSSA(Element* element); 40 40 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); … … 45 45 void GradientJBbarL1L2(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 46 46 void GradientJBbarHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 47 void GradientJBbarM LHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index);47 void GradientJBbarMOLHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 48 48 void GradientJBbarSSA(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 49 49 void GradientJBFS(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 50 50 void GradientJBGradient(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 51 51 void GradientJBHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 52 void GradientJBM LHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index);52 void GradientJBMOLHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 53 53 void GradientJBSSA(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 54 54 void GradientJDragFS(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); … … 56 56 void GradientJDragL1L2(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 57 57 void GradientJDragHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 58 void GradientJDragM LHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index);58 void GradientJDragMOLHO(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 59 59 void GradientJDragSSA(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); 60 60 void GradientJDragHydroFS(Element* element,Vector<IssmDouble>* gradient,int control_interp,int control_index); … … 66 66 void InputUpdateFromSolutionFS(IssmDouble* solution,Element* element); 67 67 void InputUpdateFromSolutionHoriz(IssmDouble* solution,Element* element); 68 void InputUpdateFromSolutionM LHO(IssmDouble* solution,Element* element);68 void InputUpdateFromSolutionMOLHO(IssmDouble* solution,Element* element); 69 69 void UpdateConstraints(FemModel* femmodel); 70 70 }; -
issm/trunk/src/c/analyses/BalancethicknessAnalysis.cpp
r26744 r27035 552 552 }/*}}}*/ 553 553 void BalancethicknessAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 554 /*Default, do nothing*/ 555 return; 556 }/*}}}*/ 554 SetActiveNodesLSMx(femmodel); 555 }/*}}}*/ -
issm/trunk/src/c/analyses/FreeSurfaceBaseAnalysis.cpp
r26744 r27035 73 73 } 74 74 75 iomodel->FetchDataToInput(inputs,elements,"md.geometry. surface",SurfaceEnum);75 iomodel->FetchDataToInput(inputs,elements,"md.geometry.base",BaseEnum); 76 76 iomodel->FetchDataToInput(inputs,elements,"md.initialization.sealevel",SealevelEnum,0); 77 77 iomodel->FetchDataToInput(inputs,elements,"md.mask.ice_levelset",MaskIceLevelsetEnum); … … 96 96 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.floatingice_melting_rate",BasalforcingsFloatingiceMeltingRateEnum); 97 97 if(isstochastic){ 98 99 100 98 iomodel->FetchDataToInput(inputs,elements,"md.stochasticforcing.default_id",StochasticForcingDefaultIdEnum); 99 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.floatingice_melting_rate",BaselineBasalforcingsFloatingiceMeltingRateEnum); 100 } 101 101 break; 102 102 case LinearFloatingMeltRateEnum: … … 108 108 break; 109 109 case SpatialLinearFloatingMeltRateEnum: 110 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsDeepwaterMeltingRateEnum); 111 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_elevation",BasalforcingsDeepwaterElevationEnum); 112 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.upperwater_elevation",BasalforcingsUpperwaterElevationEnum); 110 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsSpatialDeepwaterMeltingRateEnum); 111 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_elevation",BasalforcingsSpatialDeepwaterElevationEnum); 112 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.upperwater_melting_rate",BasalforcingsSpatialUpperwaterMeltingRateEnum); 113 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.upperwater_elevation",BasalforcingsSpatialUpperwaterElevationEnum); 114 if(isstochastic){ 115 iomodel->FetchDataToInput(inputs,elements,"md.stochasticforcing.default_id",StochasticForcingDefaultIdEnum); 116 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_melting_rate",BaselineBasalforcingsSpatialDeepwaterMeltingRateEnum); 117 } 113 118 break; 114 119 case BasalforcingsPicoEnum: … … 143 148 }/*}}}*/ 144 149 ElementMatrix* FreeSurfaceBaseAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/ 145 _error_("Not implemented");150 _error_("Not implemented"); 146 151 }/*}}}*/ 147 152 ElementMatrix* FreeSurfaceBaseAnalysis::CreateKMatrix(Element* element){/*{{{*/ … … 152 157 IssmDouble *xyz_list = NULL; 153 158 IssmDouble Jdet,D_scalar,dt,h; 154 IssmDouble vel,vx,vy ;159 IssmDouble vel,vx,vy,tau; 155 160 156 161 /*Get basal element*/ … … 225 230 } 226 231 227 if(stabilization==2){ 228 /*Streamline upwinding*/ 229 if(dim==1){ 230 vel=fabs(vx)+1.e-8; 231 D[0] = h/(2.*vel)*vx*vx; 232 } 233 else{ 234 vel=sqrt(vx*vx+vy*vy)+1.e-8; 235 D[0*dim+0]=h/(2*vel)*vx*vx; 236 D[1*dim+0]=h/(2*vel)*vy*vx; 237 D[0*dim+1]=h/(2*vel)*vx*vy; 238 D[1*dim+1]=h/(2*vel)*vy*vy; 239 } 240 } 241 else if(stabilization==1){ 232 if(stabilization==1){ 242 233 /*SSA*/ 243 234 if(dim==1){ … … 250 241 D[0*dim+0]=h/2.0*fabs(vx); 251 242 D[1*dim+1]=h/2.0*fabs(vy); 243 } 244 } 245 else if(stabilization==2){ 246 /*Streamline upwinding*/ 247 if(dim==1){ 248 vel=fabs(vx)+1.e-8; 249 D[0] = h/(2.*vel)*vx*vx; 250 } 251 else{ 252 vel=sqrt(vx*vx+vy*vy)+1.e-8; 253 D[0*dim+0]=h/(2*vel)*vx*vx; 254 D[1*dim+0]=h/(2*vel)*vy*vx; 255 D[0*dim+1]=h/(2*vel)*vx*vy; 256 D[1*dim+1]=h/(2*vel)*vy*vy; 257 } 258 259 } 260 else if(stabilization==5){ 261 /*SUPG*/ 262 if(dim==1){ 263 vx_input->GetInputAverage(&vx); 264 tau=h/(2.*fabs(vx)+1e-10); 265 } 266 else{ 267 vx_input->GetInputAverage(&vx); 268 vy_input->GetInputAverage(&vy); 269 tau=1*h/(2.*pow(vx*vx+vy*vy,0.5)+1e-10); 252 270 } 253 271 } … … 258 276 for(int j=0;j<numnodes;j++){ 259 277 Ke->values[i*numnodes+j] += ( 260 261 262 278 dbasis[0*numnodes+i] *(D[0*dim+0]*dbasis[0*numnodes+j] + D[0*dim+1]*dbasis[1*numnodes+j]) + 279 dbasis[1*numnodes+i] *(D[1*dim+0]*dbasis[0*numnodes+j] + D[1*dim+1]*dbasis[1*numnodes+j]) 280 ); 263 281 } 264 282 } … … 266 284 else{ 267 285 for(int i=0;i<numnodes;i++) for(int j=0;j<numnodes;j++) Ke->values[i*numnodes+j] += dbasis[0*numnodes+i]*D[0]*dbasis[0*numnodes+j]; 286 } 287 } 288 else if(stabilization==5){ 289 D_scalar=gauss->weight*Jdet*dt; 290 if(dim==2){ 291 for(int i=0;i<numnodes;i++){ 292 for(int j=0;j<numnodes;j++){ 293 Ke->values[i*numnodes+j]+=tau*D_scalar* 294 (vx*dbasis[0*numnodes+i]+vy*dbasis[1*numnodes+i])* 295 (vx*dbasis[0*numnodes+j]+vy*dbasis[1*numnodes+j]); 296 } 297 } 298 } 299 else{ 300 for(int i=0;i<numnodes;i++) for(int j=0;j<numnodes;j++) Ke->values[i*numnodes+j]+=tau*D_scalar*(vx*dbasis[0*numnodes+i])*(vx*dbasis[0*numnodes+j]); 268 301 } 269 302 } … … 280 313 }/*}}}*/ 281 314 ElementVector* FreeSurfaceBaseAnalysis::CreatePVector(Element* element){/*{{{*/ 315 282 316 /*Intermediaries*/ 283 int domaintype,dim ;317 int domaintype,dim,stabilization; 284 318 IssmDouble Jdet,dt; 285 IssmDouble gmb,fmb,mb,bed, phi,vz;319 IssmDouble gmb,fmb,mb,bed,vx,vy,vz,tau; 286 320 Element* basalelement = NULL; 287 321 IssmDouble *xyz_list = NULL; … … 309 343 /*Fetch number of nodes and dof for this finite element*/ 310 344 int numnodes = basalelement->GetNumberOfNodes(); 345 int melt_style,point1; 346 IssmDouble fraction1,fraction2; 347 bool mainlyfloating; 311 348 312 349 /*Initialize Element vector and other vectors*/ 313 350 ElementVector* pe = basalelement->NewElementVector(); 314 351 IssmDouble* basis = xNew<IssmDouble>(numnodes); 352 IssmDouble* dbasis = xNew<IssmDouble>(dim*numnodes); 353 IssmDouble gllevelset,phi=1.; 315 354 316 355 /*Retrieve all inputs and parameters*/ 317 basalelement->GetVerticesCoordinates(&xyz_list);318 356 basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 357 basalelement->FindParam(&melt_style,GroundinglineMeltInterpolationEnum); 319 358 Input* groundedice_input = basalelement->GetInput(MaskOceanLevelsetEnum); _assert_(groundedice_input); 320 359 Input* gmb_input = basalelement->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(gmb_input); 321 360 Input* fmb_input = basalelement->GetInput(BasalforcingsFloatingiceMeltingRateEnum); _assert_(fmb_input); 322 361 Input* base_input = basalelement->GetInput(BaseEnum); _assert_(base_input); 323 Input* vz_input = NULL; 362 Input* gllevelset_input = basalelement->GetInput(MaskOceanLevelsetEnum); _assert_(gllevelset_input); 363 Input* vz_input = NULL; 364 Input* vx_input = NULL; 365 Input* vy_input = NULL; 324 366 switch(dim){ 325 case 1: vz_input = basalelement->GetInput(VyEnum); _assert_(vz_input); break; 326 case 2: vz_input = basalelement->GetInput(VzEnum); _assert_(vz_input); break; 367 case 1: 368 vx_input=basalelement->GetInput(VxEnum); _assert_(vx_input); 369 vz_input=basalelement->GetInput(VyEnum) ; _assert_(vz_input); 370 break; 371 case 2: 372 vx_input=basalelement->GetInput(VxEnum); _assert_(vx_input); 373 vy_input=basalelement->GetInput(VyEnum); _assert_(vy_input); 374 vz_input=basalelement->GetInput(VzEnum); _assert_(vz_input); 375 break; 327 376 default: _error_("not implemented"); 328 377 } 378 IssmDouble h = basalelement->CharacteristicLength(); 379 380 /*Recover portion of element that is grounded*/ 381 basalelement->GetVerticesCoordinates(&xyz_list); 382 phi=basalelement->GetGroundedPortion(xyz_list); 383 Gauss* gauss = NULL; 384 if(melt_style==SubelementMelt2Enum){ 385 basalelement->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating); 386 gauss = basalelement->NewGauss(point1,fraction1,fraction2,3); 387 } 388 else{ 389 gauss = basalelement->NewGauss(3); 390 } 329 391 330 392 /* Start looping on the number of gaussian points: */ 331 Gauss* gauss=basalelement->NewGauss(2);332 393 while(gauss->next()){ 333 394 … … 335 396 basalelement->NodalFunctions(basis,gauss); 336 397 337 vz_input->GetInputValue(&vz,gauss); 398 399 vz_input->GetInputValue(&vz,gauss); 338 400 gmb_input->GetInputValue(&gmb,gauss); 339 401 fmb_input->GetInputValue(&fmb,gauss); 340 402 base_input->GetInputValue(&bed,gauss); 341 403 groundedice_input->GetInputValue(&phi,gauss); 342 if(phi>0) mb=gmb; 343 else mb=fmb; 404 gllevelset_input->GetInputValue(&gllevelset,gauss); 405 if(melt_style==SubelementMelt1Enum){ 406 //if (phi>0.999999999) mb=gmb; 407 //else mb=(1-phi)*fmb+phi*gmb; // phi is the fraction of grounded ice so (1-phi) is floating 408 if(phi>0) mb=gmb; 409 else mb=fmb; 410 } 411 else if(melt_style==SubelementMelt2Enum){ 412 if(gllevelset>0.) mb=gmb; 413 else mb=fmb; 414 } 415 else if(melt_style==NoMeltOnPartiallyFloatingEnum){ 416 if (phi<0.00000001) mb=fmb; 417 else mb=gmb; 418 } 419 else if(melt_style==FullMeltOnPartiallyFloatingEnum){ 420 if (phi<0.99999999) mb=fmb; 421 else mb=gmb; 422 } 423 else _error_("melt interpolation "<<EnumToStringx(melt_style)<<" not implemented yet"); 344 424 345 425 for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight*(bed+dt*(mb) + dt*vz)*basis[i]; 426 427 if(stabilization==5){ 428 /*SUPG*/ 429 basalelement->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 430 if(dim==1){ 431 vx_input->GetInputAverage(&vx); 432 tau=h/(2.*fabs(vx)+1e-10); 433 for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight*(dt*mb+dt*vz)*tau*(vx*dbasis[0*numnodes+i]); 434 } 435 else{ 436 vx_input->GetInputAverage(&vx); 437 vy_input->GetInputAverage(&vy); 438 tau=1*h/(2.*pow(vx*vx+vy*vy,0.5)+1e-10); 439 for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight*(bed*0.+dt*mb+dt*vz)*tau*(vx*dbasis[0*numnodes+i]+vy*dbasis[1*numnodes+i]); 440 } 441 } 346 442 } 347 443 … … 349 445 xDelete<IssmDouble>(xyz_list); 350 446 xDelete<IssmDouble>(basis); 447 xDelete<IssmDouble>(dbasis); 351 448 delete gauss; 352 449 if(basalelement->IsSpawnedElement()){basalelement->DeleteMaterials(); delete basalelement;}; … … 355 452 }/*}}}*/ 356 453 void FreeSurfaceBaseAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 357 454 _error_("not implemented yet"); 358 455 }/*}}}*/ 359 456 void FreeSurfaceBaseAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_interp,int control_index){/*{{{*/ -
issm/trunk/src/c/analyses/FreeSurfaceTopAnalysis.cpp
r26744 r27035 80 80 iomodel->FetchDataToInput(inputs,elements,"md.mask.ice_levelset",MaskIceLevelsetEnum); 81 81 iomodel->FetchDataToInput(inputs,elements,"md.initialization.vx",VxEnum); 82 iomodel->FetchDataToInput(inputs,elements,"md.initialization.vy",VyEnum); 82 83 if(iomodel->domaintype!=Domain2DhorizontalEnum){ 83 84 iomodel->FetchDataToInput(inputs,elements,"md.mesh.vertexonsurface",MeshVertexonsurfaceEnum); … … 111 112 }/*}}}*/ 112 113 ElementMatrix* FreeSurfaceTopAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/ 113 _error_("Not implemented");114 _error_("Not implemented"); 114 115 }/*}}}*/ 115 116 ElementMatrix* FreeSurfaceTopAnalysis::CreateKMatrix(Element* element){/*{{{*/ … … 120 121 IssmDouble *xyz_list = NULL; 121 122 IssmDouble Jdet,D_scalar,dt,h; 122 IssmDouble vel,vx,vy ;123 IssmDouble vel,vx,vy,tau; 123 124 124 125 /*Get top element*/ … … 195 196 } 196 197 197 if(stabilization==2){ 198 if(stabilization==1){ 199 /*artifical diffusion*/ 200 if(dim==1){ 201 vx_input->GetInputAverage(&vx); 202 D[0]=h/2.*fabs(vx); 203 } 204 else{ 205 vx_input->GetInputAverage(&vx); 206 vy_input->GetInputAverage(&vy); 207 208 D[0*dim+0]=h/2.0*fabs(vx); 209 D[1*dim+1]=h/2.0*fabs(vy); 210 } 211 } 212 else if(stabilization==2){ 198 213 /*Streamline upwinding*/ 199 214 if(dim==1){ … … 209 224 } 210 225 } 211 else if(stabilization== 1){212 /*S SA*/226 else if(stabilization==5){ 227 /*SUPG*/ 213 228 if(dim==1){ 214 229 vx_input->GetInputAverage(&vx); 215 D[0]=h/2.*fabs(vx);230 tau=h/(2.*fabs(vx)+1e-10); 216 231 } 217 232 else{ 218 233 vx_input->GetInputAverage(&vx); 219 234 vy_input->GetInputAverage(&vy); 220 221 D[0*dim+0]=h/2.0*fabs(vx); 222 D[1*dim+1]=h/2.0*fabs(vy); 235 tau=1*h/(2.*pow(vx*vx+vy*vy,0.5)+1e-10); 223 236 } 224 237 } … … 229 242 for(int j=0;j<numnodes;j++){ 230 243 Ke->values[i*numnodes+j] += ( 231 232 233 244 dbasis[0*numnodes+i] *(D[0*dim+0]*dbasis[0*numnodes+j] + D[0*dim+1]*dbasis[1*numnodes+j]) + 245 dbasis[1*numnodes+i] *(D[1*dim+0]*dbasis[0*numnodes+j] + D[1*dim+1]*dbasis[1*numnodes+j]) 246 ); 234 247 } 235 248 } … … 237 250 else{ 238 251 for(int i=0;i<numnodes;i++) for(int j=0;j<numnodes;j++) Ke->values[i*numnodes+j] += dbasis[0*numnodes+i]*D[0]*dbasis[0*numnodes+j]; 252 } 253 } 254 else if(stabilization==5){ 255 D_scalar=gauss->weight*Jdet*dt; 256 if(dim==2){ 257 for(int i=0;i<numnodes;i++){ 258 for(int j=0;j<numnodes;j++){ 259 Ke->values[i*numnodes+j]+=tau*D_scalar* 260 (vx*dbasis[0*numnodes+i]+vy*dbasis[1*numnodes+i])* 261 (vx*dbasis[0*numnodes+j]+vy*dbasis[1*numnodes+j]); 262 } 263 } 264 } 265 else{ 266 for(int i=0;i<numnodes;i++) for(int j=0;j<numnodes;j++) Ke->values[i*numnodes+j]+=tau*D_scalar*(vx*dbasis[0*numnodes+i])*(vx*dbasis[0*numnodes+j]); 239 267 } 240 268 } … … 251 279 }/*}}}*/ 252 280 ElementVector* FreeSurfaceTopAnalysis::CreatePVector(Element* element){/*{{{*/ 281 253 282 /*Intermediaries*/ 254 int domaintype,dim ;283 int domaintype,dim,stabilization; 255 284 IssmDouble Jdet,dt; 256 IssmDouble ms,surface,v z;285 IssmDouble ms,surface,vx,vy,vz,tau; 257 286 Element* topelement = NULL; 258 287 IssmDouble *xyz_list = NULL; … … 284 313 ElementVector* pe = topelement->NewElementVector(); 285 314 IssmDouble* basis = xNew<IssmDouble>(numnodes); 315 IssmDouble* dbasis = xNew<IssmDouble>(dim*numnodes); 286 316 287 317 /*Retrieve all inputs and parameters*/ 288 318 topelement->GetVerticesCoordinates(&xyz_list); 289 319 topelement->FindParam(&dt,TimesteppingTimeStepEnum); 290 Input* ms_input = topelement->GetInput(SmbMassBalanceEnum); _assert_(ms_input); 291 Input* surface_input = topelement->GetInput(SurfaceEnum); _assert_(surface_input); 292 Input* vz_input = NULL; 320 Input *ms_input = topelement->GetInput(SmbMassBalanceEnum); _assert_(ms_input); 321 Input *surface_input = topelement->GetInput(SurfaceEnum); _assert_(surface_input); 322 Input *vz_input = NULL; 323 Input *vx_input = NULL; 324 Input *vy_input = NULL; 293 325 switch(dim){ 294 case 1: vz_input = topelement->GetInput(VyEnum); _assert_(vz_input); break; 295 case 2: vz_input = topelement->GetInput(VzEnum); _assert_(vz_input); break; 326 case 1: 327 vx_input=topelement->GetInput(VxEnum); _assert_(vx_input); 328 vz_input = topelement->GetInput(VyEnum) ; _assert_(vz_input); 329 break; 330 case 2: 331 vx_input=topelement->GetInput(VxEnum); _assert_(vx_input); 332 vy_input = topelement->GetInput(VyEnum); _assert_(vy_input); 333 vz_input = topelement->GetInput(VzEnum); _assert_(vz_input); 334 break; 296 335 default: _error_("not implemented"); 297 336 } 337 IssmDouble h = topelement->CharacteristicLength(); 298 338 299 339 /*Initialize mb_correction to 0, do not forget!:*/ … … 312 352 } 313 353 354 if(stabilization==5){ 355 /*SUPG*/ 356 topelement->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 357 if(dim==1){ 358 vx_input->GetInputAverage(&vx); 359 tau=h/(2.*fabs(vx)+1e-10); 360 for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight*(dt*ms+dt*vz)*tau*(vx*dbasis[0*numnodes+i]); 361 } 362 else{ 363 vx_input->GetInputAverage(&vx); 364 vy_input->GetInputAverage(&vy); 365 tau=h/(2.*pow(vx*vx+vy*vy,0.5)+1e-10); 366 for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight*(dt*ms+dt*vz)*tau*(vx*dbasis[0*numnodes+i]+vy*dbasis[1*numnodes+i]); 367 } 368 } 369 314 370 /*Clean up and return*/ 315 371 xDelete<IssmDouble>(xyz_list); 316 372 xDelete<IssmDouble>(basis); 373 xDelete<IssmDouble>(dbasis); 317 374 delete gauss; 318 375 if(topelement->IsSpawnedElement()){topelement->DeleteMaterials(); delete topelement;}; … … 321 378 }/*}}}*/ 322 379 void FreeSurfaceTopAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 323 380 _error_("not implemented yet"); 324 381 }/*}}}*/ 325 382 void FreeSurfaceTopAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_interp,int control_index){/*{{{*/ … … 329 386 330 387 element->InputUpdateFromSolutionOneDof(solution,SurfaceEnum); 388 389 /*Now, we need to do some "processing"*/ 390 int numvertices = element->GetNumberOfVertices(); 391 int migration_style; 392 393 IssmDouble* surface = xNew<IssmDouble>(numvertices); 394 IssmDouble* newsurface = xNew<IssmDouble>(numvertices); 395 IssmDouble* thickness = xNew<IssmDouble>(numvertices); 396 IssmDouble* base = xNew<IssmDouble>(numvertices); 397 IssmDouble* bed = xNew<IssmDouble>(numvertices); 398 IssmDouble* phi = xNew<IssmDouble>(numvertices); 399 IssmDouble* sealevel = xNew<IssmDouble>(numvertices); 400 401 IssmDouble minthickness = element->FindParam(MasstransportMinThicknessEnum); 402 IssmDouble rho_ice = element->FindParam(MaterialsRhoIceEnum); 403 IssmDouble rho_water = element->FindParam(MaterialsRhoSeawaterEnum); 404 405 bool isgroundingline; 406 element->FindParam(&isgroundingline,TransientIsgroundinglineEnum); 407 element->FindParam(&migration_style,GroundinglineMigrationEnum); 408 if(isgroundingline) element->GetInputListOnVertices(&bed[0],BedEnum); 409 410 element->GetInputListOnVertices(&base[0],BaseEnum); 411 element->GetInputListOnVertices(&surface[0],SurfaceEnum); 412 element->GetInputListOnVertices(&phi[0],MaskOceanLevelsetEnum); 413 element->GetInputListOnVertices(&sealevel[0],SealevelEnum); 414 415 for(int i=0;i<numvertices;i++){ 416 newsurface[i]=surface[i]; 417 thickness[i]=surface[i]-base[i]; 418 /*Check solution*/ 419 if(xIsNan<IssmDouble>(thickness[i])) _error_("NaN found in solution vector"); 420 if(xIsInf<IssmDouble>(thickness[i])) _error_("Inf found in solution vector"); 421 422 /* check for thickness<minthickness */ 423 if(thickness[i]<minthickness){ 424 thickness[i]=minthickness; 425 if(phi[i]>0.){ 426 if(base[i]<=bed[i]) base[i] = bed[i]; 427 newsurface[i] = base[i]+minthickness; 428 }else{ 429 // assume floatation condition 430 newsurface[i] = (1.-rho_ice/rho_water)*minthickness; 431 base[i] = -rho_ice/rho_water*minthickness; 432 } 433 } 434 435 /* update thickness */ 436 thickness[i]=newsurface[i]-base[i]; 437 /* some checks */ 438 if(thickness[i]<0.) _error_("thickness<0"); 439 if(newsurface[i]<base[i]) _error_("surface<base"); 440 } 441 442 /* update inputs */ 443 element->AddInput(BaseEnum,base,element->GetElementType()); 444 element->AddInput(SurfaceEnum,newsurface,element->GetElementType()); 445 element->AddInput(ThicknessEnum,thickness,element->GetElementType()); 446 447 /* Free resources */ 448 xDelete<IssmDouble>(newsurface); 449 xDelete<IssmDouble>(surface); 450 xDelete<IssmDouble>(thickness); 451 xDelete<IssmDouble>(base); 452 xDelete<IssmDouble>(bed); 453 xDelete<IssmDouble>(phi); 454 xDelete<IssmDouble>(sealevel); 331 455 }/*}}}*/ 332 456 void FreeSurfaceTopAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ -
issm/trunk/src/c/analyses/HydrologyGlaDSAnalysis.cpp
r26744 r27035 472 472 473 473 /*Skip if water or ice shelf element*/ 474 if(element->IsAllFloating()) return;474 //if(element->IsAllFloating()) return; 475 475 476 476 /*Intermediaries */ … … 543 543 if(h_new[iv]<AEPS) h_new[iv] = AEPS; 544 544 } 545 546 /*Force floating ice to have zero sheet thickness*/ 547 if(element->IsAllFloating()){ 548 for(int iv=0;iv<numvertices;iv++) h_new[iv] = 0.; 549 } 545 550 546 551 element->AddInput(HydrologySheetThicknessEnum,h_new,P1Enum); … … 561 566 562 567 /*Skip if water or ice shelf element*/ 563 if(element->IsAllFloating()) return;568 //if(element->IsAllFloating()) return; 564 569 565 570 /*Intermediary*/ … … 604 609 } 605 610 611 /*Force floating ice to have zero effective pressure*/ 612 if(element->IsAllFloating()){ 613 for(int iv=0;iv<numnodes;iv++) N[iv] = 0.; 614 } 615 606 616 element->AddInput(EffectivePressureEnum,N,element->FiniteElement()); 607 617 608 618 /*Clean up and return*/ 609 619 delete gauss; -
issm/trunk/src/c/analyses/HydrologyShaktiAnalysis.cpp
r26744 r27035 286 286 IssmDouble lr,br,vx,vy,beta,lc; 287 287 IssmDouble alpha2,frictionheat; 288 IssmDouble PMPheat,d pressure_water[2],dbed[2];288 IssmDouble PMPheat,dissipation,dpressure_water[2],dbed[2]; 289 289 IssmDouble* xyz_list = NULL; 290 290 // IssmDouble dgapxx; /***/ … … 381 381 dpressure_water[0] = rho_water*g*(dh[0] - dbed[0]); 382 382 dpressure_water[1] = rho_water*g*(dh[1] - dbed[1]); 383 PMPheat=-CT*CW*conductivity*(dh[0]*dpressure_water[0]+dh[1]*dpressure_water[1]); 383 PMPheat=CT*CW*conductivity*rho_water*(dh[0]*dpressure_water[0]+dh[1]*dpressure_water[1]); 384 PMPheat=0; /*** TEST no PMPheat***/ 384 385 385 386 meltrate = 1/latentheat*(G+frictionheat+rho_water*g*conductivity*(dh[0]*dh[0]+dh[1]*dh[1])-PMPheat); 386 _assert_(meltrate>0.);387 387 388 388 for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight* … … 549 549 IssmDouble alpha2,frictionheat; 550 550 IssmDouble* xyz_list = NULL; 551 IssmDouble dpressure_water[2],dbed[2],PMPheat ;551 IssmDouble dpressure_water[2],dbed[2],PMPheat,dissipation; 552 552 IssmDouble q = 0.; 553 553 IssmDouble channelization = 0.; … … 629 629 dpressure_water[0] = rho_water*g*(dh[0] - dbed[0]); 630 630 dpressure_water[1] = rho_water*g*(dh[1] - dbed[1]); 631 PMPheat=-CT*CW*conductivity*(dh[0]*dpressure_water[0]+dh[1]*dpressure_water[1]); 631 PMPheat=CT*CW*conductivity*rho_water*(dh[0]*dpressure_water[0]+dh[1]*dpressure_water[1]); 632 PMPheat=0; /*** TEST no PMPheat***/ 633 dissipation=rho_water*g*conductivity*(dh[0]*dh[0]+dh[1]*dh[1]); 632 634 633 635 meltrate = 1/latentheat*(G+frictionheat+rho_water*g*conductivity*(dh[0]*dh[0]+dh[1]*dh[1])-PMPheat); 634 _assert_(meltrate>0.); 636 637 element->AddInput(DummyEnum,&meltrate,P0Enum); 638 element->AddInput(EsaEmotionEnum,&frictionheat,P0Enum); 639 element->AddInput(EsaNmotionEnum,&dissipation,P0Enum); 640 element->AddInput(EsaUmotionEnum,&PMPheat,P0Enum); 641 635 642 636 643 newgap += gauss->weight*Jdet*(gap+dt*( … … 664 671 665 672 /*Limit gap height to grow to surface*/ 666 if(newgap>thickness) 667 newgap = thickness; 673 // if(newgap>thickness) 674 // newgap = thickness; 675 if(newgap>1) 676 newgap = 1; 668 677 669 678 /*Add new gap as an input*/ -
issm/trunk/src/c/analyses/HydrologyTwsAnalysis.cpp
r26744 r27035 44 44 }/*}}}*/ 45 45 void HydrologyTwsAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 46 47 /*retrieve some parameters: */ 48 int hydrology_model; 49 int numoutputs; 50 char** requestedoutputs = NULL; 51 iomodel->FindConstant(&hydrology_model,"md.hydrology.model"); 52 53 /*Now, do we really want Tws?*/ 54 if(hydrology_model!=HydrologyTwsEnum) return; 55 56 parameters->AddObject(new IntParam(HydrologyModelEnum,hydrology_model)); 57 58 /*Requested outputs*/ 59 iomodel->FindConstant(&requestedoutputs,&numoutputs,"md.hydrology.requested_outputs"); 60 parameters->AddObject(new IntParam(HydrologyNumRequestedOutputsEnum,numoutputs)); 61 if(numoutputs)parameters->AddObject(new StringArrayParam(HydrologyRequestedOutputsEnum,requestedoutputs,numoutputs)); 62 iomodel->DeleteData(&requestedoutputs,numoutputs,"md.hydrology.requested_outputs"); 46 63 47 64 }/*}}}*/ -
issm/trunk/src/c/analyses/LevelsetAnalysis.cpp
r26744 r27035 10 10 #include "../modules/modules.h" 11 11 #include "../solutionsequences/solutionsequences.h" 12 #include <math.h> 12 13 13 14 void LevelsetAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ … … 79 80 80 81 iomodel->FetchDataToInput(inputs,elements,"md.mask.ice_levelset",MaskIceLevelsetEnum); 82 iomodel->FetchDataToInput(inputs,elements,"md.mask.ocean_levelset",MaskOceanLevelsetEnum); 81 83 iomodel->FetchDataToInput(inputs,elements,"md.initialization.vx",VxEnum); 82 84 iomodel->FetchDataToInput(inputs,elements,"md.initialization.vy",VyEnum); … … 88 90 iomodel->FindConstant(&isstochastic,"md.stochasticforcing.isstochasticforcing"); 89 91 switch(calvinglaw){ 92 93 /*"Continuous" calving laws*/ 90 94 case DefaultCalvingEnum: 91 95 iomodel->FetchDataToInput(inputs,elements,"md.calving.calvingrate",CalvingCalvingrateEnum); … … 103 107 iomodel->FetchDataToInput(inputs,elements,"md.geometry.bed",BedEnum); 104 108 break; 105 case CalvingMinthicknessEnum:106 iomodel->FetchDataToInput(inputs,elements,"md.geometry.bed",BedEnum);107 break;108 case CalvingHabEnum:109 iomodel->FetchDataToInput(inputs,elements,"md.calving.flotation_fraction",CalvingHabFractionEnum);110 break;111 case CalvingCrevasseDepthEnum:112 iomodel->FetchDataToInput(inputs,elements,"md.calving.water_height",WaterheightEnum);113 break;114 109 case CalvingDev2Enum: 115 110 iomodel->FetchDataToInput(inputs,elements,"md.calving.stress_threshold_groundedice",CalvingStressThresholdGroundediceEnum); 116 111 iomodel->FetchDataToInput(inputs,elements,"md.calving.stress_threshold_floatingice",CalvingStressThresholdFloatingiceEnum); 117 112 break; 113 case CalvingTestEnum: 114 break; 115 case CalvingParameterizationEnum: 116 iomodel->FetchDataToInput(inputs,elements,"md.calving.stress_threshold_groundedice",CalvingStressThresholdGroundediceEnum); 117 iomodel->FetchDataToInput(inputs,elements,"md.calving.stress_threshold_floatingice",CalvingStressThresholdFloatingiceEnum); 118 iomodel->FetchDataToInput(inputs,elements,"md.geometry.bed",BedEnum); 119 break; 120 121 /*"Discrete" calving laws (need to specify rate as 0 so that we can still solve the level set equation)*/ 122 case CalvingMinthicknessEnum: 123 iomodel->FetchDataToInput(inputs,elements,"md.geometry.bed",BedEnum); 124 iomodel->ConstantToInput(inputs,elements,0.,CalvingratexEnum,P1Enum); 125 iomodel->ConstantToInput(inputs,elements,0.,CalvingrateyEnum,P1Enum); 126 break; 127 case CalvingHabEnum: 128 iomodel->FetchDataToInput(inputs,elements,"md.calving.flotation_fraction",CalvingHabFractionEnum); 129 iomodel->ConstantToInput(inputs,elements,0.,CalvingratexEnum,P1Enum); 130 iomodel->ConstantToInput(inputs,elements,0.,CalvingrateyEnum,P1Enum); 131 break; 132 case CalvingCrevasseDepthEnum: 133 iomodel->FetchDataToInput(inputs,elements,"md.calving.water_height",WaterheightEnum); 134 iomodel->ConstantToInput(inputs,elements,0.,CalvingratexEnum,P1Enum); 135 iomodel->ConstantToInput(inputs,elements,0.,CalvingrateyEnum,P1Enum); 136 break; 137 118 138 default: 119 139 _error_("Calving law "<<EnumToStringx(calvinglaw)<<" not supported yet"); … … 126 146 case FrontalForcingsDefaultEnum: 127 147 iomodel->FetchDataToInput(inputs,elements,"md.frontalforcings.meltingrate",CalvingMeltingrateEnum); 148 if (calvinglaw == CalvingParameterizationEnum) { 149 iomodel->FetchDataToInput(inputs,elements,"md.frontalforcings.ablationrate",CalvingAblationrateEnum); 150 } 128 151 break; 129 152 case FrontalForcingsRignotEnum: … … 148 171 149 172 int calvinglaw; 173 IssmDouble *transparam = NULL; 174 IssmDouble yts; 175 int N,M; 176 bool interp,cycle; 177 150 178 iomodel->FindConstant(&calvinglaw,"md.calving.law"); 151 179 switch(calvinglaw){ … … 168 196 parameters->AddObject(iomodel->CopyConstantObject("md.calving.height_above_floatation",CalvingHeightAboveFloatationEnum)); 169 197 break; 198 case CalvingTestEnum: 199 iomodel->FindConstant(&interp,"md.timestepping.interp_forcing"); 200 iomodel->FindConstant(&cycle,"md.timestepping.cycle_forcing"); 201 iomodel->FetchData(&transparam,&N,&M,"md.calving.speedfactor"); 202 if(N==1){ 203 _assert_(M==1); 204 parameters->AddObject(new DoubleParam(CalvingTestSpeedfactorEnum,transparam[0])); 205 } 206 else{ 207 _assert_(N==2); 208 parameters->AddObject(new TransientParam(CalvingTestSpeedfactorEnum,&transparam[0],&transparam[M],interp,cycle,M)); 209 } 210 xDelete<IssmDouble>(transparam); 211 iomodel->FetchData(&transparam,&N,&M,"md.calving.independentrate"); 212 if(N==1){ 213 _assert_(M==1); 214 parameters->AddObject(new DoubleParam(CalvingTestIndependentRateEnum,transparam[0])); 215 } 216 else{ 217 _assert_(N==2); 218 parameters->AddObject(new TransientParam(CalvingTestIndependentRateEnum,&transparam[0],&transparam[M],interp,cycle,M)); 219 } 220 xDelete<IssmDouble>(transparam); 221 break; 222 case CalvingParameterizationEnum: 223 parameters->AddObject(iomodel->CopyConstantObject("md.calving.min_thickness",CalvingMinthicknessEnum)); 224 parameters->AddObject(iomodel->CopyConstantObject("md.calving.use_param",CalvingUseParamEnum)); 225 parameters->AddObject(iomodel->CopyConstantObject("md.calving.scale_theta",CalvingScaleThetaEnum)); 226 parameters->AddObject(iomodel->CopyConstantObject("md.calving.amp_alpha",CalvingAmpAlphaEnum)); 227 parameters->AddObject(iomodel->CopyConstantObject("md.calving.midp",CalvingMidpointEnum)); 228 parameters->AddObject(iomodel->CopyConstantObject("md.calving.nonlinearlaw",CalvingNonlinearLawEnum)); 229 break; 170 230 default: 171 231 _error_("Calving law "<<EnumToStringx(calvinglaw)<<" not supported yet"); … … 175 235 int melt_parameterization; 176 236 iomodel->FindConstant(&melt_parameterization,"md.frontalforcings.parameterization"); 177 int M,N;178 IssmDouble* transparam = NULL;179 237 switch(melt_parameterization){ 180 238 case FrontalForcingsDefaultEnum: … … 209 267 /*parameters: */ 210 268 int stabilization; 211 bool save_results;212 femmodel->parameters->FindParam(&save_results,SaveResultsEnum);213 269 femmodel->parameters->FindParam(&stabilization,LevelsetStabilizationEnum); 214 270 … … 222 278 else{ 223 279 solutionsequence_linear(femmodel); 224 }225 226 if(save_results){227 int outputs[1] = {MaskIceLevelsetEnum};228 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],1);229 280 } 230 281 }/*}}}*/ … … 400 451 break; 401 452 } 453 case 6:{ 454 /*SUPG*/ 455 IssmDouble vx,vy; 456 mf_vx_input->GetInputAverage(&vx); 457 mf_vy_input->GetInputAverage(&vy); 458 vel=sqrt(vx*vx+vy*vy)+1.e-8; 459 IssmDouble ECN, K; 460 ECN = vel *dt /h; 461 K = 1./tanh(ECN) - 1./ECN; 462 // if (ECN<1e-6) K = ECN /3.0; 463 464 /*According to Hilmar, xi=K is too large*/ 465 IssmDouble xi=0.1*K; 466 467 IssmDouble tau=xi*h/(2*vel); 468 Input* levelset_input = NULL; 469 470 471 IssmDouble kappa; 472 IssmDouble p=4, q=4; 473 IssmDouble phi[3]; 474 475 levelset_input=basalelement->GetInput(MaskIceLevelsetEnum); _assert_(levelset_input); 476 levelset_input->GetInputValue(&phi[0], gauss); 477 478 IssmDouble dphidx=0., dphidy=0.; 479 IssmDouble nphi; 480 481 for(int i=0;i<numnodes;i++){ 482 dphidx += phi[i]*dbasis[0*numnodes+i]; 483 dphidy += phi[i]*dbasis[1*numnodes+i]; 484 } 485 nphi = sqrt(dphidx*dphidx+dphidy*dphidy); 486 487 if (nphi >= 1) { 488 kappa = 1 - 1.0/nphi; 489 } 490 else { 491 kappa = 0.5/M_PI *sin(2*M_PI*nphi)/nphi; 492 } 493 494 kappa = kappa * vel / h; 495 496 /*Mass matrix - part 2*/ 497 for(int i=0;i<numnodes;i++){ 498 for(int j=0;j<numnodes;j++){ 499 Ke->values[i*numnodes+j]+=gauss->weight*Jdet*tau*basis[j]*(vx*dbasis[0*numnodes+i]+vy*dbasis[1*numnodes+i]); 500 } 501 } 502 503 /*Advection matrix - part 2, A*/ 504 for(int i=0;i<numnodes;i++){ 505 for(int j=0;j<numnodes;j++){ 506 Ke->values[i*numnodes+j]+=dt*gauss->weight*Jdet*tau*(vx*dbasis[0*numnodes+j]+vy*dbasis[1*numnodes+j])*(vx*dbasis[0*numnodes+i]+vy*dbasis[1*numnodes+i]); 507 } 508 } 509 /*Add the pertubation term \nabla\cdot(\kappa*\nabla\phi)*/ 510 for(int i=0;i<numnodes;i++){ 511 for(int j=0;j<numnodes;j++){ 512 for(int k=0;k<dim;k++){ 513 Ke->values[i*numnodes+j]+= dt*gauss->weight*Jdet*kappa*dbasis[k*numnodes+j]*dbasis[k*numnodes+i]; 514 } 515 } 516 } 517 518 break; 519 } 402 520 default: 403 521 _error_("unknown type of stabilization in LevelsetAnalysis.cpp"); … … 435 553 IssmDouble* basis = xNew<IssmDouble>(numnodes); 436 554 IssmDouble* dbasis = NULL; 437 if( stabilization==5) dbasis= xNew<IssmDouble>(2*numnodes);555 if((stabilization==5) |(stabilization == 6)) dbasis= xNew<IssmDouble>(2*numnodes); 438 556 439 557 /*Retrieve all inputs and parameters*/ … … 456 574 457 575 if(stabilization==5){ /*SUPG*/ 458 576 IssmDouble vx,vy,vel; 459 577 basalelement->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 460 578 mf_vx_input->GetInputAverage(&vx); … … 469 587 } 470 588 } 589 else if (stabilization ==6) { 590 IssmDouble vx,vy,vel; 591 basalelement->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 592 mf_vx_input->GetInputAverage(&vx); 593 mf_vy_input->GetInputAverage(&vy); 594 vel=sqrt(vx*vx+vy*vy)+1.e-8; 595 596 IssmDouble ECN, K; 597 ECN = vel *dt /h; 598 K = 1./tanh(ECN) - 1./ECN; 599 // if (ECN<1e-6) K = ECN /3.0; 600 601 /*According to Hilmar, xi=K is too large*/ 602 IssmDouble xi=0.1*K; 603 604 IssmDouble tau=xi*h/(2*vel); 605 606 /*Force vector - part 2*/ 607 for(int i=0;i<numnodes;i++){ 608 pe->values[i]+=Jdet*gauss->weight*lsf*tau*(vx*dbasis[0*numnodes+i]+vy*dbasis[1*numnodes+i]); 609 } 610 } 471 611 } 472 612 … … 474 614 xDelete<IssmDouble>(xyz_list); 475 615 xDelete<IssmDouble>(basis); 476 616 xDelete<IssmDouble>(dbasis); 477 617 basalelement->FindParam(&domaintype,DomainTypeEnum); 478 618 if(basalelement->IsSpawnedElement()){basalelement->DeleteMaterials(); delete basalelement;}; … … 525 665 } 526 666 }/*}}}*/ 667 void LevelsetAnalysis::PostProcess(FemModel* femmodel){/*{{{*/ 668 669 /*This function is only used by "discrete calving laws" for which we change 670 * the value of the levelset after the advection step (level set equation 671 * solve) based on the law*/ 672 673 /*Intermediaries*/ 674 int calvinglaw; 675 IssmDouble newlevelset[6]; 676 femmodel->parameters->FindParam(&calvinglaw,CalvingLawEnum); 677 678 /*Apply minimum thickness criterion*/ 679 if(calvinglaw==CalvingMinthicknessEnum || calvinglaw==CalvingVonmisesEnum || calvinglaw==CalvingParameterizationEnum){ 680 681 IssmDouble mig_max = femmodel->parameters->FindParam(MigrationMaxEnum); 682 IssmDouble dt = femmodel->parameters->FindParam(TimesteppingTimeStepEnum); 683 684 /*Get current distance to terminus*/ 685 InputDuplicatex(femmodel,MaskIceLevelsetEnum,DistanceToCalvingfrontEnum); 686 femmodel->DistanceToFieldValue(MaskIceLevelsetEnum,0,DistanceToCalvingfrontEnum); 687 688 /*Intermediaries*/ 689 IssmDouble thickness,bed,sealevel,distance,levelset; 690 IssmDouble min_thickness = femmodel->parameters->FindParam(CalvingMinthicknessEnum); 691 692 /*Loop over all elements of this partition*/ 693 for(Object* & object : femmodel->elements->objects){ 694 Element* element = xDynamicCast<Element*>(object); 695 696 /*no need to postprocess an ice free element*/ 697 if(!element->IsIceInElement()) continue; 698 699 int numnodes = element->GetNumberOfNodes(); _assert_(numnodes<7); 700 Gauss* gauss = element->NewGauss(); 701 Input *H_input = element->GetInput(ThicknessEnum); _assert_(H_input); 702 Input *b_input = element->GetInput(BedEnum); _assert_(b_input); 703 Input *sl_input = element->GetInput(SealevelEnum); _assert_(sl_input); 704 Input *dis_input = element->GetInput(DistanceToCalvingfrontEnum); _assert_(dis_input); 705 Input *levelset_input = element->GetInput(MaskIceLevelsetEnum); _assert_(levelset_input); 706 707 /*Potentially constrain nodes of this element*/ 708 for(int in=0;in<numnodes;in++){ 709 gauss->GaussNode(element->GetElementType(),in); 710 711 levelset_input->GetInputValue(&levelset,gauss); 712 H_input->GetInputValue(&thickness,gauss); 713 b_input->GetInputValue(&bed,gauss); 714 sl_input->GetInputValue(&sealevel,gauss); 715 dis_input->GetInputValue(&distance,gauss); 716 717 if(thickness<min_thickness && bed<sealevel && fabs(distance)<mig_max*dt && levelset<0){ 718 newlevelset[in] = +400.; //Arbitrary > 0 number (i.e. deactivate this node) 719 } 720 else{ 721 newlevelset[in] = levelset; 722 } 723 } 724 element->AddInput(MaskIceLevelsetEnum,&newlevelset[0],element->GetElementType()); 725 delete gauss; 726 } 727 } 728 }/*}}}*/ 527 729 void LevelsetAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 528 730 … … 530 732 int calvinglaw; 531 733 femmodel->parameters->FindParam(&calvinglaw,CalvingLawEnum); 532 533 if(calvinglaw==CalvingMinthicknessEnum || calvinglaw==CalvingVonmisesEnum){ 734 IssmDouble mig_max = femmodel->parameters->FindParam(MigrationMaxEnum); 735 IssmDouble dt = femmodel->parameters->FindParam(TimesteppingTimeStepEnum); 736 737 /*Get current distance to terminus*/ 738 InputDuplicatex(femmodel,MaskIceLevelsetEnum,DistanceToCalvingfrontEnum); 739 femmodel->DistanceToFieldValue(MaskIceLevelsetEnum,0,DistanceToCalvingfrontEnum); 740 741 if(calvinglaw==CalvingHabEnum){ 534 742 535 743 /*Intermediaries*/ 536 IssmDouble thickness,bed,sealevel; 537 IssmDouble min_thickness = femmodel->parameters->FindParam(CalvingMinthicknessEnum); 744 IssmDouble thickness,water_depth,distance,hab_fraction; 538 745 539 746 /*Loop over all elements of this partition*/ … … 541 748 Element* element = xDynamicCast<Element*>(object); 542 749 543 int numnodes = element->GetNumberOfNodes(); 544 Gauss* gauss = element->NewGauss(); 545 Input* H_input = element->GetInput(ThicknessEnum); _assert_(H_input); 546 Input* b_input = element->GetInput(BedEnum); _assert_(b_input); 547 Input* sl_input = element->GetInput(SealevelEnum); _assert_(sl_input); 750 IssmDouble rho_ice = element->FindParam(MaterialsRhoIceEnum); 751 IssmDouble rho_water = element->FindParam(MaterialsRhoSeawaterEnum); 752 753 int numnodes = element->GetNumberOfNodes(); 754 Gauss* gauss = element->NewGauss(); 755 Input* H_input = element->GetInput(ThicknessEnum); _assert_(H_input); 756 Input* bed_input = element->GetInput(BedEnum); _assert_(bed_input); 757 Input* hab_fraction_input = element->GetInput(CalvingHabFractionEnum); _assert_(hab_fraction_input); 758 Input* dis_input = element->GetInput(DistanceToCalvingfrontEnum); _assert_(dis_input); 548 759 549 760 /*Potentially constrain nodes of this element*/ … … 554 765 555 766 H_input->GetInputValue(&thickness,gauss); 556 b_input->GetInputValue(&bed,gauss);557 sl_input->GetInputValue(&sealevel,gauss);558 if(thickness<min_thickness && bed<sealevel){559 node->ApplyConstraint(0,+1.);560 }561 else {562 /* no ice, set no spc */563 node->DofInFSet(0);564 }565 }566 delete gauss;567 }568 }569 else if(calvinglaw==CalvingHabEnum){570 571 /*Intermediaries*/572 IssmDouble thickness,water_depth,levelset,hab_fraction;573 574 /*Get the fraction of the flotation thickness at the terminus*/575 InputDuplicatex(femmodel,MaskIceLevelsetEnum,DistanceToCalvingfrontEnum);576 femmodel->DistanceToFieldValue(MaskIceLevelsetEnum,0,DistanceToCalvingfrontEnum);577 578 /*Loop over all elements of this partition*/579 for(Object* & object : femmodel->elements->objects){580 Element* element = xDynamicCast<Element*>(object);581 582 IssmDouble rho_ice = element->FindParam(MaterialsRhoIceEnum);583 IssmDouble rho_water = element->FindParam(MaterialsRhoSeawaterEnum);584 585 int numnodes = element->GetNumberOfNodes();586 Gauss* gauss = element->NewGauss();587 Input* H_input = element->GetInput(ThicknessEnum); _assert_(H_input);588 Input* bed_input = element->GetInput(BedEnum); _assert_(bed_input);589 Input* hab_fraction_input = element->GetInput(CalvingHabFractionEnum); _assert_(hab_fraction_input);590 Input* ls_input = element->GetInput(DistanceToCalvingfrontEnum); _assert_(ls_input);591 592 /*Potentially constrain nodes of this element*/593 for(int in=0;in<numnodes;in++){594 gauss->GaussNode(element->GetElementType(),in);595 Node* node=element->GetNode(in);596 if(!node->IsActive()) continue;597 598 H_input->GetInputValue(&thickness,gauss);599 767 bed_input->GetInputValue(&water_depth,gauss); 600 ls_input->GetInputValue(&levelset,gauss);768 dis_input->GetInputValue(&distance,gauss); 601 769 hab_fraction_input->GetInputValue(&hab_fraction,gauss); 602 770 603 if(thickness<((rho_water/rho_ice)*(1+hab_fraction)*-water_depth) && levelset>-300. && levelset<0.){771 if(thickness<((rho_water/rho_ice)*(1+hab_fraction)*-water_depth) && fabs(distance)<mig_max*dt){ 604 772 node->ApplyConstraint(0,+1.); 605 773 } … … 628 796 629 797 IssmDouble crevasse_threshold = femmodel->parameters->FindParam(CalvingCrevasseThresholdEnum); 630 IssmDouble mig_max = femmodel->parameters->FindParam(MigrationMaxEnum); 631 IssmDouble dt = femmodel->parameters->FindParam(TimesteppingTimeStepEnum); 798 632 799 633 800 for(Object* & object : femmodel->elements->objects){ … … 704 871 surface_input->GetInputValue(&surface,gauss); 705 872 873 /*FIXME: not sure about levelset<0. && fabs(levelset)>-mig_max*dt! SHould maybe be distance<mig_max*dt*/ 706 874 if((surface_crevasse>surface || crevassedepth>crevasse_threshold*thickness) && bed<0. && levelset<0. && levelset>-mig_max*dt && constraint_nodes[node->Lid()]==0.){ 707 875 local_nflipped++; -
issm/trunk/src/c/analyses/LevelsetAnalysis.h
r26744 r27035 32 32 void InputUpdateFromSolution(IssmDouble* solution,Element* element); 33 33 void UpdateConstraints(FemModel* femmodel); 34 35 /*Specific methods to LevelsetAnalysis*/ 36 void PostProcess(FemModel* femmodel); 34 37 }; 35 38 #endif -
issm/trunk/src/c/analyses/LoveAnalysis.cpp
r26744 r27035 33 33 parameters->AddObject(iomodel->CopyConstantObject("md.love.mu0",LoveMu0Enum)); 34 34 parameters->AddObject(iomodel->CopyConstantObject("md.love.Gravitational_Constant",LoveGravitationalConstantEnum)); 35 parameters->AddObject(iomodel->CopyConstantObject("md.love.chandler_wobble",LoveChandlerWobbleEnum)); 35 36 parameters->AddObject(iomodel->CopyConstantObject("md.love.allow_layer_deletion",LoveAllowLayerDeletionEnum)); 36 37 parameters->AddObject(iomodel->CopyConstantObject("md.love.underflow_tol",LoveUnderflowTolEnum)); 38 parameters->AddObject(iomodel->CopyConstantObject("md.love.pw_threshold",LovePostWidderThresholdEnum)); 37 39 parameters->AddObject(iomodel->CopyConstantObject("md.love.integration_steps_per_layer",LoveIntStepsPerLayerEnum)); 38 40 parameters->AddObject(iomodel->CopyConstantObject("md.love.istemporal",LoveIsTemporalEnum)); … … 43 45 parameters->AddObject(iomodel->CopyConstantObject("md.love.core_mantle_boundary",LoveCoreMantleBoundaryEnum)); 44 46 parameters->AddObject(iomodel->CopyConstantObject("md.love.complex_computation",LoveComplexComputationEnum)); 47 parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.rotational.equatorialmoi",RotationalEquatorialMoiEnum)); 48 parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.rotational.polarmoi",RotationalPolarMoiEnum)); 49 parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.rotational.angularvelocity",RotationalAngularVelocityEnum)); 50 parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.lovenumbers.tk2secular",TidalLoveK2SecularEnum)); 45 51 }/*}}}*/ 46 52 void LoveAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ -
issm/trunk/src/c/analyses/MasstransportAnalysis.cpp
r26744 r27035 182 182 break; 183 183 case SpatialLinearFloatingMeltRateEnum: 184 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsDeepwaterMeltingRateEnum); 185 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_elevation",BasalforcingsDeepwaterElevationEnum); 186 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.upperwater_elevation",BasalforcingsUpperwaterElevationEnum); 184 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsSpatialDeepwaterMeltingRateEnum); 185 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_elevation",BasalforcingsSpatialDeepwaterElevationEnum); 186 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.upperwater_melting_rate",BasalforcingsSpatialUpperwaterMeltingRateEnum); 187 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.upperwater_elevation",BasalforcingsSpatialUpperwaterElevationEnum); 188 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.perturbation_melting_rate",BasalforcingsPerturbationMeltingRateEnum,0.); 189 if(isstochastic){ 190 iomodel->FetchDataToInput(inputs,elements,"md.stochasticforcing.default_id",StochasticForcingDefaultIdEnum); 191 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_melting_rate",BaselineBasalforcingsSpatialDeepwaterMeltingRateEnum); 192 } 187 193 break; 188 194 case BasalforcingsPicoEnum: … … 212 218 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.ocean_salinity",BasalforcingsOceanSalinityEnum); 213 219 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.ocean_temp",BasalforcingsOceanTempEnum); 220 break; 221 case AutoregressionLinearFloatingMeltRateEnum: 222 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.basin_id",BasalforcingsLinearBasinIdEnum); 223 if(isstochastic) iomodel->FetchDataToInput(inputs,elements,"md.stochasticforcing.default_id",StochasticForcingDefaultIdEnum); 214 224 break; 215 225 default: -
issm/trunk/src/c/analyses/SamplingAnalysis.cpp
r26744 r27035 76 76 iomodel->FetchDataToInput(inputs,elements,"md.sampling.kappa",SamplingKappaEnum); 77 77 iomodel->FetchDataToInput(inputs,elements,"md.sampling.beta",SamplingBetaEnum,0.); 78 iomodel->FetchDataToInput(inputs,elements,"md.sampling.tau",SamplingTauEnum); 78 79 iomodel->FetchDataToInput(inputs,elements,"md.initialization.sample",SampleEnum,0.); 80 iomodel->FetchDataToInput(inputs,elements,"md.initialization.sample",SampleNoiseEnum,0.); 81 if(iomodel->solution_enum==TransientSolutionEnum) iomodel->FetchDataToInput(inputs,elements,"md.sampling.phi",SamplingPhiEnum,0.); 79 82 80 83 }/*}}}*/ … … 84 87 char** requestedoutputs = NULL; 85 88 86 parameters->AddObject(iomodel->CopyConstantObject("md.sampling.tau",SamplingTauEnum));87 89 parameters->AddObject(iomodel->CopyConstantObject("md.sampling.alpha",SamplingAlphaEnum)); 88 90 parameters->AddObject(iomodel->CopyConstantObject("md.sampling.robin",SamplingRobinEnum)); 89 if(solution_enum==TransientSolutionEnum) parameters->AddObject(iomodel->CopyConstantObject("md.sampling.phi",SamplingPhiEnum));90 91 parameters->AddObject(iomodel->CopyConstantObject("md.sampling.seed",SamplingSeedEnum)); 91 92 … … 273 274 element->GetDofListLocal(&doflist,NoneApproximationEnum,GsetEnum); 274 275 IssmDouble* newsample = xNew<IssmDouble>(numnodes); 276 IssmDouble* tau = xNew<IssmDouble>(numnodes); 277 element->GetInputListOnNodes(&tau[0],SamplingTauEnum); 275 278 276 279 /*Use the dof list to index into the solution vector: */ 277 280 for(int i=0;i<numnodes;i++){ 278 newsample[i]=solution[doflist[i]]; 281 newsample[i]=solution[doflist[i]] / tau[i]; // new 282 279 283 /*Check solution*/ 280 284 if(xIsNan<IssmDouble>(newsample[i])) _error_("NaN found in solution vector"); … … 287 291 /*Free ressources:*/ 288 292 xDelete<IssmDouble>(newsample); 293 xDelete<IssmDouble>(tau); 289 294 xDelete<int>(doflist); 290 295 }/*}}}*/ … … 418 423 *pMff=Mff; 419 424 }/*}}}*/ 425 void SamplingAnalysis::UpdateTransientSample(FemModel * femmodel){ 426 427 for(int j=0;j<femmodel->elements->Size();j++){ 428 Element* element=(Element*)femmodel->elements->GetObjectByOffset(j); 429 UpdateTransientSample(element); 430 } 431 432 } 433 void SamplingAnalysis::UpdateTransientSample(Element * element){ 434 435 /*Intermediaries */ 436 IssmDouble phi, sample, noise; 437 438 /*Fetch number vertices for this element*/ 439 int numvertices = element->GetNumberOfVertices(); 440 441 /*Initialize new sample*/ 442 IssmDouble* sample_new = xNew<IssmDouble>(numvertices); 443 444 /*Retrieve all inputs and parameters*/ 445 Input* sample_input=element->GetInput(SampleOldEnum); _assert_(sample_input); 446 Input* noise_input=element->GetInput(SampleNoiseEnum); _assert_(noise_input); 447 Input* phi_input=element->GetInput(SamplingPhiEnum); _assert_(phi_input); 448 449 /* Start looping on the number of gaussian points: */ 450 Gauss* gauss=element->NewGauss(); 451 for(int iv=0;iv<numvertices;iv++){ 452 gauss->GaussVertex(iv); 453 454 /*Get input values at gauss points*/ 455 sample_input->GetInputValue(&sample,gauss); 456 noise_input->GetInputValue(&noise,gauss); 457 phi_input->GetInputValue(&phi,gauss); 458 459 /*Get new sample*/ 460 sample_new[iv] = phi*sample + noise; 461 462 } 463 464 element->AddInput(SampleEnum,sample_new,element->GetElementType()); 465 466 /*Clean up and return*/ 467 xDelete<IssmDouble>(sample_new); 468 delete gauss; 469 470 } -
issm/trunk/src/c/analyses/SamplingAnalysis.h
r26744 r27035 40 40 void MassMatrix(Matrix<IssmDouble>** pMff,FemModel* femmodel); 41 41 42 void UpdateTransientSample(FemModel* femmodel); 43 void UpdateTransientSample(Element * element); 44 42 45 }; 43 46 #endif -
issm/trunk/src/c/analyses/SealevelchangeAnalysis.cpp
r26744 r27035 85 85 IssmDouble* love_tk=NULL; 86 86 IssmDouble* love_tl=NULL; 87 IssmDouble* love_pmtf_colinear=NULL; 88 IssmDouble* love_pmtf_ortho=NULL; 87 89 IssmDouble* love_timefreq=NULL; 88 90 bool love_istime=true; … … 101 103 IssmDouble* H_viscoelastic_interpolated= NULL; 102 104 IssmDouble* H_viscoelastic_local = NULL; 105 IssmDouble* Pmtf_col_interpolated = NULL; 106 IssmDouble* Pmtf_ortho_interpolated = NULL; 107 IssmDouble* Pmtf_z_interpolated = NULL; 108 IssmDouble* Love_th2_interpolated = NULL; 109 IssmDouble* Love_tk2_interpolated = NULL; 110 IssmDouble* Love_tl2_interpolated = NULL; 111 103 112 int M,m,lower_row,upper_row; 104 113 IssmDouble degacc=.01; … … 166 175 /*compute planet area and plug into parameters:*/ 167 176 iomodel->FetchData(&planetradius,"md.solidearth.planetradius"); 168 planetarea=4* PI*planetradius*planetradius;177 planetarea=4*M_PI*planetradius*planetradius; 169 178 parameters->AddObject(new DoubleParam(SolidearthPlanetAreaEnum,planetarea)); 170 179 … … 253 262 iomodel->FetchData(&love_k,&ndeg,&precomputednt,"md.solidearth.lovenumbers.k"); 254 263 iomodel->FetchData(&love_l,&ndeg,&precomputednt,"md.solidearth.lovenumbers.l"); 255 iomodel->FetchData(&love_th,&ndeg,&precomputednt,"md.solidearth.lovenumbers.th");256 iomodel->FetchData(&love_tk,&ndeg,&precomputednt,"md.solidearth.lovenumbers.tk");257 iomodel->FetchData(&love_tl,&ndeg,&precomputednt,"md.solidearth.lovenumbers.tl");258 264 259 265 parameters->AddObject(new DoubleParam(SolidearthSettingsTimeAccEnum,timeacc)); … … 261 267 parameters->AddObject(new DoubleMatParam(LoadLoveKEnum,love_k,ndeg,precomputednt)); 262 268 parameters->AddObject(new DoubleMatParam(LoadLoveLEnum,love_l,ndeg,precomputednt)); 263 parameters->AddObject(new DoubleMatParam(TidalLoveHEnum,love_th,ndeg,precomputednt)); 264 parameters->AddObject(new DoubleMatParam(TidalLoveKEnum,love_tk,ndeg,precomputednt)); 265 parameters->AddObject(new DoubleMatParam(TidalLoveLEnum,love_tl,ndeg,precomputednt)); 269 270 if (rotation){ 271 iomodel->FetchData(&love_th,&ndeg,&precomputednt,"md.solidearth.lovenumbers.th"); 272 iomodel->FetchData(&love_tk,&ndeg,&precomputednt,"md.solidearth.lovenumbers.tk"); 273 iomodel->FetchData(&love_tl,&ndeg,&precomputednt,"md.solidearth.lovenumbers.tl"); 274 iomodel->FetchData(&love_pmtf_colinear,&dummy,&precomputednt,"md.solidearth.lovenumbers.pmtf_colinear"); 275 iomodel->FetchData(&love_pmtf_ortho,&dummy,&precomputednt,"md.solidearth.lovenumbers.pmtf_ortho"); 276 277 parameters->AddObject(new DoubleMatParam(LovePolarMotionTransferFunctionColinearEnum,love_pmtf_colinear,1,precomputednt)); 278 parameters->AddObject(new DoubleMatParam(LovePolarMotionTransferFunctionOrthogonalEnum,love_pmtf_ortho,1,precomputednt)); 279 parameters->AddObject(new DoubleMatParam(TidalLoveHEnum,love_th,ndeg,precomputednt)); 280 parameters->AddObject(new DoubleMatParam(TidalLoveKEnum,love_tk,ndeg,precomputednt)); 281 parameters->AddObject(new DoubleMatParam(TidalLoveLEnum,love_tl,ndeg,precomputednt)); 282 } 283 266 284 parameters->AddObject(new DoubleMatParam(LoveTimeFreqEnum,love_timefreq,precomputednt,1)); 267 285 parameters->AddObject(new BoolParam(LoveIsTimeEnum,love_istime)); … … 283 301 parameters->AddObject(new IntParam(SealevelchangeViscousIndexEnum,0)); 284 302 xDelete<IssmDouble>(viscoustimes); 303 if (rotation){ 304 IssmDouble* viscouspolarmotion=NULL; 305 viscouspolarmotion=xNewZeroInit<IssmDouble>(3*nt); 306 parameters->AddObject(new DoubleMatParam(SealevelchangeViscousPolarMotionEnum,viscouspolarmotion,3,nt)); 307 xDelete<IssmDouble>(viscouspolarmotion); 308 } 285 309 } 286 310 else { … … 307 331 } 308 332 309 if(rotation)parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.lovenumbers.tk2secular",TidalLoveK2SecularEnum)); 310 333 if(rotation) parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.lovenumbers.tk2secular",TidalLoveK2SecularEnum)); 311 334 if(selfattraction){ 312 335 313 /*compute combined legendre + love number (elastic green function :*/336 /*compute combined legendre + love number (elastic green function):*/ 314 337 m=DetermineLocalSize(M,IssmComm::GetComm()); 315 338 GetOwnershipBoundariesFromRange(&lower_row,&upper_row,m,IssmComm::GetComm()); … … 441 464 U_viscoelastic_interpolated=xNew<IssmDouble>(M*nt,"t"); 442 465 if(horiz)H_viscoelastic_interpolated=xNew<IssmDouble>(M*nt,"t"); 466 if(rotation){ 467 Pmtf_col_interpolated=xNew<IssmDouble>(nt,"t"); 468 Pmtf_ortho_interpolated=xNew<IssmDouble>(nt,"t"); 469 Pmtf_z_interpolated=xNew<IssmDouble>(nt,"t"); 470 Love_tk2_interpolated=xNew<IssmDouble>(nt,"t"); 471 Love_th2_interpolated=xNew<IssmDouble>(nt,"t"); 472 if (horiz) Love_tl2_interpolated=xNew<IssmDouble>(nt,"t"); 473 } 443 474 #else 444 475 G_viscoelastic_interpolated=xNew<IssmDouble>(M*nt); 445 476 U_viscoelastic_interpolated=xNew<IssmDouble>(M*nt); 446 477 if(horiz)H_viscoelastic_interpolated=xNew<IssmDouble>(M*nt); 478 if(rotation){ 479 Pmtf_col_interpolated=xNew<IssmDouble>(nt); 480 Pmtf_ortho_interpolated=xNew<IssmDouble>(nt); 481 Pmtf_z_interpolated=xNew<IssmDouble>(nt); 482 Love_tk2_interpolated=xNew<IssmDouble>(nt); 483 Love_th2_interpolated=xNew<IssmDouble>(nt); 484 if (horiz) Love_tl2_interpolated=xNew<IssmDouble>(nt); 485 } 447 486 #endif 448 487 … … 477 516 if(horiz)H_viscoelastic_interpolated[timeindex]=(1-lincoeff)*H_viscoelastic[timepreindex]+lincoeff*H_viscoelastic[timepreindex+1]; 478 517 } 518 519 if(rotation){ 520 int timepreindex= 2*precomputednt+timeindex2; 521 Pmtf_col_interpolated[t]=(1.0-lincoeff)*love_pmtf_colinear[timeindex2]+lincoeff*love_pmtf_colinear[timeindex2+1]; 522 Pmtf_ortho_interpolated[t]=(1.0-lincoeff)*love_pmtf_ortho[timeindex2]+lincoeff*love_pmtf_ortho[timeindex2+1]; 523 Pmtf_z_interpolated[t]=1.0+(1.0-lincoeff)*love_k[timepreindex]+lincoeff*love_k[timepreindex+1]; 524 Love_tk2_interpolated[t]=(1.0-lincoeff)*love_tk[timepreindex]+lincoeff*love_tk[timepreindex+1]; 525 Love_th2_interpolated[t]=(1.0-lincoeff)*love_th[timepreindex]+lincoeff*love_th[timepreindex+1]; 526 if (horiz) Love_tl2_interpolated[t]=(1.0-lincoeff)*love_tl[timepreindex]+lincoeff*love_tl[timepreindex+1]; 527 } 479 528 } 480 529 … … 491 540 if(horiz)H_viscoelastic_interpolated=H_viscoelastic; 492 541 #endif 542 543 if(rotation){ //if this cpu handles degree 2 544 #ifdef _HAVE_AD_ 545 Pmtf_col_interpolated=xNew<IssmDouble>(1,"t"); 546 Pmtf_ortho_interpolated=xNew<IssmDouble>(1,"t"); 547 Pmtf_z_interpolated=xNew<IssmDouble>(1,"t"); 548 Love_tk2_interpolated=xNew<IssmDouble>(1,"t"); 549 Love_th2_interpolated=xNew<IssmDouble>(1,"t"); 550 if (horiz) Love_tl2_interpolated=xNew<IssmDouble>(1,"t"); 551 #else 552 Pmtf_col_interpolated=xNew<IssmDouble>(1); 553 Pmtf_ortho_interpolated=xNew<IssmDouble>(1); 554 Pmtf_z_interpolated=xNew<IssmDouble>(1); 555 Love_tk2_interpolated=xNew<IssmDouble>(1); 556 Love_th2_interpolated=xNew<IssmDouble>(1); 557 if (horiz) Love_tl2_interpolated=xNew<IssmDouble>(1); 558 #endif 559 560 Pmtf_col_interpolated=love_pmtf_colinear; 561 Pmtf_ortho_interpolated=love_pmtf_ortho; 562 Pmtf_z_interpolated[0]=1.0+love_k[2]; 563 Love_tk2_interpolated[0]=love_tk[2]; 564 Love_th2_interpolated[0]=love_th[2]; 565 if (horiz) Love_tl2_interpolated[0]=love_tl[2]; 566 } 493 567 } 494 568 … … 499 573 parameters->AddObject(new DoubleVecParam(SealevelchangeUViscoElasticEnum,U_viscoelastic_interpolated,M*nt)); 500 574 if(horiz)parameters->AddObject(new DoubleVecParam(SealevelchangeHViscoElasticEnum,H_viscoelastic_interpolated,M*nt)); 575 if(rotation){ 576 parameters->AddObject(new DoubleVecParam(SealevelchangePolarMotionTransferFunctionColinearEnum,Pmtf_col_interpolated,nt)); 577 parameters->AddObject(new DoubleVecParam(SealevelchangePolarMotionTransferFunctionOrthogonalEnum,Pmtf_ortho_interpolated,nt)); 578 parameters->AddObject(new DoubleVecParam(SealevelchangePolarMotionTransferFunctionZEnum,Pmtf_z_interpolated,nt)); 579 parameters->AddObject(new DoubleVecParam(SealevelchangeTidalH2Enum,Love_th2_interpolated,nt)); 580 parameters->AddObject(new DoubleVecParam(SealevelchangeTidalK2Enum,Love_tk2_interpolated,nt)); 581 if (horiz) parameters->AddObject(new DoubleVecParam(SealevelchangeTidalL2Enum,Love_tl2_interpolated,nt)); 582 } 501 583 } 502 584 … … 519 601 xDelete<IssmDouble>(H_viscoelastic_local); 520 602 } 603 if(rotation){ 604 xDelete<IssmDouble>(love_pmtf_colinear); 605 xDelete<IssmDouble>(love_pmtf_ortho); 606 607 } 521 608 } 522 609 } /*}}}*/ … … 545 632 iomodel->DeleteData(&requestedoutputs,numoutputs,"md.solidearth.requested_outputs"); 546 633 /*}}}*/ 547 548 634 }/*}}}*/ 549 635 -
issm/trunk/src/c/analyses/SmbAnalysis.cpp
r26744 r27035 24 24 25 25 int smb_model; 26 bool isdelta18o,ismungsm,isd18opd,issetpddfac,isprecipscaled,istemperaturescaled,isfirnwarming ;26 bool isdelta18o,ismungsm,isd18opd,issetpddfac,isprecipscaled,istemperaturescaled,isfirnwarming,isstochastic; 27 27 28 28 /*Update elements: */ … … 38 38 /*Figure out smb model: */ 39 39 iomodel->FindConstant(&smb_model,"md.smb.model"); 40 iomodel->FindConstant(&isstochastic,"md.stochasticforcing.isstochasticforcing"); 40 41 switch(smb_model){ 41 42 case SMBforcingEnum: 42 43 iomodel->FetchDataToInput(inputs,elements,"md.smb.mass_balance",SmbMassBalanceEnum,0.); 44 if(isstochastic){ 45 iomodel->FetchDataToInput(inputs,elements,"md.stochasticforcing.default_id",StochasticForcingDefaultIdEnum); 46 iomodel->FetchDataToInput(inputs,elements,"md.smb.mass_balance",BaselineSmbMassBalanceEnum,0.); 47 } 43 48 break; 44 49 case SMBgembEnum: -
issm/trunk/src/c/analyses/StressbalanceAnalysis.cpp
r26744 r27035 31 31 IssmDouble rho_ice; 32 32 IssmDouble FSreconditioning; 33 bool isSIA,isSSA,isL1L2,isM LHO,isHO,isFS,iscoupling;33 bool isSIA,isSSA,isL1L2,isMOLHO,isHO,isFS,iscoupling; 34 34 bool spcpresent = false; 35 35 int Mx,Nx; … … 59 59 iomodel->FindConstant(&isSSA,"md.flowequation.isSSA"); 60 60 iomodel->FindConstant(&isL1L2,"md.flowequation.isL1L2"); 61 iomodel->FindConstant(&isM LHO,"md.flowequation.isMLHO");61 iomodel->FindConstant(&isMOLHO,"md.flowequation.isMOLHO"); 62 62 iomodel->FindConstant(&isHO,"md.flowequation.isHO"); 63 63 iomodel->FindConstant(&isFS,"md.flowequation.isFS"); 64 64 65 65 /*Is this model only SIA??*/ 66 if(!isSSA && !isHO && !isFS && !isL1L2 && !isM LHO) return;66 if(!isSSA && !isHO && !isFS && !isL1L2 && !isMOLHO) return; 67 67 68 68 /*Do we have coupling*/ 69 if((isSIA?1.:0.) + (isSSA?1.:0.) + (isL1L2?1.:0.) + (isM LHO?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.)69 if((isSIA?1.:0.) + (isSSA?1.:0.) + (isL1L2?1.:0.) + (isMOLHO?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.) 70 70 iscoupling = true; 71 71 else … … 78 78 if(isSSA) iomodel->FindConstant(&finiteelement,"md.flowequation.fe_SSA"); 79 79 else if(isL1L2) finiteelement = P1Enum; 80 else if(isM LHO) finiteelement = P1Enum;80 else if(isMOLHO) finiteelement = P1Enum; 81 81 else if(isHO) iomodel->FindConstant(&finiteelement,"md.flowequation.fe_HO"); 82 82 else if(isFS){ iomodel->FindConstant(&finiteelement,"md.flowequation.fe_FS"); … … 188 188 } 189 189 else{ 190 if(!isM LHO){190 if(!isMOLHO){ 191 191 IoModelToConstraintsx(constraints,iomodel,"md.stressbalance.spcvx",StressbalanceAnalysisEnum,finiteelement,0); 192 192 if(iomodel->domaintype!=Domain2DverticalEnum){ … … 194 194 } 195 195 } 196 else{//M LHO196 else{//MOLHO 197 197 IoModelToConstraintsx(constraints,iomodel,"md.stressbalance.spcvx_base",StressbalanceAnalysisEnum,finiteelement,0); 198 198 IoModelToConstraintsx(constraints,iomodel,"md.stressbalance.spcvx_shear",StressbalanceAnalysisEnum,finiteelement,1); … … 462 462 int count; 463 463 int penpair_ids[2]; 464 bool isSSA,isL1L2,isM LHO,isHO,isFS;464 bool isSSA,isL1L2,isMOLHO,isHO,isFS; 465 465 int numpenalties,numrifts,numriftsegments; 466 466 IssmDouble *riftinfo = NULL; … … 470 470 /*Fetch parameters: */ 471 471 iomodel->FindConstant(&isL1L2,"md.flowequation.isL1L2"); 472 iomodel->FindConstant(&isM LHO,"md.flowequation.isMLHO");472 iomodel->FindConstant(&isMOLHO,"md.flowequation.isMOLHO"); 473 473 iomodel->FindConstant(&isFS,"md.flowequation.isFS"); 474 474 iomodel->FindConstant(&isSSA,"md.flowequation.isSSA"); … … 477 477 478 478 /*Is this SIA only?*/ 479 if(!isSSA && !isHO && !isFS && !isL1L2 && !isM LHO) return;479 if(!isSSA && !isHO && !isFS && !isL1L2 && !isMOLHO) return; 480 480 481 481 /*Initialize counter: */ … … 522 522 523 523 /*Intermediary*/ 524 bool isSSA,isL1L2,isM LHO,isHO,isFS,iscoupling;524 bool isSSA,isL1L2,isMOLHO,isHO,isFS,iscoupling; 525 525 int finiteelement=-1,approximation=-1; 526 526 … … 528 528 iomodel->FindConstant(&isSSA,"md.flowequation.isSSA"); 529 529 iomodel->FindConstant(&isL1L2,"md.flowequation.isL1L2"); 530 iomodel->FindConstant(&isM LHO,"md.flowequation.isMLHO");530 iomodel->FindConstant(&isMOLHO,"md.flowequation.isMOLHO"); 531 531 iomodel->FindConstant(&isHO,"md.flowequation.isHO"); 532 532 iomodel->FindConstant(&isFS,"md.flowequation.isFS"); 533 533 534 534 /*Now, check that we have non SIA elements */ 535 if(!isSSA && !isL1L2 && !isM LHO && !isHO && !isFS) return;535 if(!isSSA && !isL1L2 && !isMOLHO && !isHO && !isFS) return; 536 536 537 537 /*Do we have coupling*/ 538 if( (isSSA?1.:0.) + (isL1L2?1.:0.) + (isM LHO?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.)538 if( (isSSA?1.:0.) + (isL1L2?1.:0.) + (isMOLHO?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.) 539 539 iscoupling = true; 540 540 else … … 553 553 finiteelement = P1Enum; 554 554 } 555 else if(isM LHO){556 approximation = M LHOApproximationEnum;555 else if(isMOLHO){ 556 approximation = MOLHOApproximationEnum; 557 557 finiteelement = P1Enum; 558 558 } … … 630 630 break; 631 631 case L1L2ApproximationEnum: numdofs = 2; break; 632 case M LHOApproximationEnum: numdofs = 4; break;632 case MOLHOApproximationEnum: numdofs = 4; break; 633 633 case HOApproximationEnum: 634 634 switch(domaintype){ … … 695 695 int FrictionCoupling; 696 696 int* finiteelement_list=NULL; 697 bool isSSA,isL1L2,isM LHO,isHO,isFS,iscoupling;697 bool isSSA,isL1L2,isMOLHO,isHO,isFS,iscoupling; 698 698 bool control_analysis; 699 699 bool dakota_analysis; … … 703 703 iomodel->FindConstant(&isSSA,"md.flowequation.isSSA"); 704 704 iomodel->FindConstant(&isL1L2,"md.flowequation.isL1L2"); 705 iomodel->FindConstant(&isM LHO,"md.flowequation.isMLHO");705 iomodel->FindConstant(&isMOLHO,"md.flowequation.isMOLHO"); 706 706 iomodel->FindConstant(&isHO,"md.flowequation.isHO"); 707 707 iomodel->FindConstant(&isFS,"md.flowequation.isFS"); … … 713 713 714 714 /*return if no processing required*/ 715 if(!isSSA && !isL1L2 && !isM LHO && !isHO && !isFS) return;715 if(!isSSA && !isL1L2 && !isMOLHO && !isHO && !isFS) return; 716 716 717 717 /*Fetch data needed and allocate vectors: */ … … 720 720 721 721 /*Do we have coupling*/ 722 if( (isSSA?1.:0.) + (isL1L2?1.:0.) + (isM LHO?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.)722 if( (isSSA?1.:0.) + (isL1L2?1.:0.) + (isMOLHO?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.) 723 723 iscoupling = true; 724 724 else … … 729 729 if(isSSA) iomodel->FindConstant(&finiteelement,"md.flowequation.fe_SSA"); 730 730 else if(isL1L2) finiteelement = P1Enum; 731 else if(isM LHO) finiteelement = P1Enum;731 else if(isMOLHO) finiteelement = P1Enum; 732 732 else if(isHO) iomodel->FindConstant(&finiteelement,"md.flowequation.fe_HO"); 733 733 else if(isFS) iomodel->FindConstant(&finiteelement,"md.flowequation.fe_FS"); … … 781 781 iomodel->FetchDataToInput(inputs,elements,"md.initialization.vx",VxEnum,0.); 782 782 iomodel->FetchDataToInput(inputs,elements,"md.initialization.vy",VyEnum,0.); 783 /*M LHO*/784 if(isM LHO){783 /*MOLHO*/ 784 if(isMOLHO){ 785 785 iomodel->FetchDataToInput(inputs,elements,"md.initialization.vx",VxShearEnum,0.); 786 786 iomodel->FetchDataToInput(inputs,elements,"md.initialization.vy",VyShearEnum,0.); 787 /*3D M LHO also need to have VxBase and VyBase for reconstruting Vx and Vy*/787 /*3D MOLHO also need to have VxBase and VyBase for reconstruting Vx and Vy*/ 788 788 if (iomodel->domaintype==Domain3DEnum) { 789 789 iomodel->FetchDataToInput(inputs,elements,"md.initialization.vx",VxBaseEnum,0.); … … 836 836 break; 837 837 case SpatialLinearFloatingMeltRateEnum: 838 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsDeepwaterMeltingRateEnum); 839 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_elevation",BasalforcingsDeepwaterElevationEnum); 840 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.upperwater_elevation",BasalforcingsUpperwaterElevationEnum); 838 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsSpatialDeepwaterMeltingRateEnum); 839 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_elevation",BasalforcingsSpatialDeepwaterElevationEnum); 840 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.upperwater_melting_rate",BasalforcingsSpatialUpperwaterMeltingRateEnum); 841 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.upperwater_elevation",BasalforcingsSpatialUpperwaterElevationEnum); 842 if(isstochastic){ 843 iomodel->FetchDataToInput(inputs,elements,"md.stochasticforcing.default_id",StochasticForcingDefaultIdEnum); 844 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_melting_rate",BaselineBasalforcingsSpatialDeepwaterMeltingRateEnum); 845 } 841 846 break; 842 847 case BasalforcingsPicoEnum: … … 985 990 parameters->AddObject(iomodel->CopyConstantObject("md.flowequation.isSSA",FlowequationIsSSAEnum)); 986 991 parameters->AddObject(iomodel->CopyConstantObject("md.flowequation.isL1L2",FlowequationIsL1L2Enum)); 987 parameters->AddObject(iomodel->CopyConstantObject("md.flowequation.isM LHO",FlowequationIsMLHOEnum));992 parameters->AddObject(iomodel->CopyConstantObject("md.flowequation.isMOLHO",FlowequationIsMOLHOEnum)); 988 993 parameters->AddObject(iomodel->CopyConstantObject("md.flowequation.isHO",FlowequationIsHOEnum)); 989 994 parameters->AddObject(iomodel->CopyConstantObject("md.flowequation.isFS",FlowequationIsFSEnum)); … … 1088 1093 1089 1094 /*Intermediaries*/ 1090 bool isSSA,isL1L2,isM LHO,isHO,isFS;1095 bool isSSA,isL1L2,isMOLHO,isHO,isFS; 1091 1096 bool conserve_loads = true; 1092 1097 int newton,domaintype,fe_FS; … … 1095 1100 femmodel->parameters->FindParam(&isSSA,FlowequationIsSSAEnum); 1096 1101 femmodel->parameters->FindParam(&isL1L2,FlowequationIsL1L2Enum); 1097 femmodel->parameters->FindParam(&isM LHO,FlowequationIsMLHOEnum);1102 femmodel->parameters->FindParam(&isMOLHO,FlowequationIsMOLHOEnum); 1098 1103 femmodel->parameters->FindParam(&isHO,FlowequationIsHOEnum); 1099 1104 femmodel->parameters->FindParam(&isFS,FlowequationIsFSEnum); … … 1102 1107 femmodel->parameters->FindParam(&newton,StressbalanceIsnewtonEnum); 1103 1108 1104 if(isFS && !(isSSA || isHO || isL1L2 || isM LHO)){1109 if(isFS && !(isSSA || isHO || isL1L2 || isMOLHO)){ 1105 1110 femmodel->SetCurrentConfiguration(StressbalanceAnalysisEnum); 1106 1111 … … 1124 1129 solutionsequence_nonlinear(femmodel,conserve_loads); 1125 1130 } 1126 else if(!isFS && (isSSA || isHO || isL1L2 || isM LHO)){1131 else if(!isFS && (isSSA || isHO || isL1L2 || isMOLHO)){ 1127 1132 femmodel->SetCurrentConfiguration(StressbalanceAnalysisEnum); 1128 1133 if(newton>0) … … 1138 1143 } 1139 1144 } 1140 else if ((isSSA || isL1L2 || isM LHO || isHO) && isFS){1145 else if ((isSSA || isL1L2 || isMOLHO || isHO) && isFS){ 1141 1146 if(VerboseSolution()) _printf0_(" computing coupling between lower order models and FS\n"); 1142 1147 solutionsequence_FScoupling_nonlinear(femmodel,conserve_loads); … … 1190 1195 case L1L2ApproximationEnum: 1191 1196 return CreateKMatrixL1L2(element); 1192 case M LHOApproximationEnum:1193 return CreateKMatrixM LHO(element);1197 case MOLHOApproximationEnum: 1198 return CreateKMatrixMOLHO(element); 1194 1199 case HOApproximationEnum: 1195 1200 return CreateKMatrixHO(element); … … 1219 1224 case L1L2ApproximationEnum: 1220 1225 return CreatePVectorL1L2(element); 1221 case M LHOApproximationEnum:1222 return CreatePVectorM LHO(element);1226 case MOLHOApproximationEnum: 1227 return CreatePVectorMOLHO(element); 1223 1228 case HOApproximationEnum: 1224 1229 return CreatePVectorHO(element); … … 1248 1253 GetSolutionFromInputsHoriz(solution,element); 1249 1254 return; 1250 case M LHOApproximationEnum:1251 GetSolutionFromInputsM LHO(solution,element);1255 case MOLHOApproximationEnum: 1256 GetSolutionFromInputsMOLHO(solution,element); 1252 1257 return; 1253 1258 case SSAHOApproximationEnum: case HOFSApproximationEnum: case SSAFSApproximationEnum: … … 1330 1335 InputUpdateFromSolutionL1L2(solution,element); 1331 1336 return; 1332 case M LHOApproximationEnum:1333 InputUpdateFromSolutionM LHO(solution,element);1337 case MOLHOApproximationEnum: 1338 InputUpdateFromSolutionMOLHO(solution,element); 1334 1339 return; 1335 1340 case SSAHOApproximationEnum: … … 2755 2760 }/*}}}*/ 2756 2761 2757 /*M LHO*/2758 ElementMatrix* StressbalanceAnalysis::CreateKMatrixM LHO(Element* element){/*{{{*/2762 /*MOLHO*/ 2763 ElementMatrix* StressbalanceAnalysis::CreateKMatrixMOLHO(Element* element){/*{{{*/ 2759 2764 2760 2765 /* Check if ice in element */ … … 2779 2784 2780 2785 /*compute all stiffness matrices for this element*/ 2781 ElementMatrix* Ke1=CreateKMatrixM LHOViscous(basalelement);2782 ElementMatrix* Ke2=CreateKMatrixM LHOFriction(basalelement);2786 ElementMatrix* Ke1=CreateKMatrixMOLHOViscous(basalelement); 2787 ElementMatrix* Ke2=CreateKMatrixMOLHOFriction(basalelement); 2783 2788 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2); 2784 2789 … … 2789 2794 return Ke; 2790 2795 }/*}}}*/ 2791 ElementMatrix* StressbalanceAnalysis::CreateKMatrixM LHOFriction(Element* element){/*{{{*/2796 ElementMatrix* StressbalanceAnalysis::CreateKMatrixMOLHOFriction(Element* element){/*{{{*/ 2792 2797 2793 2798 if(element->IsAllFloating()) return NULL; … … 2816 2821 2817 2822 /*Initialize Element matrix and vectors*/ 2818 ElementMatrix* Ke = element->NewElementMatrix(M LHOApproximationEnum);2823 ElementMatrix* Ke = element->NewElementMatrix(MOLHOApproximationEnum); 2819 2824 IssmDouble* basis = xNew<IssmDouble>(numnodes); 2820 2825 … … 2871 2876 return Ke; 2872 2877 }/*}}}*/ 2873 ElementMatrix* StressbalanceAnalysis::CreateKMatrixM LHOViscous(Element* element){/*{{{*/2878 ElementMatrix* StressbalanceAnalysis::CreateKMatrixMOLHOViscous(Element* element){/*{{{*/ 2874 2879 2875 2880 /* Check if ice in element */ … … 2886 2891 2887 2892 /*Initialize Element matrix and vectors*/ 2888 ElementMatrix* Ke = element->NewElementMatrix(M LHOApproximationEnum);2893 ElementMatrix* Ke = element->NewElementMatrix(MOLHOApproximationEnum); 2889 2894 IssmDouble* dbasis = xNew<IssmDouble>(2*numnodes); // like SSA 2890 2895 IssmDouble* basis = xNew<IssmDouble>(numnodes); // like SSA … … 2910 2915 thickness_input->GetInputValue(&thickness, gauss); 2911 2916 n_input->GetInputValue(&n,gauss); 2912 element->material->ViscosityM LHO(&viscosity[0],dim,xyz_list,gauss,vxbase_input,vybase_input,vxshear_input,vyshear_input,thickness_input,n_input);2917 element->material->ViscosityMOLHO(&viscosity[0],dim,xyz_list,gauss,vxbase_input,vybase_input,vxshear_input,vyshear_input,thickness_input,n_input); 2913 2918 2914 2919 for(int i=0;i<numnodes;i++){//shape functions on tria element … … 2976 2981 2977 2982 /*Transform Coordinate System*/ 2978 //basalelement->TransformStiffnessMatrixCoord(Ke,XYM LHOEnum);2983 //basalelement->TransformStiffnessMatrixCoord(Ke,XYMOLHOEnum); 2979 2984 2980 2985 /*Clean up and return*/ … … 2985 2990 return Ke; 2986 2991 }/*}}}*/ 2987 ElementVector* StressbalanceAnalysis::CreatePVectorM LHO(Element* element){/*{{{*/2992 ElementVector* StressbalanceAnalysis::CreatePVectorMOLHO(Element* element){/*{{{*/ 2988 2993 2989 2994 /* Check if ice in element */ … … 3008 3013 3009 3014 /*compute all load vectors for this element*/ 3010 ElementVector* pe1=CreatePVectorM LHODrivingStress(basalelement);3011 ElementVector* pe2=CreatePVectorM LHOFront(basalelement);3015 ElementVector* pe1=CreatePVectorMOLHODrivingStress(basalelement); 3016 ElementVector* pe2=CreatePVectorMOLHOFront(basalelement); 3012 3017 ElementVector* pe =new ElementVector(pe1,pe2); 3013 3018 … … 3018 3023 return pe; 3019 3024 }/*}}}*/ 3020 ElementVector* StressbalanceAnalysis::CreatePVectorM LHODrivingStress(Element* element){/*{{{*/3025 ElementVector* StressbalanceAnalysis::CreatePVectorMOLHODrivingStress(Element* element){/*{{{*/ 3021 3026 3022 3027 /*Intermediaries */ … … 3028 3033 3029 3034 /*Initialize Element vector and vectors*/ 3030 ElementVector* pe = element->NewElementVector(M LHOApproximationEnum);3035 ElementVector* pe = element->NewElementVector(MOLHOApproximationEnum); 3031 3036 IssmDouble* basis = xNew<IssmDouble>(numnodes); 3032 3037 … … 3057 3062 3058 3063 /*Transform coordinate system*/ 3059 //element->TransformLoadVectorCoord(pe,XYM LHOEnum);3064 //element->TransformLoadVectorCoord(pe,XYMOLHOEnum); 3060 3065 3061 3066 /*Clean up and return*/ … … 3065 3070 return pe; 3066 3071 }/*}}}*/ 3067 ElementVector* StressbalanceAnalysis::CreatePVectorM LHOFront(Element* element){/*{{{*/3072 ElementVector* StressbalanceAnalysis::CreatePVectorMOLHOFront(Element* element){/*{{{*/ 3068 3073 3069 3074 /*If no front, return NULL*/ … … 3081 3086 3082 3087 /*Initialize Element vector and other vectors*/ 3083 ElementVector* pe = element->NewElementVector(M LHOApproximationEnum);3088 ElementVector* pe = element->NewElementVector(MOLHOApproximationEnum); 3084 3089 IssmDouble* basis = xNew<IssmDouble>(numnodes); 3085 3090 … … 3130 3135 3131 3136 /*Transform coordinate system*/ 3132 //element->TransformLoadVectorCoord(pe,XYM LHOEnum);3137 //element->TransformLoadVectorCoord(pe,XYMOLHOEnum); 3133 3138 3134 3139 /*Clean up and return*/ … … 3139 3144 return pe; 3140 3145 }/*}}}*/ 3141 void StressbalanceAnalysis::InputUpdateFromSolutionM LHO(IssmDouble* solution,Element* element){/*{{{*/3146 void StressbalanceAnalysis::InputUpdateFromSolutionMOLHO(IssmDouble* solution,Element* element){/*{{{*/ 3142 3147 3143 3148 int i,dim,domaintype; … … 3192 3197 3193 3198 /*Fetch dof list and allocate solution vectors*/ 3194 basalelement->GetDofListLocal(&doflist,M LHOApproximationEnum,GsetEnum);3199 basalelement->GetDofListLocal(&doflist,MOLHOApproximationEnum,GsetEnum); 3195 3200 IssmDouble* values = xNew<IssmDouble>(numdof); 3196 3201 IssmDouble* vbx = xNew<IssmDouble>(numnodes); … … 3215 3220 3216 3221 /*Ok, we have vx and vy in values, fill in vx and vy arrays: */ 3217 for(i=0;i<numnodes;i++){ //numnodes of the 2D mesh in which the M LHO is written3222 for(i=0;i<numnodes;i++){ //numnodes of the 2D mesh in which the MOLHO is written 3218 3223 vbx[i] =values[i*4+0]; //base vx 3219 3224 vshx[i]=values[i*4+1]; //shear vx … … 3252 3257 switch(domaintype){ 3253 3258 case Domain2DhorizontalEnum: 3254 for(i=0;i<numnodes;i++){ //numnodes of the 2D mesh in which the M LHO is written3259 for(i=0;i<numnodes;i++){ //numnodes of the 2D mesh in which the MOLHO is written 3255 3260 vx[i]=vbx[i]+vshx[i]*(n[i]+1)/(n[i]+2); 3256 3261 vy[i]=vby[i]+vshy[i]*(n[i]+1)/(n[i]+2); … … 3264 3269 basalelement->GetInputListOnNodes(&H[0],ThicknessEnum,0.); 3265 3270 basalelement->GetInputListOnNodes(&s[0],SurfaceEnum,0.); 3266 element->Recover3DM LHOInput(VxEnum, numnodes, vbx, vshx, n, H, s);3267 element->Recover3DM LHOInput(VyEnum, numnodes, vby, vshy, n, H, s);3271 element->Recover3DMOLHOInput(VxEnum, numnodes, vbx, vshx, n, H, s); 3272 element->Recover3DMOLHOInput(VyEnum, numnodes, vby, vshy, n, H, s); 3268 3273 break; 3269 3274 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); … … 3289 3294 if(basalelement->IsSpawnedElement()){basalelement->DeleteMaterials(); delete basalelement;}; 3290 3295 }/*}}}*/ 3291 void StressbalanceAnalysis::GetSolutionFromInputsM LHO(Vector<IssmDouble>* solution,Element* element){/*{{{*/3296 void StressbalanceAnalysis::GetSolutionFromInputsMOLHO(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 3292 3297 3293 3298 IssmDouble vbx,vby,vshx,vshy; … … 3308 3313 int numdof = numnodes*dofpernode; 3309 3314 element->GetInputValue(&approximation,ApproximationEnum); 3310 if(approximation!=M LHOApproximationEnum) _error_("mesh "<<EnumToStringx(approximation)<<" not supported here");3315 if(approximation!=MOLHOApproximationEnum) _error_("mesh "<<EnumToStringx(approximation)<<" not supported here"); 3311 3316 3312 3317 /*Fetch dof list and allocate solution vector*/ -
issm/trunk/src/c/analyses/StressbalanceAnalysis.h
r26744 r27035 57 57 ElementVector* CreatePVectorL1L2DrivingStress(Element* element); 58 58 void InputUpdateFromSolutionL1L2(IssmDouble* solution,Element* element); 59 /*M LHO*/60 ElementMatrix* CreateKMatrixM LHO(Element* element);61 ElementMatrix* CreateKMatrixM LHOFriction(Element* element);62 ElementMatrix* CreateKMatrixM LHOViscous(Element* element);63 ElementVector* CreatePVectorM LHO(Element* element);64 ElementVector* CreatePVectorM LHOFront(Element* element);65 ElementVector* CreatePVectorM LHODrivingStress(Element* element);66 void InputUpdateFromSolutionM LHO(IssmDouble* solution,Element* element);67 void GetSolutionFromInputsM LHO(Vector<IssmDouble>* solution,Element* element);59 /*MOLHO*/ 60 ElementMatrix* CreateKMatrixMOLHO(Element* element); 61 ElementMatrix* CreateKMatrixMOLHOFriction(Element* element); 62 ElementMatrix* CreateKMatrixMOLHOViscous(Element* element); 63 ElementVector* CreatePVectorMOLHO(Element* element); 64 ElementVector* CreatePVectorMOLHOFront(Element* element); 65 ElementVector* CreatePVectorMOLHODrivingStress(Element* element); 66 void InputUpdateFromSolutionMOLHO(IssmDouble* solution,Element* element); 67 void GetSolutionFromInputsMOLHO(Vector<IssmDouble>* solution,Element* element); 68 68 /*HO*/ 69 69 ElementMatrix* CreateJacobianMatrixHO(Element* element); -
issm/trunk/src/c/analyses/StressbalanceSIAAnalysis.cpp
r26744 r27035 10 10 11 11 /*Intermediaries*/ 12 bool isSIA,isSSA,isL1L2,isM LHO,isHO,isFS,iscoupling;12 bool isSIA,isSSA,isL1L2,isMOLHO,isHO,isFS,iscoupling; 13 13 14 14 /*Fetch parameters: */ … … 16 16 iomodel->FindConstant(&isSSA,"md.flowequation.isSSA"); 17 17 iomodel->FindConstant(&isL1L2,"md.flowequation.isL1L2"); 18 iomodel->FindConstant(&isM LHO,"md.flowequation.isMLHO");18 iomodel->FindConstant(&isMOLHO,"md.flowequation.isMOLHO"); 19 19 iomodel->FindConstant(&isHO,"md.flowequation.isHO"); 20 20 iomodel->FindConstant(&isFS,"md.flowequation.isFS"); … … 24 24 25 25 /*Do we have coupling*/ 26 if((isSIA?1.:0.) + (isSSA?1.:0.) + (isL1L2?1.:0.) + (isM LHO?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.)26 if((isSIA?1.:0.) + (isSSA?1.:0.) + (isL1L2?1.:0.) + (isMOLHO?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.) 27 27 iscoupling = true; 28 28 else -
issm/trunk/src/c/analyses/StressbalanceVerticalAnalysis.cpp
r26744 r27035 12 12 13 13 /*Intermediary*/ 14 bool isSIA,isSSA,isL1L2,isM LHO,isHO,isFS,iscoupling;14 bool isSIA,isSSA,isL1L2,isMOLHO,isHO,isFS,iscoupling; 15 15 int Mz,Nz; 16 16 IssmDouble *spcvz = NULL; … … 23 23 iomodel->FindConstant(&isSSA,"md.flowequation.isSSA"); 24 24 iomodel->FindConstant(&isL1L2,"md.flowequation.isL1L2"); 25 iomodel->FindConstant(&isM LHO,"md.flowequation.isMLHO");25 iomodel->FindConstant(&isMOLHO,"md.flowequation.isMOLHO"); 26 26 iomodel->FindConstant(&isHO,"md.flowequation.isHO"); 27 27 iomodel->FindConstant(&isFS,"md.flowequation.isFS"); 28 28 29 29 /*Do we have coupling*/ 30 if((isSIA?1.:0.) + (isSSA?1.:0.) + (isL1L2?1.:0.) + (isM LHO?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.)30 if((isSIA?1.:0.) + (isSSA?1.:0.) + (isL1L2?1.:0.) + (isMOLHO?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.) 31 31 iscoupling = true; 32 32 else … … 139 139 break; 140 140 case SpatialLinearFloatingMeltRateEnum: 141 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsDeepwaterMeltingRateEnum); 142 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_elevation",BasalforcingsDeepwaterElevationEnum); 143 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.upperwater_elevation",BasalforcingsUpperwaterElevationEnum); 141 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsSpatialDeepwaterMeltingRateEnum); 142 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_elevation",BasalforcingsSpatialDeepwaterElevationEnum); 143 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.upperwater_melting_rate",BasalforcingsSpatialUpperwaterMeltingRateEnum); 144 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.upperwater_elevation",BasalforcingsSpatialUpperwaterElevationEnum); 145 if(isstochastic){ 146 iomodel->FetchDataToInput(inputs,elements,"md.stochasticforcing.default_id",StochasticForcingDefaultIdEnum); 147 iomodel->FetchDataToInput(inputs,elements,"md.basalforcings.deepwater_melting_rate",BaselineBasalforcingsSpatialDeepwaterMeltingRateEnum); 148 } 144 149 break; 145 150 case BasalforcingsPicoEnum: -
issm/trunk/src/c/classes/Cfdragcoeffabsgrad.cpp
r26744 r27035 30 30 this->name = NULL; 31 31 this->weights_enum = UNDEF; 32 this->misfit=0;33 32 this->timepassedflag = false; 34 33 } … … 43 42 this->weights_enum=in_weights_enum; 44 43 this->timepassedflag=in_timepassedflag; 45 46 this->misfit=0;47 44 } 48 45 /*}}}*/ 49 46 Cfdragcoeffabsgrad::~Cfdragcoeffabsgrad(){/*{{{*/ 50 47 if(this->name)xDelete(this->name); 51 this->misfit=0;52 48 } 53 49 /*}}}*/ … … 55 51 Object* Cfdragcoeffabsgrad::copy() {/*{{{*/ 56 52 Cfdragcoeffabsgrad* mf = new Cfdragcoeffabsgrad(this->name,this->definitionenum, this->weights_enum,this->timepassedflag); 57 mf->misfit=this->misfit;58 53 return (Object*) mf; 59 54 } … … 115 110 int domaintype,numcomponents; 116 111 IssmDouble Jelem=0.; 117 IssmDouble misfit,Jdet;112 IssmDouble Jdet; 118 113 IssmDouble dp[2],weight; 119 114 IssmDouble* xyz_list = NULL; -
issm/trunk/src/c/classes/Cfdragcoeffabsgrad.h
r26744 r27035 11 11 12 12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum); 13 void GetVectorFromInputsx( IssmDouble** pvector, int* pvector_size, FemModel* femmodel,int name);14 13 15 14 class Cfdragcoeffabsgrad: public Object, public Definition{ … … 21 20 int weights_enum; 22 21 bool timepassedflag; 23 24 IssmDouble misfit; //value carried over in time.25 22 26 23 /*Cfdragcoeffabsgrad constructors, destructors :*/ -
issm/trunk/src/c/classes/Cflevelsetmisfit.cpp
r26744 r27035 32 32 this->observation_enum = UNDEF; 33 33 this->weights_enum = UNDEF; 34 this->misfit=0;35 34 this->datatime=0.; 36 35 this->timepassedflag = false; … … 49 48 this->datatime=in_datatime; 50 49 this->timepassedflag=in_timepassedflag; 51 52 this->misfit=0;53 50 } 54 51 /*}}}*/ 55 52 Cflevelsetmisfit::~Cflevelsetmisfit(){/*{{{*/ 56 53 if(this->name)xDelete(this->name); 57 this->misfit=0;58 54 } 59 55 /*}}}*/ … … 61 57 Object* Cflevelsetmisfit::copy() {/*{{{*/ 62 58 Cflevelsetmisfit* mf = new Cflevelsetmisfit(this->name,this->definitionenum, this->model_enum,this->observation_enum,this->weights_enum,this->datatime,this->timepassedflag); 63 mf->misfit=this->misfit;64 59 return (Object*) mf; 65 60 } … … 95 90 marshallhandle->call(this->datatime); 96 91 marshallhandle->call(this->timepassedflag); 97 marshallhandle->call(this->misfit);98 92 } 99 93 /*}}}*/ -
issm/trunk/src/c/classes/Cflevelsetmisfit.h
r26744 r27035 11 11 12 12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum); 13 void GetVectorFromInputsx( IssmDouble** pvector, int* pvector_size, FemModel* femmodel,int name);14 13 15 14 class Cflevelsetmisfit: public Object, public Definition{ … … 24 23 IssmDouble datatime; 25 24 bool timepassedflag; 26 27 IssmDouble misfit; //value carried over in time.28 25 29 26 /*Cflevelsetmisfit constructors, destructors :*/ -
issm/trunk/src/c/classes/Cfsurfacelogvel.cpp
r26744 r27035 29 29 this->definitionenum = -1; 30 30 this->name = NULL; 31 this->misfit=0;32 31 this->datatime=0.; 33 32 this->timepassedflag = false; … … 45 44 this->timepassedflag=in_timepassedflag; 46 45 47 this->misfit=0;48 46 } 49 47 /*}}}*/ 50 48 Cfsurfacelogvel::~Cfsurfacelogvel(){/*{{{*/ 51 49 if(this->name)xDelete(this->name); 52 this->misfit=0;53 50 } 54 51 /*}}}*/ … … 56 53 Object* Cfsurfacelogvel::copy() {/*{{{*/ 57 54 Cfsurfacelogvel* mf = new Cfsurfacelogvel(this->name,this->definitionenum,this->datatime,this->timepassedflag); 58 mf->misfit=this->misfit;59 55 return (Object*) mf; 60 56 } … … 75 71 /*}}}*/ 76 72 void Cfsurfacelogvel::Marshall(MarshallHandle* marshallhandle){/*{{{*/ 77 _error_("not implemented yet!"); 73 int object_enum=CfsurfacelogvelEnum; 74 marshallhandle->call(object_enum); 75 76 marshallhandle->call(this->definitionenum); 77 marshallhandle->call(this->name); 78 marshallhandle->call(this->datatime); 79 marshallhandle->call(this->timepassedflag); 78 80 } 79 81 /*}}}*/ … … 100 102 femmodel->parameters->FindParam(&time,TimeEnum); 101 103 102 IssmDouble J=0.; 103 IssmDouble J_sum=0.; 104 if(this->datatime<=time && !timepassedflag){ 104 if(this->datatime<=time && !this->timepassedflag){ 105 106 IssmDouble J=0.; 107 IssmDouble J_sum=0.; 108 105 109 for(Object* & object : femmodel->elements->objects){ 106 110 Element* element=xDynamicCast<Element*>(object); … … 113 117 114 118 this->timepassedflag = true; 115 } 116 return J; 119 return J_sum; 120 } 121 else{ 122 return 0.; 123 } 117 124 }/*}}}*/ 118 125 IssmDouble Cfsurfacelogvel::Cfsurfacelogvel_Calculation(Element* element, int definitionenum){/*{{{*/ -
issm/trunk/src/c/classes/Cfsurfacelogvel.h
r26744 r27035 11 11 12 12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum); 13 void GetVectorFromInputsx( IssmDouble** pvector, int* pvector_size, FemModel* femmodel,int name);14 13 15 14 class Cfsurfacelogvel: public Object, public Definition{ … … 21 20 IssmDouble datatime; 22 21 bool timepassedflag; 23 24 IssmDouble misfit; //value carried over in time.25 22 26 23 /*Cfsurfacelogvel constructors, destructors :*/ -
issm/trunk/src/c/classes/Cfsurfacesquare.cpp
r26744 r27035 6 6 /*{{{*/ 7 7 #ifdef HAVE_CONFIG_H 8 8 #include <config.h> 9 9 #else 10 10 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" … … 27 27 Cfsurfacesquare::Cfsurfacesquare(){/*{{{*/ 28 28 29 this->definitionenum = -1;30 this->name = NULL;31 this->model_enum = UNDEF;29 this->definitionenum = -1; 30 this->name = NULL; 31 this->model_enum = UNDEF; 32 32 this->observation_enum = UNDEF; 33 this->weights_enum = UNDEF; 34 this->misfit=0; 35 this->datatime=0.; 36 this->timepassedflag = false; 33 this->weights_enum = UNDEF; 34 this->datatime = 0.; 35 this->timepassedflag = false; 37 36 } 38 37 /*}}}*/ … … 49 48 this->datatime=in_datatime; 50 49 this->timepassedflag=in_timepassedflag; 51 52 this->misfit=0;53 50 } 54 51 /*}}}*/ 55 52 Cfsurfacesquare::~Cfsurfacesquare(){/*{{{*/ 56 53 if(this->name)xDelete(this->name); 57 this->misfit=0; 58 } 59 /*}}}*/ 54 } 55 /*}}}*/ 56 60 57 /*Object virtual function resolutoin: */ 61 58 Object* Cfsurfacesquare::copy() {/*{{{*/ 62 59 Cfsurfacesquare* mf = new Cfsurfacesquare(this->name,this->definitionenum, this->model_enum,this->observation_enum,this->weights_enum,this->datatime,this->timepassedflag); 63 mf->misfit=this->misfit;64 60 return (Object*) mf; 65 61 } … … 95 91 marshallhandle->call(this->datatime); 96 92 marshallhandle->call(this->timepassedflag); 97 marshallhandle->call(this->misfit);98 93 } 99 94 /*}}}*/ … … 102 97 } 103 98 /*}}}*/ 99 104 100 /*Definition virtual function resolutoin: */ 105 101 int Cfsurfacesquare::DefinitionEnum(){/*{{{*/ … … 115 111 /*}}}*/ 116 112 IssmDouble Cfsurfacesquare::Response(FemModel* femmodel){/*{{{*/ 117 /*diverse: */ 118 IssmDouble time; 119 120 /*recover time parameters: */ 121 femmodel->parameters->FindParam(&time,TimeEnum); 122 123 IssmDouble J=0.; 124 IssmDouble J_sum=0.; 125 126 if(datatime<=time && !timepassedflag){ 127 for(Object* & object : femmodel->elements->objects){ 128 Element* element=xDynamicCast<Element*>(object); 129 J+=this->Cfsurfacesquare_Calculation(element,model_enum,observation_enum,weights_enum); 130 } 131 132 ISSM_MPI_Allreduce ( (void*)&J,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 133 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 134 J=J_sum; 135 136 timepassedflag = true; 137 return J; 138 } 139 else return J; 140 } 141 /*}}}*/ 113 114 /*recover time parameters: */ 115 IssmDouble time; 116 femmodel->parameters->FindParam(&time,TimeEnum); 117 118 /*Do the calculation only if this is the first time we are passed datatime*/ 119 if(this->datatime<=time && !this->timepassedflag){ 120 121 IssmDouble J=0.; 122 IssmDouble J_sum=0.; 123 124 for(Object* & object : femmodel->elements->objects){ 125 Element* element=xDynamicCast<Element*>(object); 126 J+=this->Cfsurfacesquare_Calculation(element,model_enum,observation_enum,weights_enum); 127 } 128 129 ISSM_MPI_Allreduce ( (void*)&J,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 130 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 131 132 this->timepassedflag = true; 133 return J_sum; 134 } 135 else{ 136 return 0.; 137 } 138 } 139 /*}}}*/ 142 140 IssmDouble Cfsurfacesquare::Cfsurfacesquare_Calculation(Element* element, int model_enum, int observation_enum, int weights_enum){/*{{{*/ 143 141 -
issm/trunk/src/c/classes/Cfsurfacesquare.h
r26744 r27035 11 11 12 12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum); 13 void GetVectorFromInputsx( IssmDouble** pvector, int* pvector_size, FemModel* femmodel,int name);14 13 15 14 class Cfsurfacesquare: public Object, public Definition{ … … 25 24 IssmDouble datatime; 26 25 bool timepassedflag; 27 28 IssmDouble misfit; //value carried over in time.29 26 30 27 /*Cfsurfacesquare constructors, destructors :*/ -
issm/trunk/src/c/classes/Elements/Element.cpp
r26744 r27035 69 69 70 70 /*Get Basin ID and Basin coefficients*/ 71 if(enum_type==SMBautoregressionEnum) this->GetInputValue(&basinid,SmbBasinsIdEnum); 72 if(enum_type==FrontalForcingsRignotAutoregressionEnum) this->GetInputValue(&basinid,FrontalForcingsBasinIdEnum); 71 if(enum_type==SMBautoregressionEnum) this->GetInputValue(&basinid,SmbBasinsIdEnum); 72 if(enum_type==FrontalForcingsRignotAutoregressionEnum) this->GetInputValue(&basinid,FrontalForcingsBasinIdEnum); 73 if(enum_type==BasalforcingsDeepwaterMeltingRateAutoregressionEnum) this->GetInputValue(&basinid,BasalforcingsLinearBasinIdEnum); 73 74 for(int i=0;i<arorder;i++) phi_basin[i] = phi[basinid*arorder+i]; 74 75 beta0_basin = beta0[basinid]; … … 92 93 xDelete<IssmDouble>(oldvarspin); 93 94 } 94 if(enum_type==SMBautoregressionEnum) this->inputs->SetArrayInput(SmbValuesAutoregressionEnum,this->lid,varspin,numvertices*arorder); 95 if(enum_type==FrontalForcingsRignotAutoregressionEnum) this->inputs->SetArrayInput(ThermalforcingValuesAutoregressionEnum,this->lid,varspin,numvertices*arorder); 95 if(enum_type==SMBautoregressionEnum) this->inputs->SetArrayInput(SmbValuesAutoregressionEnum,this->lid,varspin,numvertices*arorder); 96 if(enum_type==FrontalForcingsRignotAutoregressionEnum) this->inputs->SetArrayInput(ThermalforcingValuesAutoregressionEnum,this->lid,varspin,numvertices*arorder); 97 if(enum_type==BasalforcingsDeepwaterMeltingRateAutoregressionEnum) this->inputs->SetArrayInput(BasalforcingsDeepwaterMeltingRateValuesAutoregressionEnum,this->lid,varspin,numvertices*arorder); 96 98 97 99 /*Cleanup and return*/ … … 123 125 outenum_type = FrontalForcingsThermalForcingEnum; 124 126 break; 127 case(BasalforcingsDeepwaterMeltingRateAutoregressionEnum): 128 arenum_type = BasalforcingsDeepwaterMeltingRateValuesAutoregressionEnum; 129 basinenum_type = BasalforcingsLinearBasinIdEnum; 130 noiseenum_type = BasalforcingsDeepwaterMeltingRateNoiseEnum; 131 outenum_type = BasalforcingsSpatialDeepwaterMeltingRateEnum; 132 break; 125 133 } 126 134 … … 172 180 xDelete<IssmDouble>(varlist); 173 181 xDelete<IssmDouble>(valuesautoregression); 182 }/*}}}*/ 183 void Element::BasinLinearFloatingiceMeltingRate(IssmDouble* deepwaterel,IssmDouble* upperwatermelt,IssmDouble* upperwaterel,IssmDouble* perturbation){/*{{{*/ 184 185 const int NUM_VERTICES = this->GetNumberOfVertices(); 186 187 int basinid; 188 IssmDouble alpha; 189 IssmDouble base[MAXVERTICES]; 190 IssmDouble values[MAXVERTICES]; 191 IssmDouble deepwatermelt[MAXVERTICES]; 192 193 /*Get element-specific values*/ 194 this->GetInputValue(&basinid,BasalforcingsLinearBasinIdEnum); 195 this->GetInputListOnVertices(&base[0],BaseEnum); 196 this->GetInputListOnVertices(&deepwatermelt[0],BasalforcingsSpatialDeepwaterMeltingRateEnum); 197 198 /*Compute melt rate at vertices according to basin-specific values of input arguments*/ 199 for(int i=0;i<NUM_VERTICES;i++){ 200 if(base[i]>=upperwaterel[basinid]){ 201 values[i]=upperwatermelt[basinid]; 202 } 203 else if (base[i]<deepwaterel[basinid]){ 204 values[i]=deepwatermelt[i]; 205 } 206 else{ 207 alpha = (base[i]-upperwaterel[basinid])/(deepwaterel[basinid]-upperwaterel[basinid]); 208 values[i]=deepwatermelt[i]*alpha+(1.-alpha)*upperwatermelt[basinid]; 209 } 210 } 211 212 this->AddInput(BasalforcingsFloatingiceMeltingRateEnum,&values[0],P1Enum); 213 }/*}}}*/ 214 void Element::CalvingFromRate(){/*{{{*/ 215 216 /*We are provided a calving rate, figure out the x/y components*/ 217 int dim,domaintype; 218 IssmDouble vx,vy,vel,dphidx,dphidy,dphi,c; 219 IssmDouble calvingratex[MAXVERTICES]; 220 IssmDouble calvingratey[MAXVERTICES]; 221 222 /*Get problem dimension and whether there is moving front or not*/ 223 this->FindParam(&domaintype,DomainTypeEnum); 224 225 switch(domaintype){ 226 case Domain2DverticalEnum: dim = 1; break; 227 case Domain2DhorizontalEnum: dim = 2; break; 228 case Domain3DEnum: dim = 2; break; 229 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 230 } 231 if(dim==1) _error_("not implemented in 1D..."); 232 233 Input *calvingrate_input = this->GetInput(CalvingCalvingrateEnum); _assert_(calvingrate_input); 234 Input *vx_input = this->GetInput(VxEnum); _assert_(vx_input); 235 Input *vy_input = this->GetInput(VyEnum); _assert_(vy_input); 236 Input *lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input); 237 Input *lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input); 238 239 /*Allocate arrays*/ 240 const int NUM_VERTICES = this->GetNumberOfVertices(); 241 242 /* Start looping on the number of vertices: */ 243 Gauss* gauss=this->NewGauss(); 244 for (int iv=0;iv<NUM_VERTICES;iv++){ 245 gauss->GaussVertex(iv); 246 247 calvingrate_input->GetInputValue(&c,gauss); 248 vx_input->GetInputValue(&vx,gauss); 249 vy_input->GetInputValue(&vy,gauss); 250 lsf_slopex_input->GetInputValue(&dphidx,gauss); 251 lsf_slopey_input->GetInputValue(&dphidy,gauss); 252 253 vel=sqrt(vx*vx + vy*vy) + 1e-14; 254 dphi=sqrt(dphidx*dphidx+dphidy*dphidy)+ 1e-14; 255 256 if(false){ 257 /*Velocity direction*/ 258 calvingratex[iv] = c*vx/vel; 259 calvingratey[iv] = c*vy/vel; 260 } 261 else{ 262 /*Lelvelset gradient (perpendicular to ice front)*/ 263 calvingratex[iv] = c*dphidx/dphi; 264 calvingratey[iv] = c*dphidy/dphi; 265 } 266 } 267 268 269 /*Add to inputs*/ 270 this->AddInput(CalvingratexEnum,&calvingratex[0],P1DGEnum); 271 this->AddInput(CalvingrateyEnum,&calvingratey[0],P1DGEnum); 272 //this->AddInput(CalvingCalvingrateEnum,&calvingrate[0],P1DGEnum); /*Do not change calving rate, that's our input!*/ 273 274 /*Clean up and return*/ 275 delete gauss; 276 }/*}}}*/ 277 void Element::CalvingSetZeroRate(){/*{{{*/ 278 279 /*Set calving rate as 0, this is probably because we are dealing with discrete calving laws*/ 280 IssmDouble calvingratex[MAXVERTICES] = {0.}; 281 IssmDouble calvingratey[MAXVERTICES] = {0.}; 282 IssmDouble calvingrate[MAXVERTICES] = {0.}; 283 this->AddInput(CalvingratexEnum,&calvingratex[0],P1DGEnum); 284 this->AddInput(CalvingrateyEnum,&calvingratey[0],P1DGEnum); 285 this->AddInput(CalvingCalvingrateEnum,&calvingrate[0],P1DGEnum); 174 286 }/*}}}*/ 175 287 void Element::ComputeLambdaS(){/*{{{*/ … … 929 1041 } 930 1042 /*}}}*/ 931 void Element::dViscositydBM LHO(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vxbase_input,Input* vybase_input, Input* vxshear_input ,Input* vyshear_input,Input* thickness_input,Input* n_input, IssmDouble zeta){/*{{{*/1043 void Element::dViscositydBMOLHO(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vxbase_input,Input* vybase_input, Input* vxshear_input ,Input* vyshear_input,Input* thickness_input,Input* n_input, IssmDouble zeta){/*{{{*/ 932 1044 933 1045 /*Intermediaries*/ … … 939 1051 940 1052 /* eps_eff^2 = exx^2 + eyy^2 + exy^2 + exz^2 + eyz^2 + exx*eyy */ 941 this->StrainRateM LHO(&epsilon[0],xyz_list,gauss,1053 this->StrainRateMOLHO(&epsilon[0],xyz_list,gauss, 942 1054 vxbase_input,vybase_input,vxshear_input,vyshear_input,thickness_input,n_input,zeta); 943 1055 eps_eff=sqrt(epsilon[0]*epsilon[0] + epsilon[1]*epsilon[1] + epsilon[2]*epsilon[2] … … 2158 2270 return shelf; 2159 2271 }/*}}}*/ 2272 bool Element::IsAllGrounded(){/*{{{*/ 2273 2274 Input* input=this->GetInput(MaskOceanLevelsetEnum); _assert_(input); 2275 if(input->GetInputMin() < 0.){ 2276 return false; 2277 } 2278 else{ 2279 return true; 2280 } 2281 }/*}}}*/ 2160 2282 bool Element::IsGrounded(){/*{{{*/ 2161 2283 … … 2257 2379 2258 2380 }/*}}}*/ 2381 void Element::LapseRateBasinSMB(int numelevbins, IssmDouble* lapserates, IssmDouble* elevbins,IssmDouble* refelevation){/*{{{*/ 2382 2383 /*Variable declaration*/ 2384 const int numvertices = this->GetNumberOfVertices(); 2385 bool isadjustsmb = false; 2386 int basinid,bb1,bb2; 2387 IssmDouble ela,refelevation_b; 2388 IssmDouble* surfacelist = xNew<IssmDouble>(numvertices); 2389 IssmDouble* smblist = xNew<IssmDouble>(numvertices); 2390 /* numelevbins values of lapse rates */ 2391 IssmDouble* lapserates_b = xNew<IssmDouble>(numelevbins); 2392 /* (numelevbins-1) limits between elevation bins (be cautious with indexing) */ 2393 IssmDouble* elevbins_b = xNew<IssmDouble>(numelevbins-1); 2394 2395 /*Retrieve SMB values non-adjusted for SMB lapse rate*/ 2396 this->GetInputListOnVertices(smblist,SmbMassBalanceEnum); 2397 /*Get surface elevation on vertices*/ 2398 this->GetInputListOnVertices(surfacelist,SurfaceEnum); 2399 /*Get basin-specific parameters of the element*/ 2400 this->GetInputValue(&basinid,SmbBasinsIdEnum); 2401 refelevation_b = refelevation[basinid]; 2402 for(int ii=0;ii<(numelevbins-1);ii++) elevbins_b[ii] = elevbins[basinid*(numelevbins-1)+ii]; 2403 for(int ii=0;ii<numelevbins;ii++){ 2404 lapserates_b[ii] = lapserates[basinid*numelevbins+ii]; 2405 if(lapserates_b[ii]!=0) isadjustsmb=true; 2406 } 2407 /*Adjust SMB if any lapse rate value is non-zero*/ 2408 if(isadjustsmb){ 2409 2410 for(int v=0;v<numvertices;v++){ 2411 /*Find elevation bin of Reference elevation and of Vertex*/ 2412 for(int ii=0;ii<(numelevbins-1);ii++){ 2413 if(surfacelist[v]<=elevbins_b[ii]) bb1 = ii; 2414 if(refelevation_b<=elevbins_b[ii]) bb2 = ii; 2415 } 2416 /*Check for elevations above highest bin limit */ 2417 if(surfacelist[v]>elevbins_b[numelevbins-1-1]) bb1 = numelevbins-1; 2418 if(refelevation_b>elevbins_b[numelevbins-1-1]) bb2 = numelevbins-1; 2419 /*Vertex and Reference elevation in same elevation bin*/ 2420 if(bb1==bb2){ 2421 smblist[v] = smblist[v]+(surfacelist[v]-refelevation_b)*lapserates_b[bb2]; 2422 } 2423 /*Vertex in lower elevation bin than Reference elevation*/ 2424 if(bb1<bb2){ 2425 smblist[v] = smblist[v]+(elevbins_b[bb2-1]-refelevation_b)*lapserates_b[bb2]; 2426 for(int ii=bb2-1;ii>bb1;ii--) smblist[v] = smblist[v]+(elevbins_b[ii-1]-elevbins_b[ii])*lapserates_b[ii]; 2427 smblist[v] = smblist[v]+(surfacelist[v]-elevbins_b[bb1])*lapserates_b[bb1]; 2428 } 2429 /*Vertex in higher elevation bin than Reference elevation*/ 2430 if(bb1>bb2){ 2431 smblist[v] = smblist[v]+(elevbins_b[bb2]-refelevation_b)*lapserates_b[bb2]; 2432 for(int ii=bb2+1;ii<bb1;ii++) smblist[v] = smblist[v]+(elevbins_b[ii]-elevbins_b[ii-1])*lapserates_b[ii]; 2433 smblist[v] = smblist[v]+(surfacelist[v]-elevbins_b[bb1-1])*lapserates_b[bb1]; 2434 } 2435 } 2436 } 2437 2438 /*Add input to element*/ 2439 this->AddInput(SmbMassBalanceEnum,smblist,P1Enum); 2440 2441 /*Cleanup*/ 2442 xDelete<IssmDouble>(lapserates_b); 2443 xDelete<IssmDouble>(elevbins_b); 2444 xDelete<IssmDouble>(surfacelist); 2445 xDelete<IssmDouble>(smblist); 2446 }/*}}}*/ 2259 2447 void Element::LinearFloatingiceMeltingRate(){/*{{{*/ 2260 2448 … … 2264 2452 IssmDouble base[MAXVERTICES]; 2265 2453 IssmDouble values[MAXVERTICES]; 2266 IssmDouble perturbation[MAXVERTICES];2267 2454 IssmDouble time; 2268 2455 … … 2275 2462 2276 2463 this->GetInputListOnVertices(&base[0],BaseEnum); 2277 this->GetInputListOnVertices(&perturbation[0],BasalforcingsPerturbationMeltingRateEnum);2278 2464 for(int i=0;i<NUM_VERTICES;i++){ 2279 2465 if(base[i]>=upperwaterel){ … … 2287 2473 values[i]=deepwatermelt*alpha+(1.-alpha)*upperwatermelt; 2288 2474 } 2289 2290 values[i]+=perturbation[i];2291 2475 } 2292 2476 … … 2298 2482 const int NUM_VERTICES = this->GetNumberOfVertices(); 2299 2483 2484 IssmDouble alpha; 2300 2485 IssmDouble deepwatermelt[MAXVERTICES]; 2301 IssmDouble deepwaterel[MAXVERTICES];; 2486 IssmDouble deepwaterel[MAXVERTICES]; 2487 IssmDouble upperwatermelt[MAXVERTICES]; 2302 2488 IssmDouble upperwaterel[MAXVERTICES]; 2489 IssmDouble perturbation[MAXVERTICES]; 2303 2490 IssmDouble base[MAXVERTICES]; 2304 2491 IssmDouble values[MAXVERTICES]; 2305 2492 2306 2493 this->GetInputListOnVertices(&base[0],BaseEnum); 2307 this->GetInputListOnVertices(&deepwatermelt[0],BasalforcingsDeepwaterMeltingRateEnum); 2308 this->GetInputListOnVertices(&deepwaterel[0],BasalforcingsDeepwaterElevationEnum); 2309 this->GetInputListOnVertices(&upperwaterel[0],BasalforcingsUpperwaterElevationEnum); 2494 this->GetInputListOnVertices(&deepwatermelt[0],BasalforcingsSpatialDeepwaterMeltingRateEnum); 2495 this->GetInputListOnVertices(&deepwaterel[0],BasalforcingsSpatialDeepwaterElevationEnum); 2496 this->GetInputListOnVertices(&upperwatermelt[0],BasalforcingsSpatialUpperwaterMeltingRateEnum); 2497 this->GetInputListOnVertices(&upperwaterel[0],BasalforcingsSpatialUpperwaterElevationEnum); 2498 this->GetInputListOnVertices(&perturbation[0],BasalforcingsPerturbationMeltingRateEnum); 2310 2499 2311 2500 for(int i=0;i<NUM_VERTICES;i++){ 2312 if(base[i]>upperwaterel[i]) values[i]=0; 2313 else if (base[i]<deepwaterel[i]) values[i]=deepwatermelt[i]; 2314 else values[i]=deepwatermelt[i]*(base[i]-upperwaterel[i])/(deepwaterel[i]-upperwaterel[i]); 2501 if(base[i]>=upperwaterel[i]){ 2502 values[i]=upperwatermelt[i]; 2503 } 2504 else if (base[i]<deepwaterel[i]){ 2505 values[i]=deepwatermelt[i]; 2506 } 2507 else{ 2508 alpha = (base[i]-upperwaterel[i])/(deepwaterel[i]-upperwaterel[i]); 2509 values[i]=deepwatermelt[i]*alpha+(1.-alpha)*upperwatermelt[i]; 2510 } 2511 values[i] += perturbation[i]; 2315 2512 } 2316 2513 … … 3050 3247 case P1xP3Enum: 3051 3248 case P1xP4Enum: 3249 case P1DGEnum: 3052 3250 temp_input->element_values[3] = yearlytemperatures[3]; 3053 3251 temp_input->element_values[4] = yearlytemperatures[4]; … … 3074 3272 case P1xP3Enum: 3075 3273 case P1xP4Enum: 3274 case P1DGEnum: 3076 3275 ThermalToEnthalpy(&enth_input->element_values[3],yearlytemperatures[3],0.,0.); 3077 3276 ThermalToEnthalpy(&enth_input->element_values[4],yearlytemperatures[4],0.,0.); … … 3355 3554 this->CalvingCrevasseDepth(); 3356 3555 break; 3556 case CalvingParameterizationEnum: 3557 this->CalvingRateParameterization(); 3558 break; 3559 case CalvingTestEnum: 3560 this->CalvingRateTest(); 3561 break; 3357 3562 default: 3358 3563 _error_("Calving law "<<EnumToStringx(calvinglaw)<<" not supported yet"); … … 3364 3569 case StrainRateperpendicularEnum: this->StrainRateperpendicular(); break; 3365 3570 case SurfaceCrevasseEnum: this->CalvingCrevasseDepth(); break; 3366 case SigmaVMEnum: this->C alvingRateVonmises(); break;3571 case SigmaVMEnum: this->ComputeSigmaVM(); break; 3367 3572 case PartitioningEnum: this->inputs->SetInput(PartitioningEnum,this->lid,IssmComm::GetRank()); break; 3368 3573 } … … 4414 4619 4415 4620 }/*}}}*/ 4416 void Element::StrainRateM LHO(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vxbase_input,Input* vybase_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input,IssmDouble zeta){/*{{{*/4417 /*Compute the 2d Blatter/M LHO Strain Rate (5 components) for a given vertical coordinate (zeta):4621 void Element::StrainRateMOLHO(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vxbase_input,Input* vybase_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input,IssmDouble zeta){/*{{{*/ 4622 /*Compute the 2d Blatter/MOLHO Strain Rate (5 components) for a given vertical coordinate (zeta): 4418 4623 * 4419 4624 * epsilon=[exx eyy exy exz eyz] -
issm/trunk/src/c/classes/Elements/Element.h
r26744 r27035 70 70 void AutoregressionInit(int numbasins,int arorder,int nspin,IssmDouble starttime,IssmDouble tstep_ar,IssmDouble tinit_ar,IssmDouble* beta0,IssmDouble* beta1,IssmDouble* phi,int enum_type); 71 71 void Autoregression(bool isstepforar,int arorder,IssmDouble telapsed_ar,IssmDouble* beta0,IssmDouble* beta1,IssmDouble* phi,bool isfieldstochastic,int enum_type); 72 void BasinLinearFloatingiceMeltingRate(IssmDouble* deepwaterel,IssmDouble* upperwatermelt,IssmDouble* upperwaterel,IssmDouble* perturbation); 73 void CalvingSetZeroRate(void); 74 void CalvingFromRate(void); 72 75 void ComputeLambdaS(void); 73 76 void ComputeNewDamage(); … … 83 86 void dViscositydBHO(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 84 87 void dViscositydBSSA(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 85 void dViscositydBM LHO(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vxbase_input,Input* vybase_input, Input* vxshear_input ,Input* vyshear_input,Input* thickness_input,Input* n_input, IssmDouble zeta);88 void dViscositydBMOLHO(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vxbase_input,Input* vybase_input, Input* vxshear_input ,Input* vyshear_input,Input* thickness_input,Input* n_input, IssmDouble zeta); 86 89 void dViscositydDSSA(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 87 90 void Echo(); … … 144 147 145 148 bool IsAllFloating(); 149 bool IsAllGrounded(); 146 150 bool IsGrounded(); 147 151 bool IsOnBase(); … … 153 157 bool IsLandInElement(); 154 158 void Ismip6FloatingiceMeltingRate(); 159 void LapseRateBasinSMB(int numelevbins, IssmDouble* lapserates, IssmDouble* elevbins,IssmDouble* refelevation); 155 160 void LinearFloatingiceMeltingRate(); 156 161 void SpatialLinearFloatingiceMeltingRate(); … … 185 190 void StrainRateHO(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 186 191 void StrainRateHO2dvertical(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 187 void StrainRateM LHO(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input,IssmDouble zeta);192 void StrainRateMOLHO(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input,IssmDouble zeta); 188 193 void StrainRateSSA(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 189 194 void StrainRateSSA1d(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input); … … 227 232 virtual void AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part)=0; 228 233 virtual void BasalNodeIndices(int* pnumindices,int** pindices,int finiteelement){_error_("not implemented yet");}; 234 virtual void CalvingRateParameterization(void){_error_("not implemented yet");}; 229 235 virtual void CalvingRateVonmises(void){_error_("not implemented yet");}; 236 virtual void CalvingRateTest(void){_error_("not implemented yet");}; 230 237 virtual void CalvingCrevasseDepth(void){_error_("not implemented yet");}; 231 238 virtual void CalvingRateLevermann(void)=0; … … 236 243 virtual void ComputeDeviatoricStressTensor(void)=0; 237 244 virtual void ComputeSigmaNN(void)=0; 245 virtual void ComputeSigmaVM(void){_error_("not implemented yet");}; 238 246 virtual void ComputeStressTensor(void)=0; 239 247 virtual void ComputeEsaStrainAndVorticity(void)=0; … … 343 351 virtual void PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding)=0; 344 352 virtual int PressureInterpolation()=0; 345 virtual void Recover3DM LHOInput(int targetVel_enum, int numnodes, IssmDouble* vb, IssmDouble* vsh, IssmDouble* n, IssmDouble* H, IssmDouble* s){_error_("not implemented yet");};353 virtual void Recover3DMOLHOInput(int targetVel_enum, int numnodes, IssmDouble* vb, IssmDouble* vsh, IssmDouble* n, IssmDouble* H, IssmDouble* s){_error_("not implemented yet");}; 346 354 virtual void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe)=0; 347 355 virtual void ResetFSBasalBoundaryCondition()=0; … … 395 403 396 404 virtual void SealevelchangeGeometrySubElementKernel(SealevelGeometry* slgeom)=0; 397 virtual void SealevelchangeMomentOfInertiaCentroid(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom)=0;398 405 virtual void SealevelchangeShift(GrdLoads* loads, IssmDouble offset, SealevelGeometry* slgeom)=0; 399 406 virtual void SealevelchangeGeometryInitial(IssmDouble* xxe, IssmDouble* yye, IssmDouble* zze, IssmDouble* areae)=0; … … 404 411 virtual void SealevelchangeOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble* sealevelpercpu, SealevelGeometry* slgeom)=0; 405 412 virtual void SealevelchangeDeformationConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom)=0; 406 virtual void SealevelchangeMomentOfInertiaSubElement(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom)=0; 407 virtual void SealevelchangeUpdateViscousFields()=0; 413 virtual void SealevelchangeUpdateViscousFields(IssmDouble lincoeff, int newindex, int offset)=0; 408 414 #endif 409 415 -
issm/trunk/src/c/classes/Elements/Penta.cpp
r26744 r27035 271 271 272 272 if(!this->IsOnBase()) return; 273 274 IssmDouble xyz_list[NUMVERTICES][3]; 275 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/ 276 IssmDouble calvingratex[NUMVERTICES]; 277 IssmDouble calvingratey[NUMVERTICES]; 273 this->ComputeSigmaVM(); 274 278 275 IssmDouble calvingrate[NUMVERTICES]; 279 IssmDouble lambda1,lambda2,ex,ey,vx,vy,vel; 280 IssmDouble B,sigma_max,sigma_max_floating,sigma_max_grounded,n; 281 IssmDouble epse_2,groundedice,bed,sealevel; 282 IssmDouble sigma_vm[NUMVERTICES]; 283 284 /* Get node coordinates and dof list: */ 285 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 276 IssmDouble vx,vy; 277 IssmDouble sigma_vm,sigma_max,sigma_max_floating,sigma_max_grounded; 278 IssmDouble groundedice,bed,sealevel; 286 279 287 280 /*Depth average B for stress calculation*/ 288 this->InputDepthAverageAtBase(MaterialsRheologyBEnum,MaterialsRheologyBbarEnum);289 281 this->InputDepthAverageAtBase(VxEnum,VxAverageEnum); 290 282 this->InputDepthAverageAtBase(VyEnum,VyAverageEnum); … … 295 287 Input* gr_input = this->GetInput(MaskOceanLevelsetEnum); _assert_(gr_input); 296 288 Input* bs_input = this->GetInput(BaseEnum); _assert_(bs_input); 297 Input* B_input = this->GetInput(MaterialsRheologyBbarEnum); _assert_(B_input);298 Input* n_input = this->GetInput(MaterialsRheologyNEnum); _assert_(n_input);299 289 Input* smax_fl_input = this->GetInput(CalvingStressThresholdFloatingiceEnum); _assert_(smax_fl_input); 300 290 Input* smax_gr_input = this->GetInput(CalvingStressThresholdGroundediceEnum); _assert_(smax_gr_input); 301 291 Input* sl_input = this->GetInput(SealevelEnum); _assert_(sl_input); 292 Input* sigma_vm_input = this->GetInput(SigmaVMEnum); _assert_(sigma_vm_input); 302 293 303 294 /* Start looping on the number of vertices: */ … … 307 298 308 299 /*Get velocity components and thickness*/ 309 B_input->GetInputValue(&B,&gauss);310 n_input->GetInputValue(&n,&gauss);311 300 vx_input->GetInputValue(&vx,&gauss); 312 301 vy_input->GetInputValue(&vy,&gauss); 302 sigma_vm_input->GetInputValue(&sigma_vm,&gauss); 313 303 gr_input->GetInputValue(&groundedice,&gauss); 314 304 bs_input->GetInputValue(&bed,&gauss); 315 305 smax_fl_input->GetInputValue(&sigma_max_floating,&gauss); 316 306 smax_gr_input->GetInputValue(&sigma_max_grounded,&gauss); 317 vel=sqrt(vx*vx+vy*vy)+1.e-14;318 307 sl_input->GetInputValue(&sealevel,&gauss); 319 320 /*Compute strain rate and viscosity: */321 this->StrainRateSSA(&epsilon[0],&xyz_list[0][0],&gauss,vx_input,vy_input);322 323 /*Get Eigen values*/324 Matrix2x2Eigen(&lambda1,&lambda2,&ex,&ey,epsilon[0],epsilon[2],epsilon[1]);325 _assert_(!xIsNan<IssmDouble>(lambda1));326 _assert_(!xIsNan<IssmDouble>(lambda2));327 328 /*Process Eigen values (only account for extension)*/329 lambda1 = max(lambda1,0.);330 lambda2 = max(lambda2,0.);331 332 /*Calculate sigma_vm*/333 epse_2 = 1./2. *(lambda1*lambda1 + lambda2*lambda2);334 sigma_vm[iv] = sqrt(3.) * B * pow(epse_2,1./(2.*n));335 308 336 309 /*Tensile stress threshold*/ … … 342 315 /*Assign values*/ 343 316 if(bed>sealevel){ 344 calvingratex[iv]=0.; 345 calvingratey[iv]=0.; 317 calvingrate[iv] = 0.; 346 318 } 347 319 else{ 348 calvingratex[iv]=vx*sigma_vm[iv]/sigma_max; 349 calvingratey[iv]=vy*sigma_vm[iv]/sigma_max; 350 } 351 calvingrate[iv] =sqrt(calvingratex[iv]*calvingratex[iv] + calvingratey[iv]*calvingratey[iv]); 320 calvingrate[iv] = sqrt(vx*vx+vy*vy)*sigma_vm/sigma_max; 321 } 352 322 } 353 323 354 324 /*Add input*/ 355 this->AddBasalInput(CalvingratexEnum,&calvingratex[0],P1DGEnum);356 this->AddBasalInput(CalvingrateyEnum,&calvingratey[0],P1DGEnum);357 325 this->AddBasalInput(CalvingCalvingrateEnum,&calvingrate[0],P1DGEnum); 358 this->AddBasalInput(SigmaVMEnum,&sigma_vm[0],P1DGEnum); 359 326 this->CalvingFromRate(); 327 328 /*Extrude*/ 329 this->InputExtrude(CalvingCalvingrateEnum,-1); 360 330 this->InputExtrude(CalvingratexEnum,-1); 361 331 this->InputExtrude(CalvingrateyEnum,-1); 362 this->InputExtrude(CalvingCalvingrateEnum,-1);363 this->InputExtrude(SigmaVMEnum,-1);364 332 } 365 333 /*}}}*/ … … 847 815 this->AddInput(StressTensoryzEnum,&sigma_yz[0],P1DGEnum); 848 816 this->AddInput(StressTensorzzEnum,&sigma_zz[0],P1DGEnum); 817 } 818 /*}}}*/ 819 void Penta::ComputeSigmaVM(){/*{{{*/ 820 821 if(!this->IsOnBase()) return; 822 823 IssmDouble xyz_list[NUMVERTICES][3]; 824 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/ 825 IssmDouble lambda1,lambda2,ex,ey,vx,vy,vel; 826 IssmDouble B,n; 827 IssmDouble sigma_vm[NUMVERTICES]; 828 829 /* Get node coordinates and dof list: */ 830 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 831 832 /*Depth average B for stress calculation*/ 833 this->InputDepthAverageAtBase(MaterialsRheologyBEnum,MaterialsRheologyBbarEnum); 834 this->InputDepthAverageAtBase(VxEnum,VxAverageEnum); 835 this->InputDepthAverageAtBase(VyEnum,VyAverageEnum); 836 837 /*Retrieve all inputs and parameters we will need*/ 838 Input* vx_input = this->GetInput(VxAverageEnum); _assert_(vx_input); 839 Input* vy_input = this->GetInput(VyAverageEnum); _assert_(vy_input); 840 Input* B_input = this->GetInput(MaterialsRheologyBbarEnum); _assert_(B_input); 841 Input* n_input = this->GetInput(MaterialsRheologyNEnum); _assert_(n_input); 842 843 /* Start looping on the number of vertices: */ 844 GaussPenta gauss; 845 for(int iv=0;iv<3;iv++){ 846 gauss.GaussVertex(iv); 847 848 /*Get velocity components and thickness*/ 849 B_input->GetInputValue(&B,&gauss); 850 n_input->GetInputValue(&n,&gauss); 851 vx_input->GetInputValue(&vx,&gauss); 852 vy_input->GetInputValue(&vy,&gauss); 853 vel=sqrt(vx*vx+vy*vy)+1.e-14; 854 855 /*Compute strain rate and viscosity: */ 856 this->StrainRateSSA(&epsilon[0],&xyz_list[0][0],&gauss,vx_input,vy_input); 857 858 /*Get Eigen values*/ 859 Matrix2x2Eigen(&lambda1,&lambda2,&ex,&ey,epsilon[0],epsilon[2],epsilon[1]); 860 _assert_(!xIsNan<IssmDouble>(lambda1)); 861 _assert_(!xIsNan<IssmDouble>(lambda2)); 862 863 /*Process Eigen values (only account for extension)*/ 864 lambda1 = max(lambda1,0.); 865 lambda2 = max(lambda2,0.); 866 867 /*Calculate sigma_vm*/ 868 IssmDouble epse_2 = 1./2. *(lambda1*lambda1 + lambda2*lambda2); 869 sigma_vm[iv] = sqrt(3.) * B * pow(epse_2,1./(2.*n)); 870 } 871 872 /*Add input*/ 873 this->AddBasalInput(SigmaVMEnum,&sigma_vm[0],P1DGEnum); 874 this->InputExtrude(SigmaVMEnum,-1); 849 875 } 850 876 /*}}}*/ … … 2840 2866 } 2841 2867 /*}}}*/ 2842 void Penta::MovingFrontalVelocity(void){/*{{{*/ 2868 void Penta::MovingFrontalVelocity(void){/*{{{*/ 2869 2843 2870 if(!this->IsOnBase()) return; 2844 int dim,domaintype, calvinglaw, i;2871 int domaintype, calvinglaw, i; 2845 2872 IssmDouble v[3],w[3],c[3],m[3],dlsf[3]; 2846 2873 IssmDouble norm_dlsf, norm_calving, calvingrate, meltingrate, groundedice; 2847 2874 IssmDouble migrationmax, calvinghaf, heaviside, haf_eps; 2848 IssmDouble xyz_list[NUMVERTICES][3]; 2849 IssmDouble movingfrontvx[NUMVERTICES]; 2850 IssmDouble movingfrontvy[NUMVERTICES]; 2851 IssmDouble vel; 2875 IssmDouble xyz_list[NUMVERTICES][3]; 2876 IssmDouble movingfrontvx[NUMVERTICES]; 2877 IssmDouble movingfrontvy[NUMVERTICES]; 2878 IssmDouble vel; 2879 int dim=2; 2852 2880 2853 2881 /* Get node coordinates and dof list: */ 2854 2882 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2855 2856 Input* vx_input = NULL;2857 Input* vy_input = NULL;2858 2883 Input* calvingratex_input = NULL; 2859 2884 Input* calvingratey_input = NULL; 2860 Input* lsf_slopex_input = NULL;2861 Input* lsf_slopey_input = NULL;2862 2885 Input* calvingrate_input = NULL; 2863 2886 Input* meltingrate_input = NULL; 2864 Input* gr_input = NULL; 2887 2888 /*Load levelset function gradients*/ 2889 Input *lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input); 2890 Input *lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input); 2891 Input *vx_input = this->GetInput(VxAverageEnum); _assert_(vx_input); 2892 Input *vy_input = this->GetInput(VyAverageEnum); _assert_(vy_input); 2893 Input *gr_input = this->GetInput(MaskOceanLevelsetEnum); _assert_(gr_input); 2865 2894 2866 2895 /*Get problem dimension and whether there is moving front or not*/ 2867 this->FindParam(&domaintype,DomainTypeEnum);2868 2896 this->FindParam(&calvinglaw,CalvingLawEnum); 2869 2870 switch(domaintype){2871 case Domain2DverticalEnum: dim = 1; break;2872 case Domain2DhorizontalEnum: dim = 2; break;2873 case Domain3DEnum: dim = 2; break;2874 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet");2875 }2876 /*Load velocities*/2877 switch(domaintype){2878 case Domain2DverticalEnum:2879 vx_input=this->GetInput(VxEnum); _assert_(vx_input);2880 break;2881 case Domain2DhorizontalEnum:2882 vx_input=this->GetInput(VxEnum); _assert_(vx_input);2883 vy_input=this->GetInput(VyEnum); _assert_(vy_input);2884 gr_input=this->GetInput(MaskOceanLevelsetEnum); _assert_(gr_input);2885 break;2886 case Domain3DEnum:2887 vx_input=this->GetInput(VxAverageEnum); _assert_(vx_input);2888 vy_input=this->GetInput(VyAverageEnum); _assert_(vy_input);2889 gr_input=this->GetInput(MaskOceanLevelsetEnum); _assert_(gr_input);2890 break;2891 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet");2892 }2893 2894 2897 switch(calvinglaw){ 2895 2898 case DefaultCalvingEnum: 2896 2899 case CalvingVonmisesEnum: 2897 lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input);2898 if(dim==2) lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input);2899 calvingrate_input = this->GetInput(CalvingCalvingrateEnum); _assert_(calvingrate_input);2900 meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input);2901 break;2902 2900 case CalvingLevermannEnum: 2903 switch(domaintype){ 2904 case Domain2DverticalEnum: 2905 calvingratex_input=this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 2906 break; 2907 case Domain2DhorizontalEnum: 2908 calvingratex_input=this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 2909 calvingratey_input=this->GetInput(CalvingrateyEnum); _assert_(calvingratey_input); 2910 break; 2911 case Domain3DEnum: 2912 calvingratex_input=this->GetInput(CalvingratexAverageEnum); _assert_(calvingratex_input); 2913 calvingratey_input=this->GetInput(CalvingrateyAverageEnum); _assert_(calvingratey_input); 2914 break; 2915 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 2916 } 2901 calvingratex_input=this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 2902 calvingratey_input=this->GetInput(CalvingrateyEnum); _assert_(calvingratey_input); 2917 2903 meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input); 2918 2904 break; 2919 2905 case CalvingMinthicknessEnum: 2920 lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input);2921 if(dim==2) lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input);2922 meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input);2923 break;2924 2906 case CalvingHabEnum: 2925 lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input);2926 if(dim==2) lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input);2927 meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input);2928 break;2929 2907 case CalvingCrevasseDepthEnum: 2930 lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input);2931 if(dim==2) lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input);2932 2908 meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input); 2933 2909 break; 2934 2910 case CalvingDev2Enum: 2935 2911 this->FindParam(&calvinghaf,CalvingHeightAboveFloatationEnum); 2936 lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input);2937 if(dim==2) lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input);2938 2912 calvingrate_input = this->GetInput(CalvingCalvingrateEnum); _assert_(calvingrate_input); 2939 2913 meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input); … … 2952 2926 vy_input->GetInputValue(&v[1],&gauss); 2953 2927 gr_input->GetInputValue(&groundedice,&gauss); 2928 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss); 2929 lsf_slopey_input->GetInputValue(&dlsf[1],&gauss); 2930 norm_dlsf=sqrt(dlsf[0]*dlsf[0] + dlsf[1]*dlsf[1]); 2954 2931 2955 2932 /*Get calving speed*/ … … 2957 2934 case DefaultCalvingEnum: 2958 2935 case CalvingVonmisesEnum: 2959 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss);2960 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],&gauss);2961 calvingrate_input->GetInputValue(&calvingrate,&gauss);2962 meltingrate_input->GetInputValue(&meltingrate,&gauss);2963 2964 if(groundedice<0) meltingrate = 0.;2965 2966 norm_dlsf=0.;2967 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2);2968 norm_dlsf=sqrt(norm_dlsf);2969 2970 if(norm_dlsf>1.e-10)2971 for(i=0;i<dim;i++){2972 c[i]=calvingrate*dlsf[i]/norm_dlsf; m[i]=meltingrate*dlsf[i]/norm_dlsf;2973 }2974 else2975 for(i=0;i<dim;i++){2976 c[i]=0.; m[i]=0.;2977 }2978 break;2979 2980 2936 case CalvingLevermannEnum: 2981 2937 calvingratex_input->GetInputValue(&c[0],&gauss); 2982 if(dim==2)calvingratey_input->GetInputValue(&c[1],&gauss);2938 calvingratey_input->GetInputValue(&c[1],&gauss); 2983 2939 meltingrate_input->GetInputValue(&meltingrate,&gauss); 2984 norm_calving=0.; 2985 for(i=0;i<dim;i++) norm_calving+=pow(c[i],2); 2986 norm_calving=sqrt(norm_calving)+1.e-14; 2987 for(i=0;i<dim;i++) m[i]=meltingrate*c[i]/norm_calving; 2940 if(groundedice<0) meltingrate = 0.; 2941 m[0]=meltingrate*dlsf[0]/norm_dlsf; 2942 m[1]=meltingrate*dlsf[1]/norm_dlsf; 2988 2943 break; 2989 2944 2990 2945 case CalvingMinthicknessEnum: 2991 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss);2992 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],&gauss);2946 case CalvingHabEnum: 2947 case CalvingCrevasseDepthEnum: 2993 2948 meltingrate_input->GetInputValue(&meltingrate,&gauss); 2994 2995 norm_dlsf=0.; 2996 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2); 2997 norm_dlsf=sqrt(norm_dlsf); 2949 if(groundedice<0) meltingrate = 0.; 2998 2950 2999 2951 if(norm_dlsf>1.e-10) … … 3009 2961 break; 3010 2962 3011 case CalvingHabEnum:3012 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss);3013 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],&gauss);3014 meltingrate_input->GetInputValue(&meltingrate,&gauss);3015 3016 norm_dlsf=0.;3017 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2);3018 norm_dlsf=sqrt(norm_dlsf);3019 3020 if(norm_dlsf>1.e-10)3021 for(i=0;i<dim;i++){3022 c[i]=0.;3023 m[i]=meltingrate*dlsf[i]/norm_dlsf;3024 }3025 else3026 for(i=0;i<dim;i++){3027 c[i]=0.;3028 m[i]=0.;3029 }3030 break;3031 3032 case CalvingCrevasseDepthEnum:3033 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss);3034 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],&gauss);3035 meltingrate_input->GetInputValue(&meltingrate,&gauss);3036 3037 if(groundedice<0) meltingrate = 0.;3038 3039 norm_dlsf=0.;3040 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2);3041 norm_dlsf=sqrt(norm_dlsf);3042 3043 if(norm_dlsf>1.e-10)3044 for(i=0;i<dim;i++){3045 c[i]=0.;3046 m[i]=meltingrate*dlsf[i]/norm_dlsf;3047 }3048 else3049 for(i=0;i<dim;i++){3050 c[i]=0.;3051 m[i]=0.;3052 }3053 break;3054 3055 2963 case CalvingDev2Enum: 3056 2964 { 3057 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss);3058 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],&gauss);3059 2965 calvingrate_input->GetInputValue(&calvingrate,&gauss); 3060 2966 meltingrate_input->GetInputValue(&meltingrate,&gauss); … … 3081 2987 } 3082 2988 3083 norm_dlsf=0.;3084 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2);3085 norm_dlsf=sqrt(norm_dlsf);3086 3087 2989 if(norm_dlsf>1.e-10) 3088 2990 for(i=0;i<dim;i++){ … … 3111 3013 this->AddInput(MovingFrontalVxEnum,&movingfrontvx[0],P1DGEnum); 3112 3014 this->AddInput(MovingFrontalVyEnum,&movingfrontvy[0],P1DGEnum); 3113 3114 3015 this->InputExtrude(MovingFrontalVxEnum,-1); 3115 3016 this->InputExtrude(MovingFrontalVyEnum,-1); … … 3296 3197 norm=sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); 3297 3198 3298 for(int i=0;i<3;i++) normal[i]=normal[i]/ norm;3199 for(int i=0;i<3;i++) normal[i]=normal[i]/(norm+1e-10); 3299 3200 } 3300 3201 /*}}}*/ … … 3381 3282 } 3382 3283 /*}}}*/ 3383 void Penta::Recover3DM LHOInput(int targetVel_enum, int numnodes, IssmDouble* vb, IssmDouble* vsh, IssmDouble* n, IssmDouble* H, IssmDouble* s){/*{{{*/3284 void Penta::Recover3DMOLHOInput(int targetVel_enum, int numnodes, IssmDouble* vb, IssmDouble* vsh, IssmDouble* n, IssmDouble* H, IssmDouble* s){/*{{{*/ 3384 3285 /* Recover the velocity acording to v=vb+(1-\zeta^{n+1})vsh, where \zeta=(s-z)/H 3385 3286 * The variables vb, vsh, n, H and s are all from the 2D horizontal mesh(Tria), with "numnodes" DOFs -
issm/trunk/src/c/classes/Elements/Penta.h
r26744 r27035 49 49 void AddControlInput(int input_enum,Inputs* inputs,IoModel* iomodel,IssmDouble* values,IssmDouble* values_min,IssmDouble* values_max, int interpolation_enum,int id); 50 50 void ControlInputExtrude(int enum_type,int start); 51 void ComputeSigmaVM(void); 51 52 void DatasetInputExtrude(int enum_type,int start); 52 53 void DatasetInputCreate(IssmDouble* array,int M,int N,int* individual_enums,int num_inputs,Inputs* inputs,IoModel* iomodel,int input_enum); … … 169 170 void PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding); 170 171 int PressureInterpolation(); 171 void Recover3DM LHOInput(int targetVel_enum, int numnodes, IssmDouble* vb, IssmDouble* vsh, IssmDouble* n, IssmDouble* H, IssmDouble* s);172 void Recover3DMOLHOInput(int targetVel_enum, int numnodes, IssmDouble* vb, IssmDouble* vsh, IssmDouble* n, IssmDouble* H, IssmDouble* s); 172 173 void ReduceMatrices(ElementMatrix* Ke,ElementVector* pe); 173 174 void ResetFSBasalBoundaryCondition(void); … … 225 226 void GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,Matlitho* litho, IssmDouble* x,IssmDouble* y){_error_("not implemented yet");}; 226 227 void SealevelchangeGeometrySubElementKernel(SealevelGeometry* slgeom){_error_("not implemented yet");}; 227 void SealevelchangeMomentOfInertiaCentroid(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom){_error_("not implemented yet");};228 228 void SealevelchangeShift(GrdLoads* loads, IssmDouble offset, SealevelGeometry* slgeom){_error_("not implemented yet");}; 229 229 void SealevelchangeGeometryInitial(IssmDouble* xxe, IssmDouble* yye, IssmDouble* zze, IssmDouble* areae){_error_("not implemented yet");}; … … 234 234 void SealevelchangeOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble* sealevelpercpu, SealevelGeometry* slgeom){_error_("not implemented yet");}; 235 235 void SealevelchangeDeformationConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom){_error_("not implemented yet");}; 236 void SealevelchangeMomentOfInertiaSubElement(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom){_error_("not implemented yet");}; 237 void SealevelchangeUpdateViscousFields(){_error_("not implemented yet");}; 236 void SealevelchangeUpdateViscousFields(IssmDouble lincoeff, int newindex, int offset){_error_("not implemented yet");}; 238 237 #endif 239 238 -
issm/trunk/src/c/classes/Elements/Seg.h
r26744 r27035 179 179 void GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,Matlitho* litho, IssmDouble* x,IssmDouble* y){_error_("not implemented yet");}; 180 180 void SealevelchangeGeometrySubElementKernel(SealevelGeometry* slgeom){_error_("not implemented yet");}; 181 void SealevelchangeMomentOfInertiaCentroid(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom){_error_("not implemented yet");};182 181 void SealevelchangeShift(GrdLoads* loads, IssmDouble offset, SealevelGeometry* slgeom){_error_("not implemented yet");}; 183 182 void SealevelchangeGeometryInitial(IssmDouble* xxe, IssmDouble* yye, IssmDouble* zze, IssmDouble* areae){_error_("not implemented yet");}; … … 188 187 void SealevelchangeOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble* sealevelpercpu, SealevelGeometry* slgeom){_error_("not implemented yet");}; 189 188 void SealevelchangeDeformationConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom){_error_("not implemented yet");}; 190 void SealevelchangeMomentOfInertiaSubElement(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom){_error_("not implemented yet");}; 191 void SealevelchangeUpdateViscousFields(){_error_("not implemented yet");}; 189 void SealevelchangeUpdateViscousFields(IssmDouble lincoeff, int newindex, int offset){_error_("not implemented yet");}; 192 190 #endif 193 191 -
issm/trunk/src/c/classes/Elements/Tetra.cpp
r26744 r27035 605 605 norm=sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); 606 606 607 for(int i=0;i<3;i++) normal[i]=normal[i]/ norm;607 for(int i=0;i<3;i++) normal[i]=normal[i]/(norm+1e-10); 608 608 } 609 609 /*}}}*/ -
issm/trunk/src/c/classes/Elements/Tetra.h
r26744 r27035 186 186 void GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt, Matlitho* litho, IssmDouble* x,IssmDouble* y){_error_("not implemented yet");}; 187 187 void SealevelchangeGeometrySubElementKernel(SealevelGeometry* slgeom){_error_("not implemented yet");}; 188 void SealevelchangeMomentOfInertiaCentroid(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom){_error_("not implemented yet");};189 188 void SealevelchangeShift(GrdLoads* loads, IssmDouble offset, SealevelGeometry* slgeom){_error_("not implemented yet");}; 190 189 void SealevelchangeGeometryInitial(IssmDouble* xxe, IssmDouble* yye, IssmDouble* zze, IssmDouble* areae){_error_("not implemented yet");}; … … 195 194 void SealevelchangeOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble* sealevelpercpu, SealevelGeometry* slgeom){_error_("not implemented yet");}; 196 195 void SealevelchangeDeformationConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom){_error_("not implemented yet");}; 197 void SealevelchangeMomentOfInertiaSubElement(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom){_error_("not implemented yet");}; 198 void SealevelchangeUpdateViscousFields(){_error_("not implemented yet");}; 196 void SealevelchangeUpdateViscousFields(IssmDouble lincoeff, int newindex, int offset){_error_("not implemented yet");}; 199 197 #endif 200 198 -
issm/trunk/src/c/classes/Elements/Tria.cpp
r26744 r27035 29 29 #define NUMVERTICES 3 30 30 #define NUMVERTICES1D 2 31 //#define ISMICI 131 //#define MICI 1 //1 = DeConto & Pollard, 2 = DOMINOS 32 32 33 33 /*Constructors/destructor/copy*/ … … 313 313 void Tria::CalvingRateVonmises(){/*{{{*/ 314 314 315 IssmDouble xyz_list[NUMVERTICES][3];316 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/317 IssmDouble calvingratex[NUMVERTICES]; 318 IssmDouble calvingratey[NUMVERTICES];315 /*First, compute Von Mises Stress*/ 316 this->ComputeSigmaVM(); 317 318 /*Now compute calving rate*/ 319 319 IssmDouble calvingrate[NUMVERTICES]; 320 IssmDouble lambda1,lambda2,ex,ey,vx,vy,vel; 321 IssmDouble sigma_vm[NUMVERTICES]; 322 IssmDouble B,sigma_max,sigma_max_floating,sigma_max_grounded,n; 323 IssmDouble epse_2,groundedice,bed,sealevel; // added sealevel 324 325 /* Get node coordinates and dof list: */ 326 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 320 IssmDouble sigma_vm,vx,vy; 321 IssmDouble sigma_max,sigma_max_floating,sigma_max_grounded,n; 322 IssmDouble groundedice,bed,sealevel; 327 323 328 324 /*Retrieve all inputs and parameters we will need*/ 329 Input* vx_input = this->GetInput(VxEnum); _assert_(vx_input); 330 Input* vy_input = this->GetInput(VyEnum); _assert_(vy_input); 331 Input* B_input = this->GetInput(MaterialsRheologyBbarEnum); _assert_(B_input); 332 Input* gr_input = this->GetInput(MaskOceanLevelsetEnum); _assert_(gr_input); 333 Input* bs_input = this->GetInput(BaseEnum); _assert_(bs_input); 334 Input* smax_fl_input = this->GetInput(CalvingStressThresholdFloatingiceEnum); _assert_(smax_fl_input); 335 Input* smax_gr_input = this->GetInput(CalvingStressThresholdGroundediceEnum); _assert_(smax_gr_input); 336 Input* n_input = this->GetInput(MaterialsRheologyNEnum); _assert_(n_input); 337 Input* sl_input = this->GetInput(SealevelEnum); _assert_(sl_input); 325 Input* vx_input = this->GetInput(VxEnum); _assert_(vx_input); 326 Input* vy_input = this->GetInput(VyEnum); _assert_(vy_input); 327 Input* gr_input = this->GetInput(MaskOceanLevelsetEnum); _assert_(gr_input); 328 Input* bs_input = this->GetInput(BaseEnum); _assert_(bs_input); 329 Input* smax_fl_input = this->GetInput(CalvingStressThresholdFloatingiceEnum); _assert_(smax_fl_input); 330 Input* smax_gr_input = this->GetInput(CalvingStressThresholdGroundediceEnum); _assert_(smax_gr_input); 331 Input* sl_input = this->GetInput(SealevelEnum); _assert_(sl_input); 332 Input* sigma_vm_input = this->GetInput(SigmaVMEnum); _assert_(sigma_vm_input); 338 333 339 334 /* Start looping on the number of vertices: */ … … 343 338 344 339 /*Get velocity components and thickness*/ 345 B_input->GetInputValue(&B,&gauss); 346 n_input->GetInputValue(&n,&gauss); 340 sigma_vm_input->GetInputValue(&sigma_vm,&gauss); 347 341 vx_input->GetInputValue(&vx,&gauss); 348 342 vy_input->GetInputValue(&vy,&gauss); … … 351 345 smax_fl_input->GetInputValue(&sigma_max_floating,&gauss); 352 346 smax_gr_input->GetInputValue(&sigma_max_grounded,&gauss); 353 vel=sqrt(vx*vx+vy*vy)+1.e-14;354 347 sl_input->GetInputValue(&sealevel,&gauss); 355 356 /*Compute strain rate and viscosity: */357 this->StrainRateSSA(&epsilon[0],&xyz_list[0][0],&gauss,vx_input,vy_input);358 359 /*Get Eigen values*/360 Matrix2x2Eigen(&lambda1,&lambda2,&ex,&ey,epsilon[0],epsilon[2],epsilon[1]);361 _assert_(!xIsNan<IssmDouble>(lambda1));362 _assert_(!xIsNan<IssmDouble>(lambda2));363 364 /*Process Eigen values (only account for extension)*/365 lambda1 = max(lambda1,0.);366 lambda2 = max(lambda2,0.);367 368 /*Calculate sigma_vm*/369 epse_2 = 1./2. *(lambda1*lambda1 + lambda2*lambda2);370 sigma_vm[iv] = sqrt(3.) * B * pow(epse_2,1./(2.*n));371 372 /*OLD (keep for a little bit)*/373 //sigma_max = 800.e+3; //IUGG previous test374 //sigma_max = 1000.e+3; //GRL375 //if(groundedice<0) sigma_max=150.e+3;376 348 377 349 /*Tensile stress threshold*/ … … 380 352 else 381 353 sigma_max = sigma_max_grounded; 354 382 355 /*Assign values*/ 383 if(bed>sealevel){ // Changed 0. to sealevel 384 calvingratex[iv]=0.; 385 calvingratey[iv]=0.; 356 if(bed>sealevel){ 357 calvingrate[iv] = 0.; 386 358 } 387 359 else{ 388 calvingratex[iv]=vx*sigma_vm[iv]/sigma_max; 389 calvingratey[iv]=vy*sigma_vm[iv]/sigma_max; 390 } 391 calvingrate[iv] =sqrt(calvingratex[iv]*calvingratex[iv] + calvingratey[iv]*calvingratey[iv]); 392 360 calvingrate[iv] = sqrt(vx*vx+vy*vy)*sigma_vm/sigma_max; 361 } 362 } 363 364 /*Add input*/ 365 this->AddInput(CalvingCalvingrateEnum,&calvingrate[0],P1DGEnum); 366 this->CalvingFromRate(); 367 } 368 /*}}}*/ 369 void Tria::CalvingRateTest(){/*{{{*/ 370 371 IssmDouble calvingratex[NUMVERTICES]; 372 IssmDouble calvingratey[NUMVERTICES]; 373 IssmDouble calvingrate[NUMVERTICES]; 374 IssmDouble vx,vy,vel; 375 IssmDouble dphidx, dphidy, dphi; 376 IssmDouble time; 377 IssmDouble coeff, indrate; 378 379 /*Retrieve all inputs and parameters we will need*/ 380 parameters->FindParam(&time,TimeEnum); 381 parameters->FindParam(&coeff,CalvingTestSpeedfactorEnum,time); 382 parameters->FindParam(&indrate,CalvingTestIndependentRateEnum,time); 383 384 Input* vx_input = this->GetInput(VxEnum); _assert_(vx_input); 385 Input* vy_input = this->GetInput(VyEnum); _assert_(vy_input); 386 Input *lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input); 387 Input *lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input); 388 389 /* Start looping on the number of vertices: */ 390 GaussTria gauss; 391 for(int iv=0;iv<NUMVERTICES;iv++){ 392 gauss.GaussVertex(iv); 393 394 /*Get velocity components and thickness*/ 395 vx_input->GetInputValue(&vx,&gauss); 396 vy_input->GetInputValue(&vy,&gauss); 397 398 lsf_slopex_input->GetInputValue(&dphidx,&gauss); 399 lsf_slopey_input->GetInputValue(&dphidy,&gauss); 400 401 vel=sqrt(vx*vx + vy*vy) + 1e-14; 402 dphi=sqrt(dphidx*dphidx+dphidy*dphidy)+ 1e-14; 403 404 calvingratex[iv]= coeff*vx + indrate*dphidx/dphi; 405 calvingratey[iv]= coeff*vy + indrate*dphidy/dphi; 406 calvingrate[iv] = sqrt(calvingratex[iv]*calvingratex[iv] + calvingratey[iv]*calvingratey[iv]); 393 407 } 394 408 … … 397 411 this->AddInput(CalvingrateyEnum,&calvingratey[0],P1DGEnum); 398 412 this->AddInput(CalvingCalvingrateEnum,&calvingrate[0],P1DGEnum); 399 this->AddInput(SigmaVMEnum,&sigma_vm[0],P1DGEnum);400 413 } 401 414 /*}}}*/ … … 655 668 IssmDouble calvingratex,calvingratey,thickness,Jdet,flux_per_area; 656 669 IssmDouble rho_ice=FindParam(MaterialsRhoIceEnum); 657 Input* thickness_input=this->GetInput(ThicknessEnum); _assert_(thickness_input); 658 Input* calvingratex_input=NULL; 659 Input* calvingratey_input=NULL; 660 if(domaintype==Domain2DhorizontalEnum){ 661 calvingratex_input=this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 662 calvingratey_input=this->GetInput(CalvingrateyEnum); _assert_(calvingratey_input); 663 } 664 else{ 665 calvingratex_input=this->GetInput(CalvingratexAverageEnum); _assert_(calvingratex_input); 666 calvingratey_input=this->GetInput(CalvingrateyAverageEnum); _assert_(calvingratey_input); 667 } 670 Input* thickness_input = this->GetInput(ThicknessEnum); _assert_(thickness_input); 671 Input* calvingratex_input = this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 672 Input* calvingratey_input = this->GetInput(CalvingrateyEnum); _assert_(calvingratey_input); 668 673 669 674 /*Start looping on Gaussian points*/ … … 789 794 IssmDouble calvingratex,calvingratey,vx,vy,vel,meltingrate,meltingratex,meltingratey,thickness,Jdet,flux_per_area; 790 795 IssmDouble rho_ice=FindParam(MaterialsRhoIceEnum); 791 Input* thickness_input=this->GetInput(ThicknessEnum); _assert_(thickness_input); 792 Input* calvingratex_input=NULL; 793 Input* calvingratey_input=NULL; 794 Input* vx_input=NULL; 795 Input* vy_input=NULL; 796 Input* meltingrate_input=NULL; 797 if(domaintype==Domain2DhorizontalEnum){ 798 calvingratex_input=this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 799 calvingratey_input=this->GetInput(CalvingrateyEnum); _assert_(calvingratey_input); 800 vx_input=this->GetInput(VxEnum); _assert_(vx_input); 801 vy_input=this->GetInput(VyEnum); _assert_(vy_input); 802 meltingrate_input=this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input); 803 } 804 else{ 805 calvingratex_input=this->GetInput(CalvingratexAverageEnum); _assert_(calvingratex_input); 806 calvingratey_input=this->GetInput(CalvingrateyAverageEnum); _assert_(calvingratey_input); 807 } 796 Input* thickness_input = this->GetInput(ThicknessEnum); _assert_(thickness_input); 797 Input* calvingratex_input = this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 798 Input* calvingratey_input = this->GetInput(CalvingrateyEnum); _assert_(calvingratey_input); 799 Input* vx_input = this->GetInput(VxEnum); _assert_(vx_input); 800 Input* vy_input = this->GetInput(VyEnum); _assert_(vy_input); 801 Input* meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input); 808 802 809 803 /*Start looping on Gaussian points*/ … … 832 826 delete gauss; 833 827 } 828 } 829 /*}}}*/ 830 void Tria::CalvingRateParameterization(){/*{{{*/ 831 832 IssmDouble xyz_list[NUMVERTICES][3]; 833 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/ 834 IssmDouble calvingrate[NUMVERTICES]; 835 IssmDouble lambda1,lambda2,ex,ey,vx,vy,vel; 836 IssmDouble sigma_vm[NUMVERTICES]; 837 IssmDouble B,sigma_max,sigma_max_floating,sigma_max_grounded,n; 838 IssmDouble epse_2,groundedice,bed,sealevel; 839 IssmDouble arate, rho_ice, rho_water, thickness, paramX, Hab; 840 int use_parameter=0; 841 int nonlinear_law=0; 842 IssmDouble theta, alpha, midp, gamma; 843 844 /* Get node coordinates and dof list: */ 845 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 846 847 /*Retrieve all inputs and parameters we will need*/ 848 Input *vx_input = this->GetInput(VxEnum); _assert_(vx_input); 849 Input *vy_input = this->GetInput(VyEnum); _assert_(vy_input); 850 Input *B_input = this->GetInput(MaterialsRheologyBbarEnum); _assert_(B_input); 851 Input *gr_input = this->GetInput(MaskOceanLevelsetEnum); _assert_(gr_input); 852 Input *bs_input = this->GetInput(BedEnum); _assert_(bs_input); 853 Input *H_input = this->GetInput(ThicknessEnum); _assert_(H_input); 854 Input *smax_fl_input = this->GetInput(CalvingStressThresholdFloatingiceEnum); _assert_(smax_fl_input); 855 Input *smax_gr_input = this->GetInput(CalvingStressThresholdGroundediceEnum); _assert_(smax_gr_input); 856 Input *n_input = this->GetInput(MaterialsRheologyNEnum); _assert_(n_input); 857 Input *sl_input = this->GetInput(SealevelEnum); _assert_(sl_input); 858 Input *arate_input = this->GetInput(CalvingAblationrateEnum); _assert_(arate_input); 859 860 /* Ice and sea water density */ 861 this->FindParam(&rho_ice,MaterialsRhoIceEnum); 862 this->FindParam(&rho_water,MaterialsRhoSeawaterEnum); 863 864 /* Use which parameter */ 865 this->FindParam(&use_parameter, CalvingUseParamEnum); 866 this->FindParam(&theta, CalvingScaleThetaEnum); 867 this->FindParam(&alpha, CalvingAmpAlphaEnum); 868 this->FindParam(&midp, CalvingMidpointEnum); 869 this->FindParam(&nonlinear_law, CalvingNonlinearLawEnum); 870 871 /* Start looping on the number of vertices: */ 872 GaussTria* gauss=new GaussTria(); 873 for(int iv=0;iv<NUMVERTICES;iv++){ 874 gauss->GaussVertex(iv); 875 876 /*Get velocity components and thickness*/ 877 B_input->GetInputValue(&B,gauss); 878 n_input->GetInputValue(&n,gauss); 879 vx_input->GetInputValue(&vx,gauss); 880 vy_input->GetInputValue(&vy,gauss); 881 gr_input->GetInputValue(&groundedice,gauss); 882 bs_input->GetInputValue(&bed,gauss); 883 H_input->GetInputValue(&thickness,gauss); 884 smax_fl_input->GetInputValue(&sigma_max_floating,gauss); 885 smax_gr_input->GetInputValue(&sigma_max_grounded,gauss); 886 vel=sqrt(vx*vx+vy*vy)+1.e-14; 887 sl_input->GetInputValue(&sealevel,gauss); 888 arate_input->GetInputValue(&arate,gauss); 889 890 /*Compute strain rate and viscosity: */ 891 this->StrainRateSSA(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input); 892 893 /*Get Eigen values*/ 894 Matrix2x2Eigen(&lambda1,&lambda2,&ex,&ey,epsilon[0],epsilon[2],epsilon[1]); 895 _assert_(!xIsNan<IssmDouble>(lambda1)); 896 _assert_(!xIsNan<IssmDouble>(lambda2)); 897 898 /*Process Eigen values (only account for extension)*/ 899 lambda1 = max(lambda1,0.); 900 lambda2 = max(lambda2,0.); 901 902 /*Calculate sigma_vm*/ 903 epse_2 = 1./2. *(lambda1*lambda1 + lambda2*lambda2); 904 sigma_vm[iv] = sqrt(3.) * B * pow(epse_2,1./(2.*n)); 905 906 /*Tensile stress threshold*/ 907 if(groundedice<0) 908 sigma_max = sigma_max_floating; 909 else 910 sigma_max = sigma_max_grounded; 911 912 switch (use_parameter) { 913 case 0: 914 /* bed elevation */ 915 paramX = bed; 916 break; 917 case 1: 918 /* Height above floatation */ 919 if (bed>sealevel) paramX = 0.0; 920 else paramX = thickness - (rho_water/rho_ice) * (sealevel-bed); 921 break; 922 case 2: 923 /* Thicknese */ 924 paramX = thickness; 925 break; 926 case 4: 927 /* bed elevation+linear curve fitting */ 928 paramX = bed; 929 break; 930 case -1: 931 /* use nothing, just the arate*/ 932 break; 933 default: 934 _error_("The parameter is not supported yet!"); 935 } 936 937 /* Compute the hyperbolic tangent function */ 938 if ((use_parameter>-0.5) & (use_parameter<3)) { 939 gamma = 0.5*theta*(1.0-tanh((paramX+midp)/alpha))+(1.0-theta); 940 if (gamma<0.0) gamma =0.0; 941 } 942 else if (use_parameter>=3) { 943 gamma = alpha*paramX + theta; 944 if (gamma > 1.0) gamma = 1.0; 945 if (gamma < 0.0) gamma = 0.0; 946 } 947 else gamma = 1; 948 949 /*-------------------------------------------*/ 950 if (nonlinear_law) { 951 /*This von Mises type has too strong positive feedback with vel included 952 * calvingrate[iv] = (arate+sigma_vm[iv]*vel/sigma_max)*gamma; 953 */ 954 Hab = thickness - (rho_water/rho_ice) * (sealevel-bed); 955 if (Hab < 0.) Hab = 0.; 956 if (bed > sealevel) Hab = 0.; 957 958 calvingrate[iv] = (arate+Hab/sigma_max)*gamma; 959 } 960 else { 961 calvingrate[iv] = arate*gamma; 962 } 963 } 964 965 /*Add input*/ 966 this->AddInput(CalvingCalvingrateEnum,&calvingrate[0],P1DGEnum); 967 this->AddInput(SigmaVMEnum,&sigma_vm[0],P1DGEnum); 968 this->CalvingFromRate(); 969 970 /*Clean up and return*/ 971 delete gauss; 834 972 } 835 973 /*}}}*/ … … 914 1052 } 915 1053 /*}}}*/ 916 void Tria::ComputeEsaStrainAndVorticity(){ /*{{{*/1054 void Tria::ComputeEsaStrainAndVorticity(){ /*{{{*/ 917 1055 918 1056 IssmDouble xyz_list[NUMVERTICES][3]; … … 1010 1148 delete gauss; 1011 1149 } 1150 } 1151 /*}}}*/ 1152 void Tria::ComputeSigmaVM(){/*{{{*/ 1153 1154 IssmDouble xyz_list[NUMVERTICES][3]; 1155 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/ 1156 IssmDouble lambda1,lambda2,ex,ey,vx,vy,vel; 1157 IssmDouble sigma_vm[NUMVERTICES]; 1158 IssmDouble B,n; 1159 1160 /* Get node coordinates and dof list: */ 1161 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 1162 1163 /*Retrieve all inputs and parameters we will need*/ 1164 Input* vx_input = this->GetInput(VxEnum); _assert_(vx_input); 1165 Input* vy_input = this->GetInput(VyEnum); _assert_(vy_input); 1166 Input* B_input = this->GetInput(MaterialsRheologyBbarEnum); _assert_(B_input); 1167 Input* n_input = this->GetInput(MaterialsRheologyNEnum); _assert_(n_input); 1168 1169 /* Start looping on the number of vertices: */ 1170 GaussTria gauss; 1171 for(int iv=0;iv<NUMVERTICES;iv++){ 1172 gauss.GaussVertex(iv); 1173 1174 /*Get velocity components and thickness*/ 1175 B_input->GetInputValue(&B,&gauss); 1176 n_input->GetInputValue(&n,&gauss); 1177 vx_input->GetInputValue(&vx,&gauss); 1178 vy_input->GetInputValue(&vy,&gauss); 1179 vel=sqrt(vx*vx+vy*vy)+1.e-14; 1180 1181 /*Compute strain rate and viscosity: */ 1182 this->StrainRateSSA(&epsilon[0],&xyz_list[0][0],&gauss,vx_input,vy_input); 1183 1184 /*Get Eigen values*/ 1185 Matrix2x2Eigen(&lambda1,&lambda2,&ex,&ey,epsilon[0],epsilon[2],epsilon[1]); 1186 _assert_(!xIsNan<IssmDouble>(lambda1)); 1187 _assert_(!xIsNan<IssmDouble>(lambda2)); 1188 1189 /*Process Eigen values (only account for extension)*/ 1190 lambda1 = max(lambda1,0.); 1191 lambda2 = max(lambda2,0.); 1192 1193 /*Calculate sigma_vm*/ 1194 IssmDouble epse_2 = 1./2. *(lambda1*lambda1 + lambda2*lambda2); 1195 sigma_vm[iv] = sqrt(3.) * B * pow(epse_2,1./(2.*n)); 1196 } 1197 1198 /*Add input*/ 1199 this->AddInput(SigmaVMEnum,&sigma_vm[0],P1DGEnum); 1012 1200 } 1013 1201 /*}}}*/ … … 1937 2125 //compute sea level load weights 1938 2126 this->GetFractionGeometry(loadweights,&phi,&point1,&fraction1,&fraction2,&istrapeze1,levelset); 1939 2127 for (int i=0;i<NUMVERTICES;i++) loadweights[i]/=phi; 1940 2128 this->GetBarycenterFromLevelset(platbar,plongbar, phi, fraction1, fraction2, late, longe, point1,istrapeze1,planetradius); 1941 2129 … … 2028 2216 this->GetFractionGeometry(loadweights,&phi2,&point2,&f,&g,&istrapeze2,levelset2); 2029 2217 this->GetBarycenterFromLevelset(platbar,plongbar, phi2, f, g, late, longe, point2,istrapeze2,planetradius); 2218 for (int i=0;i<NUMVERTICES;i++) loadweights[i]/=phi2; 2030 2219 *ploadarea=area*phi2; 2031 2220 return; … … 2034 2223 this->GetFractionGeometry(loadweights,&phi1,&point1,&d,&e,&istrapeze1,levelset1); 2035 2224 this->GetBarycenterFromLevelset(platbar,plongbar, phi1, d, e, late, longe, point1,istrapeze1,planetradius); 2225 for (int i=0;i<NUMVERTICES;i++) loadweights[i]/=phi1; 2036 2226 *ploadarea=area*phi1; 2037 2227 return; … … 2046 2236 this->GetBarycenterFromLevelset(platbar,plongbar, phi1, d, e, late, longe, point1,istrapeze1,planetradius); 2047 2237 *ploadarea=area*phi1; 2048 for (int i=0;i<NUMVERTICES;i++) loadweights[i]=weights1[i] ;2238 for (int i=0;i<NUMVERTICES;i++) loadweights[i]=weights1[i]/phi1; 2049 2239 return; 2050 2240 } … … 2107 2297 2108 2298 //interpolant weights of each point. Any field F[0,1,2] provided at the original vertices [0,1,2] will be equal on point k to sum_i (F[i] * w[k][i]) 2109 w[ 0][0]=1; //A2110 w[ 1][1]=1; //B2111 w[ 2][2]=1; //C2299 w[i0][i0]=1; //A 2300 w[i1][i1]=1; //B 2301 w[i2][i2]=1; //C 2112 2302 w[3][i0]=1.0-d; w[3][i1]=d; //D 2113 2303 w[4][i0]=1.0-e; w[4][i2]=e; //E … … 2331 2521 for (int j=0;j<3;j++){ 2332 2522 for (int i=0;i<NUMVERTICES;i++) { 2333 loadweights[j] =w1[i][j]*area1 + w2[i][j]*area2 + w3[i][j]*area3;2523 loadweights[j]+=w1[i][j]*area1 + w2[i][j]*area2 + w3[i][j]*area3; 2334 2524 barycenter[j]+=xyz1[i][j]*area1+xyz2[i][j]*area2+xyz3[i][j]*area3; 2335 2525 } 2336 loadweights[j]/=area ;2526 loadweights[j]/=areasub*3.0; 2337 2527 barycenter[j]/=areasub *3.0; 2338 2528 } … … 2604 2794 input->Serve(numindices,&indices[0]); 2605 2795 break; 2796 case P1xP2Enum: 2797 case P1xP3Enum: 2606 2798 case P1xP4Enum: 2607 2799 case P1DGEnum: … … 3596 3788 } 3597 3789 3598 3599 3790 /*Cleanup & return: */ 3600 3791 xDelete<int>(indices); … … 4101 4292 IssmDouble norm_dlsf, norm_calving, calvingrate, meltingrate, groundedice; 4102 4293 IssmDouble migrationmax, calvinghaf, heaviside, haf_eps; 4103 IssmDouble 4104 IssmDouble 4105 IssmDouble 4106 IssmDouble 4294 IssmDouble xyz_list[NUMVERTICES][3]; 4295 IssmDouble movingfrontvx[NUMVERTICES]; 4296 IssmDouble movingfrontvy[NUMVERTICES]; 4297 IssmDouble vel; 4107 4298 4108 4299 /* Get node coordinates and dof list: */ 4109 4300 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 4110 4301 4111 Input* vx_input = NULL;4112 Input* vy_input = NULL;4113 4302 Input* calvingratex_input = NULL; 4114 4303 Input* calvingratey_input = NULL; 4115 Input* lsf_slopex_input = NULL;4116 Input* lsf_slopey_input = NULL;4117 4304 Input* calvingrate_input = NULL; 4118 4305 Input* meltingrate_input = NULL; 4119 Input* gr_input = NULL;4120 4306 4121 4307 /*Get problem dimension and whether there is moving front or not*/ … … 4129 4315 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 4130 4316 } 4131 /*Load velocities*/ 4132 switch(domaintype){ 4133 case Domain2DverticalEnum: 4134 vx_input=this->GetInput(VxEnum); _assert_(vx_input); 4135 break; 4136 case Domain2DhorizontalEnum: 4137 vx_input=this->GetInput(VxEnum); _assert_(vx_input); 4138 vy_input=this->GetInput(VyEnum); _assert_(vy_input); 4139 gr_input=this->GetInput(MaskOceanLevelsetEnum); _assert_(gr_input); 4140 break; 4141 case Domain3DEnum: 4142 vx_input=this->GetInput(VxAverageEnum); _assert_(vx_input); 4143 vy_input=this->GetInput(VyAverageEnum); _assert_(vy_input); 4144 gr_input=this->GetInput(MaskOceanLevelsetEnum); _assert_(gr_input); 4145 break; 4146 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 4147 } 4317 4318 /*Load levelset function gradients*/ 4319 Input *gr_input = this->GetInput(MaskOceanLevelsetEnum); _assert_(gr_input); 4320 Input *lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input); 4321 Input *lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input); 4322 Input *vx_input = this->GetInput(VxEnum); _assert_(vx_input); 4323 Input *vy_input = this->GetInput(VyEnum); _assert_(vy_input); 4148 4324 4149 4325 switch(calvinglaw){ 4150 4326 case DefaultCalvingEnum: 4151 4327 case CalvingVonmisesEnum: 4152 lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input);4153 if(dim==2) lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input);4154 calvingrate_input = this->GetInput(CalvingCalvingrateEnum); _assert_(calvingrate_input);4155 meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input);4156 break;4157 4328 case CalvingLevermannEnum: 4158 switch(domaintype){ 4159 case Domain2DverticalEnum: 4160 calvingratex_input=this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 4161 break; 4162 case Domain2DhorizontalEnum: 4163 calvingratex_input=this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 4164 calvingratey_input=this->GetInput(CalvingrateyEnum); _assert_(calvingratey_input); 4165 break; 4166 case Domain3DEnum: 4167 calvingratex_input=this->GetInput(CalvingratexAverageEnum); _assert_(calvingratex_input); 4168 calvingratey_input=this->GetInput(CalvingrateyAverageEnum); _assert_(calvingratey_input); 4169 break; 4170 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 4171 } 4329 case CalvingTestEnum: 4330 case CalvingParameterizationEnum: 4331 calvingratex_input=this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 4332 calvingratey_input=this->GetInput(CalvingrateyEnum); _assert_(calvingratey_input); 4172 4333 meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input); 4173 4334 break; 4174 4335 case CalvingMinthicknessEnum: 4175 lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input);4176 if(dim==2) lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input);4177 meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input);4178 break;4179 4336 case CalvingHabEnum: 4180 lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input);4181 if(dim==2) lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input);4182 meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input);4183 break;4184 4337 case CalvingCrevasseDepthEnum: 4185 lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input);4186 if(dim==2) lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input);4187 4338 meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input); 4188 4339 break; 4189 4340 case CalvingDev2Enum: 4190 4341 this->FindParam(&calvinghaf,CalvingHeightAboveFloatationEnum); 4191 lsf_slopex_input = this->GetInput(LevelsetfunctionSlopeXEnum); _assert_(lsf_slopex_input);4192 if(dim==2) lsf_slopey_input = this->GetInput(LevelsetfunctionSlopeYEnum); _assert_(lsf_slopey_input);4193 4342 calvingrate_input = this->GetInput(CalvingCalvingrateEnum); _assert_(calvingrate_input); 4194 4343 meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input); … … 4207 4356 vy_input->GetInputValue(&v[1],&gauss); 4208 4357 gr_input->GetInputValue(&groundedice,&gauss); 4358 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss); 4359 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],&gauss); 4360 4361 norm_dlsf=0.; 4362 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2); 4363 norm_dlsf=sqrt(norm_dlsf); 4209 4364 4210 4365 /*Get calving speed*/ … … 4212 4367 case DefaultCalvingEnum: 4213 4368 case CalvingVonmisesEnum: 4214 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss); 4215 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],&gauss); 4216 calvingrate_input->GetInputValue(&calvingrate,&gauss); 4369 case CalvingTestEnum: 4370 case CalvingParameterizationEnum: 4371 calvingratex_input->GetInputValue(&c[0],&gauss); 4372 calvingratey_input->GetInputValue(&c[1],&gauss); 4217 4373 meltingrate_input->GetInputValue(&meltingrate,&gauss); 4218 4374 if(groundedice<0) meltingrate = 0.; 4219 4220 norm_dlsf=0.; 4221 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2); 4222 norm_dlsf=sqrt(norm_dlsf); 4223 4224 if(norm_dlsf>1.e-10) 4225 for(i=0;i<dim;i++){ 4226 c[i]=calvingrate*dlsf[i]/norm_dlsf; m[i]=meltingrate*dlsf[i]/norm_dlsf; 4227 } 4228 else 4229 for(i=0;i<dim;i++){ 4230 c[i]=0.; m[i]=0.; 4231 } 4375 m[0]=meltingrate*dlsf[0]/norm_dlsf; 4376 m[1]=meltingrate*dlsf[1]/norm_dlsf; 4377 4378 if(norm_dlsf<1.e-10){ 4379 for(i=0;i<dim;i++){ 4380 c[i]=0.; m[i]=0.; 4381 } 4382 } 4232 4383 break; 4233 4384 … … 4243 4394 4244 4395 case CalvingMinthicknessEnum: 4245 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss);4246 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],&gauss);4396 case CalvingHabEnum: 4397 case CalvingCrevasseDepthEnum: 4247 4398 meltingrate_input->GetInputValue(&meltingrate,&gauss); 4248 4249 norm_dlsf=0.;4250 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2);4251 norm_dlsf=sqrt(norm_dlsf);4252 4399 4253 4400 if(norm_dlsf>1.e-10) … … 4263 4410 break; 4264 4411 4265 case CalvingHabEnum:4266 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss);4267 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],&gauss);4268 meltingrate_input->GetInputValue(&meltingrate,&gauss);4269 4270 norm_dlsf=0.;4271 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2);4272 norm_dlsf=sqrt(norm_dlsf);4273 4274 if(norm_dlsf>1.e-10)4275 for(i=0;i<dim;i++){4276 c[i]=0.;4277 m[i]=meltingrate*dlsf[i]/norm_dlsf;4278 }4279 else4280 for(i=0;i<dim;i++){4281 c[i]=0.;4282 m[i]=0.;4283 }4284 break;4285 4286 case CalvingCrevasseDepthEnum:4287 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss);4288 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],&gauss);4289 meltingrate_input->GetInputValue(&meltingrate,&gauss);4290 4291 if(groundedice<0) meltingrate = 0.;4292 4293 norm_dlsf=0.;4294 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2);4295 norm_dlsf=sqrt(norm_dlsf);4296 4297 if(norm_dlsf>1.e-10)4298 for(i=0;i<dim;i++){4299 c[i]=0.;4300 m[i]=meltingrate*dlsf[i]/norm_dlsf;4301 }4302 else4303 for(i=0;i<dim;i++){4304 c[i]=0.;4305 m[i]=0.;4306 }4307 break;4308 4309 4412 case CalvingDev2Enum: 4310 4413 { 4311 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss);4312 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],&gauss);4313 4414 calvingrate_input->GetInputValue(&calvingrate,&gauss); 4314 4415 meltingrate_input->GetInputValue(&meltingrate,&gauss); … … 4335 4436 } 4336 4437 4337 norm_dlsf=0.;4338 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2);4339 norm_dlsf=sqrt(norm_dlsf);4340 4341 4438 if(norm_dlsf>1.e-10) 4342 4439 for(i=0;i<dim;i++){ … … 4351 4448 break; 4352 4449 } 4450 calvingratex_input->GetInputValue(&c[0],&gauss); 4451 if(dim==2) calvingratey_input->GetInputValue(&c[1],&gauss); 4452 for(i=0;i<dim;i++) m[i]=0.; 4453 break; 4353 4454 4354 4455 default: … … 4381 4482 ls_input->GetInputValue(&ls,&gauss); 4382 4483 4383 /*Do we assume that the calving front does not move?*/ 4384 //movingfrontvx[iv] = 0.; 4385 //movingfrontvy[iv] = 0.; 4386 4387 //if(Hc>80. && bed<0. && fabs(ls)<100.e3){ //Pollard & De Conto 4388 if(Hc>135. && bed<0. && fabs(ls)<100.e3){ // Crawford et all 4389 4390 lsf_slopex_input->GetInputValue(&dlsf[0],&gauss); 4391 norm_dlsf=0.; 4392 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2); 4393 norm_dlsf=sqrt(norm_dlsf); 4394 4395 /*use vel direction instead of LSF*/ 4396 vx_input->GetInputValue(&v[0],&gauss); 4397 vy_input->GetInputValue(&v[1],&gauss); 4398 vel=sqrt(v[0]*v[0] + v[1]*v[1]); 4399 norm_dlsf = max(vel,1.e-10); 4400 dlsf[0] = v[0]; 4401 dlsf[1] = v[1]; 4484 /*use vel direction instead of LSF*/ 4485 vx_input->GetInputValue(&v[0],&gauss); 4486 vy_input->GetInputValue(&v[1],&gauss); 4487 vel=sqrt(v[0]*v[0] + v[1]*v[1]); 4488 norm_dlsf = max(vel,1.e-10); 4489 dlsf[0] = v[0]; 4490 dlsf[1] = v[1]; 4491 4492 /*Do we assume that the calving front does not move if MICI is not engaged?*/ 4493 movingfrontvx[iv] = 0.; 4494 movingfrontvy[iv] = 0.; 4495 //movingfrontvx[iv] = -2000./(365*24*3600.)*dlsf[0]/norm_dlsf; 4496 //movingfrontvy[iv] = -2000./(365*24*3600.)*dlsf[1]/norm_dlsf; 4497 4498 if(MICI==1 && Hc>80. && bed<0. && fabs(ls)<100.e3){ //Pollard & De Conto 4499 IssmDouble C = (min(max(Hc,80.),100.) - 80.)/20. * 10./(24*3600.); /*Original MICI! convert from m/day to m/s*/ 4500 4501 /*Front motion = ice speed (v) - calving rate*/ 4502 movingfrontvx[iv] = v[0]-C*dlsf[0]/norm_dlsf; 4503 movingfrontvy[iv] = v[1]-C*dlsf[1]/norm_dlsf; 4504 } 4505 else if (MICI==2 && Hc>135. && bed<0. && fabs(ls)<100.e3){ // Crawford et all 4402 4506 4403 4507 /*5C Bn (worst case scenario)*/ … … 4405 4509 IssmDouble alpha = 7.3; 4406 4510 IssmDouble C = min(2000.,I*pow(Hc,alpha))/(24*3600.); /*convert from m/day to m/s*/ 4407 //IssmDouble C = (min(max(Hc,80.),100.) - 80.)/20. * 10./(24*3600.); /*Original MICI! convert from m/day to m/s*/ 4408 movingfrontvx[iv] = -C*dlsf[0]/norm_dlsf; 4409 movingfrontvy[iv] = -C*dlsf[1]/norm_dlsf; 4511 4512 /*Front motion = ice speed (v) - calving rate*/ 4513 movingfrontvx[iv] = v[0] -C*dlsf[0]/norm_dlsf; 4514 movingfrontvy[iv] = v[1] -C*dlsf[1]/norm_dlsf; 4410 4515 } 4411 4516 } … … 4587 4692 norm=sqrt(vector[0]*vector[0] + vector[1]*vector[1]); 4588 4693 4589 normal[0]= + vector[1]/ norm;4590 normal[1]= - vector[0]/ norm;4694 normal[0]= + vector[1]/(norm+1e-10); 4695 normal[1]= - vector[0]/(norm+1e-10); 4591 4696 } 4592 4697 /*}}}*/ … … 5214 5319 IssmDouble calvingratex,calvingratey,thickness,Jdet; 5215 5320 IssmDouble rho_ice=FindParam(MaterialsRhoIceEnum); 5216 Input* thickness_input=this->GetInput(ThicknessEnum); _assert_(thickness_input); 5217 Input* calvingratex_input=NULL; 5218 Input* calvingratey_input=NULL; 5219 if(domaintype==Domain2DhorizontalEnum){ 5220 calvingratex_input=this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 5221 calvingratey_input=this->GetInput(CalvingrateyEnum); _assert_(calvingratey_input); 5222 } 5223 else{ 5224 calvingratex_input=this->GetInput(CalvingratexAverageEnum); _assert_(calvingratex_input); 5225 calvingratey_input=this->GetInput(CalvingrateyAverageEnum); _assert_(calvingratey_input); 5226 } 5321 Input* thickness_input = this->GetInput(ThicknessEnum); _assert_(thickness_input); 5322 Input* calvingratex_input = this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 5323 Input* calvingratey_input = this->GetInput(CalvingrateyEnum); _assert_(calvingratey_input); 5227 5324 5228 5325 /*Start looping on Gaussian points*/ … … 5340 5437 /*Get inputs*/ 5341 5438 IssmDouble flux = 0.; 5342 IssmDouble calvingratex,calvingratey,vx,vy,vel,meltingrate,meltingratex,meltingratey,thickness,Jdet ;5439 IssmDouble calvingratex,calvingratey,vx,vy,vel,meltingrate,meltingratex,meltingratey,thickness,Jdet,groundedice; 5343 5440 IssmDouble rho_ice=FindParam(MaterialsRhoIceEnum); 5344 Input* thickness_input=this->GetInput(ThicknessEnum); _assert_(thickness_input); 5345 Input* calvingratex_input=NULL; 5346 Input* calvingratey_input=NULL; 5347 Input* vx_input=NULL; 5348 Input* vy_input=NULL; 5349 Input* meltingrate_input=NULL; 5350 if(domaintype==Domain2DhorizontalEnum){ 5351 calvingratex_input=this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 5352 calvingratey_input=this->GetInput(CalvingrateyEnum); _assert_(calvingratey_input); 5353 vx_input=this->GetInput(VxEnum); _assert_(vx_input); 5354 vy_input=this->GetInput(VyEnum); _assert_(vy_input); 5355 meltingrate_input=this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input); 5356 } 5357 else{ 5358 calvingratex_input=this->GetInput(CalvingratexAverageEnum); _assert_(calvingratex_input); 5359 calvingratey_input=this->GetInput(CalvingrateyAverageEnum); _assert_(calvingratey_input); 5360 } 5441 Input* thickness_input = this->GetInput(ThicknessEnum); _assert_(thickness_input); 5442 Input *gr_input = this->GetInput(MaskOceanLevelsetEnum); _assert_(gr_input); 5443 Input* calvingratex_input = this->GetInput(CalvingratexEnum); _assert_(calvingratex_input); 5444 Input* calvingratey_input = this->GetInput(CalvingrateyEnum); _assert_(calvingratey_input); 5445 Input* vx_input = this->GetInput(VxEnum); _assert_(vx_input); 5446 Input* vy_input = this->GetInput(VyEnum); _assert_(vy_input); 5447 Input* meltingrate_input = this->GetInput(CalvingMeltingrateEnum); _assert_(meltingrate_input); 5361 5448 5362 5449 /*Start looping on Gaussian points*/ … … 5366 5453 calvingratex_input->GetInputValue(&calvingratex,gauss); 5367 5454 calvingratey_input->GetInputValue(&calvingratey,gauss); 5455 gr_input->GetInputValue(&groundedice,gauss); 5368 5456 vx_input->GetInputValue(&vx,gauss); 5369 5457 vy_input->GetInputValue(&vy,gauss); 5370 5458 vel=vx*vx+vy*vy; 5371 5459 meltingrate_input->GetInputValue(&meltingrate,gauss); 5460 if(groundedice<0) meltingrate = 0.; 5372 5461 meltingratex=meltingrate*vx/(sqrt(vel)+1.e-14); 5373 5462 meltingratey=meltingrate*vy/(sqrt(vel)+1.e-14); … … 6237 6326 IssmDouble area,planetarea,planetradius; 6238 6327 IssmDouble constant,ratioe; 6239 IssmDouble I; //change in ice thickness or water level(Farrel and Clarke, Equ. 4)6240 6328 IssmDouble rho_earth; 6241 6329 IssmDouble NewtonG; 6242 IssmDouble g ;6330 IssmDouble g, cent_scaling; 6243 6331 IssmDouble lati,longi; 6244 6332 IssmDouble latitude[NUMVERTICES]; … … 6291 6379 6292 6380 /*Rotational:*/ 6381 #ifdef _HAVE_RESTRICT_ 6382 IssmDouble* __restrict__ tide_love_h = NULL; 6383 IssmDouble* __restrict__ tide_love_k = NULL; 6384 IssmDouble* __restrict__ tide_love_l = NULL; 6385 IssmDouble* __restrict__ LoveRotRSL = NULL; 6386 IssmDouble* __restrict__ LoveRotU = NULL; 6387 IssmDouble* __restrict__ LoveRothoriz = NULL; 6388 IssmDouble* __restrict__ Grot = NULL; 6389 IssmDouble* __restrict__ GUrot = NULL; 6390 IssmDouble* __restrict__ GNrot = NULL; 6391 IssmDouble* __restrict__ GErot = NULL; 6392 #else 6293 6393 IssmDouble* tide_love_h = NULL; 6294 6394 IssmDouble* tide_love_k = NULL; 6295 6395 IssmDouble* tide_love_l = NULL; 6396 IssmDouble* LoveRotRSL = NULL; 6397 IssmDouble* LoveRotU = NULL; 6398 IssmDouble* LoveRothoriz = NULL; 6399 IssmDouble* Grot = NULL; 6400 IssmDouble* GUrot = NULL; 6401 IssmDouble* GNrot = NULL; 6402 IssmDouble* GErot = NULL; 6403 #endif 6404 6296 6405 IssmDouble moi_e, moi_p, omega; 6297 IssmDouble Grotm1[3],GUrotm1[3],GNrotm1[3],GErotm1[3];6298 IssmDouble Grotm2[3],GUrotm2[3],GNrotm2[3],GErotm2[3];6299 IssmDouble Grotm3[3],GUrotm3[3],GNrotm3[3],GErotm3[3];6300 6406 IssmDouble Y21cos , Y21sin , Y20; 6301 6407 IssmDouble dY21cos_dlat,dY21sin_dlat,dY20_dlat; 6302 6408 IssmDouble dY21cos_dlon,dY21sin_dlon; 6303 IssmDouble LoveRotRSL,LoveRotU,LoveRothoriz;6304 6409 IssmDouble polenudge; 6305 6410 /*}}}*/ … … 6324 6429 6325 6430 if(computerotation){ 6326 parameters->FindParam(&tide_love_h,NULL,NULL,TidalLoveHEnum);6327 parameters->FindParam(&tide_love_k,NULL,NULL,TidalLoveKEnum);6328 parameters->FindParam(&tide_love_l,NULL,NULL,TidalLoveLEnum);6329 6431 parameters->FindParam(&moi_e,RotationalEquatorialMoiEnum); 6330 6432 parameters->FindParam(&moi_p,RotationalPolarMoiEnum); 6331 6433 parameters->FindParam(&omega,RotationalAngularVelocityEnum); 6434 //parameters->FindParam(&tide_love_h,NULL,NULL,SealevelchangeTidalH2Enum); 6435 //parameters->FindParam(&tide_love_k,NULL,NULL,SealevelchangeTidalK2Enum); 6436 //if(horiz) parameters->FindParam(&tide_love_l,NULL,NULL,SealevelchangeTidalL2Enum); 6332 6437 } 6333 6438 /*}}}*/ … … 6347 6452 parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelchangeHViscoElasticEnum)); _assert_(parameter); 6348 6453 parameter->GetParameterValueByPointer((IssmDouble**)&H_viscoelastic_precomputed,NULL); 6454 } 6455 6456 if(computerotation){ 6457 parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelchangeTidalH2Enum)); _assert_(parameter); 6458 parameter->GetParameterValueByPointer((IssmDouble**)&tide_love_h,NULL); 6459 6460 parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelchangeTidalK2Enum)); _assert_(parameter); 6461 parameter->GetParameterValueByPointer((IssmDouble**)&tide_love_k,NULL); 6462 6463 if (horiz) { 6464 parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelchangeTidalL2Enum)); _assert_(parameter); 6465 parameter->GetParameterValueByPointer((IssmDouble**)&tide_love_l,NULL); 6466 } 6349 6467 } 6350 6468 } … … 6387 6505 IssmDouble alpha; 6388 6506 IssmDouble delPhi,delLambda; 6389 /*recover info for this element and vertex:*/6507 /*recovers info for this element and vertex:*/ 6390 6508 IssmDouble late= asin(zze[e]/sqrt( pow(xxe[e],2.0)+ pow(yye[e],2.0)+ pow(zze[e],2.0))); 6391 6509 IssmDouble longe= atan2(yye[e],xxe[e]); … … 6394 6512 longi=longitude[i]; 6395 6513 6396 /*Compute alpha angle between centroid and current vertex and index intoprecomputed tables: */6514 /*Computes alpha angle between centroid and current vertex, and indexes alpha in precomputed tables: */ 6397 6515 delPhi=fabs(lati-late); delLambda=fabs(longi-longe); if (delLambda>M_PI)delLambda=2*M_PI-delLambda; 6398 6516 alpha=2.*asin(sqrt(pow(sin(delPhi/2),2)+cos(lati)*cos(late)*pow(sin(delLambda/2),2))); … … 6462 6580 /*Compute rotation kernel:{{{*/ 6463 6581 if(computerotation){ 6582 //initialization 6583 LoveRotRSL = xNewZeroInit<IssmDouble>(nt); 6584 LoveRotU = xNewZeroInit<IssmDouble>(nt); 6585 LoveRothoriz= xNewZeroInit<IssmDouble>(nt); 6586 Grot = xNewZeroInit<IssmDouble>(3*3*nt); //3 polar motion components * 3 vertices * number of time steps 6587 GUrot = xNewZeroInit<IssmDouble>(3*3*nt); 6588 6589 if (horiz){ 6590 GErot=xNewZeroInit<IssmDouble>(3*3*nt); 6591 GNrot=xNewZeroInit<IssmDouble>(3*3*nt); 6592 } 6464 6593 6465 6594 /*What is the gravity at planet's surface: */ 6466 6595 g=4.0/3.0*M_PI*rho_earth*NewtonG*planetradius; 6467 6468 //Amplitude of the rotational feedback 6469 LoveRotRSL=((1.0+tide_love_k[2]-tide_love_h[2])/g)*pow(omega*planetradius,2.0); 6470 LoveRotU=(tide_love_h[2]/g)*pow(omega*planetradius,2.0); 6471 LoveRothoriz=(tide_love_l[2]/g)*pow(omega*planetradius,2.0); 6472 6596 cent_scaling=pow(omega*planetradius,2.0); //centrifugal potential dimensioning constant 6597 for(int t=0;t<nt;t++){ 6598 //Amplitude of the rotational feedback 6599 //to speed up calculation we include the dimension constant r^2*Omega^2/g, so all 3 of these are in meters 6600 LoveRotRSL[t]=((1.0+tide_love_k[t]-tide_love_h[t])/g)*cent_scaling; 6601 LoveRotU[t]=(tide_love_h[t]/g)*cent_scaling; 6602 if (horiz) LoveRothoriz[t]=(tide_love_l[t]/g)*cent_scaling; 6603 } 6473 6604 for(int i=0;i<3;i++){ 6474 6605 … … 6489 6620 longi=longitude[i]; 6490 6621 6491 //Spherical harmonic functions of degree 2 6622 //Spherical harmonic functions of degree 2 (spatial pattern of rotation) 6492 6623 Y21cos= -0.5*sin(2.*lati)*cos(longi); 6493 6624 Y21sin= -0.5*sin(2.*lati)*sin(longi); 6494 6625 Y20 = -(1.0/6.0 - 0.5*cos(2.0*lati)); 6495 6626 6496 Grotm1[i]= LoveRotRSL*Y21cos; 6497 Grotm2[i]= LoveRotRSL*Y21sin; 6498 Grotm3[i]= LoveRotRSL*Y20; 6499 6500 if (computeelastic){ 6501 GUrotm1[i]= LoveRotU*Y21cos; 6502 GUrotm2[i]= LoveRotU*Y21sin; 6503 GUrotm3[i]= LoveRotU*Y20; 6504 if (horiz){ 6627 if (computeelastic && horiz){ 6505 6628 //bed_N = Love_l * d(Y)/dlat ; 6506 6629 dY21cos_dlat=-cos(2.*lati)*cos(longi); 6507 6630 dY21sin_dlat=-cos(2.*lati)*sin(longi); 6508 6631 dY20_dlat= -sin(2.*lati); 6509 GNrotm1[i]= LoveRothoriz*dY21cos_dlat;6510 GNrotm2[i]= LoveRothoriz*dY21sin_dlat;6511 GNrotm3[i]= LoveRothoriz*dY20_dlat;6512 6632 6513 6633 //bed_E = Love_l * 1/cos(lat) * d(Y)/dlon ; … … 6515 6635 dY21sin_dlon=Y21cos/cos(lati); 6516 6636 //dY20_dlon=0.; 6517 6518 GErotm1[i]= LoveRothoriz*dY21cos_dlon; 6519 GErotm2[i]= LoveRothoriz*dY21sin_dlon; 6520 GErotm3[i]= 0.0; 6637 } 6638 6639 for(int t=0;t<nt;t++){ 6640 6641 Grot[0*3*nt+i*nt+t]= LoveRotRSL[t]*Y21cos; //x component of polar motion 6642 Grot[1*3*nt+i*nt+t]= LoveRotRSL[t]*Y21sin; //y 6643 Grot[2*3*nt+i*nt+t]= LoveRotRSL[t]*Y20; //z 6644 6645 if (computeelastic){ 6646 GUrot[0*3*nt+i*nt+t]= LoveRotU[t]*Y21cos; 6647 GUrot[1*3*nt+i*nt+t]= LoveRotU[t]*Y21sin; 6648 GUrot[2*3*nt+i*nt+t]= LoveRotU[t]*Y20; 6649 if (horiz){ 6650 //bed_N = Love_l * d(Y)/dlat ; 6651 GNrot[0*3*nt+i*nt+t]= LoveRothoriz[t]*dY21cos_dlat; 6652 GNrot[1*3*nt+i*nt+t]= LoveRothoriz[t]*dY21sin_dlat; 6653 GNrot[2*3*nt+i*nt+t]= LoveRothoriz[t]*dY20_dlat; 6654 6655 //bed_E = Love_l * 1/cos(lat) * d(Y)/dlon ; 6656 GErot[0*3*nt+i*nt+t]= LoveRothoriz[t]*dY21cos_dlon; 6657 GErot[1*3*nt+i*nt+t]= LoveRothoriz[t]*dY21sin_dlon; 6658 GErot[2*3*nt+i*nt+t]= 0.0; 6659 } 6521 6660 } 6522 6661 } 6523 6662 } 6524 this->AddInput(SealevelGrotm1Enum,&Grotm1[0],P1Enum); 6525 this->AddInput(SealevelGrotm2Enum,&Grotm2[0],P1Enum); 6526 this->AddInput(SealevelGrotm3Enum,&Grotm3[0],P1Enum); 6663 this->inputs->SetArrayInput(SealevelchangeGrotEnum,this->lid,Grot,3*3*nt); 6527 6664 if (computeelastic){ 6528 this->AddInput(SealevelGUrotm1Enum,&GUrotm1[0],P1Enum); 6529 this->AddInput(SealevelGUrotm2Enum,&GUrotm2[0],P1Enum); 6530 this->AddInput(SealevelGUrotm3Enum,&GUrotm3[0],P1Enum); 6665 this->inputs->SetArrayInput(SealevelchangeGUrotEnum,this->lid,GUrot,3*3*nt); 6531 6666 if(horiz){ 6532 this->AddInput(SealevelGNrotm1Enum,&GNrotm1[0],P1Enum); 6533 this->AddInput(SealevelGNrotm2Enum,&GNrotm2[0],P1Enum); 6534 this->AddInput(SealevelGNrotm3Enum,&GNrotm3[0],P1Enum); 6535 this->AddInput(SealevelGErotm1Enum,&GErotm1[0],P1Enum); 6536 this->AddInput(SealevelGErotm2Enum,&GErotm2[0],P1Enum); 6537 this->AddInput(SealevelGErotm3Enum,&GErotm3[0],P1Enum); 6667 this->inputs->SetArrayInput(SealevelchangeGNrotEnum,this->lid,GNrot,3*3*nt); 6668 this->inputs->SetArrayInput(SealevelchangeGErotEnum,this->lid,GErot,3*3*nt); 6538 6669 } 6539 6670 } … … 6551 6682 viscousN=xNewZeroInit<IssmDouble>(3*nt); 6552 6683 viscousE=xNewZeroInit<IssmDouble>(3*nt); 6553 this->inputs->SetArrayInput(SealevelchangeViscousNEnum,this->lid,viscous RSL,3*nt);6554 this->inputs->SetArrayInput(SealevelchangeViscousEEnum,this->lid,viscous U,3*nt);6684 this->inputs->SetArrayInput(SealevelchangeViscousNEnum,this->lid,viscousN,3*nt); 6685 this->inputs->SetArrayInput(SealevelchangeViscousEEnum,this->lid,viscousE,3*nt); 6555 6686 } 6556 6687 } … … 6566 6697 delete GE; 6567 6698 } 6699 if(computerotation){ 6700 delete Grot; 6701 delete GUrot; 6702 if (horiz){ 6703 delete GNrot; 6704 delete GErot; 6705 } 6706 } 6568 6707 } 6569 6708 #else … … 6574 6713 xDelete(GN); 6575 6714 xDelete(GE); 6715 } 6716 if(computerotation){ 6717 xDelete(Grot); 6718 xDelete(GUrot); 6719 if (horiz){ 6720 xDelete(GNrot); 6721 xDelete(GErot); 6722 } 6576 6723 } 6577 6724 } … … 7127 7274 } 7128 7275 /*}}}*/ 7129 void Tria::SealevelchangeUpdateViscousFields( ){ /*{{{*/7276 void Tria::SealevelchangeUpdateViscousFields(IssmDouble lincoeff, int newindex, int offset){ /*{{{*/ 7130 7277 7131 7278 /*Inputs:*/ … … 7134 7281 IssmDouble* viscousN=NULL; 7135 7282 IssmDouble* viscousE=NULL; 7136 IssmDouble* viscoustimes=NULL;7137 7283 int viscousnumsteps; 7138 int viscousindex=0;7139 int newindex=0;7140 7284 int dummy; 7141 7285 bool viscous=false; 7142 IssmDouble currenttime; 7143 IssmDouble lincoeff=0; 7144 int horiz; 7286 int horiz=0; 7145 7287 7146 7288 this->parameters->FindParam(&viscous,SolidearthSettingsViscousEnum); … … 7148 7290 if(viscous){ 7149 7291 this->parameters->FindParam(&horiz,SolidearthSettingsHorizEnum); 7150 7151 7292 this->parameters->FindParam(&viscousnumsteps,SealevelchangeViscousNumStepsEnum); 7152 this->parameters->FindParam(&viscoustimes,NULL,SealevelchangeViscousTimesEnum);7153 this->parameters->FindParam(&viscousindex,SealevelchangeViscousIndexEnum);7154 this->parameters->FindParam(¤ttime,TimeEnum);7155 7293 7156 7294 this->inputs->GetArrayPtr(SealevelchangeViscousRSLEnum,this->lid,&viscousRSL,&dummy); … … 7161 7299 } 7162 7300 7163 bool foundtime=false;7164 int offset=1;7165 lincoeff=0;7166 newindex=viscousnumsteps-2;7167 7168 for(int t=viscousindex;t<viscousnumsteps;t++){7169 if (viscoustimes[t]>currenttime){7170 newindex=t-1;7171 lincoeff=(currenttime-viscoustimes[newindex])/(viscoustimes[t]-viscoustimes[newindex]);7172 foundtime=true;7173 offset=0;7174 break;7175 }7176 }7177 7178 if(!foundtime) lincoeff=1;7179 viscoustimes[newindex]=currenttime;7180 7301 for(int i=0;i<NUMVERTICES;i++){ 7181 7302 viscousRSL[i*viscousnumsteps+newindex+offset]=(1-lincoeff)*viscousRSL[i*viscousnumsteps+newindex]+lincoeff*viscousRSL[i*viscousnumsteps+newindex+1]; … … 7186 7307 } 7187 7308 } 7188 viscousindex=newindex+offset; 7189 7190 this->parameters->SetParam(viscousindex,SealevelchangeViscousIndexEnum); 7191 this->parameters->SetParam(viscoustimes,viscousnumsteps,SealevelchangeViscousTimesEnum); 7192 7193 /*free allocations:*/ 7194 xDelete<IssmDouble>(viscoustimes); 7309 7195 7310 } 7196 7311 … … 7198 7313 /*}}}*/ 7199 7314 void Tria::SealevelchangeBarystaticLoads(GrdLoads* loads, BarystaticContributions* barycontrib, SealevelGeometry* slgeom){ /*{{{*/ 7315 7316 int nel; 7200 7317 7201 7318 /*Inputs:*/ … … 7203 7320 IssmDouble W[NUMVERTICES]; 7204 7321 IssmDouble BP[NUMVERTICES]; 7322 IssmDouble* areae=NULL; 7205 7323 7206 7324 /*output: */ … … 7219 7337 this->parameters->FindParam(&rho_water,MaterialsRhoSeawaterEnum); 7220 7338 this->parameters->FindParam(&rho_freshwater,MaterialsRhoFreshwaterEnum); 7339 this->parameters->FindParam(&areae,&nel,AreaeEnum); 7221 7340 7222 7341 /*Retrieve inputs:*/ … … 7243 7362 7244 7363 /*Compute barystatic component in kg:*/ 7364 // Note: Iavg, etc, already include partial area factor phi for subelement loading 7245 7365 bslcice = -slgeom->LoadArea[SLGEOM_ICE][this->lid]*Iavg; 7246 7366 bslchydro = -slgeom->LoadArea[SLGEOM_WATER][this->lid]*Wavg; … … 7267 7387 BPavg=0; 7268 7388 } 7269 /*Plug remaining values into centroi load vector:*/7389 /*Plug remaining values into centroid load vector:*/ 7270 7390 loads->vloads->SetValue(this->sid,Iavg+Wavg+BPavg,INS_VAL); 7271 7391 … … 7279 7399 /*sal green function:*/ 7280 7400 IssmDouble* G=NULL; 7401 IssmDouble* Grot=NULL; 7281 7402 IssmDouble* Gsub[SLGEOM_NUMLOADS]; 7282 7403 bool computefuture=false; … … 7288 7409 int size; 7289 7410 int nel,nbar; 7290 IssmDouble Grotm1[3]; 7291 IssmDouble Grotm2[3]; 7292 IssmDouble Grotm3[3]; 7411 7293 7412 7294 7413 this->parameters->FindParam(&sal,SolidearthSettingsSelfAttractionEnum); … … 7302 7421 this->inputs->GetArrayPtr(SealevelchangeGsubelHydroEnum,this->lid,&Gsub[SLGEOM_WATER],&size); 7303 7422 this->inputs->GetArrayPtr(SealevelchangeGsubelOceanEnum,this->lid,&Gsub[SLGEOM_OCEAN],&size); 7304 7305 this->SealevelchangeGxL(sealevelpercpu, G, Gsub, loads, slgeom, nel,percpu=true,SealevelchangeViscousRSLEnum,computefuture=false); 7306 } 7307 7308 if(rotation){ 7309 Element::GetInputListOnVertices(&Grotm1[0],SealevelGrotm1Enum); 7310 Element::GetInputListOnVertices(&Grotm2[0],SealevelGrotm2Enum); 7311 Element::GetInputListOnVertices(&Grotm3[0],SealevelGrotm3Enum); 7312 7313 for(int i=0;i<NUMVERTICES;i++){ 7314 if(slgeom->lids[this->vertices[i]->lid]==this->lid){ 7315 sealevelpercpu[this->vertices[i]->lid]+=Grotm1[i]*polarmotionvector[0]+Grotm2[i]*polarmotionvector[1]+Grotm3[i]*polarmotionvector[2]; 7316 } 7317 } 7318 } 7423 if (rotation) this->inputs->GetArrayPtr(SealevelchangeGrotEnum,this->lid,&Grot,&size); 7424 7425 this->SealevelchangeGxL(sealevelpercpu, G, Gsub, Grot, loads, polarmotionvector, slgeom, nel,percpu=true,SealevelchangeViscousRSLEnum,computefuture=false); 7426 } 7427 7319 7428 return; 7320 7429 } /*}}}*/ 7321 7430 void Tria::SealevelchangeOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble* sealevelpercpu, SealevelGeometry* slgeom){ /*{{{*/ 7322 7431 7323 /*sal green function:*/7324 7432 IssmDouble oceanaverage=0; 7325 7433 IssmDouble oceanarea=0; … … 7369 7477 IssmDouble* GE=NULL; 7370 7478 IssmDouble* GN=NULL; 7479 IssmDouble* Grot=NULL; 7480 IssmDouble* GUrot=NULL; 7481 IssmDouble* GNrot=NULL; 7482 IssmDouble* GErot=NULL; 7371 7483 IssmDouble* Gsub[SLGEOM_NUMLOADS]; 7372 7484 IssmDouble* GUsub[SLGEOM_NUMLOADS]; … … 7377 7489 int horiz; 7378 7490 int size; 7379 IssmDouble Grotm1[3]; 7380 IssmDouble Grotm2[3]; 7381 IssmDouble Grotm3[3]; 7382 IssmDouble GUrotm1[3]; 7383 IssmDouble GUrotm2[3]; 7384 IssmDouble GUrotm3[3]; 7385 IssmDouble GNrotm1[3]; 7386 IssmDouble GNrotm2[3]; 7387 IssmDouble GNrotm3[3]; 7388 IssmDouble GErotm1[3]; 7389 IssmDouble GErotm2[3]; 7390 IssmDouble GErotm3[3]; 7491 7391 7492 bool rotation= false; 7392 7493 bool elastic=false; … … 7424 7525 this->inputs->GetArrayPtr(SealevelchangeGEsubelOceanEnum,this->lid,&GEsub[SLGEOM_OCEAN],&size); 7425 7526 } 7426 } 7427 this->SealevelchangeGxL(&RSLGrd[0],G, Gsub, loads, slgeom, nel,percpu=false,SealevelchangeViscousRSLEnum,computefuture=true); 7527 if (rotation) { 7528 this->inputs->GetArrayPtr(SealevelchangeGrotEnum,this->lid,&Grot,&size); 7529 this->inputs->GetArrayPtr(SealevelchangeGUrotEnum,this->lid,&GUrot,&size); 7530 if (horiz){ 7531 this->inputs->GetArrayPtr(SealevelchangeGErotEnum,this->lid,&GErot,&size); 7532 this->inputs->GetArrayPtr(SealevelchangeGNrotEnum,this->lid,&GNrot,&size); 7533 } 7534 } 7535 } 7536 this->SealevelchangeGxL(&RSLGrd[0],G, Gsub, Grot, loads, polarmotionvector, slgeom, nel,percpu=false,SealevelchangeViscousRSLEnum,computefuture=true); 7428 7537 7429 7538 if(elastic){ 7430 this->SealevelchangeGxL(&UGrd[0],GU, GUsub, loads, slgeom, nel,percpu=false,SealevelchangeViscousUEnum,computefuture=true); 7431 if(horiz ){ 7432 this->SealevelchangeGxL(&NGrd[0],GN, GNsub, loads, slgeom, nel,percpu=false,SealevelchangeViscousNEnum,computefuture=true); 7433 this->SealevelchangeGxL(&EGrd[0],GE, GEsub, loads, slgeom, nel,percpu=false,SealevelchangeViscousEEnum,computefuture=true); 7434 } 7435 } 7436 } 7437 7438 if(rotation){ 7439 Element::GetInputListOnVertices(&Grotm1[0],SealevelGrotm1Enum); 7440 Element::GetInputListOnVertices(&Grotm2[0],SealevelGrotm2Enum); 7441 Element::GetInputListOnVertices(&Grotm3[0],SealevelGrotm3Enum); 7442 7443 for(int i=0;i<NUMVERTICES;i++){ 7444 if(slgeom->lids[this->vertices[i]->lid]==this->lid){ 7445 RSLGrd[i]+=Grotm1[i]*polarmotionvector[0]+Grotm2[i]*polarmotionvector[1]+Grotm3[i]*polarmotionvector[2]; 7446 } 7447 } 7448 7449 if (elastic){ 7450 Element::GetInputListOnVertices(&GUrotm1[0],SealevelGUrotm1Enum); 7451 Element::GetInputListOnVertices(&GUrotm2[0],SealevelGUrotm2Enum); 7452 Element::GetInputListOnVertices(&GUrotm3[0],SealevelGUrotm3Enum); 7453 7454 for(int i=0;i<NUMVERTICES;i++){ 7455 if(slgeom->lids[this->vertices[i]->lid]==this->lid){ 7456 UGrd[i]+=GUrotm1[i]*polarmotionvector[0]+GUrotm2[i]*polarmotionvector[1]+GUrotm3[i]*polarmotionvector[2]; 7457 } 7458 } 7459 if (horiz){ 7460 Element::GetInputListOnVertices(&GNrotm1[0],SealevelGNrotm1Enum); 7461 Element::GetInputListOnVertices(&GNrotm2[0],SealevelGNrotm2Enum); 7462 Element::GetInputListOnVertices(&GNrotm3[0],SealevelGNrotm3Enum); 7463 Element::GetInputListOnVertices(&GErotm1[0],SealevelGErotm1Enum); 7464 Element::GetInputListOnVertices(&GErotm2[0],SealevelGErotm2Enum); 7465 Element::GetInputListOnVertices(&GErotm3[0],SealevelGErotm3Enum); 7466 7467 for(int i=0;i<NUMVERTICES;i++){ 7468 if(slgeom->lids[this->vertices[i]->lid]==this->lid){ 7469 NGrd[i]+=GNrotm1[i]*polarmotionvector[0]+GNrotm2[i]*polarmotionvector[1]+GNrotm3[i]*polarmotionvector[2]; 7470 EGrd[i]+=GErotm1[i]*polarmotionvector[0]+GErotm2[i]*polarmotionvector[1]+GErotm3[i]*polarmotionvector[2]; 7471 } 7472 } 7539 this->SealevelchangeGxL(&UGrd[0],GU, GUsub, GUrot, loads, polarmotionvector, slgeom, nel,percpu=false,SealevelchangeViscousUEnum,computefuture=true); 7540 if(horiz){ 7541 this->SealevelchangeGxL(&NGrd[0],GN, GNsub, GNrot, loads, polarmotionvector, slgeom, nel,percpu=false,SealevelchangeViscousNEnum,computefuture=true); 7542 this->SealevelchangeGxL(&EGrd[0],GE, GEsub, GErot, loads, polarmotionvector, slgeom, nel,percpu=false,SealevelchangeViscousEEnum,computefuture=true); 7473 7543 } 7474 7544 } … … 7495 7565 7496 7566 } /*}}}*/ 7497 void Tria::SealevelchangeGxL(IssmDouble* grdfieldout, IssmDouble* G, IssmDouble** Gsub, GrdLoads* loads, SealevelGeometry* slgeom, int nel, bool percpu, int viscousenum, bool computefuture) { /*{{{*/ 7567 void Tria::SealevelchangeGxL(IssmDouble* grdfieldout, IssmDouble* G, IssmDouble** Gsub, IssmDouble* Grot, GrdLoads* loads, IssmDouble* polarmotionvector, SealevelGeometry* slgeom, int nel, bool percpu, int viscousenum, bool computefuture) { /*{{{*/ 7568 7569 //This function performs the actual convolution between Green functions and surface Loads for a particular grd field 7498 7570 7499 7571 IssmDouble* grdfield=NULL; 7500 7572 int i,e,l,t,nbar; 7501 7573 bool computeviscous=false; 7574 bool rotation=false; 7502 7575 IssmDouble* viscousfield=NULL; 7503 int nt=1; //important 7576 int nt=1; //important, ensures there is a defined value if computeviscous is false 7504 7577 int viscousindex=0; //important 7505 7578 int viscousnumsteps=1; //important 7506 7579 7507 7580 this->parameters->FindParam(&computeviscous,SolidearthSettingsViscousEnum); 7581 this->parameters->FindParam(&rotation,SolidearthSettingsRotationEnum); 7508 7582 if(computeviscous){ 7509 7583 this->parameters->FindParam(&viscousnumsteps,SealevelchangeViscousNumStepsEnum); 7510 if(computefuture) nt=viscousnumsteps; 7584 this->parameters->FindParam(&viscousindex,SealevelchangeViscousIndexEnum); 7585 if(computefuture) { 7586 nt=viscousnumsteps-viscousindex+2; //number of time steps remaining to reach final_time, +1 is sufficient with no adaptative time stepping, +2 necessary otherwise; we assume the safe choice here for the sake of simplicity 7587 if (nt>viscousnumsteps) nt=viscousnumsteps; 7588 } 7511 7589 else nt=1; 7512 7513 //allocate 7514 grdfield=xNewZeroInit<IssmDouble>(3*nt); 7515 } 7516 else grdfield=xNewZeroInit<IssmDouble>(3*nt); 7517 7518 if(loads->sealevelloads){ 7519 7590 } 7591 //allocate 7592 grdfield=xNewZeroInit<IssmDouble>(3*nt); 7593 7594 if(rotation){ //add rotational feedback 7595 for(int i=0;i<NUMVERTICES;i++){ //vertices 7596 if(slgeom->lids[this->vertices[i]->lid]==this->lid){ 7597 for (int m=0;m<3;m++){ //polar motion components 7598 for(t=0;t<nt;t++){ //time 7599 int index=m*3*viscousnumsteps+i*viscousnumsteps+t; 7600 grdfield[i*nt+t]+=Grot[index]*polarmotionvector[m]; 7601 } 7602 } 7603 } 7604 } 7605 } 7606 7607 7608 if(loads->sealevelloads){ // general case: loads + sealevel loads 7520 7609 for(i=0;i<NUMVERTICES;i++) { 7521 7610 if(slgeom->lids[this->vertices[i]->lid]!=this->lid)continue; … … 7546 7635 } 7547 7636 else{ //this is the initial convolution where only loads are provided 7548 7549 7637 for(i=0;i<NUMVERTICES;i++) { 7550 7638 if(slgeom->lids[this->vertices[i]->lid]!=this->lid)continue; … … 7567 7655 } 7568 7656 7569 if(computeviscous){ 7657 if(computeviscous){ /*{{{*/ 7658 // we need to do up to 3 things (* = only if computefuture) 7659 // 1*: add new grdfield contribution to the viscous stack for future time steps 7660 // 2: collect viscous grdfield from past loads due at present-day and add it to grdfield[current_time] 7661 // 3*: subtract from viscous stack the grdfield that has already been accounted for so we don't add it again at the next time step 7662 7570 7663 IssmDouble* grdfieldinterp=NULL; 7571 7664 IssmDouble* viscoustimes=NULL; … … 7574 7667 IssmDouble timeacc; 7575 7668 7576 this->parameters->FindParam(&viscousindex,SealevelchangeViscousIndexEnum);7577 7669 this->parameters->FindParam(&viscoustimes,NULL,SealevelchangeViscousTimesEnum); 7578 7670 this->parameters->FindParam(&final_time,TimesteppingFinalTimeEnum); 7579 7671 this->parameters->FindParam(&timeacc,SolidearthSettingsTimeAccEnum); 7580 7672 this->inputs->GetArrayPtr(viscousenum,this->lid,&viscousfield,NULL); 7673 /* Map new grdfield generated by present-day loads onto viscous time vector*/ 7581 7674 if(computefuture){ 7582 grdfieldinterp=xNew<IssmDouble>(3*nt); 7675 grdfieldinterp=xNewZeroInit<IssmDouble>(3*viscousnumsteps); 7676 //viscousindex time and first time step of grdfield coincide, so just copy that value 7677 for(int i=0;i<NUMVERTICES;i++){ 7678 if(slgeom->lids[this->vertices[i]->lid]!=this->lid)continue; 7679 grdfieldinterp[i*viscousnumsteps+viscousindex]= grdfield[i*nt+0]; 7680 } 7583 7681 if(viscoustimes[viscousindex]<final_time){ 7682 //And interpolate the rest of the points in the future 7584 7683 lincoeff=(viscoustimes[viscousindex+1]-viscoustimes[viscousindex])/timeacc; 7585 for(int t=viscousindex;t<nt;t++){ 7586 if(t==viscousindex){ 7587 for(int i=0;i<NUMVERTICES;i++){ 7588 if(slgeom->lids[this->vertices[i]->lid]!=this->lid)continue; 7589 grdfieldinterp[i*nt+t]= grdfield[i*nt+0]; 7590 } 7591 } 7592 else{ 7593 for(int i=0;i<NUMVERTICES;i++){ 7594 if(slgeom->lids[this->vertices[i]->lid]!=this->lid)continue; 7595 grdfieldinterp[i*nt+t]= (1-lincoeff)*grdfield[i*nt+(t-viscousindex-1)]+lincoeff*grdfield[i*nt+(t-viscousindex)]; 7596 } 7684 for(int t=viscousindex+1;t<viscousnumsteps;t++){ 7685 for(int i=0;i<NUMVERTICES;i++){ 7686 if(slgeom->lids[this->vertices[i]->lid]!=this->lid)continue; 7687 grdfieldinterp[i*viscousnumsteps+t]= (1-lincoeff)*grdfield[i*nt+(t-viscousindex-1)]+lincoeff*grdfield[i*nt+(t-viscousindex)]; 7597 7688 } 7598 7689 } … … 7606 7697 } 7607 7698 7608 if(computefuture){/*update viscous stack with future deformation from present load: */7609 7610 for(int t= nt-1;t>=viscousindex;t--){7699 /*update viscous stack with future deformation from present load: */ 7700 if(computefuture){ 7701 for(int t=viscousnumsteps-1;t>=viscousindex;t--){ 7611 7702 for(int i=0;i<NUMVERTICES;i++){ 7612 7703 if(slgeom->lids[this->vertices[i]->lid]!=this->lid)continue; 7613 7704 //offset viscousfield to remove all deformation that has already been added 7614 viscousfield[i*viscousnumsteps+t]+=grdfieldinterp[i* nt+t]-grdfieldinterp[i*nt+viscousindex]-viscousfield[i*viscousnumsteps+viscousindex];7705 viscousfield[i*viscousnumsteps+t]+=grdfieldinterp[i*viscousnumsteps+t]-grdfieldinterp[i*viscousnumsteps+viscousindex]-viscousfield[i*viscousnumsteps+viscousindex]; 7615 7706 } 7616 7707 } 7617 /* Re-add viscous stack now that we updated:*/7708 /*Save viscous stack now that we updated the values:*/ 7618 7709 this->inputs->SetArrayInput(viscousenum,this->lid,viscousfield,3*viscousnumsteps); 7619 7710 } … … 7621 7712 /*Free allocatoins:*/ 7622 7713 xDelete<IssmDouble>(viscoustimes); 7623 } 7714 } 7715 /*}}}*/ 7624 7716 7625 7717 /*store values computed on vertices, but don't repeat the computation if another element already computed it!:*/ … … 7636 7728 7637 7729 } /*}}}*/ 7638 void Tria::SealevelchangeMomentOfInertiaCentroid(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom){/*{{{*/ 7639 7640 IssmDouble S=0; 7641 7642 /*Compute area of element:*/ 7643 IssmDouble area,planetarea,re; 7644 IssmDouble late,longe; 7645 this->Element::GetInputValue(&area,AreaEnum); 7646 7647 /*recover parameters: */ 7648 this->parameters->FindParam(&planetarea,SolidearthPlanetAreaEnum); 7649 this->parameters->FindParam(&re,SolidearthPlanetRadiusEnum); 7650 late=slgeom->late[this->lid]/180*M_PI; 7651 longe=slgeom->longe[this->lid]/180*M_PI; 7652 7653 /*recover total load: */ 7654 if(loads->loads) S+=loads->loads[this->Sid()]; 7655 if(loads->sealevelloads) S+=loads->sealevelloads[this->Sid()]; 7656 7657 /* Perturbation terms for moment of inertia (moi_list): 7658 * computed analytically (see Wu & Peltier, eqs 10 & 32) 7659 * also consistent with my GMD formulation! 7660 * ALL in geographic coordinates 7661 * */ 7662 dI_list[0] = -4*M_PI*(S*area)*pow(re,4)*(sin(late)*cos(late)*cos(longe))/planetarea; 7663 dI_list[1] = -4*M_PI*(S*area)*pow(re,4)*(sin(late)*cos(late)*sin(longe))/planetarea; 7664 dI_list[2] = +4*M_PI*(S*area)*pow(re,4)*(1-pow(sin(late),2))/planetarea; 7665 return; 7666 }/*}}}*/ 7667 void Tria::SealevelchangeMomentOfInertiaSubElement(IssmDouble* dI_list, GrdLoads* grdloads, SealevelGeometry* slgeom){/*{{{*/ 7668 7669 IssmDouble SA=0; 7670 IssmDouble* loads=NULL; 7671 IssmDouble* sealevelloads=NULL; 7672 IssmDouble late,longe,re; 7673 int intj; 7674 IssmDouble area; 7675 IssmDouble planetarea; 7676 7677 /*recover parameters: */ 7678 this->parameters->FindParam(&planetarea,SolidearthPlanetAreaEnum); 7679 this->parameters->FindParam(&re,SolidearthPlanetRadiusEnum); 7680 7681 /*Initalize:*/ 7682 for(int i=0;i<3;i++)dI_list[i]=0; 7683 7684 /*Go through our loads:*/ 7685 for(int i=0;i<SLGEOM_NUMLOADS;i++){ 7686 if(slgeom->issubelement[i][this->lid]){ 7687 loads=grdloads->subloads[i]; 7688 if(i==SLGEOM_OCEAN) sealevelloads=grdloads->subsealevelloads; 7689 intj=slgeom->subelementmapping[i][this->lid]; 7690 late=slgeom->latbarycentre[i][intj]/180*M_PI; 7691 longe=slgeom->longbarycentre[i][intj]/180*M_PI; 7692 area=slgeom->area_subel[i][intj]; 7693 7694 /*recover total load: */ 7695 if(loads) SA+=loads[intj]*area; 7696 if(sealevelloads) SA+=sealevelloads[intj]*area; 7697 } 7698 } 7699 7700 /* Perturbation terms for moment of inertia (moi_list): 7701 * computed analytically (see Wu & Peltier, eqs 10 & 32) 7702 * also consistent with my GMD formulation! 7703 * ALL in geographic coordinates 7704 * */ 7705 dI_list[0] += -4*M_PI*(SA)*pow(re,4)*(sin(late)*cos(late)*cos(longe))/planetarea; 7706 dI_list[1] += -4*M_PI*(SA)*pow(re,4)*(sin(late)*cos(late)*sin(longe))/planetarea; 7707 dI_list[2] += +4*M_PI*(SA)*pow(re,4)*(1-pow(sin(late),2))/planetarea; 7708 7709 return; 7710 }/*}}}*/ 7730 7711 7731 void Tria::SealevelchangeShift(GrdLoads* loads, IssmDouble offset, SealevelGeometry* slgeom){ /*{{{*/ 7712 7732 -
issm/trunk/src/c/classes/Elements/Tria.h
r26744 r27035 55 55 void AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part); 56 56 void CalvingRateVonmises(); 57 void CalvingRateTest(); 57 58 void CalvingCrevasseDepth(); 58 59 void CalvingRateLevermann(); 59 60 void CalvingFluxLevelset(); 60 61 void CalvingMeltingFluxLevelset(); 62 void CalvingRateParameterization(); 61 63 IssmDouble CharacteristicLength(void); 62 64 void ComputeBasalStress(void); … … 64 66 void ComputeEsaStrainAndVorticity(); 65 67 void ComputeSigmaNN(); 68 void ComputeSigmaVM(); 66 69 void ComputeStressTensor(); 67 70 void ComputeSurfaceNormalVelocity(); … … 177 180 void SealevelchangeDeformationConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom); 178 181 void SealevelchangeShift(GrdLoads* loads, IssmDouble offset, SealevelGeometry* slgeom); 179 void SealevelchangeMomentOfInertiaCentroid(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom); 180 void SealevelchangeMomentOfInertiaSubElement(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom); 181 void SealevelchangeUpdateViscousFields(); 182 void SealevelchangeUpdateViscousFields(IssmDouble lincoeff, int newindex, int offset); 182 183 #endif 183 184 /*}}}*/ … … 243 244 void UpdateConstraintsExtrudeFromBase(void); 244 245 void UpdateConstraintsExtrudeFromTop(void); 245 void SealevelchangeGxL(IssmDouble* sealevel, IssmDouble* G, IssmDouble** Gsub, GrdLoads* loads,SealevelGeometry* slgeom, int nel, bool percpu,int stackenum,bool computefuture);246 void SealevelchangeGxL(IssmDouble* sealevel, IssmDouble* G, IssmDouble** Gsub, IssmDouble* Grot, GrdLoads* loads, IssmDouble* polarmotionvector,SealevelGeometry* slgeom, int nel, bool percpu,int stackenum,bool computefuture); 246 247 /*}}}*/ 247 248 -
issm/trunk/src/c/classes/ExternalResults/GenericExternalResult.h
r26744 r27035 227 227 } /*}}}*/ 228 228 template <> inline void GenericExternalResult<bool>::Marshall(MarshallHandle* marshallhandle){/*{{{*/ 229 printf("-------------- file: GenericExternalResult.h line: %i\n",__LINE__);230 229 this->GenericMarshall(marshallhandle); 231 230 … … 331 330 } /*}}}*/ 332 331 template <> inline void GenericExternalResult<char*>::Marshall(MarshallHandle* marshallhandle){/*{{{*/ 333 printf("-------------- file: GenericExternalResult.h line: %i\n",__LINE__);334 332 marshallhandle->call(this->id); 335 333 marshallhandle->call(this->result_name); … … 456 454 } /*}}}*/ 457 455 template <> inline void GenericExternalResult<int*>::Marshall(MarshallHandle* marshallhandle){/*{{{*/ 458 printf("-------------- file: GenericExternalResult.h line: %i\n",__LINE__);459 456 460 457 int object_enum = this->ObjectEnum(); … … 590 587 } /*}}}*/ 591 588 template <> inline void GenericExternalResult<IssmPDouble*>::Marshall(MarshallHandle* marshallhandle){/*{{{*/ 592 printf("-------------- file: GenericExternalResult.h line: %i\n",__LINE__);593 589 594 590 int object_enum = this->ObjectEnum(); -
issm/trunk/src/c/classes/FemModel.cpp
r26744 r27035 576 576 } 577 577 /*}}}*/ 578 void FemModel::Restart( ){ /*{{{*/579 580 FILE * restartfid=NULL;581 char * restartfilename= NULL;582 int femmodel_size =0;583 int fread_return =0;584 char * femmodel_buffer=NULL;585 char * femmodel_buffer_ini=NULL;578 void FemModel::Restart(int verboselevel){ /*{{{*/ 579 580 FILE *restartfid = NULL; 581 char *restartfilename = NULL; 582 int femmodel_size = 0; 583 int fread_return = 0; 584 char *femmodel_buffer = NULL; 585 char *femmodel_buffer_ini = NULL; 586 586 587 587 /*First, recover the name of the restart file: */ … … 597 597 598 598 /*Print banner*/ 599 _printf0_(" \n"); 600 _printf0_("====================================================================\n"); 601 _printf0_(" RESTART DETECTED: "<<restartfilename<< "\n"); 602 _printf0_("====================================================================\n"); 603 _printf0_(" \n"); 599 if(verboselevel>1){ 600 _printf0_(" \n"); 601 _printf0_("====================================================================\n"); 602 _printf0_(" RESTART DETECTED: "<<restartfilename<< "\n"); 603 _printf0_("====================================================================\n"); 604 _printf0_(" \n"); 605 } 606 else if(verboselevel==1){ 607 _printf0_(" == restarting from "<<restartfilename<<"\n"); 608 } 609 else{ 610 /*Do not print anything*/ 611 } 604 612 605 613 /*Figure out size of buffer to be read: */ … … 645 653 646 654 /*Read files*/ 647 this->Restart( );655 this->Restart(1); 648 656 649 657 /*Clean up and return*/ … … 3097 3105 void FemModel::UpdateConstraintsx(void){ /*{{{*/ 3098 3106 3099 IssmDouble time ;3107 IssmDouble time,yts; 3100 3108 int analysis_type,config_type; 3101 3109 … … 3104 3112 parameters->FindParam(&config_type,ConfigurationTypeEnum); 3105 3113 parameters->FindParam(&time,TimeEnum); 3114 parameters->FindParam(&yts,ConstantsYtsEnum); 3106 3115 3107 3116 int index=AnalysisIndex(config_type); … … 3109 3118 3110 3119 /*start module: */ 3111 if(VerboseModule()) _printf0_(" Updating constraints and active domain of analysis " << EnumToStringx(analysis_type) << " for time: " << time << "\n");3120 if(VerboseModule()) _printf0_(" Updating constraints and active domain of analysis " << EnumToStringx(analysis_type) << " for time: " << time/yts << "\n"); 3112 3121 3113 3122 Analysis* analysis= EnumToAnalysis(analysis_type); … … 3121 3130 NodesDofx(nodes,parameters); 3122 3131 3123 } 3124 /*}}}*/ 3132 }/*}}}*/ 3125 3133 int FemModel::UpdateVertexPositionsx(void){ /*{{{*/ 3126 3134 … … 3211 3219 this->parameters->FindParam(&temp,FlowequationIsSSAEnum); iomodel->AddConstant(new IoConstant(temp,"md.flowequation.isSSA")); 3212 3220 this->parameters->FindParam(&temp,FlowequationIsL1L2Enum); iomodel->AddConstant(new IoConstant(temp,"md.flowequation.isL1L2")); 3213 this->parameters->FindParam(&temp,FlowequationIsM LHOEnum); iomodel->AddConstant(new IoConstant(temp,"md.flowequation.isMLHO"));3221 this->parameters->FindParam(&temp,FlowequationIsMOLHOEnum); iomodel->AddConstant(new IoConstant(temp,"md.flowequation.isMOLHO")); 3214 3222 this->parameters->FindParam(&temp,FlowequationIsHOEnum); iomodel->AddConstant(new IoConstant(temp,"md.flowequation.isHO")); 3215 3223 this->parameters->FindParam(&temp,FlowequationIsFSEnum); iomodel->AddConstant(new IoConstant(temp,"md.flowequation.isFS")); -
issm/trunk/src/c/classes/FemModel.h
r26744 r27035 83 83 void InitFromFids(char* rootpath, FILE* IOMODEL, FILE* toolkitsoptionsfid, int in_solution_type, bool trace, IssmPDouble* X=NULL); 84 84 void Marshall(MarshallHandle* marshallhandle); 85 void Restart( void);85 void Restart(int verboselevel=2); 86 86 void RestartAD(int step); 87 87 void SetCurrentConfiguration(int configuration_type); -
issm/trunk/src/c/classes/GrdLoads.cpp
r26744 r27035 68 68 69 69 } /*}}}*/ 70 void GrdLoads::SHDegree2Coefficients(IssmDouble* deg2coeff, FemModel* femmodel, SealevelGeometry* slgeom){ 71 72 IssmDouble area,re, S; 73 int ylmindex, intj; 74 IssmDouble deg2coeff_local[5]; 75 76 femmodel->parameters->FindParam(&re,SolidearthPlanetRadiusEnum); 77 78 for (int c=0;c<5;c++) deg2coeff_local[c]=0; 79 80 for(Object* & object : femmodel->elements->objects){ 81 Element* element = xDynamicCast<Element*>(object); 82 //first, loads on centroids 83 S=0; 84 S+=loads[element->Sid()]; 85 86 if(sealevelloads) S+=sealevelloads[element->Sid()]; 87 if(S!=0){ 88 element->Element::GetInputValue(&area,AreaEnum); 89 90 for (int c=0;c<5;c++){ //degree l=2 has 2*l+1=5 coefficients: 2,0; 2,1cos; 2,1sin; 2,2cos; 2,2sin 91 ylmindex=(4+c)*slgeom->localnel+element->lid; // starting at index=l^2 92 deg2coeff_local[c] += S*area/re/re*slgeom->Ylm[ylmindex]; 93 } 94 } 95 //add loads on subelement barycenters 96 for (int i=0;i<SLGEOM_NUMLOADS;i++){ 97 if (slgeom->issubelement[i][element->lid]){ 98 intj=slgeom->subelementmapping[i][element->lid]; 99 S=0; 100 S+=subloads[i][intj]; 101 if(i==SLGEOM_OCEAN && sealevelloads) S+=subsealevelloads[intj]; 102 if(S!=0){ 103 area=slgeom->area_subel[i][intj]; 104 for (int c=0;c<5;c++){ //degree l=2 has 2*l+1=5 coefficients 105 ylmindex=(4+c)*slgeom->localnel+element->lid; // starting at index=l^2 106 deg2coeff_local[c] += S*area/re/re*slgeom->Ylm_subel[i][ylmindex]; 107 } 108 } 109 } 110 } 111 } 112 113 //sum each degree 2 coefficient across all cpus to get global total 114 ISSM_MPI_Reduce (°2coeff_local[0],°2coeff[0],1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() ); 115 ISSM_MPI_Bcast(°2coeff[0],1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 116 ISSM_MPI_Reduce (°2coeff_local[1],°2coeff[1],1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() ); 117 ISSM_MPI_Bcast(°2coeff[1],1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 118 ISSM_MPI_Reduce (°2coeff_local[2],°2coeff[2],1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() ); 119 ISSM_MPI_Bcast(°2coeff[2],1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 120 121 } -
issm/trunk/src/c/classes/GrdLoads.h
r26744 r27035 29 29 void BroadcastLoads(void); 30 30 void BroadcastSealevelLoads(void); 31 void SHDegree2Coefficients(IssmDouble* deg2coeff, FemModel* femmodel, SealevelGeometry* slgeom); 31 32 }; 32 33 #endif /* _SEALEVELGRDLOADS_H_ */ -
issm/trunk/src/c/classes/Inputs/TransientInput.cpp
r26744 r27035 125 125 void TransientInput::Marshall(MarshallHandle* marshallhandle){ /*{{{*/ 126 126 127 bool isnull; 128 127 129 int object_enum = TransientInputEnum; 128 130 marshallhandle->call(object_enum); … … 149 151 if(marshallhandle->OperationNumber()!=MARSHALLING_LOAD){ 150 152 for(int i=0;i<this->numtimesteps;i++){ 151 _assert_(this->inputs[i]); 152 object_enum = this->inputs[i]->ObjectEnum(); 153 marshallhandle->call(object_enum); 154 this->inputs[i]->Marshall(marshallhandle); 153 154 //_assert_(this->inputs[i]); 155 isnull = false; 156 if(!this->inputs[i]) isnull = true; 157 marshallhandle->call(isnull); 158 159 if(!isnull){ 160 object_enum = this->inputs[i]->ObjectEnum(); 161 marshallhandle->call(object_enum); 162 this->inputs[i]->Marshall(marshallhandle); 163 } 155 164 } 156 165 } 157 166 else{ 158 167 for(int i=0;i<this->numtimesteps;i++){ 159 marshallhandle->call(object_enum); 160 161 if(object_enum==TriaInputEnum){ 162 TriaInput* triainput2=new TriaInput(); 163 triainput2->Marshall(marshallhandle); 164 this->inputs[i]=triainput2; 165 } 166 else if(object_enum==PentaInputEnum){ 167 PentaInput* pentainput2=new PentaInput(); 168 pentainput2->Marshall(marshallhandle); 169 this->inputs[i]=pentainput2; 170 } 171 else{ 172 _error_("input "<<EnumToStringx(object_enum)<<" not supported"); 168 marshallhandle->call(isnull); 169 if(!isnull){ 170 marshallhandle->call(object_enum); 171 172 if(object_enum==TriaInputEnum){ 173 TriaInput* triainput2=new TriaInput(); 174 triainput2->Marshall(marshallhandle); 175 this->inputs[i]=triainput2; 176 } 177 else if(object_enum==PentaInputEnum){ 178 PentaInput* pentainput2=new PentaInput(); 179 pentainput2->Marshall(marshallhandle); 180 this->inputs[i]=pentainput2; 181 } 182 else{ 183 _error_("input "<<EnumToStringx(object_enum)<<" not supported"); 184 } 173 185 } 174 186 } -
issm/trunk/src/c/classes/Loads/Channel.cpp
r26744 r27035 603 603 /*Initialize Element matrix and return if necessary*/ 604 604 Tria* tria=(Tria*)element; 605 if(!tria->IsIceInElement() || t his->boundary){605 if(!tria->IsIceInElement() || tria->IsAllFloating() || this->boundary){ 606 606 this->S = 0.; 607 607 return; -
issm/trunk/src/c/classes/Loads/Penpair.cpp
r26744 r27035 355 355 default: _error_("Approximation "<<EnumToStringx(approximation1)<<" not supported yet"); 356 356 } 357 case M LHOApproximationEnum:358 switch(approximation1){ 359 case M LHOApproximationEnum: return PenaltyCreateKMatrixStressbalanceSSAHO(kmax);357 case MOLHOApproximationEnum: 358 switch(approximation1){ 359 case MOLHOApproximationEnum: return PenaltyCreateKMatrixStressbalanceSSAHO(kmax); 360 360 default: _error_("Approximation "<<EnumToStringx(approximation1)<<" not supported yet"); 361 361 } -
issm/trunk/src/c/classes/Materials/Material.h
r26744 r27035 51 51 virtual void ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input)=0; 52 52 virtual void ViscosityHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input)=0; 53 virtual void ViscosityM LHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input)=0;54 virtual void ViscosityM LHOAdjoint(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input)=0;53 virtual void ViscosityMOLHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input)=0; 54 virtual void ViscosityMOLHOAdjoint(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input)=0; 55 55 virtual void ViscosityL1L2(IssmDouble* pviscosity,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* surf)=0; 56 56 virtual void ViscositySSA(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input)=0; -
issm/trunk/src/c/classes/Materials/Matestar.cpp
r26744 r27035 567 567 *pviscosity=GetViscosityGeneral(vx,vy,vz,&dvx[0],&dvy[0],&dvz[0],eps_eff,isdepthaveraged,gauss); 568 568 }/*}}}*/ 569 void Matestar::ViscosityM LHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input){/*{{{*/570 _error_("not implemented yet"); 571 }/*}}}*/ 572 void Matestar::ViscosityM LHOAdjoint(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input){/*{{{*/569 void Matestar::ViscosityMOLHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input){/*{{{*/ 570 _error_("not implemented yet"); 571 }/*}}}*/ 572 void Matestar::ViscosityMOLHOAdjoint(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input){/*{{{*/ 573 573 _error_("not implemented yet"); 574 574 }/*}}}*/ -
issm/trunk/src/c/classes/Materials/Matestar.h
r26744 r27035 76 76 void ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input); 77 77 void ViscosityHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 78 void ViscosityM LHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input);79 void ViscosityM LHOAdjoint(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input);78 void ViscosityMOLHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input); 79 void ViscosityMOLHOAdjoint(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input); 80 80 void ViscosityL1L2(IssmDouble* pviscosity,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* surf); 81 81 void ViscositySSA(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); -
issm/trunk/src/c/classes/Materials/Matice.cpp
r26744 r27035 394 394 } 395 395 else{ 396 397 /*if no strain rate, return maximum viscosity*/ 398 if(eps_eff==0.){ 399 viscosity = 1.e+14/2.; 400 //viscosity=2.5*pow(10.,17); 401 } 402 396 /*if strain rate is 0., it is probably our initial guess, use an average 397 * viscosity instead of a large one*/ 398 if(eps_eff==0.) viscosity = 1.e+14/2.; 403 399 else{ 400 /*if no strain rate, return maximum viscosity*/ 401 //if(eps_eff<1.e-6) eps_eff = 1e-6; 404 402 viscosity=(1.-D)*B/(2.*pow(E,1./n)*pow(eps_eff,(n-1.)/n)); 405 403 } … … 736 734 *pviscosity=viscosity; 737 735 }/*}}}*/ 738 void Matice::ViscosityM LHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vxbase_input,Input* vybase_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input){/*{{{*/736 void Matice::ViscosityMOLHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vxbase_input,Input* vybase_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input){/*{{{*/ 739 737 740 738 /*Intermediaries*/ … … 757 755 758 756 /* eps_eff^2 = exx^2 + eyy^2 + exy^2 + exz^2 + eyz^2 + exx*eyy (for a given zeta)*/ 759 element->StrainRateM LHO(&epsilon[0],xyz_list,gauss,757 element->StrainRateMOLHO(&epsilon[0],xyz_list,gauss, 760 758 vxbase_input,vybase_input,vxshear_input,vyshear_input,thickness_input,n_input,zeta); 761 759 epsilon_eff=sqrt(epsilon[0]*epsilon[0] + epsilon[1]*epsilon[1] + epsilon[2]*epsilon[2] … … 797 795 delete gauss_seg; 798 796 }/*}}}*/ 799 void Matice::ViscosityM LHOAdjoint(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vxbase_input,Input* vybase_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input){/*{{{*/797 void Matice::ViscosityMOLHOAdjoint(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vxbase_input,Input* vybase_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input){/*{{{*/ 800 798 801 799 /* To compute the additional 5 terms in the viscosity appear in the adjoint equation*/ … … 819 817 820 818 /* eps_eff^2 = exx^2 + eyy^2 + exy^2 + exz^2 + eyz^2 + exx*eyy (for a given zeta)*/ 821 element->StrainRateM LHO(&epsilon[0],xyz_list,gauss,819 element->StrainRateMOLHO(&epsilon[0],xyz_list,gauss, 822 820 vxbase_input,vybase_input,vxshear_input,vyshear_input,thickness_input,n_input,zeta); 823 821 epsilon_eff=sqrt(epsilon[0]*epsilon[0] + epsilon[1]*epsilon[1] + epsilon[2]*epsilon[2] -
issm/trunk/src/c/classes/Materials/Matice.h
r26744 r27035 78 78 void ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input); 79 79 void ViscosityHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); 80 void ViscosityM LHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input);81 void ViscosityM LHOAdjoint(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input);80 void ViscosityMOLHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input); 81 void ViscosityMOLHOAdjoint(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input); 82 82 void ViscosityL1L2(IssmDouble* pviscosity,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* surf); 83 83 void ViscositySSA(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input); -
issm/trunk/src/c/classes/Materials/Matlitho.h
r26744 r27035 72 72 void ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input){_error_("not supported");}; 73 73 void ViscosityHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){_error_("not supported");}; 74 void ViscosityM LHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input){_error_("not supported");};75 void ViscosityM LHOAdjoint(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input){_error_("not supported");};74 void ViscosityMOLHO(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input){_error_("not supported");}; 75 void ViscosityMOLHOAdjoint(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vxshear_input,Input* vyshear_input,Input* thickness_input,Input* n_input){_error_("not supported");}; 76 76 void ViscosityL1L2(IssmDouble* pviscosity,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* surf){_error_("not supported");}; 77 77 void ViscositySSA(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input){_error_("not supported");}; -
issm/trunk/src/c/classes/Node.cpp
r26744 r27035 118 118 this->HardDeactivate(); 119 119 } 120 if(in_approximation==M LHOApproximationEnum && !reCast<int>(iomodel->Data("md.mesh.vertexonbase")[io_index])){120 if(in_approximation==MOLHOApproximationEnum && !reCast<int>(iomodel->Data("md.mesh.vertexonbase")[io_index])){ 121 121 this->HardDeactivate(); 122 122 } -
issm/trunk/src/c/classes/Radar.h
r26744 r27035 11 11 12 12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum); 13 void GetVectorFromInputsx( IssmDouble** pvector, int* pvector_size, FemModel* femmodel,int name);14 13 15 14 class Radar: public Object, public Definition{ -
issm/trunk/src/c/classes/SealevelGeometry.cpp
r26744 r27035 35 35 nsubel[i]=0; 36 36 nbar[i]=0; 37 Ylm_subel[i]= xNewZeroInit<IssmDouble>(localnel*9); 37 38 } 38 39 late=xNew<IssmDouble>(localnel); … … 40 41 isoceanin=xNew<bool>(localnel); 41 42 lids=xNew<int>(localnodsin); 43 Ylm=xNewZeroInit<IssmDouble>(localnel*9); // (degmax+1)^2 terms, degmax=2 42 44 43 45 }; /*}}}*/ … … 56 58 xDelete<IssmDouble>(longbarycentre[i]); 57 59 xDelete<IssmDouble>(area_subel[i]); 58 } 60 xDelete<IssmDouble>(Ylm_subel[i]); 61 } 62 xDelete<IssmDouble>(Ylm); 59 63 xDelete<IssmDouble>(late); 60 64 xDelete<IssmDouble>(longe); … … 71 75 for (int i=0;i<SLGEOM_NUMLOADS;i++){ 72 76 subelementmapping[i]=xNew<int>(localnel); 77 #ifdef _HAVE_PETSC_ 73 78 GetOwnershipBoundariesFromRange(&lower_row,&dummy,nsubel[i],IssmComm::GetComm()); 79 #else 80 _error_("not supported without PETSc compiled"); 81 #endif 74 82 75 83 int count=0; … … 155 163 156 164 } /*}}}*/ 165 void SealevelGeometry::BuildSphericalHarmonics(){ /*{{{*/ 166 //builds spherical harmonics functions for degrees 0, 1, 2 on centroids/barycenters 167 //0: used for global average 168 //1: used for geocenter motion 169 //2: used for rotational feedback 170 int intj, count; 171 172 IssmDouble YlmNorm[9]; 173 174 //YlmNormalization: N^2=(2*l+1)/4/pi * factorial(l-m)/factorial(l+m) if m==0 175 // : 2*N^2 if m>0 176 // such that integral(Ylm * Ylm *YlmNorm dS) = 1 on the unit sphere. 177 YlmNorm[0]=(0.25/M_PI); //Y00 178 YlmNorm[1]=(0.75/M_PI); //Y10 179 YlmNorm[2]=(0.75/M_PI); //Y11c 180 YlmNorm[3]=YlmNorm[2]; //Y11s 181 YlmNorm[4]=(1.25/M_PI); //Y20 182 YlmNorm[5]=(1.25/3./M_PI); //Y21c 183 YlmNorm[6]=YlmNorm[5]; //Y21s 184 YlmNorm[7]=(1.25/12./M_PI); //Y22c 185 YlmNorm[8]=YlmNorm[7]; //Y22s 186 187 for (int e=0;e<localnel;e++){ 188 IssmDouble lat=late[e]*M_PI/180.; 189 IssmDouble lon=longe[e]*M_PI/180.; 190 Ylm[0*localnel+e] = 1.0 *YlmNorm[0]; //Y00 191 192 Ylm[1*localnel+e] = sin(lat)*YlmNorm[1]; //Y10 193 Ylm[2*localnel+e] = cos(lat)*cos(lon)*YlmNorm[2]; //Y11cos 194 Ylm[3*localnel+e] = cos(lat)*sin(lon)*YlmNorm[3]; //Y11sin 195 196 //Ylm[4*localnel+e] = 0.25 - 0.75*cos(2.0*lat) ; //Y20 197 Ylm[4*localnel+e] = (1.5*pow(sin(lat),2.)-0.5)*YlmNorm[4]; //Y20 198 Ylm[5*localnel+e] = 1.5*sin(2.*lat)*cos(lon)*YlmNorm[5]; //Y21cos 199 Ylm[6*localnel+e] = 1.5*sin(2.*lat)*sin(lon)*YlmNorm[6]; //Y21sin 200 Ylm[7*localnel+e] = 1.5*(1.+cos(2.*lat))*cos(2.*lon)*YlmNorm[7]; //Y22cos 201 Ylm[8*localnel+e] = 1.5*(1.+cos(2.*lat))*sin(2.*lon)*YlmNorm[8]; //Y22sin 202 } 203 204 for (int i=0;i<SLGEOM_NUMLOADS;i++){ 205 for (int e=0;e<localnel;e++){ 206 if (issubelement[i][e]){ 207 intj=subelementmapping[i][e]; 208 IssmDouble lat=latbarycentre[i][intj]*M_PI/180.; 209 IssmDouble lon=longbarycentre[i][intj]*M_PI/180.; 210 Ylm_subel[i][0*localnel+e] = 1.0*YlmNorm[0]; //Y00 211 212 Ylm_subel[i][1*localnel+e] = sin(lat)*YlmNorm[1]; //Y10 213 Ylm_subel[i][2*localnel+e] = cos(lat)*cos(lon)*YlmNorm[2]; //Y11cos 214 Ylm_subel[i][3*localnel+e] = cos(lat)*sin(lon)*YlmNorm[3]; //Y11sin 215 216 Ylm_subel[i][4*localnel+e] = (1.5*pow(sin(lat),2.)-0.5)*YlmNorm[4]; //Y20 217 Ylm_subel[i][5*localnel+e] = 1.5*sin(2.*lat)*cos(lon)*YlmNorm[5]; //Y21cos 218 Ylm_subel[i][6*localnel+e] = 1.5*sin(2.*lat)*sin(lon)*YlmNorm[6]; //Y21sin 219 Ylm_subel[i][7*localnel+e] = 1.5*(1.+cos(2.*lat))*cos(2.*lon)*YlmNorm[7]; //Y22cos 220 Ylm_subel[i][8*localnel+e] = 1.5*(1.+cos(2.*lat))*sin(2.*lon)*YlmNorm[8]; //Y22sin 221 } 222 } 223 } 224 } /*}}}*/ -
issm/trunk/src/c/classes/SealevelGeometry.h
r26744 r27035 14 14 15 15 #include "../toolkits/toolkits.h" 16 #include "../classes/classes.h" 16 17 17 18 class SealevelGeometry{ … … 30 31 IssmDouble* late; 31 32 IssmDouble* longe; 33 IssmDouble* Ylm; 34 IssmDouble* Ylm_subel[SLGEOM_NUMLOADS]; 35 IssmDouble* YlmNorm[9]; 32 36 bool* isoceanin; 33 37 bool* issubelement[SLGEOM_NUMLOADS]; … … 45 49 int GNEnum(int l); 46 50 int GEEnum(int l); 51 void BuildSphericalHarmonics(void); 47 52 }; 48 53 #endif /* _SEALEVELGEOMETRY_H_ */ -
issm/trunk/src/c/classes/matrix/ElementMatrix.cpp
r26744 r27035 260 260 _printf_(" sglobaldoflist (" << sglobaldoflist << "): "); 261 261 for(i=0;i<nrows;i++)_printf_(" " << sglobaldoflist[i]); _printf_(" \n"); 262 } 263 /*}}}*/ 264 bool ElementMatrix::HasDof(int dof,int set){/*{{{*/ 265 266 if(set==FsetEnum){ 267 for(int i=0;i<this->nrows;i++) if(this->fglobaldoflist[i] == dof) return true; 268 } 269 else if(set==GsetEnum){ 270 for(int i=0;i<this->nrows;i++) if(this->gglobaldoflist[i] == dof) return true; 271 } 272 else if(set==SsetEnum){ 273 for(int i=0;i<this->nrows;i++) if(this->sglobaldoflist[i] == dof) return true; 274 } 275 else{ 276 _error_("not supported yet"); 277 } 278 279 return false; 262 280 } 263 281 /*}}}*/ -
issm/trunk/src/c/classes/matrix/ElementMatrix.h
r26744 r27035 46 46 void StaticCondensation(int numindices,int* indices); 47 47 void Transpose(void); 48 bool HasDof(int dof,int set); 48 49 }; 49 50 #endif //#ifndef _ELEMENT_MATRIX_H_ -
issm/trunk/src/c/cores/ProcessArguments.cpp
r25836 r27035 29 29 30 30 /*Create all file paths*/ 31 char* binfilename = xNew<char>(strlen(rootpath)+strlen(modelname)+strlen(".bin") +1); sprintf(binfilename, "%s%s%s",rootpath,modelname,".bin"); 32 char* outbinfilename = xNew<char>(strlen(rootpath)+strlen(modelname)+strlen(".outbin") +1); sprintf(outbinfilename,"%s%s%s",rootpath,modelname,".outbin"); 33 char* toolkitsfilename = xNew<char>(strlen(rootpath)+strlen(modelname)+strlen(".toolkits") +1); sprintf(toolkitsfilename,"%s%s%s",rootpath,modelname,".toolkits"); 34 char* lockfilename = xNew<char>(strlen(rootpath)+strlen(modelname)+strlen(".lock") +1); sprintf(lockfilename, "%s%s%s",rootpath,modelname,".lock"); 35 char* restartfilename = xNew<char>(strlen(rootpath)+strlen(modelname)+strlen(".rst.")+rank_length+1); 36 sprintf(restartfilename,"%s%s%s%i",rootpath,modelname,".rst.",my_rank); 31 int base_length = strlen(rootpath)+strlen(modelname); 32 char* binfilename = xNew<char>(base_length+strlen(".bin") +1); sprintf(binfilename, "%s%s%s",rootpath,modelname,".bin"); 33 char* outbinfilename = xNew<char>(base_length+strlen(".outbin") +1); sprintf(outbinfilename,"%s%s%s",rootpath,modelname,".outbin"); 34 char* toolkitsfilename = xNew<char>(base_length+strlen(".toolkits")+1); sprintf(toolkitsfilename,"%s%s%s",rootpath,modelname,".toolkits"); 35 char* lockfilename = xNew<char>(base_length+strlen(".lock") +1); sprintf(lockfilename, "%s%s%s",rootpath,modelname,".lock"); 36 char* restartfilename = xNew<char>(base_length+strlen("_rank")+rank_length+strlen(".rst")+1); 37 sprintf(restartfilename,"%s%s%s%i%s",rootpath,modelname,"_rank",my_rank,".rst"); 37 38 38 39 /*Clean up and assign output pointer*/ … … 44 45 *prootpath=rootpath; 45 46 *pmodelname=modelname; 46 47 47 } -
issm/trunk/src/c/cores/bmb_core.cpp
r24313 r27035 36 36 FloatingiceMeltingRatex(femmodel); 37 37 38 /*Extrude basal melt*/ 39 femmodel->parameters->SetParam(BasalforcingsFloatingiceMeltingRateEnum,InputToExtrudeEnum); 40 extrudefrombase_core(femmodel); 38 /*Extrude basal melt if not default melting rate (which may be a transient input that can't be extruded)*/ 39 if(basalforcing_model!=FloatingMeltRateEnum){ 40 femmodel->parameters->SetParam(BasalforcingsFloatingiceMeltingRateEnum,InputToExtrudeEnum); 41 extrudefrombase_core(femmodel); 42 } 41 43 } -
issm/trunk/src/c/cores/controladm1qn3_core.cpp
r26744 r27035 15 15 #include <sstream> // for output of the CoDiPack tape 16 16 #include <fenv.h> 17 void transient_ad(FemModel* femmodel);17 double transient_ad(FemModel* femmodel, double* G,double* Jlist); 18 18 #endif 19 19 … … 222 222 int *N = NULL; 223 223 int *control_enum = NULL; 224 int checkpoint_frequency; 224 225 femmodel->parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum); 225 226 femmodel->parameters->FindParam(&num_controls,InversionNumControlParametersEnum); … … 228 229 femmodel->parameters->FindParam(&M,NULL,ControlInputSizeMEnum); 229 230 femmodel->parameters->FindParam(&control_enum,NULL,InversionControlParametersEnum); 231 femmodel->parameters->FindParam(&checkpoint_frequency,SettingsCheckpointFrequencyEnum); 230 232 231 233 /*Constrain input vector and update controls*/ … … 236 238 237 239 int offset = 0; 238 for 240 for(int c=0;c<num_controls;c++){ 239 241 for(int i=0;i<M[c]*N[c];i++){ 240 242 int index = offset+i; … … 246 248 } 247 249 248 /*Start Tracing*/ 249 simul_starttrace(femmodel); 250 /*Set X as our new control input and as INDEPENDENT*/ 250 /*Special case: do we need to run AD with checkpointing?*/ 251 #ifdef _HAVE_CODIPACK_ 252 if(checkpoint_frequency && solution_type == TransientSolutionEnum){ 253 SetControlInputsFromVectorx(femmodel,X); 254 *pf = transient_ad(femmodel, G, &Jlist[(*Jlisti)*JlistN]); 255 } 256 else 257 #endif 258 { 259 260 /*Start Tracing*/ 261 simul_starttrace(femmodel); 262 /*Set X as our new control input and as INDEPENDENT*/ 251 263 #ifdef _HAVE_AD_ 252 IssmDouble* aX=xNew<IssmDouble>(intn,"t");264 IssmDouble* aX=xNew<IssmDouble>(intn,"t"); 253 265 #else 254 IssmDouble* aX=xNew<IssmDouble>(intn);266 IssmDouble* aX=xNew<IssmDouble>(intn); 255 267 #endif 256 268 257 #if defined(_HAVE_ADOLC_) 258 if(my_rank==0){ 259 for(int i=0;i<intn;i++){ 260 aX[i]<<=X[i]; 261 } 262 } 263 #elif defined(_HAVE_CODIPACK_) 264 265 /*Get tape*/ 266 #if _CODIPACK_MAJOR_==2 267 auto& tape_codi = IssmDouble::getTape(); 268 #elif _CODIPACK_MAJOR_==1 269 auto& tape_codi = IssmDouble::getGlobalTape(); 270 #else 271 #error "_CODIPACK_MAJOR_ not supported" 272 #endif 273 274 codi_global.input_indices.clear(); 275 if(my_rank==0){ 276 for (int i=0;i<intn;i++) { 277 aX[i]=X[i]; 278 tape_codi.registerInput(aX[i]); 279 #if _CODIPACK_MAJOR_==2 280 codi_global.input_indices.push_back(aX[i].getIdentifier()); 281 #elif _CODIPACK_MAJOR_==1 282 codi_global.input_indices.push_back(aX[i].getGradientData()); 283 #else 284 #error "_CODIPACK_MAJOR_ not supported" 285 #endif 286 287 } 288 } 289 #else 290 _error_("not suppoted"); 291 #endif 292 293 ISSM_MPI_Bcast(aX,intn,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 294 SetControlInputsFromVectorx(femmodel,aX); 295 xDelete<IssmDouble>(aX); 296 297 /*Compute solution (forward)*/ 298 void (*solutioncore)(FemModel*)=NULL; 299 CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type); 300 solutioncore(femmodel); 301 302 /*Get Dependents*/ 303 IssmDouble output_value; 304 int num_dependents; 305 IssmPDouble *dependents; 306 IssmDouble J = 0.; 307 DataSet *dependent_objects = ((DataSetParam*)femmodel->parameters->FindParamObject(AutodiffDependentObjectsEnum))->value; 308 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 309 310 /*Go through our dependent variables, and compute the response:*/ 311 dependents=xNew<IssmPDouble>(num_dependents); 312 #if defined(_HAVE_CODIPACK_) 313 codi_global.output_indices.clear(); 314 #endif 315 int i=-1; 316 for(Object* & object:dependent_objects->objects){ 317 i++; 318 DependentObject* dep=xDynamicCast<DependentObject*>(object); 319 if(solution_type==TransientSolutionEnum) output_value = dep->GetValue(); 320 if(solution_type!=TransientSolutionEnum) dep->Responsex(&output_value,femmodel); 321 if(my_rank==0) { 269 #if defined(_HAVE_ADOLC_) 270 if(my_rank==0){ 271 for(int i=0;i<intn;i++){ 272 aX[i]<<=X[i]; 273 } 274 } 275 #elif defined(_HAVE_CODIPACK_) 276 277 /*Get tape*/ 278 #if _CODIPACK_MAJOR_==2 279 auto& tape_codi = IssmDouble::getTape(); 280 #elif _CODIPACK_MAJOR_==1 281 auto& tape_codi = IssmDouble::getGlobalTape(); 282 #else 283 #error "_CODIPACK_MAJOR_ not supported" 284 #endif 285 286 codi_global.input_indices.clear(); 287 if(my_rank==0){ 288 for (int i=0;i<intn;i++) { 289 aX[i]=X[i]; 290 tape_codi.registerInput(aX[i]); 291 #if _CODIPACK_MAJOR_==2 292 codi_global.input_indices.push_back(aX[i].getIdentifier()); 293 #elif _CODIPACK_MAJOR_==1 294 codi_global.input_indices.push_back(aX[i].getGradientData()); 295 #else 296 #error "_CODIPACK_MAJOR_ not supported" 297 #endif 298 299 } 300 } 301 #else 302 _error_("not suppoted"); 303 #endif 304 305 ISSM_MPI_Bcast(aX,intn,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 306 SetControlInputsFromVectorx(femmodel,aX); 307 xDelete<IssmDouble>(aX); 308 309 /*Compute solution (forward)*/ 310 void (*solutioncore)(FemModel*)=NULL; 311 CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type); 312 solutioncore(femmodel); 313 314 /*Get Dependents*/ 315 IssmDouble output_value; 316 int num_dependents; 317 IssmPDouble *dependents; 318 IssmDouble J = 0.; 319 DataSet *dependent_objects = ((DataSetParam*)femmodel->parameters->FindParamObject(AutodiffDependentObjectsEnum))->value; 320 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 321 322 /*Go through our dependent variables, and compute the response:*/ 323 dependents=xNew<IssmPDouble>(num_dependents); 324 #if defined(_HAVE_CODIPACK_) 325 codi_global.output_indices.clear(); 326 #endif 327 int i=-1; 328 for(Object* & object:dependent_objects->objects){ 329 i++; 330 DependentObject* dep=xDynamicCast<DependentObject*>(object); 331 if(solution_type==TransientSolutionEnum) output_value = dep->GetValue(); 332 if(solution_type!=TransientSolutionEnum) dep->Responsex(&output_value,femmodel); 322 333 323 334 #if defined(_HAVE_CODIPACK_) … … 340 351 J+=output_value; 341 352 } 342 } 343 344 /*Turning off trace tape*/ 345 simul_stoptrace(); 346 347 /*intermediary: */ 348 int num_independents=intn; 349 IssmPDouble *aWeightVector=NULL; 350 IssmPDouble *weightVectorTimesJac=NULL; 351 IssmPDouble *totalgradient=xNewZeroInit<IssmPDouble>(num_independents); 352 353 /*if no dependents, no point in running a driver: */ 354 if(!(num_dependents*num_independents)) _error_("this is not allowed"); 355 356 /*for adolc to run in parallel, we 0 out on rank~=0. But we still keep track of num_dependents:*/ 357 int num_dependents_old = num_dependents; 358 int num_independents_old = num_independents; 359 360 #if defined(_HAVE_ADOLC_) 361 /*Get gradient for ADOLC {{{*/ 362 if(my_rank!=0){ 363 num_dependents = 0; 364 num_independents = 0; 365 } 366 367 /*get the EDF pointer:*/ 368 ext_diff_fct *anEDF_for_solverx_p=xDynamicCast<GenericParam<Adolc_edf> * >(femmodel->parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p; 369 370 /* these are always needed regardless of the interpreter */ 371 anEDF_for_solverx_p->dp_x=xNew<double>(anEDF_for_solverx_p->max_n); 372 anEDF_for_solverx_p->dp_y=xNew<double>(anEDF_for_solverx_p->max_m); 373 374 /* Ok, now we are going to call the fos_reverse in a loop on the index, from 0 to num_dependents, so 375 * as to generate num_dependents gradients: */ 376 for(int aDepIndex=0;aDepIndex<num_dependents_old;aDepIndex++){ 377 378 /*initialize direction index in the weights vector: */ 379 aWeightVector=xNewZeroInit<IssmPDouble>(num_dependents); 380 if (my_rank==0) aWeightVector[aDepIndex]=1.; 381 382 /*initialize output gradient: */ 383 weightVectorTimesJac=xNew<IssmPDouble>(num_independents); 384 385 /*set the forward method function pointer: */ 386 #ifdef _HAVE_GSL_ 387 anEDF_for_solverx_p->fos_reverse=EDF_fos_reverse_for_solverx; 388 #endif 389 #ifdef _HAVE_MUMPS_ 390 anEDF_for_solverx_p->fos_reverse_iArr=fos_reverse_mumpsSolveEDF; 391 #endif 392 393 anEDF_for_solverx_p->dp_U=xNew<IssmPDouble>(anEDF_for_solverx_p->max_m); 394 anEDF_for_solverx_p->dp_Z=xNew<IssmPDouble>(anEDF_for_solverx_p->max_n); 395 396 /*call driver: */ 397 fos_reverse(my_rank,num_dependents,num_independents, aWeightVector, weightVectorTimesJac ); 398 399 /*Add to totalgradient: */ 400 if(my_rank==0) for(int i=0;i<num_independents;i++) { 401 totalgradient[i]+=weightVectorTimesJac[i]; 402 } 403 404 /*free resources :*/ 405 xDelete(weightVectorTimesJac); 406 xDelete(aWeightVector); 407 } 408 /*}}}*/ 409 #elif defined(_HAVE_CODIPACK_) 410 /*Get gradient for CoDiPack{{{*/ 411 if(VerboseAutodiff())_printf0_(" CoDiPack fos_reverse\n"); 412 413 /* call the fos_reverse in a loop on the index, from 0 to num_dependents, so 414 * as to generate num_dependents gradients: */ 415 for(int dep_index=0;dep_index<num_dependents_old;dep_index++){ 416 417 /*initialize direction index in the weights vector: */ 418 if(my_rank==0){ 419 if(dep_index<0 || dep_index>=num_dependents || codi_global.output_indices.size() <= dep_index){ 420 _error_("index value for dependent index should be in [0,num_dependents-1]"); 353 354 /*Turning off trace tape*/ 355 simul_stoptrace(); 356 357 /*intermediary: */ 358 int num_independents=intn; 359 IssmPDouble *aWeightVector=NULL; 360 IssmPDouble *weightVectorTimesJac=NULL; 361 IssmPDouble *totalgradient=xNewZeroInit<IssmPDouble>(num_independents); 362 363 /*if no dependents, no point in running a driver: */ 364 if(!(num_dependents*num_independents)) _error_("this is not allowed"); 365 366 /*for adolc to run in parallel, we 0 out on rank~=0. But we still keep track of num_dependents:*/ 367 int num_dependents_old = num_dependents; 368 int num_independents_old = num_independents; 369 370 #if defined(_HAVE_ADOLC_) 371 /*Get gradient for ADOLC {{{*/ 372 if(my_rank!=0){ 373 num_dependents = 0; 374 num_independents = 0; 375 } 376 377 /*get the EDF pointer:*/ 378 ext_diff_fct *anEDF_for_solverx_p=xDynamicCast<GenericParam<Adolc_edf> * >(femmodel->parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p; 379 380 /* these are always needed regardless of the interpreter */ 381 anEDF_for_solverx_p->dp_x=xNew<double>(anEDF_for_solverx_p->max_n); 382 anEDF_for_solverx_p->dp_y=xNew<double>(anEDF_for_solverx_p->max_m); 383 384 /* Ok, now we are going to call the fos_reverse in a loop on the index, from 0 to num_dependents, so 385 * as to generate num_dependents gradients: */ 386 for(int aDepIndex=0;aDepIndex<num_dependents_old;aDepIndex++){ 387 388 /*initialize direction index in the weights vector: */ 389 aWeightVector=xNewZeroInit<IssmPDouble>(num_dependents); 390 if (my_rank==0) aWeightVector[aDepIndex]=1.; 391 392 /*initialize output gradient: */ 393 weightVectorTimesJac=xNew<IssmPDouble>(num_independents); 394 395 /*set the forward method function pointer: */ 396 #ifdef _HAVE_GSL_ 397 anEDF_for_solverx_p->fos_reverse=EDF_fos_reverse_for_solverx; 398 #endif 399 #ifdef _HAVE_MUMPS_ 400 anEDF_for_solverx_p->fos_reverse_iArr=fos_reverse_mumpsSolveEDF; 401 #endif 402 403 anEDF_for_solverx_p->dp_U=xNew<IssmPDouble>(anEDF_for_solverx_p->max_m); 404 anEDF_for_solverx_p->dp_Z=xNew<IssmPDouble>(anEDF_for_solverx_p->max_n); 405 406 /*call driver: */ 407 fos_reverse(my_rank,num_dependents,num_independents, aWeightVector, weightVectorTimesJac ); 408 409 /*Add to totalgradient: */ 410 if(my_rank==0) for(int i=0;i<num_independents;i++) { 411 totalgradient[i]+=weightVectorTimesJac[i]; 421 412 } 422 tape_codi.setGradient(codi_global.output_indices[dep_index],1.0); 423 } 424 //feclearexcept(FE_ALL_EXCEPT); 425 //feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); 426 tape_codi.evaluate(); 427 428 /*Get gradient for this dependent */ 429 weightVectorTimesJac=xNew<IssmPDouble>(num_independents); 430 auto in_size = codi_global.input_indices.size(); 431 for(size_t i = 0; i < in_size; ++i){ 432 _assert_(i<num_independents); 433 weightVectorTimesJac[i] = tape_codi.getGradient(codi_global.input_indices[i]); 434 } 435 if(my_rank==0) for(int i=0;i<num_independents;i++){ 436 totalgradient[i]+=weightVectorTimesJac[i]; 437 } 438 xDelete(weightVectorTimesJac); 439 } 440 441 /*Clear tape*/ 442 tape_codi.reset(); 443 /*}}}*/ 444 #else 445 _error_("not suppoted"); 446 #endif 447 448 /*Broadcast gradient to other ranks*/ 449 ISSM_MPI_Bcast(totalgradient,num_independents_old,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 450 /*Check size of Jlist to avoid crashes*/ 451 _assert_((*Jlisti)<JlistM); 452 _assert_(JlistN==num_responses+1); 453 454 /*Compute objective function and broadcast it to other cpus*/ 455 *pf = reCast<double>(J); 456 ISSM_MPI_Bcast(pf,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 457 _printf0_("f(x) = "<<setw(12)<<setprecision(7)<<*pf<<" | "); 458 459 /*Record cost function values and delete Jtemp*/ 460 for(int i=0;i<num_responses;i++) Jlist[(*Jlisti)*JlistN+i] = dependents[i]; 461 Jlist[(*Jlisti)*JlistN+num_responses] = reCast<IssmPDouble>(J); 462 463 if(*indic==0){ 464 /*dry run, no gradient required*/ 465 466 /*Retrieve objective functions independently*/ 467 _printf0_(" N/A |\n"); 468 for(int i=0;i<num_responses;i++) _printf0_(" "<<setw(12)<<setprecision(7)<<Jlist[(*Jlisti)*JlistN+i]); 469 _printf0_("\n"); 470 471 *Jlisti = (*Jlisti) +1; 472 xDelete<double>(XU); 473 xDelete<double>(XL); 474 return; 475 } 476 477 /*Compute gradient*/ 478 for(long i=0;i<num_independents_old;i++) G[i] = totalgradient[i]; 413 414 /*free resources :*/ 415 xDelete(weightVectorTimesJac); 416 xDelete(aWeightVector); 417 } 418 /*}}}*/ 419 #elif defined(_HAVE_CODIPACK_) 420 /*Get gradient for CoDiPack{{{*/ 421 if(VerboseAutodiff())_printf0_(" CoDiPack fos_reverse\n"); 422 423 /* call the fos_reverse in a loop on the index, from 0 to num_dependents, so 424 * as to generate num_dependents gradients: */ 425 for(int dep_index=0;dep_index<num_dependents_old;dep_index++){ 426 427 /*initialize direction index in the weights vector: */ 428 if(my_rank==0){ 429 if(dep_index<0 || dep_index>=num_dependents || codi_global.output_indices.size() <= dep_index){ 430 _error_("index value for dependent index should be in [0,num_dependents-1]"); 431 } 432 tape_codi.setGradient(codi_global.output_indices[dep_index],1.0); 433 } 434 //feclearexcept(FE_ALL_EXCEPT); 435 //feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); 436 tape_codi.evaluate(); 437 438 /*Get gradient for this dependent */ 439 weightVectorTimesJac=xNew<IssmPDouble>(num_independents); 440 auto in_size = codi_global.input_indices.size(); 441 for(size_t i = 0; i < in_size; ++i){ 442 _assert_(i<num_independents); 443 weightVectorTimesJac[i] = tape_codi.getGradient(codi_global.input_indices[i]); 444 } 445 if(my_rank==0) for(int i=0;i<num_independents;i++){ 446 totalgradient[i]+=weightVectorTimesJac[i]; 447 } 448 xDelete(weightVectorTimesJac); 449 } 450 451 /*Clear tape*/ 452 tape_codi.reset(); 453 /*}}}*/ 454 #else 455 _error_("not suppoted"); 456 #endif 457 458 /*Broadcast gradient to other ranks*/ 459 ISSM_MPI_Bcast(totalgradient,num_independents_old,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 460 461 /*Check size of Jlist to avoid crashes*/ 462 _assert_((*Jlisti)<JlistM); 463 _assert_(JlistN==num_responses+1); 464 465 /*Compute objective function and broadcast it to other cpus*/ 466 *pf = reCast<double>(J); 467 ISSM_MPI_Bcast(pf,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 468 469 /*Record cost function values and delete Jtemp*/ 470 for(int i=0;i<num_responses;i++) Jlist[(*Jlisti)*JlistN+i] = dependents[i]; 471 Jlist[(*Jlisti)*JlistN+num_responses] = reCast<IssmPDouble>(J); 472 473 if(*indic==0){ 474 /*dry run, no gradient required*/ 475 476 /*Retrieve objective functions independently*/ 477 _printf0_("f(x) = "<<setw(12)<<setprecision(7)<<*pf<<" | "); 478 _printf0_(" N/A |\n"); 479 for(int i=0;i<num_responses;i++) _printf0_(" "<<setw(12)<<setprecision(7)<<Jlist[(*Jlisti)*JlistN+i]); 480 _printf0_("\n"); 481 482 *Jlisti = (*Jlisti) +1; 483 xDelete<double>(XU); 484 xDelete<double>(XL); 485 return; 486 } 487 488 /*Compute gradient*/ 489 for(long i=0;i<num_independents_old;i++) G[i] = totalgradient[i]; 490 491 xDelete<IssmPDouble>(dependents); 492 xDelete<IssmPDouble>(totalgradient); 493 } /*====????*/ 479 494 480 495 /*Constrain Gradient*/ … … 496 511 497 512 /*Print info*/ 513 _printf0_("f(x) = "<<setw(12)<<setprecision(7)<<*pf<<" | "); 498 514 _printf0_(" "<<setw(12)<<setprecision(7)<<Gnorm<<" |"); 499 515 for(int i=0;i<num_responses;i++) _printf0_(" "<<setw(12)<<setprecision(7)<<Jlist[(*Jlisti)*JlistN+i]); … … 509 525 xDelete<int>(N); 510 526 xDelete<double>(scaling_factors); 511 xDelete<IssmPDouble>(dependents);512 xDelete<IssmPDouble>(totalgradient);513 527 }/*}}}*/ 514 528 void controladm1qn3_core(FemModel* femmodel){/*{{{*/ 515 529 516 int checkpoint_frequency;517 femmodel->parameters->FindParam(&checkpoint_frequency,SettingsCheckpointFrequencyEnum);518 if(checkpoint_frequency){519 #ifdef _HAVE_CODIPACK_520 transient_ad(femmodel);521 femmodel->OutputControlsx(&femmodel->results);522 printf("No optimization implemented yet, skipping\n");523 return;524 #else525 _error_("checkpointing not implemented for ADOLC");526 #endif527 }528 530 529 531 /*Intermediaries*/ -
issm/trunk/src/c/cores/controltao_core.cpp
r25836 r27035 95 95 GetVectorFromControlInputsx(&XL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound"); 96 96 GetVectorFromControlInputsx(&XU,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound"); 97 #if PETSC_VERSION_LT(3,17,0) 97 98 TaoSetInitialVector(tao,X->pvector->vector); 99 #else 100 //TaoSetSolution(tao,X->pvector->vector); 101 _error_("not implemented yet"); 102 #endif 98 103 TaoSetVariableBounds(tao,XL->pvector->vector,XU->pvector->vector); 99 104 delete XL; … … 110 115 111 116 /*Save results*/ 117 #if PETSC_VERSION_LT(3,17,0) 112 118 TaoGetSolutionVector(tao,&X->pvector->vector); 119 #else 120 TaoGetSolution(tao,&X->pvector->vector); 121 #endif 113 122 G=new Vector<IssmDouble>(0); VecFree(&G->pvector->vector); 123 #if PETSC_VERSION_LT(3,17,0) 114 124 TaoGetGradientVector(tao,&G->pvector->vector); 125 #else 126 //TaoGetGradient(tao,&G->pvector->vector); 127 _error_("not implemented yet"); 128 #endif 115 129 SetControlInputsFromVectorx(femmodel,X); 116 130 ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,G); -
issm/trunk/src/c/cores/groundingline_core.cpp
r25836 r27035 16 16 17 17 /* intermediaries */ 18 int numoutputs; 18 19 bool save_results; 20 char** requested_outputs = NULL; 19 21 20 22 /* recover parameters */ 21 23 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); 24 femmodel->parameters->FindParam(&numoutputs,GroundinglineNumRequestedOutputsEnum); 25 if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,GroundinglineRequestedOutputsEnum); 22 26 23 27 /*Move grounding line*/ … … 33 37 extrudefrombase_core(femmodel); 34 38 35 if(save_results){ 36 int outputs[3] = {SurfaceEnum,BaseEnum,MaskOceanLevelsetEnum}; 37 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],3); 38 } 39 /*Save results*/ 40 if(save_results) femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs); 41 42 /*Free ressources:*/ 43 if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);} 39 44 40 45 /*Stop profiler*/ -
issm/trunk/src/c/cores/love_core.cpp
r26744 r27035 10 10 #include "../solutionsequences/solutionsequences.h" 11 11 #include "petscblaslapack.h" 12 #ifdef _HAVE_MPLAPACK_ 13 #include <quadmath.h> 14 #include "mpblas__Float128.h" 15 #include "mplapack__Float128.h" 16 #endif 17 18 #ifdef _HAVE_MPLAPACK_ 19 _Float128 a = 0.2345234534512079875620048770134538q; 20 #endif 12 21 13 22 /*local definitions:*/ … … 20 29 int nyi; 21 30 int starting_layer; 31 int* deg_layer_delete; 22 32 23 33 LoveVariables(){ /*{{{*/ … … 27 37 nyi=0; 28 38 starting_layer=0; 39 deg_layer_delete=NULL; 29 40 } /*}}}*/ 30 LoveVariables(IssmDouble* EarthMassin,IssmDouble g0in,IssmDouble r0in,int nyiin,int starting_layerin ){ /*{{{*/41 LoveVariables(IssmDouble* EarthMassin,IssmDouble g0in,IssmDouble r0in,int nyiin,int starting_layerin, int* deg_layer_deletein){ /*{{{*/ 31 42 EarthMass=EarthMassin; 32 43 g0=g0in; … … 34 45 nyi=nyiin; 35 46 starting_layer=starting_layerin; 47 deg_layer_delete=deg_layer_deletein; 36 48 } /*}}}*/ 37 49 ~LoveVariables(){}; 50 }; /*}}}*/ 51 52 template <class doubletype> class LoveNumbers{ /*{{{*/ 53 54 public: 55 doubletype* H; 56 doubletype* K; 57 doubletype* L; 58 doubletype* Kernels; 59 int sh_nmin, sh_nmax, nfreq, nkernels; 60 61 LoveNumbers(){ /*{{{*/ 62 H=NULL; 63 K=NULL; 64 L=NULL; 65 Kernels=NULL; 66 sh_nmin=0; 67 sh_nmax=0; 68 nfreq=0; 69 nkernels=0; 70 } /*}}}*/ 71 LoveNumbers(int sh_nminin, int sh_nmaxin, int nfreqin, Matlitho* matlitho){ /*{{{*/ 72 sh_nmax=sh_nmaxin; 73 sh_nmin=sh_nminin; 74 nfreq=nfreqin; 75 nkernels=(sh_nmax+1)*(matlitho->numlayers+1)*6; 76 H=xNewZeroInit<doubletype>(nfreq*(sh_nmax+1)); 77 K=xNewZeroInit<doubletype>(nfreq*(sh_nmax+1)); 78 L=xNewZeroInit<doubletype>(nfreq*(sh_nmax+1)); 79 Kernels=xNewZeroInit<doubletype>(nfreq*nkernels); 80 } /*}}}*/ 81 void DownCastToDouble(LoveNumbers<IssmDouble>* LoveDouble){ 82 for(int i=0;i<(sh_nmax+1)*nfreq;i++){ 83 LoveDouble->H[i]=std::real(H[i]); 84 LoveDouble->K[i]=std::real(K[i]); 85 LoveDouble->L[i]=std::real(L[i]); 86 } 87 } 88 void LoveMPI_Gather(LoveNumbers<doubletype>* Love_local, int lower_row){ 89 int* recvcounts=xNew<int>(IssmComm::GetSize()); 90 int* displs=xNew<int>(IssmComm::GetSize()); 91 int rc; 92 int offset; 93 int nf_local = Love_local->nfreq; 94 95 /*Deal H, K, L first, as they share the same size*/ 96 rc=(sh_nmax+1)*nf_local; 97 offset=(sh_nmax+1)*lower_row; 98 ISSM_MPI_Allgather(&rc,1,ISSM_MPI_INT,recvcounts,1,ISSM_MPI_INT,IssmComm::GetComm()); 99 ISSM_MPI_Allgather(&offset,1,ISSM_MPI_INT,displs,1,ISSM_MPI_INT,IssmComm::GetComm()); 100 ISSM_MPI_Allgatherv(Love_local->H, rc, ISSM_MPI_DOUBLE, H, recvcounts, displs, ISSM_MPI_DOUBLE,IssmComm::GetComm()); 101 ISSM_MPI_Allgatherv(Love_local->K, rc, ISSM_MPI_DOUBLE, K, recvcounts, displs, ISSM_MPI_DOUBLE,IssmComm::GetComm()); 102 ISSM_MPI_Allgatherv(Love_local->L, rc, ISSM_MPI_DOUBLE, L, recvcounts, displs, ISSM_MPI_DOUBLE,IssmComm::GetComm()); 103 104 /* deal with love kernels now */ 105 rc=nf_local*nkernels; 106 offset=lower_row*nkernels; 107 ISSM_MPI_Allgather(&rc,1,ISSM_MPI_INT,recvcounts,1,ISSM_MPI_INT,IssmComm::GetComm()); 108 ISSM_MPI_Allgather(&offset,1,ISSM_MPI_INT,displs,1,ISSM_MPI_INT,IssmComm::GetComm()); 109 ISSM_MPI_Allgatherv(Love_local->Kernels, rc, ISSM_MPI_DOUBLE, Kernels, recvcounts, displs, ISSM_MPI_DOUBLE,IssmComm::GetComm()); 110 111 xDelete<int>(recvcounts); 112 xDelete<int>(displs); 113 } 114 void Copy(LoveNumbers<doubletype>* LoveDup){ 115 for(int i=0;i<(sh_nmax+1)*nfreq;i++){ 116 H[i]=LoveDup->H[i]; 117 K[i]=LoveDup->K[i]; 118 L[i]=LoveDup->L[i]; 119 } 120 for(int i=0;i<nkernels*nfreq;i++){ 121 Kernels[i]=LoveDup->Kernels[i]; 122 } 123 } 124 ~LoveNumbers(){ 125 xDelete<doubletype>(H); 126 xDelete<doubletype>(K); 127 xDelete<doubletype>(L); 128 xDelete<doubletype>(Kernels); 129 }; 38 130 }; /*}}}*/ 39 131 … … 123 215 return xi; 124 216 }/*}}}*/ 125 template<typename doubletype> void postwidder_transform(doubletype* Lovet, doubletype* Lovef,int d, int t, int NTit, doubletype* xi, FemModel* femmodel){ /*{{{*/217 template<typename doubletype> void postwidder_transform(doubletype* Lovet, doubletype* Lovef,int d, int t, int sh_nmax,int NTit, doubletype* xi, FemModel* femmodel){ /*{{{*/ 126 218 //Computes Lovet for time step t and degree d from the PW coefficients xi and the corresponding 2*NTit frequency samples in Lovef 127 219 128 int nfreq, indxi, indf; 129 femmodel->parameters->FindParam(&nfreq,LoveNfreqEnum); 130 int nt=nfreq/2/NTit; 131 132 indf=d*nfreq+t*2*NTit; 220 int indxi, indf; 221 IssmDouble PW_test; 222 IssmDouble PW_threshold; 223 femmodel->parameters->FindParam(&PW_threshold,LovePostWidderThresholdEnum); 224 225 indf=(t*2*NTit)*(sh_nmax+1)+d; 133 226 doubletype* LoveM = xNew<doubletype>(NTit); 227 228 229 // test variation across frequencies tested, something with little frequency dependence is not worth going through PW tranform 230 // that transform would also be numerically unstable 231 PW_test = abs((Lovef[indf+(2*NTit-1)*(sh_nmax+1)]-Lovef[indf])/Lovef[indf]); 232 233 //if (PW_test < PW_threshold){ //elastic or fluid response: Love(t) = Love(s), we can do an early return 234 // Lovet[t*(sh_nmax+1)+d]=Lovef[indf]; 235 // return; 236 //} 237 238 if (PW_test==0){ //elastic or fluid response: Love(t) = Love(s), we can do an early return 239 Lovet[t*(sh_nmax+1)+d]=Lovef[indf]; 240 return; 241 } 134 242 135 243 for (int M=1;M<NTit+1;M++){ … … 137 245 for (int k=1;k<2*M+1;k++){ 138 246 indxi=(M-1)*(2*NTit)+k-1; 139 LoveM[M-1]+=xi[indxi]*Lovef[indf+ k-1];247 LoveM[M-1]+=xi[indxi]*Lovef[indf+(k-1)*(sh_nmax+1)]; 140 248 } 141 249 … … 146 254 if ( abs(LoveM[M-1]-LoveM[M-2]) > abs(LoveM[M-2]-LoveM[M-3]) && 147 255 abs(LoveM[M-2]-LoveM[M-3]) > abs(LoveM[M-3]-LoveM[M-4]) ){ 148 Lovet[ d*nt+t]=LoveM[M-3];256 Lovet[t*(sh_nmax+1)+d]=LoveM[M-3]; 149 257 return; 150 258 } 151 259 } 152 260 } 153 Lovet[ d*nt+t]=LoveM[NTit-1];261 Lovet[t*(sh_nmax+1)+d]=LoveM[NTit-1]; 154 262 }/*}}}*/ 155 263 template <typename doubletype> void GetEarthRheology(doubletype* pla, doubletype* pmu, int layer_index, doubletype omega, Matlitho* matlitho){ /*{{{*/ … … 726 834 727 835 }/*}}}*/ 728 template <typename doubletype> void yi_boundary_conditions(doubletype* yi_righthandside, int deg, FemModel* femmodel, Matlitho* matlitho,LoveVariables* vars ){ /*{{{*/836 template <typename doubletype> void yi_boundary_conditions(doubletype* yi_righthandside, int deg, FemModel* femmodel, Matlitho* matlitho,LoveVariables* vars, int forcing_type){ /*{{{*/ 729 837 730 838 IssmDouble g0,r0,mu0,ra,rb,rc; 731 int nyi, forcing_type,icb,cmb,starting_layer;839 int nyi,icb,cmb,starting_layer; 732 840 IssmDouble* EarthMass; 733 841 … … 739 847 740 848 femmodel->parameters->FindParam(&mu0,LoveMu0Enum); 741 femmodel->parameters->FindParam(&forcing_type,LoveForcingTypeEnum);742 849 femmodel->parameters->FindParam(&icb,LoveInnerCoreBoundaryEnum); 743 850 femmodel->parameters->FindParam(&cmb,LoveCoreMantleBoundaryEnum); … … 810 917 } 811 918 }/*}}}*/ 812 template <typename doubletype> void solve_yi_system(doubletype* loveh, doubletype* lovel, doubletype* lovek, int deg, doubletype omega, doubletype* yi, doubletype* rhs, FemModel* femmodel, Matlitho* matlitho, LoveVariables* vars){ /*{{{*/919 template <typename doubletype> void solve_yi_system(doubletype* loveh, doubletype* lovel, doubletype* lovek, int deg, doubletype omega, IssmDouble* frequencies, doubletype* yi, doubletype* rhs, FemModel* femmodel, Matlitho* matlitho, LoveVariables* vars, bool verbosecpu){ /*{{{*/ 813 920 814 921 IssmDouble g0,r0,mu0,loveratio,underflow_tol; 815 IssmDouble* frequencies;922 //IssmDouble* frequencies; 816 923 int nyi,starting_layer, dummy; 817 924 bool allow_layer_deletion; … … 827 934 femmodel->parameters->FindParam(&allow_layer_deletion,LoveAllowLayerDeletionEnum); 828 935 femmodel->parameters->FindParam(&underflow_tol,LoveUnderflowTolEnum); 829 femmodel->parameters->FindParam(&frequencies,&dummy,LoveFrequenciesEnum);936 //femmodel->parameters->FindParam(&frequencies,&dummy,LoveFrequenciesEnum); 830 937 IssmDouble ra=matlitho->radius[matlitho->numlayers]; 831 938 bool exit=false; 832 939 int lda,ldb; 940 833 941 834 942 for(;!exit;){ //cycles of: attempt to solve the yi system, then delete a layer if necessary … … 854 962 xDelete<int>(ipiv); 855 963 856 if(VerboseModule() && info!=0){ 857 _printf0_("love core warning in DGESV : LAPACK linear equation solver couldn't resolve the system"); 964 /*_printf_("i j yi[i+nyi*j] rhs[i]"); 965 for (int i=0;i<nyi;i++){ 966 _printf_(i<<" "<<rhs[i]<<"\n"); 967 } 968 969 for (int i=0;i<nyi;i++){ 970 for (int j=0;j<nyi;j++){ 971 _printf_(i<<" "<<j<<" "<<yi[i+nyi*j]<<" "<<rhs[i]<<"\n"); 972 } 973 } 974 _error_("love core warning in DGESV : LAPACK linear equation solver couldn't resolve the system");*/ 975 976 if(VerboseSolution() && info!=0){ 858 977 _printf_("i j yi[i+nyi*j] rhs[i]"); 859 978 for (int i=0;i<nyi;i++){ … … 862 981 } 863 982 } 983 _error_("love core warning in DGESV : LAPACK linear equation solver couldn't resolve the system"); 864 984 } 865 985 … … 880 1000 if (abs(lovek1/lovek1s) < loveratio) loveratio = abs(lovek1/lovek1s); 881 1001 882 if (!allow_layer_deletion || nyi<=12 || omega!=angular_frequency<doubletype>(frequencies[0])){ 1002 1003 1004 if (!allow_layer_deletion || nyi<=12 || omega!=angular_frequency<doubletype>(frequencies[0]) || deg==0){ 883 1005 goto save_results; 884 1006 /*We are not allowed to delete layers, or there is only one layer left. We also don't want to delete … … 887 1009 } 888 1010 889 if (loveratio<=underflow_tol || xIsNan(loveratio) || xIsInf(loveratio)){//We need to delete a layer and try again if the ratio between deepest love number to surface love number is too low (risk of underflow) or garbage 890 if(VerboseSolution()){ 891 _printf_("\n Degree: " << deg <<", surface/Depth Love number ratio small: "<<loveratio<<"\n"); 892 _printf_(" Changing the interface where the integration starts\n"); 893 _printf_(" New start interface: r="<< matlitho->radius[starting_layer+1] <<"m\n\n"); 894 } 1011 if (omega==0){ // if running elastic love_numbers, record at which degree we must delete layers, this way we synch layer deletion between cpus next time we calculate love numbers 1012 //We need to delete a layer and try again if the ratio between deepest love number to surface love number is too low (risk of underflow) or garbage 1013 if (loveratio<=underflow_tol || xIsNan(loveratio) || xIsInf(loveratio)) { 1014 vars->deg_layer_delete[starting_layer]=deg; 1015 if(VerboseSolution() && verbosecpu){ 1016 _printf_("\n Degree: " << deg <<", surface/Depth Love number ratio small: "<<loveratio<<"\n"); 1017 _printf_(" Changing the interface where integration starts\n"); 1018 _printf_(" New start interface: r="<< matlitho->radius[starting_layer+1] <<"m\n\n"); 1019 } 1020 } 1021 } 1022 1023 if (deg==vars->deg_layer_delete[starting_layer]){ // if we are at the degree where we should delete the current layer, proceed to delete the bottom layer 1024 if (omega!=0 && VerboseSolution() && verbosecpu) _printf_(", deleting layer " << starting_layer << "\n"); 895 1025 nyi-=6; 896 1026 starting_layer+=1; … … 934 1064 xDelete<doubletype>(rhslocal); 935 1065 } 936 xDelete<IssmDouble>(frequencies);1066 //xDelete<IssmDouble>(frequencies); 937 1067 938 1068 }/*}}}*/ 939 template <typename doubletype> void love_freq_to_temporal( doubletype* LoveHt,doubletype* LoveLt,doubletype* LoveKt,doubletype* LoveHf,doubletype* LoveLf,doubletype* LoveKf, FemModel* femmodel){ /*{{{*/1069 template <typename doubletype> void love_freq_to_temporal(LoveNumbers<doubletype>* Lovet, LoveNumbers<doubletype>* Tidalt, doubletype* pmtf_colineart, doubletype* pmtf_orthot, LoveNumbers<doubletype>* Lovef,LoveNumbers<doubletype>* Tidalf, IssmDouble* frequencies, FemModel* femmodel, bool verbosecpu){ /*{{{*/ 940 1070 //Transforms all frequency-dependent love numbers into time-dependent love numbers 941 int nfreq,sh_nmax,sh_nmin,indxi,indf, NTit; 942 943 femmodel->parameters->FindParam(&nfreq,LoveNfreqEnum); 944 femmodel->parameters->FindParam(&sh_nmax,LoveShNmaxEnum); 945 femmodel->parameters->FindParam(&sh_nmin,LoveShNminEnum); 1071 int nfreq,sh_nmax,sh_nmin,indxi,indf, NTit, forcing_type, nt; 1072 IssmDouble kf,Omega,moi_e,moi_p,alpha; 1073 doubletype* pmtf_colinearf=NULL; 1074 doubletype* pmtf_orthof=NULL; 1075 bool chandler_wobble=false; 1076 1077 nfreq=Lovef->nfreq; 1078 sh_nmin=Lovef->sh_nmin; 1079 sh_nmax=Lovef->sh_nmax; 1080 946 1081 femmodel->parameters->FindParam(&NTit,LoveNTemporalIterationsEnum); 947 1082 948 int nt=nfreq/2/NTit; 1083 //Parameters for the rotationnal feedback 1084 femmodel->parameters->FindParam(&chandler_wobble,LoveChandlerWobbleEnum); 1085 femmodel->parameters->FindParam(&forcing_type,LoveForcingTypeEnum); 1086 femmodel->parameters->FindParam(&kf,TidalLoveK2SecularEnum); 1087 femmodel->parameters->FindParam(&Omega,RotationalAngularVelocityEnum); 1088 femmodel->parameters->FindParam(&moi_e,RotationalEquatorialMoiEnum); 1089 femmodel->parameters->FindParam(&moi_p,RotationalPolarMoiEnum); 1090 1091 nt=Lovet->nfreq; 949 1092 doubletype* xi=postwidder_coef<doubletype>(NTit); 1093 1094 if(VerboseSolution() && verbosecpu) _printf_(" Inverse Laplace Transform... "); 950 1095 951 1096 for (int d=sh_nmin;d<sh_nmax+1;d++){ 952 1097 for (int t=0;t<nt;t++){ 953 postwidder_transform<doubletype>(LoveHt,LoveHf,d,t,NTit,xi,femmodel); 954 postwidder_transform<doubletype>(LoveLt,LoveLf,d,t,NTit,xi,femmodel); 955 postwidder_transform<doubletype>(LoveKt,LoveKf,d,t,NTit,xi,femmodel); 956 } 957 } 1098 postwidder_transform<doubletype>(Lovet->H,Lovef->H,d,t,sh_nmax,NTit,xi,femmodel); 1099 postwidder_transform<doubletype>(Lovet->K,Lovef->K,d,t,sh_nmax,NTit,xi,femmodel); 1100 postwidder_transform<doubletype>(Lovet->L,Lovef->L,d,t,sh_nmax,NTit,xi,femmodel); 1101 } 1102 } 1103 1104 if(VerboseSolution() && verbosecpu) _printf_("done!\n"); 1105 1106 if (forcing_type==11){ //Let's retrieve the functions necessary for the rotational_feedback 1107 if(VerboseSolution() && verbosecpu) _printf_(" Transforming PMTF and tidal love numbers... "); 1108 pmtf_colinearf = xNewZeroInit<doubletype>(3*nfreq); 1109 pmtf_orthof = xNewZeroInit<doubletype>(3*nfreq); 1110 int d=2; 1111 doubletype s,R1,R2; 1112 alpha=(moi_p-moi_e)/moi_e; //Earth flattening 1113 1114 if (chandler_wobble){ //Chandler Wobble is untested yet 1115 for (int fr=0;fr<nfreq;fr++){ 1116 s=angular_frequency<doubletype>(frequencies[fr]); 1117 R1=alpha*Omega*(1.0-Tidalf->K[fr*3+d]/kf); 1118 R2=1.0+alpha*Tidalf->K[fr*3+d]/kf; 1119 pmtf_colinearf[fr*3+d]=alpha*(1.0+Lovef->K[fr*(sh_nmax+1)+d])*(Omega*R1-pow(s,2)*R2)/(pow(R1,2.0)+pow(s*R2,2.0)); 1120 pmtf_orthof[fr*3+d]=alpha*(1.0+Lovef->K[fr*(sh_nmax+1)+d])*s*Omega*(1.0+alpha)/(pow(R1,2.0)+pow(s*R2,2.0)); 1121 } 1122 } 1123 else { 1124 for (int fr=0;fr<nfreq;fr++){ 1125 pmtf_colinearf[fr*3+d]=(1.0+Lovef->K[fr*(sh_nmax+1)+d])/(1.0-Tidalf->K[fr*3+d]/kf); 1126 pmtf_orthof[fr*3+d]=0.0; 1127 } 1128 } 1129 for (int t=0;t<nt;t++){ 1130 postwidder_transform<doubletype>(Tidalt->H,Tidalf->H,2,t,2,NTit,xi,femmodel); 1131 postwidder_transform<doubletype>(Tidalt->K,Tidalf->K,2,t,2,NTit,xi,femmodel); 1132 postwidder_transform<doubletype>(Tidalt->L,Tidalf->L,2,t,2,NTit,xi,femmodel); 1133 postwidder_transform<doubletype>(pmtf_colineart,pmtf_colinearf,2,t,2,NTit,xi,femmodel); 1134 postwidder_transform<doubletype>(pmtf_orthot,pmtf_orthof,2,t,2,NTit,xi,femmodel); 1135 } 1136 if(VerboseSolution() && verbosecpu) _printf_("done!\n"); 1137 } 1138 958 1139 xDelete<doubletype>(xi); 1140 xDelete<doubletype>(pmtf_colinearf); 1141 xDelete<doubletype>(pmtf_orthof); 1142 }/*}}}*/ 1143 1144 template <typename doubletype> void compute_love_numbers(LoveNumbers<doubletype>* Lovef, LoveNumbers<doubletype>* Elastic, int forcing_type, int sh_cutoff, IssmDouble* frequencies, FemModel* femmodel, Matlitho* matlitho, LoveVariables* vars, bool verbosecpu){ 1145 1146 int nstep, kernel_index,kernel_indexe,deleted_layer_offset, deg, sh_nmin, sh_nmax, nfreq; 1147 doubletype lovek, loveh, lovel, loveratio; 1148 doubletype omega; 1149 doubletype* yi_prefactor=NULL; 1150 doubletype* yi_righthandside=NULL; 1151 doubletype* yi=NULL; 1152 IssmDouble underflow_tol; 1153 bool freq_skip, istemporal; 1154 1155 femmodel->parameters->FindParam(&nstep,LoveIntStepsPerLayerEnum); 1156 femmodel->parameters->FindParam(&istemporal,LoveIsTemporalEnum); 1157 1158 nfreq=Lovef->nfreq; 1159 sh_nmin=Lovef->sh_nmin; 1160 sh_nmax=Lovef->sh_nmax; 1161 if (Elastic==NULL) sh_cutoff=sh_nmax; 1162 1163 // reset deleted layers in case we have called this function before; 1164 vars->starting_layer=0; 1165 vars->nyi=6*(matlitho->numlayers+1); 1166 1167 yi_prefactor=xNewZeroInit<doubletype>(6*6*nstep*matlitho->numlayers); 1168 yi_righthandside=xNewZeroInit<doubletype>(vars->nyi); 1169 yi=xNewZeroInit<doubletype>(vars->nyi*vars->nyi); 1170 1171 //precalculate yi coefficients that do not depend on degree or frequency 1172 fill_yi_prefactor<doubletype>(yi_prefactor, NULL, NULL,femmodel, matlitho,vars); 1173 1174 if (VerboseSolution() && Elastic && verbosecpu) _printf_("\n"); 1175 1176 for(int deg=0;deg<2;deg++){ // calculation is in the center of mass reference frame, neutralize degree 0 and 1 mass changes 1177 for (int fr=0;fr<nfreq;fr++){ 1178 Lovef->K[fr*(sh_nmax+1)+deg]=-1.0; 1179 } 1180 } 1181 1182 for(int deg=sh_nmin;deg<sh_cutoff+1;deg++){ 1183 if (VerboseSolution() && Elastic && verbosecpu) { 1184 _printf_("\r Degree: " << deg << "/" << sh_nmax << " "); 1185 } 1186 1187 //precalculate yi coefficients that depend on degree but not frequency 1188 fill_yi_prefactor<doubletype>(yi_prefactor, °, NULL,femmodel, matlitho,vars); 1189 1190 for (int fr=0;fr<nfreq;fr++){ 1191 omega=angular_frequency<doubletype>(frequencies[fr]); 1192 1193 //precalculate yi coefficients that depend on degree and frequency 1194 fill_yi_prefactor<doubletype>(yi_prefactor, °,&omega,femmodel, matlitho,vars); 1195 1196 //solve the system 1197 yi_boundary_conditions<doubletype>(yi_righthandside,deg,femmodel,matlitho,vars,forcing_type); 1198 build_yi_system<doubletype>(yi,deg,omega,yi_prefactor,femmodel,matlitho,vars); 1199 solve_yi_system<doubletype>(&loveh,&lovel,&lovek, deg, omega, frequencies, yi, yi_righthandside,femmodel, matlitho,vars,verbosecpu); 1200 Lovef->H[fr*(sh_nmax+1)+deg]=loveh; 1201 Lovef->K[fr*(sh_nmax+1)+deg]=lovek-1.0; 1202 Lovef->L[fr*(sh_nmax+1)+deg]=lovel; 1203 deleted_layer_offset=(matlitho->numlayers+1)*6-vars->nyi;// =6 per deleted layer 1204 kernel_index=fr*(sh_nmax+1)*(matlitho->numlayers+1)*6 + deg*(matlitho->numlayers+1)*6 + deleted_layer_offset; 1205 for (int i=0;i<vars->nyi;i++){ 1206 Lovef->Kernels[kernel_index+i]=yi_righthandside[i]; 1207 } 1208 } 1209 } 1210 1211 if (Elastic) { // if elastic values were provided, we copy elastic love numbers above the cutoff degree instead of calculating them 1212 for(int deg=sh_cutoff+1;deg<sh_nmax+1;deg++){ 1213 if (VerboseSolution() && Elastic && verbosecpu) { 1214 if (deg==sh_nmax || deg%100==0) _printf_("\r Degree: " << deg << "/" << Lovef->sh_nmax << " "); 1215 } 1216 for (int fr=0;fr<nfreq;fr++){ 1217 // just copy the elastic values 1218 Lovef->H[fr*(sh_nmax+1)+deg]=Elastic->H[deg]; 1219 Lovef->K[fr*(sh_nmax+1)+deg]=Elastic->K[deg]; 1220 Lovef->L[fr*(sh_nmax+1)+deg]=Elastic->L[deg]; 1221 deleted_layer_offset=(matlitho->numlayers+1)*6-vars->nyi;// =6 per deleted layer 1222 kernel_index=fr*(sh_nmax+1)*(matlitho->numlayers+1)*6 + deg*(matlitho->numlayers+1)*6 + deleted_layer_offset; 1223 kernel_indexe=deg*(matlitho->numlayers+1)*6 + deleted_layer_offset; 1224 for (int i=0;i<vars->nyi;i++){ 1225 Lovef->Kernels[kernel_index+i]=Elastic->Kernels[kernel_indexe+i]; 1226 } 1227 } 1228 } 1229 } 1230 1231 if (VerboseSolution() && Elastic && verbosecpu) _printf_("\n"); 1232 xDelete<doubletype>(yi); 1233 xDelete<doubletype>(yi_righthandside); 1234 xDelete<doubletype>(yi_prefactor); 959 1235 }/*}}}*/ 960 1236 … … 973 1249 IssmDouble g0,r0; 974 1250 int nyi,starting_layer; 1251 int* deg_layer_delete; 975 1252 976 1253 femmodel->parameters->FindParam(&GG,LoveGravitationalConstantEnum); 977 1254 EarthMass=xNewZeroInit<IssmDouble>(numlayers+1); 1255 deg_layer_delete=xNewZeroInit<int>(numlayers); 978 1256 979 1257 for (int i=0;i<numlayers;i++){ … … 993 1271 starting_layer=0; 994 1272 995 return new LoveVariables(EarthMass,g0,r0,nyi,starting_layer); 1273 if(VerboseSolution()){ 1274 _printf_(" Surface gravity: " << g0 << " m.s^-2\n"); 1275 _printf_(" Mean density: " << EarthMass[numlayers-1]/(4.0/3.0*PI*pow(r0,3.0)) << " kg.m^-3\n"); 1276 } 1277 1278 return new LoveVariables(EarthMass,g0,r0,nyi,starting_layer,deg_layer_delete); 996 1279 997 1280 } /*}}}*/ … … 999 1282 1000 1283 Matlitho* matlitho=NULL; 1001 int nfreq, nyi,starting_layer,nstep,forcing_type,dummy;1284 int nfreq, NTit,nt, forcing_type,dummy, sh_cutoff; 1002 1285 int sh_nmin,sh_nmax,kernel_index,deleted_layer_offset; 1003 bool allow_layer_deletion,love_kernels, istemporal ;1286 bool allow_layer_deletion,love_kernels, istemporal, freq_skip; 1004 1287 bool verbosemod = (int)VerboseModule(); 1005 IssmDouble mu0, underflow_tol;1006 1288 IssmDouble *frequencies = NULL; 1289 IssmDouble *frequencies_local=NULL; 1007 1290 bool save_results; 1008 1291 bool complex_computation; 1292 bool verbosecpu=false; 1009 1293 1010 1294 doubletype omega; 1011 1295 doubletype lovek, loveh, lovel, loveratio; 1012 1013 doubletype* LoveKf = NULL; 1014 doubletype* LoveHf = NULL; 1015 doubletype* LoveLf = NULL; 1016 1017 doubletype* LoveKernels= NULL; 1296 IssmDouble pw_threshold, pw_test_h, pw_test_l,pw_test_k; 1297 1298 LoveNumbers<doubletype>* Lovef=NULL; 1299 LoveNumbers<doubletype>* Tidalf=NULL; 1300 1301 /* parallel computing */ 1302 LoveNumbers<doubletype>* Lovef_local=NULL; 1303 LoveNumbers<doubletype>* Tidalf_local=NULL; 1304 1305 /*elastic & fluid love numbers*/ 1306 LoveNumbers<doubletype>* Elastic=NULL; 1307 IssmDouble* frequencies_elastic=NULL; 1308 LoveNumbers<doubletype>* Fluid=NULL; 1309 IssmDouble* frequencies_fluid=NULL; 1310 1018 1311 LoveVariables* vars=NULL; 1019 doubletype* yi_prefactor=NULL;1020 doubletype* yi_righthandside=NULL;1021 doubletype* yi=NULL;1022 1023 if(VerboseSolution()) _printf0_(" computing LOVE numbers\n");1024 1312 1025 1313 /*recover materials parameters: there is only one Matlitho, chase it down the hard way:*/ … … 1039 1327 femmodel->parameters->FindParam(&sh_nmax,LoveShNmaxEnum); 1040 1328 femmodel->parameters->FindParam(&sh_nmin,LoveShNminEnum); 1041 femmodel->parameters->FindParam(&mu0,LoveMu0Enum);1042 1329 femmodel->parameters->FindParam(&allow_layer_deletion,LoveAllowLayerDeletionEnum); 1043 1330 femmodel->parameters->FindParam(&love_kernels,LoveKernelsEnum); 1044 1331 femmodel->parameters->FindParam(&forcing_type,LoveForcingTypeEnum); 1045 1332 femmodel->parameters->FindParam(&istemporal,LoveIsTemporalEnum); 1046 femmodel->parameters->FindParam(&nstep,LoveIntStepsPerLayerEnum);1047 1333 femmodel->parameters->FindParam(&complex_computation,LoveComplexComputationEnum); 1048 1049 /*Initialize three love matrices: geoid, vertical and horizontal displacement (real and imaginary parts) */ 1050 LoveKf = xNewZeroInit<doubletype>(nfreq*(sh_nmax+1)); 1051 LoveHf = xNewZeroInit<doubletype>(nfreq*(sh_nmax+1)); 1052 LoveLf = xNewZeroInit<doubletype>(nfreq*(sh_nmax+1)); 1334 femmodel->parameters->FindParam(&pw_threshold,LovePostWidderThresholdEnum); 1335 if (istemporal) femmodel->parameters->FindParam(&NTit,LoveNTemporalIterationsEnum); 1336 1337 /*Initialize three love matrices: geoid, vertical and horizontal displacement*/ 1338 Lovef= new LoveNumbers<doubletype>(sh_nmin,sh_nmax,nfreq, matlitho); 1339 Tidalf= new LoveNumbers<doubletype>(2,2,nfreq, matlitho); 1340 Elastic= new LoveNumbers<doubletype>(sh_nmin,sh_nmax,1,matlitho); 1341 Fluid= new LoveNumbers<doubletype>(sh_nmin,sh_nmax,1,matlitho); 1053 1342 1054 1343 /*Initialize love kernels (real and imaginary parts): */ 1055 LoveKernels= xNewZeroInit<doubletype>(nfreq*(sh_nmax+1)*(matlitho->numlayers+1)*6);1056 1057 1344 vars=love_init(femmodel,matlitho); 1058 1345 1059 yi_prefactor=xNewZeroInit<doubletype>(6*6*nstep*matlitho->numlayers); 1060 yi_righthandside=xNewZeroInit<doubletype>(vars->nyi); 1061 yi=xNewZeroInit<doubletype>(vars->nyi*vars->nyi); 1062 1063 //precalculate yi coefficients that do not depend on degree or frequency 1064 fill_yi_prefactor<doubletype>(yi_prefactor, NULL, NULL,femmodel, matlitho,vars); 1065 for(int deg=sh_nmin;deg<sh_nmax+1;deg++){ 1066 1067 //precalculate yi coefficients that depend on degree but not frequency 1068 fill_yi_prefactor<doubletype>(yi_prefactor, °, NULL,femmodel, matlitho,vars); 1069 1070 for (int fr=0;fr<nfreq;fr++){ 1071 omega=angular_frequency<doubletype>(frequencies[fr]); 1072 1073 //precalculate yi coefficients that depend on degree and frequency 1074 fill_yi_prefactor<doubletype>(yi_prefactor, °,&omega,femmodel, matlitho,vars); 1075 1076 yi_boundary_conditions<doubletype>(yi_righthandside,deg,femmodel,matlitho,vars); 1077 1078 build_yi_system<doubletype>(yi,deg,omega,yi_prefactor,femmodel,matlitho,vars); 1079 1080 solve_yi_system<doubletype>(&loveh,&lovel,&lovek, deg, omega, yi, yi_righthandside,femmodel, matlitho,vars); 1081 1082 LoveHf[deg*nfreq+fr]=loveh; 1083 LoveKf[deg*nfreq+fr]=lovek-1.0; 1084 LoveLf[deg*nfreq+fr]=lovel; 1085 1086 deleted_layer_offset=(matlitho->numlayers+1)*6-vars->nyi;// =6 per deleted layer 1087 kernel_index=deg*nfreq*(matlitho->numlayers+1)*6 + fr*(matlitho->numlayers+1)*6 + deleted_layer_offset; 1088 for (int i=0;i<vars->nyi;i++){ 1089 LoveKernels[kernel_index+i]=yi_righthandside[i]; 1090 } 1091 } 1092 } 1093 1094 xDelete<doubletype>(yi); 1095 xDelete<doubletype>(yi_righthandside); 1346 //distribute frequencies for parallel computation /*{{{*/ 1347 int nt_local, nf_local, lower_row, upper_row; 1348 if (istemporal){ 1349 //temporal love numbers are obtained via blocks of 2*NTit frequencies samples 1350 //here we are making sure no block is split between different cpus, which would make the inverse laplace transform impossible 1351 nt=nfreq/2/NTit; 1352 nt_local=DetermineLocalSize(nt,IssmComm::GetComm()); 1353 nf_local=nt_local*2*NTit; // number of local frequencies 1354 GetOwnershipBoundariesFromRange(&lower_row,&upper_row,nt_local,IssmComm::GetComm()); 1355 lower_row*=2*NTit; 1356 upper_row*=2*NTit; 1357 } 1358 else{ 1359 //in this case frequency samples are completely independent so we can split them evenly across cpus 1360 nf_local=DetermineLocalSize(nfreq,IssmComm::GetComm()); 1361 GetOwnershipBoundariesFromRange(&lower_row,&upper_row,nf_local,IssmComm::GetComm()); 1362 } 1363 1364 if (lower_row==0) verbosecpu=true; //let only cpu1 be verbose 1365 if(VerboseSolution() && verbosecpu) _printf0_(" computing LOVE numbers\n"); 1366 1367 frequencies_local=xNewZeroInit<IssmDouble>(nf_local); 1368 for (int fr=0;fr<nf_local;fr++) frequencies_local[fr]=frequencies[lower_row+fr]; 1369 1370 Lovef_local= new LoveNumbers<doubletype>(sh_nmin,sh_nmax,nf_local, matlitho); 1371 Tidalf_local= new LoveNumbers<doubletype>(2,2,nf_local, matlitho); 1372 1373 /*}}}*/ 1374 frequencies_elastic=xNewZeroInit<IssmDouble>(1); 1375 frequencies_fluid=xNewZeroInit<IssmDouble>(1); 1376 for (int fr=0;fr<nfreq;fr++){ // find the lowest non-zero frequency requested 1377 if (frequencies_fluid[0]==0) frequencies_fluid[0]=frequencies[fr]; 1378 else if(frequencies[fr]!=0 && frequencies_fluid[0]>frequencies[fr]) frequencies_fluid[0]=frequencies[fr]; 1379 } 1380 1381 // run elastic and fluid love numbers 1382 if(VerboseSolution() && verbosecpu) _printf_(" elastic\n"); 1383 compute_love_numbers<doubletype>(Elastic, NULL, forcing_type, sh_nmax,frequencies_elastic, femmodel, matlitho, vars,verbosecpu); 1384 1385 if (nfreq>1){ 1386 compute_love_numbers<doubletype>(Fluid, NULL, forcing_type, sh_nmax,frequencies_fluid, femmodel, matlitho, vars,verbosecpu); 1387 sh_cutoff=sh_nmax; 1388 for (int deg=100;deg<sh_nmax+1;deg++){ 1389 pw_test_h=abs((Fluid->H[deg]-Elastic->H[deg])/Elastic->H[deg]); 1390 pw_test_k=abs((Fluid->K[deg]-Elastic->K[deg])/Elastic->K[deg]); 1391 pw_test_l=abs((Fluid->L[deg]-Elastic->L[deg])/Elastic->L[deg]); 1392 if (pw_test_h<pw_threshold && pw_test_k<pw_threshold && pw_test_l<pw_threshold){ 1393 sh_cutoff=deg; 1394 if(VerboseSolution() && verbosecpu){ 1395 _printf_(" Degree: " << deg << "/" << sh_nmax << " "); 1396 _printf_(" found negligible variation across frequencies, will copy elastic values after this degree\n"); 1397 _printf_(" Delta_h/h=" << pw_test_h << "; Delta_k/k="<< pw_test_k << "; Delta_l/l=" << pw_test_l << "; threshold set to " << pw_threshold << "\n"); 1398 } 1399 break; 1400 } 1401 } 1402 } 1403 else sh_cutoff=sh_nmax; 1404 1405 1406 1407 //Take care of rotationnal feedback love numbers first, if relevant /*{{{*/ 1408 if (forcing_type==11 && sh_nmin<=2 && sh_nmax>=2){ // if forcing is surface loading and we have degree 2 1409 if(VerboseSolution() && verbosecpu) _printf_(" tidal\n"); 1410 int tidal_forcing_type=9; 1411 compute_love_numbers<doubletype>(Tidalf_local, NULL,tidal_forcing_type=9, 2,frequencies_local, femmodel, matlitho, vars,verbosecpu); 1412 } 1413 /*}}}*/ 1414 1415 //Resume requested forcing_type 1416 if (nfreq>1){ // if we are not running just elastic love numbers 1417 if(VerboseSolution() && verbosecpu){ 1418 if (forcing_type==11) _printf_(" loading\n"); 1419 else if(forcing_type==9) _printf_(" tidal\n"); 1420 else _printf_(" love\n"); 1421 } 1422 compute_love_numbers<doubletype>(Lovef_local, Elastic, forcing_type, sh_cutoff, frequencies_local, femmodel, matlitho, vars,verbosecpu); 1423 } 1424 else{ 1425 Lovef_local->Copy(Elastic); 1426 } 1427 /*}}}*/ 1428 1096 1429 1097 1430 //Temporal love numbers 1098 1431 if (istemporal && !complex_computation){ 1099 1100 IssmDouble* LoveHtDouble=NULL; 1101 IssmDouble* LoveKtDouble=NULL; 1102 IssmDouble* LoveLtDouble=NULL; 1103 doubletype* LoveHt=NULL; 1104 doubletype* LoveLt=NULL; 1105 doubletype* LoveKt=NULL; 1106 1107 int NTit; 1108 femmodel->parameters->FindParam(&NTit,LoveNTemporalIterationsEnum); 1109 int nt = nfreq/2/NTit; 1110 1111 LoveHt=xNewZeroInit<doubletype>((sh_nmax+1)*nt); 1112 LoveLt=xNewZeroInit<doubletype>((sh_nmax+1)*nt); 1113 LoveKt=xNewZeroInit<doubletype>((sh_nmax+1)*nt); 1114 1115 love_freq_to_temporal<doubletype>(LoveHt,LoveLt,LoveKt,LoveHf,LoveLf,LoveKf,femmodel); 1116 1117 /*Downcast and add into parameters:*/ 1118 LoveHtDouble=xNew<IssmDouble>((sh_nmax+1)*nt); 1119 LoveLtDouble=xNew<IssmDouble>((sh_nmax+1)*nt); 1120 LoveKtDouble=xNew<IssmDouble>((sh_nmax+1)*nt); 1121 for(int i=0;i<(sh_nmax+1)*nt;i++){ 1122 LoveHtDouble[i]=std::real(LoveHt[i]); 1123 LoveLtDouble[i]=std::real(LoveLt[i]); 1124 LoveKtDouble[i]=std::real(LoveKt[i]); 1125 } 1432 /*Initialize*/ 1433 doubletype* pmtf_colineart=NULL; 1434 doubletype* pmtf_orthot=NULL; 1435 LoveNumbers<doubletype>* Lovet=NULL; 1436 LoveNumbers<doubletype>* Tidalt=NULL; 1437 /*Downcast arrays to be exported in parameters*/ 1438 LoveNumbers<IssmDouble>* LovetDouble=NULL; 1439 LoveNumbers<IssmDouble>* TidaltDouble=NULL; 1440 IssmDouble* pmtf_colineartDouble=NULL; 1441 IssmDouble* pmtf_orthotDouble=NULL; 1442 /* parallel computing */ 1443 doubletype* pmtf_colineart_local=NULL; 1444 doubletype* pmtf_orthot_local=NULL; 1445 LoveNumbers<doubletype>* Lovet_local=NULL; 1446 LoveNumbers<doubletype>* Tidalt_local=NULL; 1447 1448 Lovet= new LoveNumbers<doubletype>(sh_nmin,sh_nmax,nt,matlitho); 1449 Tidalt= new LoveNumbers<doubletype>(2,2,nt,matlitho); 1450 pmtf_colineart=xNewZeroInit<doubletype>(3*nt); 1451 pmtf_orthot=xNewZeroInit<doubletype>(3*nt); 1452 1453 Lovet_local= new LoveNumbers<doubletype>(sh_nmin,sh_nmax,nt_local,matlitho); 1454 Tidalt_local= new LoveNumbers<doubletype>(2,2,nt_local,matlitho); 1455 pmtf_colineart_local=xNewZeroInit<doubletype>(3*nt_local); 1456 pmtf_orthot_local=xNewZeroInit<doubletype>(3*nt_local); 1457 1458 love_freq_to_temporal<doubletype>(Lovet_local,Tidalt_local,pmtf_colineart_local,pmtf_orthot_local,Lovef_local,Tidalf_local,frequencies_local,femmodel,verbosecpu); 1459 1460 /* MPI Gather */ /*{{{*/ 1461 Lovef->LoveMPI_Gather(Lovef_local, lower_row); 1462 if (forcing_type==11 && sh_nmin<=2 && sh_nmax>=2){ 1463 Tidalf->LoveMPI_Gather(Tidalf_local, lower_row); 1464 } 1465 Lovet->LoveMPI_Gather(Lovet_local, lower_row/2/NTit); 1466 Tidalt->LoveMPI_Gather(Tidalt_local, lower_row/2/NTit); 1467 //pmtf: 1468 int* recvcounts=xNew<int>(IssmComm::GetSize()); 1469 int* displs=xNew<int>(IssmComm::GetSize()); 1470 int rc; 1471 int offset; 1472 rc=3*nt_local; 1473 offset=3*lower_row/2/NTit; 1474 ISSM_MPI_Allgather(&rc,1,ISSM_MPI_INT,recvcounts,1,ISSM_MPI_INT,IssmComm::GetComm()); 1475 ISSM_MPI_Allgather(&offset,1,ISSM_MPI_INT,displs,1,ISSM_MPI_INT,IssmComm::GetComm()); 1476 ISSM_MPI_Allgatherv(pmtf_colineart_local, rc, ISSM_MPI_DOUBLE, pmtf_colineart, recvcounts, displs, ISSM_MPI_DOUBLE,IssmComm::GetComm()); 1477 ISSM_MPI_Allgatherv(pmtf_orthot_local, rc, ISSM_MPI_DOUBLE, pmtf_orthot, recvcounts, displs, ISSM_MPI_DOUBLE,IssmComm::GetComm()); 1478 xDelete<int>(recvcounts); 1479 xDelete<int>(displs); 1480 /*}}}*/ 1481 1482 /*Downcast and add into parameters:*/ /*{{{*/ 1483 LovetDouble= new LoveNumbers<IssmDouble>(sh_nmin,sh_nmax,nt,matlitho); 1484 TidaltDouble= new LoveNumbers<IssmDouble>(2,2,nt,matlitho); 1485 1486 pmtf_colineartDouble=xNew<IssmDouble>(nt); 1487 pmtf_orthotDouble=xNew<IssmDouble>(nt); 1488 1489 Lovet->DownCastToDouble(LovetDouble); 1490 Tidalt->DownCastToDouble(TidaltDouble); 1491 for(int i=0;i<nt;i++){ 1492 pmtf_colineartDouble[i]=std::real(pmtf_colineart[2*nt+i]); 1493 pmtf_orthotDouble[i]=std::real(pmtf_orthot[2*nt+i]); 1494 } 1495 1126 1496 if(forcing_type==9){ //tidal loading 1127 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveHEnum,Love HtDouble,(sh_nmax+1)*nt,1));1128 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveKEnum,Love KtDouble,(sh_nmax+1)*nt,1));1129 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveLEnum,Love LtDouble,(sh_nmax+1)*nt,1));1497 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveHEnum,LovetDouble->H,(sh_nmax+1)*nt,1)); 1498 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveKEnum,LovetDouble->K,(sh_nmax+1)*nt,1)); 1499 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveLEnum,LovetDouble->L,(sh_nmax+1)*nt,1)); 1130 1500 } 1131 1501 else if(forcing_type==11){ //surface loading 1132 femmodel->parameters->AddObject(new DoubleMatParam(LoadLoveHEnum,LoveHtDouble,(sh_nmax+1)*nt,1)); 1133 femmodel->parameters->AddObject(new DoubleMatParam(LoadLoveKEnum,LoveKtDouble,(sh_nmax+1)*nt,1)); 1134 femmodel->parameters->AddObject(new DoubleMatParam(LoadLoveLEnum,LoveLtDouble,(sh_nmax+1)*nt,1)); 1135 } 1136 xDelete<IssmDouble>(LoveHtDouble); 1137 xDelete<IssmDouble>(LoveKtDouble); 1138 xDelete<IssmDouble>(LoveLtDouble); 1139 1502 femmodel->parameters->AddObject(new DoubleMatParam(LoadLoveHEnum,LovetDouble->H,(sh_nmax+1)*nt,1)); 1503 femmodel->parameters->AddObject(new DoubleMatParam(LoadLoveKEnum,LovetDouble->K,(sh_nmax+1)*nt,1)); 1504 femmodel->parameters->AddObject(new DoubleMatParam(LoadLoveLEnum,LovetDouble->L,(sh_nmax+1)*nt,1)); 1505 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveHEnum,TidaltDouble->H,3*nt,1)); 1506 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveKEnum,TidaltDouble->K,3*nt,1)); 1507 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveLEnum,TidaltDouble->L,3*nt,1)); 1508 femmodel->parameters->AddObject(new DoubleMatParam(LovePolarMotionTransferFunctionColinearEnum,pmtf_colineartDouble,nt,1)); 1509 femmodel->parameters->AddObject(new DoubleMatParam(LovePolarMotionTransferFunctionOrthogonalEnum,pmtf_orthotDouble,nt,1)); 1510 } 1511 1512 xDelete<IssmDouble>(pmtf_colineartDouble); 1513 xDelete<IssmDouble>(pmtf_orthotDouble); 1514 /*}}}*/ 1515 1140 1516 /*Add into external results, no need to downcast, we can handle complexes/quad precision: */ 1141 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveKrEnum,LoveKt,sh_nmax+1,nt,0,0)); 1142 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveHrEnum,LoveHt,sh_nmax+1,nt,0,0)); 1143 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveLrEnum,LoveLt,sh_nmax+1,nt,0,0)); 1144 1145 xDelete<doubletype>(LoveHt); 1146 xDelete<doubletype>(LoveLt); 1147 xDelete<doubletype>(LoveKt); 1517 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveKtEnum,Lovet->K,nt,sh_nmax+1,0,0)); 1518 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveHtEnum,Lovet->H,nt,sh_nmax+1,0,0)); 1519 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveLtEnum,Lovet->L,nt,sh_nmax+1,0,0)); 1520 1521 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveTidalKtEnum,Tidalt->K,nt,3,0,0)); 1522 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveTidalHtEnum,Tidalt->H,nt,3,0,0)); 1523 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveTidalLtEnum,Tidalt->L,nt,3,0,0)); 1524 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LovePMTF1tEnum,pmtf_colineart,nt,3,0,0)); 1525 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LovePMTF2tEnum,pmtf_orthot,nt,3,0,0)); 1526 1527 delete Lovet; 1528 delete Tidalt; 1529 delete Lovet_local; 1530 delete Tidalt_local; 1531 delete LovetDouble; 1532 delete TidaltDouble; 1533 1534 xDelete<doubletype>(pmtf_colineart); 1535 xDelete<doubletype>(pmtf_orthot); 1148 1536 } 1149 1537 else{ 1150 1151 IssmDouble* LoveHfDouble=NULL; 1152 IssmDouble* LoveKfDouble=NULL; 1153 IssmDouble* LoveLfDouble=NULL; 1538 LoveNumbers<IssmDouble>* LovefDouble=NULL; 1539 LovefDouble= new LoveNumbers<IssmDouble>(sh_nmin,sh_nmax,nfreq,matlitho); 1540 1541 /*MPI_Gather*/ 1542 if (nfreq>1){ 1543 Lovef->LoveMPI_Gather(Lovef_local, lower_row); 1544 if (forcing_type==11 && sh_nmin<=2 && sh_nmax>=2){ 1545 Tidalf->LoveMPI_Gather(Tidalf_local, lower_row); 1546 } 1547 } 1548 else{ 1549 Lovef->Copy(Elastic); 1550 Tidalf->Copy(Tidalf_local); 1551 } 1154 1552 1155 1553 /*Add into parameters:*/ 1156 LoveHfDouble=xNew<IssmDouble>((sh_nmax+1)*nfreq); 1157 LoveLfDouble=xNew<IssmDouble>((sh_nmax+1)*nfreq); 1158 LoveKfDouble=xNew<IssmDouble>((sh_nmax+1)*nfreq); 1159 for(int i=0;i<(sh_nmax+1)*nfreq;i++){ 1160 LoveHfDouble[i]=std::real(LoveHf[i]); 1161 LoveLfDouble[i]=std::real(LoveLf[i]); 1162 LoveKfDouble[i]=std::real(LoveKf[i]); 1163 } 1554 Lovef->DownCastToDouble(LovefDouble); 1164 1555 if(forcing_type==9){ //tidal loading 1165 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveHEnum,Love HfDouble,(sh_nmax+1)*nfreq,1));1166 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveKEnum,Love KfDouble,(sh_nmax+1)*nfreq,1));1167 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveLEnum,Love LfDouble,(sh_nmax+1)*nfreq,1));1556 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveHEnum,LovefDouble->H,(sh_nmax+1)*nfreq,1)); 1557 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveKEnum,LovefDouble->K,(sh_nmax+1)*nfreq,1)); 1558 femmodel->parameters->AddObject(new DoubleMatParam(TidalLoveLEnum,LovefDouble->L,(sh_nmax+1)*nfreq,1)); 1168 1559 } 1169 1560 else if(forcing_type==11){ //surface loading 1170 femmodel->parameters->AddObject(new DoubleMatParam(LoadLoveHEnum,LoveHfDouble,(sh_nmax+1)*nfreq,1)); 1171 femmodel->parameters->AddObject(new DoubleMatParam(LoadLoveKEnum,LoveKfDouble,(sh_nmax+1)*nfreq,1)); 1172 femmodel->parameters->AddObject(new DoubleMatParam(LoadLoveLEnum,LoveLfDouble,(sh_nmax+1)*nfreq,1)); 1173 } 1174 xDelete<IssmDouble>(LoveHfDouble); 1175 xDelete<IssmDouble>(LoveKfDouble); 1176 xDelete<IssmDouble>(LoveLfDouble); 1561 femmodel->parameters->AddObject(new DoubleMatParam(LoadLoveHEnum,LovefDouble->H,(sh_nmax+1)*nfreq,1)); 1562 femmodel->parameters->AddObject(new DoubleMatParam(LoadLoveKEnum,LovefDouble->K,(sh_nmax+1)*nfreq,1)); 1563 femmodel->parameters->AddObject(new DoubleMatParam(LoadLoveLEnum,LovefDouble->L,(sh_nmax+1)*nfreq,1)); 1564 } 1565 delete LovefDouble; 1177 1566 } 1178 1567 1179 1568 /*Add into external results:*/ 1180 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveKiEnum,LoveKf,sh_nmax+1,nfreq,0,0)); 1181 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveHiEnum,LoveHf,sh_nmax+1,nfreq,0,0)); 1182 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveLiEnum,LoveLf,sh_nmax+1,nfreq,0,0)); 1183 1569 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveKfEnum,Lovef->K,nfreq,sh_nmax+1,0,0)); 1570 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveHfEnum,Lovef->H,nfreq,sh_nmax+1,0,0)); 1571 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveLfEnum,Lovef->L,nfreq,sh_nmax+1,0,0)); 1184 1572 /*Only when love_kernels is on*/ 1185 1573 if (love_kernels==1) { 1186 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveKernelsEnum,LoveKernels,(sh_nmax+1)*(matlitho->numlayers+1)*6,nfreq,0,0)); 1187 } 1188 1574 femmodel->results->AddObject(new GenericExternalResult<doubletype*>(femmodel->results->Size()+1,LoveKernelsEnum,Lovef->Kernels,nfreq,(sh_nmax+1)*(matlitho->numlayers+1)*6,0,0)); 1575 } 1189 1576 /*Free resources:*/ 1190 1577 xDelete<IssmDouble>(frequencies); 1191 xDelete<doubletype>(LoveKf); 1192 xDelete<doubletype>(LoveHf); 1193 xDelete<doubletype>(LoveLf); 1194 xDelete<doubletype>(LoveKernels); 1195 1578 xDelete<IssmDouble>(frequencies_local); 1579 xDelete<IssmDouble>(frequencies_elastic); 1580 delete Lovef; 1581 delete Lovef_local; 1582 delete Tidalf; 1583 delete Tidalf_local; 1584 delete Elastic; 1196 1585 /* Legacy for fortran core, to be removed after complete validation */ 1197 1586 … … 1225 1614 1226 1615 /*Add love matrices to results:*/ 1227 //femmodel->results->AddObject(new GenericExternalResult<IssmDouble*>(femmodel->results->Size()+1,LoveK rEnum,LoveKr,sh_nmax+1,nfreq,0,0));1228 //femmodel->results->AddObject(new GenericExternalResult<IssmDouble*>(femmodel->results->Size()+1,LoveH rEnum,LoveHr,sh_nmax+1,nfreq,0,0));1229 //femmodel->results->AddObject(new GenericExternalResult<IssmDouble*>(femmodel->results->Size()+1,LoveL rEnum,LoveLr,sh_nmax+1,nfreq,0,0));1230 //femmodel->results->AddObject(new GenericExternalResult<IssmDouble*>(femmodel->results->Size()+1,LoveK iEnum,LoveKi,sh_nmax+1,nfreq,0,0));1231 //femmodel->results->AddObject(new GenericExternalResult<IssmDouble*>(femmodel->results->Size()+1,LoveH iEnum,LoveHi,sh_nmax+1,nfreq,0,0));1232 //femmodel->results->AddObject(new GenericExternalResult<IssmDouble*>(femmodel->results->Size()+1,LoveL iEnum,LoveLi,sh_nmax+1,nfreq,0,0));1616 //femmodel->results->AddObject(new GenericExternalResult<IssmDouble*>(femmodel->results->Size()+1,LoveKtEnum,LoveKr,sh_nmax+1,nfreq,0,0)); 1617 //femmodel->results->AddObject(new GenericExternalResult<IssmDouble*>(femmodel->results->Size()+1,LoveHtEnum,LoveHr,sh_nmax+1,nfreq,0,0)); 1618 //femmodel->results->AddObject(new GenericExternalResult<IssmDouble*>(femmodel->results->Size()+1,LoveLtEnum,LoveLr,sh_nmax+1,nfreq,0,0)); 1619 //femmodel->results->AddObject(new GenericExternalResult<IssmDouble*>(femmodel->results->Size()+1,LoveKfEnum,LoveKi,sh_nmax+1,nfreq,0,0)); 1620 //femmodel->results->AddObject(new GenericExternalResult<IssmDouble*>(femmodel->results->Size()+1,LoveHfEnum,LoveHi,sh_nmax+1,nfreq,0,0)); 1621 //femmodel->results->AddObject(new GenericExternalResult<IssmDouble*>(femmodel->results->Size()+1,LoveLfEnum,LoveLi,sh_nmax+1,nfreq,0,0)); 1233 1622 1234 1623 //xDelete<IssmDouble>(LoveKr); … … 1251 1640 template void GetEarthRheology<IssmDouble>(IssmDouble* pla, IssmDouble* pmu, int layer_index, IssmDouble omega, Matlitho* matlitho); 1252 1641 template void GetEarthRheology<IssmComplex>(IssmComplex* pla, IssmComplex* pmu, int layer_index, IssmComplex omega, Matlitho* matlitho); 1253 template void yi_boundary_conditions<IssmDouble>(IssmDouble* yi_righthandside, int deg, FemModel* femmodel, Matlitho* matlitho,LoveVariables* vars );1254 template void yi_boundary_conditions<IssmComplex>(IssmComplex* yi_righthandside, int deg, FemModel* femmodel, Matlitho* matlitho,LoveVariables* vars );1642 template void yi_boundary_conditions<IssmDouble>(IssmDouble* yi_righthandside, int deg, FemModel* femmodel, Matlitho* matlitho,LoveVariables* vars, int forcing_type); 1643 template void yi_boundary_conditions<IssmComplex>(IssmComplex* yi_righthandside, int deg, FemModel* femmodel, Matlitho* matlitho,LoveVariables* vars, int forcing_type); 1255 1644 template void yi_derivatives<IssmDouble>(IssmDouble* dydx, IssmDouble* y, int layer_index, int n, IssmDouble* yi_prefactor, FemModel* femmodel, Matlitho* matlitho); 1256 1645 template void yi_derivatives<IssmComplex>(IssmComplex* dydx, IssmComplex* y, int layer_index, int n, IssmComplex* yi_prefactor, FemModel* femmodel, Matlitho* matlitho); … … 1263 1652 template void build_yi_system<IssmDouble>(IssmDouble* yi, int deg, IssmDouble omega, IssmDouble* yi_prefactor, FemModel* femmodel, Matlitho* matlitho,LoveVariables* vars); 1264 1653 template void build_yi_system<IssmComplex>(IssmComplex* yi, int deg, IssmComplex omega, IssmComplex* yi_prefactor, FemModel* femmodel, Matlitho* matlitho,LoveVariables* vars); 1265 template void solve_yi_system<IssmDouble>(IssmDouble* loveh, IssmDouble* lovel, IssmDouble* lovek, int deg, IssmDouble omega, IssmDouble* yi, IssmDouble* rhs, FemModel* femmodel, Matlitho* matlitho, LoveVariables* vars); 1266 template void solve_yi_system<IssmComplex>(IssmComplex* loveh, IssmComplex* lovel, IssmComplex* lovek, int deg, IssmComplex omega, IssmComplex* yi, IssmComplex* rhs, FemModel* femmodel, Matlitho* matlitho, LoveVariables* vars); 1654 template void solve_yi_system<IssmDouble>(IssmDouble* loveh, IssmDouble* lovel, IssmDouble* lovek, int deg, IssmDouble omega, IssmDouble* frequencies, IssmDouble* yi, IssmDouble* rhs, FemModel* femmodel, Matlitho* matlitho, LoveVariables* vars,bool verbosecpu); 1655 template void solve_yi_system<IssmComplex>(IssmComplex* loveh, IssmComplex* lovel, IssmComplex* lovek, int deg, IssmComplex omega, IssmDouble* frequencies, IssmComplex* yi, IssmComplex* rhs, FemModel* femmodel, Matlitho* matlitho, LoveVariables* vars,bool verbosecpu); 1656 template void compute_love_numbers<IssmDouble>(LoveNumbers<IssmDouble>* Lovef, LoveNumbers<IssmDouble>* Elastic, int forcing_type, int sh_cutoff,IssmDouble* frequencies, FemModel* femmodel, Matlitho* matlitho, LoveVariables* vars, bool verbosecpu); 1657 template void compute_love_numbers<IssmComplex>(LoveNumbers<IssmComplex>* Lovef, LoveNumbers<IssmComplex>* Elastic, int forcing_type, int sh_cutoff, IssmDouble* frequencies, FemModel* femmodel, Matlitho* matlitho, LoveVariables* vars, bool verbosecpu); 1267 1658 template IssmDouble factorial<IssmDouble>(int n); 1268 1659 template IssmDouble* postwidder_coef<IssmDouble>(int NTit); 1269 1660 template IssmDouble n_C_r<IssmDouble>(int n, int r); 1270 template void postwidder_transform<IssmDouble>(IssmDouble* Lovet, IssmDouble* Lovef,int d, int t, int NTit, IssmDouble* xi, FemModel* femmodel);1661 template void postwidder_transform<IssmDouble>(IssmDouble* Lovet, IssmDouble* Lovef,int d, int t, int sh_nmax,int NTit, IssmDouble* xi, FemModel* femmodel); 1271 1662 1272 1663 /*}}}*/ -
issm/trunk/src/c/cores/masstransport_core.cpp
r26744 r27035 49 49 solutionsequence_linear(femmodel); 50 50 femmodel->parameters->SetParam(SurfaceEnum,InputToExtrudeEnum); 51 extrudefromtop_core(femmodel); 52 femmodel->parameters->SetParam(ThicknessEnum,InputToExtrudeEnum); 53 extrudefromtop_core(femmodel); 54 femmodel->parameters->SetParam(BaseEnum,InputToExtrudeEnum); 51 55 extrudefromtop_core(femmodel); 52 56 } -
issm/trunk/src/c/cores/movingfront_core.cpp
r26744 r27035 48 48 } 49 49 50 /* smoothen slope of lsf for computation of normal on ice domain*/ 51 levelsetfunctionslope_core(femmodel); 52 50 53 /* start the work from here */ 51 54 if(VerboseSolution()) _printf0_(" computing calving and undercutting\n"); … … 53 56 FrontalForcingsx(femmodel); 54 57 if(VerboseSolution()) _printf0_(" computing new ice front position\n"); 55 56 /* smoothen slope of lsf for computation of normal on ice domain*/57 levelsetfunctionslope_core(femmodel);58 58 59 59 /* determine variables for extrapolation */ … … 114 114 115 115 /* solve level set equation */ 116 analysis = new LevelsetAnalysis();117 analysis->Core(femmodel);118 delete analysis;116 LevelsetAnalysis lsanalysis; 117 lsanalysis.Core(femmodel); 118 lsanalysis.PostProcess(femmodel); 119 119 120 120 /*Kill ice berg to avoid free body motion*/ 121 121 if(killicebergs){ 122 int killberg = 0; 122 123 if(VerboseSolution()) _printf0_(" looking for icebergs to kill\n"); 123 KillIcebergsx(femmodel); 124 killberg = KillIcebergsx(femmodel); 125 /*wait for all cores*/ 126 int totalkill; 127 ISSM_MPI_Reduce(&killberg,&totalkill,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm()); 128 ISSM_MPI_Bcast(&totalkill,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 129 130 if (totalkill > 0) { 131 if(VerboseSolution()) _printf0_(" reinitializing level set after killing " << totalkill << " icebergs\n"); 132 femmodel->ResetLevelset(); 133 ResetBoundaryConditions(femmodel,LevelsetAnalysisEnum); 134 } 124 135 } 125 136 … … 128 139 if(VerboseSolution()) _printf0_(" reinitializing level set\n"); 129 140 femmodel->ResetLevelset(); 141 ResetBoundaryConditions(femmodel,LevelsetAnalysisEnum); 130 142 } 131 143 … … 133 145 GetMaskOfIceVerticesLSMx(femmodel); 134 146 147 /*Save results*/ 148 if(save_results){ 149 int outputs[1] = {MaskIceLevelsetEnum}; 150 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],1); 151 } 152 135 153 /*End profiler*/ 136 154 femmodel->profiler->Stop(MOVINGFRONTCORE); -
issm/trunk/src/c/cores/sampling_core.cpp
r26744 r27035 5 5 #include "../classes/classes.h" 6 6 #include "../solutionsequences/solutionsequences.h" 7 #include "../analyses/analyses.h" // new 8 #include "../modules/modules.h" 7 9 8 10 void sampling_core(FemModel* femmodel){ … … 30 32 /*Generate random sample*/ 31 33 if(VerboseSolution()) _printf0_(" call computational core\n"); 34 SamplingAnalysis* analysis = new SamplingAnalysis(); 32 35 femmodel->SetCurrentConfiguration(SamplingAnalysisEnum); 36 37 if(solution_type==TransientSolutionEnum){ 38 InputDuplicatex(femmodel,SampleEnum,SampleOldEnum); 39 40 int seed; 41 femmodel->parameters->FindParam(&seed,SamplingSeedEnum); 42 if(seed>=0){ 43 int step; 44 femmodel->parameters->FindParam(&step,StepEnum); 45 seed = seed + 13923272*step; // change default seed for transient simulations (by considering an arbitrary shift based on the step number) 46 femmodel->parameters->SetParam(seed,SamplingSeedEnum); 47 } 48 49 } 50 33 51 solutionsequence_sampling(femmodel); 52 53 if(solution_type==TransientSolutionEnum){ 54 55 InputDuplicatex(femmodel,SampleEnum,SampleNoiseEnum); 56 57 analysis->UpdateTransientSample(femmodel); 58 59 } 60 61 delete analysis; 34 62 35 63 if(save_results){ … … 46 74 /*profiler*/ 47 75 femmodel->profiler->Stop(SAMPLINGCORE); 76 77 48 78 } -
issm/trunk/src/c/cores/sealevelchange_core.cpp
r26744 r27035 24 24 bool slcconvergence(Vector<IssmDouble>* RSLg,Vector<IssmDouble>* RSLg_old,IssmDouble eps_rel,IssmDouble eps_abs); 25 25 IssmDouble SealevelloadsOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble totaloceanarea); 26 void PolarMotion(IssmDouble* m, FemModel* femmodel,GrdLoads* loads, SealevelGeometry* slgeom); 26 void PolarMotion(IssmDouble* m, FemModel* femmodel,GrdLoads* loads, SealevelGeometry* slgeom, bool computefuture); 27 void SealevelchangeUpdateViscousTimeSeries(FemModel* femmodel); 27 28 void ConserveOceanMass(FemModel* femmodel,GrdLoads* loads, IssmDouble offset, SealevelGeometry* slgeom); 28 29 void ivins_deformation_core(FemModel* femmodel); … … 247 248 bool rotation=false; 248 249 bool planethasocean=false; 250 bool computefuture=false; 249 251 IssmDouble* sealevelpercpu=NULL; 250 252 … … 304 306 if(VerboseSolution()) _printf0_(" starting GRD convolutions\n"); 305 307 306 /*update viscous RSL:*/ 307 for(Object* & object : femmodel->elements->objects){ 308 Element* element = xDynamicCast<Element*>(object); 309 element->SealevelchangeUpdateViscousFields(); 310 } 308 /*update viscous time series to keep up with time stepping:*/ 309 SealevelchangeUpdateViscousTimeSeries(femmodel); 311 310 312 311 /*buildup loads: */ … … 319 318 loads->BroadcastLoads(); 320 319 321 //compute polar motion:322 PolarMotion(&polarmotionvector[0],femmodel,loads,slgeom);323 324 320 /*skip computation of sea level equation if requested, which means sea level loads should be zeroed */ 325 321 if(!sealevelloading){ 326 322 loads->sealevelloads=xNewZeroInit<IssmDouble>(nel); 327 323 loads->subsealevelloads=xNewZeroInit<IssmDouble>(slgeom->nbar[SLGEOM_OCEAN]); 328 324 PolarMotion(&polarmotionvector[0],femmodel,loads, slgeom, computefuture=true); 329 325 goto deformation; 330 326 } … … 332 328 if(VerboseSolution()) _printf0_(" converging GRD convolutions\n"); 333 329 for(;;){ 330 331 //compute polar motion: 332 PolarMotion(&polarmotionvector[0],femmodel,loads,slgeom,computefuture=false); 334 333 335 334 oldsealevelloads=loads->vsealevelloads->Duplicate(); loads->vsealevelloads->Copy(oldsealevelloads); … … 338 337 for(Object* & object : femmodel->elements->objects){ 339 338 Element* element = xDynamicCast<Element*>(object); 340 element->SealevelchangeConvolution(sealevelpercpu, loads 339 element->SealevelchangeConvolution(sealevelpercpu, loads, polarmotionvector,slgeom); 341 340 } 342 341 … … 364 363 loads->BroadcastSealevelLoads(); 365 364 366 //compute polar motion:367 PolarMotion(&polarmotionvector[0],femmodel,loads, slgeom);368 369 365 //convergence? 370 366 if(slcconvergence(loads->vsealevelloads,oldsealevelloads,eps_rel,eps_abs))break; … … 374 370 iterations++; 375 371 } 372 373 //recompute polar motion one final time, this time updating viscous stacks for future time steps 374 if (viscous) PolarMotion(&polarmotionvector[0],femmodel,loads, slgeom, computefuture=true); 376 375 377 376 deformation: … … 418 417 419 418 if (rotation) { 420 femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,Sealevel InertiaTensorXZEnum,polarmotionvector[0],step,time));421 femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,Sealevel InertiaTensorYZEnum,polarmotionvector[1],step,time));422 femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,Sealevel InertiaTensorZZEnum,polarmotionvector[2],step,time));419 femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,SealevelchangePolarMotionXEnum,polarmotionvector[0],step,time)); 420 femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,SealevelchangePolarMotionYEnum,polarmotionvector[1],step,time)); 421 femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,SealevelchangePolarMotionZEnum,polarmotionvector[2],step,time)); 423 422 } 424 423 … … 666 665 } 667 666 667 /*Compute spherical harmonic functions for spatial integrations of the loads*/ 668 slgeom->BuildSphericalHarmonics(); 669 668 670 femmodel->parameters->AddObject(new DoubleVecParam(XxeEnum,xxe,nel)); 669 671 femmodel->parameters->AddObject(new DoubleVecParam(YyeEnum,yye,nel)); … … 731 733 732 734 vsealevelloadsvolume->PointwiseMult(loads->vsealevelloads,oceanareas); 733 vsubsealevelloadsvolume->PointwiseMult(loads->vsubsealevelloads,suboceanareas); 735 vsubsealevelloadsvolume->PointwiseMult(loads->vsubsealevelloads,suboceanareas); 734 736 735 737 vsealevelloadsvolume->Sum(&sealevelloadsaverage); … … 740 742 return (sealevelloadsaverage+subsealevelloadsaverage)/totaloceanarea; 741 743 } /*}}}*/ 742 void PolarMotion(IssmDouble* polarmotionvector, FemModel* femmodel,GrdLoads* loads, SealevelGeometry* slgeom){ /*{{{*/ 743 744 IssmDouble moi_list[3]={0,0,0}; 745 IssmDouble moi_list_sub[3]={0,0,0}; 746 IssmDouble moi_list_cpu[3]={0,0,0}; 747 IssmDouble* tide_love_h = NULL; 748 IssmDouble* tide_love_k = NULL; 749 IssmDouble* load_love_k = NULL; 750 IssmDouble tide_love_k2secular; 751 IssmDouble moi_e, moi_p; 752 IssmDouble m1, m2, m3; 744 void PolarMotion(IssmDouble* polarmotionvector, FemModel* femmodel,GrdLoads* loads, SealevelGeometry* slgeom, bool computefuture){ /*{{{*/ 745 //The purpose of this routine is to get the polar motion vector m=(m1, m2, m3) induced by the GrdLoads 746 IssmDouble S2coef[3]; 747 IssmDouble* pmtf_col= NULL; 748 IssmDouble* pmtf_ortho = NULL; 749 IssmDouble* pmtf_z = NULL; 750 IssmDouble* m1=NULL; 751 IssmDouble* m2=NULL; 752 IssmDouble* m3=NULL; 753 IssmDouble* m1interp=NULL; 754 IssmDouble* m2interp=NULL; 755 IssmDouble* m3interp=NULL; 756 757 IssmDouble moi_e, moi_p, re; 758 IssmDouble mhprefactor, mzprefactor; 753 759 bool rotation=false; 760 bool viscous=false; 761 int nt=1; 762 763 IssmDouble* viscoustimes=NULL; 764 IssmDouble* viscouspolarmotion=NULL; 765 int viscousnumsteps; 766 int viscousindex=0; 767 int dummy; 768 IssmDouble currenttime, final_time, lincoeff, timeacc; 754 769 755 770 /*early return?:*/ … … 758 773 759 774 /*retrieve parameters: */ 760 femmodel->parameters->FindParam(&load_love_k,NULL,NULL,LoadLoveKEnum); 761 femmodel->parameters->FindParam(&tide_love_h,NULL,NULL,TidalLoveHEnum); 762 femmodel->parameters->FindParam(&tide_love_k,NULL,NULL,TidalLoveKEnum); 763 femmodel->parameters->FindParam(&tide_love_k2secular,TidalLoveK2SecularEnum); 775 femmodel->parameters->FindParam(&viscous,SolidearthSettingsViscousEnum); 764 776 femmodel->parameters->FindParam(&moi_e,RotationalEquatorialMoiEnum); 765 777 femmodel->parameters->FindParam(&moi_p,RotationalPolarMoiEnum); 766 767 for(Object* & object : femmodel->elements->objects){ 768 Element* element = xDynamicCast<Element*>(object); 769 770 element->SealevelchangeMomentOfInertiaCentroid(&moi_list[0],loads,slgeom); 771 element->SealevelchangeMomentOfInertiaSubElement(&moi_list_sub[0],loads, slgeom); 772 773 moi_list_cpu[0] += moi_list[0]+moi_list_sub[0]; 774 moi_list_cpu[1] += moi_list[1]+moi_list_sub[1]; 775 moi_list_cpu[2] += moi_list[2]+moi_list_sub[2]; 776 } 777 778 for (int i=0;i<3;i++) moi_list[i]=0; 779 780 ISSM_MPI_Reduce (&moi_list_cpu[0],&moi_list[0],1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() ); 781 ISSM_MPI_Bcast(&moi_list[0],1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 782 783 ISSM_MPI_Reduce (&moi_list_cpu[1],&moi_list[1],1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() ); 784 ISSM_MPI_Bcast(&moi_list[1],1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 785 786 ISSM_MPI_Reduce (&moi_list_cpu[2],&moi_list[2],1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() ); 787 ISSM_MPI_Bcast(&moi_list[2],1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 788 789 /*compute perturbation terms for angular velocity vector: */ 790 m1 = 1/(1-tide_love_k[2]/tide_love_k2secular) * (1+load_love_k[2])/(moi_p-moi_e) * moi_list[0]; 791 m2 = 1/(1-tide_love_k[2]/tide_love_k2secular) * (1+load_love_k[2])/(moi_p-moi_e) * moi_list[1]; 792 m3 = -(1+load_love_k[2])/moi_p * moi_list[2]; // term associated with fluid number (3-order-of-magnitude smaller) is negelected 778 femmodel->parameters->FindParam(&pmtf_col,NULL,SealevelchangePolarMotionTransferFunctionColinearEnum); 779 femmodel->parameters->FindParam(&pmtf_ortho,NULL,SealevelchangePolarMotionTransferFunctionOrthogonalEnum); 780 femmodel->parameters->FindParam(&pmtf_z,NULL,SealevelchangePolarMotionTransferFunctionZEnum); 781 femmodel->parameters->FindParam(&re,SolidearthPlanetRadiusEnum); 782 783 if (viscous){ 784 femmodel->parameters->FindParam(&final_time,TimesteppingFinalTimeEnum); 785 femmodel->parameters->FindParam(&timeacc,SolidearthSettingsTimeAccEnum); 786 femmodel->parameters->FindParam(&viscousnumsteps,SealevelchangeViscousNumStepsEnum); 787 femmodel->parameters->FindParam(&viscoustimes,NULL,SealevelchangeViscousTimesEnum); 788 femmodel->parameters->FindParam(&viscousindex,SealevelchangeViscousIndexEnum); 789 femmodel->parameters->FindParam(¤ttime,TimeEnum); 790 femmodel->parameters->FindParam(&viscouspolarmotion,NULL,NULL,SealevelchangeViscousPolarMotionEnum); 791 792 if (computefuture){ 793 nt = viscousnumsteps; 794 m1interp=xNewZeroInit<IssmDouble>(nt); 795 m2interp=xNewZeroInit<IssmDouble>(nt); 796 m3interp=xNewZeroInit<IssmDouble>(nt); 797 } 798 } 799 800 m1=xNewZeroInit<IssmDouble>(nt); 801 m2=xNewZeroInit<IssmDouble>(nt); 802 m3=xNewZeroInit<IssmDouble>(nt); 803 804 //Isolate degree 2 load coefficients 805 for (int i=0;i<3;i++) S2coef[i]=0; 806 loads->SHDegree2Coefficients(&S2coef[0],femmodel,slgeom); 807 808 //compute present (& future) polar motion from present loads 809 mhprefactor=-4.*M_PI/5.*pow(re,4.)/(moi_p-moi_e); 810 mzprefactor=8.*M_PI/15.*pow(re,4.)/moi_p; 811 for (int tprime=0;tprime<nt;tprime++){ 812 m1[tprime] = mhprefactor * (pmtf_col[tprime] * S2coef[1] + pmtf_ortho[tprime] * S2coef[2]); //x-component 813 m2[tprime] = mhprefactor * (pmtf_col[tprime] * S2coef[2] - pmtf_ortho[tprime] * S2coef[1]); //y-component 814 m3[tprime] = mzprefactor * pmtf_z[tprime] * S2coef[0]; //z-component 815 } 816 817 if(viscous){ 818 // we need to do up to 3 things (* = only if computefuture) 819 // 1*: add new PM contribution to the viscous stack for future time steps 820 // 2: collect viscous PM from past loads due at present-day and add it to PM[current_time] 821 // 3*: subtract from viscous stack PM that has already been accounted for so we don't add it again at the next time step 822 if(computefuture){ 823 if(viscoustimes[viscousindex]<final_time){ 824 lincoeff=(viscoustimes[viscousindex+1]-viscoustimes[viscousindex])/timeacc; 825 for(int t=viscousindex;t<nt;t++){ //we resynchronize m from the relative time above to the absolute time where t=0 <=> beginning of the simulation 826 if(t==viscousindex){ 827 m1interp[t]= m1[0]; 828 m2interp[t]= m2[0]; 829 m3interp[t]= m3[0]; 830 } 831 else{ //we reinterpolate PM on viscoustimes, so we can handle the case where we are running with adaptative/uneven time steps 832 int tprime=t-viscousindex-1; 833 m1interp[t]= (1.0-lincoeff)*m1[tprime]+lincoeff*m1[tprime+1]; 834 m2interp[t]= (1.0-lincoeff)*m2[tprime]+lincoeff*m2[tprime+1]; 835 m3interp[t]= (1.0-lincoeff)*m3[tprime]+lincoeff*m3[tprime+1]; 836 } 837 } 838 } 839 } 840 /*update PM at present time using viscous stack at present time: */ 841 m1[0]+=viscouspolarmotion[0*nt+viscousindex]; 842 m2[0]+=viscouspolarmotion[1*nt+viscousindex]; 843 m3[0]+=viscouspolarmotion[2*nt+viscousindex]; 844 if(computefuture){ /*update viscous stack with future deformation from present load: */ 845 for(int t=nt-1;t>=viscousindex;t--){ 846 //offset viscous PM to remove all deformation that has already been added 847 viscouspolarmotion[0*nt+t]+=m1interp[t]-m1interp[viscousindex]-viscouspolarmotion[0*nt+viscousindex]; 848 viscouspolarmotion[1*nt+t]+=m2interp[t]-m2interp[viscousindex]-viscouspolarmotion[1*nt+viscousindex]; 849 viscouspolarmotion[2*nt+t]+=m3interp[t]-m3interp[viscousindex]-viscouspolarmotion[2*nt+viscousindex]; 850 } 851 // save updated viscous PM 852 femmodel->parameters->SetParam(viscouspolarmotion,viscousnumsteps,3,SealevelchangeViscousPolarMotionEnum); 853 } 854 } 855 793 856 794 857 /*Assign output pointers:*/ 795 polarmotionvector[0]=m1; 796 polarmotionvector[1]=m2; 797 polarmotionvector[2]=m3; 858 polarmotionvector[0]=m1[0]; 859 polarmotionvector[1]=m2[0]; 860 polarmotionvector[2]=m3[0]; 861 862 /*Free allocations:*/ 863 xDelete<IssmDouble>(m1); 864 xDelete<IssmDouble>(m2); 865 xDelete<IssmDouble>(m3); 866 if (viscous){ 867 if (computefuture){ 868 xDelete<IssmDouble>(m1interp); 869 xDelete<IssmDouble>(m2interp); 870 xDelete<IssmDouble>(m3interp); 871 } 872 } 873 798 874 } /*}}}*/ 875 void SealevelchangeUpdateViscousTimeSeries(FemModel* femmodel){ /*{{{*/ 876 877 IssmDouble* viscouspolarmotion=NULL; 878 IssmDouble* viscoustimes=NULL; 879 int viscousnumsteps; 880 int viscousindex=0; 881 int newindex=0; 882 int dummy; 883 bool viscous=false; 884 bool rotation=false; 885 IssmDouble currenttime; 886 IssmDouble lincoeff=0; 887 888 femmodel->parameters->FindParam(&viscous,SolidearthSettingsViscousEnum); 889 femmodel->parameters->FindParam(&rotation,SolidearthSettingsRotationEnum); 890 891 if(viscous){ 892 femmodel->parameters->FindParam(&viscousnumsteps,SealevelchangeViscousNumStepsEnum); 893 femmodel->parameters->FindParam(&viscoustimes,NULL,SealevelchangeViscousTimesEnum); 894 femmodel->parameters->FindParam(&viscousindex,SealevelchangeViscousIndexEnum); 895 femmodel->parameters->FindParam(¤ttime,TimeEnum); 896 if (rotation) femmodel->parameters->FindParam(&viscouspolarmotion,NULL,NULL,SealevelchangeViscousPolarMotionEnum); 897 898 bool foundtime=false; 899 int offset=1; //handles the egde case where time found = max time in viscoustimes 900 lincoeff=0; 901 newindex=viscousnumsteps-2; 902 903 for(int t=viscousindex;t<viscousnumsteps;t++){ 904 if (viscoustimes[t]>=currenttime){ 905 newindex=t-1; 906 foundtime=true; 907 lincoeff=(currenttime-viscoustimes[newindex])/(viscoustimes[t]-viscoustimes[newindex]); 908 offset=0; 909 break; 910 } 911 } 912 913 if(rotation){ 914 int index=0; 915 for (int i=0;i<3;i++){ 916 index=i*viscousnumsteps+newindex; 917 viscouspolarmotion[index+offset]=(1-lincoeff)*viscouspolarmotion[index]+lincoeff*viscouspolarmotion[index+1]; 918 } 919 femmodel->parameters->SetParam(viscouspolarmotion,viscousnumsteps,3,SealevelchangeViscousPolarMotionEnum); 920 } 921 922 923 /*update viscous inputs:*/ 924 for(Object* & object : femmodel->elements->objects){ 925 Element* element = xDynamicCast<Element*>(object); 926 element->SealevelchangeUpdateViscousFields(lincoeff,newindex,offset); 927 } 928 929 viscoustimes[newindex]=currenttime; 930 viscousindex=newindex+offset; 931 932 femmodel->parameters->SetParam(viscousindex,SealevelchangeViscousIndexEnum); 933 femmodel->parameters->SetParam(viscoustimes,viscousnumsteps,SealevelchangeViscousTimesEnum); 934 935 /*free allocations:*/ 936 xDelete<IssmDouble>(viscoustimes); 937 } 938 939 940 } 799 941 void ConserveOceanMass(FemModel* femmodel,GrdLoads* loads, IssmDouble offset, SealevelGeometry* slgeom){ /*{{{*/ 800 942 … … 809 951 IssmDouble* CombineLoads(IssmDouble* load,IssmDouble* subload,FemModel* femmodel, SealevelGeometry* slgeom,int loadtype,int nel){ /*{{{*/ 810 952 953 //merges loads on centroids and subelements onto a single variable loadcopy 811 954 int* indices=xNew<int>(nel); 812 955 for(int i=0;i<nel;i++)indices[i]=i; -
issm/trunk/src/c/cores/stressbalance_core.cpp
r26744 r27035 19 19 bool dakota_analysis,control_analysis; 20 20 int domaintype; 21 bool isSIA,isSSA,isL1L2,isM LHO,isHO,isFS,isNitsche;21 bool isSIA,isSSA,isL1L2,isMOLHO,isHO,isFS,isNitsche; 22 22 bool save_results; 23 23 int solution_type; … … 31 31 femmodel->parameters->FindParam(&isSSA,FlowequationIsSSAEnum); 32 32 femmodel->parameters->FindParam(&isL1L2,FlowequationIsL1L2Enum); 33 femmodel->parameters->FindParam(&isM LHO,FlowequationIsMLHOEnum);33 femmodel->parameters->FindParam(&isMOLHO,FlowequationIsMOLHOEnum); 34 34 femmodel->parameters->FindParam(&isHO,FlowequationIsHOEnum); 35 35 femmodel->parameters->FindParam(&isFS,FlowequationIsFSEnum); … … 75 75 76 76 /*Compute stressbalance for SSA L1L2 HO and FS*/ 77 if(isSSA || isL1L2 || isM LHO || isHO || isFS){77 if(isSSA || isL1L2 || isMOLHO || isHO || isFS){ 78 78 analysis = new StressbalanceAnalysis(); 79 79 analysis->Core(femmodel); … … 82 82 83 83 /*Compute vertical velocities*/ 84 if (domaintype==Domain3DEnum && (isSIA || isSSA || isL1L2 || isM LHO || isHO)){84 if (domaintype==Domain3DEnum && (isSIA || isSSA || isL1L2 || isMOLHO || isHO)){ 85 85 86 86 /*We need basal melt rates for vertical velocity*/ -
issm/trunk/src/c/cores/transient_core.cpp
r26744 r27035 16 16 #include "../modules/modules.h" 17 17 #include "../solutionsequences/solutionsequences.h" 18 19 #ifdef _HAVE_CODIPACK_ 20 extern CoDi_global codi_global; 21 #endif 18 22 19 23 /*Prototypes*/ … … 74 78 if(VerboseSolution()){ 75 79 _printf0_("iteration " << step << "/" << ceil((finaltime-time)/dt)+step << \ 76 " time [yr]: " << setprecision(4)<< time/yts << " (time step: " << dt/yts << ")\n");80 " time [yr]: " <<std::fixed<<setprecision(2)<< time/yts << " (time step: " << dt/yts << ")\n"); 77 81 } 78 82 bool save_results=false; … … 150 154 femmodel->parameters->FindParam(&issampling,TransientIssamplingEnum); 151 155 femmodel->parameters->FindParam(&numoutputs,TransientNumRequestedOutputsEnum); 152 femmodel->parameters->FindParam(&isstochasticforcing,StochasticForcingIsStochasticForcingEnum); 156 femmodel->parameters->FindParam(&isstochasticforcing,StochasticForcingIsStochasticForcingEnum); 153 157 154 158 #if defined(_HAVE_OCEAN_ ) … … 275 279 276 280 #ifdef _HAVE_CODIPACK_ 277 void transient_ad(FemModel* femmodel){/*{{{*/281 double transient_ad(FemModel* femmodel, double* G, double* Jlist){/*{{{*/ 278 282 279 283 /*parameters: */ … … 282 286 bool isoceancoupling; 283 287 int step,timestepping; 284 int checkpoint_frequency ;288 int checkpoint_frequency,num_responses; 285 289 286 290 /*Get rank*/ … … 293 297 femmodel->parameters->FindParam(&yts,ConstantsYtsEnum); 294 298 femmodel->parameters->FindParam(×tepping,TimesteppingTypeEnum); 299 femmodel->parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum); 295 300 femmodel->parameters->FindParam(&checkpoint_frequency,SettingsCheckpointFrequencyEnum); _assert_(checkpoint_frequency>0); 296 301 … … 343 348 344 349 /*Go through our dependent variables, and compute the response:*/ 345 if(finaltime==time){ 346 DataSet* dependent_objects=((DataSetParam*)femmodel->parameters->FindParamObject(AutodiffDependentObjectsEnum))->value; 347 for(Object* & object:dependent_objects->objects){ 348 DependentObject* dep=(DependentObject*)object; 349 dep->Responsex(&output_value,femmodel); 350 dep->AddValue(output_value); 351 } 350 DataSet* dependent_objects=((DataSetParam*)femmodel->parameters->FindParamObject(AutodiffDependentObjectsEnum))->value; 351 for(Object* & object:dependent_objects->objects){ 352 DependentObject* dep=(DependentObject*)object; 353 dep->Responsex(&output_value,femmodel); 354 dep->AddValue(output_value); 352 355 } 353 356 … … 395 398 SetControlInputsFromVectorx(femmodel,X); 396 399 397 IssmDouble J = 0.; 400 IssmDouble J = 0.; 401 int count = 0; 398 402 DataSet* dependent_objects=((DataSetParam*)femmodel->parameters->FindParamObject(AutodiffDependentObjectsEnum))->value; 399 403 for(Object* & object:dependent_objects->objects){ 400 404 DependentObject* dep=(DependentObject*)object; 401 J += dep->GetValue(); 402 } 403 tape_codi.registerOutput(J); 405 IssmDouble output_value = dep->GetValue(); 406 407 408 J += output_value; 409 410 tape_codi.registerOutput(J); 411 #if _CODIPACK_MAJOR_==2 412 codi_global.output_indices.push_back(J.getIdentifier()); 413 #elif _CODIPACK_MAJOR_==1 414 codi_global.output_indices.push_back(J.getGradientData()); 415 #else 416 #error "_CODIPACK_MAJOR_ not supported" 417 #endif 418 419 /*Keep track of output for printing*/ 420 Jlist[count] = output_value.getValue(); 421 count++; 422 } 423 Jlist[count] = J.getValue(); 424 _assert_(count == num_responses); 404 425 405 426 tape_codi.setPassive(); 406 if(IssmComm::GetRank()==0) J.gradient() = 1.0; 407 tape_codi.evaluate(); 427 428 if(VerboseAutodiff())_printf0_(" CoDiPack fos_reverse\n"); 429 for(int i=0;i<num_responses;i++){ 430 if(my_rank==0) tape_codi.setGradient(codi_global.output_indices[i],1.0); 431 tape_codi.evaluate(); 432 } 408 433 409 434 /*Initialize Xb and Yb*/ … … 444 469 femmodel->parameters->SetParam(thisstep,StepEnum); 445 470 femmodel->parameters->SetParam(thisdt,TimesteppingTimeStepEnum); 446 _printf0_("step "<<thisstep<<" ("<<ii+1<<"/"<<checkpoint_frequency<<") time [yr]: "\ 447 <<std::fixed<<std::setprecision(2)<<thistime/yts<< " (time step: " << thisdt/yts << ")\n"); 471 472 if(VerboseSolution()){ 473 _printf0_("step "<<thisstep<<" ("<<ii+1<<"/"<<checkpoint_frequency<<") time [yr]: "\ 474 <<std::fixed<<std::setprecision(2)<<thistime/yts<< " (time step: " << thisdt/yts << ")\n"); 475 } 476 448 477 transient_step(femmodel); 449 478 450 479 /*Go through our dependent variables, and compute the response:*/ 451 if(thistime==finaltime){ 452 DataSet* dependent_objects=((DataSetParam*)femmodel->parameters->FindParamObject(AutodiffDependentObjectsEnum))->value; 453 for(Object* & object:dependent_objects->objects){ 454 DependentObject* dep=(DependentObject*)object; 455 dep->Responsex(&output_value,femmodel); 456 dep->AddValue(output_value); 457 } 480 DataSet* dependent_objects=((DataSetParam*)femmodel->parameters->FindParamObject(AutodiffDependentObjectsEnum))->value; 481 for(Object* & object:dependent_objects->objects){ 482 DependentObject* dep=(DependentObject*)object; 483 dep->Responsex(&output_value,femmodel); 484 dep->AddValue(output_value); 458 485 } 459 486 … … 484 511 for(int i=0; i<Xsize; i++) Xb[i] += X[i].gradient(); 485 512 } 513 486 514 /*Clear tape*/ 487 515 tape_codi.reset(); 488 516 489 517 /*Broadcast gradient to other ranks (make sure to sum all gradients)*/ 490 double* gradient=xNew<double>(Xsize); 491 ISSM_MPI_Allreduce(Xb,gradient,Xsize,ISSM_MPI_PDOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 492 493 /*Now set final gradient*/ 494 IssmDouble* aG=xNew<IssmDouble>(Xsize); 495 for(int i=0;i<Xsize;i++) aG[i] = reCast<IssmDouble>(gradient[i]); 496 xDelete<double>(gradient); 497 ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,aG); 498 xDelete<IssmDouble>(aG); 499 518 ISSM_MPI_Allreduce(Xb,G,Xsize,ISSM_MPI_PDOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 519 520 /*Cleanup and return misfit*/ 500 521 xDelete<IssmDouble>(X); 501 522 xDelete<double>(Xb); 502 523 xDelete<double>(Yb); 503 524 xDelete<int>(Yin); 525 return J.getValue(); 504 526 }/*}}}*/ 505 527 #endif -
issm/trunk/src/c/datastructures/DataSet.cpp
r26744 r27035 261 261 this->AddObject(cfsurf); 262 262 } 263 else if(obj_enum==CfsurfacelogvelEnum){ 264 Cfsurfacelogvel* cfsurf=new Cfsurfacelogvel(); 265 cfsurf->Marshall(marshallhandle); 266 this->AddObject(cfsurf); 267 } 263 268 else if(obj_enum==MassfluxatgateEnum){ 264 269 Massfluxatgate<IssmDouble>* massfluxgate=new Massfluxatgate<IssmDouble>(); -
issm/trunk/src/c/modules/Calvingx/Calvingx.cpp
r26744 r27035 15 15 /*Calculate calving rate*/ 16 16 switch(calvinglaw){ 17 case DefaultCalvingEnum:18 17 case CalvingMinthicknessEnum: 19 18 case CalvingHabEnum: 19 femmodel->ElementOperationx(&Element::CalvingSetZeroRate); 20 break; 21 case DefaultCalvingEnum: 22 femmodel->ElementOperationx(&Element::CalvingFromRate); 20 23 break; 21 24 case CalvingCrevasseDepthEnum: 25 femmodel->ElementOperationx(&Element::CalvingSetZeroRate); 26 /*rate is 0 but we need to calculate a few things to determine where it will calve*/ 22 27 femmodel->StrainRateparallelx(); 23 28 femmodel->StrainRateeffectivex(); … … 35 40 femmodel->ElementOperationx(&Element::CalvingRateVonmises); 36 41 break; 42 case CalvingTestEnum: 43 femmodel->ElementOperationx(&Element::CalvingRateTest); 44 break; 45 case CalvingParameterizationEnum: 46 femmodel->ElementOperationx(&Element::CalvingRateParameterization); 47 break; 37 48 default: 38 49 _error_("Caving law "<<EnumToStringx(calvinglaw)<<" not supported yet"); -
issm/trunk/src/c/modules/FloatingiceMeltingRatex/FloatingiceMeltingRatex.cpp
r26744 r27035 45 45 if(VerboseSolution())_printf0_(" call BeckmannGoosse Floating melting rate module\n"); 46 46 BeckmannGoosseFloatingiceMeltingRatex(femmodel); 47 break; 48 case AutoregressionLinearFloatingMeltRateEnum: 49 if(VerboseSolution())_printf0_(" call Autoregression Linear Floating melting rate module\n"); 50 AutoregressionLinearFloatingiceMeltingRatex(femmodel); 47 51 break; 48 52 default: … … 206 210 } 207 211 /*}}}*/ 212 void AutoregressionLinearFloatingiceMeltingRateInitx(FemModel* femmodel){/*{{{*/ 213 214 /*Initialization step of AutoregressionLinearFloatingiceMeltingRatex*/ 215 int M,N,Nphi,arorder,numbasins,my_rank; 216 IssmDouble starttime,tstep_ar,tinit_ar; 217 femmodel->parameters->FindParam(&numbasins,BasalforcingsLinearNumBasinsEnum); 218 femmodel->parameters->FindParam(&arorder,BasalforcingsAutoregressiveOrderEnum); 219 IssmDouble* beta0 = NULL; 220 IssmDouble* beta1 = NULL; 221 IssmDouble* phi = NULL; 222 femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum); 223 femmodel->parameters->FindParam(&tstep_ar,BasalforcingsAutoregressionTimestepEnum); 224 femmodel->parameters->FindParam(&tinit_ar,BasalforcingsAutoregressionInitialTimeEnum); 225 femmodel->parameters->FindParam(&beta0,&M,BasalforcingsBeta0Enum); _assert_(M==numbasins); 226 femmodel->parameters->FindParam(&beta1,&M,BasalforcingsBeta1Enum); _assert_(M==numbasins); 227 femmodel->parameters->FindParam(&phi,&M,&Nphi,BasalforcingsPhiEnum); _assert_(M==numbasins); _assert_(Nphi==arorder); 228 229 /*AR model spin-up with 0 noise to initialize BasalforcingsDeepwaterMeltingRateValuesAutoregressionEnum (688 = log(0.001)/log(0.99): decaying time of inluence of phi[0]=0.99 to 0.001 of beta_0*/ 230 int nspin = 688; 231 for(Object* &object:femmodel->elements->objects){ 232 Element* element = xDynamicCast<Element*>(object); //generate element object 233 element->AutoregressionInit(numbasins,arorder,nspin,starttime,tstep_ar,tinit_ar,beta0,beta1,phi,BasalforcingsDeepwaterMeltingRateAutoregressionEnum); 234 } 235 /*Cleanup*/ 236 xDelete<IssmDouble>(beta0); 237 xDelete<IssmDouble>(beta1); 238 xDelete<IssmDouble>(phi); 239 }/*}}}*/ 240 void AutoregressionLinearFloatingiceMeltingRatex(FemModel* femmodel){/*{{{*/ 241 242 /*Get time parameters*/ 243 IssmDouble time,dt,starttime,tstep_ar; 244 femmodel->parameters->FindParam(&time,TimeEnum); 245 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 246 femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum); 247 femmodel->parameters->FindParam(&tstep_ar,BasalforcingsAutoregressionTimestepEnum); 248 249 /*Initialize module at first time step*/ 250 if(time<=starttime+dt){AutoregressionLinearFloatingiceMeltingRateInitx(femmodel);} 251 /*Determine if this is a time step for the AR model*/ 252 bool isstepforar = false; 253 254 #ifndef _HAVE_AD_ 255 if((fmod(time,tstep_ar)<fmod((time-dt),tstep_ar)) || (time<=starttime+dt) || tstep_ar==dt) isstepforar = true; 256 #else 257 _error_("not implemented yet"); 258 #endif 259 260 /*Load parameters*/ 261 bool isstochastic; 262 bool isdeepmeltingstochastic = false; 263 int M,N,Nphi,arorder,numbasins,my_rank; 264 femmodel->parameters->FindParam(&numbasins,BasalforcingsLinearNumBasinsEnum); 265 femmodel->parameters->FindParam(&arorder,BasalforcingsAutoregressiveOrderEnum); 266 IssmDouble tinit_ar; 267 IssmDouble* beta0 = NULL; 268 IssmDouble* beta1 = NULL; 269 IssmDouble* phi = NULL; 270 IssmDouble* deepwaterel = NULL; 271 IssmDouble* upperwaterel = NULL; 272 IssmDouble* upperwatermelt = NULL; 273 IssmDouble* perturbation = NULL; 274 275 /*Get autoregressive parameters*/ 276 femmodel->parameters->FindParam(&tinit_ar,BasalforcingsAutoregressionInitialTimeEnum); 277 femmodel->parameters->FindParam(&beta0,&M,BasalforcingsBeta0Enum); _assert_(M==numbasins); 278 femmodel->parameters->FindParam(&beta1,&M,BasalforcingsBeta1Enum); _assert_(M==numbasins); 279 femmodel->parameters->FindParam(&phi,&M,&Nphi,BasalforcingsPhiEnum); _assert_(M==numbasins); _assert_(Nphi==arorder); 280 281 /*Get basin-specific parameters*/ 282 femmodel->parameters->FindParam(&deepwaterel,&M,BasalforcingsDeepwaterElevationEnum); _assert_(M==numbasins); 283 femmodel->parameters->FindParam(&upperwaterel,&M,BasalforcingsUpperwaterElevationEnum); _assert_(M==numbasins); 284 femmodel->parameters->FindParam(&upperwatermelt,&M,BasalforcingsUpperwaterMeltingRateEnum); _assert_(M==numbasins); 285 286 /*Evaluate whether stochasticity on DeepwaterMeltingRate is requested*/ 287 femmodel->parameters->FindParam(&isstochastic,StochasticForcingIsStochasticForcingEnum); 288 if(isstochastic){ 289 int numstochasticfields; 290 int* stochasticfields; 291 femmodel->parameters->FindParam(&numstochasticfields,StochasticForcingNumFieldsEnum); 292 femmodel->parameters->FindParam(&stochasticfields,&N,StochasticForcingFieldsEnum); _assert_(N==numstochasticfields); 293 for(int i=0;i<numstochasticfields;i++){ 294 if(stochasticfields[i]==BasalforcingsDeepwaterMeltingRateAutoregressionEnum) isdeepmeltingstochastic = true; 295 } 296 xDelete<int>(stochasticfields); 297 } 298 /*Time elapsed with respect to AR model initial time*/ 299 IssmDouble telapsed_ar = time-tinit_ar; 300 301 /*Loop over each element to compute FloatingiceMeltingRate at vertices*/ 302 for(Object* &object:femmodel->elements->objects){ 303 Element* element = xDynamicCast<Element*>(object); 304 /*Compute autoregression*/ 305 element->Autoregression(isstepforar,arorder,telapsed_ar,beta0,beta1,phi,isdeepmeltingstochastic,BasalforcingsDeepwaterMeltingRateAutoregressionEnum); 306 element->BasinLinearFloatingiceMeltingRate(deepwaterel,upperwatermelt,upperwaterel,perturbation); 307 } 308 309 /*Cleanup*/ 310 xDelete<IssmDouble>(beta0); 311 xDelete<IssmDouble>(beta1); 312 xDelete<IssmDouble>(phi); 313 xDelete<IssmDouble>(deepwaterel); 314 xDelete<IssmDouble>(upperwaterel); 315 xDelete<IssmDouble>(upperwatermelt); 316 xDelete<IssmDouble>(perturbation); 317 }/*}}}*/ -
issm/trunk/src/c/modules/FloatingiceMeltingRatex/FloatingiceMeltingRatex.h
r24313 r27035 16 16 void FloatingiceMeltingRateIsmip6x(FemModel* femmodel); 17 17 void BeckmannGoosseFloatingiceMeltingRatex(FemModel* femmodel); 18 void AutoregressionLinearFloatingiceMeltingRateInitx(FemModel* femmodel); 19 void AutoregressionLinearFloatingiceMeltingRatex(FemModel* femmodel); 18 20 19 21 #endif /* _FloatingiceMeltingRatex_H*/ -
issm/trunk/src/c/modules/FrontalForcingsx/FrontalForcingsx.cpp
r26744 r27035 46 46 femmodel->parameters->FindParam(&phi,&M,&Nphi,FrontalForcingsPhiEnum); _assert_(M==numbasins); _assert_(Nphi==arorder); 47 47 48 /*AR model spin-up with 0 noise to initialize ThermalforcingValuesAutoregressionEnum */49 int nspin {2*arorder+5};48 /*AR model spin-up with 0 noise to initialize ThermalforcingValuesAutoregressionEnum (688 = log(0.001)/log(0.99): decaying time of inluence of phi[0]=0.99 to 0.001 of beta_0*/ 49 int nspin = 688; 50 50 for(Object* &object:femmodel->elements->objects){ 51 51 Element* element = xDynamicCast<Element*>(object); //generate element object -
issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h
r26744 r27035 9 9 /* local prototypes: */ 10 10 void GetVectorFromInputsx(Vector<IssmDouble>** pvector,FemModel* femmodel,int name,int type); 11 void GetVectoronBaseFromInputsx(Vector<IssmDouble>** pvector,FemModel* femmodel,int name,int type);12 11 void GetVectorFromInputsx(Vector<IssmDouble>** pvector,FemModel* femmodel,int name,int type,IssmDouble time); 13 12 void GetVectorFromInputsx(IssmDouble** pvector,FemModel* femmodel,int name,int type); 14 void GetVectoronBaseFromInputsx(IssmDouble** pvector,FemModel* femmodel,int name,int type);15 13 void GetVectorFromInputsx(IssmDouble** pvector,int* pvector_size, FemModel* femmodel,int name); 16 14 15 void GetVectoronBaseFromInputsx(IssmDouble** pvector,FemModel* femmodel,int name,int type); 16 void GetVectoronBaseFromInputsx(Vector<IssmDouble>** pvector,FemModel* femmodel,int name,int type); 17 17 18 #endif /* _GETVECTORFROMINPUTSXX_H */ -
issm/trunk/src/c/modules/KillIcebergsx/KillIcebergsx.cpp
r25836 r27035 9 9 #include "../InputUpdateFromVectorx/InputUpdateFromVectorx.h" 10 10 11 voidKillIcebergsx(FemModel* femmodel){11 int KillIcebergsx(FemModel* femmodel){ 12 12 13 13 /*Intermediaries*/ … … 18 18 IssmDouble *local_mask = xNewZeroInit<IssmDouble>(nbv_local); 19 19 bool *element_flag = xNewZeroInit<bool>(femmodel->elements->Size()); 20 IssmDouble ice; 20 21 21 22 /*Step 1, go through all elements and put 1 in local_mask if the element is grounded*/ … … 27 28 element_flag[i] = true; 28 29 } 29 else{ 30 if(element->IsGrounded()){ 30 else { 31 if(element->IsAllGrounded()){ 32 /* only look at element with ice but not fully grounded */ 31 33 int numvertices = element->GetNumberOfVertices(); 32 for(int v=0;v<numvertices;v++) local_mask[element->vertices[v]->Lid()] = 1.; 34 Gauss* gauss=element->NewGauss(); 35 Input* icelevel_input = element->GetInput(MaskIceLevelsetEnum); _assert_(icelevel_input); 36 37 for(int v=0;v<numvertices;v++) { 38 gauss->GaussVertex(v); 39 icelevel_input->GetInputValue(&ice,gauss); 40 /* The initial mask is very strict, we look at all grounded elements and set the mask for ice nodes only. */ 41 if (ice < 0) local_mask[element->vertices[v]->Lid()] = 1.; 42 } 43 delete gauss; 33 44 } 34 45 } … … 48 59 /*Local iterations on partition*/ 49 60 bool keepgoing = true; 50 int didsomething = 0;51 61 int iter = 1; 52 62 while(keepgoing){ … … 54 64 55 65 keepgoing = false; 56 didsomething = 0;57 66 int i=0; 58 67 for(Object* & object : femmodel->elements->objects){ … … 62 71 int numvertices = element->GetNumberOfVertices(); 63 72 bool found1 = false; 73 IssmDouble sumlocalmask = 0.; 74 64 75 for(int j=0;j<numvertices;j++){ 65 76 lid = element->vertices[j]->Lid(); 66 if(local_mask[lid]>0.){ 77 /*we need to have at least a sharing edge, to extend the mask*/ 78 sumlocalmask += local_mask[lid]; 79 if(sumlocalmask > 1.5){ 67 80 found1 = true; 68 81 break; … … 73 86 for(int j=0;j<numvertices;j++){ 74 87 lid = element->vertices[j]->Lid(); 75 if(local_mask[lid]==0.){ 76 local_mask[lid]=1.; 77 keepgoing = true; 78 didsomething = 1; 79 } 88 local_mask[lid]=1.; 80 89 } 90 keepgoing = true; 81 91 } 82 92 } … … 99 109 xDelete<bool>(element_flag); 100 110 111 int killbergReinit = 0; 101 112 /*OK, now deactivate iceberg and count the number of deactivated vertices*/ 102 113 for(Object* & object : femmodel->elements->objects){ … … 120 131 element->AddInput(MaskIceLevelsetEnum,values,P1Enum); 121 132 xDelete<IssmDouble>(values); 133 killbergReinit += 1; 122 134 } 123 135 } 124 136 } 125 126 137 /*cleanup*/ 127 138 xDelete<IssmDouble>(local_mask); 139 140 /*Recompute the sign distance for the levelset function*/ 141 return killbergReinit; 128 142 } -
issm/trunk/src/c/modules/KillIcebergsx/KillIcebergsx.h
r23992 r27035 6 6 7 7 /* local prototypes: */ 8 voidKillIcebergsx(FemModel* femmodel);8 int KillIcebergsx(FemModel* femmodel); 9 9 10 10 #endif -
issm/trunk/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp
r26744 r27035 311 311 /*cfsurfacelogvel variables: */ 312 312 int num_cfsurfacelogvels; 313 char** cfsurfacelogvel_name = NULL; 314 char** cfsurfacelogvel_definitionstring = NULL; 315 IssmDouble** cfsurfacelogvel_vxobs = NULL; 316 IssmDouble** cfsurfacelogvel_vyobs = NULL; 317 char** cfsurfacelogvel_vxobs_string = NULL; 318 char** cfsurfacelogvel_vyobs_string = NULL; 319 int* cfsurfacelogvel_observation_M = NULL; 320 int* cfsurfacelogvel_observation_N = NULL; 321 IssmDouble** cfsurfacelogvel_weights = NULL; 322 int* cfsurfacelogvel_weights_M = NULL; 323 int* cfsurfacelogvel_weights_N = NULL; 324 char** cfsurfacelogvel_weightstring = NULL; 325 IssmDouble* cfsurfacelogvel_datatime = NULL; 326 327 /*Fetch name, modeltring, observation, observationtring, etc ... (see src/m/classes/cfsurfacelogvel.m): */ 328 iomodel->FetchMultipleData(&cfsurfacelogvel_name,&num_cfsurfacelogvels, "md.cfsurfacelogvel.name"); 329 iomodel->FetchMultipleData(&cfsurfacelogvel_definitionstring,&num_cfsurfacelogvels, "md.cfsurfacelogvel.definitionstring"); 330 iomodel->FetchMultipleData(&cfsurfacelogvel_vxobs,&cfsurfacelogvel_observation_M,&cfsurfacelogvel_observation_N,&num_cfsurfacelogvels, "md.cfsurfacelogvel.vxobs"); 331 iomodel->FetchMultipleData(&cfsurfacelogvel_vxobs_string,&num_cfsurfacelogvels, "md.cfsurfacelogvel.vxobs_string"); 332 iomodel->FetchMultipleData(&cfsurfacelogvel_vyobs,&cfsurfacelogvel_observation_M,&cfsurfacelogvel_observation_N,&num_cfsurfacelogvels, "md.cfsurfacelogvel.vyobs"); 333 iomodel->FetchMultipleData(&cfsurfacelogvel_vyobs_string,&num_cfsurfacelogvels, "md.cfsurfacelogvel.vyobs_string"); iomodel->FetchMultipleData(&cfsurfacelogvel_weights,&cfsurfacelogvel_weights_M,&cfsurfacelogvel_weights_N,&num_cfsurfacelogvels, "md.cfsurfacelogvel.weights"); 334 iomodel->FetchMultipleData(&cfsurfacelogvel_weightstring,&num_cfsurfacelogvels, "md.cfsurfacelogvel.weights_string"); 335 iomodel->FetchMultipleData(&cfsurfacelogvel_datatime,&num_cfsurfacelogvels, "md.cfsurfacelogvel.datatime"); 313 char **cfsurfacelogvel_name = NULL; 314 char **cfsurfacelogvel_definitionstring = NULL; 315 IssmDouble **cfsurfacelogvel_vxobs = NULL; 316 IssmDouble **cfsurfacelogvel_vyobs = NULL; 317 char **cfsurfacelogvel_vxobs_string = NULL; 318 char **cfsurfacelogvel_vyobs_string = NULL; 319 int *cfsurfacelogvel_observation_M = NULL; 320 int *cfsurfacelogvel_observation_N = NULL; 321 IssmDouble **cfsurfacelogvel_weights = NULL; 322 int *cfsurfacelogvel_weights_M = NULL; 323 int *cfsurfacelogvel_weights_N = NULL; 324 char **cfsurfacelogvel_weightstring = NULL; 325 IssmDouble *cfsurfacelogvel_datatime = NULL; 326 327 /*Fetch name, modeltring, observation, observationtring, etc ... (see src/m/classes/cfsurfacelogvel.m): */ 328 iomodel->FetchMultipleData(&cfsurfacelogvel_name,&num_cfsurfacelogvels,"md.cfsurfacelogvel.name"); 329 iomodel->FetchMultipleData(&cfsurfacelogvel_definitionstring,&num_cfsurfacelogvels,"md.cfsurfacelogvel.definitionstring"); 330 iomodel->FetchMultipleData(&cfsurfacelogvel_vxobs,&cfsurfacelogvel_observation_M,&cfsurfacelogvel_observation_N,&num_cfsurfacelogvels,"md.cfsurfacelogvel.vxobs"); 331 iomodel->FetchMultipleData(&cfsurfacelogvel_vxobs_string,&num_cfsurfacelogvels,"md.cfsurfacelogvel.vxobs_string"); 332 iomodel->FetchMultipleData(&cfsurfacelogvel_vyobs,NULL,NULL,&num_cfsurfacelogvels,"md.cfsurfacelogvel.vyobs"); 333 iomodel->FetchMultipleData(&cfsurfacelogvel_vyobs_string,&num_cfsurfacelogvels,"md.cfsurfacelogvel.vyobs_string"); 334 iomodel->FetchMultipleData(&cfsurfacelogvel_weights,&cfsurfacelogvel_weights_M,&cfsurfacelogvel_weights_N,&num_cfsurfacelogvels,"md.cfsurfacelogvel.weights"); 335 iomodel->FetchMultipleData(&cfsurfacelogvel_weightstring,&num_cfsurfacelogvels,"md.cfsurfacelogvel.weights_string"); 336 iomodel->FetchMultipleData(&cfsurfacelogvel_datatime,&num_cfsurfacelogvels,"md.cfsurfacelogvel.datatime"); 336 337 337 338 for(j=0;j<num_cfsurfacelogvels;j++){ -
issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp
r26744 r27035 252 252 break; 253 253 case BeckmannGoosseFloatingMeltRateEnum: 254 break; 255 case AutoregressionLinearFloatingMeltRateEnum: 256 /*Add parameters that are not in standard nbvertices format*/ 257 parameters->AddObject(iomodel->CopyConstantObject("md.basalforcings.num_basins",BasalforcingsLinearNumBasinsEnum)); 258 parameters->AddObject(iomodel->CopyConstantObject("md.basalforcings.ar_order",BasalforcingsAutoregressiveOrderEnum)); 259 parameters->AddObject(iomodel->CopyConstantObject("md.basalforcings.ar_initialtime",BasalforcingsAutoregressionInitialTimeEnum)); 260 parameters->AddObject(iomodel->CopyConstantObject("md.basalforcings.ar_timestep",BasalforcingsAutoregressionTimestepEnum)); 261 iomodel->FetchData(&transparam,&M,&N,"md.basalforcings.beta0"); 262 parameters->AddObject(new DoubleVecParam(BasalforcingsBeta0Enum,transparam,N)); 263 xDelete<IssmDouble>(transparam); 264 iomodel->FetchData(&transparam,&M,&N,"md.basalforcings.beta1"); 265 parameters->AddObject(new DoubleVecParam(BasalforcingsBeta1Enum,transparam,N)); 266 xDelete<IssmDouble>(transparam); 267 iomodel->FetchData(&transparam,&M,&N,"md.basalforcings.phi"); 268 parameters->AddObject(new DoubleMatParam(BasalforcingsPhiEnum,transparam,M,N)); 269 xDelete<IssmDouble>(transparam); 270 iomodel->FetchData(&transparam,&M,&N,"md.basalforcings.upperwater_melting_rate"); 271 parameters->AddObject(new DoubleVecParam(BasalforcingsUpperwaterMeltingRateEnum,transparam,N)); 272 xDelete<IssmDouble>(transparam); 273 iomodel->FetchData(&transparam,&M,&N,"md.basalforcings.upperwater_elevation"); 274 parameters->AddObject(new DoubleVecParam(BasalforcingsUpperwaterElevationEnum,transparam,N)); 275 xDelete<IssmDouble>(transparam); 276 iomodel->FetchData(&transparam,&M,&N,"md.basalforcings.deepwater_elevation"); 277 parameters->AddObject(new DoubleVecParam(BasalforcingsDeepwaterElevationEnum,transparam,N)); 278 xDelete<IssmDouble>(transparam); 254 279 break; 255 280 default: … … 403 428 parameters->AddObject(iomodel->CopyConstantObject("md.smb.ar_initialtime",SmbAutoregressionInitialTimeEnum)); 404 429 parameters->AddObject(iomodel->CopyConstantObject("md.smb.ar_timestep",SmbAutoregressionTimestepEnum)); 430 parameters->AddObject(iomodel->CopyConstantObject("md.smb.num_bins",SmbNumElevationBinsEnum)); 405 431 iomodel->FetchData(&transparam,&M,&N,"md.smb.beta0"); 406 432 parameters->AddObject(new DoubleVecParam(SmbBeta0Enum,transparam,N)); … … 412 438 parameters->AddObject(new DoubleMatParam(SmbPhiEnum,transparam,M,N)); 413 439 xDelete<IssmDouble>(transparam); 414 break; 440 iomodel->FetchData(&transparam,&M,&N,"md.smb.lapserates"); 441 parameters->AddObject(new DoubleMatParam(SmbLapseRatesEnum,transparam,M,N)); 442 xDelete<IssmDouble>(transparam); 443 iomodel->FetchData(&transparam,&M,&N,"md.smb.elevationbins"); 444 parameters->AddObject(new DoubleMatParam(SmbElevationBinsEnum,transparam,M,N)); 445 xDelete<IssmDouble>(transparam); 446 iomodel->FetchData(&transparam,&M,&N,"md.smb.refelevation"); 447 parameters->AddObject(new DoubleVecParam(SmbRefElevationEnum,transparam,N)); 448 xDelete<IssmDouble>(transparam); 449 break; 415 450 case SMBgembEnum: 416 451 parameters->AddObject(iomodel->CopyConstantObject("md.smb.aIce",SmbAIceEnum)); … … 486 521 } 487 522 else if(hydrology_model==HydrologyGlaDSEnum){ 523 /*Nothing to add*/ 524 } 525 else if(hydrology_model==HydrologyTwsEnum){ 488 526 /*Nothing to add*/ 489 527 } … … 508 546 parameters->AddObject(iomodel->CopyConstantObject("md.stochasticforcing.num_fields",StochasticForcingNumFieldsEnum)); 509 547 parameters->AddObject(iomodel->CopyConstantObject("md.stochasticforcing.defaultdimension",StochasticForcingDefaultDimensionEnum)); 548 parameters->AddObject(iomodel->CopyConstantObject("md.stochasticforcing.stochastictimestep",StochasticForcingTimestepEnum)); 510 549 iomodel->FindConstant(&fields,&num_fields,"md.stochasticforcing.fields"); 511 550 if(num_fields<1) _error_("no stochasticforcing fields found"); -
issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
r26744 r27035 81 81 UpdateElementsAndMaterialsDakota(elements,inputs,materials,iomodel); 82 82 #endif 83 if(solution_enum==TransientSolutionEnum) UpdateElementsTransient(elements,parameters,inputs,iomodel); 84 83 if(solution_enum==TransientSolutionEnum){ 84 UpdateParametersTransient(parameters,iomodel); 85 UpdateElementsTransient(elements,parameters,inputs,iomodel); 86 } 85 87 /*Output definitions dataset: */ 86 88 if(VerboseMProcessor()) _printf0_(" creating output definitions" << "\n"); -
issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h
r25836 r27035 24 24 void UpdateElementsAndMaterialsDakota(Elements* elements,Inputs* inputs,Materials* materials, IoModel* iomodel); 25 25 void UpdateElementsTransient(Elements* elements,Parameters* parameters,Inputs* inputs,IoModel* iomodel); 26 void UpdateParametersTransient(Parameters* parameters,IoModel* iomodel); 26 27 void CreateNodes(Nodes*nodes, IoModel* iomodel,int analysis,int finite_element,bool isamr=false,int approximation=NoneApproximationEnum,int* approximations=NULL); 27 28 -
issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp
r25836 r27035 40 40 xDelete<IssmDouble>(serial_vector); 41 41 } 42 #ifdef _HAVE_AD_ 43 void SetControlInputsFromVectorx(FemModel* femmodel,IssmPDouble* vector){ 44 45 /*Get total size and recast*/ 46 int num_controls; 47 int* M = NULL; 48 int* N = NULL; 49 femmodel->parameters->FindParam(&num_controls,InversionNumControlParametersEnum); 50 femmodel->parameters->FindParam(&M,NULL,ControlInputSizeMEnum); 51 femmodel->parameters->FindParam(&N,NULL,ControlInputSizeNEnum); 52 53 int size = 0; 54 for(int i=0;i<num_controls;i++) size += M[i]*N[i]; 55 56 IssmDouble* serial_vector=xNew<IssmDouble>(size); 57 for(int i=0;i<size;i++) serial_vector[i] = reCast<IssmDouble>(vector[i]); 58 59 SetControlInputsFromVectorx(femmodel,serial_vector); 60 61 xDelete<IssmDouble>(serial_vector); 62 xDelete<int>(M); 63 xDelete<int>(N); 64 } 65 #endif -
issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.h
r18301 r27035 11 11 void SetControlInputsFromVectorx(FemModel* femmodel,IssmDouble* vector); 12 12 13 #ifdef _HAVE_AD_ 14 void SetControlInputsFromVectorx(FemModel* femmodel,IssmPDouble* vector); 15 #endif 16 13 17 #endif -
issm/trunk/src/c/modules/Solverx/Solverx.cpp
r24686 r27035 65 65 /*Check convergence*/ 66 66 if(solver_residue>solver_residue_threshold){ 67 _printf0_("solver residue too high!: norm(KU-F)/norm(F)=" << solver_residue << " > "<<solver_residue_threshold<<" (md.settings.solver_residue_threshold) ");67 _printf0_("solver residue too high!: norm(KU-F)/norm(F)=" << solver_residue << " > "<<solver_residue_threshold<<" (md.settings.solver_residue_threshold)\n"); 68 68 return false; 69 69 } -
issm/trunk/src/c/modules/StochasticForcingx/StochasticForcingx.cpp
r26676 r27035 11 11 void StochasticForcingx(FemModel* femmodel){/*{{{*/ 12 12 13 14 //VV testing (12Nov)15 /*16 IssmDouble timeVV,dtVV,starttimeVV;17 femmodel->parameters->FindParam(&timeVV,TimeEnum);18 femmodel->parameters->FindParam(&dtVV,TimesteppingTimeStepEnum);19 femmodel->parameters->FindParam(&starttimeVV,TimesteppingStartTimeEnum);20 IssmDouble valMean = 0;21 IssmDouble valSdev = 0.5;22 int seed;23 //seed = reCast<int,IssmDouble>((timeVV-starttimeVV)/dtVV);24 seed = -1;25 IssmDouble rdmVV;26 univariateNormal_test0(&rdmVV,valMean,valSdev,seed);27 _printf_("VV rdmVV: "<<rdmVV<<'\n');28 */29 13 30 14 /*Retrieve parameters*/ … … 42 26 femmodel->parameters->FindParam(&covariance,&M,&N,StochasticForcingCovarianceEnum); _assert_(M==dimtot); _assert_(N==dimtot); 43 27 28 /*Check if this is a timestep for new noiseterms computation*/ 29 bool isstepforstoch = false; 30 IssmDouble time,dt,starttime,tstep_stoch; 31 femmodel->parameters->FindParam(&time,TimeEnum); 32 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 33 femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum); 34 femmodel->parameters->FindParam(&tstep_stoch,StochasticForcingTimestepEnum); 35 36 #ifndef _HAVE_AD_ 37 if((fmod(time,tstep_stoch)<fmod((time-dt),tstep_stoch)) || (time<=starttime+dt) || tstep_stoch==dt) isstepforstoch = true; 38 #else 39 _error_("not implemented yet"); 40 #endif 41 44 42 /*Compute noise terms*/ 45 IssmDouble* noiseterms = xNew<IssmDouble>(dimtot); 46 my_rank=IssmComm::GetRank(); 47 if(my_rank==0){ 48 int fixedseed; 49 IssmDouble time,dt,starttime; 50 femmodel->parameters->FindParam(&time,TimeEnum); 51 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 52 femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum); 53 /*Determine whether random seed is fixed to time step (randomflag==false) or random seed truly random (randomflag==true)*/ 54 if(randomflag) fixedseed=-1; 55 else fixedseed = reCast<int,IssmDouble>((time-starttime)/dt); 56 /*multivariateNormal needs to be passed a NULL pointer to avoid memory leak issues*/ 57 IssmDouble* temparray = NULL; 58 multivariateNormal(&temparray,dimtot,0.0,covariance,fixedseed); 59 for(int i=0;i<dimtot;i++) noiseterms[i]=temparray[i]; 60 xDelete<IssmDouble>(temparray); 61 } 62 ISSM_MPI_Bcast(noiseterms,dimtot,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 63 43 IssmDouble* noiseterms = xNew<IssmDouble>(dimtot); 44 if(isstepforstoch){ 45 my_rank=IssmComm::GetRank(); 46 if(my_rank==0){ 47 int fixedseed; 48 /*Determine whether random seed is fixed to time step (randomflag==false) or random seed truly random (randomflag==true)*/ 49 if(randomflag) fixedseed=-1; 50 else fixedseed = reCast<int,IssmDouble>((time-starttime)/dt); 51 /*multivariateNormal needs to be passed a NULL pointer to avoid memory leak issues*/ 52 IssmDouble* temparray = NULL; 53 multivariateNormal(&temparray,dimtot,0.0,covariance,fixedseed); 54 for(int i=0;i<dimtot;i++) noiseterms[i]=temparray[i]; 55 xDelete<IssmDouble>(temparray); 56 } 57 ISSM_MPI_Bcast(noiseterms,dimtot,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 58 femmodel->parameters->SetParam(noiseterms,dimtot,StochasticForcingNoisetermsEnum); 59 } 60 else{ 61 IssmDouble* temparray = NULL; 62 femmodel->parameters->FindParam(&temparray,&N,StochasticForcingNoisetermsEnum); _assert_(N==dimtot); 63 for(int i=0;i<dimtot;i++) noiseterms[i] = temparray[i]; 64 xDelete<IssmDouble>(temparray); 65 } 66 64 67 int i=0; 65 68 for(int j=0;j<numfields;j++){ … … 73 76 74 77 /*Deal with the autoregressive models*/ 75 if(fields[j]==SMBautoregressionEnum || fields[j]==FrontalForcingsRignotAutoregressionEnum ){78 if(fields[j]==SMBautoregressionEnum || fields[j]==FrontalForcingsRignotAutoregressionEnum || fields[j]==BasalforcingsDeepwaterMeltingRateAutoregressionEnum){ 76 79 switch(fields[j]){ 77 80 case SMBautoregressionEnum: … … 82 85 dimenum_type = FrontalForcingsBasinIdEnum; 83 86 noiseenum_type = ThermalforcingAutoregressionNoiseEnum; 87 break; 88 case BasalforcingsDeepwaterMeltingRateAutoregressionEnum: 89 dimenum_type = BasalforcingsLinearBasinIdEnum; 90 noiseenum_type = BasalforcingsDeepwaterMeltingRateNoiseEnum; 84 91 break; 85 92 } … … 98 105 case SMBautoregressionEnum: 99 106 case FrontalForcingsRignotAutoregressionEnum: 107 case BasalforcingsDeepwaterMeltingRateAutoregressionEnum: 100 108 /*Already done above*/ 101 109 break; 110 case BasalforcingsSpatialDeepwaterMeltingRateEnum: 111 /*Delete BasalforcingsSpatialDeepwaterMeltingRateEnum at previous time step (required if it is transient)*/ 112 femmodel->inputs->DeleteInput(BasalforcingsSpatialDeepwaterMeltingRateEnum); 113 for(Object* &object:femmodel->elements->objects){ 114 Element* element = xDynamicCast<Element*>(object); 115 int numvertices = element->GetNumberOfVertices(); 116 IssmDouble baselinedeepwatermelt; 117 IssmDouble deepwatermelt_tot[numvertices]; 118 Input* baselinedeepwatermelt_input = NULL; 119 baselinedeepwatermelt_input = element->GetInput(BaselineBasalforcingsSpatialDeepwaterMeltingRateEnum); _assert_(baselinedeepwatermelt_input); 120 element->GetInputValue(&dimensionid,StochasticForcingDefaultIdEnum); 121 Gauss* gauss = element->NewGauss(); 122 for(int i=0;i<numvertices;i++){ 123 gauss->GaussVertex(i); 124 baselinedeepwatermelt_input->GetInputValue(&baselinedeepwatermelt,gauss); 125 deepwatermelt_tot[i] = baselinedeepwatermelt+noisefield[dimensionid]; 126 } 127 element->AddInput(BasalforcingsSpatialDeepwaterMeltingRateEnum,&deepwatermelt_tot[0],P1DGEnum); 128 delete gauss; 129 } 130 break; 102 131 case DefaultCalvingEnum: 103 132 /*Delete CalvingCalvingrateEnum at previous time step (required if it is transient)*/ … … 136 165 gauss->GaussVertex(i); 137 166 baselinefloatingicemeltrate_input->GetInputValue(&baselinefloatingicemeltrate,gauss); 138 floatingicemeltrate_tot[i] = max(0.0,baselinefloatingicemeltrate+noisefield[dimensionid]); 167 /*No check for positive melt rate because basal accretion is allowed*/ 168 floatingicemeltrate_tot[i] = baselinefloatingicemeltrate+noisefield[dimensionid]; 139 169 } 140 170 element->AddInput(BasalforcingsFloatingiceMeltingRateEnum,&floatingicemeltrate_tot[0],P1DGEnum); … … 142 172 } 143 173 break; 144 //VV working(29Nov2021) 174 case SMBforcingEnum: 175 /*Delete SmbMassBalanceEnum at previous time step (required if it is transient)*/ 176 femmodel->inputs->DeleteInput(SmbMassBalanceEnum); 177 for(Object* &object:femmodel->elements->objects){ 178 Element* element = xDynamicCast<Element*>(object); 179 int numvertices = element->GetNumberOfVertices(); 180 IssmDouble baselinesmb; 181 IssmDouble smb_tot[numvertices]; 182 Input* baselinesmb_input = NULL; 183 baselinesmb_input = element->GetInput(BaselineSmbMassBalanceEnum); _assert_(baselinesmb_input); 184 element->GetInputValue(&dimensionid,StochasticForcingDefaultIdEnum); 185 Gauss* gauss = element->NewGauss(); 186 for(int i=0;i<numvertices;i++){ 187 gauss->GaussVertex(i); 188 baselinesmb_input->GetInputValue(&baselinesmb,gauss); 189 smb_tot[i] = baselinesmb+noisefield[dimensionid]; 190 } 191 element->AddInput(SmbMassBalanceEnum,&smb_tot[0],P1DGEnum); 192 delete gauss; 193 } 194 break; 145 195 case FrictionWaterPressureEnum: 146 196 /*Specify that WaterPressure is stochastic*/ … … 165 215 } 166 216 break; 167 168 /*169 case FrictionEffectivePressureEnum:170 femmodel->parameters->SetParam(true,StochasticForcingIsEffectivePressureEnum);171 for(Object* &object:femmodel->elements->objects){172 Element* element = xDynamicCast<Element*>(object);173 int numvertices = element->GetNumberOfVertices();174 IssmDouble Neff[numvertices];175 element->GetInputValue(&dimensionid,StochasticForcingDefaultIdEnum);176 Gauss* gauss=element->NewGauss();177 Friction* friction = new Friction(element);178 for(int i=0;i<numvertices;i++){179 gauss->GaussVertex(i);180 Neff[i] = friction->EffectivePressure(gauss);181 Neff[i] = Neff[i]+noisefield[dimensionid];182 }183 element->AddInput(FrictionEffectivePressureEnum,Neff,P1DGEnum);184 delete gauss;185 delete friction;186 }187 break;188 */189 190 217 default: 191 218 _error_("Field "<<EnumToStringx(fields[j])<<" does not support stochasticity yet."); -
issm/trunk/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp
r26744 r27035 66 66 Input* vyobs_input = NULL; 67 67 68 /*Read SurfaceEnum from 2D models:SSA, L1L2, M LHO*/68 /*Read SurfaceEnum from 2D models:SSA, L1L2, MOLHO*/ 69 69 if (domaintype == Domain2DhorizontalEnum) { 70 70 vx_input = topelement->GetInput(VxSurfaceEnum); _assert_(vx_input); -
issm/trunk/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp
r26744 r27035 74 74 Input* vyobs_input = NULL; 75 75 76 /*Read SurfaceEnum from 2D models:SSA, L1L2, M LHO*/76 /*Read SurfaceEnum from 2D models:SSA, L1L2, MOLHO*/ 77 77 if (domaintype == Domain2DhorizontalEnum) { 78 78 vx_input = topelement->GetInput(VxSurfaceEnum); _assert_(vx_input); -
issm/trunk/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp
r26744 r27035 68 68 Input* vyobs_input = NULL; 69 69 70 /*Read SurfaceEnum from 2D models:SSA, L1L2, M LHO*/70 /*Read SurfaceEnum from 2D models:SSA, L1L2, MOLHO*/ 71 71 if (domaintype == Domain2DhorizontalEnum) { 72 72 vx_input = topelement->GetInput(VxSurfaceEnum); _assert_(vx_input); -
issm/trunk/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp
r26744 r27035 68 68 Input* vyobs_input = NULL; 69 69 70 /*Read SurfaceEnum from 2D models:SSA, L1L2, M LHO*/70 /*Read SurfaceEnum from 2D models:SSA, L1L2, MOLHO*/ 71 71 if (domaintype == Domain2DhorizontalEnum) { 72 72 vx_input = topelement->GetInput(VxSurfaceEnum); _assert_(vx_input); -
issm/trunk/src/c/modules/SurfaceMassBalancex/SurfaceMassBalancex.cpp
r26744 r27035 164 164 femmodel->parameters->FindParam(&phi,&M,&Nphi,SmbPhiEnum); _assert_(M==numbasins); _assert_(Nphi==arorder); 165 165 166 /*AR model spin-up with 0 noise to initialize SmbValuesAutoregressionEnum */167 int nspin {2*arorder+5};166 /*AR model spin-up with 0 noise to initialize SmbValuesAutoregressionEnum (688 = log(0.001)/log(0.99): decaying time of inluence of phi[0]=0.99 to 0.001 of beta_0*/ 167 int nspin = 688; 168 168 for(Object* &object:femmodel->elements->objects){ 169 169 Element* element = xDynamicCast<Element*>(object); //generate element object … … 198 198 bool isstochastic; 199 199 bool issmbstochastic = false; 200 int M,N,Nphi,arorder,numbasins, my_rank;200 int M,N,Nphi,arorder,numbasins,numelevbins,my_rank; 201 201 femmodel->parameters->FindParam(&numbasins,SmbNumBasinsEnum); 202 202 femmodel->parameters->FindParam(&arorder,SmbAutoregressiveOrderEnum); 203 femmodel->parameters->FindParam(&numelevbins,SmbNumElevationBinsEnum); 203 204 IssmDouble tinit_ar; 204 IssmDouble* beta0 = NULL; 205 IssmDouble* beta1 = NULL; 206 IssmDouble* phi = NULL; 205 IssmDouble* beta0 = NULL; 206 IssmDouble* beta1 = NULL; 207 IssmDouble* phi = NULL; 208 IssmDouble* lapserates = NULL; 209 IssmDouble* elevbins = NULL; 210 IssmDouble* refelevation = NULL; 207 211 208 212 femmodel->parameters->FindParam(&tinit_ar,SmbAutoregressionInitialTimeEnum); 209 femmodel->parameters->FindParam(&beta0,&M,SmbBeta0Enum); _assert_(M==numbasins); 210 femmodel->parameters->FindParam(&beta1,&M,SmbBeta1Enum); _assert_(M==numbasins); 211 femmodel->parameters->FindParam(&phi,&M,&Nphi,SmbPhiEnum); _assert_(M==numbasins); _assert_(Nphi==arorder); 213 femmodel->parameters->FindParam(&beta0,&M,SmbBeta0Enum); _assert_(M==numbasins); 214 femmodel->parameters->FindParam(&beta1,&M,SmbBeta1Enum); _assert_(M==numbasins); 215 femmodel->parameters->FindParam(&phi,&M,&Nphi,SmbPhiEnum); _assert_(M==numbasins); _assert_(Nphi==arorder); 216 femmodel->parameters->FindParam(&lapserates,&M,&N,SmbLapseRatesEnum); _assert_(M==numbasins); _assert_(N==numelevbins); 217 femmodel->parameters->FindParam(&elevbins,&M,&N,SmbElevationBinsEnum); _assert_(M==numbasins); _assert_(N==numelevbins-1); 218 femmodel->parameters->FindParam(&refelevation,&M,SmbRefElevationEnum); _assert_(M==numbasins); 212 219 213 220 femmodel->parameters->FindParam(&isstochastic,StochasticForcingIsStochasticForcingEnum); … … 228 235 for(Object* &object:femmodel->elements->objects){ 229 236 Element* element = xDynamicCast<Element*>(object); 230 element->Autoregression(isstepforar,arorder,telapsed_ar,beta0,beta1,phi,issmbstochastic,SMBautoregressionEnum); 231 } 237 /*Compute autoregression*/ 238 element->Autoregression(isstepforar,arorder,telapsed_ar,beta0,beta1,phi,issmbstochastic,SMBautoregressionEnum); 239 /*Compute lapse rate adjustment*/ 240 element->LapseRateBasinSMB(numelevbins,lapserates,elevbins,refelevation); 241 } 232 242 233 243 /*Cleanup*/ … … 235 245 xDelete<IssmDouble>(beta1); 236 246 xDelete<IssmDouble>(phi); 247 xDelete<IssmDouble>(lapserates); 248 xDelete<IssmDouble>(elevbins); 249 xDelete<IssmDouble>(refelevation); 237 250 }/*}}}*/ 238 251 void Delta18oParameterizationx(FemModel* femmodel){/*{{{*/ -
issm/trunk/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp
r26744 r27035 68 68 Input* vyobs_input = NULL; 69 69 70 /*Read SurfaceEnum from 2D models:SSA, L1L2, M LHO*/70 /*Read SurfaceEnum from 2D models:SSA, L1L2, MOLHO*/ 71 71 if (domaintype == Domain2DhorizontalEnum) { 72 72 vx_input = topelement->GetInput(VxSurfaceEnum); _assert_(vx_input); -
issm/trunk/src/c/shared/Enum/Enum.vim
r26744 r27035 64 64 syn keyword cConstant BalancethicknessStabilizationEnum 65 65 syn keyword cConstant BarystaticContributionsEnum 66 syn keyword cConstant BasalforcingsAutoregressionInitialTimeEnum 67 syn keyword cConstant BasalforcingsAutoregressionTimestepEnum 68 syn keyword cConstant BasalforcingsAutoregressiveOrderEnum 69 syn keyword cConstant BasalforcingsBeta0Enum 70 syn keyword cConstant BasalforcingsBeta1Enum 66 71 syn keyword cConstant BasalforcingsBottomplumedepthEnum 67 72 syn keyword cConstant BasalforcingsCrustthicknessEnum … … 77 82 syn keyword cConstant BasalforcingsIsmip6NumBasinsEnum 78 83 syn keyword cConstant BasalforcingsIsmip6TfDepthsEnum 84 syn keyword cConstant BasalforcingsLinearNumBasinsEnum 79 85 syn keyword cConstant BasalforcingsLowercrustheatEnum 80 86 syn keyword cConstant BasalforcingsMantleconductivityEnum 81 87 syn keyword cConstant BasalforcingsNusseltEnum 88 syn keyword cConstant BasalforcingsPhiEnum 82 89 syn keyword cConstant BasalforcingsPicoAverageOverturningEnum 83 90 syn keyword cConstant BasalforcingsPicoAverageSalinityEnum … … 105 112 syn keyword cConstant CalvingLawEnum 106 113 syn keyword cConstant CalvingMinthicknessEnum 114 syn keyword cConstant CalvingTestSpeedfactorEnum 115 syn keyword cConstant CalvingTestIndependentRateEnum 116 syn keyword cConstant CalvingUseParamEnum 117 syn keyword cConstant CalvingScaleThetaEnum 118 syn keyword cConstant CalvingAmpAlphaEnum 119 syn keyword cConstant CalvingMidpointEnum 120 syn keyword cConstant CalvingNonlinearLawEnum 107 121 syn keyword cConstant ConfigurationTypeEnum 108 122 syn keyword cConstant ConstantsGEnum … … 162 176 syn keyword cConstant FlowequationIsHOEnum 163 177 syn keyword cConstant FlowequationIsL1L2Enum 164 syn keyword cConstant FlowequationIsM LHOEnum178 syn keyword cConstant FlowequationIsMOLHOEnum 165 179 syn keyword cConstant FlowequationIsSIAEnum 166 180 syn keyword cConstant FlowequationIsSSAEnum … … 189 203 syn keyword cConstant GroundinglineMeltInterpolationEnum 190 204 syn keyword cConstant GroundinglineMigrationEnum 205 syn keyword cConstant GroundinglineNumRequestedOutputsEnum 206 syn keyword cConstant GroundinglineRequestedOutputsEnum 191 207 syn keyword cConstant HydrologyAveragingEnum 192 208 syn keyword cConstant HydrologyCavitySpacingEnum … … 263 279 syn keyword cConstant LockFileNameEnum 264 280 syn keyword cConstant LoveAllowLayerDeletionEnum 281 syn keyword cConstant LoveChandlerWobbleEnum 265 282 syn keyword cConstant LoveCoreMantleBoundaryEnum 266 283 syn keyword cConstant LoveEarthMassEnum … … 283 300 syn keyword cConstant LoveStartingLayerEnum 284 301 syn keyword cConstant LoveUnderflowTolEnum 302 syn keyword cConstant LovePostWidderThresholdEnum 285 303 syn keyword cConstant MassFluxSegmentsEnum 286 304 syn keyword cConstant MassFluxSegmentsPresentEnum … … 352 370 syn keyword cConstant ModelnameEnum 353 371 syn keyword cConstant SamplingAlphaEnum 354 syn keyword cConstant SamplingPhiEnum355 372 syn keyword cConstant SamplingNumRequestedOutputsEnum 356 373 syn keyword cConstant SamplingRequestedOutputsEnum 357 374 syn keyword cConstant SamplingRobinEnum 358 375 syn keyword cConstant SamplingSeedEnum 359 syn keyword cConstant SamplingTauEnum360 376 syn keyword cConstant SaveResultsEnum 361 377 syn keyword cConstant SolidearthPartitionIceEnum … … 369 385 syn keyword cConstant SolidearthSettingsAbstolEnum 370 386 syn keyword cConstant SolidearthSettingsCrossSectionShapeEnum 371 syn keyword cConstant RotationalAngularVelocityEnum372 387 syn keyword cConstant SolidearthSettingsElasticEnum 373 388 syn keyword cConstant SolidearthSettingsViscousEnum … … 376 391 syn keyword cConstant SealevelchangeViscousTimesEnum 377 392 syn keyword cConstant SealevelchangeViscousIndexEnum 393 syn keyword cConstant SealevelchangeViscousPolarMotionEnum 394 syn keyword cConstant SealevelchangeRunCountEnum 395 syn keyword cConstant SealevelchangeTransitionsEnum 396 syn keyword cConstant SealevelchangeRequestedOutputsEnum 397 syn keyword cConstant RotationalAngularVelocityEnum 378 398 syn keyword cConstant RotationalEquatorialMoiEnum 399 syn keyword cConstant RotationalPolarMoiEnum 400 syn keyword cConstant LovePolarMotionTransferFunctionColinearEnum 401 syn keyword cConstant LovePolarMotionTransferFunctionOrthogonalEnum 379 402 syn keyword cConstant TidalLoveHEnum 380 403 syn keyword cConstant TidalLoveKEnum … … 388 411 syn keyword cConstant SealevelchangeGSelfAttractionEnum 389 412 syn keyword cConstant SealevelchangeGViscoElasticEnum 413 syn keyword cConstant SealevelchangeUViscoElasticEnum 414 syn keyword cConstant SealevelchangeHViscoElasticEnum 415 syn keyword cConstant SealevelchangePolarMotionTransferFunctionColinearEnum 416 syn keyword cConstant SealevelchangePolarMotionTransferFunctionOrthogonalEnum 417 syn keyword cConstant SealevelchangePolarMotionTransferFunctionZEnum 418 syn keyword cConstant SealevelchangeTidalK2Enum 419 syn keyword cConstant SealevelchangeTidalH2Enum 420 syn keyword cConstant SealevelchangeTidalL2Enum 390 421 syn keyword cConstant SolidearthSettingsSealevelLoadingEnum 391 422 syn keyword cConstant SolidearthSettingsGRDEnum 392 423 syn keyword cConstant SolidearthSettingsRunFrequencyEnum 393 424 syn keyword cConstant SolidearthSettingsTimeAccEnum 394 syn keyword cConstant SealevelchangeHViscoElasticEnum395 425 syn keyword cConstant SolidearthSettingsHorizEnum 396 426 syn keyword cConstant SolidearthSettingsMaxiterEnum … … 404 434 syn keyword cConstant StochasticForcingIsStochasticForcingEnum 405 435 syn keyword cConstant StochasticForcingIsWaterPressureEnum 436 syn keyword cConstant StochasticForcingNoisetermsEnum 406 437 syn keyword cConstant StochasticForcingNumFieldsEnum 407 438 syn keyword cConstant StochasticForcingRandomflagEnum 408 syn keyword cConstant RotationalPolarMoiEnum439 syn keyword cConstant StochasticForcingTimestepEnum 409 440 syn keyword cConstant SolidearthSettingsReltolEnum 410 syn keyword cConstant SealevelchangeRequestedOutputsEnum411 441 syn keyword cConstant SolidearthSettingsSelfAttractionEnum 412 442 syn keyword cConstant SolidearthSettingsRotationEnum 413 443 syn keyword cConstant SolidearthSettingsMaxSHCoeffEnum 414 syn keyword cConstant SealevelchangeRunCountEnum415 syn keyword cConstant SealevelchangeTransitionsEnum416 syn keyword cConstant SealevelchangeUViscoElasticEnum417 444 syn keyword cConstant SettingsIoGatherEnum 418 445 syn keyword cConstant SettingsNumResultsOnNodesEnum … … 439 466 syn keyword cConstant SmbDpermilEnum 440 467 syn keyword cConstant SmbDsnowIdxEnum 468 syn keyword cConstant SmbElevationBinsEnum 441 469 syn keyword cConstant SmbCldFracEnum 442 470 syn keyword cConstant SmbDelta18oEnum … … 466 494 syn keyword cConstant SmbIsturbulentfluxEnum 467 495 syn keyword cConstant SmbKEnum 496 syn keyword cConstant SmbLapseRatesEnum 468 497 syn keyword cConstant SmbNumBasinsEnum 498 syn keyword cConstant SmbNumElevationBinsEnum 469 499 syn keyword cConstant SmbNumRequestedOutputsEnum 470 500 syn keyword cConstant SmbPfacEnum 471 501 syn keyword cConstant SmbPhiEnum 472 502 syn keyword cConstant SmbRdlEnum 503 syn keyword cConstant SmbRefElevationEnum 473 504 syn keyword cConstant SmbRequestedOutputsEnum 474 505 syn keyword cConstant SmbRlapsEnum … … 579 610 syn keyword cConstant BalancethicknessThickeningRateEnum 580 611 syn keyword cConstant BasalCrevasseEnum 612 syn keyword cConstant BasalforcingsDeepwaterMeltingRateAutoregressionEnum 613 syn keyword cConstant BasalforcingsDeepwaterMeltingRateNoiseEnum 614 syn keyword cConstant BasalforcingsDeepwaterMeltingRateValuesAutoregressionEnum 581 615 syn keyword cConstant BasalforcingsFloatingiceMeltingRateEnum 582 616 syn keyword cConstant BasalforcingsGeothermalfluxEnum 583 617 syn keyword cConstant BasalforcingsGroundediceMeltingRateEnum 618 syn keyword cConstant BasalforcingsLinearBasinIdEnum 584 619 syn keyword cConstant BasalforcingsPerturbationMeltingRateEnum 620 syn keyword cConstant BasalforcingsSpatialDeepwaterElevationEnum 621 syn keyword cConstant BasalforcingsSpatialDeepwaterMeltingRateEnum 622 syn keyword cConstant BasalforcingsSpatialUpperwaterElevationEnum 623 syn keyword cConstant BasalforcingsSpatialUpperwaterMeltingRateEnum 585 624 syn keyword cConstant BasalforcingsIsmip6BasinIdEnum 586 625 syn keyword cConstant BasalforcingsIsmip6TfEnum … … 604 643 syn keyword cConstant BaseSlopeYEnum 605 644 syn keyword cConstant BaselineBasalforcingsFloatingiceMeltingRateEnum 645 syn keyword cConstant BaselineBasalforcingsSpatialDeepwaterMeltingRateEnum 606 646 syn keyword cConstant BaselineCalvingCalvingrateEnum 607 647 syn keyword cConstant BaselineFrictionEffectivePressureEnum 648 syn keyword cConstant BaselineSmbMassBalanceEnum 608 649 syn keyword cConstant BedEnum 609 650 syn keyword cConstant BedGRDEnum … … 618 659 syn keyword cConstant CalvingCalvingrateEnum 619 660 syn keyword cConstant CalvingHabFractionEnum 661 syn keyword cConstant CalvingAblationrateEnum 620 662 syn keyword cConstant CalvingMeltingrateEnum 621 663 syn keyword cConstant CalvingStressThresholdFloatingiceEnum 622 664 syn keyword cConstant CalvingStressThresholdGroundediceEnum 623 665 syn keyword cConstant CalvinglevermannCoeffEnum 624 syn keyword cConstant CalvingratexAverageEnum625 666 syn keyword cConstant CalvingratexEnum 626 syn keyword cConstant CalvingrateyAverageEnum627 667 syn keyword cConstant CalvingrateyEnum 628 668 syn keyword cConstant CalvingFluxLevelsetEnum … … 803 843 syn keyword cConstant RheologyBbarAbsGradientEnum 804 844 syn keyword cConstant SampleEnum 845 syn keyword cConstant SampleOldEnum 846 syn keyword cConstant SampleNoiseEnum 805 847 syn keyword cConstant SamplingBetaEnum 806 848 syn keyword cConstant SamplingKappaEnum 849 syn keyword cConstant SamplingPhiEnum 850 syn keyword cConstant SamplingTauEnum 807 851 syn keyword cConstant SealevelEnum 808 852 syn keyword cConstant SealevelGRDEnum … … 839 883 syn keyword cConstant BslcRateEnum 840 884 syn keyword cConstant GmtslcEnum 841 syn keyword cConstant SealevelGrotm1Enum842 syn keyword cConstant SealevelGrotm2Enum843 syn keyword cConstant SealevelGrotm3Enum844 syn keyword cConstant SealevelGUrotm1Enum845 syn keyword cConstant SealevelGUrotm2Enum846 syn keyword cConstant SealevelGUrotm3Enum847 syn keyword cConstant SealevelGNrotm1Enum848 syn keyword cConstant SealevelGNrotm2Enum849 syn keyword cConstant SealevelGNrotm3Enum850 syn keyword cConstant SealevelGErotm1Enum851 syn keyword cConstant SealevelGErotm2Enum852 syn keyword cConstant SealevelGErotm3Enum853 885 syn keyword cConstant SealevelRSLBarystaticEnum 854 886 syn keyword cConstant SealevelRSLRateEnum … … 862 894 syn keyword cConstant SealevelchangeGEEnum 863 895 syn keyword cConstant SealevelchangeGNEnum 896 syn keyword cConstant SealevelchangeGrotEnum 897 syn keyword cConstant SealevelchangeGUrotEnum 898 syn keyword cConstant SealevelchangeGNrotEnum 899 syn keyword cConstant SealevelchangeGErotEnum 864 900 syn keyword cConstant SealevelchangeGsubelOceanEnum 865 901 syn keyword cConstant SealevelchangeGUsubelOceanEnum … … 1195 1231 syn keyword cConstant ArrheniusEnum 1196 1232 syn keyword cConstant AutodiffJacobianEnum 1233 syn keyword cConstant AutoregressionLinearFloatingMeltRateEnum 1197 1234 syn keyword cConstant Balancethickness2AnalysisEnum 1198 1235 syn keyword cConstant Balancethickness2SolutionEnum … … 1218 1255 syn keyword cConstant CalvingHabEnum 1219 1256 syn keyword cConstant CalvingLevermannEnum 1257 syn keyword cConstant CalvingTestEnum 1258 syn keyword cConstant CalvingParameterizationEnum 1220 1259 syn keyword cConstant CalvingVonmisesEnum 1221 1260 syn keyword cConstant CfdragcoeffabsgradEnum … … 1346 1385 syn keyword cConstant JEnum 1347 1386 syn keyword cConstant L1L2ApproximationEnum 1348 syn keyword cConstant M LHOApproximationEnum1387 syn keyword cConstant MOLHOApproximationEnum 1349 1388 syn keyword cConstant L2ProjectionBaseAnalysisEnum 1350 1389 syn keyword cConstant L2ProjectionEPLAnalysisEnum … … 1358 1397 syn keyword cConstant LoadsEnum 1359 1398 syn keyword cConstant LoveAnalysisEnum 1360 syn keyword cConstant LoveH iEnum1361 syn keyword cConstant LoveH rEnum1399 syn keyword cConstant LoveHfEnum 1400 syn keyword cConstant LoveHtEnum 1362 1401 syn keyword cConstant LoveKernelsImagEnum 1363 1402 syn keyword cConstant LoveKernelsRealEnum 1364 syn keyword cConstant LoveKiEnum 1365 syn keyword cConstant LoveKrEnum 1366 syn keyword cConstant LoveLiEnum 1367 syn keyword cConstant LoveLrEnum 1403 syn keyword cConstant LoveKfEnum 1404 syn keyword cConstant LoveKtEnum 1405 syn keyword cConstant LoveLfEnum 1406 syn keyword cConstant LoveLtEnum 1407 syn keyword cConstant LoveTidalHtEnum 1408 syn keyword cConstant LoveTidalKtEnum 1409 syn keyword cConstant LoveTidalLtEnum 1410 syn keyword cConstant LovePMTF1tEnum 1411 syn keyword cConstant LovePMTF2tEnum 1368 1412 syn keyword cConstant LoveSolutionEnum 1369 1413 syn keyword cConstant MINIEnum … … 1477 1521 syn keyword cConstant SealevelAbsoluteEnum 1478 1522 syn keyword cConstant SealevelEmotionEnum 1479 syn keyword cConstant Sealevel InertiaTensorXZEnum1480 syn keyword cConstant Sealevel InertiaTensorYZEnum1481 syn keyword cConstant Sealevel InertiaTensorZZEnum1523 syn keyword cConstant SealevelchangePolarMotionXEnum 1524 syn keyword cConstant SealevelchangePolarMotionYEnum 1525 syn keyword cConstant SealevelchangePolarMotionZEnum 1482 1526 syn keyword cConstant SealevelchangePolarMotionEnum 1483 1527 syn keyword cConstant SealevelNmotionEnum … … 1580 1624 syn keyword cType Cfsurfacesquare 1581 1625 syn keyword cType Channel 1582 syn keyword cType classes1583 1626 syn keyword cType Constraint 1584 1627 syn keyword cType Constraints … … 1587 1630 syn keyword cType ControlInput 1588 1631 syn keyword cType Covertree 1632 syn keyword cType DataSetParam 1589 1633 syn keyword cType DatasetInput 1590 syn keyword cType DataSetParam1591 1634 syn keyword cType Definition 1592 1635 syn keyword cType DependentObject … … 1601 1644 syn keyword cType ElementInput 1602 1645 syn keyword cType ElementMatrix 1646 syn keyword cType ElementVector 1603 1647 syn keyword cType Elements 1604 syn keyword cType ElementVector1605 1648 syn keyword cType ExponentialVariogram 1606 1649 syn keyword cType ExternalResult … … 1609 1652 syn keyword cType Friction 1610 1653 syn keyword cType Gauss 1611 syn keyword cType GaussianVariogram1612 syn keyword cType gaussobjects1613 1654 syn keyword cType GaussPenta 1614 1655 syn keyword cType GaussSeg 1615 1656 syn keyword cType GaussTetra 1616 1657 syn keyword cType GaussTria 1658 syn keyword cType GaussianVariogram 1617 1659 syn keyword cType GenericExternalResult 1618 1660 syn keyword cType GenericOption … … 1630 1672 syn keyword cType IssmDirectApplicInterface 1631 1673 syn keyword cType IssmParallelDirectApplicInterface 1632 syn keyword cType krigingobjects1633 1674 syn keyword cType Load 1634 1675 syn keyword cType Loads … … 1641 1682 syn keyword cType Matice 1642 1683 syn keyword cType Matlitho 1643 syn keyword cType matrixobjects1644 1684 syn keyword cType MatrixParam 1645 1685 syn keyword cType Misfit … … 1654 1694 syn keyword cType Observations 1655 1695 syn keyword cType Option 1696 syn keyword cType OptionUtilities 1656 1697 syn keyword cType Options 1657 syn keyword cType OptionUtilities1658 1698 syn keyword cType Param 1659 1699 syn keyword cType Parameters … … 1669 1709 syn keyword cType Regionaloutput 1670 1710 syn keyword cType Results 1711 syn keyword cType RiftStruct 1671 1712 syn keyword cType Riftfront 1672 syn keyword cType RiftStruct1673 1713 syn keyword cType SealevelGeometry 1674 1714 syn keyword cType Seg 1675 1715 syn keyword cType SegInput 1716 syn keyword cType SegRef 1676 1717 syn keyword cType Segment 1677 syn keyword cType SegRef1678 1718 syn keyword cType SpcDynamic 1679 1719 syn keyword cType SpcStatic … … 1694 1734 syn keyword cType Vertex 1695 1735 syn keyword cType Vertices 1736 syn keyword cType classes 1737 syn keyword cType gaussobjects 1738 syn keyword cType krigingobjects 1739 syn keyword cType matrixobjects 1696 1740 syn keyword cType AdjointBalancethickness2Analysis 1697 1741 syn keyword cType AdjointBalancethicknessAnalysis -
issm/trunk/src/c/shared/Enum/EnumDefinitions.h
r26744 r27035 58 58 BalancethicknessStabilizationEnum, 59 59 BarystaticContributionsEnum, 60 BasalforcingsAutoregressionInitialTimeEnum, 61 BasalforcingsAutoregressionTimestepEnum, 62 BasalforcingsAutoregressiveOrderEnum, 63 BasalforcingsBeta0Enum, 64 BasalforcingsBeta1Enum, 60 65 BasalforcingsBottomplumedepthEnum, 61 66 BasalforcingsCrustthicknessEnum, … … 71 76 BasalforcingsIsmip6NumBasinsEnum, 72 77 BasalforcingsIsmip6TfDepthsEnum, 78 BasalforcingsLinearNumBasinsEnum, 73 79 BasalforcingsLowercrustheatEnum, 74 80 BasalforcingsMantleconductivityEnum, 75 81 BasalforcingsNusseltEnum, 82 BasalforcingsPhiEnum, 76 83 BasalforcingsPicoAverageOverturningEnum, 77 84 BasalforcingsPicoAverageSalinityEnum, … … 99 106 CalvingLawEnum, 100 107 CalvingMinthicknessEnum, 108 CalvingTestSpeedfactorEnum, 109 CalvingTestIndependentRateEnum, 110 CalvingUseParamEnum, 111 CalvingScaleThetaEnum, 112 CalvingAmpAlphaEnum, 113 CalvingMidpointEnum, 114 CalvingNonlinearLawEnum, 101 115 ConfigurationTypeEnum, 102 116 ConstantsGEnum, … … 156 170 FlowequationIsHOEnum, 157 171 FlowequationIsL1L2Enum, 158 FlowequationIsM LHOEnum,172 FlowequationIsMOLHOEnum, 159 173 FlowequationIsSIAEnum, 160 174 FlowequationIsSSAEnum, … … 183 197 GroundinglineMeltInterpolationEnum, 184 198 GroundinglineMigrationEnum, 199 GroundinglineNumRequestedOutputsEnum, 200 GroundinglineRequestedOutputsEnum, 185 201 HydrologyAveragingEnum, 186 202 HydrologyCavitySpacingEnum, … … 257 273 LockFileNameEnum, 258 274 LoveAllowLayerDeletionEnum, 275 LoveChandlerWobbleEnum, 259 276 LoveCoreMantleBoundaryEnum, 260 277 LoveEarthMassEnum, … … 277 294 LoveStartingLayerEnum, 278 295 LoveUnderflowTolEnum, 296 LovePostWidderThresholdEnum, 279 297 MassFluxSegmentsEnum, 280 298 MassFluxSegmentsPresentEnum, … … 346 364 ModelnameEnum, 347 365 SamplingAlphaEnum, 348 SamplingPhiEnum,349 366 SamplingNumRequestedOutputsEnum, 350 367 SamplingRequestedOutputsEnum, 351 368 SamplingRobinEnum, 352 369 SamplingSeedEnum, 353 SamplingTauEnum,354 370 SaveResultsEnum, 355 371 SolidearthPartitionIceEnum, … … 363 379 SolidearthSettingsAbstolEnum, 364 380 SolidearthSettingsCrossSectionShapeEnum, 365 RotationalAngularVelocityEnum,366 381 SolidearthSettingsElasticEnum, 367 382 SolidearthSettingsViscousEnum, … … 370 385 SealevelchangeViscousTimesEnum, 371 386 SealevelchangeViscousIndexEnum, 387 SealevelchangeViscousPolarMotionEnum, 388 SealevelchangeRunCountEnum, 389 SealevelchangeTransitionsEnum, 390 SealevelchangeRequestedOutputsEnum, 391 RotationalAngularVelocityEnum, 372 392 RotationalEquatorialMoiEnum, 393 RotationalPolarMoiEnum, 394 LovePolarMotionTransferFunctionColinearEnum, 395 LovePolarMotionTransferFunctionOrthogonalEnum, 373 396 TidalLoveHEnum, 374 397 TidalLoveKEnum, … … 382 405 SealevelchangeGSelfAttractionEnum, 383 406 SealevelchangeGViscoElasticEnum, 407 SealevelchangeUViscoElasticEnum, 408 SealevelchangeHViscoElasticEnum, 409 SealevelchangePolarMotionTransferFunctionColinearEnum, 410 SealevelchangePolarMotionTransferFunctionOrthogonalEnum, 411 SealevelchangePolarMotionTransferFunctionZEnum, 412 SealevelchangeTidalK2Enum, 413 SealevelchangeTidalH2Enum, 414 SealevelchangeTidalL2Enum, 384 415 SolidearthSettingsSealevelLoadingEnum, 385 416 SolidearthSettingsGRDEnum, 386 417 SolidearthSettingsRunFrequencyEnum, 387 418 SolidearthSettingsTimeAccEnum, 388 SealevelchangeHViscoElasticEnum,389 419 SolidearthSettingsHorizEnum, 390 420 SolidearthSettingsMaxiterEnum, … … 398 428 StochasticForcingIsStochasticForcingEnum, 399 429 StochasticForcingIsWaterPressureEnum, 430 StochasticForcingNoisetermsEnum, 400 431 StochasticForcingNumFieldsEnum, 401 432 StochasticForcingRandomflagEnum, 402 RotationalPolarMoiEnum,433 StochasticForcingTimestepEnum, 403 434 SolidearthSettingsReltolEnum, 404 SealevelchangeRequestedOutputsEnum,405 435 SolidearthSettingsSelfAttractionEnum, 406 436 SolidearthSettingsRotationEnum, 407 437 SolidearthSettingsMaxSHCoeffEnum, 408 SealevelchangeRunCountEnum,409 SealevelchangeTransitionsEnum,410 SealevelchangeUViscoElasticEnum,411 438 SettingsIoGatherEnum, 412 439 SettingsNumResultsOnNodesEnum, … … 433 460 SmbDpermilEnum, 434 461 SmbDsnowIdxEnum, 462 SmbElevationBinsEnum, 435 463 SmbCldFracEnum, 436 464 SmbDelta18oEnum, … … 460 488 SmbIsturbulentfluxEnum, 461 489 SmbKEnum, 490 SmbLapseRatesEnum, 462 491 SmbNumBasinsEnum, 492 SmbNumElevationBinsEnum, 463 493 SmbNumRequestedOutputsEnum, 464 494 SmbPfacEnum, 465 495 SmbPhiEnum, 466 496 SmbRdlEnum, 497 SmbRefElevationEnum, 467 498 SmbRequestedOutputsEnum, 468 499 SmbRlapsEnum, … … 534 565 TransientIsgroundinglineEnum, 535 566 TransientIshydrologyEnum, 536 TransientIsmasstransportEnum, 567 TransientIsmasstransportEnum, 537 568 TransientIsoceantransportEnum, 538 569 TransientIsmovingfrontEnum, … … 575 606 BalancethicknessThickeningRateEnum, 576 607 BasalCrevasseEnum, 608 BasalforcingsDeepwaterMeltingRateAutoregressionEnum, 609 BasalforcingsDeepwaterMeltingRateNoiseEnum, 610 BasalforcingsDeepwaterMeltingRateValuesAutoregressionEnum, 577 611 BasalforcingsFloatingiceMeltingRateEnum, 578 612 BasalforcingsGeothermalfluxEnum, 579 613 BasalforcingsGroundediceMeltingRateEnum, 614 BasalforcingsLinearBasinIdEnum, 580 615 BasalforcingsPerturbationMeltingRateEnum, 616 BasalforcingsSpatialDeepwaterElevationEnum, 617 BasalforcingsSpatialDeepwaterMeltingRateEnum, 618 BasalforcingsSpatialUpperwaterElevationEnum, 619 BasalforcingsSpatialUpperwaterMeltingRateEnum, 581 620 BasalforcingsIsmip6BasinIdEnum, 582 621 BasalforcingsIsmip6TfEnum, … … 600 639 BaseSlopeYEnum, 601 640 BaselineBasalforcingsFloatingiceMeltingRateEnum, 641 BaselineBasalforcingsSpatialDeepwaterMeltingRateEnum, 602 642 BaselineCalvingCalvingrateEnum, 603 643 BaselineFrictionEffectivePressureEnum, 644 BaselineSmbMassBalanceEnum, 604 645 BedEnum, 605 646 BedGRDEnum, … … 614 655 CalvingCalvingrateEnum, 615 656 CalvingHabFractionEnum, 657 CalvingAblationrateEnum, 616 658 CalvingMeltingrateEnum, 617 659 CalvingStressThresholdFloatingiceEnum, 618 660 CalvingStressThresholdGroundediceEnum, 619 661 CalvinglevermannCoeffEnum, 620 CalvingratexAverageEnum,621 662 CalvingratexEnum, 622 CalvingrateyAverageEnum,623 663 CalvingrateyEnum, 624 664 CalvingFluxLevelsetEnum, … … 799 839 RheologyBbarAbsGradientEnum, 800 840 SampleEnum, 841 SampleOldEnum, 842 SampleNoiseEnum, 801 843 SamplingBetaEnum, 802 844 SamplingKappaEnum, 845 SamplingPhiEnum, 846 SamplingTauEnum, 803 847 SealevelEnum, 804 848 SealevelGRDEnum, … … 835 879 BslcRateEnum, 836 880 GmtslcEnum, 837 SealevelGrotm1Enum,838 SealevelGrotm2Enum,839 SealevelGrotm3Enum,840 SealevelGUrotm1Enum,841 SealevelGUrotm2Enum,842 SealevelGUrotm3Enum,843 SealevelGNrotm1Enum,844 SealevelGNrotm2Enum,845 SealevelGNrotm3Enum,846 SealevelGErotm1Enum,847 SealevelGErotm2Enum,848 SealevelGErotm3Enum,849 881 SealevelRSLBarystaticEnum, 850 882 SealevelRSLRateEnum, … … 858 890 SealevelchangeGEEnum, 859 891 SealevelchangeGNEnum, 892 SealevelchangeGrotEnum, 893 SealevelchangeGUrotEnum, 894 SealevelchangeGNrotEnum, 895 SealevelchangeGErotEnum, 860 896 SealevelchangeGsubelOceanEnum, 861 897 SealevelchangeGUsubelOceanEnum, … … 1036 1072 TemperatureSEMICEnum, 1037 1073 ThermalforcingAutoregressionNoiseEnum, 1038 ThermalforcingValuesAutoregressionEnum, 1074 ThermalforcingValuesAutoregressionEnum, 1039 1075 ThermalSpctemperatureEnum, 1040 1076 ThicknessAbsGradientEnum, … … 1194 1230 ArrheniusEnum, 1195 1231 AutodiffJacobianEnum, 1232 AutoregressionLinearFloatingMeltRateEnum, 1196 1233 Balancethickness2AnalysisEnum, 1197 1234 Balancethickness2SolutionEnum, … … 1217 1254 CalvingHabEnum, 1218 1255 CalvingLevermannEnum, 1256 CalvingTestEnum, 1257 CalvingParameterizationEnum, 1219 1258 CalvingVonmisesEnum, 1220 1259 CfdragcoeffabsgradEnum, … … 1345 1384 JEnum, 1346 1385 L1L2ApproximationEnum, 1347 M LHOApproximationEnum,1386 MOLHOApproximationEnum, 1348 1387 L2ProjectionBaseAnalysisEnum, 1349 1388 L2ProjectionEPLAnalysisEnum, … … 1357 1396 LoadsEnum, 1358 1397 LoveAnalysisEnum, 1359 LoveH iEnum,1360 LoveH rEnum,1398 LoveHfEnum, 1399 LoveHtEnum, 1361 1400 LoveKernelsImagEnum, 1362 1401 LoveKernelsRealEnum, 1363 LoveKiEnum, 1364 LoveKrEnum, 1365 LoveLiEnum, 1366 LoveLrEnum, 1402 LoveKfEnum, 1403 LoveKtEnum, 1404 LoveLfEnum, 1405 LoveLtEnum, 1406 LoveTidalHtEnum, 1407 LoveTidalKtEnum, 1408 LoveTidalLtEnum, 1409 LovePMTF1tEnum, 1410 LovePMTF2tEnum, 1367 1411 LoveSolutionEnum, 1368 1412 MINIEnum, … … 1476 1520 SealevelAbsoluteEnum, 1477 1521 SealevelEmotionEnum, 1478 Sealevel InertiaTensorXZEnum,1479 Sealevel InertiaTensorYZEnum,1480 Sealevel InertiaTensorZZEnum,1522 SealevelchangePolarMotionXEnum, 1523 SealevelchangePolarMotionYEnum, 1524 SealevelchangePolarMotionZEnum, 1481 1525 SealevelchangePolarMotionEnum, 1482 1526 SealevelNmotionEnum, -
issm/trunk/src/c/shared/Enum/EnumToStringx.cpp
r26744 r27035 66 66 case BalancethicknessStabilizationEnum : return "BalancethicknessStabilization"; 67 67 case BarystaticContributionsEnum : return "BarystaticContributions"; 68 case BasalforcingsAutoregressionInitialTimeEnum : return "BasalforcingsAutoregressionInitialTime"; 69 case BasalforcingsAutoregressionTimestepEnum : return "BasalforcingsAutoregressionTimestep"; 70 case BasalforcingsAutoregressiveOrderEnum : return "BasalforcingsAutoregressiveOrder"; 71 case BasalforcingsBeta0Enum : return "BasalforcingsBeta0"; 72 case BasalforcingsBeta1Enum : return "BasalforcingsBeta1"; 68 73 case BasalforcingsBottomplumedepthEnum : return "BasalforcingsBottomplumedepth"; 69 74 case BasalforcingsCrustthicknessEnum : return "BasalforcingsCrustthickness"; … … 79 84 case BasalforcingsIsmip6NumBasinsEnum : return "BasalforcingsIsmip6NumBasins"; 80 85 case BasalforcingsIsmip6TfDepthsEnum : return "BasalforcingsIsmip6TfDepths"; 86 case BasalforcingsLinearNumBasinsEnum : return "BasalforcingsLinearNumBasins"; 81 87 case BasalforcingsLowercrustheatEnum : return "BasalforcingsLowercrustheat"; 82 88 case BasalforcingsMantleconductivityEnum : return "BasalforcingsMantleconductivity"; 83 89 case BasalforcingsNusseltEnum : return "BasalforcingsNusselt"; 90 case BasalforcingsPhiEnum : return "BasalforcingsPhi"; 84 91 case BasalforcingsPicoAverageOverturningEnum : return "BasalforcingsPicoAverageOverturning"; 85 92 case BasalforcingsPicoAverageSalinityEnum : return "BasalforcingsPicoAverageSalinity"; … … 107 114 case CalvingLawEnum : return "CalvingLaw"; 108 115 case CalvingMinthicknessEnum : return "CalvingMinthickness"; 116 case CalvingTestSpeedfactorEnum : return "CalvingTestSpeedfactor"; 117 case CalvingTestIndependentRateEnum : return "CalvingTestIndependentRate"; 118 case CalvingUseParamEnum : return "CalvingUseParam"; 119 case CalvingScaleThetaEnum : return "CalvingScaleTheta"; 120 case CalvingAmpAlphaEnum : return "CalvingAmpAlpha"; 121 case CalvingMidpointEnum : return "CalvingMidpoint"; 122 case CalvingNonlinearLawEnum : return "CalvingNonlinearLaw"; 109 123 case ConfigurationTypeEnum : return "ConfigurationType"; 110 124 case ConstantsGEnum : return "ConstantsG"; … … 164 178 case FlowequationIsHOEnum : return "FlowequationIsHO"; 165 179 case FlowequationIsL1L2Enum : return "FlowequationIsL1L2"; 166 case FlowequationIsM LHOEnum : return "FlowequationIsMLHO";180 case FlowequationIsMOLHOEnum : return "FlowequationIsMOLHO"; 167 181 case FlowequationIsSIAEnum : return "FlowequationIsSIA"; 168 182 case FlowequationIsSSAEnum : return "FlowequationIsSSA"; … … 191 205 case GroundinglineMeltInterpolationEnum : return "GroundinglineMeltInterpolation"; 192 206 case GroundinglineMigrationEnum : return "GroundinglineMigration"; 207 case GroundinglineNumRequestedOutputsEnum : return "GroundinglineNumRequestedOutputs"; 208 case GroundinglineRequestedOutputsEnum : return "GroundinglineRequestedOutputs"; 193 209 case HydrologyAveragingEnum : return "HydrologyAveraging"; 194 210 case HydrologyCavitySpacingEnum : return "HydrologyCavitySpacing"; … … 265 281 case LockFileNameEnum : return "LockFileName"; 266 282 case LoveAllowLayerDeletionEnum : return "LoveAllowLayerDeletion"; 283 case LoveChandlerWobbleEnum : return "LoveChandlerWobble"; 267 284 case LoveCoreMantleBoundaryEnum : return "LoveCoreMantleBoundary"; 268 285 case LoveEarthMassEnum : return "LoveEarthMass"; … … 285 302 case LoveStartingLayerEnum : return "LoveStartingLayer"; 286 303 case LoveUnderflowTolEnum : return "LoveUnderflowTol"; 304 case LovePostWidderThresholdEnum : return "LovePostWidderThreshold"; 287 305 case MassFluxSegmentsEnum : return "MassFluxSegments"; 288 306 case MassFluxSegmentsPresentEnum : return "MassFluxSegmentsPresent"; … … 354 372 case ModelnameEnum : return "Modelname"; 355 373 case SamplingAlphaEnum : return "SamplingAlpha"; 356 case SamplingPhiEnum : return "SamplingPhi";357 374 case SamplingNumRequestedOutputsEnum : return "SamplingNumRequestedOutputs"; 358 375 case SamplingRequestedOutputsEnum : return "SamplingRequestedOutputs"; 359 376 case SamplingRobinEnum : return "SamplingRobin"; 360 377 case SamplingSeedEnum : return "SamplingSeed"; 361 case SamplingTauEnum : return "SamplingTau";362 378 case SaveResultsEnum : return "SaveResults"; 363 379 case SolidearthPartitionIceEnum : return "SolidearthPartitionIce"; … … 371 387 case SolidearthSettingsAbstolEnum : return "SolidearthSettingsAbstol"; 372 388 case SolidearthSettingsCrossSectionShapeEnum : return "SolidearthSettingsCrossSectionShape"; 373 case RotationalAngularVelocityEnum : return "RotationalAngularVelocity";374 389 case SolidearthSettingsElasticEnum : return "SolidearthSettingsElastic"; 375 390 case SolidearthSettingsViscousEnum : return "SolidearthSettingsViscous"; … … 378 393 case SealevelchangeViscousTimesEnum : return "SealevelchangeViscousTimes"; 379 394 case SealevelchangeViscousIndexEnum : return "SealevelchangeViscousIndex"; 395 case SealevelchangeViscousPolarMotionEnum : return "SealevelchangeViscousPolarMotion"; 396 case SealevelchangeRunCountEnum : return "SealevelchangeRunCount"; 397 case SealevelchangeTransitionsEnum : return "SealevelchangeTransitions"; 398 case SealevelchangeRequestedOutputsEnum : return "SealevelchangeRequestedOutputs"; 399 case RotationalAngularVelocityEnum : return "RotationalAngularVelocity"; 380 400 case RotationalEquatorialMoiEnum : return "RotationalEquatorialMoi"; 401 case RotationalPolarMoiEnum : return "RotationalPolarMoi"; 402 case LovePolarMotionTransferFunctionColinearEnum : return "LovePolarMotionTransferFunctionColinear"; 403 case LovePolarMotionTransferFunctionOrthogonalEnum : return "LovePolarMotionTransferFunctionOrthogonal"; 381 404 case TidalLoveHEnum : return "TidalLoveH"; 382 405 case TidalLoveKEnum : return "TidalLoveK"; … … 390 413 case SealevelchangeGSelfAttractionEnum : return "SealevelchangeGSelfAttraction"; 391 414 case SealevelchangeGViscoElasticEnum : return "SealevelchangeGViscoElastic"; 415 case SealevelchangeUViscoElasticEnum : return "SealevelchangeUViscoElastic"; 416 case SealevelchangeHViscoElasticEnum : return "SealevelchangeHViscoElastic"; 417 case SealevelchangePolarMotionTransferFunctionColinearEnum : return "SealevelchangePolarMotionTransferFunctionColinear"; 418 case SealevelchangePolarMotionTransferFunctionOrthogonalEnum : return "SealevelchangePolarMotionTransferFunctionOrthogonal"; 419 case SealevelchangePolarMotionTransferFunctionZEnum : return "SealevelchangePolarMotionTransferFunctionZ"; 420 case SealevelchangeTidalK2Enum : return "SealevelchangeTidalK2"; 421 case SealevelchangeTidalH2Enum : return "SealevelchangeTidalH2"; 422 case SealevelchangeTidalL2Enum : return "SealevelchangeTidalL2"; 392 423 case SolidearthSettingsSealevelLoadingEnum : return "SolidearthSettingsSealevelLoading"; 393 424 case SolidearthSettingsGRDEnum : return "SolidearthSettingsGRD"; 394 425 case SolidearthSettingsRunFrequencyEnum : return "SolidearthSettingsRunFrequency"; 395 426 case SolidearthSettingsTimeAccEnum : return "SolidearthSettingsTimeAcc"; 396 case SealevelchangeHViscoElasticEnum : return "SealevelchangeHViscoElastic";397 427 case SolidearthSettingsHorizEnum : return "SolidearthSettingsHoriz"; 398 428 case SolidearthSettingsMaxiterEnum : return "SolidearthSettingsMaxiter"; … … 406 436 case StochasticForcingIsStochasticForcingEnum : return "StochasticForcingIsStochasticForcing"; 407 437 case StochasticForcingIsWaterPressureEnum : return "StochasticForcingIsWaterPressure"; 438 case StochasticForcingNoisetermsEnum : return "StochasticForcingNoiseterms"; 408 439 case StochasticForcingNumFieldsEnum : return "StochasticForcingNumFields"; 409 440 case StochasticForcingRandomflagEnum : return "StochasticForcingRandomflag"; 410 case RotationalPolarMoiEnum : return "RotationalPolarMoi";441 case StochasticForcingTimestepEnum : return "StochasticForcingTimestep"; 411 442 case SolidearthSettingsReltolEnum : return "SolidearthSettingsReltol"; 412 case SealevelchangeRequestedOutputsEnum : return "SealevelchangeRequestedOutputs";413 443 case SolidearthSettingsSelfAttractionEnum : return "SolidearthSettingsSelfAttraction"; 414 444 case SolidearthSettingsRotationEnum : return "SolidearthSettingsRotation"; 415 445 case SolidearthSettingsMaxSHCoeffEnum : return "SolidearthSettingsMaxSHCoeff"; 416 case SealevelchangeRunCountEnum : return "SealevelchangeRunCount";417 case SealevelchangeTransitionsEnum : return "SealevelchangeTransitions";418 case SealevelchangeUViscoElasticEnum : return "SealevelchangeUViscoElastic";419 446 case SettingsIoGatherEnum : return "SettingsIoGather"; 420 447 case SettingsNumResultsOnNodesEnum : return "SettingsNumResultsOnNodes"; … … 441 468 case SmbDpermilEnum : return "SmbDpermil"; 442 469 case SmbDsnowIdxEnum : return "SmbDsnowIdx"; 470 case SmbElevationBinsEnum : return "SmbElevationBins"; 443 471 case SmbCldFracEnum : return "SmbCldFrac"; 444 472 case SmbDelta18oEnum : return "SmbDelta18o"; … … 468 496 case SmbIsturbulentfluxEnum : return "SmbIsturbulentflux"; 469 497 case SmbKEnum : return "SmbK"; 498 case SmbLapseRatesEnum : return "SmbLapseRates"; 470 499 case SmbNumBasinsEnum : return "SmbNumBasins"; 500 case SmbNumElevationBinsEnum : return "SmbNumElevationBins"; 471 501 case SmbNumRequestedOutputsEnum : return "SmbNumRequestedOutputs"; 472 502 case SmbPfacEnum : return "SmbPfac"; 473 503 case SmbPhiEnum : return "SmbPhi"; 474 504 case SmbRdlEnum : return "SmbRdl"; 505 case SmbRefElevationEnum : return "SmbRefElevation"; 475 506 case SmbRequestedOutputsEnum : return "SmbRequestedOutputs"; 476 507 case SmbRlapsEnum : return "SmbRlaps"; … … 581 612 case BalancethicknessThickeningRateEnum : return "BalancethicknessThickeningRate"; 582 613 case BasalCrevasseEnum : return "BasalCrevasse"; 614 case BasalforcingsDeepwaterMeltingRateAutoregressionEnum : return "BasalforcingsDeepwaterMeltingRateAutoregression"; 615 case BasalforcingsDeepwaterMeltingRateNoiseEnum : return "BasalforcingsDeepwaterMeltingRateNoise"; 616 case BasalforcingsDeepwaterMeltingRateValuesAutoregressionEnum : return "BasalforcingsDeepwaterMeltingRateValuesAutoregression"; 583 617 case BasalforcingsFloatingiceMeltingRateEnum : return "BasalforcingsFloatingiceMeltingRate"; 584 618 case BasalforcingsGeothermalfluxEnum : return "BasalforcingsGeothermalflux"; 585 619 case BasalforcingsGroundediceMeltingRateEnum : return "BasalforcingsGroundediceMeltingRate"; 620 case BasalforcingsLinearBasinIdEnum : return "BasalforcingsLinearBasinId"; 586 621 case BasalforcingsPerturbationMeltingRateEnum : return "BasalforcingsPerturbationMeltingRate"; 622 case BasalforcingsSpatialDeepwaterElevationEnum : return "BasalforcingsSpatialDeepwaterElevation"; 623 case BasalforcingsSpatialDeepwaterMeltingRateEnum : return "BasalforcingsSpatialDeepwaterMeltingRate"; 624 case BasalforcingsSpatialUpperwaterElevationEnum : return "BasalforcingsSpatialUpperwaterElevation"; 625 case BasalforcingsSpatialUpperwaterMeltingRateEnum : return "BasalforcingsSpatialUpperwaterMeltingRate"; 587 626 case BasalforcingsIsmip6BasinIdEnum : return "BasalforcingsIsmip6BasinId"; 588 627 case BasalforcingsIsmip6TfEnum : return "BasalforcingsIsmip6Tf"; … … 606 645 case BaseSlopeYEnum : return "BaseSlopeY"; 607 646 case BaselineBasalforcingsFloatingiceMeltingRateEnum : return "BaselineBasalforcingsFloatingiceMeltingRate"; 647 case BaselineBasalforcingsSpatialDeepwaterMeltingRateEnum : return "BaselineBasalforcingsSpatialDeepwaterMeltingRate"; 608 648 case BaselineCalvingCalvingrateEnum : return "BaselineCalvingCalvingrate"; 609 649 case BaselineFrictionEffectivePressureEnum : return "BaselineFrictionEffectivePressure"; 650 case BaselineSmbMassBalanceEnum : return "BaselineSmbMassBalance"; 610 651 case BedEnum : return "Bed"; 611 652 case BedGRDEnum : return "BedGRD"; … … 620 661 case CalvingCalvingrateEnum : return "CalvingCalvingrate"; 621 662 case CalvingHabFractionEnum : return "CalvingHabFraction"; 663 case CalvingAblationrateEnum : return "CalvingAblationrate"; 622 664 case CalvingMeltingrateEnum : return "CalvingMeltingrate"; 623 665 case CalvingStressThresholdFloatingiceEnum : return "CalvingStressThresholdFloatingice"; 624 666 case CalvingStressThresholdGroundediceEnum : return "CalvingStressThresholdGroundedice"; 625 667 case CalvinglevermannCoeffEnum : return "CalvinglevermannCoeff"; 626 case CalvingratexAverageEnum : return "CalvingratexAverage";627 668 case CalvingratexEnum : return "Calvingratex"; 628 case CalvingrateyAverageEnum : return "CalvingrateyAverage";629 669 case CalvingrateyEnum : return "Calvingratey"; 630 670 case CalvingFluxLevelsetEnum : return "CalvingFluxLevelset"; … … 805 845 case RheologyBbarAbsGradientEnum : return "RheologyBbarAbsGradient"; 806 846 case SampleEnum : return "Sample"; 847 case SampleOldEnum : return "SampleOld"; 848 case SampleNoiseEnum : return "SampleNoise"; 807 849 case SamplingBetaEnum : return "SamplingBeta"; 808 850 case SamplingKappaEnum : return "SamplingKappa"; 851 case SamplingPhiEnum : return "SamplingPhi"; 852 case SamplingTauEnum : return "SamplingTau"; 809 853 case SealevelEnum : return "Sealevel"; 810 854 case SealevelGRDEnum : return "SealevelGRD"; … … 841 885 case BslcRateEnum : return "BslcRate"; 842 886 case GmtslcEnum : return "Gmtslc"; 843 case SealevelGrotm1Enum : return "SealevelGrotm1";844 case SealevelGrotm2Enum : return "SealevelGrotm2";845 case SealevelGrotm3Enum : return "SealevelGrotm3";846 case SealevelGUrotm1Enum : return "SealevelGUrotm1";847 case SealevelGUrotm2Enum : return "SealevelGUrotm2";848 case SealevelGUrotm3Enum : return "SealevelGUrotm3";849 case SealevelGNrotm1Enum : return "SealevelGNrotm1";850 case SealevelGNrotm2Enum : return "SealevelGNrotm2";851 case SealevelGNrotm3Enum : return "SealevelGNrotm3";852 case SealevelGErotm1Enum : return "SealevelGErotm1";853 case SealevelGErotm2Enum : return "SealevelGErotm2";854 case SealevelGErotm3Enum : return "SealevelGErotm3";855 887 case SealevelRSLBarystaticEnum : return "SealevelRSLBarystatic"; 856 888 case SealevelRSLRateEnum : return "SealevelRSLRate"; … … 864 896 case SealevelchangeGEEnum : return "SealevelchangeGE"; 865 897 case SealevelchangeGNEnum : return "SealevelchangeGN"; 898 case SealevelchangeGrotEnum : return "SealevelchangeGrot"; 899 case SealevelchangeGUrotEnum : return "SealevelchangeGUrot"; 900 case SealevelchangeGNrotEnum : return "SealevelchangeGNrot"; 901 case SealevelchangeGErotEnum : return "SealevelchangeGErot"; 866 902 case SealevelchangeGsubelOceanEnum : return "SealevelchangeGsubelOcean"; 867 903 case SealevelchangeGUsubelOceanEnum : return "SealevelchangeGUsubelOcean"; … … 1197 1233 case ArrheniusEnum : return "Arrhenius"; 1198 1234 case AutodiffJacobianEnum : return "AutodiffJacobian"; 1235 case AutoregressionLinearFloatingMeltRateEnum : return "AutoregressionLinearFloatingMeltRate"; 1199 1236 case Balancethickness2AnalysisEnum : return "Balancethickness2Analysis"; 1200 1237 case Balancethickness2SolutionEnum : return "Balancethickness2Solution"; … … 1220 1257 case CalvingHabEnum : return "CalvingHab"; 1221 1258 case CalvingLevermannEnum : return "CalvingLevermann"; 1259 case CalvingTestEnum : return "CalvingTest"; 1260 case CalvingParameterizationEnum : return "CalvingParameterization"; 1222 1261 case CalvingVonmisesEnum : return "CalvingVonmises"; 1223 1262 case CfdragcoeffabsgradEnum : return "Cfdragcoeffabsgrad"; … … 1348 1387 case JEnum : return "J"; 1349 1388 case L1L2ApproximationEnum : return "L1L2Approximation"; 1350 case M LHOApproximationEnum : return "MLHOApproximation";1389 case MOLHOApproximationEnum : return "MOLHOApproximation"; 1351 1390 case L2ProjectionBaseAnalysisEnum : return "L2ProjectionBaseAnalysis"; 1352 1391 case L2ProjectionEPLAnalysisEnum : return "L2ProjectionEPLAnalysis"; … … 1360 1399 case LoadsEnum : return "Loads"; 1361 1400 case LoveAnalysisEnum : return "LoveAnalysis"; 1362 case LoveH iEnum : return "LoveHi";1363 case LoveH rEnum : return "LoveHr";1401 case LoveHfEnum : return "LoveHf"; 1402 case LoveHtEnum : return "LoveHt"; 1364 1403 case LoveKernelsImagEnum : return "LoveKernelsImag"; 1365 1404 case LoveKernelsRealEnum : return "LoveKernelsReal"; 1366 case LoveKiEnum : return "LoveKi"; 1367 case LoveKrEnum : return "LoveKr"; 1368 case LoveLiEnum : return "LoveLi"; 1369 case LoveLrEnum : return "LoveLr"; 1405 case LoveKfEnum : return "LoveKf"; 1406 case LoveKtEnum : return "LoveKt"; 1407 case LoveLfEnum : return "LoveLf"; 1408 case LoveLtEnum : return "LoveLt"; 1409 case LoveTidalHtEnum : return "LoveTidalHt"; 1410 case LoveTidalKtEnum : return "LoveTidalKt"; 1411 case LoveTidalLtEnum : return "LoveTidalLt"; 1412 case LovePMTF1tEnum : return "LovePMTF1t"; 1413 case LovePMTF2tEnum : return "LovePMTF2t"; 1370 1414 case LoveSolutionEnum : return "LoveSolution"; 1371 1415 case MINIEnum : return "MINI"; … … 1479 1523 case SealevelAbsoluteEnum : return "SealevelAbsolute"; 1480 1524 case SealevelEmotionEnum : return "SealevelEmotion"; 1481 case Sealevel InertiaTensorXZEnum : return "SealevelInertiaTensorXZ";1482 case Sealevel InertiaTensorYZEnum : return "SealevelInertiaTensorYZ";1483 case Sealevel InertiaTensorZZEnum : return "SealevelInertiaTensorZZ";1525 case SealevelchangePolarMotionXEnum : return "SealevelchangePolarMotionX"; 1526 case SealevelchangePolarMotionYEnum : return "SealevelchangePolarMotionY"; 1527 case SealevelchangePolarMotionZEnum : return "SealevelchangePolarMotionZ"; 1484 1528 case SealevelchangePolarMotionEnum : return "SealevelchangePolarMotion"; 1485 1529 case SealevelNmotionEnum : return "SealevelNmotion"; -
issm/trunk/src/c/shared/Enum/Enumjl.vim
r26744 r27035 57 57 syn keyword juliaConstC BalancethicknessStabilizationEnum 58 58 syn keyword juliaConstC BarystaticContributionsEnum 59 syn keyword juliaConstC BasalforcingsAutoregressionInitialTimeEnum 60 syn keyword juliaConstC BasalforcingsAutoregressionTimestepEnum 61 syn keyword juliaConstC BasalforcingsAutoregressiveOrderEnum 62 syn keyword juliaConstC BasalforcingsBeta0Enum 63 syn keyword juliaConstC BasalforcingsBeta1Enum 59 64 syn keyword juliaConstC BasalforcingsBottomplumedepthEnum 60 65 syn keyword juliaConstC BasalforcingsCrustthicknessEnum … … 70 75 syn keyword juliaConstC BasalforcingsIsmip6NumBasinsEnum 71 76 syn keyword juliaConstC BasalforcingsIsmip6TfDepthsEnum 77 syn keyword juliaConstC BasalforcingsLinearNumBasinsEnum 72 78 syn keyword juliaConstC BasalforcingsLowercrustheatEnum 73 79 syn keyword juliaConstC BasalforcingsMantleconductivityEnum 74 80 syn keyword juliaConstC BasalforcingsNusseltEnum 81 syn keyword juliaConstC BasalforcingsPhiEnum 75 82 syn keyword juliaConstC BasalforcingsPicoAverageOverturningEnum 76 83 syn keyword juliaConstC BasalforcingsPicoAverageSalinityEnum … … 98 105 syn keyword juliaConstC CalvingLawEnum 99 106 syn keyword juliaConstC CalvingMinthicknessEnum 107 syn keyword juliaConstC CalvingTestSpeedfactorEnum 108 syn keyword juliaConstC CalvingTestIndependentRateEnum 109 syn keyword juliaConstC CalvingUseParamEnum 110 syn keyword juliaConstC CalvingScaleThetaEnum 111 syn keyword juliaConstC CalvingAmpAlphaEnum 112 syn keyword juliaConstC CalvingMidpointEnum 113 syn keyword juliaConstC CalvingNonlinearLawEnum 100 114 syn keyword juliaConstC ConfigurationTypeEnum 101 115 syn keyword juliaConstC ConstantsGEnum … … 155 169 syn keyword juliaConstC FlowequationIsHOEnum 156 170 syn keyword juliaConstC FlowequationIsL1L2Enum 157 syn keyword juliaConstC FlowequationIsM LHOEnum171 syn keyword juliaConstC FlowequationIsMOLHOEnum 158 172 syn keyword juliaConstC FlowequationIsSIAEnum 159 173 syn keyword juliaConstC FlowequationIsSSAEnum … … 182 196 syn keyword juliaConstC GroundinglineMeltInterpolationEnum 183 197 syn keyword juliaConstC GroundinglineMigrationEnum 198 syn keyword juliaConstC GroundinglineNumRequestedOutputsEnum 199 syn keyword juliaConstC GroundinglineRequestedOutputsEnum 184 200 syn keyword juliaConstC HydrologyAveragingEnum 185 201 syn keyword juliaConstC HydrologyCavitySpacingEnum … … 256 272 syn keyword juliaConstC LockFileNameEnum 257 273 syn keyword juliaConstC LoveAllowLayerDeletionEnum 274 syn keyword juliaConstC LoveChandlerWobbleEnum 258 275 syn keyword juliaConstC LoveCoreMantleBoundaryEnum 259 276 syn keyword juliaConstC LoveEarthMassEnum … … 276 293 syn keyword juliaConstC LoveStartingLayerEnum 277 294 syn keyword juliaConstC LoveUnderflowTolEnum 295 syn keyword juliaConstC LovePostWidderThresholdEnum 278 296 syn keyword juliaConstC MassFluxSegmentsEnum 279 297 syn keyword juliaConstC MassFluxSegmentsPresentEnum … … 345 363 syn keyword juliaConstC ModelnameEnum 346 364 syn keyword juliaConstC SamplingAlphaEnum 347 syn keyword juliaConstC SamplingPhiEnum348 365 syn keyword juliaConstC SamplingNumRequestedOutputsEnum 349 366 syn keyword juliaConstC SamplingRequestedOutputsEnum 350 367 syn keyword juliaConstC SamplingRobinEnum 351 368 syn keyword juliaConstC SamplingSeedEnum 352 syn keyword juliaConstC SamplingTauEnum353 369 syn keyword juliaConstC SaveResultsEnum 354 370 syn keyword juliaConstC SolidearthPartitionIceEnum … … 362 378 syn keyword juliaConstC SolidearthSettingsAbstolEnum 363 379 syn keyword juliaConstC SolidearthSettingsCrossSectionShapeEnum 364 syn keyword juliaConstC RotationalAngularVelocityEnum365 380 syn keyword juliaConstC SolidearthSettingsElasticEnum 366 381 syn keyword juliaConstC SolidearthSettingsViscousEnum … … 369 384 syn keyword juliaConstC SealevelchangeViscousTimesEnum 370 385 syn keyword juliaConstC SealevelchangeViscousIndexEnum 386 syn keyword juliaConstC SealevelchangeViscousPolarMotionEnum 387 syn keyword juliaConstC SealevelchangeRunCountEnum 388 syn keyword juliaConstC SealevelchangeTransitionsEnum 389 syn keyword juliaConstC SealevelchangeRequestedOutputsEnum 390 syn keyword juliaConstC RotationalAngularVelocityEnum 371 391 syn keyword juliaConstC RotationalEquatorialMoiEnum 392 syn keyword juliaConstC RotationalPolarMoiEnum 393 syn keyword juliaConstC LovePolarMotionTransferFunctionColinearEnum 394 syn keyword juliaConstC LovePolarMotionTransferFunctionOrthogonalEnum 372 395 syn keyword juliaConstC TidalLoveHEnum 373 396 syn keyword juliaConstC TidalLoveKEnum … … 381 404 syn keyword juliaConstC SealevelchangeGSelfAttractionEnum 382 405 syn keyword juliaConstC SealevelchangeGViscoElasticEnum 406 syn keyword juliaConstC SealevelchangeUViscoElasticEnum 407 syn keyword juliaConstC SealevelchangeHViscoElasticEnum 408 syn keyword juliaConstC SealevelchangePolarMotionTransferFunctionColinearEnum 409 syn keyword juliaConstC SealevelchangePolarMotionTransferFunctionOrthogonalEnum 410 syn keyword juliaConstC SealevelchangePolarMotionTransferFunctionZEnum 411 syn keyword juliaConstC SealevelchangeTidalK2Enum 412 syn keyword juliaConstC SealevelchangeTidalH2Enum 413 syn keyword juliaConstC SealevelchangeTidalL2Enum 383 414 syn keyword juliaConstC SolidearthSettingsSealevelLoadingEnum 384 415 syn keyword juliaConstC SolidearthSettingsGRDEnum 385 416 syn keyword juliaConstC SolidearthSettingsRunFrequencyEnum 386 417 syn keyword juliaConstC SolidearthSettingsTimeAccEnum 387 syn keyword juliaConstC SealevelchangeHViscoElasticEnum388 418 syn keyword juliaConstC SolidearthSettingsHorizEnum 389 419 syn keyword juliaConstC SolidearthSettingsMaxiterEnum … … 397 427 syn keyword juliaConstC StochasticForcingIsStochasticForcingEnum 398 428 syn keyword juliaConstC StochasticForcingIsWaterPressureEnum 429 syn keyword juliaConstC StochasticForcingNoisetermsEnum 399 430 syn keyword juliaConstC StochasticForcingNumFieldsEnum 400 431 syn keyword juliaConstC StochasticForcingRandomflagEnum 401 syn keyword juliaConstC RotationalPolarMoiEnum432 syn keyword juliaConstC StochasticForcingTimestepEnum 402 433 syn keyword juliaConstC SolidearthSettingsReltolEnum 403 syn keyword juliaConstC SealevelchangeRequestedOutputsEnum404 434 syn keyword juliaConstC SolidearthSettingsSelfAttractionEnum 405 435 syn keyword juliaConstC SolidearthSettingsRotationEnum 406 436 syn keyword juliaConstC SolidearthSettingsMaxSHCoeffEnum 407 syn keyword juliaConstC SealevelchangeRunCountEnum408 syn keyword juliaConstC SealevelchangeTransitionsEnum409 syn keyword juliaConstC SealevelchangeUViscoElasticEnum410 437 syn keyword juliaConstC SettingsIoGatherEnum 411 438 syn keyword juliaConstC SettingsNumResultsOnNodesEnum … … 432 459 syn keyword juliaConstC SmbDpermilEnum 433 460 syn keyword juliaConstC SmbDsnowIdxEnum 461 syn keyword juliaConstC SmbElevationBinsEnum 434 462 syn keyword juliaConstC SmbCldFracEnum 435 463 syn keyword juliaConstC SmbDelta18oEnum … … 459 487 syn keyword juliaConstC SmbIsturbulentfluxEnum 460 488 syn keyword juliaConstC SmbKEnum 489 syn keyword juliaConstC SmbLapseRatesEnum 461 490 syn keyword juliaConstC SmbNumBasinsEnum 491 syn keyword juliaConstC SmbNumElevationBinsEnum 462 492 syn keyword juliaConstC SmbNumRequestedOutputsEnum 463 493 syn keyword juliaConstC SmbPfacEnum 464 494 syn keyword juliaConstC SmbPhiEnum 465 495 syn keyword juliaConstC SmbRdlEnum 496 syn keyword juliaConstC SmbRefElevationEnum 466 497 syn keyword juliaConstC SmbRequestedOutputsEnum 467 498 syn keyword juliaConstC SmbRlapsEnum … … 572 603 syn keyword juliaConstC BalancethicknessThickeningRateEnum 573 604 syn keyword juliaConstC BasalCrevasseEnum 605 syn keyword juliaConstC BasalforcingsDeepwaterMeltingRateAutoregressionEnum 606 syn keyword juliaConstC BasalforcingsDeepwaterMeltingRateNoiseEnum 607 syn keyword juliaConstC BasalforcingsDeepwaterMeltingRateValuesAutoregressionEnum 574 608 syn keyword juliaConstC BasalforcingsFloatingiceMeltingRateEnum 575 609 syn keyword juliaConstC BasalforcingsGeothermalfluxEnum 576 610 syn keyword juliaConstC BasalforcingsGroundediceMeltingRateEnum 611 syn keyword juliaConstC BasalforcingsLinearBasinIdEnum 577 612 syn keyword juliaConstC BasalforcingsPerturbationMeltingRateEnum 613 syn keyword juliaConstC BasalforcingsSpatialDeepwaterElevationEnum 614 syn keyword juliaConstC BasalforcingsSpatialDeepwaterMeltingRateEnum 615 syn keyword juliaConstC BasalforcingsSpatialUpperwaterElevationEnum 616 syn keyword juliaConstC BasalforcingsSpatialUpperwaterMeltingRateEnum 578 617 syn keyword juliaConstC BasalforcingsIsmip6BasinIdEnum 579 618 syn keyword juliaConstC BasalforcingsIsmip6TfEnum … … 597 636 syn keyword juliaConstC BaseSlopeYEnum 598 637 syn keyword juliaConstC BaselineBasalforcingsFloatingiceMeltingRateEnum 638 syn keyword juliaConstC BaselineBasalforcingsSpatialDeepwaterMeltingRateEnum 599 639 syn keyword juliaConstC BaselineCalvingCalvingrateEnum 600 640 syn keyword juliaConstC BaselineFrictionEffectivePressureEnum 641 syn keyword juliaConstC BaselineSmbMassBalanceEnum 601 642 syn keyword juliaConstC BedEnum 602 643 syn keyword juliaConstC BedGRDEnum … … 611 652 syn keyword juliaConstC CalvingCalvingrateEnum 612 653 syn keyword juliaConstC CalvingHabFractionEnum 654 syn keyword juliaConstC CalvingAblationrateEnum 613 655 syn keyword juliaConstC CalvingMeltingrateEnum 614 656 syn keyword juliaConstC CalvingStressThresholdFloatingiceEnum 615 657 syn keyword juliaConstC CalvingStressThresholdGroundediceEnum 616 658 syn keyword juliaConstC CalvinglevermannCoeffEnum 617 syn keyword juliaConstC CalvingratexAverageEnum618 659 syn keyword juliaConstC CalvingratexEnum 619 syn keyword juliaConstC CalvingrateyAverageEnum620 660 syn keyword juliaConstC CalvingrateyEnum 621 661 syn keyword juliaConstC CalvingFluxLevelsetEnum … … 796 836 syn keyword juliaConstC RheologyBbarAbsGradientEnum 797 837 syn keyword juliaConstC SampleEnum 838 syn keyword juliaConstC SampleOldEnum 839 syn keyword juliaConstC SampleNoiseEnum 798 840 syn keyword juliaConstC SamplingBetaEnum 799 841 syn keyword juliaConstC SamplingKappaEnum 842 syn keyword juliaConstC SamplingPhiEnum 843 syn keyword juliaConstC SamplingTauEnum 800 844 syn keyword juliaConstC SealevelEnum 801 845 syn keyword juliaConstC SealevelGRDEnum … … 832 876 syn keyword juliaConstC BslcRateEnum 833 877 syn keyword juliaConstC GmtslcEnum 834 syn keyword juliaConstC SealevelGrotm1Enum835 syn keyword juliaConstC SealevelGrotm2Enum836 syn keyword juliaConstC SealevelGrotm3Enum837 syn keyword juliaConstC SealevelGUrotm1Enum838 syn keyword juliaConstC SealevelGUrotm2Enum839 syn keyword juliaConstC SealevelGUrotm3Enum840 syn keyword juliaConstC SealevelGNrotm1Enum841 syn keyword juliaConstC SealevelGNrotm2Enum842 syn keyword juliaConstC SealevelGNrotm3Enum843 syn keyword juliaConstC SealevelGErotm1Enum844 syn keyword juliaConstC SealevelGErotm2Enum845 syn keyword juliaConstC SealevelGErotm3Enum846 878 syn keyword juliaConstC SealevelRSLBarystaticEnum 847 879 syn keyword juliaConstC SealevelRSLRateEnum … … 855 887 syn keyword juliaConstC SealevelchangeGEEnum 856 888 syn keyword juliaConstC SealevelchangeGNEnum 889 syn keyword juliaConstC SealevelchangeGrotEnum 890 syn keyword juliaConstC SealevelchangeGUrotEnum 891 syn keyword juliaConstC SealevelchangeGNrotEnum 892 syn keyword juliaConstC SealevelchangeGErotEnum 857 893 syn keyword juliaConstC SealevelchangeGsubelOceanEnum 858 894 syn keyword juliaConstC SealevelchangeGUsubelOceanEnum … … 1188 1224 syn keyword juliaConstC ArrheniusEnum 1189 1225 syn keyword juliaConstC AutodiffJacobianEnum 1226 syn keyword juliaConstC AutoregressionLinearFloatingMeltRateEnum 1190 1227 syn keyword juliaConstC Balancethickness2AnalysisEnum 1191 1228 syn keyword juliaConstC Balancethickness2SolutionEnum … … 1211 1248 syn keyword juliaConstC CalvingHabEnum 1212 1249 syn keyword juliaConstC CalvingLevermannEnum 1250 syn keyword juliaConstC CalvingTestEnum 1251 syn keyword juliaConstC CalvingParameterizationEnum 1213 1252 syn keyword juliaConstC CalvingVonmisesEnum 1214 1253 syn keyword juliaConstC CfdragcoeffabsgradEnum … … 1339 1378 syn keyword juliaConstC JEnum 1340 1379 syn keyword juliaConstC L1L2ApproximationEnum 1341 syn keyword juliaConstC M LHOApproximationEnum1380 syn keyword juliaConstC MOLHOApproximationEnum 1342 1381 syn keyword juliaConstC L2ProjectionBaseAnalysisEnum 1343 1382 syn keyword juliaConstC L2ProjectionEPLAnalysisEnum … … 1351 1390 syn keyword juliaConstC LoadsEnum 1352 1391 syn keyword juliaConstC LoveAnalysisEnum 1353 syn keyword juliaConstC LoveH iEnum1354 syn keyword juliaConstC LoveH rEnum1392 syn keyword juliaConstC LoveHfEnum 1393 syn keyword juliaConstC LoveHtEnum 1355 1394 syn keyword juliaConstC LoveKernelsImagEnum 1356 1395 syn keyword juliaConstC LoveKernelsRealEnum 1357 syn keyword juliaConstC LoveKiEnum 1358 syn keyword juliaConstC LoveKrEnum 1359 syn keyword juliaConstC LoveLiEnum 1360 syn keyword juliaConstC LoveLrEnum 1396 syn keyword juliaConstC LoveKfEnum 1397 syn keyword juliaConstC LoveKtEnum 1398 syn keyword juliaConstC LoveLfEnum 1399 syn keyword juliaConstC LoveLtEnum 1400 syn keyword juliaConstC LoveTidalHtEnum 1401 syn keyword juliaConstC LoveTidalKtEnum 1402 syn keyword juliaConstC LoveTidalLtEnum 1403 syn keyword juliaConstC LovePMTF1tEnum 1404 syn keyword juliaConstC LovePMTF2tEnum 1361 1405 syn keyword juliaConstC LoveSolutionEnum 1362 1406 syn keyword juliaConstC MINIEnum … … 1470 1514 syn keyword juliaConstC SealevelAbsoluteEnum 1471 1515 syn keyword juliaConstC SealevelEmotionEnum 1472 syn keyword juliaConstC Sealevel InertiaTensorXZEnum1473 syn keyword juliaConstC Sealevel InertiaTensorYZEnum1474 syn keyword juliaConstC Sealevel InertiaTensorZZEnum1516 syn keyword juliaConstC SealevelchangePolarMotionXEnum 1517 syn keyword juliaConstC SealevelchangePolarMotionYEnum 1518 syn keyword juliaConstC SealevelchangePolarMotionZEnum 1475 1519 syn keyword juliaConstC SealevelchangePolarMotionEnum 1476 1520 syn keyword juliaConstC SealevelNmotionEnum -
issm/trunk/src/c/shared/Enum/StringToEnumx.cpp
r26744 r27035 66 66 else if (strcmp(name,"BalancethicknessStabilization")==0) return BalancethicknessStabilizationEnum; 67 67 else if (strcmp(name,"BarystaticContributions")==0) return BarystaticContributionsEnum; 68 else if (strcmp(name,"BasalforcingsAutoregressionInitialTime")==0) return BasalforcingsAutoregressionInitialTimeEnum; 69 else if (strcmp(name,"BasalforcingsAutoregressionTimestep")==0) return BasalforcingsAutoregressionTimestepEnum; 70 else if (strcmp(name,"BasalforcingsAutoregressiveOrder")==0) return BasalforcingsAutoregressiveOrderEnum; 71 else if (strcmp(name,"BasalforcingsBeta0")==0) return BasalforcingsBeta0Enum; 72 else if (strcmp(name,"BasalforcingsBeta1")==0) return BasalforcingsBeta1Enum; 68 73 else if (strcmp(name,"BasalforcingsBottomplumedepth")==0) return BasalforcingsBottomplumedepthEnum; 69 74 else if (strcmp(name,"BasalforcingsCrustthickness")==0) return BasalforcingsCrustthicknessEnum; … … 79 84 else if (strcmp(name,"BasalforcingsIsmip6NumBasins")==0) return BasalforcingsIsmip6NumBasinsEnum; 80 85 else if (strcmp(name,"BasalforcingsIsmip6TfDepths")==0) return BasalforcingsIsmip6TfDepthsEnum; 86 else if (strcmp(name,"BasalforcingsLinearNumBasins")==0) return BasalforcingsLinearNumBasinsEnum; 81 87 else if (strcmp(name,"BasalforcingsLowercrustheat")==0) return BasalforcingsLowercrustheatEnum; 82 88 else if (strcmp(name,"BasalforcingsMantleconductivity")==0) return BasalforcingsMantleconductivityEnum; 83 89 else if (strcmp(name,"BasalforcingsNusselt")==0) return BasalforcingsNusseltEnum; 90 else if (strcmp(name,"BasalforcingsPhi")==0) return BasalforcingsPhiEnum; 84 91 else if (strcmp(name,"BasalforcingsPicoAverageOverturning")==0) return BasalforcingsPicoAverageOverturningEnum; 85 92 else if (strcmp(name,"BasalforcingsPicoAverageSalinity")==0) return BasalforcingsPicoAverageSalinityEnum; … … 107 114 else if (strcmp(name,"CalvingLaw")==0) return CalvingLawEnum; 108 115 else if (strcmp(name,"CalvingMinthickness")==0) return CalvingMinthicknessEnum; 116 else if (strcmp(name,"CalvingTestSpeedfactor")==0) return CalvingTestSpeedfactorEnum; 117 else if (strcmp(name,"CalvingTestIndependentRate")==0) return CalvingTestIndependentRateEnum; 118 else if (strcmp(name,"CalvingUseParam")==0) return CalvingUseParamEnum; 119 else if (strcmp(name,"CalvingScaleTheta")==0) return CalvingScaleThetaEnum; 120 else if (strcmp(name,"CalvingAmpAlpha")==0) return CalvingAmpAlphaEnum; 121 else if (strcmp(name,"CalvingMidpoint")==0) return CalvingMidpointEnum; 122 else if (strcmp(name,"CalvingNonlinearLaw")==0) return CalvingNonlinearLawEnum; 109 123 else if (strcmp(name,"ConfigurationType")==0) return ConfigurationTypeEnum; 110 124 else if (strcmp(name,"ConstantsG")==0) return ConstantsGEnum; … … 123 137 else if (strcmp(name,"CumBslcOceanPartition")==0) return CumBslcOceanPartitionEnum; 124 138 else if (strcmp(name,"CumGmtslc")==0) return CumGmtslcEnum; 125 else if (strcmp(name,"CumGmslc")==0) return CumGmslcEnum; 139 else stage=2; 140 } 141 if(stage==2){ 142 if (strcmp(name,"CumGmslc")==0) return CumGmslcEnum; 126 143 else if (strcmp(name,"DamageC1")==0) return DamageC1Enum; 127 144 else if (strcmp(name,"DamageC2")==0) return DamageC2Enum; … … 137 154 else if (strcmp(name,"DamageMaxDamage")==0) return DamageMaxDamageEnum; 138 155 else if (strcmp(name,"DamageStabilization")==0) return DamageStabilizationEnum; 139 else stage=2; 140 } 141 if(stage==2){ 142 if (strcmp(name,"DamageStressThreshold")==0) return DamageStressThresholdEnum; 156 else if (strcmp(name,"DamageStressThreshold")==0) return DamageStressThresholdEnum; 143 157 else if (strcmp(name,"DamageStressUBound")==0) return DamageStressUBoundEnum; 144 158 else if (strcmp(name,"DebugProfiling")==0) return DebugProfilingEnum; … … 167 181 else if (strcmp(name,"FlowequationIsHO")==0) return FlowequationIsHOEnum; 168 182 else if (strcmp(name,"FlowequationIsL1L2")==0) return FlowequationIsL1L2Enum; 169 else if (strcmp(name,"FlowequationIsM LHO")==0) return FlowequationIsMLHOEnum;183 else if (strcmp(name,"FlowequationIsMOLHO")==0) return FlowequationIsMOLHOEnum; 170 184 else if (strcmp(name,"FlowequationIsSIA")==0) return FlowequationIsSIAEnum; 171 185 else if (strcmp(name,"FlowequationIsSSA")==0) return FlowequationIsSSAEnum; … … 194 208 else if (strcmp(name,"GroundinglineMeltInterpolation")==0) return GroundinglineMeltInterpolationEnum; 195 209 else if (strcmp(name,"GroundinglineMigration")==0) return GroundinglineMigrationEnum; 210 else if (strcmp(name,"GroundinglineNumRequestedOutputs")==0) return GroundinglineNumRequestedOutputsEnum; 211 else if (strcmp(name,"GroundinglineRequestedOutputs")==0) return GroundinglineRequestedOutputsEnum; 196 212 else if (strcmp(name,"HydrologyAveraging")==0) return HydrologyAveragingEnum; 197 213 else if (strcmp(name,"HydrologyCavitySpacing")==0) return HydrologyCavitySpacingEnum; … … 244 260 else if (strcmp(name,"InversionAlgorithm")==0) return InversionAlgorithmEnum; 245 261 else if (strcmp(name,"InversionControlParameters")==0) return InversionControlParametersEnum; 246 else if (strcmp(name,"InversionControlScalingFactors")==0) return InversionControlScalingFactorsEnum; 262 else stage=3; 263 } 264 if(stage==3){ 265 if (strcmp(name,"InversionControlScalingFactors")==0) return InversionControlScalingFactorsEnum; 247 266 else if (strcmp(name,"InversionCostFunctions")==0) return InversionCostFunctionsEnum; 248 267 else if (strcmp(name,"InversionDxmin")==0) return InversionDxminEnum; … … 260 279 else if (strcmp(name,"InversionNumCostFunctions")==0) return InversionNumCostFunctionsEnum; 261 280 else if (strcmp(name,"InversionStepThreshold")==0) return InversionStepThresholdEnum; 262 else stage=3; 263 } 264 if(stage==3){ 265 if (strcmp(name,"InversionType")==0) return InversionTypeEnum; 281 else if (strcmp(name,"InversionType")==0) return InversionTypeEnum; 266 282 else if (strcmp(name,"Ivins")==0) return IvinsEnum; 267 283 else if (strcmp(name,"IsSlcCoupling")==0) return IsSlcCouplingEnum; … … 271 287 else if (strcmp(name,"LockFileName")==0) return LockFileNameEnum; 272 288 else if (strcmp(name,"LoveAllowLayerDeletion")==0) return LoveAllowLayerDeletionEnum; 289 else if (strcmp(name,"LoveChandlerWobble")==0) return LoveChandlerWobbleEnum; 273 290 else if (strcmp(name,"LoveCoreMantleBoundary")==0) return LoveCoreMantleBoundaryEnum; 274 291 else if (strcmp(name,"LoveEarthMass")==0) return LoveEarthMassEnum; … … 291 308 else if (strcmp(name,"LoveStartingLayer")==0) return LoveStartingLayerEnum; 292 309 else if (strcmp(name,"LoveUnderflowTol")==0) return LoveUnderflowTolEnum; 310 else if (strcmp(name,"LovePostWidderThreshold")==0) return LovePostWidderThresholdEnum; 293 311 else if (strcmp(name,"MassFluxSegments")==0) return MassFluxSegmentsEnum; 294 312 else if (strcmp(name,"MassFluxSegmentsPresent")==0) return MassFluxSegmentsPresentEnum; … … 360 378 else if (strcmp(name,"Modelname")==0) return ModelnameEnum; 361 379 else if (strcmp(name,"SamplingAlpha")==0) return SamplingAlphaEnum; 362 else if (strcmp(name,"SamplingPhi")==0) return SamplingPhiEnum;363 380 else if (strcmp(name,"SamplingNumRequestedOutputs")==0) return SamplingNumRequestedOutputsEnum; 364 381 else if (strcmp(name,"SamplingRequestedOutputs")==0) return SamplingRequestedOutputsEnum; 365 382 else if (strcmp(name,"SamplingRobin")==0) return SamplingRobinEnum; 366 383 else if (strcmp(name,"SamplingSeed")==0) return SamplingSeedEnum; 367 else if (strcmp(name,"SamplingTau")==0) return SamplingTauEnum;368 384 else if (strcmp(name,"SaveResults")==0) return SaveResultsEnum; 369 else if (strcmp(name,"SolidearthPartitionIce")==0) return SolidearthPartitionIceEnum; 385 else stage=4; 386 } 387 if(stage==4){ 388 if (strcmp(name,"SolidearthPartitionIce")==0) return SolidearthPartitionIceEnum; 370 389 else if (strcmp(name,"SolidearthPartitionHydro")==0) return SolidearthPartitionHydroEnum; 371 390 else if (strcmp(name,"SolidearthPartitionOcean")==0) return SolidearthPartitionOceanEnum; … … 377 396 else if (strcmp(name,"SolidearthSettingsAbstol")==0) return SolidearthSettingsAbstolEnum; 378 397 else if (strcmp(name,"SolidearthSettingsCrossSectionShape")==0) return SolidearthSettingsCrossSectionShapeEnum; 379 else if (strcmp(name,"RotationalAngularVelocity")==0) return RotationalAngularVelocityEnum;380 398 else if (strcmp(name,"SolidearthSettingsElastic")==0) return SolidearthSettingsElasticEnum; 381 399 else if (strcmp(name,"SolidearthSettingsViscous")==0) return SolidearthSettingsViscousEnum; … … 383 401 else if (strcmp(name,"SealevelchangeViscousNumSteps")==0) return SealevelchangeViscousNumStepsEnum; 384 402 else if (strcmp(name,"SealevelchangeViscousTimes")==0) return SealevelchangeViscousTimesEnum; 385 else stage=4; 386 } 387 if(stage==4){ 388 if (strcmp(name,"SealevelchangeViscousIndex")==0) return SealevelchangeViscousIndexEnum; 403 else if (strcmp(name,"SealevelchangeViscousIndex")==0) return SealevelchangeViscousIndexEnum; 404 else if (strcmp(name,"SealevelchangeViscousPolarMotion")==0) return SealevelchangeViscousPolarMotionEnum; 405 else if (strcmp(name,"SealevelchangeRunCount")==0) return SealevelchangeRunCountEnum; 406 else if (strcmp(name,"SealevelchangeTransitions")==0) return SealevelchangeTransitionsEnum; 407 else if (strcmp(name,"SealevelchangeRequestedOutputs")==0) return SealevelchangeRequestedOutputsEnum; 408 else if (strcmp(name,"RotationalAngularVelocity")==0) return RotationalAngularVelocityEnum; 389 409 else if (strcmp(name,"RotationalEquatorialMoi")==0) return RotationalEquatorialMoiEnum; 410 else if (strcmp(name,"RotationalPolarMoi")==0) return RotationalPolarMoiEnum; 411 else if (strcmp(name,"LovePolarMotionTransferFunctionColinear")==0) return LovePolarMotionTransferFunctionColinearEnum; 412 else if (strcmp(name,"LovePolarMotionTransferFunctionOrthogonal")==0) return LovePolarMotionTransferFunctionOrthogonalEnum; 390 413 else if (strcmp(name,"TidalLoveH")==0) return TidalLoveHEnum; 391 414 else if (strcmp(name,"TidalLoveK")==0) return TidalLoveKEnum; … … 399 422 else if (strcmp(name,"SealevelchangeGSelfAttraction")==0) return SealevelchangeGSelfAttractionEnum; 400 423 else if (strcmp(name,"SealevelchangeGViscoElastic")==0) return SealevelchangeGViscoElasticEnum; 424 else if (strcmp(name,"SealevelchangeUViscoElastic")==0) return SealevelchangeUViscoElasticEnum; 425 else if (strcmp(name,"SealevelchangeHViscoElastic")==0) return SealevelchangeHViscoElasticEnum; 426 else if (strcmp(name,"SealevelchangePolarMotionTransferFunctionColinear")==0) return SealevelchangePolarMotionTransferFunctionColinearEnum; 427 else if (strcmp(name,"SealevelchangePolarMotionTransferFunctionOrthogonal")==0) return SealevelchangePolarMotionTransferFunctionOrthogonalEnum; 428 else if (strcmp(name,"SealevelchangePolarMotionTransferFunctionZ")==0) return SealevelchangePolarMotionTransferFunctionZEnum; 429 else if (strcmp(name,"SealevelchangeTidalK2")==0) return SealevelchangeTidalK2Enum; 430 else if (strcmp(name,"SealevelchangeTidalH2")==0) return SealevelchangeTidalH2Enum; 431 else if (strcmp(name,"SealevelchangeTidalL2")==0) return SealevelchangeTidalL2Enum; 401 432 else if (strcmp(name,"SolidearthSettingsSealevelLoading")==0) return SolidearthSettingsSealevelLoadingEnum; 402 433 else if (strcmp(name,"SolidearthSettingsGRD")==0) return SolidearthSettingsGRDEnum; 403 434 else if (strcmp(name,"SolidearthSettingsRunFrequency")==0) return SolidearthSettingsRunFrequencyEnum; 404 435 else if (strcmp(name,"SolidearthSettingsTimeAcc")==0) return SolidearthSettingsTimeAccEnum; 405 else if (strcmp(name,"SealevelchangeHViscoElastic")==0) return SealevelchangeHViscoElasticEnum;406 436 else if (strcmp(name,"SolidearthSettingsHoriz")==0) return SolidearthSettingsHorizEnum; 407 437 else if (strcmp(name,"SolidearthSettingsMaxiter")==0) return SolidearthSettingsMaxiterEnum; … … 415 445 else if (strcmp(name,"StochasticForcingIsStochasticForcing")==0) return StochasticForcingIsStochasticForcingEnum; 416 446 else if (strcmp(name,"StochasticForcingIsWaterPressure")==0) return StochasticForcingIsWaterPressureEnum; 447 else if (strcmp(name,"StochasticForcingNoiseterms")==0) return StochasticForcingNoisetermsEnum; 417 448 else if (strcmp(name,"StochasticForcingNumFields")==0) return StochasticForcingNumFieldsEnum; 418 449 else if (strcmp(name,"StochasticForcingRandomflag")==0) return StochasticForcingRandomflagEnum; 419 else if (strcmp(name," RotationalPolarMoi")==0) return RotationalPolarMoiEnum;450 else if (strcmp(name,"StochasticForcingTimestep")==0) return StochasticForcingTimestepEnum; 420 451 else if (strcmp(name,"SolidearthSettingsReltol")==0) return SolidearthSettingsReltolEnum; 421 else if (strcmp(name,"SealevelchangeRequestedOutputs")==0) return SealevelchangeRequestedOutputsEnum;422 452 else if (strcmp(name,"SolidearthSettingsSelfAttraction")==0) return SolidearthSettingsSelfAttractionEnum; 423 453 else if (strcmp(name,"SolidearthSettingsRotation")==0) return SolidearthSettingsRotationEnum; 424 454 else if (strcmp(name,"SolidearthSettingsMaxSHCoeff")==0) return SolidearthSettingsMaxSHCoeffEnum; 425 else if (strcmp(name,"SealevelchangeRunCount")==0) return SealevelchangeRunCountEnum;426 else if (strcmp(name,"SealevelchangeTransitions")==0) return SealevelchangeTransitionsEnum;427 else if (strcmp(name,"SealevelchangeUViscoElastic")==0) return SealevelchangeUViscoElasticEnum;428 455 else if (strcmp(name,"SettingsIoGather")==0) return SettingsIoGatherEnum; 429 456 else if (strcmp(name,"SettingsNumResultsOnNodes")==0) return SettingsNumResultsOnNodesEnum; … … 450 477 else if (strcmp(name,"SmbDpermil")==0) return SmbDpermilEnum; 451 478 else if (strcmp(name,"SmbDsnowIdx")==0) return SmbDsnowIdxEnum; 479 else if (strcmp(name,"SmbElevationBins")==0) return SmbElevationBinsEnum; 452 480 else if (strcmp(name,"SmbCldFrac")==0) return SmbCldFracEnum; 453 481 else if (strcmp(name,"SmbDelta18o")==0) return SmbDelta18oEnum; … … 477 505 else if (strcmp(name,"SmbIsturbulentflux")==0) return SmbIsturbulentfluxEnum; 478 506 else if (strcmp(name,"SmbK")==0) return SmbKEnum; 479 else if (strcmp(name,"SmbNumBasins")==0) return SmbNumBasinsEnum; 507 else if (strcmp(name,"SmbLapseRates")==0) return SmbLapseRatesEnum; 508 else stage=5; 509 } 510 if(stage==5){ 511 if (strcmp(name,"SmbNumBasins")==0) return SmbNumBasinsEnum; 512 else if (strcmp(name,"SmbNumElevationBins")==0) return SmbNumElevationBinsEnum; 480 513 else if (strcmp(name,"SmbNumRequestedOutputs")==0) return SmbNumRequestedOutputsEnum; 481 514 else if (strcmp(name,"SmbPfac")==0) return SmbPfacEnum; 482 515 else if (strcmp(name,"SmbPhi")==0) return SmbPhiEnum; 483 516 else if (strcmp(name,"SmbRdl")==0) return SmbRdlEnum; 517 else if (strcmp(name,"SmbRefElevation")==0) return SmbRefElevationEnum; 484 518 else if (strcmp(name,"SmbRequestedOutputs")==0) return SmbRequestedOutputsEnum; 485 519 else if (strcmp(name,"SmbRlaps")==0) return SmbRlapsEnum; … … 506 540 else if (strcmp(name,"Step")==0) return StepEnum; 507 541 else if (strcmp(name,"Steps")==0) return StepsEnum; 508 else stage=5; 509 } 510 if(stage==5){ 511 if (strcmp(name,"StressbalanceAbstol")==0) return StressbalanceAbstolEnum; 542 else if (strcmp(name,"StressbalanceAbstol")==0) return StressbalanceAbstolEnum; 512 543 else if (strcmp(name,"StressbalanceFSreconditioning")==0) return StressbalanceFSreconditioningEnum; 513 544 else if (strcmp(name,"StressbalanceIsnewton")==0) return StressbalanceIsnewtonEnum; … … 593 624 else if (strcmp(name,"BalancethicknessThickeningRate")==0) return BalancethicknessThickeningRateEnum; 594 625 else if (strcmp(name,"BasalCrevasse")==0) return BasalCrevasseEnum; 626 else if (strcmp(name,"BasalforcingsDeepwaterMeltingRateAutoregression")==0) return BasalforcingsDeepwaterMeltingRateAutoregressionEnum; 627 else if (strcmp(name,"BasalforcingsDeepwaterMeltingRateNoise")==0) return BasalforcingsDeepwaterMeltingRateNoiseEnum; 628 else if (strcmp(name,"BasalforcingsDeepwaterMeltingRateValuesAutoregression")==0) return BasalforcingsDeepwaterMeltingRateValuesAutoregressionEnum; 595 629 else if (strcmp(name,"BasalforcingsFloatingiceMeltingRate")==0) return BasalforcingsFloatingiceMeltingRateEnum; 596 630 else if (strcmp(name,"BasalforcingsGeothermalflux")==0) return BasalforcingsGeothermalfluxEnum; 597 else if (strcmp(name,"BasalforcingsGroundediceMeltingRate")==0) return BasalforcingsGroundediceMeltingRateEnum; 631 else stage=6; 632 } 633 if(stage==6){ 634 if (strcmp(name,"BasalforcingsGroundediceMeltingRate")==0) return BasalforcingsGroundediceMeltingRateEnum; 635 else if (strcmp(name,"BasalforcingsLinearBasinId")==0) return BasalforcingsLinearBasinIdEnum; 598 636 else if (strcmp(name,"BasalforcingsPerturbationMeltingRate")==0) return BasalforcingsPerturbationMeltingRateEnum; 637 else if (strcmp(name,"BasalforcingsSpatialDeepwaterElevation")==0) return BasalforcingsSpatialDeepwaterElevationEnum; 638 else if (strcmp(name,"BasalforcingsSpatialDeepwaterMeltingRate")==0) return BasalforcingsSpatialDeepwaterMeltingRateEnum; 639 else if (strcmp(name,"BasalforcingsSpatialUpperwaterElevation")==0) return BasalforcingsSpatialUpperwaterElevationEnum; 640 else if (strcmp(name,"BasalforcingsSpatialUpperwaterMeltingRate")==0) return BasalforcingsSpatialUpperwaterMeltingRateEnum; 599 641 else if (strcmp(name,"BasalforcingsIsmip6BasinId")==0) return BasalforcingsIsmip6BasinIdEnum; 600 642 else if (strcmp(name,"BasalforcingsIsmip6Tf")==0) return BasalforcingsIsmip6TfEnum; … … 618 660 else if (strcmp(name,"BaseSlopeY")==0) return BaseSlopeYEnum; 619 661 else if (strcmp(name,"BaselineBasalforcingsFloatingiceMeltingRate")==0) return BaselineBasalforcingsFloatingiceMeltingRateEnum; 662 else if (strcmp(name,"BaselineBasalforcingsSpatialDeepwaterMeltingRate")==0) return BaselineBasalforcingsSpatialDeepwaterMeltingRateEnum; 620 663 else if (strcmp(name,"BaselineCalvingCalvingrate")==0) return BaselineCalvingCalvingrateEnum; 621 664 else if (strcmp(name,"BaselineFrictionEffectivePressure")==0) return BaselineFrictionEffectivePressureEnum; 665 else if (strcmp(name,"BaselineSmbMassBalance")==0) return BaselineSmbMassBalanceEnum; 622 666 else if (strcmp(name,"Bed")==0) return BedEnum; 623 667 else if (strcmp(name,"BedGRD")==0) return BedGRDEnum; … … 629 673 else if (strcmp(name,"BedSlopeY")==0) return BedSlopeYEnum; 630 674 else if (strcmp(name,"BottomPressure")==0) return BottomPressureEnum; 631 else stage=6; 632 } 633 if(stage==6){ 634 if (strcmp(name,"BottomPressureOld")==0) return BottomPressureOldEnum; 675 else if (strcmp(name,"BottomPressureOld")==0) return BottomPressureOldEnum; 635 676 else if (strcmp(name,"CalvingCalvingrate")==0) return CalvingCalvingrateEnum; 636 677 else if (strcmp(name,"CalvingHabFraction")==0) return CalvingHabFractionEnum; 678 else if (strcmp(name,"CalvingAblationrate")==0) return CalvingAblationrateEnum; 637 679 else if (strcmp(name,"CalvingMeltingrate")==0) return CalvingMeltingrateEnum; 638 680 else if (strcmp(name,"CalvingStressThresholdFloatingice")==0) return CalvingStressThresholdFloatingiceEnum; 639 681 else if (strcmp(name,"CalvingStressThresholdGroundedice")==0) return CalvingStressThresholdGroundediceEnum; 640 682 else if (strcmp(name,"CalvinglevermannCoeff")==0) return CalvinglevermannCoeffEnum; 641 else if (strcmp(name,"CalvingratexAverage")==0) return CalvingratexAverageEnum;642 683 else if (strcmp(name,"Calvingratex")==0) return CalvingratexEnum; 643 else if (strcmp(name,"CalvingrateyAverage")==0) return CalvingrateyAverageEnum;644 684 else if (strcmp(name,"Calvingratey")==0) return CalvingrateyEnum; 645 685 else if (strcmp(name,"CalvingFluxLevelset")==0) return CalvingFluxLevelsetEnum; … … 712 752 else if (strcmp(name,"FrictionP")==0) return FrictionPEnum; 713 753 else if (strcmp(name,"FrictionPressureAdjustedTemperature")==0) return FrictionPressureAdjustedTemperatureEnum; 714 else if (strcmp(name,"FrictionQ")==0) return FrictionQEnum; 754 else stage=7; 755 } 756 if(stage==7){ 757 if (strcmp(name,"FrictionQ")==0) return FrictionQEnum; 715 758 else if (strcmp(name,"FrictionSedimentCompressibilityCoefficient")==0) return FrictionSedimentCompressibilityCoefficientEnum; 716 759 else if (strcmp(name,"FrictionTillFrictionAngle")==0) return FrictionTillFrictionAngleEnum; … … 752 795 else if (strcmp(name,"HydrologyHeadOld")==0) return HydrologyHeadOldEnum; 753 796 else if (strcmp(name,"HydrologyMoulinInput")==0) return HydrologyMoulinInputEnum; 754 else stage=7; 755 } 756 if(stage==7){ 757 if (strcmp(name,"HydrologyNeumannflux")==0) return HydrologyNeumannfluxEnum; 797 else if (strcmp(name,"HydrologyNeumannflux")==0) return HydrologyNeumannfluxEnum; 758 798 else if (strcmp(name,"HydrologyReynolds")==0) return HydrologyReynoldsEnum; 759 799 else if (strcmp(name,"HydrologySheetConductivity")==0) return HydrologySheetConductivityEnum; … … 823 863 else if (strcmp(name,"RheologyBbarAbsGradient")==0) return RheologyBbarAbsGradientEnum; 824 864 else if (strcmp(name,"Sample")==0) return SampleEnum; 865 else if (strcmp(name,"SampleOld")==0) return SampleOldEnum; 866 else if (strcmp(name,"SampleNoise")==0) return SampleNoiseEnum; 825 867 else if (strcmp(name,"SamplingBeta")==0) return SamplingBetaEnum; 826 868 else if (strcmp(name,"SamplingKappa")==0) return SamplingKappaEnum; 869 else if (strcmp(name,"SamplingPhi")==0) return SamplingPhiEnum; 870 else if (strcmp(name,"SamplingTau")==0) return SamplingTauEnum; 827 871 else if (strcmp(name,"Sealevel")==0) return SealevelEnum; 828 872 else if (strcmp(name,"SealevelGRD")==0) return SealevelGRDEnum; … … 831 875 else if (strcmp(name,"SealevelBarystaticIceWeights")==0) return SealevelBarystaticIceWeightsEnum; 832 876 else if (strcmp(name,"SealevelBarystaticIceArea")==0) return SealevelBarystaticIceAreaEnum; 833 else if (strcmp(name,"SealevelBarystaticIceLatbar")==0) return SealevelBarystaticIceLatbarEnum; 877 else stage=8; 878 } 879 if(stage==8){ 880 if (strcmp(name,"SealevelBarystaticIceLatbar")==0) return SealevelBarystaticIceLatbarEnum; 834 881 else if (strcmp(name,"SealevelBarystaticIceLongbar")==0) return SealevelBarystaticIceLongbarEnum; 835 882 else if (strcmp(name,"SealevelBarystaticIceLoad")==0) return SealevelBarystaticIceLoadEnum; … … 859 906 else if (strcmp(name,"BslcRate")==0) return BslcRateEnum; 860 907 else if (strcmp(name,"Gmtslc")==0) return GmtslcEnum; 861 else if (strcmp(name,"SealevelGrotm1")==0) return SealevelGrotm1Enum;862 else if (strcmp(name,"SealevelGrotm2")==0) return SealevelGrotm2Enum;863 else if (strcmp(name,"SealevelGrotm3")==0) return SealevelGrotm3Enum;864 else if (strcmp(name,"SealevelGUrotm1")==0) return SealevelGUrotm1Enum;865 else if (strcmp(name,"SealevelGUrotm2")==0) return SealevelGUrotm2Enum;866 else if (strcmp(name,"SealevelGUrotm3")==0) return SealevelGUrotm3Enum;867 else if (strcmp(name,"SealevelGNrotm1")==0) return SealevelGNrotm1Enum;868 else if (strcmp(name,"SealevelGNrotm2")==0) return SealevelGNrotm2Enum;869 else if (strcmp(name,"SealevelGNrotm3")==0) return SealevelGNrotm3Enum;870 else if (strcmp(name,"SealevelGErotm1")==0) return SealevelGErotm1Enum;871 else if (strcmp(name,"SealevelGErotm2")==0) return SealevelGErotm2Enum;872 else if (strcmp(name,"SealevelGErotm3")==0) return SealevelGErotm3Enum;873 908 else if (strcmp(name,"SealevelRSLBarystatic")==0) return SealevelRSLBarystaticEnum; 874 909 else if (strcmp(name,"SealevelRSLRate")==0) return SealevelRSLRateEnum; 875 910 else if (strcmp(name,"SealevelUGrd")==0) return SealevelUGrdEnum; 876 911 else if (strcmp(name,"SealevelNGrd")==0) return SealevelNGrdEnum; 877 else stage=8; 878 } 879 if(stage==8){ 880 if (strcmp(name,"SealevelUEastEsa")==0) return SealevelUEastEsaEnum; 912 else if (strcmp(name,"SealevelUEastEsa")==0) return SealevelUEastEsaEnum; 881 913 else if (strcmp(name,"SealevelUNorthEsa")==0) return SealevelUNorthEsaEnum; 882 914 else if (strcmp(name,"SealevelchangeIndices")==0) return SealevelchangeIndicesEnum; … … 885 917 else if (strcmp(name,"SealevelchangeGE")==0) return SealevelchangeGEEnum; 886 918 else if (strcmp(name,"SealevelchangeGN")==0) return SealevelchangeGNEnum; 919 else if (strcmp(name,"SealevelchangeGrot")==0) return SealevelchangeGrotEnum; 920 else if (strcmp(name,"SealevelchangeGUrot")==0) return SealevelchangeGUrotEnum; 921 else if (strcmp(name,"SealevelchangeGNrot")==0) return SealevelchangeGNrotEnum; 922 else if (strcmp(name,"SealevelchangeGErot")==0) return SealevelchangeGErotEnum; 887 923 else if (strcmp(name,"SealevelchangeGsubelOcean")==0) return SealevelchangeGsubelOceanEnum; 888 924 else if (strcmp(name,"SealevelchangeGUsubelOcean")==0) return SealevelchangeGUsubelOceanEnum; … … 962 998 else if (strcmp(name,"SmbGdnini")==0) return SmbGdniniEnum; 963 999 else if (strcmp(name,"SmbGsp")==0) return SmbGspEnum; 964 else if (strcmp(name,"SmbGspini")==0) return SmbGspiniEnum; 1000 else stage=9; 1001 } 1002 if(stage==9){ 1003 if (strcmp(name,"SmbGspini")==0) return SmbGspiniEnum; 965 1004 else if (strcmp(name,"SmbHref")==0) return SmbHrefEnum; 966 1005 else if (strcmp(name,"SmbIsInitialized")==0) return SmbIsInitializedEnum; … … 998 1037 else if (strcmp(name,"SmbSizeini")==0) return SmbSizeiniEnum; 999 1038 else if (strcmp(name,"SmbSmbCorr")==0) return SmbSmbCorrEnum; 1000 else stage=9; 1001 } 1002 if(stage==9){ 1003 if (strcmp(name,"SmbSmbref")==0) return SmbSmbrefEnum; 1039 else if (strcmp(name,"SmbSmbref")==0) return SmbSmbrefEnum; 1004 1040 else if (strcmp(name,"SmbSzaValue")==0) return SmbSzaValueEnum; 1005 1041 else if (strcmp(name,"SmbT")==0) return SmbTEnum; … … 1085 1121 else if (strcmp(name,"VxSurface")==0) return VxSurfaceEnum; 1086 1122 else if (strcmp(name,"VyAverage")==0) return VyAverageEnum; 1087 else if (strcmp(name,"VyBase")==0) return VyBaseEnum; 1123 else stage=10; 1124 } 1125 if(stage==10){ 1126 if (strcmp(name,"VyBase")==0) return VyBaseEnum; 1088 1127 else if (strcmp(name,"Vy")==0) return VyEnum; 1089 1128 else if (strcmp(name,"VyMesh")==0) return VyMeshEnum; … … 1121 1160 else if (strcmp(name,"Outputdefinition19")==0) return Outputdefinition19Enum; 1122 1161 else if (strcmp(name,"Outputdefinition20")==0) return Outputdefinition20Enum; 1123 else stage=10; 1124 } 1125 if(stage==10){ 1126 if (strcmp(name,"Outputdefinition21")==0) return Outputdefinition21Enum; 1162 else if (strcmp(name,"Outputdefinition21")==0) return Outputdefinition21Enum; 1127 1163 else if (strcmp(name,"Outputdefinition22")==0) return Outputdefinition22Enum; 1128 1164 else if (strcmp(name,"Outputdefinition23")==0) return Outputdefinition23Enum; … … 1208 1244 else if (strcmp(name,"Outputdefinition96")==0) return Outputdefinition96Enum; 1209 1245 else if (strcmp(name,"Outputdefinition97")==0) return Outputdefinition97Enum; 1210 else if (strcmp(name,"Outputdefinition98")==0) return Outputdefinition98Enum; 1246 else stage=11; 1247 } 1248 if(stage==11){ 1249 if (strcmp(name,"Outputdefinition98")==0) return Outputdefinition98Enum; 1211 1250 else if (strcmp(name,"Outputdefinition99")==0) return Outputdefinition99Enum; 1212 1251 else if (strcmp(name,"Outputdefinition9")==0) return Outputdefinition9Enum; … … 1224 1263 else if (strcmp(name,"Arrhenius")==0) return ArrheniusEnum; 1225 1264 else if (strcmp(name,"AutodiffJacobian")==0) return AutodiffJacobianEnum; 1265 else if (strcmp(name,"AutoregressionLinearFloatingMeltRate")==0) return AutoregressionLinearFloatingMeltRateEnum; 1226 1266 else if (strcmp(name,"Balancethickness2Analysis")==0) return Balancethickness2AnalysisEnum; 1227 1267 else if (strcmp(name,"Balancethickness2Solution")==0) return Balancethickness2SolutionEnum; … … 1244 1284 else if (strcmp(name,"Boundary")==0) return BoundaryEnum; 1245 1285 else if (strcmp(name,"BuddJacka")==0) return BuddJackaEnum; 1246 else stage=11; 1247 } 1248 if(stage==11){ 1249 if (strcmp(name,"CalvingDev2")==0) return CalvingDev2Enum; 1286 else if (strcmp(name,"CalvingDev2")==0) return CalvingDev2Enum; 1250 1287 else if (strcmp(name,"CalvingHab")==0) return CalvingHabEnum; 1251 1288 else if (strcmp(name,"CalvingLevermann")==0) return CalvingLevermannEnum; 1289 else if (strcmp(name,"CalvingTest")==0) return CalvingTestEnum; 1290 else if (strcmp(name,"CalvingParameterization")==0) return CalvingParameterizationEnum; 1252 1291 else if (strcmp(name,"CalvingVonmises")==0) return CalvingVonmisesEnum; 1253 1292 else if (strcmp(name,"Cfdragcoeffabsgrad")==0) return CfdragcoeffabsgradEnum; … … 1328 1367 else if (strcmp(name,"GaussTetra")==0) return GaussTetraEnum; 1329 1368 else if (strcmp(name,"GaussTria")==0) return GaussTriaEnum; 1330 else if (strcmp(name,"GenericOption")==0) return GenericOptionEnum; 1369 else stage=12; 1370 } 1371 if(stage==12){ 1372 if (strcmp(name,"GenericOption")==0) return GenericOptionEnum; 1331 1373 else if (strcmp(name,"GenericParam")==0) return GenericParamEnum; 1332 1374 else if (strcmp(name,"GenericExternalResult")==0) return GenericExternalResultEnum; … … 1367 1409 else if (strcmp(name,"Indexed")==0) return IndexedEnum; 1368 1410 else if (strcmp(name,"IntExternalResult")==0) return IntExternalResultEnum; 1369 else stage=12; 1370 } 1371 if(stage==12){ 1372 if (strcmp(name,"ElementInput")==0) return ElementInputEnum; 1411 else if (strcmp(name,"ElementInput")==0) return ElementInputEnum; 1373 1412 else if (strcmp(name,"IntMatExternalResult")==0) return IntMatExternalResultEnum; 1374 1413 else if (strcmp(name,"IntMatParam")==0) return IntMatParamEnum; … … 1381 1420 else if (strcmp(name,"J")==0) return JEnum; 1382 1421 else if (strcmp(name,"L1L2Approximation")==0) return L1L2ApproximationEnum; 1383 else if (strcmp(name,"M LHOApproximation")==0) return MLHOApproximationEnum;1422 else if (strcmp(name,"MOLHOApproximation")==0) return MOLHOApproximationEnum; 1384 1423 else if (strcmp(name,"L2ProjectionBaseAnalysis")==0) return L2ProjectionBaseAnalysisEnum; 1385 1424 else if (strcmp(name,"L2ProjectionEPLAnalysis")==0) return L2ProjectionEPLAnalysisEnum; … … 1393 1432 else if (strcmp(name,"Loads")==0) return LoadsEnum; 1394 1433 else if (strcmp(name,"LoveAnalysis")==0) return LoveAnalysisEnum; 1395 else if (strcmp(name,"LoveH i")==0) return LoveHiEnum;1396 else if (strcmp(name,"LoveH r")==0) return LoveHrEnum;1434 else if (strcmp(name,"LoveHf")==0) return LoveHfEnum; 1435 else if (strcmp(name,"LoveHt")==0) return LoveHtEnum; 1397 1436 else if (strcmp(name,"LoveKernelsImag")==0) return LoveKernelsImagEnum; 1398 1437 else if (strcmp(name,"LoveKernelsReal")==0) return LoveKernelsRealEnum; 1399 else if (strcmp(name,"LoveKi")==0) return LoveKiEnum; 1400 else if (strcmp(name,"LoveKr")==0) return LoveKrEnum; 1401 else if (strcmp(name,"LoveLi")==0) return LoveLiEnum; 1402 else if (strcmp(name,"LoveLr")==0) return LoveLrEnum; 1438 else if (strcmp(name,"LoveKf")==0) return LoveKfEnum; 1439 else if (strcmp(name,"LoveKt")==0) return LoveKtEnum; 1440 else if (strcmp(name,"LoveLf")==0) return LoveLfEnum; 1441 else if (strcmp(name,"LoveLt")==0) return LoveLtEnum; 1442 else if (strcmp(name,"LoveTidalHt")==0) return LoveTidalHtEnum; 1443 else if (strcmp(name,"LoveTidalKt")==0) return LoveTidalKtEnum; 1444 else if (strcmp(name,"LoveTidalLt")==0) return LoveTidalLtEnum; 1445 else if (strcmp(name,"LovePMTF1t")==0) return LovePMTF1tEnum; 1446 else if (strcmp(name,"LovePMTF2t")==0) return LovePMTF2tEnum; 1403 1447 else if (strcmp(name,"LoveSolution")==0) return LoveSolutionEnum; 1404 1448 else if (strcmp(name,"MINI")==0) return MINIEnum; … … 1446 1490 else if (strcmp(name,"Nodal")==0) return NodalEnum; 1447 1491 else if (strcmp(name,"Nodalvalue")==0) return NodalvalueEnum; 1448 else if (strcmp(name,"NodeSId")==0) return NodeSIdEnum; 1492 else stage=13; 1493 } 1494 if(stage==13){ 1495 if (strcmp(name,"NodeSId")==0) return NodeSIdEnum; 1449 1496 else if (strcmp(name,"NoneApproximation")==0) return NoneApproximationEnum; 1450 1497 else if (strcmp(name,"None")==0) return NoneEnum; … … 1490 1537 else if (strcmp(name,"Riftfront")==0) return RiftfrontEnum; 1491 1538 else if (strcmp(name,"SamplingAnalysis")==0) return SamplingAnalysisEnum; 1492 else stage=13; 1493 } 1494 if(stage==13){ 1495 if (strcmp(name,"SamplingSolution")==0) return SamplingSolutionEnum; 1539 else if (strcmp(name,"SamplingSolution")==0) return SamplingSolutionEnum; 1496 1540 else if (strcmp(name,"SIAApproximation")==0) return SIAApproximationEnum; 1497 1541 else if (strcmp(name,"SMBautoregression")==0) return SMBautoregressionEnum; … … 1515 1559 else if (strcmp(name,"SealevelAbsolute")==0) return SealevelAbsoluteEnum; 1516 1560 else if (strcmp(name,"SealevelEmotion")==0) return SealevelEmotionEnum; 1517 else if (strcmp(name,"Sealevel InertiaTensorXZ")==0) return SealevelInertiaTensorXZEnum;1518 else if (strcmp(name,"Sealevel InertiaTensorYZ")==0) return SealevelInertiaTensorYZEnum;1519 else if (strcmp(name,"Sealevel InertiaTensorZZ")==0) return SealevelInertiaTensorZZEnum;1561 else if (strcmp(name,"SealevelchangePolarMotionX")==0) return SealevelchangePolarMotionXEnum; 1562 else if (strcmp(name,"SealevelchangePolarMotionY")==0) return SealevelchangePolarMotionYEnum; 1563 else if (strcmp(name,"SealevelchangePolarMotionZ")==0) return SealevelchangePolarMotionZEnum; 1520 1564 else if (strcmp(name,"SealevelchangePolarMotion")==0) return SealevelchangePolarMotionEnum; 1521 1565 else if (strcmp(name,"SealevelNmotion")==0) return SealevelNmotionEnum; … … 1569 1613 else if (strcmp(name,"TotalSmbScaled")==0) return TotalSmbScaledEnum; 1570 1614 else if (strcmp(name,"TransientArrayParam")==0) return TransientArrayParamEnum; 1571 else if (strcmp(name,"TransientInput")==0) return TransientInputEnum; 1615 else stage=14; 1616 } 1617 if(stage==14){ 1618 if (strcmp(name,"TransientInput")==0) return TransientInputEnum; 1572 1619 else if (strcmp(name,"TransientParam")==0) return TransientParamEnum; 1573 1620 else if (strcmp(name,"TransientSolution")==0) return TransientSolutionEnum; … … 1604 1651 else if (strcmp(name,"TriangleInterp")==0) return TriangleInterpEnum; 1605 1652 else if (strcmp(name,"MaximumNumberOfDefinitions")==0) return MaximumNumberOfDefinitionsEnum; 1606 else stage=1 4;1653 else stage=15; 1607 1654 } 1608 1655 /*If we reach this point, the string provided has not been found*/ -
issm/trunk/src/c/shared/Enum/Synchronize.sh
r26744 r27035 193 193 END 194 194 #}}} 195 #Build issmenum.jl {{{ 196 #Header 197 cat <<END > $ISSM_DIR/src/c/shared/Enum/issmenums.jl 198 # WARNING: DO NOT MODIFY THIS FILE 199 # this file has been automatically generated by Synchronize.sh 200 # Please read README for more information 201 202 @enum IssmEnum begin 203 END 204 cat temp | awk '{print "\t" $1}' >> $ISSM_DIR/src/c/shared/Enum/issmenums.jl 205 #Move on to EnumToString 206 cat <<END >> $ISSM_DIR/src/c/shared/Enum/issmenums.jl 207 end 208 209 function EnumToString(enum::IssmEnum) 210 END 211 cat temp | awk '{print "\tif(enum==" $1 ") return \"" substr($1,1,length($1)-4) "\" end"}' >> $ISSM_DIR/src/c/shared/Enum/issmenums.jl 212 #Move on to StringToEnumx 213 cat <<END >> $ISSM_DIR/src/c/shared/Enum/issmenums.jl 214 end 215 END 216 #}}} 195 217 196 218 #vim file -
issm/trunk/src/c/shared/Exceptions/Exceptions.cpp
r25836 r27035 15 15 #include <iomanip> 16 16 #include "./exceptions.h" 17 #include "../io/Print/Print.h"18 #include "../io/Comm/IssmComm.h"19 #include "../MemOps/MemOps.h"20 17 21 18 ErrorException::ErrorException(const string & what_arg){/*{{{*/ … … 31 28 32 29 }/*}}}*/ 33 ErrorException::ErrorException( const string& what_file, const string& what_function,int what_line, const string& what_arg){/*{{{*/30 ErrorException::ErrorException(int what_rank,const string& what_file, const string& what_function,int what_line, const string& what_arg){/*{{{*/ 34 31 32 /*Intermediaries*/ 35 33 int len; 36 34 37 len = strlen(what_arg.c_str())+1; 38 what_str = new char[len]; 39 memcpy(what_str,what_arg.c_str(),len); 35 this->rank = what_rank; 36 this->file_line= what_line; 40 37 41 len = strlen(what_file.c_str())+1;42 file_name= new char[len];43 memcpy( file_name,what_file.c_str(),len);38 len = strlen(what_arg.c_str())+1; 39 this->what_str = new char[len]; 40 memcpy(this->what_str,what_arg.c_str(),len); 44 41 45 len = strlen(what_function.c_str())+1;46 function_name = new char[len];47 memcpy( function_name,what_function.c_str(),len);42 len = strlen(what_file.c_str())+1; 43 this->file_name = new char[len]; 44 memcpy(this->file_name,what_file.c_str(),len); 48 45 49 file_line= what_line;50 /*When error messages are not shown properly, uncomment the following line*/51 this->Report();46 len = strlen(what_function.c_str())+1; 47 this->function_name = new char[len]; 48 memcpy(this->function_name,what_function.c_str(),len); 52 49 50 /*Uncomment if messages do not print properly*/ 51 //this->Report(); 53 52 }/*}}}*/ 54 53 ErrorException::~ErrorException() throw(){/*{{{*/ … … 58 57 }/*}}}*/ 59 58 const char* ErrorException::what() const throw(){/*{{{*/ 60 //this->Report();61 59 return what_str; 62 60 }/*}}}*/ … … 64 62 65 63 /*WINDOWS*/ 66 if(! function_name ||file_line==0){67 _printf_("Error message: " << what());64 if(!this->function_name || this->file_line==0){ 65 cerr << "Error message: " << what() << endl; 68 66 return; 69 67 } 70 68 71 /*recover my_rank and num_procs:*/ 72 int my_rank = IssmComm::GetRank(); 73 int num_procs = IssmComm::GetSize(); 74 75 if(num_procs==1){ 76 _printf_("\n??? Error in ==> " << file_name << ":" << file_line << "\n"); 77 _printf_(function_name << " error message: " << what() << "\n\n"); 78 } 79 else{ 80 _printf_("\n[" << my_rank<< "] ??? Error using ==> " << file_name << ":" << file_line << "\n"); 81 _printf_( "[" << my_rank << "] " << function_name << " error message: " << what() << "\n\n"); 82 } 69 cerr <<"\n[" << this->rank<< "] ??? Error using ==> " << this->file_name << ":" << this->file_line << 70 "\n[" << this->rank<< "] " << this->function_name << " error message: " << what() << "\n" << endl; 83 71 84 72 return; … … 91 79 92 80 /*WINDOWS*/ 93 if(! function_name ||file_line==0){81 if(!this->function_name || this->file_line==0){ 94 82 buffer << " error message: " << this->what_str; 95 83 } … … 101 89 /*Convert std::ostringstream to std::string and then create char* */ 102 90 std::string buffer2 = buffer.str(); 103 message = xNew<char>(strlen(buffer2.c_str())+1); sprintf(message,"%s",buffer2.c_str()); 91 message = new char[strlen(buffer2.c_str())+1]; 92 sprintf(message,"%s",buffer2.c_str()); 93 104 94 return message; 105 95 }/*}}}*/ -
issm/trunk/src/c/shared/Exceptions/exceptions.h
r24686 r27035 28 28 #include <sstream> 29 29 30 /*macros: */ 30 /*macros: (should move somewhere else)*/ 31 #include "../io/Comm/IssmComm.h" 31 32 /* _assert_ {{{*/ 32 33 /*Assertion macro: do nothing if macro _ISSM_DEBUG_ undefined*/ … … 50 51 do{std::ostringstream aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy; \ 51 52 aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy << StreamArgs << std::ends; \ 52 throw ErrorException( __FILE__,__func__,__LINE__,aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy.str());}while(0)53 throw ErrorException(IssmComm::GetRank(),__FILE__,__func__,__LINE__,aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy.str());}while(0) 53 54 #endif 54 55 /*}}}*/ … … 78 79 79 80 /*ISSM exception class: */ 80 class ErrorException: public exception 81 class ErrorException: public exception{ /*{{{*/ 81 82 82 83 char* what_str; … … 84 85 char* file_name; 85 86 int file_line; 87 int rank; 86 88 87 89 public: 88 ErrorException(const string &what_arg); //for windows 89 ErrorException(const string &what_file,const string& what_function,int what_line,const string& what_arg);//UNIX 90 /*Windows*/ 91 ErrorException(const string &what_arg); 92 /*Linux/macOS*/ 93 ErrorException(int what_rank,const string &what_file,const string& what_function,int what_line,const string& what_arg); 90 94 ~ErrorException() throw(); 91 95 virtual const char *what() const throw(); -
issm/trunk/src/c/shared/MemOps/MemOps.h
r26744 r27035 151 151 template <class T> T* xMemCpy(T* dest, const T* src, unsigned int size) {/*{{{*/ 152 152 assert(dest); assert(src); 153 #if defined(_HAVE_ADOLC_) 153 #if defined(_HAVE_ADOLC_) || defined(_HAVE_CODIPACK_) 154 154 for (int i=0; i<size;++i) dest[i]=src[i]; 155 155 #else -
issm/trunk/src/c/shared/Random/randomgenerator.cpp
r26656 r27035 18 18 19 19 pseed = new unsigned int; 20 20 *pseed = std::chrono::steady_clock::now().time_since_epoch()/std::chrono::milliseconds(1); 21 21 a = 1103515245; // BSD Formula 22 22 c = 12345; // BSD Formula … … 24 24 return; 25 25 }/*}}}*/ 26 27 26 linear_congruential_engine::linear_congruential_engine(unsigned int _a, unsigned int _b, unsigned int _m){/*{{{*/ 28 27 29 28 pseed = new unsigned int; 30 29 *pseed = std::chrono::steady_clock::now().time_since_epoch()/std::chrono::milliseconds(1); 31 30 a = _a; 32 31 c = _b; … … 34 33 return; 35 34 }/*}}}*/ 36 37 35 linear_congruential_engine::~linear_congruential_engine(){} 38 36 -
issm/trunk/src/c/shared/io/Marshalling/IoCodeConversions.cpp
r26744 r27035 241 241 case 11: return SMBgradientscomponentsEnum; 242 242 case 12: return SMBsemicEnum; 243 case 55: return SMBautoregressionEnum;243 case 13: return SMBautoregressionEnum; 244 244 default: _error_("Marshalled SMB code \""<<enum_in<<"\" not supported yet"); 245 245 } … … 255 255 case 7: return BasalforcingsIsmip6Enum; 256 256 case 8: return BeckmannGoosseFloatingMeltRateEnum; 257 case 9: return AutoregressionLinearFloatingMeltRateEnum; 257 258 default: _error_("Marshalled Basal Forcings code \""<<enum_in<<"\" not supported yet"); 258 259 } … … 267 268 case 6: return CalvingCrevasseDepthEnum; 268 269 case 7: return CalvingDev2Enum; 270 case 9: return CalvingParameterizationEnum; 271 case 8: return CalvingTestEnum; 269 272 default: _error_("Marshalled Calving law code \""<<enum_in<<"\" not supported yet"); 270 273 } … … 274 277 case 1: return FrontalForcingsDefaultEnum; 275 278 case 2: return FrontalForcingsRignotEnum; 276 case 55: return FrontalForcingsRignotAutoregressionEnum;279 case 3: return FrontalForcingsRignotAutoregressionEnum; 277 280 default: _error_("Marshalled Frontalforcings code \""<<enum_in<<"\" not supported yet"); 278 281 } … … 342 345 case 2: return SSAApproximationEnum; 343 346 case 3: return L1L2ApproximationEnum; 344 case 4: return M LHOApproximationEnum;347 case 4: return MOLHOApproximationEnum; 345 348 case 5: return HOApproximationEnum; 346 349 case 6: return FSApproximationEnum; … … 357 360 case 2: return SSAApproximationEnum; 358 361 case 3: return L1L2ApproximationEnum; 359 case 4: return M LHOApproximationEnum;362 case 4: return MOLHOApproximationEnum; 360 363 case 5: return HOApproximationEnum; 361 364 case 6: return FSApproximationEnum; -
issm/trunk/src/c/shared/io/Marshalling/Marshalling.cpp
r26744 r27035 91 91 void RegisterInputFunctor::call(IssmDouble & value){/*{{{*/ 92 92 _assert_(this->double_count<size_max); 93 _assert_(!xIsNan<IssmDouble>(value)); 93 94 /*Comment out this assert, some parameters are NaN (e.g. abstol) by default*/ 95 //_assert_(!xIsNan<IssmDouble>(value)); 96 94 97 this->tape_codi->registerInput(value); 95 98 #if _CODIPACK_MAJOR_==2 … … 137 140 }/*}}}*/ 138 141 void RegisterOutputFunctor::call(IssmDouble & value){/*{{{*/ 139 _assert_(!xIsNan<IssmDouble>(value));142 //_assert_(!xIsNan<IssmDouble>(value)); 140 143 this->tape_codi->registerOutput(value); 141 144 this->double_count++; -
issm/trunk/src/c/solutionsequences/convergence.cpp
r24313 r27035 90 90 //compute max(du) 91 91 duf=old_uf->Duplicate(); old_uf->Copy(duf); duf->AYPX(uf,-1.0); 92 ndu =duf->Norm(NORM_TWO); nduinf=duf->Norm(NORM_INF);93 if (xIsNan<IssmDouble>(ndu ) || xIsNan<IssmDouble>(nu)) _error_("convergence criterion is NaN!");92 nduinf=duf->Norm(NORM_INF); 93 if (xIsNan<IssmDouble>(nduinf)) _error_("convergence criterion is NaN!"); 94 94 95 95 //clean up -
issm/trunk/src/c/solutionsequences/solutionsequence_sampling.cpp
r26744 r27035 13 13 void GaussianVector(Vector<IssmDouble>* ppf,int seed){/*{{{*/ 14 14 15 16 /*Intermediaries*/17 double rdnumber;18 19 15 /*Define seed*/ 20 16 rnd::linear_congruential_engine random_engine; 21 if(seed>=0) 22 { 17 if(seed>=0){ 23 18 int my_rank; 24 19 ISSM_MPI_Comm_rank(ISSM_MPI_COMM_WORLD,&my_rank); … … 28 23 29 24 /* Define univariate distribution */ 30 31 25 rnd::normal_distribution distribution(0.0,1.0); 32 26 … … 38 32 ppf->GetLocalSize(&M); 39 33 for(int i=0;i<M;i++){ 40 rdnumber = distribution.generator(random_engine);34 double rdnumber = distribution.generator(random_engine); 41 35 ppf->SetValue(local_indices[i],rdnumber,INS_VAL); 42 36 } 43 37 ppf->Assemble(); 44 38 39 /*Cleanup*/ 40 random_engine.free_resources(); 41 xDelete<int>(local_indices); 42 xDelete<IssmDouble>(local_vector); 45 43 }/*}}}*/ 46 44 void solutionsequence_sampling(FemModel* femmodel){ … … 51 49 Vector<IssmDouble>* ug = NULL; 52 50 Vector<IssmDouble>* uf = NULL; 53 Vector<IssmDouble>* old_uf = NULL; // previous solution vector (for transient) 54 Vector<IssmDouble>* pf = NULL; 51 Vector<IssmDouble>* pf = NULL; 55 52 Vector<IssmDouble>* df = NULL; 56 53 Vector<IssmDouble>* ys=NULL; … … 62 59 63 60 /*parameters:*/ 64 int solution_type, alpha, step, seed, nsize; 65 IssmDouble phi, tau; 61 int alpha, seed, nsize; 66 62 67 63 /*Recover parameters: */ 68 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);69 64 femmodel->parameters->FindParam(&seed,SamplingSeedEnum); 70 65 femmodel->parameters->FindParam(&alpha,SamplingAlphaEnum); 71 femmodel->parameters->FindParam(&tau,SamplingTauEnum);72 73 /*Recover parameters for transient simulation: */74 if(solution_type==TransientSolutionEnum)75 {76 femmodel->parameters->FindParam(&step,StepEnum);77 femmodel->parameters->FindParam(&phi,SamplingPhiEnum);78 if(seed>=0) seed = seed + 13923272*step; // change default seed for transient simulations (by considering an arbitrary shif based on the step number)79 80 GetSolutionFromInputsx(&ug,femmodel);81 Reducevectorgtofx(&uf, ug, femmodel->nodes,femmodel->parameters);82 old_uf=uf->Duplicate();83 }84 66 85 67 /*CreateAnalysis*/ … … 101 83 Reduceloadx(pf, Kfs, ys); 102 84 delete Kfs; 103 104 /*Copy old solution for transient run */105 if(solution_type==TransientSolutionEnum) uf->Copy(old_uf);106 85 107 86 /* Generate random RHS */ … … 130 109 } 131 110 132 /* Divide results by tau */133 uf->Scale(1.0/tau);134 135 /* Update solution x_{t+1} = phi x_{t} + noise for transient */136 if(solution_type==TransientSolutionEnum) uf->AXPY(old_uf,phi);137 138 111 /* Update input */ 139 112 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters); … … 141 114 142 115 /*clean-up*/ 143 delete Kff; delete pf; delete df; delete uf; delete ys; delete old_uf;116 delete Kff; delete pf; delete df; delete uf; delete ys; 144 117 delete Ml; delete Mscale; 145 118 delete analysis; -
issm/trunk/src/m/classes/SMBautoregression.m
r26744 r27035 14 14 phi = NaN; 15 15 basin_id = NaN; 16 lapserates = NaN; 17 elevationbins = NaN; 18 refelevation = NaN; 16 19 steps_per_step = 1; 17 20 averaging = 0; … … 59 62 self.ar_order = 0.0; %autoregression model of order 0 60 63 end % }}} 61 function md = checkconsistency(self,md,solution,analyses) 64 function md = checkconsistency(self,md,solution,analyses) % {{{ 62 65 63 66 if ismember('MasstransportAnalysis',analyses), … … 70 73 md = checkfield(md,'fieldname','smb.ar_timestep','numel',1,'NaN',1,'Inf',1,'>=',md.timestepping.time_step); %autoregression time step cannot be finer than ISSM timestep 71 74 md = checkfield(md,'fieldname','smb.phi','NaN',1,'Inf',1,'size',[md.smb.num_basins,md.smb.ar_order]); 75 76 if (any(isnan(md.smb.refelevation)==0) || numel(md.smb.refelevation)>1) 77 md = checkfield(md,'fieldname','smb.refelevation','NaN',1,'Inf',1,'>=',0,'size',[1,md.smb.num_basins],'numel',md.smb.num_basins); 78 end 79 [nbas,nbins] = size(md.smb.lapserates); 80 if (any(isnan(reshape(md.smb.lapserates,[1,nbas*nbins]))==0) || numel(md.smb.lapserates)>1) 81 md = checkfield(md,'fieldname','smb.lapserates','NaN',1,'Inf',1,'size',[md.smb.num_basins,nbins],'numel',md.smb.num_basins*nbins); 82 md = checkfield(md,'fieldname','smb.elevationbins','NaN',1,'Inf',1,'size',[md.smb.num_basins,nbins-1],'numel',md.smb.num_basins*(nbins-1)); 83 if(issorted(md.smb.elevationbins,2)==0) 84 error('md.smb.elevationbins should have rows in order of increasing elevation'); 85 end 86 elseif (isnan(md.smb.elevationbins(1,1))==0 || numel(md.smb.elevationbins)>1) 87 %elevationbins specified but not lapserates: this will inevitably lead to inconsistencies 88 [nbas,nbins] = size(md.smb.elevationbins); 89 nbins = nbins+1; 90 md = checkfield(md,'fieldname','smb.lapserates','NaN',1,'Inf',1,'size',[md.smb.num_basins,nbins],'numel',md.smb.num_basins*nbins); 91 md = checkfield(md,'fieldname','smb.elevationbins','NaN',1,'Inf',1,'size',[md.smb.num_basins,nbins-1],'numel',md.smb.num_basins*(nbins-1)); 92 end 72 93 end 73 94 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 74 95 md = checkfield(md,'fieldname','smb.averaging','numel',[1],'values',[0 1 2]); 75 96 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1); 76 end 97 end % }}} 77 98 function disp(self) % {{{ 78 99 disp(sprintf(' surface forcings parameters:')); 79 100 fielddisplay(self,'num_basins','number of different basins [unitless]'); 80 101 fielddisplay(self,'basin_id','basin number assigned to each element [unitless]'); 81 fielddisplay(self,'beta0','basin-specific intercept values [m ice eq./yr] ');102 fielddisplay(self,'beta0','basin-specific intercept values [m ice eq./yr] (if beta_1==0 mean=beta_0/(1-sum(phi)))'); 82 103 fielddisplay(self,'beta1','basin-specific trend values [m ice eq. yr^(-2)]'); 83 104 fielddisplay(self,'ar_order','order of the autoregressive model [unitless]'); … … 85 106 fielddisplay(self,'ar_timestep','time resolution of the autoregressive model [yr]'); 86 107 fielddisplay(self,'phi','basin-specific vectors of lag coefficients [unitless]'); 108 fielddisplay(self,'lapserates','basin-specific SMB lapse rates applied in each elevation bin, 1 row per basin, 1 column per bin [m ice eq yr^-1 m^-1] (default: no lapse rate)'); 109 fielddisplay(self,'elevationbins','basin-specific separations between elevation bins, 1 row per basin, 1 column per limit between bins [m] (default: no basin separation)'); 110 fielddisplay(self,'refelevation','basin-specific reference elevations at which SMB is calculated, and from which SMB is downscaled using lapserates (default: basin mean elevation) [m]'); 87 111 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 88 112 fielddisplay(self, 'averaging', 'averaging methods from short to long steps'); … … 97 121 yts=md.constants.yts; 98 122 99 WriteData(fid,prefix,'name','md.smb.model','data',55,'format','Integer'); 123 templapserates = md.smb.lapserates; 124 tempelevationbins = md.smb.elevationbins; 125 temprefelevation = md.smb.refelevation; 126 [nbas,nbins] = size(md.smb.lapserates); 127 if(any(isnan(reshape(md.smb.lapserates,[1,nbas*nbins])))) 128 templapserates = zeros(md.smb.num_basins,2); 129 disp(' smb.lapserates not specified: set to 0'); 130 tempelevationbins = zeros(md.smb.num_basins,1); %dummy elevation bins 131 end 132 if(any(isnan(md.smb.refelevation))) 133 temprefelevation = zeros(1,md.smb.num_basins); 134 areas = GetAreas(md.mesh.elements,md.mesh.x,md.mesh.y); 135 for ii=1:md.smb.num_basins 136 indices = find(md.smb.basin_id==ii); 137 elemsh = zeros(numel(indices),1); 138 for jj=1:numel(indices) 139 elemsh(jj) = mean(md.geometry.surface(md.mesh.elements(indices(jj),:))); 140 end 141 temprefelevation(ii) = sum(areas(indices).*elemsh)/sum(areas(indices)); 142 end 143 if(any(reshape(md.smb.lapserates,[1,nbas*nbins])~=0)) 144 disp(' smb.refelevation not specified: Reference elevations set to mean surface elevation of basins'); 145 end 146 end 147 [nbas,nbins] = size(templapserates); 148 149 WriteData(fid,prefix,'name','md.smb.model','data',13,'format','Integer'); 100 150 WriteData(fid,prefix,'object',self,'class','smb','fieldname','num_basins','format','Integer'); 101 151 WriteData(fid,prefix,'object',self,'class','smb','fieldname','ar_order','format','Integer'); … … 106 156 WriteData(fid,prefix,'object',self,'class','smb','fieldname','beta1','format','DoubleMat','name','md.smb.beta1','scale',1./(yts^2),'yts',yts); 107 157 WriteData(fid,prefix,'object',self,'class','smb','fieldname','phi','format','DoubleMat','name','md.smb.phi','yts',yts); 158 WriteData(fid,prefix,'data',templapserates,'format','DoubleMat','name','md.smb.lapserates','scale',1./yts,'yts',yts); 159 WriteData(fid,prefix,'data',tempelevationbins,'format','DoubleMat','name','md.smb.elevationbins'); 160 WriteData(fid,prefix,'data',temprefelevation,'format','DoubleMat','name','md.smb.refelevation'); 161 WriteData(fid,prefix,'data',nbins,'format','Integer','name','md.smb.num_bins'); 108 162 WriteData(fid,prefix,'object',self,'fieldname','steps_per_step','format','Integer'); 109 163 WriteData(fid,prefix,'object',self,'fieldname','averaging','format','Integer'); -
issm/trunk/src/m/classes/SMBautoregression.py
r26744 r27035 5 5 from project3d import * 6 6 from WriteData import * 7 7 from GetAreas import * 8 8 9 9 class SMBautoregression(object): … … 23 23 self.phi = np.nan 24 24 self.basin_id = np.nan 25 self.lapserates = np.nan 26 self.elevationbins = np.nan 27 self.refelevation = np.nan 25 28 self.steps_per_step = 1 26 29 self.averaging = 0 … … 38 41 s += '{}\n'.format(fielddisplay(self, 'num_basins', 'number of different basins [unitless]')) 39 42 s += '{}\n'.format(fielddisplay(self, 'basin_id', 'basin number assigned to each element [unitless]')) 40 s += '{}\n'.format(fielddisplay(self, 'beta0', 'basin-specific intercept values [m ice eq./yr] '))43 s += '{}\n'.format(fielddisplay(self, 'beta0', 'basin-specific intercept values [m ice eq./yr] (if beta_1==0 mean=beta_0/(1-sum(phi)))')) 41 44 s += '{}\n'.format(fielddisplay(self, 'beta1', 'basin-specific trend values [m ice eq. yr^(-2)]')) 42 45 s += '{}\n'.format(fielddisplay(self, 'ar_order', 'order of the autoregressive model [unitless]')) … … 44 47 s += '{}\n'.format(fielddisplay(self, 'ar_timestep', 'time resolution of the autoregressive model [yr]')) 45 48 s += '{}\n'.format(fielddisplay(self, 'phi', 'basin-specific vectors of lag coefficients [unitless]')) 46 s += '{}\n'.format(fielddisplay(self, 'covmat', 'inter-basin covariance matrix for multivariate normal noise at each time step [m^2 ice eq. yr^(-2)]')) 47 s += '{}\n'.format(fielddisplay(self, 'randomflag', 'whether to apply real randomness (true) or pseudo-randomness with fixed seed (false)')) 49 s += '{}\n'.format(fielddisplay(self, 'lapserates', 'basin-specific SMB lapse rates applied in each elevation bin, 1 row per basin, 1 column per bin [m ice eq yr^-1 m^-1] (default: no lapse rate)')) 50 s += '{}\n'.format(fielddisplay(self, 'elevationbins', 'basin-specific SMB lapse rates applied in range of SMB<0 [m ice eq yr^-1 m^-1] (default: no lapse rate)')) 51 s += '{}\n'.format(fielddisplay(self, 'refelevation', 'basin-specific reference elevations at which SMB is calculated, and from which SMB is downscaled using lapserates (default: basin mean elevation) [m]')) 48 52 s += '{}\n'.format(fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 49 53 s += '{}\n'.format(fielddisplay(self, 'averaging', 'averaging methods from short to long steps')) … … 91 95 md = checkfield(md, 'fieldname', 'smb.num_basins', 'numel', 1, 'NaN', 1, 'Inf', 1, '>', 0) 92 96 md = checkfield(md, 'fieldname', 'smb.basin_id', 'Inf', 1, '>=', 0, '<=', md.smb.num_basins, 'size', [md.mesh.numberofelements]) 97 if len(np.shape(self.beta0)) == 1: 98 self.beta0 = np.array([self.beta0]) 99 self.beta1 = np.array([self.beta1]) 93 100 md = checkfield(md, 'fieldname', 'smb.beta0', 'NaN', 1, 'Inf', 1, 'size', [1, md.smb.num_basins], 'numel', md.smb.num_basins) # Scheme fails if passed as column vector 94 101 md = checkfield(md, 'fieldname', 'smb.beta1', 'NaN', 1, 'Inf', 1, 'size', [1, md.smb.num_basins], 'numel', md.smb.num_basins) # Scheme fails if passed as column vector; NOTE: As opposed to MATLAB implementation, pass list … … 97 104 md = checkfield(md, 'fieldname', 'smb.ar_timestep', 'numel', 1, 'NaN', 1, 'Inf', 1, '>=', md.timestepping.time_step) # Autoregression time step cannot be finer than ISSM timestep 98 105 md = checkfield(md, 'fieldname', 'smb.phi', 'NaN', 1, 'Inf', 1, 'size', [md.smb.num_basins, md.smb.ar_order]) 106 107 if(np.any(np.isnan(self.refelevation) is False) or np.size(self.refelevation) > 1): 108 if len(np.shape(self.refelevation)) == 1: 109 self.refelevation = np.array([self.refelevation]) 110 md = checkfield(md, 'fieldname', 'smb.refelevation', 'NaN', 1, 'Inf', 1, '>=', 0, 'size', [1, md.smb.num_basins], 'numel', md.smb.num_basins) 111 112 if(np.any(np.isnan(self.lapserates) is False) or np.size(self.lapserates) > 1): 113 if len(np.shape(self.lapserates)) == 1: 114 self.lapserates = np.array([self.lapserates]) 115 nbins = 1 116 else: 117 nbins = np.shape(self.lapserates)[1] 118 if len(np.shape(self.elevationbins)) == 1: 119 self.elevationbins = np.array([self.elevationbins]) 120 md = checkfield(md, 'fieldname', 'smb.lapserates', 'NaN', 1, 'Inf', 1, 'size', [md.smb.num_basins, nbins], 'numel', md.smb.num_basins*nbins) 121 md = checkfield(md, 'fieldname', 'smb.elevationbins', 'NaN', 1, 'Inf', 1, 'size', [md.smb.num_basins, nbins-1], 'numel', md.smb.num_basins*(nbins-1)) 122 for rr in range(md.smb.num_basins): 123 if(np.all(self.elevationbins[rr,0:-1]<=self.elevationbins[rr,1:])==False): 124 raise TypeError('md.smb.elevationbins should have rows in order of increasing elevation') 125 elif(np.any(np.isnan(self.elevationbins) is False) or np.size(self.elevationbins) > 1): 126 #elevationbins specified but not lapserates: this will inevitably lead to inconsistencies 127 if len(np.shape(self.elevationbins)) == 1: 128 self.elevationbins = np.array([self.elevationbins]) 129 nbins = 1 130 else: 131 nbins = np.shape(self.elevationbins)[1]+1 132 md = checkfield(md, 'fieldname', 'smb.lapserates', 'NaN', 1, 'Inf', 1, 'size', [md.smb.num_basins, nbins], 'numel', md.smb.num_basins*nbins) 133 md = checkfield(md, 'fieldname', 'smb.elevationbins', 'NaN', 1, 'Inf', 1, 'size', [md.smb.num_basins, nbins-1], 'numel', md.smb.num_basins*(nbins-1)) 134 99 135 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 100 136 md = checkfield(md, 'fieldname', 'smb.averaging', 'numel', [1], 'values', [0, 1, 2]) … … 106 142 yts = md.constants.yts 107 143 108 WriteData(fid, prefix, 'name', 'md.smb.model', 'data', 55, 'format', 'Integer') 144 templapserates = np.copy(md.smb.lapserates) 145 tempelevationbins = np.copy(md.smb.elevationbins) 146 temprefelevation = np.copy(md.smb.refelevation) 147 if(np.any(np.isnan(md.smb.lapserates))): 148 templapserates = np.zeros((md.smb.num_basins,2)) 149 print(' smb.lapserates not specified: set to 0') 150 tempelevationbins = np.zeros((md.smb.num_basins,1)) #dummy elevation bins 151 if(np.any(np.isnan(md.smb.refelevation))): 152 temprefelevation = np.zeros((md.smb.num_basins)).reshape(1,md.smb.num_basins) 153 areas = GetAreas(md.mesh.elements, md.mesh.x, md.mesh.y) 154 for ii, bid in enumerate(np.unique(md.smb.basin_id)): 155 indices = np.where(md.smb.basin_id == bid)[0] 156 elemsh = np.zeros((len(indices))) 157 for jj in range(len(indices)): 158 elemsh[jj] = np.mean(md.geometry.surface[md.mesh.elements[indices[jj], :] - 1]) 159 temprefelevation[0, ii] = np.sum(areas[indices] * elemsh) / np.sum(areas[indices]) 160 if(np.any(templapserates != 0)): 161 print(' smb.refelevation not specified: Reference elevations set to mean surface elevation of basins') 162 nbins = np.shape(templapserates)[1] 163 164 WriteData(fid, prefix, 'name', 'md.smb.model', 'data', 13, 'format', 'Integer') 109 165 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'num_basins', 'format', 'Integer') 110 166 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'ar_order', 'format', 'Integer') 111 167 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'ar_initialtime', 'format', 'Double', 'scale', yts) 112 168 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'ar_timestep', 'format', 'Double', 'scale', yts) 113 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'basin_id', 'data', self.basin_id , 'name', 'md.smb.basin_id', 'format', 'IntMat', 'mattype', 2)# 0-indexed169 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'basin_id', 'data', self.basin_id - 1, 'name', 'md.smb.basin_id', 'format', 'IntMat', 'mattype', 2) # 0-indexed 114 170 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'beta0', 'format', 'DoubleMat', 'name', 'md.smb.beta0', 'scale', 1 / yts, 'yts', yts) 115 171 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'beta1', 'format', 'DoubleMat', 'name', 'md.smb.beta1', 'scale', 1 / (yts ** 2), 'yts', yts) 116 172 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'phi', 'format', 'DoubleMat', 'name', 'md.smb.phi', 'yts', yts) 173 WriteData(fid, prefix, 'data', templapserates, 'name', 'md.smb.lapserates', 'format', 'DoubleMat', 'scale', 1 / yts, 'yts', yts) 174 WriteData(fid, prefix, 'data', tempelevationbins, 'name', 'md.smb.elevationbins', 'format', 'DoubleMat') 175 WriteData(fid, prefix, 'data', temprefelevation, 'name', 'md.smb.refelevation', 'format', 'DoubleMat') 176 WriteData(fid, prefix, 'data', nbins, 'name', 'md.smb.num_bins', 'format', 'Integer') 117 177 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer') 118 178 WriteData(fid, prefix, 'object', self, 'fieldname', 'averaging', 'format', 'Integer') -
issm/trunk/src/m/classes/SMBpddSicopolis.py
r25836 r27035 129 129 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 's0t', 'format', 'DoubleMat', 'mattype', 1) 130 130 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'rlaps', 'format', 'Double') 131 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'monthlytemperatures', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)131 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'monthlytemperatures', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 132 132 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'precipitation', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 133 133 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'temperature_anomaly', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) -
issm/trunk/src/m/classes/basalforcings.m
r26744 r27035 15 15 case 0 16 16 self=setdefaultparameters(self); 17 case 1 18 self =structtoobj(basalforcings(),varargin{1}); 17 19 otherwise 18 20 error('constructor not supported'); -
issm/trunk/src/m/classes/calvingvonmises.m
r26744 r27035 44 44 if (~strcmp(solution,'TransientSolution') | md.transient.ismovingfront==0), return; end 45 45 46 md = checkfield(md,'fieldname','calving.stress_threshold_groundedice','>',0,'NaN',1,'Inf',1 );47 md = checkfield(md,'fieldname','calving.stress_threshold_floatingice','>',0,'NaN',1,'Inf',1 );46 md = checkfield(md,'fieldname','calving.stress_threshold_groundedice','>',0,'NaN',1,'Inf',1,'size','universal'); 47 md = checkfield(md,'fieldname','calving.stress_threshold_floatingice','>',0,'NaN',1,'Inf',1,'size','universal'); 48 48 md = checkfield(md,'fieldname','calving.min_thickness','>=',0,'NaN',1,'Inf',1,'numel',1); 49 49 end % }}} … … 58 58 yts=md.constants.yts; 59 59 WriteData(fid,prefix,'name','md.calving.law','data',2,'format','Integer'); 60 WriteData(fid,prefix,'object',self,'fieldname','stress_threshold_groundedice','format','DoubleMat','mattype',1 );61 WriteData(fid,prefix,'object',self,'fieldname','stress_threshold_floatingice','format','DoubleMat','mattype',1 );60 WriteData(fid,prefix,'object',self,'fieldname','stress_threshold_groundedice','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 61 WriteData(fid,prefix,'object',self,'fieldname','stress_threshold_floatingice','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 62 62 WriteData(fid,prefix,'object',self,'fieldname','min_thickness','format','Double'); 63 63 end % }}} -
issm/trunk/src/m/classes/calvingvonmises.py
r26744 r27035 48 48 return 49 49 50 md = checkfield(md, 'fieldname', 'calving.stress_threshold_groundedice', '>', 0, 'nan', 1, 'Inf', 1 )51 md = checkfield(md, 'fieldname', 'calving.stress_threshold_floatingice', '>', 0, 'nan', 1, 'Inf', 1 )50 md = checkfield(md, 'fieldname', 'calving.stress_threshold_groundedice', '>', 0, 'nan', 1, 'Inf', 1, 'size', 'universal') 51 md = checkfield(md, 'fieldname', 'calving.stress_threshold_floatingice', '>', 0, 'nan', 1, 'Inf', 1, 'size', 'universal') 52 52 md = checkfield(md, 'fieldname', 'calving.min_thickness', '>=', 0, 'NaN', 1, 'Inf', 1, 'numel', [1]) 53 53 … … 56 56 57 57 def marshall(self, prefix, md, fid): # {{{ 58 yts = md.constants.yts 58 59 WriteData(fid, prefix, 'name', 'md.calving.law', 'data', 2, 'format', 'Integer') 59 WriteData(fid, prefix, 'object', self, 'fieldname', 'stress_threshold_groundedice', 'format', 'DoubleMat', 'mattype', 1 )60 WriteData(fid, prefix, 'object', self, 'fieldname', 'stress_threshold_floatingice', 'format', 'DoubleMat', 'mattype', 1 )60 WriteData(fid, prefix, 'object', self, 'fieldname', 'stress_threshold_groundedice', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts ) 61 WriteData(fid, prefix, 'object', self, 'fieldname', 'stress_threshold_floatingice', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 61 62 WriteData(fid, prefix, 'object', self, 'fieldname', 'min_thickness', 'format', 'Double') 62 63 # }}} -
issm/trunk/src/m/classes/clusters/generic.m
r26744 r27035 19 19 port = 0; 20 20 interactive = 1; 21 codepath = [ IssmConfig('ISSM_PREFIX') '/bin'];21 codepath = [issmdir() '/bin']; 22 22 etcpath = [issmdir() '/etc']; 23 23 executionpath = [issmdir() '/execution']; -
issm/trunk/src/m/classes/clusters/pfe.m
r26744 r27035 11 11 name = 'pfe' 12 12 login = ''; 13 modules = {'comp-intel/201 6.2.181' 'mpt'};13 modules = {'comp-intel/2018.3.222' 'mpi-intel/2018.3.222' 'scicon/app-tools'}; 14 14 numnodes = 20; 15 15 cpuspernode = 8; … … 19 19 processor = 'ivy'; 20 20 srcpath = ''; 21 extpkgpath = ''; 21 22 codepath = ''; 22 23 executionpath = ''; … … 44 45 disp(sprintf(' login: %s',cluster.login)); 45 46 disp(sprintf(' modules: %s',strjoin(cluster.modules,', '))); 46 disp(sprintf(' numnodes: % s',cluster.numnodes));47 disp(sprintf(' cpuspernode: % s',cluster.cpuspernode));47 disp(sprintf(' numnodes: %i',cluster.numnodes)); 48 disp(sprintf(' cpuspernode: %i',cluster.cpuspernode)); 48 49 disp(sprintf(' np: %i',cluster.nprocs())); 49 50 disp(sprintf(' port: %i',cluster.port)); … … 52 53 disp(sprintf(' processor: %i',cluster.processor)); 53 54 disp(sprintf(' srcpath: %s',cluster.srcpath)); 55 disp(sprintf(' extpkgpath: %s',cluster.extpkgpath)); 54 56 disp(sprintf(' codepath: %s',cluster.codepath)); 55 57 disp(sprintf(' executionpath: %s',cluster.executionpath)); 56 58 disp(sprintf(' grouplist: %s',cluster.grouplist)); 57 disp(sprintf(' interactive: % s',cluster.interactive));59 disp(sprintf(' interactive: %i',cluster.interactive)); 58 60 disp(sprintf(' bbftp: %s',cluster.bbftp)); 59 61 disp(sprintf(' numstreams: %s',cluster.numstreams)); … … 173 175 fprintf(fid,'export MPI_GROUP_MAX=64\n\n'); 174 176 fprintf(fid,'export ISSM_DIR="%s"\n',cluster.srcpath); %FIXME 177 if cluster.extpkgpath 178 fprintf(fid,'export ISSM_EXT_PKG="%s"\n',cluster.extpkgpath); 179 end 175 180 fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n'); %FIXME 176 fprintf(fid,'export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$ISSM_DIR/externalpackages/petsc/install/lib"\n');177 181 fprintf(fid,'cd %s/%s/\n\n',cluster.executionpath,dirname); 178 182 if ~isvalgrind, 179 fprintf(fid,'/u/scicon/tools/bin/toss3/several_tries mpiexec -np %i %s/%s %s %s/%s %s\n',cluster.nprocs(),cluster.codepath,executable,solution,cluster.executionpath,dirname,modelname);183 fprintf(fid,'/u/scicon/tools/bin/toss3/several_tries mpiexec -np %i mbind.x -cs -n%i %s/%s %s %s/%s %s\n',cluster.nprocs(),cluster.cpuspernode,cluster.codepath,executable,solution,cluster.executionpath,dirname,modelname); 180 184 else 181 185 fprintf(fid,'mpiexec -np %i valgrind --leak-check=full %s/%s %s %s %s\n',cluster.nprocs(),cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname); -
issm/trunk/src/m/classes/clusters/pfe.py
r26744 r27035 28 28 self.name = '' 29 29 self.login = '' 30 self.modules = ['comp-intel/201 6.2.181', 'mpt']30 self.modules = ['comp-intel/2018.3.222', 'mpi-intel/2018.3.222', 'scicon/app-tools'] 31 31 self.numnodes = 20 32 32 self.cpuspernode = 8 … … 36 36 self.processor = 'ivy' 37 37 self.srcpath = '' 38 self.extpkgpath = '' 38 39 self.codepath = '' 39 40 self.executionpath = '' … … 72 73 s += ' processor: {}\n'.format(self.processor) 73 74 s += ' srcpath: {}\n'.format(self.srcpath) 75 s += ' extpkgpath: {}\n'.format(self.extpkgpath) 74 76 s += ' codepath: {}\n'.format(self.codepath) 75 77 s += ' executionpath: {}\n'.format(self.executionpath) … … 177 179 fid.write('export MPI_GROUP_MAX=64\n\n') 178 180 fid.write('export ISSM_DIR="{}"\n'.format(self.srcpath)) # FIXME 181 if self.extpkgpath: 182 fid.write('export ISSM_EXT_PKG="{}"\n'.format(self.extpkgpath)) 179 183 fid.write('source $ISSM_DIR/etc/environment.sh\n') # FIXME 180 fid.write('export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$ISSM_DIR/externalpackages/petsc/install/lib"\n')181 184 fid.write('cd {}/{}/\n\n'.format(self.executionpath, dirname)) 182 185 fid.write('mpiexec -np {} {}/{} {} {}/{} {}\n'.format(self.nprocs(), self.codepath, executable, solution, self.executionpath, dirname, modelname)) -
issm/trunk/src/m/classes/clusters/saga.py
r26744 r27035 119 119 120 120 fid.write('#SBATCH --nodes=%i \n' % self.numnodes) 121 fid.write('#SBATCH --ntasks -per-node=%i \n' % self.cpuspernode)121 fid.write('#SBATCH --ntasks=%i \n' % self.cpuspernode) 122 122 fid.write('#SBATCH --time={}\n'.format(timestring)) #walltime is minutes 123 fid.write('#SBATCH --mem-per-cpu={}M B\n'.format(int(1000 * self.mem))) # mem is in MB123 fid.write('#SBATCH --mem-per-cpu={}M\n'.format(int(1000 * self.mem))) # mem is in MB 124 124 125 125 fid.write('#SBATCH --account=%s\n' % self.accountname) … … 130 130 fid.write('module purge\n') 131 131 fid.write('module load CMake/3.15.3-GCCcore-8.3.0\n') 132 fid.write('module load PETSc/3.12.4- intel-2019b\n')133 fid.write('module load ParMETIS/4.0.3- iimpi-2019b\n')132 fid.write('module load PETSc/3.12.4-foss-2019b\n') 133 fid.write('module load ParMETIS/4.0.3-gompi-2019b\n') 134 134 if isvalgrind: 135 135 fid.write('module --ignore-cache load Valgrind/3.16.1-gompi-2019b \n') … … 138 138 if isvalgrind: 139 139 # profiling 140 #fid.write(' mpirun {} --tool=callgrind {}/{} {} {}/{} {} 2>{}.errlog>{}.outlog \n'.format(self.valgrind, self.codepath, executable, solution, self.executionpath, dirname, modelname, modelname, modelname))140 #fid.write('srun {} --tool=callgrind {}/{} {} {}/{} {} 2>{}.errlog>{}.outlog \n'.format(self.valgrind, self.codepath, executable, solution, self.executionpath, dirname, modelname, modelname, modelname)) 141 141 # leak check 142 fid.write(' mpirun {} --leak-check=full {}/{} {} {}/{} {} 2>{}.errlog>{}.outlog '.format(self.valgrind, self.codepath, executable, solution, self.executionpath, dirname, modelname, modelname, modelname))142 fid.write('srun {} --leak-check=full {}/{} {} {}/{} {} 2>{}.errlog>{}.outlog '.format(self.valgrind, self.codepath, executable, solution, self.executionpath, dirname, modelname, modelname, modelname)) 143 143 else: 144 fid.write('time mpirun {}/{} {} {}/{} {}\n'.format(self.codepath, executable, solution, self.executionpath, dirname, modelname))144 fid.write('time srun {}/{} {} {}/{} {}\n'.format(self.codepath, executable, solution, self.executionpath, dirname, modelname)) 145 145 fid.close() 146 146 -
issm/trunk/src/m/classes/flowequation.js
r26744 r27035 22 22 fielddisplay(this,'isSSA','is the Shelfy-Stream Approximation (SSA) used ?'); 23 23 fielddisplay(this,'isL1L2','is the L1L2 approximation used ?'); 24 fielddisplay(this,'isM LHO','is the Mono-Layer Higher-Orderapproximation used?');24 fielddisplay(this,'isMOLHO','is the MOno-Layer Higher-Order (MOLHO) approximation used?'); 25 25 fielddisplay(this,'isHO','is the Higher-Order (HO) approximation used ?'); 26 26 fielddisplay(this,'isFS','are the Full-FS (FS) equations used ?'); … … 41 41 42 42 }// }}} 43 44 45 46 47 48 49 43 this.extrude = function(md) {//{{{ 44 this.element_equation=project3d(md,'vector',this.element_equation,'type','element'); 45 this.vertex_equation=project3d(md,'vector',this.vertex_equation,'type','node'); 46 this.borderSSA=project3d(md,'vector',this.borderSSA,'type','node'); 47 this.borderHO=project3d(md,'vector',this.borderHO,'type','node'); 48 this.borderFS=project3d(md,'vector',this.borderFS,'type','node'); 49 return this; 50 50 }//}}} 51 51 this.checkconsistency = function(md,solution,analyses) {//{{{ … … 59 59 checkfield(md,'fieldname','flowequation.isSSA','numel',[1],'values',[0, 1]); 60 60 checkfield(md,'fieldname','flowequation.isL1L2','numel',[1],'values',[0, 1]); 61 checkfield(md,'fieldname','flowequation.isM LHO','numel',[1],'values',[0, 1]);61 checkfield(md,'fieldname','flowequation.isMOLHO','numel',[1],'values',[0, 1]); 62 62 checkfield(md,'fieldname','flowequation.isHO','numel',[1],'values',[0, 1]); 63 63 checkfield(md,'fieldname','flowequation.isFS','numel',[1],'values',[0, 1]); … … 93 93 else throw Error('Case not supported yet'); 94 94 95 if (!(this.isSIA | this.isSSA | this.isL1L2 | this.isM LHO | this.isHO | this.isFS)){95 if (!(this.isSIA | this.isSSA | this.isL1L2 | this.isMOLHO | this.isHO | this.isFS)){ 96 96 checkmessage(md,['no element types set for this model']); 97 97 } … … 108 108 WriteData(fid,prefix,'object',this,'fieldname','isSSA','format','Boolean'); 109 109 WriteData(fid,prefix,'object',this,'fieldname','isL1L2','format','Boolean'); 110 WriteData(fid,prefix,'object',this,'fieldname','isM LHO','format','Boolean');110 WriteData(fid,prefix,'object',this,'fieldname','isMOLHO','format','Boolean'); 111 111 WriteData(fid,prefix,'object',this,'fieldname','isHO','format','Boolean'); 112 112 WriteData(fid,prefix,'object',this,'fieldname','isFS','format','Boolean'); … … 138 138 this.isSSA = 0; 139 139 this.isL1L2 = 0; 140 this.isM LHO = 0;140 this.isMOLHO = 0; 141 141 this.isHO = 0; 142 142 this.isFS = 0; -
issm/trunk/src/m/classes/flowequation.m
r26744 r27035 9 9 isSSA = 0; 10 10 isL1L2 = 0; 11 isM LHO = 0;11 isMOLHO = 0; 12 12 isHO = 0; 13 13 isFS = 0; … … 60 60 if isfield(objstruct,'borderpattyn'), self.borderHO = objstruct.borderpattyn; end; 61 61 if isfield(objstruct,'borderstokes'), self.borderFS = objstruct.borderstokes; end; 62 end 63 64 %Nov 6 2021 65 if any(self.vertex_equation==4) 66 disp(['Monolayer Higher-Order (MLHO) detected in md.flowequation, this is still under development. Please double check your settings.']); 67 end 62 63 %May 31 2022 64 if isfield(objstruct,'isMLHO') 65 self.isMOLHO = objstruct.isMLHO; 66 end 67 end 68 68 69 69 70 end% }}} … … 104 105 md = checkfield(md,'fieldname','flowequation.isSSA','numel',[1],'values',[0 1]); 105 106 md = checkfield(md,'fieldname','flowequation.isL1L2','numel',[1],'values',[0 1]); 106 md = checkfield(md,'fieldname','flowequation.isM LHO','numel',[1],'values',[0 1]);107 md = checkfield(md,'fieldname','flowequation.isMOLHO','numel',[1],'values',[0 1]); 107 108 md = checkfield(md,'fieldname','flowequation.isHO','numel',[1],'values',[0 1]); 108 109 md = checkfield(md,'fieldname','flowequation.isFS','numel',[1],'values',[0 1]); … … 135 136 error('Case not supported yet'); 136 137 end 137 if ~(self.isSIA || self.isSSA || self.isL1L2 || self.isM LHO || self.isHO || self.isFS),138 if ~(self.isSIA || self.isSSA || self.isL1L2 || self.isMOLHO || self.isHO || self.isFS), 138 139 md = checkmessage(md,['no element types set for this model']); 139 140 end … … 153 154 fielddisplay(self,'isSSA','is the Shelfy-Stream Approximation (SSA) used?'); 154 155 fielddisplay(self,'isL1L2','is the L1L2 approximation used?'); 155 fielddisplay(self,'isM LHO','is the Mono-Layer Higher-Orderapproximation used?');156 fielddisplay(self,'isMOLHO','is the MOno-Layer Higher-Order (MOLHO) approximation used?'); 156 157 fielddisplay(self,'isHO','is the Higher-Order (HO) approximation used?'); 157 158 fielddisplay(self,'isFS','are the Full-FS (FS) equations used?'); … … 172 173 WriteData(fid,prefix,'object',self,'fieldname','isSSA','format','Boolean'); 173 174 WriteData(fid,prefix,'object',self,'fieldname','isL1L2','format','Boolean'); 174 WriteData(fid,prefix,'object',self,'fieldname','isM LHO','format','Boolean');175 WriteData(fid,prefix,'object',self,'fieldname','isMOLHO','format','Boolean'); 175 176 WriteData(fid,prefix,'object',self,'fieldname','isHO','format','Boolean'); 176 177 WriteData(fid,prefix,'object',self,'fieldname','isFS','format','Boolean'); … … 197 198 writejsdouble(fid,[modelname '.flowequation.isSSA'],self.isSSA); 198 199 writejsdouble(fid,[modelname '.flowequation.isL1L2'],self.isL1L2); 199 writejsdouble(fid,[modelname '.flowequation.isM LHO'],self.isMLHO);200 writejsdouble(fid,[modelname '.flowequation.isMOLHO'],self.isMOLHO); 200 201 writejsdouble(fid,[modelname '.flowequation.isHO'],self.isHO); 201 202 writejsdouble(fid,[modelname '.flowequation.isFS'],self.isFS); -
issm/trunk/src/m/classes/flowequation.py
r26744 r27035 19 19 self.isSSA = 0 20 20 self.isL1L2 = 0 21 self.isM LHO = 021 self.isMOLHO = 0 22 22 self.isHO = 0 23 23 self.isFS = 0 … … 46 46 s += '{}\n'.format(fielddisplay(self, 'isSSA', "is the Shelfy-Stream Approximation (SSA) used?")) 47 47 s += '{}\n'.format(fielddisplay(self, 'isL1L2', "are L1L2 equations used?")) 48 s += '{}\n'.format(fielddisplay(self, 'isM LHO', "are Mono-layer Higher-Orderequations used?"))48 s += '{}\n'.format(fielddisplay(self, 'isMOLHO', "are MOno-layer Higher-Order (MOLHO) equations used?")) 49 49 s += '{}\n'.format(fielddisplay(self, 'isHO', "is the Higher-Order (HO) approximation used?")) 50 50 s += '{}\n'.format(fielddisplay(self, 'isFS', "are the Full-FS (FS) equations used?")) … … 90 90 md = checkfield(md, 'fieldname', 'flowequation.isSSA', 'numel', [1], 'values', [0, 1]) 91 91 md = checkfield(md, 'fieldname', 'flowequation.isL1L2', 'numel', [1], 'values', [0, 1]) 92 md = checkfield(md, 'fieldname', 'flowequation.isM LHO', 'numel', [1], 'values', [0, 1])92 md = checkfield(md, 'fieldname', 'flowequation.isMOLHO', 'numel', [1], 'values', [0, 1]) 93 93 md = checkfield(md, 'fieldname', 'flowequation.isHO', 'numel', [1], 'values', [0, 1]) 94 94 md = checkfield(md, 'fieldname', 'flowequation.isFS', 'numel', [1], 'values', [0, 1]) … … 121 121 raise RuntimeError('Case not supported yet') 122 122 123 if not (self.isSIA or self.isSSA or self.isL1L2 or self.isM LHO or self.isHO or self.isFS):123 if not (self.isSIA or self.isSSA or self.isL1L2 or self.isMOLHO or self.isHO or self.isFS): 124 124 md.checkmessage("no element types set for this model") 125 125 if 'StressbalanceSIAAnalysis' in analyses: … … 134 134 WriteData(fid, prefix, 'object', self, 'fieldname', 'isSSA', 'format', 'Boolean') 135 135 WriteData(fid, prefix, 'object', self, 'fieldname', 'isL1L2', 'format', 'Boolean') 136 WriteData(fid, prefix, 'object', self, 'fieldname', 'isM LHO', 'format', 'Boolean')136 WriteData(fid, prefix, 'object', self, 'fieldname', 'isMOLHO', 'format', 'Boolean') 137 137 WriteData(fid, prefix, 'object', self, 'fieldname', 'isHO', 'format', 'Boolean') 138 138 WriteData(fid, prefix, 'object', self, 'fieldname', 'isFS', 'format', 'Boolean') -
issm/trunk/src/m/classes/fourierlove.m
r26744 r27035 6 6 classdef fourierlove 7 7 properties (SetAccess=public) 8 nfreq = 0; 9 frequencies = 0; 10 sh_nmax = 0; 11 sh_nmin = 0; 12 g0 = 0; 13 r0 = 0; 14 mu0 = 0; 15 Gravitational_Constant = 0; 16 allow_layer_deletion = 0; 17 underflow_tol = 0; 18 integration_steps_per_layer = 0; 19 istemporal = 0; 20 n_temporal_iterations = 0; 21 time = 0; 22 love_kernels = 0; 23 forcing_type = 0; 24 inner_core_boundary = 0; 25 core_mantle_boundary = 0; 26 complex_computation = 0; 8 nfreq = 0; 9 frequencies = 0; 10 sh_nmax = 0; 11 sh_nmin = 0; 12 g0 = 0; 13 r0 = 0; 14 mu0 = 0; 15 Gravitational_Constant = 0; 16 chandler_wobble = 0; 17 allow_layer_deletion = 0; 18 underflow_tol = 0; 19 pw_threshold = 0; 20 integration_steps_per_layer = 0; 21 istemporal = 0; 22 n_temporal_iterations = 0; 23 time = 0; 24 love_kernels = 0; 25 forcing_type = 0; 26 inner_core_boundary = 0; 27 core_mantle_boundary = 0; 28 complex_computation = 0; 27 29 28 30 end … … 53 55 self.mu0=1e11; % Pa 54 56 self.Gravitational_Constant=6.67259e-11; % m^3 kg^-1 s^-2 57 self.chandler_wobble=0; 55 58 self.allow_layer_deletion=1; 56 59 self.underflow_tol=1e-16; %threshold of deep to surface love number ratio to trigger the deletion of layer 60 self.pw_threshold=1e-3; %if relative variation across frequencies is smaller than this ratio, the post-widder transform for time-dependent love numbers is bypassed 57 61 self.integration_steps_per_layer=100; 58 62 self.istemporal=0; … … 74 78 fielddisplay(self,'mu0','adimensioning constant for stress (default: 10^11) [Pa]'); 75 79 fielddisplay(self,'Gravitational_Constant','Newtonian constant of gravitation (default: 6.67259e-11 [m^3 kg^-1 s^-2])'); 76 fielddisplay(self,'allow_layer_deletion','allow for migration of the integration boundary with increasing spherical harmonics degree (default: 1)'); 80 fielddisplay(self,'chandler_wobble','includes the inertial terms for the chandler wobble in the rotational feedback love numbers, only for forcing_type=11 (default: 0) (/!\ 1 is untested yet)'); 81 fielddisplay(self,'allow_layer_deletion','allow for migration of the integration boundary with increasing spherical harmonics degree (default: 1)'); 77 82 fielddisplay(self,'underflow_tol','threshold of deep to surface love number ratio to trigger the deletion of layers (default: 1e-16)'); 83 fielddisplay(self,'pw_threshold','if relative variation across frequencies is smaller than this ratio, the post-widder transform for time-dependent love numbers is bypassed (default (1e-3)'); 78 84 fielddisplay(self,'integration_steps_per_layer','number of radial steps to propagate the yi system from the bottom to the top of each layer (default: 100)'); 79 85 fielddisplay(self,'istemporal',{'1 for time-dependent love numbers, 0 for frequency-dependent or elastic love numbers (default: 0)', 'If 1: use fourierlove function build_frequencies_from_time to meet consistency'}); … … 98 104 md = checkfield(md,'fieldname','love.mu0','NaN',1,'Inf',1,'numel',1,'>',0); 99 105 md = checkfield(md,'fieldname','love.Gravitational_Constant','NaN',1,'Inf',1,'numel',1,'>',0); 106 md = checkfield(md,'fieldname','love.chandler_wobble','values',[0 1]); 100 107 md = checkfield(md,'fieldname','love.allow_layer_deletion','values',[0 1]); 101 108 md = checkfield(md,'fieldname','love.underflow_tol','NaN',1,'Inf',1,'numel',1,'>',0); 109 md = checkfield(md,'fieldname','love.pw_threshold','NaN',1,'Inf',1,'numel',1,'>',0); 102 110 md = checkfield(md,'fieldname','love.integration_steps_per_layer','NaN',1,'Inf',1,'numel',1,'>',0); 103 111 md = checkfield(md,'fieldname','love.love_kernels','values',[0 1]); … … 112 120 if md.love.sh_nmin<=1 & (md.love.forcing_type==1 || md.love.forcing_type==5 || md.love.forcing_type==9) 113 121 error(['Degree 1 not supported for forcing type ' num2str(md.love.forcing_type) '. Use sh_min>=2 for this kind of calculation.']) 122 end 123 124 if md.love.chandler_wobble==1 125 disp('Warning, Chandler Wobble in Love number calculator has not been validated yet'); 114 126 end 115 127 … … 137 149 WriteData(fid,prefix,'object',self,'fieldname','mu0','format','Double'); 138 150 WriteData(fid,prefix,'object',self,'fieldname','Gravitational_Constant','format','Double'); 151 WriteData(fid,prefix,'object',self,'fieldname','chandler_wobble','format','Boolean'); 139 152 WriteData(fid,prefix,'object',self,'fieldname','allow_layer_deletion','format','Boolean'); 140 153 WriteData(fid,prefix,'object',self,'fieldname','underflow_tol','format','Double'); 154 WriteData(fid,prefix,'object',self,'fieldname','pw_threshold','format','Double'); 141 155 WriteData(fid,prefix,'object',self,'fieldname','integration_steps_per_layer','format','Integer'); 142 156 WriteData(fid,prefix,'object',self,'fieldname','istemporal','format','Boolean'); … … 164 178 for i=1:length(self.time) 165 179 for j=1:2*self.n_temporal_iterations 166 self.frequencies((i-1)*2*self.n_temporal_iterations +j) = j*log(2)/self.time(i)/2/pi; 180 if self.time(i)==0 181 self.frequencies((i-1)*2*self.n_temporal_iterations +j) =0; % convention to avoid marshalling infinite numbers 182 else 183 self.frequencies((i-1)*2*self.n_temporal_iterations +j) = j*log(2)/self.time(i)/2/pi; 184 end 167 185 end 168 186 end -
issm/trunk/src/m/classes/fourierlove.py
r26744 r27035 22 22 self.mu0 = 0 23 23 self.Gravitational_Constant = 0 24 self.chandler_wobble = 0 24 25 self.allow_layer_deletion = 0 25 26 self.underflow_tol = 0 27 self.pw_threshold = 0 26 28 self.integration_steps_per_layer = 0 27 29 self.istemporal = 0 … … 51 53 s += '{}\n'.format(fielddisplay(self, 'allow_layer_deletion', 'allow for migration of the integration boundary with increasing spherical harmonics degree (default: 1)')) 52 54 s += '{}\n'.format(fielddisplay(self, 'Gravitational_Constant', 'Newtonian constant of gravitation (default: 6.67259e-11 [m^3 kg^-1 s^-2])')) 55 s += '{}\n'.format(fielddisplay(self, 'chandler_wobble', 'includes the inertial terms for the chandler wobble in the rotational feedback love numbers, only for forcing_type=11 (default: 0) (/!\\ 1 has not been validated yet)')) 53 56 s += '{}\n'.format(fielddisplay(self, 'allow_layer_deletion', 'allow for migration of the integration boundary with increasing spherical harmonics degree (default: 1)')) 54 s += '{}\n'.format(fielddisplay(self, 'underflow_tol', 'threshold of deep to surface love number ratio to trigger the deletion of layers (default: 1e-16)')) 57 s += '{}\n'.format(fielddisplay(self, 'pw_threshold', 'if relative variation across frequencies is smaller than this ratio, the post-widder transform for time-dependent love numbers is bypassed (default (1e-3)')) 58 s += '{}\n'.format(fielddisplay(self, 'chandler_wobble', 'includes the inertial terms for the chandler wobble in the rotational feedback love numbers, only for forcing_type=11 (default: 0) (/!\\ 1 is untested)')) 55 59 s += '{}\n'.format(fielddisplay(self, 'integration_steps_per_layer', 'number of radial steps to propagate the yi system from the bottom to the top of each layer (default: 100)')) 56 60 s += '{}\n'.format(fielddisplay(self, 'istemporal', ['1 for time-dependent love numbers, 0 for frequency-dependent or elastic love numbers (default: 0)', 'If 1: use fourierlove function build_frequencies_from_time to meet consistency'])) … … 88 92 self.mu0 = 1e11 # Pa 89 93 self.Gravitational_Constant = 6.67259e-11 # m^3 kg^-1 s^-2 94 self.chandler_wobble = 0 90 95 self.allow_layer_deletion = 1 91 96 self.underflow_tol = 1e-16 # Threshold of deep to surface love number ratio to trigger the deletion of layer 97 self.pw_threshold = 1e-3 # If relative variation across frequencies is smaller than this ratio, the post-widder transform for time-dependent love numbers is bypassed 92 98 self.integration_steps_per_layer = 100 93 99 self.istemporal = 0 … … 113 119 md = checkfield(md, 'fieldname', 'love.mu0', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0) 114 120 md = checkfield(md, 'fieldname', 'love.Gravitational_Constant', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0) 121 md = checkfield(md, 'fieldname', 'love.chandler_wobble', 'values', [0, 1]) 115 122 md = checkfield(md, 'fieldname', 'love.allow_layer_deletion', 'values', [0, 1]) 116 123 md = checkfield(md, 'fieldname', 'love.underflow_tol', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0) 124 md = checkfield(md, 'fieldname', 'love.pw_threshold', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0) 117 125 md = checkfield(md, 'fieldname', 'love.integration_steps_per_layer', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0) 118 126 md = checkfield(md, 'fieldname', 'love.love_kernels', 'values', [0, 1]) … … 127 135 raise RuntimeError('Degree 1 not supported for forcing type {}. Use sh_min >= 2 for this kind of calculation.'.format(md.love.forcing_type)) 128 136 137 if md.love.chandler_wobble == 1: 138 print('Warning: Chandler wobble in Love number calculator has not been validated yet') 139 129 140 # Need 'litho' material 130 if not hasattr(md.materials, 'materials')or 'litho' not in md.materials.nature:141 if md.materials.__class__.__name__ != 'materials' or 'litho' not in md.materials.nature: 131 142 raise RuntimeError('Need a \'litho\' material to run a Fourier Love number analysis') 132 143 133 mat = np.where(np.array( nature) == 'litho')[0]144 mat = np.where(np.array(md.materials.nature) == 'litho')[0] 134 145 if md.love.forcing_type <= 4: 135 146 md = checkfield(md, 'fieldname', 'love.inner_core_boundary', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0, '<=', md.materials[mat].numlayers) … … 149 160 WriteData(fid, prefix, 'object', self, 'fieldname', 'mu0', 'format', 'Double') 150 161 WriteData(fid, prefix, 'object', self, 'fieldname', 'Gravitational_Constant', 'format', 'Double') 162 WriteData(fid, prefix, 'object', self, 'fieldname', 'chandler_wobble', 'format', 'Boolean') 151 163 WriteData(fid, prefix, 'object', self, 'fieldname', 'allow_layer_deletion', 'format', 'Boolean') 152 164 WriteData(fid, prefix, 'object', self, 'fieldname', 'underflow_tol', 'format', 'Double') 165 WriteData(fid, prefix, 'object', self, 'fieldname', 'pw_threshold', 'format', 'Double') 153 166 WriteData(fid, prefix, 'object', self, 'fieldname', 'integration_steps_per_layer', 'format', 'Integer') 154 167 WriteData(fid, prefix, 'object', self, 'fieldname', 'istemporal', 'format', 'Boolean') … … 171 184 print('Temporal love numbers: Overriding md.love.nfreq and md.love.frequencies') 172 185 self.nfreq = len(self.time) * 2 * self.n_temporal_iterations 173 self.frequencies = np.zeros((self.nfreq, 1))186 self.frequencies = np.zeros((self.nfreq,)) 174 187 for i in range(len(self.time)): 175 188 for j in range(2 * self.n_temporal_iterations): 176 self.frequencies[(i - 1) * 2 * self.n_temporal_iterations + j] = j * np.log(2) / self.time[i] / 2 / np.pi 189 if self.time[i] == 0: 190 self.frequencies[(i - 1) * 2 * self.n_temporal_iterations + j] = 0 # Convention to avoid marshalling infinite numbers 191 else: 192 self.frequencies[(i - 1) * 2 * self.n_temporal_iterations + j] = j * np.log(2) / self.time[i] / 2 / np.pi 193 return self 177 194 #}}} -
issm/trunk/src/m/classes/frontalforcings.m
r24313 r27035 7 7 properties (SetAccess=public) 8 8 meltingrate = NaN; 9 ablationrate = NaN; 9 10 end 10 11 methods … … 29 30 function self = extrude(self,md) % {{{ 30 31 self.meltingrate=project3d(md,'vector',self.meltingrate,'type','node'); 32 self.ablationrate=project3d(md,'vector',self.ablationrate,'type','node'); 31 33 end % }}} 32 34 function self = setdefaultparameters(self) % {{{ 33 35 34 36 meltingrate = NaN; 37 ablationrate = NaN; 35 38 end % }}} 36 39 function md = checkconsistency(self,md,solution,analyses) % {{{ … … 39 42 40 43 md = checkfield(md,'fieldname','frontalforcings.meltingrate','NaN',1,'Inf',1,'timeseries',1,'>=',0); 44 if ~isnan(md.frontalforcings.ablationrate) 45 md = checkfield(md,'fieldname','frontalforcings.ablationrate','Inf',1,'timeseries',1); 46 end 41 47 42 48 end % }}} … … 44 50 disp(sprintf(' Frontalforcings parameters:')); 45 51 fielddisplay(self,'meltingrate','melting rate at given location [m/a]'); 52 fielddisplay(self,'ablationrate','frontal ablation rate at given location [m/a], it contains both calving and melting'); 46 53 end % }}} 47 54 function marshall(self,prefix,md,fid) % {{{ … … 49 56 WriteData(fid,prefix,'name','md.frontalforcings.parameterization','data',1,'format','Integer'); 50 57 WriteData(fid,prefix,'object',self,'fieldname','meltingrate','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts,'scale',1./yts); 58 if ~isnan(md.frontalforcings.ablationrate) 59 WriteData(fid,prefix,'object',self,'fieldname','ablationrate','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts,'scale',1./yts); 60 end 51 61 end % }}} 52 62 end -
issm/trunk/src/m/classes/frontalforcingsrignot.py
r26744 r27035 64 64 def marshall(self, prefix, md, fid): # {{{ 65 65 WriteData(fid, prefix, 'name', 'md.frontalforcings.parameterization', 'data', 2, 'format', 'Integer') 66 WriteData(fid, prefix, 'object', self, 'fieldname', 'basin_id', 'data', self.basin_id , 'name', 'md.frontalforcings.basin_id', 'format', 'IntMat', 'mattype', 2)# 0-indexed66 WriteData(fid, prefix, 'object', self, 'fieldname', 'basin_id', 'data', self.basin_id - 1, 'name', 'md.frontalforcings.basin_id', 'format', 'IntMat', 'mattype', 2) # 0-indexed 67 67 WriteData(fid, prefix, 'object', self, 'fieldname', 'num_basins', 'format', 'Integer') 68 68 WriteData(fid, prefix, 'object', self, 'fieldname', 'subglacial_discharge', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts) -
issm/trunk/src/m/classes/frontalforcingsrignotautoregression.m
r26744 r27035 66 66 fielddisplay(self,'basin_id','basin number assigned to each element [unitless]'); 67 67 fielddisplay(self,'subglacial_discharge','sum of subglacial discharge for each basin [m/d]'); 68 fielddisplay(self,'beta0','basin-specific intercept values [∘C] ');68 fielddisplay(self,'beta0','basin-specific intercept values [∘C] (if beta_1==0 mean=beta_0/(1-sum(phi)))'); 69 69 fielddisplay(self,'beta1','basin-specific trend values [∘C yr^(-1)]'); 70 70 fielddisplay(self,'ar_order','order of the autoregressive model [unitless]'); … … 75 75 function marshall(self,prefix,md,fid) % {{{ 76 76 yts=md.constants.yts; 77 WriteData(fid,prefix,'name','md.frontalforcings.parameterization','data', 55,'format','Integer');77 WriteData(fid,prefix,'name','md.frontalforcings.parameterization','data',3,'format','Integer'); 78 78 WriteData(fid,prefix,'object',self,'class','frontalforcings','fieldname','num_basins','format','Integer'); 79 79 WriteData(fid,prefix,'object',self,'class','frontalforcings','fieldname','subglacial_discharge','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts); -
issm/trunk/src/m/classes/frontalforcingsrignotautoregression.py
r26744 r27035 1 1 # -*- coding: utf-8 -*- 2 3 2 import numpy as np 4 5 3 from checkfield import checkfield 6 4 from fielddisplay import fielddisplay 7 5 from MatlabFuncs import * 8 6 from WriteData import WriteData 7 9 8 10 9 class frontalforcingsrignotautoregression(object): … … 36 35 s += '{}\n'.format(fielddisplay(self, 'basin_id', 'basin number assigned to each element [unitless]')) 37 36 s += '{}\n'.format(fielddisplay(self, 'subglacial_discharge', 'sum of subglacial discharge for each basin [m/d]')) 38 s += '{}\n'.format(fielddisplay(self, 'beta0', 'basin-specific intercept values [°C] '))37 s += '{}\n'.format(fielddisplay(self, 'beta0', 'basin-specific intercept values [°C] (if beta_1==0 mean=beta_0/(1-sum(phi)))')) 39 38 s += '{}\n'.format(fielddisplay(self, 'beta1', 'basin-specific trend values [°C yr^(-1)]')) 40 39 s += '{}\n'.format(fielddisplay(self, 'ar_order', 'order of the autoregressive model [unitless]')) … … 49 48 self.num_basins = 0 50 49 self.subglacial_discharge = np.nan 51 self.ar_order = 0.0 # Autoregression model of order 050 self.ar_order = 0.0 # Autoregression model of order 0 52 51 return self 53 52 #}}} … … 61 60 md = checkfield(md, 'fieldname', 'frontalforcings.basin_id', 'Inf', 1, '>=', 0, '<=', md.frontalforcings.num_basins, 'size', [md.mesh.numberofelements]) 62 61 md = checkfield(md, 'fieldname', 'frontalforcings.subglacial_discharge', '>=', 0, 'NaN', 1, 'Inf', 1, 'timeseries', 1) 62 if len(np.shape(self.beta0)) == 1: 63 self.beta0 = np.array([self.beta0]) 64 self.beta1 = np.array([self.beta1]) 63 65 md = checkfield(md, 'fieldname', 'frontalforcings.beta0', 'NaN', 1, 'Inf', 1, 'size', [1, md.frontalforcings.num_basins], 'numel', md.frontalforcings.num_basins) 64 66 md = checkfield(md, 'fieldname', 'frontalforcings.beta1', 'NaN', 1, 'Inf', 1, 'size', [1, md.frontalforcings.num_basins], 'numel', md.frontalforcings.num_basins) … … 77 79 def marshall(self, prefix, md, fid): # {{{ 78 80 yts = md.constants.yts 79 WriteData(fid, prefix, 'name', 'md.frontalforcings.parameterization', 'data', 55, 'format', 'Integer')81 WriteData(fid, prefix, 'name', 'md.frontalforcings.parameterization', 'data', 3, 'format', 'Integer') 80 82 WriteData(fid, prefix, 'object', self, 'class', 'frontalforcings', 'fieldname', 'num_basins', 'format', 'Integer') 81 83 WriteData(fid, prefix, 'object', self, 'class', 'frontalforcings', 'fieldname', 'subglacial_discharge', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) … … 83 85 WriteData(fid, prefix, 'object', self, 'class', 'frontalforcings', 'fieldname', 'ar_initialtime', 'format', 'Double', 'scale', yts) 84 86 WriteData(fid, prefix, 'object', self, 'class', 'frontalforcings', 'fieldname', 'ar_timestep', 'format', 'Double', 'scale', yts) 85 WriteData(fid, prefix, 'object', self, 'class', 'frontalforcings', 'fieldname', 'basin_id', 'data', self.basin_id , 'name', 'md.frontalforcings.basin_id', 'format', 'IntMat', 'mattype', 2)# 0-indexed87 WriteData(fid, prefix, 'object', self, 'class', 'frontalforcings', 'fieldname', 'basin_id', 'data', self.basin_id - 1, 'name', 'md.frontalforcings.basin_id', 'format', 'IntMat', 'mattype', 2) # 0-indexed 86 88 WriteData(fid, prefix, 'object', self, 'class', 'frontalforcings', 'fieldname', 'beta0', 'format', 'DoubleMat', 'name', 'md.frontalforcings.beta0') 87 89 WriteData(fid, prefix, 'object', self, 'class', 'frontalforcings', 'fieldname', 'beta1', 'format', 'DoubleMat', 'name', 'md.frontalforcings.beta1', 'scale', 1 / yts, 'yts', yts) -
issm/trunk/src/m/classes/geometry.py
r26744 r27035 61 61 62 62 def marshall(self, prefix, md, fid): # {{{ 63 length_thickness = len(self.thickness) 63 if isinstance(self.thickness, (list, np.ndarray)): 64 length_thickness = len(self.thickness) 65 else: 66 length_thickness = 1 67 64 68 if (length_thickness == md.mesh.numberofvertices) or (length_thickness == md.mesh.numberofvertices + 1): 65 69 WriteData(fid, prefix, 'object', self, 'fieldname', 'thickness', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts) -
issm/trunk/src/m/classes/groundingline.m
r25836 r27035 9 9 friction_interpolation = ''; 10 10 melt_interpolation = ''; 11 requested_outputs = {}; 11 12 end 12 13 methods … … 25 26 self.friction_interpolation= 'SubelementFriction1'; 26 27 self.melt_interpolation = 'NoMeltOnPartiallyFloating'; 28 %default output 29 self.requested_outputs = {'default'}; 27 30 28 31 end % }}} … … 32 35 md = checkfield(md,'fieldname','groundingline.friction_interpolation','values',{'NoFrictionOnPartiallyFloating' 'SubelementFriction1' 'SubelementFriction2'}); 33 36 md = checkfield(md,'fieldname','groundingline.melt_interpolation','values',{'NoMeltOnPartiallyFloating' 'SubelementMelt1' 'SubelementMelt2' 'FullMeltOnPartiallyFloating'}); 37 md = checkfield(md,'fieldname','groundingline.requested_outputs','stringrow',1); 34 38 35 39 if ~strcmp(self.migration,'None') & strcmp(solution,'TransientSolution') & md.transient.isgroundingline==1, … … 48 52 49 53 end % }}} 54 function list = defaultoutputs(self,md) % {{{ 55 56 list = {'Surface','Base','MaskOceanLevelset'}; 57 58 end % }}} 50 59 function disp(self) % {{{ 51 60 disp(sprintf(' grounding line migration parameters:')); … … 53 62 fielddisplay(self,'friction_interpolation','type of friction interpolation for partially floating elements: ''NoFrictionOnPartiallyFloating'',''SubelementFriction1'', or ''SubelementFriction2'''); 54 63 fielddisplay(self,'melt_interpolation','type of melt interpolation for partially floating elements: ''NoMeltOnPartiallyFloating'',''SubelementMelt1'',''SubelementMelt2'', or ''FullMeltOnPartiallyFloating'''); 64 fielddisplay(self,'requested_outputs','additional outputs requested'); 55 65 56 66 end % }}} … … 59 69 WriteData(fid,prefix,'data',self.friction_interpolation,'name','md.groundingline.friction_interpolation','format','String'); 60 70 WriteData(fid,prefix,'data',self.melt_interpolation,'name','md.groundingline.melt_interpolation','format','String'); 71 72 %process requested outputs 73 outputs = self.requested_outputs; 74 pos = find(ismember(outputs,'default')); 75 if ~isempty(pos), 76 outputs(pos) = []; %remove 'default' from outputs 77 outputs = [outputs defaultoutputs(self,md)]; %add defaults 78 end 79 WriteData(fid,prefix,'data',outputs,'name','md.groundingline.requested_outputs','format','StringArray') 61 80 end % }}} 62 81 function savemodeljs(self,fid,modelname) % {{{ 63 82 64 83 writejsstring(fid,[modelname '.groundingline.migration'],self.migration); 65 writejsstring(fid,[modelname '.groundingline.friction_interpolation'],self.migration); 66 writejsstring(fid,[modelname '.groundingline.melt_interpolation'],self.migration); 84 writejsstring(fid,[modelname '.groundingline.friction_interpolation'],self.friction_interpolation); 85 writejsstring(fid,[modelname '.groundingline.melt_interpolation'],self.melt_interpolation); 86 writejscellstring(fid,[modelname '.groundingline.requested_outputs'],self.requested_outputs); 67 87 68 88 end % }}} -
issm/trunk/src/m/classes/groundingline.py
r26744 r27035 18 18 self.friction_interpolation = '' 19 19 self.melt_interpolation = '' 20 self.requested_outptuts = [] 20 21 21 22 # Set defaults … … 29 30 s += '{}\n'.format(fielddisplay(self, 'migration', 'type of friction interpolation on partially floating elements: ''SubelementFriction1'', ''SubelementFriction2'', ''NoFrictionOnPartiallyFloating''')) 30 31 s += '{}\n'.format(fielddisplay(self, 'migration', 'type of melt interpolation on partially floating elements: \'SubelementMelt1\', \'SubelementMelt2\', \'NoMeltOnPartiallyFloating\', \'FullMeltOnPartiallyFloating\'')) 32 s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 31 33 return s 32 34 # }}} 35 36 def defaultoutputs(self, md): # {{{ 37 return ['Surface', 'Base','MaskOceanLevelset'] 38 39 #}}} 33 40 34 41 def setdefaultparameters(self): # {{{ … … 37 44 self.friction_interpolation = 'SubelementFriction1' 38 45 self.melt_interpolation = 'NoMeltOnPartiallyFloating' 46 # Default output 47 self.requested_outputs = ['default'] 39 48 40 49 return self … … 45 54 md = checkfield(md, 'fieldname', 'groundingline.friction_interpolation', 'values', ['SubelementFriction1', 'SubelementFriction2', 'NoFrictionOnPartiallyFloating']) 46 55 md = checkfield(md, 'fieldname', 'groundingline.melt_interpolation', 'values', ['SubelementMelt1', 'SubelementMelt2', 'NoMeltOnPartiallyFloating', 'FullMeltOnPartiallyFloating']) 56 md = checkfield(md, 'fieldname', 'groundingline.requested_outputs', 'stringrow', 1) 47 57 48 58 if(not m.strcmp(self.migration, 'None') and md.transient.isgroundingline and solution == 'TransientSolution'): … … 62 72 WriteData(fid, prefix, 'data', self.friction_interpolation, 'name', 'md.groundingline.friction_interpolation', 'format', 'String') 63 73 WriteData(fid, prefix, 'data', self.melt_interpolation, 'name', 'md.groundingline.melt_interpolation', 'format', 'String') 74 75 # Process requested outputs 76 outputs = self.requested_outputs 77 indices = [i for i, x in enumerate(outputs) if x == 'default'] 78 if len(indices) > 0: 79 outputscopy = outputs[0:max(0, indices[0] - 1)] + self.defaultoutputs(md) + outputs[indices[0] + 1:] 80 outputs = outputscopy 81 WriteData(fid, prefix, 'data', outputs, 'name', 'md.groundingline.requested_outputs', 'format', 'StringArray') 64 82 # }}} -
issm/trunk/src/m/classes/hydrologyglads.py
r25836 r27035 58 58 59 59 def defaultoutputs(self, md): # {{{ 60 list = ['EffectivePressure', 'HydraulicPotential', 'HydrologySheetThickness', 'ChannelArea' ]60 list = ['EffectivePressure', 'HydraulicPotential', 'HydrologySheetThickness', 'ChannelArea', 'ChannelDischarge'] 61 61 return list 62 62 # }}} -
issm/trunk/src/m/classes/hydrologyshreve.m
r26744 r27035 35 35 end % }}} 36 36 function md = checkconsistency(self,md,solution,analyses) % {{{ 37 38 37 %Early return 39 38 if ~ismember('HydrologyShreveAnalysis',analyses) | (strcmp(solution,'TransientSolution') & md.transient.ishydrology==0), return; end -
issm/trunk/src/m/classes/hydrologytws.m
r26744 r27035 44 44 end % }}} 45 45 function marshall(self,prefix,md,fid) % {{{ 46 WriteData(fid,prefix,'name','md.hydrology.model','data', 2,'format','Integer');46 WriteData(fid,prefix,'name','md.hydrology.model','data',6,'format','Integer'); 47 47 WriteData(fid,prefix,'object',self,'fieldname','spcwatercolumn','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 48 48 outputs = self.requested_outputs; -
issm/trunk/src/m/classes/hydrologytws.py
r26744 r27035 51 51 52 52 def marshall(self, prefix, md, fid): # {{{ 53 WriteData(fid, prefix, 'name', 'md.hydrology.model', 'data', 2, 'format', 'Integer')53 WriteData(fid, prefix, 'name', 'md.hydrology.model', 'data', 6, 'format', 'Integer') 54 54 WriteData(fid, prefix, 'object', self, 'fieldname', 'spcwatercolumn', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts) 55 55 outputs = self.requested_outputs 56 56 pos = find(ismember(outputs,'default')) 57 if not len(pos) ,57 if not len(pos): 58 58 outputs[pos] = []; # remove 'default' from outputs 59 59 outputs.extend(defaultoutputs(self, md)) # add defaults -
issm/trunk/src/m/classes/initialization.m
r26744 r27035 39 39 function md = checkconsistency(self,md,solution,analyses) % {{{ 40 40 if ismember('StressbalanceAnalysis',analyses) & ~(strcmp(solution,'TransientSolution') & md.transient.isstressbalance == 0), 41 if ~(isnan(md.initialization.vx) | isnan(md.initialization.vy)),41 if numel(md.initialization.vx)>1 | numel(md.initialization.vy)>1 42 42 md = checkfield(md,'fieldname','initialization.vx','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]); 43 43 md = checkfield(md,'fieldname','initialization.vy','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]); … … 59 59 md = checkfield(md,'fieldname','initialization.vy','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]); 60 60 %Triangle with zero velocity 61 if any(sum(abs(md.initialization.vx(md.mesh.elements)),2)==0 & sum(abs(md.initialization.vy(md.mesh.elements)),2)==0 )61 if any(sum(abs(md.initialization.vx(md.mesh.elements)),2)==0 & sum(abs(md.initialization.vy(md.mesh.elements)),2)==0 & min(md.mask.ice_levelset(md.mesh.elements),[],2)<0) 62 62 md = checkmessage(md,'at least one triangle has all its vertices with a zero velocity'); 63 63 end -
issm/trunk/src/m/classes/inversion.m
r26744 r27035 104 104 %Only SSA, HO and FS are supported right now 105 105 if strcmp(solution,'StressbalanceSolution') 106 if ~(md.flowequation.isSSA || md.flowequation.isM LHO || md.flowequation.isHO || md.flowequation.isFS || md.flowequation.isL1L2),107 md = checkmessage(md,['inversion can only be performed for SSA, M LHO, HO or FS ice flow models']);106 if ~(md.flowequation.isSSA || md.flowequation.isMOLHO || md.flowequation.isHO || md.flowequation.isFS || md.flowequation.isL1L2), 107 md = checkmessage(md,['inversion can only be performed for SSA, MOLHO, HO or FS ice flow models']); 108 108 end 109 109 end -
issm/trunk/src/m/classes/inversion.py
r26744 r27035 131 131 md = checkfield(md, 'fieldname', 'inversion.step_threshold', 'size', [md.inversion.nsteps]) 132 132 md = checkfield(md, 'fieldname', 'inversion.cost_functions', 'size', [num_costfunc], 'values', supportedcostfunctions()) 133 md = checkfield(md, 'fieldname', 'inversion.cost_functions_coefficients', 'size', [md.mesh.numberofvertices, num_costfunc], '>=', 0) 134 md = checkfield(md, 'fieldname', 'inversion.gradient_scaling', 'size', [md.inversion.nsteps, num_controls]) 135 md = checkfield(md, 'fieldname', 'inversion.min_parameters', 'size', [md.mesh.numberofvertices, num_controls]) 136 md = checkfield(md, 'fieldname', 'inversion.max_parameters', 'size', [md.mesh.numberofvertices, num_controls]) 133 if num_costfunc == 1: 134 md.inversion.cost_functions_coefficients = np.squeeze(md.inversion.cost_functions_coefficients) 135 md = checkfield(md, 'fieldname', 'inversion.cost_functions_coefficients', 'size', [md.mesh.numberofvertices], '>=', 0) 136 else: 137 md = checkfield(md, 'fieldname', 'inversion.cost_functions_coefficients', 'size', [md.mesh.numberofvertices, num_costfunc], '>=', 0) 138 139 if num_controls == 1: 140 md.inversion.gradient_scaling = np.squeeze(md.inversion.gradient_scaling) 141 md.inversion.min_parameters = np.squeeze(md.inversion.min_parameters) 142 md.inversion.max_parameters = np.squeeze(md.inversion.max_parameters) 143 md = checkfield(md, 'fieldname', 'inversion.gradient_scaling', 'size', [md.inversion.nsteps]) 144 md = checkfield(md, 'fieldname', 'inversion.min_parameters', 'size', [md.mesh.numberofvertices]) 145 md = checkfield(md, 'fieldname', 'inversion.max_parameters', 'size', [md.mesh.numberofvertices]) 146 else: 147 md = checkfield(md, 'fieldname', 'inversion.gradient_scaling', 'size', [md.inversion.nsteps, num_controls]) 148 md = checkfield(md, 'fieldname', 'inversion.min_parameters', 'size', [md.mesh.numberofvertices, num_controls]) 149 md = checkfield(md, 'fieldname', 'inversion.max_parameters', 'size', [md.mesh.numberofvertices, num_controls]) 137 150 138 151 # Only SSA, HO and FS are supported right now 139 152 if solution == 'StressbalanceSolution': 140 if not (md.flowequation.isSSA or md.flowequation.isM LHO or md.flowequation.isHO or md.flowequation.isFS or md.flowequation.isL1L2):141 md.checkmessage("'inversion can only be performed for SSA, M LHO, HO or FS ice flow models")153 if not (md.flowequation.isSSA or md.flowequation.isMOLHO or md.flowequation.isHO or md.flowequation.isFS or md.flowequation.isL1L2): 154 md.checkmessage("'inversion can only be performed for SSA, MOLHO, HO or FS ice flow models") 142 155 if solution == 'BalancethicknessSolution': 143 156 md = checkfield(md, 'fieldname', 'inversion.thickness_obs', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) -
issm/trunk/src/m/classes/levelset.m
r26744 r27035 62 62 63 63 md = checkfield(md,'fieldname','levelset.spclevelset','Inf',1,'timeseries',1); 64 md = checkfield(md,'fieldname','levelset.stabilization','values',[0 1 2 5 ]);64 md = checkfield(md,'fieldname','levelset.stabilization','values',[0 1 2 5 6]); 65 65 md = checkfield(md,'fieldname','levelset.kill_icebergs','numel',1,'values',[0 1]); 66 66 md = checkfield(md,'fieldname','levelset.migration_max','numel',1,'NaN',1,'Inf',1,'>',0); -
issm/trunk/src/m/classes/lovenumbers.m
r26744 r27035 10 10 properties (SetAccess=public) 11 11 12 % regularlove numbers:13 h = []; %provided by PREM model14 k = []; %idem15 l = []; %idem12 %loading love numbers: 13 h = []; %provided by PREM model 14 k = []; %idem 15 l = []; %idem 16 16 17 17 %tidal love numbers for computing rotational feedback: 18 th = []; 19 tk = []; 20 tl = []; 21 tk2secular = 0; %deg 2 secular number. 18 th = []; 19 tk = []; 20 tl = []; 21 tk2secular = 0; %deg 2 secular number. 22 pmtf_colinear = []; 23 pmtf_ortho = []; 22 24 23 25 %time/frequency for visco-elastic love numbers … … 44 46 fielddisplay(self,'tl','tidal load Love number (deg 2)'); 45 47 fielddisplay(self,'tk2secular','secular fluid Love number'); 48 fielddisplay(self,'pmtf_colinear','Colinear component of the Polar Motion Transfer Function (e.g. x-motion due to x-component perturbation of the inertia tensor)'); 49 fielddisplay(self,'pmtf_ortho','Orthogonal component of the Polar Motion Transfer Function (couples x and y components, only used for Chandler Wobble)'); 50 46 51 47 52 fielddisplay(self,'istime','time (default: 1) or frequency love numbers (0)'); … … 62 67 self.tk2secular=0.942; 63 68 69 self.pmtf_colinear=0.0; 70 self.pmtf_ortho=0.0; 71 if maxdeg>=2 72 self.pmtf_colinear= (1.0+self.k(3,:))/(1.0-self.tk(3,:)/self.tk2secular); %valid only for elastic regime, not viscous. Also neglects chandler wobble 73 self.pmtf_ortho= 0.0; 74 end 64 75 %time: 65 76 self.istime=1; %temporal love numbers by default … … 82 93 md = checkfield(md,'fieldname','solidearth.lovenumbers.tl','NaN',1,'Inf',1); 83 94 md = checkfield(md,'fieldname','solidearth.lovenumbers.tk2secular','NaN',1,'Inf',1); 95 md = checkfield(md,'fieldname','solidearth.lovenumbers.pmtf_colinear','NaN',1,'Inf',1); 96 md = checkfield(md,'fieldname','solidearth.lovenumbers.pmtf_ortho','NaN',1,'Inf',1); 84 97 md = checkfield(md,'fieldname','solidearth.lovenumbers.timefreq','NaN',1,'Inf',1); 85 98 md = checkfield(md,'fieldname','solidearth.lovenumbers.istime','NaN',1,'Inf',1,'values',[0 1]); … … 91 104 92 105 ntf=length(self.timefreq); 93 if( size(self.h,2) ~= ntf | size(self.k,2) ~= ntf | size(self.l,2) ~= ntf | size(self.th,2) ~= ntf | size(self.tk,2) ~= ntf | size(self.tl,2) ~= ntf ),106 if( size(self.h,2) ~= ntf | size(self.k,2) ~= ntf | size(self.l,2) ~= ntf | size(self.th,2) ~= ntf | size(self.tk,2) ~= ntf | size(self.tl,2) ~= ntf | size(self.pmtf_colinear,2) ~= ntf | size(self.pmtf_ortho,2) ~= ntf), 94 107 error('lovenumbers error message: love numbers should have as many time/frequency steps as the time/frequency vector'); 108 end 109 110 if self.istime && self.timefreq(1)~=0 111 error('temporal love numbers must start with elastic response, i.e timefreq(1)=0'); 95 112 end 96 113 … … 108 125 WriteData(fid,prefix,'object',self,'fieldname','tk','name','md.solidearth.lovenumbers.tk','format','DoubleMat','mattype',1); 109 126 WriteData(fid,prefix,'object',self,'fieldname','tl','name','md.solidearth.lovenumbers.tl','format','DoubleMat','mattype',1); 127 WriteData(fid,prefix,'object',self,'fieldname','pmtf_colinear','name','md.solidearth.lovenumbers.pmtf_colinear','format','DoubleMat','mattype',1); 128 WriteData(fid,prefix,'object',self,'fieldname','pmtf_ortho','name','md.solidearth.lovenumbers.pmtf_ortho','format','DoubleMat','mattype',1); 110 129 WriteData(fid,prefix,'object',self,'data',self.tk2secular,'fieldname','lovenumbers.tk2secular','format','Double'); 111 130 -
issm/trunk/src/m/classes/lovenumbers.py
r26744 r27035 19 19 20 20 def __init__(self, *args): #{{{ 21 # Regularlove numbers22 self.h = [] 23 self.k = [] 24 self.l = [] 21 # Loading love numbers 22 self.h = [] # Provided by PREM model 23 self.k = [] # idem 24 self.l = [] # idem 25 25 26 26 # Tidal love numbers for computing rotational feedback … … 28 28 self.tk = [] 29 29 self.tl = [] 30 self.tk2secular = 0 # deg 2 secular number 30 self.tk2secular = 0 # deg 2 secular number 31 self.pmtf_colinear = [] 32 self.pmtf_ortho = [] 33 pmtf_colinear = [] 34 pmtf_ortho = [] 31 35 32 36 # Time/frequency for visco-elastic love numbers … … 49 53 s += '{}\n'.format(fielddisplay(self, 'tl', 'tidal load Love number (deg 2)')) 50 54 s += '{}\n'.format(fielddisplay(self, 'tk2secular', 'secular fluid Love number')) 55 s += '{}\n'.format(fielddisplay(self, 'pmtf_colinear', 'Colinear component of the Polar Motion Transfer Function (e.g. x-motion due to x-component perturbation of the inertia tensor)')) 56 s += '{}\n'.format(fielddisplay(self, 'pmtf_ortho', 'Orthogonal component of the Polar Motion Transfer Function (couples x and y components, only used for Chandler Wobble)')) 51 57 s += '{}\n'.format(fielddisplay(self, 'istime', 'time (default: 1) or frequency love numbers (0)')) 52 58 s += '{}\n'.format(fielddisplay(self, 'timefreq', 'time/frequency vector (yr or 1/yr)')) 59 s += '{}\n'.format(fielddisplay(self, 'pmtf_colinear', 'Colinear component of the Polar Motion Transfer Function (e.g. x-motion due to x-component perturbation of the inertia tensor)')) 60 s += '{}\n'.format(fielddisplay(self, 'pmtf_ortho', 'Orthogonal component of the Polar Motion Transfer Function (couples x and y components, only used for Chandler Wobble)')) 53 61 return s 54 62 #}}} … … 65 73 # Secular fluid love number 66 74 self.tk2secular = 0.942 75 self.pmtf_colinear=0.0 76 self.pmtf_ortho=0.0 77 if maxdeg>=2: 78 self.pmtf_colinear= (1.0+self.k[3-1,:])/(1.0-self.tk[3-1,:]/self.tk2secular) #valid only for elastic regime, not viscous. Also neglects chandler wobble 79 self.pmtf_ortho= 0.0 67 80 81 self.pmtf_colinear = np.array([0.0]).reshape(-1, 1) 82 self.pmtf_ortho = np.array([0.0]).reshape(-1, 1) 83 if maxdeg >= 2: 84 self.pmtf_colinear = ((1.0 + self.k[2, :]) / (1.0 - self.tk[2, :] / self.tk2secular)).reshape(-1, 1) # Valid only for elastic regime, not viscous. Also neglects chandler wobble. 85 self.pmtf_ortho = np.array([0.0]).reshape(-1, 1) 68 86 # Time 69 87 self.istime = 1 # Temporal love numbers by default … … 83 101 md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.tl', 'NaN', 1, 'Inf', 1) 84 102 md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.tk2secular', 'NaN', 1, 'Inf', 1) 103 md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.pmtf_colinear', 'NaN', 1, 'Inf', 1) 104 md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.pmtf_ortho', 'NaN', 1, 'Inf', 1) 85 105 md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.timefreq', 'NaN', 1, 'Inf', 1) 86 106 md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.istime', 'NaN', 1, 'Inf', 1, 'values', [0, 1]) … … 91 111 92 112 ntf = len(self.timefreq) 93 if (np.shape(self.h)[1] != ntf or np.shape(self.k)[1] != ntf or np.shape(self.l)[1] != ntf or np.shape(self.th)[1] != ntf or np.shape(self.tk)[1] != ntf or np.shape(self.tl)[1] != ntf ):113 if (np.shape(self.h)[1] != ntf or np.shape(self.k)[1] != ntf or np.shape(self.l)[1] != ntf or np.shape(self.th)[1] != ntf or np.shape(self.tk)[1] != ntf or np.shape(self.tl)[1] != ntf or np.shape(self.pmtf_colinear)[1] != ntf or np.shape(self.pmtf_ortho)[1] != ntf): 94 114 raise ValueError('lovenumbers error message: love numbers should have as many time/frequency steps as the time/frequency vector') 95 115 116 if self.istime and self.timefreq[0] != 0: 117 raise ValueError('temporal love numbers must start with elastic response, i.e. timefreq[0] = 0') 96 118 return md 97 119 #}}} … … 109 131 WriteData(fid, prefix, 'object', self, 'fieldname', 'tk', 'name', 'md.solidearth.lovenumbers.tk', 'format', 'DoubleMat', 'mattype', 1) 110 132 WriteData(fid, prefix, 'object', self, 'fieldname', 'tl', 'name', 'md.solidearth.lovenumbers.tl', 'format', 'DoubleMat', 'mattype', 1) 133 WriteData(fid, prefix, 'object', self, 'fieldname', 'pmtf_colinear', 'name', 'md.solidearth.lovenumbers.pmtf_colinear', 'format', 'DoubleMat', 'mattype', 1) 134 WriteData(fid, prefix, 'object', self, 'fieldname', 'pmtf_ortho', 'name', 'md.solidearth.lovenumbers.pmtf_ortho', 'format', 'DoubleMat', 'mattype', 1) 111 135 WriteData(fid, prefix, 'object', self, 'data', self.tk2secular, 'fieldname', 'lovenumbers.tk2secular', 'format', 'Double') 136 WriteData(fid, prefix, 'object', self, 'fieldname', 'pmtf_colinear','name','md.solidearth.lovenumbers.pmtf_colinear','format','DoubleMat','mattype',1); 137 WriteData(fid, prefix, 'object', self, 'fieldname', 'pmtf_ortho','name','md.solidearth.lovenumbers.pmtf_ortho','format','DoubleMat','mattype',1); 112 138 113 139 if (self.istime): … … 118 144 WriteData(fid, prefix, 'object', self, 'fieldname', 'timefreq', 'name', 'md.solidearth.lovenumbers.timefreq', 'format', 'DoubleMat', 'mattype', 1, 'scale', scale); 119 145 #}}} 120 146 121 147 def extrude(self, md): #{{{ 122 148 return -
issm/trunk/src/m/classes/m1qn3inversion.py
r25836 r27035 1 1 import numpy as np 2 3 2 from checkfield import checkfield 4 3 from fielddisplay import fielddisplay -
issm/trunk/src/m/classes/massfluxatgate.py
r24313 r27035 1 import numpy as np 1 2 from fielddisplay import fielddisplay 2 3 from pairoptions import pairoptions … … 20 21 self.definitionstring = '' 21 22 self.profilename = '' 22 self.segments = float('NaN')23 self.segments = np.nan 23 24 24 25 #set defaults -
issm/trunk/src/m/classes/matdamageice.py
r26744 r27035 57 57 s += '{}\n'.format(fielddisplay(self, 'rheology_law', 'law for the temperature dependance of the rheology: \'None\', \'BuddJacka\', \'Cuffey\', \'CuffeyTemperate\', \'Paterson\', \'Arrhenius\' or \'LliboutryDuval\'')) 58 58 s += '{}\n'.format(fielddisplay(self, 'earth_density', 'Mantle density [kg m^-3]')) 59 return s tring59 return s 60 60 #}}} 61 61 … … 93 93 # Thermal exchange velocity (ice-water interface) (m/s) 94 94 self.thermal_exchange_velocity = 1.00e-4 95 # Rheology law: what is the temperature dependence of B with T 95 # Rheology law: what is the temperature dependence of B with T 96 96 # available: none, paterson and arrhenius 97 97 self.rheology_law = 'Paterson' -
issm/trunk/src/m/classes/materials.m
r26744 r27035 264 264 end 265 265 ind=find(md.materials.issolid==0); 266 if sum(ismember(diff(ind),1)>=1) %if there are at least two consecutive indices that contain issolid = 0267 error(['Fluid layers detected at layers #', num2str(ind'), ', but having 2 or more adjacent fluid layers is not supported yet. Consider merging them.'])268 end266 %if sum(ismember(diff(ind),1)>=1) %if there are at least two consecutive indices that contain issolid = 0 267 % error(['Fluid layers detected at layers #', num2str(ind'), ', but having 2 or more adjacent fluid layers is not supported yet. Consider merging them.']) 268 %end 269 269 270 270 case 'hydro' -
issm/trunk/src/m/classes/materials.py
r26744 r27035 1 1 import numpy as np 2 3 2 from checkfield import checkfield 4 3 from fielddisplay import fielddisplay … … 173 172 self.rheology_n = 3 174 173 elif nat == 'litho': 175 # We default to a configuration that enables running GIA 174 # We default to a configuration that enables running GIA 176 175 # solutions using giacaron and/or giaivins 177 176 self.numlayers = 2 178 177 179 # Center of the earth (approximation, must not be 0), then the 178 # Center of the earth (approximation, must not be 0), then the 180 179 # lab (lithosphere/asthenosphere boundary) then the surface 181 180 # (with 1d3 to avoid numerical singularities) … … 250 249 raise RuntimeError('First layer must be solid (issolid[0] > 0 AND lame_mu[0] > 0). Add a weak inner core if necessary.') 251 250 ind = np.where(md.materials.issolid == 0)[0] 252 if np.sum(np.in1d(np.diff(ind),1) >= 1): # If there are at least two consecutive indices that contain issolid = 0253 raise RuntimeError('Fluid layers detected at layers #' + indices + ', but having 2 or more adjacent fluid layers is not supported yet. Consider merging them.')251 #if np.sum(np.in1d(np.diff(ind),1) >= 1): # If there are at least two consecutive indices that contain issolid = 0 252 # raise RuntimeError('Fluid layers detected at layers #' + indices + ', but having 2 or more adjacent fluid layers is not supported yet. Consider merging them.') 254 253 255 254 elif nat == 'hydro': … … 295 294 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'density', 'format', 'DoubleMat', 'mattype', 3) 296 295 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'viscosity', 'format', 'DoubleMat', 'mattype', 3) 297 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rheologymodel', 'format', 'DoubleMat', 'mattype', 3) 296 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rheologymodel', 'format', 'DoubleMat', 'mattype', 3) 298 297 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'burgers_viscosity', 'format', 'DoubleMat', 'mattype', 3) 299 298 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'burgers_mu', 'format', 'DoubleMat', 'mattype', 3) -
issm/trunk/src/m/classes/model.m
r26744 r27035 928 928 x_edges = 0.5*(md.mesh.x(edges(:,1)) + md.mesh.x(edges(:,2))); 929 929 y_edges = 0.5*(md.mesh.y(edges(:,1)) + md.mesh.y(edges(:,2))); 930 md2.mesh.x= [md2.mesh.x;x_edges];931 md2.mesh.y= [md2.mesh.y;y_edges];932 md2.mesh.elements= [...930 xnew = [md2.mesh.x;x_edges]; 931 ynew = [md2.mesh.y;y_edges]; 932 indexnew = [... 933 933 index(:,1) nbv+edges_tria(:,3) nbv+edges_tria(:,2);... 934 934 nbv+edges_tria(:,2) nbv+edges_tria(:,3) nbv+edges_tria(:,1);... 935 935 nbv+edges_tria(:,2) nbv+edges_tria(:,1) index(:,3);... 936 936 nbv+edges_tria(:,3) index(:,2) nbv+edges_tria(:,1)]; 937 md2.mesh.numberofelements = 4*nbe; 938 md2.mesh.numberofvertices = nbv + size(edges,1); 937 %md2.mesh.numberofelements = 4*nbe; 938 %md2.mesh.numberofvertices = nbv + size(edges,1); 939 940 %Call Bamg to update other mesh properties 941 [bamgmesh_out bamggeom_out]=BamgConvertMesh(indexnew,xnew,ynew); 942 md2.mesh.x = bamgmesh_out.Vertices(:,1); 943 md2.mesh.y = bamgmesh_out.Vertices(:,2); 944 md2.mesh.elements = bamgmesh_out.Triangles(:,1:3); 945 md2.mesh.edges = bamgmesh_out.IssmEdges; 946 md2.mesh.segments = bamgmesh_out.IssmSegments(:,1:3); 947 md2.mesh.segmentmarkers = bamgmesh_out.IssmSegments(:,4); 948 md2.mesh.numberofelements = size(md2.mesh.elements,1); 949 md2.mesh.numberofvertices = length(md2.mesh.x); 950 md2.mesh.numberofedges = size(md2.mesh.edges,1); 951 md2.mesh.vertexonboundary = zeros(md2.mesh.numberofvertices,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2)) = 1; 952 953 %Deal with boudary 954 md2.mesh.vertexonboundary = [md.mesh.vertexonboundary;sum(md.mesh.vertexonboundary(edges),2)==2]; 955 md2.mesh.elementconnectivity=bamgmesh_out.ElementConnectivity; 956 md2.mesh.elementconnectivity(find(isnan(md2.mesh.elementconnectivity)))=0; 939 957 disp([' Old number of elements: ' num2str(nbe)]); 940 958 disp([' New number of elements: ' num2str(4*nbe)]); … … 1734 1752 1735 1753 end % }}} 1736 function savemodeljs(md,modelname,websiteroot,varargin) % {{{ 1737 1738 %the goal of this routine is to save the model as a javascript array that can be included in any html 1739 %file: 1740 1741 options=pairoptions(varargin{:}); 1742 optimization=getfieldvalue(options,'optimize',0); 1743 1744 1745 %disp: 1746 disp(['saving model ''' modelname ''' in file ' websiteroot '/js/' modelname '.js']); 1747 1748 %open file for writing and declare the model: 1749 fid=fopen([websiteroot '/js/' modelname '.js'],'w'); 1750 fprintf(fid,'var %s=new model();\n',modelname); 1751 1752 %now go through all the classes and fwrite all the corresponding fields: 1753 1754 fields=properties('model'); 1754 function saveasstruct(md,filename) % {{{ 1755 1756 fields=sort(properties('model')); %sort fields so that comparison of binary files is easier 1757 disp('Converting all model fields to struct...'); 1758 warning off MATLAB:structOnObject 1755 1759 for i=1:length(fields), 1756 1760 field=fields{i}; 1757 1758 %Some properties do not need to be saved 1759 if ismember(field,{'results','cluster' }), 1760 continue; 1761 end 1762 1763 %some optimization: 1764 if optimization==1, 1765 %optimize for plotting only: 1766 if ~ismember(field,{'geometry','mesh','mask'}), 1767 continue; 1768 end 1769 end 1770 1771 %Check that current field is an object 1772 if ~isobject(md.(field)) 1773 error(['field ''' char(field) ''' is not an object']); 1774 end 1775 1776 %savemodeljs for current object 1777 %disp(['javascript saving ' field '...']); 1778 savemodeljs(md.(field),fid,modelname); 1779 end 1780 1781 %done, close file: 1782 fclose(fid); 1761 md.(field) = struct(md.(field)); 1762 end 1763 disp('Converting model to struct...'); 1764 md=struct(md); 1765 warning on MATLAB:structOnObject 1766 disp(['Saving as ' filename '...']); 1767 save(filename,'md','-v7.3') 1768 end % }}} 1769 function savemodeljs(md,modelname,websiteroot,varargin) % {{{ 1770 1771 %the goal of this routine is to save the model as a javascript array that can be included in any html 1772 %file: 1773 1774 options=pairoptions(varargin{:}); 1775 optimization=getfieldvalue(options,'optimize',0); 1776 1777 1778 %disp: 1779 disp(['saving model ''' modelname ''' in file ' websiteroot '/js/' modelname '.js']); 1780 1781 %open file for writing and declare the model: 1782 fid=fopen([websiteroot '/js/' modelname '.js'],'w'); 1783 fprintf(fid,'var %s=new model();\n',modelname); 1784 1785 %now go through all the classes and fwrite all the corresponding fields: 1786 1787 fields=properties('model'); 1788 for i=1:length(fields), 1789 field=fields{i}; 1790 1791 %Some properties do not need to be saved 1792 if ismember(field,{'results','cluster' }), 1793 continue; 1783 1794 end 1795 1796 %some optimization: 1797 if optimization==1, 1798 %optimize for plotting only: 1799 if ~ismember(field,{'geometry','mesh','mask'}), 1800 continue; 1801 end 1802 end 1803 1804 %Check that current field is an object 1805 if ~isobject(md.(field)) 1806 error(['field ''' char(field) ''' is not an object']); 1807 end 1808 1809 %savemodeljs for current object 1810 %disp(['javascript saving ' field '...']); 1811 savemodeljs(md.(field),fid,modelname); 1784 1812 end 1785 end 1813 1814 %done, close file: 1815 fclose(fid); 1816 end 1817 end 1818 end -
issm/trunk/src/m/classes/model.py
r26744 r27035 823 823 md.inversion.max_parameters = project2d(md, md.inversion.max_parameters, md.mesh.numberoflayers) 824 824 if md.smb.__class__.__name__ == 'SMBforcing' and not np.isnan(md.smb.mass_balance).all(): 825 825 md.smb.mass_balance = project2d(md, md.smb.mass_balance, md.mesh.numberoflayers) 826 826 elif md.smb.__class__.__name__ == 'SMBhenning' and not np.isnan(md.smb.smbref).all(): 827 827 md.smb.smbref = project2d(md, md.smb.smbref, md.mesh.numberoflayers) 828 828 829 829 # Results -
issm/trunk/src/m/classes/pairoptions.py
r26744 r27035 11 11 12 12 def __init__(self, *arg): # {{{ 13 self.functionname = ''13 #self.functionname = '' 14 14 self.list = OrderedDict() 15 15 16 16 #get calling function name 17 import inspect 18 if len(inspect.stack()) > 1: 19 self.functionname = inspect.stack()[1][3] 17 #import inspect 18 #if len(inspect.stack()) > 1: 19 #self.functionname = inspect.stack()[1][3] 20 import traceback 21 try: 22 self.functionname = traceback.extract_stack(limit=2)[0][2] 23 except IndexError: 24 pass #this is probably similar to the previous if treatment (but faster) 20 25 21 26 #initialize list … … 98 103 """ 99 104 100 disp(['WARNING: pairoptions::displayunused is not yet implemented'])105 print('WARNING: pairoptions::displayunused is not yet implemented') 101 106 # }}} 107 102 108 def exist(self, field): # {{{ 103 109 """EXIST - check if the option exists -
issm/trunk/src/m/classes/regionaloutput.py
r24313 r27035 25 25 26 26 self.name = '' 27 self.model= '' 27 28 self.definitionstring = '' 28 29 self.outputnamestring = '' 29 self.mask = float('NaN')30 self.mask = np.nan 30 31 self.maskexpstring = '' 31 32 … … 46 47 self.setmaskfromexp(modelname) 47 48 48 if (len(self.mask) <= 1 & np.any(np.isnan(self.mask))):49 error('regionaloutput error message: ''mask'' field or ''maskexpstring'' and ''model'' fields should be defined!')49 # if (len(self.mask) <= 1 & np.any(np.isnan(self.mask))): 50 # raise IOError('regionaloutput error message: ''mask'' field or ''maskexpstring'' and ''model'' fields should be defined!') 50 51 51 52 #}}} … … 76 77 return self 77 78 # }}} 79 78 80 def checkconsistency(self, md, solution, analyses): # {{{ 79 81 -
issm/trunk/src/m/classes/results.py
r25836 r27035 143 143 144 144 def __getattr__(self, key): #{{{ 145 if len(self.steps) == 1: 146 return getattr(self.steps[0], key) 147 else: 148 raise Exception('<results>.<solution> error: Currently, can only get a field if we are not working with a transient solution.') 145 # NOTE: Currently only returning value from first frame of transient solution (see retrieval of md.results.TransientSolution.BedGRD in test2051.py for justification) 146 return getattr(self.steps[0], key) 147 148 # Original code 149 # if len(self.steps) == 1: 150 # return getattr(self.steps[0], key) 151 # else: 152 # raise Exception('<results>.<solution> error: Currently, can only get a field if we are not working with a transient solution.') 149 153 #}}} 150 154 -
issm/trunk/src/m/classes/rifts.py
r24313 r27035 67 67 68 68 numpairs = 0 69 for rift in self.riftstruct: 70 numpairs += np.size(rift['penaltypairs'], axis=0) 69 if numrifts > 0: 70 for rift in self.riftstruct: 71 numpairs += np.size(rift['penaltypairs'], axis=0) 71 72 72 # Convert strings in riftstruct to hard coded numbers73 FillDict = {'Air': 0,74 'Ice': 1,75 'Melange': 2,76 'Water': 3}77 for rift in self.riftstruct:78 if rift['fill'] in ['Air', 'Ice', 'Melange', 'Water']:79 rift['fill'] = FillDict[rift['fill']]73 # Convert strings in riftstruct to hard coded numbers 74 FillDict = {'Air': 0, 75 'Ice': 1, 76 'Melange': 2, 77 'Water': 3} 78 for rift in self.riftstruct: 79 if rift['fill'] in ['Air', 'Ice', 'Melange', 'Water']: 80 rift['fill'] = FillDict[rift['fill']] 80 81 81 # 2 for nodes + 2 for elements + 2 for normals + 1 for length + 1 for fill + 1 for friction + 1 for fraction + 1 for fractionincrement + 1 for state. 82 data = np.zeros((numpairs, 12)) 83 count = 0 84 for rift in self.riftstruct: 85 numpairsforthisrift = np.size(rift['penaltypairs'], 0) 86 data[count:count + numpairsforthisrift, 0:7] = rift['penaltypairs'] 87 data[count:count + numpairsforthisrift, 7] = rift['fill'] 88 data[count:count + numpairsforthisrift, 8] = rift['friction'] 89 data[count:count + numpairsforthisrift, 9] = rift['fraction'] 90 data[count:count + numpairsforthisrift, 10] = rift['fractionincrement'] 91 data[count:count + numpairsforthisrift, 11] = rift['state'].reshape(-1) 92 count += numpairsforthisrift 93 82 # 2 for nodes + 2 for elements + 2 for normals + 1 for length + 1 for fill + 1 for friction + 1 for fraction + 1 for fractionincrement + 1 for state. 83 data = np.zeros((numpairs, 12)) 84 count = 0 85 for rift in self.riftstruct: 86 numpairsforthisrift = np.size(rift['penaltypairs'], 0) 87 data[count:count + numpairsforthisrift, 0:7] = rift['penaltypairs'] 88 data[count:count + numpairsforthisrift, 7] = rift['fill'] 89 data[count:count + numpairsforthisrift, 8] = rift['friction'] 90 data[count:count + numpairsforthisrift, 9] = rift['fraction'] 91 data[count:count + numpairsforthisrift, 10] = rift['fractionincrement'] 92 data[count:count + numpairsforthisrift, 11] = rift['state'].reshape(-1) 93 count += numpairsforthisrift 94 else: 95 data = np.zeros((numpairs, 12)) 94 96 WriteData(fid, prefix, 'data', numrifts, 'name', 'md.rifts.numrifts', 'format', 'Integer') 95 97 WriteData(fid, prefix, 'data', data, 'name', 'md.rifts.riftstruct', 'format', 'DoubleMat', 'mattype', 3) -
issm/trunk/src/m/classes/sampling.m
r26744 r27035 9 9 tau = 0; 10 10 beta = NaN; 11 phi = 0;11 phi = NaN; 12 12 alpha = 0; 13 13 robin = 0; … … 30 30 disp(sprintf('\n %s','Parameters of PDE operator (kappa^2 I-Laplacian)^(alpha/2)(tau):')); 31 31 fielddisplay(self,'kappa','coefficient of the identity operator'); 32 fielddisplay(self,'tau','scaling coefficient of the solution (default: 1.0)');32 fielddisplay(self,'tau','scaling coefficient of the solution'); 33 33 fielddisplay(self,'alpha','exponent in PDE operator, (default: 2.0, BiLaplacian covariance operator)'); 34 34 … … 47 47 function self = setdefaultparameters(self) % {{{ 48 48 49 %Scaling coefficient50 self.tau=1;51 52 49 %Apply Robin boundary conditions 53 50 self.robin=0; 54 55 %Temporal correlation factor56 self.phi=0;57 51 58 52 %Exponent in fraction SPDE (default: 2, biLaplacian covariance … … 77 71 78 72 md = checkfield(md,'fieldname','sampling.kappa','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1],'>',0); 79 md = checkfield(md,'fieldname','sampling.tau','NaN',1,'Inf',1,' numel',1,'>',0);73 md = checkfield(md,'fieldname','sampling.tau','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1],'>',0); 80 74 md = checkfield(md,'fieldname','sampling.robin','numel',1,'values',[0 1]); 81 75 if(md.sampling.robin) 82 76 md = checkfield(md,'fieldname','sampling.beta','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1],'>',0); 83 end 84 md = checkfield(md,'fieldname','sampling.phi','NaN',1,'Inf',1,'numel',1,'>=',0); 77 end 85 78 md = checkfield(md,'fieldname','sampling.alpha','NaN',1,'Inf',1,'numel',1,'>',0); 86 79 md = checkfield(md,'fieldname','sampling.seed','NaN',1,'Inf',1,'numel',1); … … 91 84 92 85 WriteData(fid,prefix,'object',self,'fieldname','kappa','format','DoubleMat','mattype',1); 93 WriteData(fid,prefix,'object',self,'fieldname','tau','format','Double ');86 WriteData(fid,prefix,'object',self,'fieldname','tau','format','DoubleMat','mattype',1); 94 87 WriteData(fid,prefix,'object',self,'fieldname','beta','format','DoubleMat','mattype',1); 95 WriteData(fid,prefix,'object',self,'fieldname','phi','format','Double ');88 WriteData(fid,prefix,'object',self,'fieldname','phi','format','DoubleMat','mattype',1); 96 89 WriteData(fid,prefix,'object',self,'fieldname','alpha','format','Integer'); 97 90 WriteData(fid,prefix,'object',self,'fieldname','robin','format','Boolean'); … … 110 103 111 104 nu = self.alpha-1; 112 KAPPA = sqrt(8*nu) /lc;113 TAU = sqrt(gamma(nu) /(gamma(self.alpha)*(4*pi)*KAPPA^(2*nu)*sigma^2));114 md.sampling.kappa = KAPPA *ones(md.mesh.numberofvertices,1);115 md.sampling.tau = TAU ;105 KAPPA = sqrt(8*nu)./lc; 106 TAU = sqrt(gamma(nu)./(gamma(self.alpha)*(4*pi)*KAPPA.^(2*nu).*sigma.^2)); 107 md.sampling.kappa = KAPPA.*ones(md.mesh.numberofvertices,1); 108 md.sampling.tau = TAU.*ones(md.mesh.numberofvertices,1); 116 109 117 110 end % }}} … … 121 114 writejsdouble(fid,[modelname '.sampling.tau'],self.tau); 122 115 writejsdouble(fid,[modelname '.sampling.beta'],self.beta); 123 writejsdouble(fid,[modelname '.sampling.phi'],self. beta);116 writejsdouble(fid,[modelname '.sampling.phi'],self.phi); 124 117 writejsdouble(fid,[modelname '.sampling.alpha'],self.alpha); 125 118 writejsdouble(fid,[modelname '.sampling.robin'],self.robin); -
issm/trunk/src/m/classes/solidearth.py
r26744 r27035 1 1 import numpy as np 2 3 2 from checkfield import checkfield 4 3 from fielddisplay import fielddisplay … … 6 5 from MatlabFuncs import * 7 6 from planetradius import planetradius 8 from project3d import project3d9 7 from rotational import rotational 10 8 from solidearthsettings import solidearthsettings … … 25 23 26 24 def __init__(self, *args): # {{{ 27 self.settings 28 self.external 29 self.lovenumbers 30 self.rotational 31 self.planetradius 32 self.requested_outputs 33 self.transitions 34 self.partitionice 35 self.partitionhydro 36 self.partitionocean 25 self.settings = solidearthsettings() 26 self.external = None 27 self.lovenumbers = lovenumbers() 28 self.rotational = rotational() 29 self.planetradius = planetradius('earth') 30 self.requested_outputs = [] 31 self.transitions = [] 32 self.partitionice = [] 33 self.partitionhydro = [] 34 self.partitionocean = [] 37 35 38 36 nargs = len(args) … … 44 42 raise Exception('solidearth constructor error message: zero or one argument only!') 45 43 # }}} 44 46 45 def __repr__(self): # {{{ 47 46 s = ' solidearthinputs, forcings and settings:\n' … … 57 56 print(self.lovenumbers) 58 57 print(self.rotational) 59 if len(self.external):58 try: 60 59 print(self.external) 60 except TypeError: 61 pass 61 62 return s 62 63 # }}} 64 63 65 def setdefaultparameters(self, planet): # {{{ 64 66 # Output default … … 79 81 self.planetradius = planetradius(planet) 80 82 # }}} 83 81 84 def checkconsistency(self, md, solution, analyses): # {{{ 82 85 if ('SealevelchangeAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslc): … … 94 97 return md 95 98 # }}} 99 96 100 def defaultoutputs(self, md): # {{{ 97 101 return ['Sealevel'] 98 102 # }}} 103 99 104 def marshall(self, prefix, md, fid): # {{{ 100 105 WriteData(fid, prefix, 'object', self, 'fieldname', 'planetradius', 'format', 'Double') … … 140 145 WriteData(fid, prefix, 'data', outputs, 'name', 'md.solidearth.requested_outputs', 'format', 'StringArray') 141 146 # }}} 147 142 148 def extrude(self, md): # {{{ 143 149 return self -
issm/trunk/src/m/classes/solidearthsettings.py
r26744 r27035 120 120 if md.mesh.__class__.__name__ == 'mesh3dsurface': 121 121 if self.grdmodel == 2: 122 raise RuntimeException('model requires a 2D mesh to run gia Ivins computations (change mesh from mesh3dsurface to mesh2d)')122 raise Exception('model requires a 2D mesh to run gia Ivins computations (change mesh from mesh3dsurface to mesh2d)') 123 123 else: 124 124 if self.grdmodel == 1: 125 raise RuntimeException('model requires a 3D surface mesh to run GRD computations (change mesh from mesh2d to mesh3dsurface)')125 raise Exception('model requires a 3D surface mesh to run GRD computations (change mesh from mesh2d to mesh3dsurface)') 126 126 if self.sealevelloading and not self.grdocean: 127 raise RuntimeException('solidearthsettings checkconsistency error message: need grdocean on if sealevelloading flag is set')127 raise Exception('solidearthsettings checkconsistency error message: need grdocean on if sealevelloading flag is set') 128 128 129 129 if self.compute_bp_grd and not md.solidearth.settings.isgrd: 130 raise RuntimeException('solidearthsettings checkconsistency error message; if bottom pressure grd patterns are requested, solidearth settings class should have isgrd flag on')130 raise Exception('solidearthsettings checkconsistency error message; if bottom pressure grd patterns are requested, solidearth settings class should have isgrd flag on') 131 131 132 132 return md -
issm/trunk/src/m/classes/spatiallinearbasalforcings.m
r25836 r27035 9 9 deepwater_melting_rate = NaN; 10 10 deepwater_elevation = NaN; 11 upperwater_melting_rate = NaN; 11 12 upperwater_elevation = NaN; 13 perturbation_melting_rate = NaN; 12 14 geothermalflux = NaN; 13 15 end … … 25 27 self.deepwater_elevation=lb.deepwater_elevation*ones(nvertices,1); 26 28 self.deepwater_melting_rate=lb.deepwater_melting_rate*ones(nvertices,1); 29 self.upperwater_melting_rate=lb.upperwater_melting_rate*ones(nvertices,1); 27 30 self.upperwater_elevation=lb.upperwater_elevation*ones(nvertices,1); 31 self.perturbation_melting_rate=lb.perturbation_melting_rate*ones(nvertices,1); 28 32 else 29 33 self=structtoobj(spatiallinearbasalforcings(),varargin{1}); … … 37 41 self.deepwater_melting_rate=project3d(md,'vector',self.deepwater_melting_rate,'type','node','layer',1); 38 42 self.deepwater_elevation=project3d(md,'vector',self.deepwater_elevation,'type','node','layer',1); 43 self.upperwater_melting_rate=project3d(md,'vector',self.upperwater_melting_rate,'type','node','layer',1); 39 44 self.upperwater_elevation=project3d(md,'vector',self.upperwater_elevation,'type','node','layer',1); 40 45 self.geothermalflux=project3d(md,'vector',self.geothermalflux,'type','node','layer',1); %bedrock only gets geothermal flux 46 self.perturbation_melting_rate=project3d(md,'vector',self.perturbation_melting_rate,'type','node','layer',1); 41 47 end % }}} 42 48 function self = initialize(self,md) % {{{ … … 58 64 function md = checkconsistency(self,md,solution,analyses) % {{{ 59 65 66 if numel(md.basalforcings.perturbation_melting_rate)>1 67 md = checkfield(md,'fieldname','basalforcings.perturbation_melting_rate','NaN',1,'Inf',1,'timeseries',1); 68 end 69 60 70 if ismember('MasstransportAnalysis',analyses) & ~(strcmp(solution,'TransientSolution') & md.transient.ismasstransport==0), 61 71 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1); 62 72 md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','NaN',1,'Inf',1,'timeseries',1,'>=',0); 63 73 md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','NaN',1,'Inf',1,'timeseries',1); 64 md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','NaN',1,'Inf',1,'timeseries',1,'<',0); 74 md = checkfield(md,'fieldname','basalforcings.upperwater_melting_rate','NaN',1,'Inf',1,'timeseries',1,'>=',0); 75 md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','NaN',1,'Inf',1,'timeseries',1,'<=',0); 65 76 end 66 77 if ismember('BalancethicknessAnalysis',analyses), … … 69 80 md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','>=',0,'numel',1); 70 81 md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','<','basalforcings.upperwater_elevation','numel',1); 82 md = checkfield(md,'fieldname','basalforcings.upperwater_melting_rate','>=',0,'numel',1); 71 83 md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','<=',0,'numel',1); 72 84 end … … 76 88 md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','>=',0,'numel',1); 77 89 md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','<','basalforcings.upperwater_elevation','numel',1); 78 md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','<',0,'numel',1); 90 md = checkfield(md,'fieldname','basalforcings.upperwater_melting_rate','>=',0,'numel',1); 91 md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','<=',0,'numel',1); 79 92 md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,'Inf',1,'timeseries',1,'>=',0); 80 93 end … … 86 99 fielddisplay(self,'deepwater_melting_rate','basal melting rate (positive if melting applied for floating ice whith base < deepwater_elevation) [m/yr]'); 87 100 fielddisplay(self,'deepwater_elevation','elevation of ocean deepwater [m]'); 101 fielddisplay(self,'upperwater_melting_rate','basal melting rate (positive if melting applied for floating ice whith base >= upperwater_elevation) [m/yr]'); 88 102 fielddisplay(self,'upperwater_elevation','elevation of ocean upperwater [m]'); 103 fielddisplay(self,'perturbation_melting_rate','basal melting rate perturbation added to computed melting rate (positive if melting) [m/yr]'); 89 104 fielddisplay(self,'geothermalflux','geothermal heat flux [W/m^2]'); 90 105 … … 94 109 yts=md.constants.yts; 95 110 96 floatingice_melting_rate=zeros(md.mesh.numberofvertices,1);97 pos=find(md.geometry.base<=md.basalforcings.deepwater_elevation);98 floatingice_melting_rate(pos)=md.basalforcings.deepwater_melting_rate(pos);99 pos=find(md.geometry.base>md.basalforcings.deepwater_elevation & md.geometry.base<md.basalforcings.upperwater_elevation);100 floatingice_melting_rate(pos)=md.basalforcings.deepwater_melting_rate(pos).*(md.geometry.base(pos)-md.basalforcings.upperwater_elevation(pos))./(md.basalforcings.deepwater_elevation(pos)-md.basalforcings.upperwater_elevation(pos));101 111 WriteData(fid,prefix,'name','md.basalforcings.model','data',6,'format','Integer'); 102 WriteData(fid,prefix,'data',floatingice_melting_rate,'format','DoubleMat','name','md.basalforcings.floatingice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);103 112 WriteData(fid,prefix,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','name','md.basalforcings.groundedice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 104 113 WriteData(fid,prefix,'object',self,'fieldname','geothermalflux','name','md.basalforcings.geothermalflux','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 105 114 WriteData(fid,prefix,'object',self,'fieldname','deepwater_melting_rate','format','DoubleMat','name','md.basalforcings.deepwater_melting_rate','scale',1./yts,'mattype',1); 106 115 WriteData(fid,prefix,'object',self,'fieldname','deepwater_elevation','format','DoubleMat','name','md.basalforcings.deepwater_elevation','mattype',1); 116 WriteData(fid,prefix,'object',self,'fieldname','upperwater_melting_rate','format','DoubleMat','name','md.basalforcings.upperwater_melting_rate','scale',1./yts,'mattype',1); 107 117 WriteData(fid,prefix,'object',self,'fieldname','upperwater_elevation','format','DoubleMat','name','md.basalforcings.upperwater_elevation','mattype',1); 118 WriteData(fid,prefix,'object',self,'fieldname','perturbation_melting_rate','format','DoubleMat','name','md.basalforcings.perturbation_melting_rate','scale',1./yts,'mattype',1); 108 119 end % }}} 109 120 end -
issm/trunk/src/m/classes/spatiallinearbasalforcings.py
r25836 r27035 21 21 self.deepwater_melting_rate = np.nan 22 22 self.deepwater_elevation = np.nan 23 self.upperwater_melting_rate = np.nan 23 24 self.upperwater_elevation = np.nan 24 25 self.geothermalflux = np.nan 26 self.perturbation_melting_rate = np.nan 25 27 26 28 self.setdefaultparameters() … … 30 32 nvertices = len(lb.groundedice_melting_rate) 31 33 self.groundedice_melting_rate = lb.groundedice_melting_rate 32 self. deepwater_melting_rate= lb.geothermalflux34 self.geothermalflux = lb.geothermalflux 33 35 self.deepwater_elevation = lb.deepwater_elevation * np.ones((nvertices, )) 34 self.upperwater_elevation = lb.deepwater_melting_rate * np.ones((nvertices, )) 35 self.geothermalflux = lb.upperwater_elevation * np.ones((nvertices, )) 36 self.deepwater_melting_rate = lb.deepwater_melting_rate * np.ones((nvertices, )) 37 self.upperwater_melting_rate = lb.upperwater_melting_rate * np.ones((nvertices, )) 38 self.upperwater_elevation = lb.upperwater_elevation * np.ones((nvertices, )) 39 self.perturbation_melting_rate = lb.perturbation_melting_rate * np.ones((nvertices, )) 36 40 else: 37 41 # TODO: This has not been tested … … 46 50 s += '{}\n'.format(fielddisplay(self, 'deepwater_melting_rate', 'basal melting rate (positive if melting applied for floating ice whith base < deepwater_elevation) [m/yr]')) 47 51 s += '{}\n'.format(fielddisplay(self, 'deepwater_elevation', 'elevation of ocean deepwater [m]')) 52 s += '{}\n'.format(fielddisplay(self, 'upperwater_melting_rate', 'basal melting rate (positive if melting applied for floating ice whith base >= upperwater_elevation) [m/yr]')) 48 53 s += '{}\n'.format(fielddisplay(self, 'upperwater_elevation', 'elevation of ocean upperwater [m]')) 54 s += '{}\n'.format(fielddisplay(self, 'perturbation_melting_rate', 'basal melting rate perturbation added to computed melting rate (positive if melting) [m/yr]')) 49 55 s += '{}\n'.format(fielddisplay(self, 'geothermalflux', 'geothermal heat flux [W/m^2]')) 50 56 return s … … 55 61 self.deepwater_melting_rate = project3d(md, 'vector', self.deepwater_melting_rate, 'type', 'node', 'layer', 1) 56 62 self.deepwater_elevation = project3d(md, 'vector', self.deepwater_elevation, 'type', 'node', 'layer', 1) 63 self.upperwater_melting_rate = project3d(md, 'vector', self.upperwater_melting_rate, 'type', 'node', 'layer', 1) 57 64 self.upperwater_elevation = project3d(md, 'vector', self.upperwater_elevation, 'type', 'node', 'layer', 1) 58 65 self.geothermalflux = project3d(md, 'vector', self.geothermalflux, 'type', 'node', 'layer', 1) # Bedrock only gets geothermal flux 66 self.perturbation_melting_rate = project3d(md, 'vector', self.upperwater_melting_rate, 'type', 'node', 'layer', 1) 59 67 return self 60 68 #}}} … … 72 80 73 81 def checkconsistency(self, md, solution, analyses): #{{{ 82 if not np.all(np.isnan(self.perturbation_melting_rate)): 83 md = checkfield(md, 'fieldname', 'basalforcings.perturbation_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 74 84 if 'MasstransportAnalysis' in analyses and not solution == 'TransientSolution' and not md.transient.ismasstransport: 75 85 md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 76 86 md = checkfield(md, 'fieldname', 'basalforcings.deepwater_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1, '>=', 0) 77 87 md = checkfield(md, 'fieldname', 'basalforcings.deepwater_elevation', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 88 md = checkfield(md, 'fieldname', 'basalforcings.upperwater_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1, '>=', 0) 78 89 md = checkfield(md, 'fieldname', 'basalforcings.upperwater_elevation', 'NaN', 1, 'Inf', 1, 'timeseries', 1, '<', 0) 79 90 if 'BalancethicknessAnalysis' in analyses: … … 82 93 md = checkfield(md, 'fieldname', 'basalforcings.deepwater_melting_rate', '>=', 0, 'numel', 1) 83 94 md = checkfield(md, 'fieldname', 'basalforcings.deepwater_elevation', '<', 'basalforcings.upperwater_elevation', 'numel', 1) 95 md = checkfield(md, 'fieldname', 'basalforcings.upperwater_melting_rate', '>=', 0, 'numel', 1) 84 96 md = checkfield(md, 'fieldname', 'basalforcings.upperwater_elevation', '<=', 0, 'numel', 1) 85 97 if 'ThermalAnalysis' in analyses and not solution == 'TransientSolution' and not md.transient.isthermal: … … 89 101 md = checkfield(md, 'fieldname', 'basalforcings.deepwater_elevation', '<', 'basalforcings.upperwater_elevation', 'numel', 1) 90 102 md = checkfield(md, 'fieldname', 'basalforcings.upperwater_elevation', '<', 0, 'numel', 1) 103 md = checkfield(md, 'fieldname', 'basalforcings.deepwater_melting_rate', '>=', 0, 'numel', 1) 91 104 md = checkfield(md, 'fieldname', 'basalforcings.geothermalflux', 'NaN', 1, 'Inf', 1, 'timeseries', 1, '>=', 0) 92 105 return md … … 96 109 yts = md.constants.yts 97 110 98 floatingice_melting_rate = np.zeros((md.mesh.numberofvertices, ))99 pos = np.where(md.geometry.base <= md.basalforcings.deepwater_elevation)[0]100 floatingice_melting_rate[pos] = md.basalforcings.deepwater_melting_rate[pos]101 pos = np.where(np.logical_and.reduce(md.geometry.base > md.basalforcings.deepwater_elevation, md.geometry.base < md.basalforcings.upperwater_elevation))102 floatingice_melting_rate[pos] = md.basalforcings.deepwater_melting_rate[pos] * (md.geometry.base[pos] - md.basalforcings.upperwater_elevation[pos]) / (md.basalforcings.deepwater_elevation[pos] - md.basalforcings.upperwater_elevation[pos])103 111 WriteData(fid, prefix, 'name', 'md.basalforcings.model', 'data', 6, 'format', 'Integer') 104 WriteData(fid, prefix, 'data', floatingice_melting_rate, 'format', 'DoubleMat', 'name', 'md.basalforcings.floatingice_melting_rate', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)105 112 WriteData(fid, prefix, 'object', self, 'fieldname', 'groundedice_melting_rate', 'format', 'DoubleMat', 'name', 'md.basalforcings.groundedice_melting_rate', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1,'yts', md.constants.yts) 106 113 WriteData(fid, prefix,'object', self, 'fieldname', 'geothermalflux', 'name', 'md.basalforcings.geothermalflux', 'format', 'DoubleMat', 'mattype', 1,'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts) 107 114 WriteData(fid, prefix, 'object', self, 'fieldname', 'deepwater_melting_rate', 'format', 'DoubleMat', 'name', 'md.basalforcings.deepwater_melting_rate', 'scale', 1. / yts, 'mattype', 1) 108 115 WriteData(fid, prefix, 'object', self, 'fieldname', 'deepwater_elevation', 'format', 'DoubleMat', 'name', 'md.basalforcings.deepwater_elevation', 'mattype', 1) 116 WriteData(fid, prefix, 'object', self, 'fieldname', 'upperwater_melting_rate', 'format', 'DoubleMat', 'name', 'md.basalforcings.upperwater_melting_rate', 'scale', 1. / yts, 'mattype', 1) 109 117 WriteData(fid, prefix, 'object', self, 'fieldname', 'upperwater_elevation', 'format', 'DoubleMat', 'name', 'md.basalforcings.upperwater_elevation', 'mattype', 1) 118 WriteData(fid, prefix, 'object', self, 'fieldname', 'perturbation_melting_rate', 'format', 'DoubleMat', 'name', 'md.basalforcings.perturbation_melting_rate', 'scale', 1. / yts, 'mattype', 1) 110 119 #}}} -
issm/trunk/src/m/classes/stochasticforcing.m
r26744 r27035 11 11 default_id = NaN; 12 12 covariance = NaN; 13 stochastictimestep = 0; 13 14 randomflag = 1; 14 15 end … … 35 36 36 37 num_fields = numel(self.fields); 38 if(self.stochastictimestep==0) 39 md.stochasticforcing.stochastictimestep = md.timestepping.time_step; %by default: stochastictimestep set to ISSM time step 40 end 37 41 38 42 %Check that covariance matrix is positive definite … … 48 52 for field=self.fields 49 53 %Checking agreement of classes 50 if(contains(field,'SMB '))54 if(contains(field,'SMBautoregression')) 51 55 mdname = structstoch.mdnames(find(strcmp(structstoch.fields,char(field)))); 52 56 if~(isequal(class(md.smb),char(mdname))) … … 54 58 end 55 59 end 60 if(contains(field,'SMBforcing')) 61 mdname = structstoch.mdnames(find(strcmp(structstoch.fields,char(field)))); 62 if~(isequal(class(md.smb),char(mdname))) 63 error('md.smb does not agree with stochasticforcing field %s', char(field)); 64 end 65 end 56 66 if(contains(field,'FrontalForcings')) 57 67 mdname = structstoch.mdnames(find(strcmp(structstoch.fields,char(field)))); … … 67 77 end 68 78 if(contains(field,'BasalforcingsFloatingice')) 79 mdname = structstoch.mdnames(find(strcmp(structstoch.fields,char(field)))); 80 if~(isequal(class(md.basalforcings),char(mdname))) 81 error('md.basalforcings does not agree with stochasticforcing field %s', char(field)); 82 end 83 end 84 if(contains(field,'BasalforcingsSpatialDeepwaterMeltingRate')) 85 mdname = structstoch.mdnames(find(strcmp(structstoch.fields,char(field)))); 86 if~(isequal(class(md.basalforcings),char(mdname))) 87 error('md.basalforcings does not agree with stochasticforcing field %s', char(field)); 88 end 89 end 90 if(contains(field,'BasalforcingsDeepwaterMeltingRateAutoregression')) 69 91 mdname = structstoch.mdnames(find(strcmp(structstoch.fields,char(field)))); 70 92 if~(isequal(class(md.basalforcings),char(mdname))) … … 85 107 end 86 108 %Checking for specific dimensions 87 if ~(strcmp(field,'SMBautoregression') || strcmp(field,'FrontalForcingsRignotAutoregression') )109 if ~(strcmp(field,'SMBautoregression') || strcmp(field,'FrontalForcingsRignotAutoregression') || strcmp(field,'BasalforcingsDeepwaterMeltingRateAutoregression')) 88 110 checkdefaults = true; %field with non-specific dimensionality 89 111 end 90 112 end 91 113 92 %Retrieve sum of all the field dimensionalities 93 size_tot = self.defaultdimension*num_fields; 94 indSMBar = -1; %about to check for index of SMBautoregression 95 indTFar = -1; %about to check for index of FrontalForcingsRignotAutoregression 114 %Retrieve all the field dimensionalities 115 dimensions = self.defaultdimension*ones(1,num_fields); 116 indSMBar = -1; %about to check for index of SMBautoregression 117 indTFar = -1; %about to check for index of FrontalForcingsRignotAutoregression 118 indBDWar = -1; %about to check for index of BasalforcingsDeepwaterMeltingRateAutoregression 96 119 if any(contains(self.fields,'SMBautoregression')) 97 size_tot = size_tot-self.defaultdimension+md.smb.num_basins; 98 indSMBar = find(contains(self.fields,'SMBautoregression')); %index of SMBar, now check for consistency with TFar timestep (08Nov2021) 120 indSMBar = find(contains(self.fields,'SMBautoregression')); %index of SMBar, now check for consistency with other ar timesteps 121 dimensions(indSMBar) = md.smb.num_basins; 122 if(md.smb.ar_timestep<self.stochastictimestep) 123 error('SMBautoregression cannot have a timestep shorter than stochastictimestep'); 124 end 99 125 end 100 126 if any(contains(self.fields,'FrontalForcingsRignotAutoregression')) 101 size_tot = size_tot-self.defaultdimension+md.frontalforcings.num_basins; 102 indTFar = find(contains(self.fields,'FrontalForcingsRignotAutoregression')); %index of TFar, now check for consistency with SMBar timestep (08Nov2021) 103 end 127 indTFar = find(contains(self.fields,'FrontalForcingsRignotAutoregression')); %index of TFar, now check for consistency with other ar timesteps 128 dimensions(indTFar) = md.frontalforcings.num_basins; 129 if(md.frontalforcings.ar_timestep<self.stochastictimestep) 130 error('FrontalForcingsRignotAutoregression cannot have a timestep shorter than stochastictimestep'); 131 end 132 end 133 if any(contains(self.fields,'BasalforcingsDeepwaterMeltingRateAutoregression')) 134 indBDWar = find(contains(self.fields,'BasalforcingsDeepwaterMeltingRateAutoregression')); %index of BDWar, now check for consistency with other ar timesteps 135 dimensions(indBDWar) = md.basalforcings.num_basins; 136 if(md.basalforcings.ar_timestep<self.stochastictimestep) 137 error('BasalforcingsDeepwaterMeltingRateAutoregression cannot have a timestep shorter than stochastictimestep'); 138 end 139 end 140 size_tot = sum(dimensions); 104 141 105 142 if(indSMBar~=-1 && indTFar~=-1) %both autoregressive models are used: check autoregressive time step consistency 106 if((md.smb.ar_timestep~=md.frontalforcings.ar_timestep) && any(self.covariance(1+sum(self.dimensions(1:indSMBar-1)):sum(self.dimensions(1:indSMBar)),1+sum(self.dimensions(1:indTFar-1)):sum(self.dimensions(1:indTFar))))~=0) 107 error('SMBautoregression and FrontalForcingsRignotAutoregression have different ar_timestep and non-zero covariance'); 108 end 109 end 110 143 if(md.smb.ar_timestep~=md.frontalforcings.ar_timestep) 144 crossentries = reshape(self.covariance(1+sum(dimensions(1:indSMBar-1)):sum(dimensions(1:indSMBar)),1+sum(dimensions(1:indTFar-1)):sum(dimensions(1:indTFar))),1,[]); 145 if any(crossentries~=0) 146 error('SMBautoregression and FrontalForcingsRignotAutoregression have different ar_timestep and non-zero covariance'); 147 end 148 end 149 end 150 if(indSMBar~=-1 && indBDWar~=-1) %both autoregressive models are used: check autoregressive time step consistency 151 if(md.smb.ar_timestep~=md.basalforcings.ar_timestep) 152 crossentries = reshape(self.covariance(1+sum(dimensions(1:indSMBar-1)):sum(dimensions(1:indSMBar)),1+sum(dimensions(1:indBDWar-1)):sum(dimensions(1:indBDWar))),1,[]); 153 if any(crossentries~=0) 154 error('SMBautoregression and BasalforcingsDeepwaterMeltingRateAutoregression have different ar_timestep and non-zero covariance'); 155 end 156 end 157 end 158 if(indTFar~=-1 && indBDWar~=-1) %both autoregressive models are used: check autoregressive time step consistency 159 if(md.frontalforcings.ar_timestep~=md.basalforcings.ar_timestep) 160 crossentries = reshape(self.covariance(1+sum(dimensions(1:indTFar-1)):sum(dimensions(1:indTFar)),1+sum(dimensions(1:indBDWar-1)):sum(dimensions(1:indBDWar))),1,[]); 161 if any(crossentries~=0) 162 error('FrontalForcingsRignotAutoregression and BasalforcingsDeepwaterMeltingRateAutoregression have different ar_timestep and non-zero covariance'); 163 end 164 end 165 end 111 166 md = checkfield(md,'fieldname','stochasticforcing.isstochasticforcing','values',[0 1]); 112 167 md = checkfield(md,'fieldname','stochasticforcing.fields','numel',num_fields,'cell',1,'values',supportedstochforcings()); 113 168 md = checkfield(md,'fieldname','stochasticforcing.covariance','NaN',1,'Inf',1,'size',[size_tot,size_tot]); %global covariance matrix 169 md = checkfield(md,'fieldname','stochasticforcing.stochastictimestep','NaN',1,'Inf',1,'>=',md.timestepping.time_step); 114 170 md = checkfield(md,'fieldname','stochasticforcing.randomflag','numel',[1],'values',[0 1]); 115 171 if(checkdefaults) %need to check the defaults … … 121 177 disp(sprintf(' stochasticforcing parameters:')); 122 178 fielddisplay(self,'isstochasticforcing','is stochasticity activated?'); 123 fielddisplay(self,'fields','fields with stochasticity applied, ex: {''SMBautoregression''}, or {''FrontalForcingsRignotAutoregression''}');179 fielddisplay(self,'fields','fields with stochasticity applied, ex: [{''SMBautoregression''}], or [{''SMBforcing''},{''DefaultCalving''}]'); 124 180 fielddisplay(self,'defaultdimension','dimensionality of the noise terms (does not apply to fields with their specific dimension)'); 125 181 fielddisplay(self,'default_id','id of each element for partitioning of the noise terms (does not apply to fields with their specific partition)'); 126 182 fielddisplay(self,'covariance','covariance matrix for within- and between-fields covariance (units must be squared field units)'); 183 fielddisplay(self,'stochastictimestep','timestep at which new stochastic noise terms are generated (default: md.timestepping.time_step)'); 127 184 fielddisplay(self,'randomflag','whether to apply real randomness (true) or pseudo-randomness with fixed seed (false)'); 128 185 disp('Available fields:'); … … 140 197 return 141 198 else 199 200 if(self.stochastictimestep==0) 201 disp(' stochasticforcing.stocahstictimestep not specified: set to md.timestepping.time_step'); 202 self.stochastictimestep = md.timestepping.time_step; %by default: stochastictimestep set to ISSM time step 203 end 142 204 143 205 %Retrieve dimensionality of each field … … 152 214 dimensions(ind) = md.frontalforcings.num_basins; 153 215 end 216 if(strcmp(field,'BasalforcingsDeepwaterMeltingRateAutoregression')) 217 dimensions(ind) = md.basalforcings.num_basins; 218 end 154 219 ind = ind+1; 155 220 end 156 221 157 222 %Scaling covariance matrix (scale column-by-column and row-by-row) 158 scaledfields = {' DefaultCalving','FloatingMeltRate','SMBautoregression'}; %list of fields that need scaling *1/yts223 scaledfields = {'BasalforcingsDeepwaterMeltingRateAutoregression','BasalforcingsSpatialDeepwaterMeltingRate','DefaultCalving','FloatingMeltRate','SMBautoregression','SMBforcing'}; %list of fields that need scaling *1/yts 159 224 tempcovariance = self.covariance; %copy of covariance to avoid writing back in member variable 160 225 for i=1:num_fields … … 173 238 self.default_id = zeros(md.mesh.numberofelements,1); 174 239 end 240 175 241 WriteData(fid,prefix,'data',num_fields,'name','md.stochasticforcing.num_fields','format','Integer'); 176 242 WriteData(fid,prefix,'object',self,'fieldname','fields','format','StringArray'); … … 179 245 WriteData(fid,prefix,'object',self,'fieldname','defaultdimension','format','Integer'); 180 246 WriteData(fid,prefix,'data',tempcovariance,'name','md.stochasticforcing.covariance','format','DoubleMat'); 247 WriteData(fid,prefix,'object',self,'fieldname','stochastictimestep','format','Double','scale',yts); 181 248 WriteData(fid,prefix,'object',self,'fieldname','randomflag','format','Boolean'); 182 249 end … … 195 262 % supported and corresponding md names 196 263 structure.fields = {... 264 'BasalforcingsDeepwaterMeltingRateAutoregression',... 265 'BasalforcingsSpatialDeepwaterMeltingRate',... 197 266 'DefaultCalving',... 198 267 'FloatingMeltRate',... 199 268 'FrictionWaterPressure',... 200 269 'FrontalForcingsRignotAutoregression',... 201 'SMBautoregression' 270 'SMBautoregression',... 271 'SMBforcing' 202 272 }; 203 273 structure.mdnames = {... 274 'autoregressionlinearbasalforcings',... 275 'spatiallinearbasalforcings',... 204 276 'calving',... 205 277 'basalforcings',... 206 278 'friction',... 207 279 'frontalforcingsrignotautoregression',... 208 'SMBautoregression' 280 'SMBautoregression',... 281 'SMBforcing' 209 282 }; 210 283 end % }}} -
issm/trunk/src/m/classes/stochasticforcing.py
r26744 r27035 18 18 self.default_id = np.nan 19 19 self.covariance = np.nan 20 self.stochastictimestep = 0 20 21 self.randomflag = 1 21 22 … … 28 29 s = ' stochasticforcing parameters:\n' 29 30 s += '{}\n'.format(fielddisplay(self, 'isstochasticforcing', 'is stochasticity activated?')) 30 s += '{}\n'.format(fielddisplay(self, 'fields', 'fields with stochasticity applied, ex: [\'SMBautoregression\'], or [\' FrontalForcingsRignotAutoregression\']'))31 s += '{}\n'.format(fielddisplay(self, 'fields', 'fields with stochasticity applied, ex: [\'SMBautoregression\'], or [\'SMBforcing\',\'DefaultCalving\']')) 31 32 s += '{}\n'.format(fielddisplay(self, 'defaultdimension', 'dimensionality of the noise terms (does not apply to fields with their specific dimension)')) 32 33 s += '{}\n'.format(fielddisplay(self, 'default_id', 'id of each element for partitioning of the noise terms (does not apply to fields with their specific partition)')) 33 34 s += '{}\n'.format(fielddisplay(self, 'covariance', 'covariance matrix for within- and between-fields covariance (units must be squared field units)')) 35 s += '{}\n'.format(fielddisplay(self, 'stochastictimestep', 'timestep at which new stochastic noise terms are generated (default: md.timestepping.time_step)')) 34 36 s += '{}\n'.format(fielddisplay(self, 'randomflag', 'whether to apply real randomness (true) or pseudo-randomness with fixed seed (false)')) 35 37 s += 'Available fields:\n' 38 s += ' BasalforcingsSpatialDeepwaterMeltingRate\n' 36 39 s += ' DefaultCalving\n' 37 40 s += ' FloatingMeltRate\n' 41 s += ' FrictionWaterPressure\n' 42 s += ' FrontalForcingsRignotAutoregression (thermal forcing)\n' 38 43 s += ' SMBautoregression\n' 39 s += ' FrontalForcingsRignotAutoregression (thermal forcing)\n'44 s += ' SMBforcing\n' 40 45 return s 41 46 #}}} … … 43 48 def setdefaultparameters(self): # {{{ 44 49 # Type of stabilization used 45 self.isstochasticforcing = 0 # stochasticforcing is turned off by default46 self.fields = [] # Need to initialize to list to avoid "RuntimeError: object of type 'float' has no len()" on import of class47 self.randomflag = 1 # true randomness is implemented by default50 self.isstochasticforcing = 0 # stochasticforcing is turned off by default 51 self.fields = [] # Need to initialize to list to avoid "RuntimeError: object of type 'float' has no len()" on import of class 52 self.randomflag = 1 # true randomness is implemented by default 48 53 return self 49 54 #}}} … … 55 60 56 61 num_fields = len(self.fields) 62 if(self.stochastictimestep==0): 63 md.stochasticforcing.stochastictimestep = md.timestepping.time_step #by default: stochastictimestep set to ISSM time step 64 print(' stochasticforcing.stocahstictimestep not specified: set to md.timestepping.time_step') 57 65 58 66 # Check that covariance matrix is positive definite (this is done internally by linalg) … … 63 71 64 72 # Check that all fields agree with the corresponding md class and if any field needs the default params 65 checkdefaults = False # Need to check defaults only if one of the fields does not have its own dimensionality73 checkdefaults = False # Need to check defaults only if one of the fields does not have its own dimensionality 66 74 structstoch = self.structstochforcing() 67 75 for field in self.fields: 68 76 # Checking agreement of classes 69 if 'SMB' in field: 77 if 'SMBautoregression' in field: 78 mdname = structstoch[field] 79 if (type(md.smb).__name__ != mdname): 80 raise TypeError('md.smb does not agree with stochasticforcing field {}'.format(field)) 81 if 'SMBforcing' in field: 70 82 mdname = structstoch[field] 71 83 if (type(md.smb).__name__ != mdname): … … 83 95 if (type(md.basalforcings).__name__ != mdname): 84 96 raise TypeError('md.basalforcings does not agree with stochasticforcing field {}'.format(field)) 97 if 'BasalforcingsSpatialDeepwaterMeltingRate' in field: 98 mdname = structstoch[field] 99 if (type(md.basalforcings).__name__ != mdname): 100 raise TypeError('md.basalforcings does not agree with stochasticforcing field {}'.format(field)) 101 if 'BasalforcingsDeepwaterMeltingRateAutoregression' in field: 102 mdname = structstoch[field] 103 if (type(md.basalforcings).__name__ != mdname): 104 raise TypeError('md.basalforcings does not agree with stochasticforcing field {}'.format(field)) 85 105 if 'WaterPressure' in field: 86 106 mdname = structstoch[field] 87 107 if (type(md.friction).__name__ != mdname): 88 108 raise TypeError('stochasticforcing field {} is only implemented for default friction'.format(field)) 89 if (md.friction.coupling!=0 and md.friction.coupling!=1 and md.friction.coupling!=2):109 if md.friction.coupling not in[0, 1, 2]: 90 110 raise TypeError('stochasticforcing field {} is only implemented for cases md.friction.coupling 0 or 1 or 2'.format(field)) 91 if (np.any(md.friction.q ==0)):92 111 if (np.any(md.friction.q == 0)): 112 raise TypeError('stochasticforcing field {} requires non-zero q exponent'.format(field)) 93 113 94 114 # Checking for specific dimensions 95 if not (field == 'SMBautoregression' or field == 'FrontalForcingsRignotAutoregression'):96 checkdefaults = True # field with non-specific dimensionality115 if field not in['SMBautoregression', 'FrontalForcingsRignotAutoregression','BasalforcingsDeepwaterMeltingRateAutoregression']: 116 checkdefaults = True # field with non-specific dimensionality 97 117 98 118 # Retrieve sum of all the field dimensionalities 99 size_tot = self.defaultdimension * num_fields 100 indSMBar = -1 # About to check for index of SMBautoregression 101 indTFar = -1 # About to check for index of FrontalForcingsRignotAutoregression 119 dimensions = self.defaultdimension*np.ones((num_fields)) 120 indSMBar = -1 # About to check for index of SMBautoregression 121 indTFar = -1 # About to check for index of FrontalForcingsRignotAutoregression 122 indBDWar = -1 # About to check for index of BasalforcingsDeepwaterMeltingRateAutoregression 102 123 if ('SMBautoregression' in self.fields): 103 size_tot = size_tot - self.defaultdimension + md.smb.num_basins 104 indSMBar = self.fields.index('SMBautoregression') # Index of SMBar, now check for consistency with TFar timestep (08Nov2021) 124 indSMBar = self.fields.index('SMBautoregression') # Index of SMBar, now check for consistency with other timesteps 125 dimensions[indSMBar] = md.smb.num_basins 126 if(md.smb.ar_timestep<self.stochastictimestep): 127 raise TypeError('SMBautoregression cannot have a timestep shorter than stochastictimestep') 105 128 if ('FrontalForcingsRignotAutoregression' in self.fields): 106 size_tot = size_tot - self.defaultdimension + md.frontalforcings.num_basins 107 indTFar = self.fields.index('FrontalForcingsRignotAutoregression') # Index of TFar, now check for consistency with SMBar timestep (08Nov2021) 108 if (indSMBar != -1 and indTFar != -1): # Both autoregressive models are used: check autoregressive time step consistency 109 covsum = self.covariance[np.sum(self.defaultdimensions[0:indSMBar]).astype(int):np.sum(self.defaultdimensions[0:indSMBar + 1]).astype(int), np.sum(self.defaultdimensions[0:indTFar]).astype(int):np.sum(self.defaultdimensions[0:indTFar + 1]).astype(int)] 129 indTFar = self.fields.index('FrontalForcingsRignotAutoregression') # Index of TFar, now check for consistency with other timesteps 130 dimensions[indTFar] = md.frontalforcings.num_basins 131 if(md.frontalforcings.ar_timestep<self.stochastictimestep): 132 raise TypeError('FrontalForcingsRignotAutoregression cannot have a timestep shorter than stochastictimestep') 133 if ('BasalforcingsDeepwaterMeltingRateAutoregression' in self.fields): 134 indBDWar = self.fields.index('BasalforcingsDeepwaterMeltingRateAutoregression') # Index of BDWar, now check for consistency with other timesteps 135 dimensions[indTFar] = md.basalforcings.num_basins 136 if(md.basalforcings.ar_timestep<self.stochastictimestep): 137 raise TypeError('BasalforcingsDeepwaterMeltingRateAutoregression cannot have a timestep shorter than stochastictimestep') 138 size_tot = np.sum(dimensions) 139 140 if (indSMBar != -1 and indTFar != -1): # Both autoregressive models are used: check autoregressive time step consistency 141 covsum = self.covariance[np.sum(dimensions[0:indSMBar]).astype(int):np.sum(dimensions[0:indSMBar + 1]).astype(int), np.sum(dimensions[0:indTFar]).astype(int):np.sum(dimensions[0:indTFar + 1]).astype(int)] 110 142 if((md.smb.ar_timestep != md.frontalforcings.ar_timestep) and np.any(covsum != 0)): 111 143 raise IOError('SMBautoregression and FrontalForcingsRignotAutoregression have different ar_timestep and non-zero covariance') 144 if (indSMBar != -1 and indBDWar != -1): # Both autoregressive models are used: check autoregressive time step consistency 145 covsum = self.covariance[np.sum(dimensions[0:indSMBar]).astype(int):np.sum(dimensions[0:indSMBar + 1]).astype(int), np.sum(dimensions[0:indBDWar]).astype(int):np.sum(dimensions[0:indBDWar + 1]).astype(int)] 146 if((md.smb.ar_timestep != md.basalforcings.ar_timestep) and np.any(covsum != 0)): 147 raise IOError('SMBautoregression and BasalforcingsDeepwaterMeltingRateAutoregression have different ar_timestep and non-zero covariance') 148 if (indTFar != -1 and indBDWar != -1): # Both autoregressive models are used: check autoregressive time step consistency 149 covsum = self.covariance[np.sum(dimensions[0:indTFar]).astype(int):np.sum(dimensions[0:indTFar + 1]).astype(int), np.sum(dimensions[0:indBDWar]).astype(int):np.sum(dimensions[0:indBDWar + 1]).astype(int)] 150 if((md.frontalforcings.ar_timestep != md.basalforcings.ar_timestep) and np.any(covsum != 0)): 151 raise IOError('FrontalForcingsRignotAutoregression and BasalforcingsDeepwaterMeltingRateAutoregression have different ar_timestep and non-zero covariance') 112 152 113 153 md = checkfield(md, 'fieldname', 'stochasticforcing.isstochasticforcing', 'values', [0, 1]) 114 154 md = checkfield(md, 'fieldname', 'stochasticforcing.fields', 'numel', num_fields, 'cell', 1, 'values', self.supportedstochforcings()) 115 155 md = checkfield(md, 'fieldname', 'stochasticforcing.covariance', 'NaN', 1, 'Inf', 1, 'size', [size_tot, size_tot]) # global covariance matrix 156 md = checkfield(md, 'fieldname', 'stochasticforcing.stochastictimestep', 'NaN', 1,'Inf', 1, '>=', md.timestepping.time_step) 116 157 md = checkfield(md, 'fieldname', 'stochasticforcing.randomflag', 'numel', [1], 'values', [0, 1]) 117 158 if (checkdefaults): 118 159 md = checkfield(md, 'fieldname', 'stochasticforcing.defaultdimension', 'numel', 1, 'NaN', 1, 'Inf', 1, '>', 0) 119 md = checkfield(md, 'fieldname', 'stochasticforcing.default_id', 'Inf',1,'NaN',1,'>=',0,'<=',self.defaultdimension,'size', [md.mesh.numberofelements])160 md = checkfield(md, 'fieldname', 'stochasticforcing.default_id', 'Inf', 1, 'NaN', 1, '>=', 0, '<=', self.defaultdimension, 'size', [md.mesh.numberofelements]) 120 161 return md 121 162 # }}} … … 128 169 def marshall(self, prefix, md, fid): # {{{ 129 170 yts = md.constants.yts 130 num_fields = len(self.fields)131 171 132 172 WriteData(fid, prefix, 'object', self, 'fieldname', 'isstochasticforcing', 'format', 'Boolean') 133 173 if not self.isstochasticforcing: 134 174 return md 175 135 176 else: 177 num_fields = len(self.fields) 178 if(self.stochastictimestep==0): 179 md.stochasticforcing.stochastictimestep = md.timestepping.time_step #by default: stochastictimestep set to ISSM time step 136 180 # Retrieve dimensionality of each field 137 dimensions = self.defaultdimension * np.ones((num_fields ,))181 dimensions = self.defaultdimension * np.ones((num_fields)) 138 182 for ind, field in enumerate(self.fields): 139 183 # Checking for specific dimensions … … 142 186 if (field == 'FrontalForcingsRignotAutoregression'): 143 187 dimensions[ind] = md.frontalforcings.num_basins 188 if (field == 'BasalforcingsDeepwaterMeltingRateAutoregression'): 189 dimensions[ind] = md.basalforcings.num_basins 144 190 145 191 # Scaling covariance matrix (scale column-by-column and row-by-row) 146 scaledfields = [' DefaultCalving','FloatingMeltRate','SMBautoregression']# list of fields that need scaling * 1/yts192 scaledfields = ['BasalforcingsDeepwaterMeltingRateAutoregression','BasalforcingsSpatialDeepwaterMeltingRate','DefaultCalving', 'FloatingMeltRate', 'SMBautoregression', 'SMBforcing'] # list of fields that need scaling * 1/yts 147 193 tempcovariance = np.copy(self.covariance) 148 194 for i in range(num_fields): … … 157 203 self.default_id = np.zeros(md.mesh.numberofelements) 158 204 # Reshape dimensions as column array for marshalling 159 dimensions = dimensions.reshape(1, len(dimensions))205 dimensions = dimensions.reshape(1, len(dimensions)) 160 206 161 207 WriteData(fid, prefix, 'data', num_fields, 'name', 'md.stochasticforcing.num_fields', 'format', 'Integer') 162 208 WriteData(fid, prefix, 'object', self, 'fieldname', 'fields', 'format', 'StringArray') 163 WriteData(fid, prefix, 'data', dimensions, 'name', 'md.stochasticforcing.dimensions', 'format', 'IntMat', 'mattype',2)164 WriteData(fid, prefix, 'object', self, 'fieldname', 'default_id', ' format', 'IntMat', 'mattype', 2) #12Nov2021 make sure this is zero-indexed!209 WriteData(fid, prefix, 'data', dimensions, 'name', 'md.stochasticforcing.dimensions', 'format', 'IntMat', 'mattype', 2) 210 WriteData(fid, prefix, 'object', self, 'fieldname', 'default_id', 'data', self.default_id - 1, 'format', 'IntMat', 'mattype', 2) #12Nov2021 make sure this is zero-indexed! 165 211 WriteData(fid, prefix, 'object', self, 'fieldname', 'defaultdimension', 'format', 'Integer') 166 212 WriteData(fid, prefix, 'data', tempcovariance, 'name', 'md.stochasticforcing.covariance', 'format', 'DoubleMat') 213 WriteData(fid, prefix, 'object', self, 'fieldname', 'stochastictimestep', 'format', 'Double', 'scale', yts) 167 214 WriteData(fid, prefix, 'object', self, 'fieldname', 'randomflag', 'format', 'Boolean') 168 215 # }}} … … 180 227 supported and corresponding md names 181 228 """ 182 structure = {'DefaultCalving': 'calving', 229 structure = {'BasalforcingsDeepwaterMeltingRateAutoregression': 'autoregressionlinearbasalforcings', 230 'BasalforcingsSpatialDeepwaterMeltingRate': 'spatiallinearbasalforcings', 231 'DefaultCalving': 'calving', 183 232 'FloatingMeltRate': 'basalforcings', 184 233 'FrictionWaterPressure': 'friction', 185 234 'FrontalForcingsRignotAutoregression': 'frontalforcingsrignotautoregression', 186 'SMBautoregression': 'SMBautoregression'} 235 'SMBautoregression': 'SMBautoregression', 236 'SMBforcing': 'SMBforcing'} 187 237 return structure 188 238 # }}} -
issm/trunk/src/m/classes/stressbalance.m
r26744 r27035 36 36 self.loadingforce=project3d(md,'vector',self.loadingforce,'type','node'); 37 37 38 % for M LHO39 if md.flowequation.isM LHO38 % for MOLHO 39 if md.flowequation.isMOLHO 40 40 self.spcvx_base=project3d(md,'vector',self.spcvx_base,'type','node'); 41 41 self.spcvy_base=project3d(md,'vector',self.spcvy_base,'type','node'); … … 134 134 md = checkfield(md,'fieldname','stressbalance.FSreconditioning','>',0); 135 135 end 136 % CHECK THIS ONLY WORKS FOR M LHO137 if md.flowequation.isM LHO136 % CHECK THIS ONLY WORKS FOR MOLHO 137 if md.flowequation.isMOLHO 138 138 md = checkfield(md,'fieldname','stressbalance.spcvx_base','Inf',1,'timeseries',1); 139 139 md = checkfield(md,'fieldname','stressbalance.spcvy_base','Inf',1,'timeseries',1); … … 169 169 fielddisplay(self,'spcvz','z-axis velocity constraint (NaN means no constraint) [m/yr]'); 170 170 171 disp(sprintf('\n %s','M LHO boundary conditions:'));171 disp(sprintf('\n %s','MOLHO boundary conditions:')); 172 172 fielddisplay(self,'spcvx_base','x-axis basal velocity constraint (NaN means no constraint) [m/yr]'); 173 173 fielddisplay(self,'spcvy_base','y-axis basal velocity constraint (NaN means no constraint) [m/yr]'); … … 226 226 end 227 227 WriteData(fid,prefix,'data',outputs,'name','md.stressbalance.requested_outputs','format','StringArray'); 228 % for M LHO229 if (md.flowequation.isM LHO)228 % for MOLHO 229 if (md.flowequation.isMOLHO) 230 230 WriteData(fid,prefix,'object',self,'class','stressbalance','fieldname','spcvx_base','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 231 231 WriteData(fid,prefix,'object',self,'class','stressbalance','fieldname','spcvy_base','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); -
issm/trunk/src/m/classes/stressbalance.py
r26744 r27035 59 59 s += '{}\n'.format(fielddisplay(self, 'spcvz', 'z-axis velocity constraint (NaN means no constraint) [m / yr]')) 60 60 s += '{}\n'.format(fielddisplay(self, 'icefront', 'segments on ice front list (last column 0: Air, 1: Water, 2: Ice')) 61 s += ' M LHO boundary conditions:\n'61 s += ' MOLHO boundary conditions:\n' 62 62 s += '{}\n'.format(fielddisplay(self, 'spcvx_base', 'x-axis basal velocity constraint (NaN means no constraint) [m / yr]')) 63 63 s += '{}\n'.format(fielddisplay(self, 'spcvy_base', 'y-axis basal velocity constraint (NaN means no constraint) [m / yr]')) … … 86 86 self.loadingforce = project3d(md, 'vector', self.loadingforce, 'type', 'node') 87 87 88 if md.flowequation.isM LHO:88 if md.flowequation.isMOLHO: 89 89 self.spcvx_base = project3d(md, 'vector', self.spcvx_base, 'type', 'node') 90 90 self.spcvy_base = project3d(md, 'vector', self.spcvy_base, 'type', 'node') … … 176 176 if np.any(np.logical_not(np.isnan(md.stressbalance.referential[pos, :]))): 177 177 md.checkmessage("no referential should be specified for basal vertices of grounded ice") 178 if md.flowequation.isM LHO:178 if md.flowequation.isMOLHO: 179 179 md = checkfield(md, 'fieldname', 'stressbalance.spcvx_base', 'Inf', 1, 'timeseries', 1) 180 180 md = checkfield(md, 'fieldname', 'stressbalance.spcvy_base', 'Inf', 1, 'timeseries', 1) … … 215 215 outputs = outputscopy 216 216 WriteData(fid, prefix, 'data', outputs, 'name', 'md.stressbalance.requested_outputs', 'format', 'StringArray') 217 # M LHO218 if md.flowequation.isM LHO:217 # MOLHO 218 if md.flowequation.isMOLHO: 219 219 WriteData(fid, prefix, 'object', self, 'class', 'stressbalance', 'fieldname', 'spcvx_base', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 220 220 WriteData(fid, prefix, 'object', self, 'class', 'stressbalance', 'fieldname', 'spcvy_base', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) -
issm/trunk/src/m/classes/taoinversion.py
r25836 r27035 1 1 import numpy as np 2 3 2 from checkfield import checkfield 4 3 from IssmConfig import IssmConfig 5 4 from marshallcostfunctions import marshallcostfunctions 5 from fielddisplay import fielddisplay 6 6 from project3d import project3d 7 7 from supportedcontrols import * … … 45 45 def __repr__(self): 46 46 s = ' taoinversion parameters:\n' 47 s += '{} '.format(fieldstring(self, 'iscontrol', 'is inversion activated?'))48 s += '{}'.format(fieldstring(self, 'mantle_viscosity', 'mantle viscosity constraints (NaN means no constraint) (Pa s)'))49 s += '{}'.format(fieldstring(self, 'lithosphere_thickness', 'lithosphere thickness constraints (NaN means no constraint) (m)'))50 s += '{}'.format(fieldstring(self, 'cross_section_shape', "1: square-edged, 2: elliptical - edged surface"))51 s += '{} '.format(fieldstring(self, 'incomplete_adjoint', '1: linear viscosity, 0: non - linear viscosity'))52 s += '{} '.format(fieldstring(self, 'control_parameters', 'ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}'))53 s += '{} '.format(fieldstring(self, 'maxsteps', 'maximum number of iterations (gradient computation)'))54 s += '{} '.format(fieldstring(self, 'maxiter', 'maximum number of Function evaluation (forward run)'))55 s += '{} '.format(fieldstring(self, 'fatol', 'convergence criterion: f(X) - f(X * ) (X: current iteration, X * : "true" solution, f: cost function)'))56 s += '{} '.format(fieldstring(self, 'frtol', 'convergence criterion: |f(X) - f(X * )| / |f(X * )|'))57 s += '{} '.format(fieldstring(self, 'gatol', 'convergence criterion: ||g(X)|| (g: gradient of the cost function)'))58 s += '{} '.format(fieldstring(self, 'grtol', 'convergence criterion: ||g(X)|| / |f(X)|'))59 s += '{} '.format(fieldstring(self, 'gttol', 'convergence criterion: ||g(X)|| / ||g(X0)|| (g(X0): gradient at initial guess X0)'))60 s += '{} '.format(fieldstring(self, 'algorithm', 'minimization algorithm: ''tao_blmvm'', ''tao_cg'', ''tao_lmvm'''))61 s += '{} '.format(fieldstring(self, 'cost_functions', 'indicate the type of response for each optimization step'))62 s += '{} '.format(fieldstring(self, 'cost_functions_coefficients', 'cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter'))63 s += '{} '.format(fieldstring(self, 'min_parameters', 'absolute minimum acceptable value of the inversed parameter on each vertex'))64 s += '{} '.format(fieldstring(self, 'max_parameters', 'absolute maximum acceptable value of the inversed parameter on each vertex'))65 s += '{} '.format(fieldstring(self, 'vx_obs', 'observed velocity x component [m / yr]'))66 s += '{} '.format(fieldstring(self, 'vy_obs', 'observed velocity y component [m / yr]'))67 s += '{} '.format(fieldstring(self, 'vel_obs', 'observed velocity magnitude [m / yr]'))68 s += '{} '.format(fieldstring(self, 'thickness_obs', 'observed thickness [m]'))69 s += '{} '.format(fieldstring(self, 'surface_obs', 'observed surface elevation [m]'))70 s += '{} '.format('Available cost functions:')71 s += '{} '.format(' 101: SurfaceAbsVelMisfit')72 s += '{} '.format(' 102: SurfaceRelVelMisfit')73 s += '{} '.format(' 103: SurfaceLogVelMisfit')74 s += '{} '.format(' 104: SurfaceLogVxVyMisfit')75 s += '{} '.format(' 105: SurfaceAverageVelMisfit')76 s += '{} '.format(' 201: ThicknessAbsMisfit')77 s += '{} '.format(' 501: DragCoefficientAbsGradient')78 s += '{} '.format(' 502: RheologyBbarAbsGradient')79 s += '{} '.format(' 503: ThicknessAbsGradient')47 s += '{}\n'.format(fielddisplay(self, 'iscontrol', 'is inversion activated?')) 48 # s += '{}\n'.format(fielddisplay(self, 'mantle_viscosity', 'mantle viscosity constraints (NaN means no constraint) (Pa s)')) 49 # s += '{}\n'.format(fielddisplay(self, 'lithosphere_thickness', 'lithosphere thickness constraints (NaN means no constraint) (m)')) 50 # s += '{}\n'.format(fielddisplay(self, 'cross_section_shape', "1: square-edged, 2: elliptical - edged surface")) 51 s += '{}\n'.format(fielddisplay(self, 'incomplete_adjoint', '1: linear viscosity, 0: non - linear viscosity')) 52 s += '{}\n'.format(fielddisplay(self, 'control_parameters', 'ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}')) 53 s += '{}\n'.format(fielddisplay(self, 'maxsteps', 'maximum number of iterations (gradient computation)')) 54 s += '{}\n'.format(fielddisplay(self, 'maxiter', 'maximum number of Function evaluation (forward run)')) 55 s += '{}\n'.format(fielddisplay(self, 'fatol', 'convergence criterion: f(X) - f(X * ) (X: current iteration, X * : "true" solution, f: cost function)')) 56 s += '{}\n'.format(fielddisplay(self, 'frtol', 'convergence criterion: |f(X) - f(X * )| / |f(X * )|')) 57 s += '{}\n'.format(fielddisplay(self, 'gatol', 'convergence criterion: ||g(X)|| (g: gradient of the cost function)')) 58 s += '{}\n'.format(fielddisplay(self, 'grtol', 'convergence criterion: ||g(X)|| / |f(X)|')) 59 s += '{}\n'.format(fielddisplay(self, 'gttol', 'convergence criterion: ||g(X)|| / ||g(X0)|| (g(X0): gradient at initial guess X0)')) 60 s += '{}\n'.format(fielddisplay(self, 'algorithm', 'minimization algorithm: ''tao_blmvm'', ''tao_cg'', ''tao_lmvm''')) 61 s += '{}\n'.format(fielddisplay(self, 'cost_functions', 'indicate the type of response for each optimization step')) 62 s += '{}\n'.format(fielddisplay(self, 'cost_functions_coefficients', 'cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter')) 63 s += '{}\n'.format(fielddisplay(self, 'min_parameters', 'absolute minimum acceptable value of the inversed parameter on each vertex')) 64 s += '{}\n'.format(fielddisplay(self, 'max_parameters', 'absolute maximum acceptable value of the inversed parameter on each vertex')) 65 s += '{}\n'.format(fielddisplay(self, 'vx_obs', 'observed velocity x component [m / yr]')) 66 s += '{}\n'.format(fielddisplay(self, 'vy_obs', 'observed velocity y component [m / yr]')) 67 s += '{}\n'.format(fielddisplay(self, 'vel_obs', 'observed velocity magnitude [m / yr]')) 68 s += '{}\n'.format(fielddisplay(self, 'thickness_obs', 'observed thickness [m]')) 69 s += '{}\n'.format(fielddisplay(self, 'surface_obs', 'observed surface elevation [m]')) 70 s += '{}\n'.format('Available cost functions:') 71 s += '{}\n'.format(' 101: SurfaceAbsVelMisfit') 72 s += '{}\n'.format(' 102: SurfaceRelVelMisfit') 73 s += '{}\n'.format(' 103: SurfaceLogVelMisfit') 74 s += '{}\n'.format(' 104: SurfaceLogVxVyMisfit') 75 s += '{}\n'.format(' 105: SurfaceAverageVelMisfit') 76 s += '{}\n'.format(' 201: ThicknessAbsMisfit') 77 s += '{}\n'.format(' 501: DragCoefficientAbsGradient') 78 s += '{}\n'.format(' 502: RheologyBbarAbsGradient') 79 s += '{}\n'.format(' 503: ThicknessAbsGradient') 80 80 return s 81 81 -
issm/trunk/src/m/consistency/checkfield.py
r26744 r27035 114 114 else: 115 115 if len(np.shape(field)) < len(fieldsize): 116 md = md.checkmessage(options.getfieldvalue('message', "field {} has size {} but should be size {}".format(fieldname, np.shape(field), fieldsize))) 116 if fieldsize[-1] > 1: 117 md = md.checkmessage(options.getfieldvalue('message', "field {} has size {} but should be size {}".format(fieldname, np.shape(field), fieldsize))) 118 else: 119 #The last dimension is one that follows matlab 2D array regulation but usually not what we do in python, we allow the difference in shape only if the number of element is equal 120 if np.prod(np.shape(field)) != np.prod(fieldsize): 121 md = md.checkmessage(options.getfieldvalue('message', "field {} has size {} but should be size {}".format(fieldname, np.shape(field), fieldsize))) 117 122 else: 118 123 for i in range(np.size(fieldsize)): … … 153 158 md = md.checkmessage(options.getfieldvalue('message', "field '{}' value should be '{}'".format(fieldname, fieldvalues[0]))) 154 159 elif len(fieldvalues) == 2: 155 md = md.checkmessage(options.getfieldvalue('message', "field '{}' values should be '{}' '{}'or '{}'".format(fieldname, fieldvalues[0], fieldvalues[1])))160 md = md.checkmessage(options.getfieldvalue('message', "field '{}' values should be '{}' or '{}'".format(fieldname, fieldvalues[0], fieldvalues[1]))) 156 161 else: 157 162 md = md.checkmessage(options.getfieldvalue('message', "field '{}' should have values in {}".format(fieldname, fieldvalues))) -
issm/trunk/src/m/consistency/comparemodels.m
r25836 r27035 27 27 if any(size(field1)~=size(field2)), 28 28 disp([fieldname ' do not have the same size']); 29 elseif isnumeric(field1) ,29 elseif isnumeric(field1) 30 30 if numel(field1)==1 & isnan(field1) & isnan(field2), 31 31 %Do not do anything 32 elseif any(field1 ~=field2),32 elseif any(field1(:)~=field2(:)) 33 33 %Deal with NaN... 34 34 pos1=find(isnan(field1)); … … 36 36 if numel(pos1)==numel(pos2) & all(pos1==pos2), 37 37 field1(pos1)=0; field2(pos2)=0; 38 if any(field1 ~=field2),38 if any(field1(:)~=field2(:)) 39 39 disp([fieldname ' differs']); 40 40 end -
issm/trunk/src/m/contrib/chenggong/interpFromMEaSUREsGeotiff.m
r26701 r27035 1 % This function calls src/m/contrib/morlighem/modeldata/interpFromGeotiff.m for multiple times to load all avaliable 2 % tif data in /totten_1/ModelData/Greenland/VelMEaSUREs/Jakobshavn_2008_2021/ within the given time period (in decimal years) 3 % For some reason, each .tif file in this folder contains two sets of data, only the first dataset is useful 1 function dataout = interpFromMEaSUREsGeotiff(X,Y,Tstart,Tend,varargin) 2 %interpFromMEaSUREsGeotiff: 3 % This function calls src/m/contrib/morlighem/modeldata/interpFromGeotiff.m for multiple times to load all avaliable 4 % tif data in /totten_1/ModelData/Greenland/VelMEaSUREs/Jakobshavn_2008_2021/ within the given time period (in decimal years) 5 % For some reason, each .tif file in this folder contains two sets of data, only the first dataset is useful 6 % 7 % Usage: 8 % dataout = interpFromMEaSUREsGeotiff(X,Y,Tstart,Tend, varargin) 9 % 10 % X, Y are the coordinates of the mesh 11 % Tstart and Tend decimal year of the start and end time 12 % 13 % Example: 14 % obsData = interpFromMEaSUREsGeotiff(md.mesh.x,md.mesh.y, tstart, tend); 15 % 16 % Options: 17 % - 'glacier': which glacier to look for 18 options = pairoptions(varargin{:}); 19 glacier = getfieldvalue(options,'glacier','Jakobshavn'); 4 20 5 function dataout = interpFromMEaSUREsGeotiff(X,Y,Tstart,Tend) 6 7 foldername = '/totten_1/ModelData/Greenland/VelMEaSUREs/Jakobshavn_2008_2021/'; 21 if strcmp(glacier, 'Jakobshavn') 22 foldername = '/totten_1/ModelData/Greenland/VelMEaSUREs/Jakobshavn_2008_2021/'; 23 elseif strcmp(glacier, 'Kangerlussuaq') 24 foldername = '/totten_1/ModelData/Greenland/VelMEaSUREs/Kangerlussuaq_2006_2021/'; 25 elseif strcmp(glacier, 'Store') 26 foldername = '/totten_1/ModelData/Greenland/VelMEaSUREs/Store_2008_2021/'; 27 elseif strcmp(glacier, 'Rink') 28 foldername = '/totten_1/ModelData/Greenland/VelMEaSUREs/Rink_2008_2022/'; 29 else 30 error(['The velocity data for ', glacier, ' is not available, please download from NSIDC first.']); 31 end 8 32 9 33 % get the time info from file names -
issm/trunk/src/m/contrib/defleurian/netCDF/export_netCDF.m
r25836 r27035 1 1 function export_netCDF(md,filename) 2 3 %Now going on Real treatment 2 %verbosity of the code, 0 is no messages, 5 is chatty 3 verbose = 5; 4 4 if exist(filename), 5 disp(sprintf('File %s allready exist', filename)); 6 prompt = 'Give a new name or "delete" to replace: '; 7 newname = input(prompt,'s'); 8 if strcmp(newname,'delete') 9 delete(filename) 10 else 11 disp(sprintf('New file name is %s ', newname)); 12 filename=newname 13 end 14 end 5 delete(filename) 6 % disp(sprintf('File %s allready exist', filename)); 7 % prompt = 'Give a new name or "delete" to replace: '; 8 % newname = input(prompt,'s'); 9 % if strcmp(newname,'delete') 10 % delete(filename) 11 % else 12 % disp(sprintf('New file name is %s ', newname)); 13 % filename=newname 14 % end 15 end 15 16 %open file and write description 16 17 mode = netcdf.getConstant('NC_NETCDF4'); 17 mode = bitor(mode,netcdf.getConstant('NC_NOCLOBBER')); %NOCLOBBER to avoid overwrite18 mode = bitor(mode,netcdf.getConstant('NC_NOCLOBBER')); %NOCLOBBER to avoid overwrite 18 19 ncid = netcdf.create(filename,mode); 19 20 netcdf.putAtt(ncid,netcdf.getConstant('NC_GLOBAL'),'description',['Results for run ' md.miscellaneous.name]); … … 21 22 22 23 %gather geometry and timestepping as dimensions 23 resfields=fieldnames(md.results); 24 Duration=size(eval(['md.results. ' resfields{1} ]),2); 24 if isempty(fieldnames(md.results)), 25 %results as no field so no time is present 26 Duration = 0; 27 else 28 resfields = fieldnames(md.results); 29 Duration = size(eval(['md.results. ' resfields{1} ]),2); 30 end 25 31 if Duration>0, 26 StepNum =Duration;32 StepNum = Duration; 27 33 else 28 34 StepNum=1; 29 end 30 31 dimlist=[2,md.mesh.numberofelements,md.mesh.numberofvertices,size(md.mesh.elements,2)]; 32 33 %define netcdf dimensions 34 DimSize(1).index=netcdf.defDim(ncid,'Time',StepNum); 35 end 36 DimSize(1).index=netcdf.defDim(ncid,'Time',StepNum); %time is the first dimension 35 37 [DimSize(1).name,DimSize(1).value]=netcdf.inqDim(ncid,DimSize(1).index); 36 38 DimValue(1)=DimSize(1).value; 37 DimSize(2).index=netcdf.defDim(ncid,'UnLim',netcdf.getConstant('NC_UNLIMITED')); 39 DimSize(2).index=netcdf.defDim(ncid,'UnLim',netcdf.getConstant('NC_UNLIMITED')); % we add an unlimited dimension if needed 38 40 [DimSize(2).name,DimSize(2).value]=netcdf.inqDim(ncid,DimSize(2).index); 39 41 DimValue(2)=DimSize(2).value; 42 % adding mesh related dimensions 43 dimlist=[2,40,md.mesh.numberofelements,md.mesh.numberofvertices,size(md.mesh.elements,2)]; 44 dimnames=["DictDummy" "StringLength" "EltNum" "VertNum" "VertPerElt"]; 45 if verbose > 0, 46 disp('===Creating dimensions ==='); 47 end 48 %define netcdf dimensions 40 49 for i=1:5 50 % do not add the dimension if it exists already 41 51 if sum(dimlist(i) == DimValue) == 0 42 DimSize(i+2).index=netcdf.defDim(ncid, ['Dimension' num2str(i+2)],dimlist(i));52 DimSize(i+2).index=netcdf.defDim(ncid,dimnames(i),dimlist(i)); 43 53 [DimSize(i+2).name,DimSize(i+2).value]=netcdf.inqDim(ncid,DimSize(i+2).index); 44 54 DimValue(i+2)=DimSize(i+2).value; 45 55 end 46 56 end 47 48 typelist=[{'numeric'} {'logical'} {'string'} {'char'} {'cell'}]; 49 57 issmclasses = fieldnames(md)'; 58 typelist={'half', 'single','double','int8','int16'... 59 ,'int32','int64','uint8','uint16','uint32'... 60 ,'uint64','logical','char','string'}; %all malab types that are 0D 61 62 for cl=1:length(issmclasses), 63 subclasses=fieldnames(md.(issmclasses{cl}))'; 64 for sc=1:length(subclasses), 65 if sum(strcmp(class(md.(issmclasses{cl}).(subclasses{sc})), typelist)) == 0, 66 issmclasses = [issmclasses class(md.(issmclasses{cl}).(subclasses{sc}))]; 67 end 68 end 69 end 50 70 %get all model classes and create respective groups 51 71 groups=fieldnames(md); 72 if verbose > 0, 73 disp('===Creating and populating groups==='); 74 end 52 75 for i=1:length(groups), 53 disp(sprintf('group name in tree %s ',groups{i})); 76 if verbose >1, 77 disp(sprintf('===Now treating %s===',groups{i})); 78 end 79 if strcmp(groups{i}, 'qmu'), 80 disp('qmu is skipped until it is more stable'); 81 continue 82 end 54 83 groupID=netcdf.defGrp(ncid,groups{i}); 55 84 %In each group gather the fields of the class 56 groupfields=fieldnames(md.(groups{i})); 57 for j=1:length(groupfields), 58 Var=md.(groups{i}).(groupfields{j}); 85 fields=fieldnames(md.(groups{i})); 86 if isempty(fields), 87 disp(sprintf("WARNING: md.%s as no fields, we skip it.",groups{i})) 88 continue 89 end 90 %looping on fields in each group 91 for j=1:length(fields), 92 Var=md.(groups{i}).(fields{j}); 93 %treatment for lists 59 94 if isa(Var,'cell') 60 Stdlist=false; 95 Stdlist=false; %first assume it is not a standard list 61 96 if length(Var) == 0 62 Stdlist=true; 97 Stdlist=true; %It is empty and so standard (for us) 63 98 else 64 99 for k=1:length(typelist) 65 100 if isa(Var{1},typelist{k}) 66 Stdlist=true; 101 Stdlist=true; %if the list is of a known type (to matlab) if not it is probably some exotic ISSM stuff 67 102 end 68 103 end 69 104 end 70 71 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),'classtype',class(md.(groups{i}))); 72 if(Stdlist) 73 disp(sprintf('=====Field name in tree %s ',groupfields{j})); 74 [DimSize,DimValue]=DefCreateVar(ncid,Var,groupID,groupfields{j},DimSize,DimValue); 75 else 76 listsize=length(Var); 77 subgroupID=netcdf.defGrp(groupID,groupfields{j}); 78 netcdf.putAtt(subgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',class(Var)); 79 for l=1:listsize 80 if isprop(Var{l},'name') 81 lname=Var{l}.name; 82 elseif isprop(Var{l},'step') 83 lname=Var{l}.step 84 else 85 lname=[class(Var{l}) int2str(l)]; 105 %print the issm class as a classtype attribute 106 klass = class(md.(groups{i})); 107 klasstring = strcat(klass, '.',klass); 108 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),'classtype',klasstring); 109 if(Stdlist) % this is a standard or empty list just proceed 110 if verbose > 4, 111 disp(sprintf("=££=creating var for %s.%s with classtype : %s",groups{i}, fields{j}, klasstring)) 112 end 113 if ~isempty(Var) && isa(Var{1}, 'char'), % we have a char array, pad it to a given length 114 Var=char(Var)'; 115 end 116 [DimSize,DimValue,varid]=CreateVar(ncid,Var,groupID,fields{j},DimSize,DimValue); 117 if ~isempty(varid), 118 FillVar(Var,groupID,varid); 119 end 120 121 else % this is a list of fields, specific treatment needed (perhaps) 122 if verbose > 4, 123 disp(sprintf("=??=we have a list of fields for %s.%s with classtype : %s",groups{i}, fields{j}, klasstring)); 124 end 125 if strcmp(groups{i}, 'outputdefinition'), 126 listsize=length(Var); 127 for k=1:listsize, 128 subgroupname=md.(groups{i}).(fields{j}){k}.definitionstring; 129 subgroupID=netcdf.defGrp(groupID,subgroupname); 130 klass=class(md.(groups{i}).(fields{j}){k}); 131 klasstring = strcat(klass, '.',klass); 132 netcdf.putAtt(subgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',klasstring); 133 subfields=fieldnames(md.(groups{i}).(fields{j}){k}); 134 for l=1:length(subfields) 135 if verbose > 4, 136 disp(sprintf("=--=creating var for %s.%s[%i].%s",groups{i}, fields{j}, k, subfields{l})); 137 end 138 Var = md.(groups{i}).(fields{j}){k}.(subfields{l}); 139 if sum(numel(Var) == size(Var)) == 0, %this is a 2D array or more (and not a vector with dimension 2 = 1) 140 Var = Var'; 141 end 142 [DimSize,DimValue,varid]=CreateVar(ncid,Var,subgroupID,subfields{l},DimSize,DimValue); 143 if ~isempty(varid), 144 FillVar(Var,subgroupID,varid); 145 end 146 end 86 147 end 87 listgroupID=netcdf.defGrp(subgroupID,lname); 88 netcdf.putAtt(listgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',class(Var{l})); 89 subfields=fieldnames(Var{l}); 90 for m=1:length(subfields) 91 if ~strcmp(subfields{m},'outlog') 92 [DimSize,DimValue]=DefCreateVar(ncid,Var{l}.(subfields{m}),listgroupID,subfields{m},DimSize,DimValue); 93 end 148 else 149 disp(sprintf("WARNING: unknown treatment for md.%s",groups{i})); 150 end 151 end 152 elseif sum(strcmp(class(Var), typelist))==1, %this is a standard matlab class with no subgrouping 153 if verbose > 4, 154 disp(sprintf("====creating var for %s.%s", groups{i}, fields{j})) 155 end 156 klass=class(md.(groups{i})); 157 klasstring = strcat(klass, '.',klass); 158 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),'classtype',klasstring); 159 if sum(numel(Var) == size(Var)) == 0, %this is a 2D array or more (and not a vector with dimension 2 = 1) 160 Var = Var'; 161 end 162 163 [DimSize,DimValue,varid]=CreateVar(ncid,Var,groupID,fields{j},DimSize,DimValue); 164 if ~isempty(varid), 165 FillVar(Var,groupID,varid); 166 end 167 168 169 elseif isa(Var,'struct') % structures need special treatment 170 if strcmp(groups{i}, 'results'), 171 klasstring='results.results'; 172 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),'classtype',klasstring); 173 Listsize= length(md.(groups{i}).(fields{j})); 174 subgroupname=fields{j}; 175 subgroupID=netcdf.defGrp(groupID,subgroupname); 176 klasstring='results.solutionstep'; 177 netcdf.putAtt(subgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',klasstring); 178 subfields=fieldnames(md.(groups{i}).(fields{j})); 179 if isempty(subfields), 180 disp(sprintf("WARNING: md.%s.%s as no subfields, we skip it.",groups{i}, fields{j})); 181 continue 182 end 183 for k=1:length(subfields), 184 if ~ismember(subfields{k}, {'errlog', 'outlog', 'SolutionType'}) 185 StackedVar=restable(); 186 for l=1:Listsize, 187 Var = md.(groups{i}).(fields{j})(l).(subfields{k}); 188 if length(Var) == 0, 189 %Some variables only have data on the first step 190 break 191 end 192 lastindex=l; 193 StackedVar=StackedVar.update(Var); 194 end 195 if verbose > 4, 196 disp(sprintf("=$$=creating var for %s.%s.%s",groups{i}, fields{j}, subfields{k})); 197 disp(sprintf("last index on the list is %i",lastindex)); 198 end 199 StackedVar=StackedVar.finalize(lastindex); 200 [DimSize,DimValue,varid]=CreateVar(ncid,StackedVar,subgroupID,subfields{k},DimSize,DimValue); 201 if ~isempty(varid), 202 FillVar(StackedVar,subgroupID,varid); 203 end 204 elseif ismember(subfields{k}, {'SolutionType'}) 205 %We just add solution type once as an attribute 206 Var = md.(groups{i}).(fields{j})(1).(subfields{k}); 207 [DimSize,DimValue,varid]=CreateVar(ncid,Var,subgroupID,subfields{k},DimSize,DimValue); 208 if ~isempty(varid), 209 FillVar(Var,subgroupID,varid); 210 end 211 94 212 end 95 213 end 96 end 97 elseif isa(Var,'struct') && ~strcmp(groupfields{j},'bamg') 98 classtype=class(md.(groups{i})); 99 if strcmp(classtype,'struct') 100 classtype=groups{i}; 101 end 102 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),'classtype',classtype); 103 if length(Var)>1 104 listsize=length(Var); 105 subgroupID=netcdf.defGrp(groupID,groupfields{j}); 106 classtype=class(Var); 107 if strcmp(classtype,'struct') 108 classtype=groups{i}; 109 end 110 netcdf.putAtt(subgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',classtype); 111 for l=1:listsize 112 if isfield(Var(l),'step') 113 lname=[int2str(Var(l).step)]; 114 else 115 lname=[class(Var(l)) int2str(l)]; 214 elseif isempty(fieldnames(md.(groups{i}).(fields{j}))) % this is an empty struct, jus treat it as normal 215 klass=class(md.(groups{i})); 216 klasstring = strcat(klass, '.',klass); 217 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),'classtype',klasstring); 218 if verbose > 4, 219 disp(sprintf("=[]=creating var for %s.%s",groups{i}, fields{j})); 220 end 221 222 [DimSize,DimValue,varid]=CreateVar(ncid,Var,groupID,fields{j},DimSize,DimValue); 223 if ~isempty(varid), 224 FillVar(Var,groupID,varid); 225 end 226 227 else 228 disp(sprintf("WARNING, md.%s.%s is not treated as it does not fall in one of the existing cases with class '%s'.",groups{i}, fields{j}, class(md.(groups{i}).(fields{j})))) 229 end 230 elseif sum(strcmp(class(Var), issmclasses)) == 1, % that is an issm class 231 if strcmp(class(Var), 'solution'), 232 if verbose > 4, 233 disp(sprintf("=$$=creating var for %s.%s",groups{i}, fields{j})) 234 disp("NEED treatment") 235 end 236 elseif strcmp(class(Var), 'dict'), %we have potential for a dict in py not to sure what it translates to here. 237 if verbose > 4, 238 disp(sprintf("=WW=creating var for %s.%s",groups{i}, fields{j})) 239 disp("NEED Treatment") 240 end 241 242 else 243 klass=class(md.(groups{i})); 244 klasstring = strcat(klass, '.',klass); 245 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),'classtype',klasstring); 246 subgroupID=netcdf.defGrp(groupID,fields{j}); 247 klass=class(md.(groups{i}).(fields{j})); 248 klasstring = strcat(klass, '.',klass); 249 netcdf.putAtt(subgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',klasstring); 250 subfields=fieldnames(Var); 251 for k=1:length(subfields), 252 if sum(strcmp(subfields{k},["outlog" "errlog"])) == 0, 253 if verbose > 4, 254 disp(sprintf("+==+creating var for %s.%s.%s",groups{i}, fields{j}, subfields{k})) 255 end 256 Var=md.(groups{i}).(fields{j}).(subfields{k}); 257 [DimSize,DimValue,varid]=CreateVar(ncid,Var,subgroupID,subfields{k},DimSize,DimValue); 258 if ~isempty(varid), 259 FillVar(Var,subgroupID,varid); 260 end 116 261 end 117 classtype=class(Var(l)); 118 if strcmp(classtype,'struct') 119 classtype=groups{i}; 120 end 121 listgroupID=netcdf.defGrp(subgroupID,lname); 122 netcdf.putAtt(listgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',classtype); 123 subfields=fieldnames(Var(l)); 124 for m=1:length(subfields) 125 if ~strcmp(subfields{m},'outlog') 126 [DimSize,DimValue]=DefCreateVar(ncid,Var(l).(subfields{m}),listgroupID,subfields{m},DimSize,DimValue); 127 end 128 end 129 end 130 else 131 subgroupID=netcdf.defGrp(groupID,groupfields{j}); 132 classtype=class(Var); 133 if strcmp(classtype,'struct') 134 classtype=groups{i}; 135 end 136 netcdf.putAtt(subgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',classtype); 137 subfields=fieldnames(Var); 138 for m=1:length(subfields) 139 if ~strcmp(subfields{m},'outlog') 140 [DimSize,DimValue]=DefCreateVar(ncid,Var.(subfields{m}),subgroupID,subfields{m},DimSize,DimValue); 141 end 142 end 262 end 263 143 264 end 144 265 else 145 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),'classtype',class(md.(groups{i}))); 146 [DimSize,DimValue]=DefCreateVar(ncid,Var,groupID,groupfields{j},DimSize,DimValue); 147 end 148 end 149 end 150 netcdf.close(ncid); 266 disp(sprintf("WARNING, md.%s.%s is not treated as it does not fall in one of the existing cases with class '%s'.",groups{i}, fields{j}, class(Var))) 267 end 268 end 269 end 270 netcdf.close(ncid); 151 271 end 152 272 153 function [DimSize,DimValue ]=DefCreateVar(ncid,Var,groupID,field,DimSize,DimValue,last,md,midfield)154 varclass=class(Var); 273 function [DimSize,DimValue,varid]=CreateVar(ncid,Var,groupID,field,DimSize,DimValue) 274 % Grab dimensions 155 275 varsize=size(Var); 156 276 varlength=length(Var); 277 % treating scalar string or bool as atribute 157 278 if isa(Var,'logical'), 158 279 if Var, … … 160 281 else, 161 282 LogicString='False'; 162 283 end 163 284 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),field,LogicString); 285 varid=[]; 286 164 287 elseif isa(Var,'char'), 165 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),field,Var); 288 if strcmp(field,'name'), % it looks like netCDF does not like attributes that are called "name" 289 field = 'varname'; 290 end 291 if size(Var,1) <= 1 %that is a single string or empty 292 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),field,Var); 293 varid=[]; 294 else % that is a character array 295 [dims,DimSize,DimValue]=GetDims(ncid,Var,DimSize,DimValue); 296 varid = netcdf.defVar(groupID,field,'NC_CHAR',dims); 297 if numel(Var)>1 298 netcdf.defVarDeflate(groupID,varid,true,true,4); 299 end 300 end 301 166 302 elseif isa(Var,'double'), %dealing with arrays 167 [dims,DimSize,DimValue]=GetDims(ncid,Var,DimSize,DimValue); 168 varid = netcdf.defVar(groupID,field,'NC_DOUBLE',dims); 303 if all(mod(Var, 1) == 0, 'all') %those are actually integers, 304 [dims,DimSize,DimValue]=GetDims(ncid,Var,DimSize,DimValue); 305 varid = netcdf.defVar(groupID,field,'NC_INT64',dims); 306 if numel(Var)>1 307 netcdf.defVarDeflate(groupID,varid,true,true,4); 308 end 309 else 310 [dims,DimSize,DimValue]=GetDims(ncid,Var,DimSize,DimValue); 311 varid = netcdf.defVar(groupID,field,'NC_DOUBLE',dims); 312 if numel(Var)>1 313 netcdf.defVarDeflate(groupID,varid,true,true,4); 314 end 315 end 316 elseif isa(Var,'cell'), 317 % cells can be a range of things, what are we dealing with here 318 if isempty(Var), 319 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),field,'emptycell'); 320 varid=[]; 321 else 322 [dims,DimSize,DimValue]=GetDims(ncid,Var,DimSize,DimValue); 323 if isa(Var{1}, 'double'), 324 varid = netcdf.defVar(groupID,field,'NC_DOUBLE',dims); 325 if numel(Var)>1 326 netcdf.defVarDeflate(groupID,varid,true,true,4); 327 end 328 else 329 varid = netcdf.defVar(groupID,field,'NC_CHAR',dims); 330 if numel(Var)>1 331 netcdf.defVarDeflate(groupID,varid,true,true,4); 332 end 333 end 334 end 335 elseif isa(Var,'struct'), 336 if isempty(fieldnames(Var)), 337 netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),field,'emptystruct'); 338 varid=[]; 339 else 340 %Start by getting the structure fields and size 341 [dims,DimSize,DimValue]=GetDims(ncid,Var,DimSize,DimValue); 342 varid = netcdf.defVar(groupID,field,'NC_CHAR',dims); 343 if numel(Var)>1 344 netcdf.defVarDeflate(groupID,varid,true,true,4); 345 end 346 end 347 else 348 disp(sprintf('no support for class %s of field %s',class(Var),field)); 349 varid=[]; 350 end 351 return 352 end 353 354 355 function FillVar(Var,groupID,varid) 356 % Grab dimensions 357 varsize=size(Var); 358 varlength=length(Var); 359 % treating scalar string or bool as atribute 360 if isa(Var,'double'), %dealing with arrays 361 if all(mod(Var, 1) == 0, 'all') %those are actually integers, 362 Var = int64(Var); 363 end 169 364 if length(Var)==0, 170 365 netcdf.putVar(groupID,varid,NaN); … … 172 367 netcdf.putVar(groupID,varid,Var); 173 368 end 174 elseif isa(Var,'cell'), 175 [dims,DimSize,DimValue]=GetDims(ncid,Var,DimSize,DimValue); 176 %dirty hack to be able to pass strings 177 varid = netcdf.defVar(groupID,field,'NC_CHAR',dims); 178 if length(Var)==0, 179 netcdf.putVar(groupID,varid,0,9,'emptycell') 180 else 181 for i=1:length(Var), 369 elseif isa(Var,'char'), % at this point this should be a character array 370 netcdf.putVar(groupID,varid,Var); 371 elseif isa(Var,'cell'), % there can be a number of things in a cell array 372 for i=1:length(Var), 373 if isa(Var{i},'char') %for characters we limit the size to 40 for now 182 374 if length(Var)>1, 183 endpoint=[1,min(length(Var{i}),40)];184 startpoint=[ 1 0];185 else 186 endpoint=min(length(Var{i}),40);375 count=[min(length(Var{i}),40), 1]; 376 startpoint=[0 i-1]; 377 else 378 count=min(length(Var{i}),40); 187 379 startpoint=0; 188 380 end 381 189 382 if length(Var{i})>40, 190 netcdf.putVar(groupID,varid,startpoint, extent,Var{i}(1:40))383 netcdf.putVar(groupID,varid,startpoint,count,Var{i}(1:40)); 191 384 disp(sprintf('some variable have been truncated')); 192 385 else 193 netcdf.putVar(groupID,varid,startpoint,endpoint,Var{i}) 194 end 386 netcdf.putVar(groupID,varid,startpoint,count,Var{i}); 387 end 388 elseif isa(Var{i},'double') 389 startpoint=[i-1]; 390 count=[1 length(Var{i}) ndims(Var{i})]; 391 for j=1:ndims(Var{i}), 392 startpoint=[startpoint 0]; 393 end 394 netcdf.putVar(groupID,varid,startpoint,count,Var{i}); 395 else 396 disp(sprintf("WARNING: cell of class %s is not supported.",class(Var{i}))) 195 397 end 196 398 end 197 399 elseif isa(Var,'struct'), 198 400 %Start by getting the structure fields and size 199 locfields=fieldnames(Var); 200 [dims,DimSize,DimValue]=GetDims(ncid,Var,DimSize,DimValue); 201 varid = netcdf.defVar(groupID,field,'NC_CHAR',dims); 202 if length(locfields)==0, 203 netcdf.putVar(groupID,varid,[0,0],[1,11],'emptystruct') 204 else 205 for i=1:length(locfields), 206 for j=1:2, 207 if j==1, 208 CharVar=locfields{i}; 209 if length(CharVar)==0 210 CharVar='emptystruct'; 211 end 212 startpoint=[i-1,0,0]; 401 locfields=fieldnames(Var) 402 for i=1:length(locfields), 403 for j=1:2, 404 if j==1, 405 CharVar=locfields{i}; 406 if length(CharVar)==0 407 CharVar='emptystruct'; 408 end 409 startpoint=[i-1,0,0]; 410 else 411 if isa(Var.(locfields{i}),'char'), 412 CharVar=Var.(locfields{i}); 213 413 else 214 if isa(Var.(locfields{i}),'char'), 215 CharVar=Var.(locfields{i}); 216 else 217 CharVar=num2str(Var.(locfields{i})); 218 end 219 if length(CharVar)==0 220 CharVar='emptystruct'; 221 end 222 startpoint=[i-1,1,0]; 223 end 224 225 extent=[1,1,min(length(CharVar),40)]; 226 if length(CharVar)>40, 227 netcdf.putVar(groupID,varid,startpoint,extent,CharVar(1:40)) 228 disp(sprintf('some variable have been truncated')); 229 else 230 netcdf.putVar(groupID,varid,startpoint,extent,CharVar) 231 end 414 CharVar=num2str(Var.(locfields{i})); 415 end 416 if length(CharVar)==0 417 CharVar='emptystruct'; 418 end 419 startpoint=[i-1,1,0]; 420 end 421 422 extent=[1,1,min(length(CharVar),40)]; 423 if length(CharVar)>40, 424 netcdf.putVar(groupID,varid,startpoint,extent,CharVar(1:40)); 425 disp(sprintf('some variable have been truncated')); 426 else 427 netcdf.putVar(groupID,varid,startpoint,extent,CharVar); 232 428 end 233 429 end 234 430 end 235 431 else 236 disp(sprintf('no support for class %s of field %s',varclass,field));237 432 disp(sprintf('no support for class %s',class(Var))); 433 end 238 434 return 239 435 end … … 241 437 function [dims,DimSize,DimValue]=GetDims(ncid,Var,DimSize,DimValue) 242 438 dims=[]; 243 if isa(Var,'cell'),244 varsize=size(Var');245 elseif isa(Var,'struct')439 celldims=[]; 440 dim=ndims(Var); 441 if isa(Var,'struct'), 246 442 varsize=length(fieldnames(Var)); 247 443 else 248 444 varsize=size(Var); 249 end 250 dim=sum(varsize>1); 251 if dim>0 252 for i=1:dim 253 indsize=find(varsize(i)==DimValue); 254 if length(indsize)>0 255 dims=[dims DimSize(indsize).index]; 256 else 257 indsize=length(DimSize)+1; 258 DimSize(indsize).index=netcdf.defDim(ncid,['Dimension' num2str(indsize)],varsize(i)); 259 [DimSize(indsize).name,DimSize(indsize).value]=netcdf.inqDim(ncid,DimSize(indsize).index); 260 DimValue(indsize)=DimSize(indsize).value; 261 dims=[dims DimSize(indsize).index]; 262 end 263 end 264 end 265 %if we have a cell variable we need to add a stringlength dimension 445 if isa(Var, 'cell') 446 %we add the dimension of the cells themselves, 447 %that will most probably fail if cells have different sizes 448 for i=1:dim, 449 newdim=size(Var{i}); 450 if ~ismember(newdim, celldims), 451 celldims=[celldims newdim]; 452 end 453 end 454 end 455 end 456 varsize=[varsize celldims]; 457 alldim=length(varsize); 458 if dim>0, 459 for i=1:alldim, 460 if size(Var, i)>1 || i>dim, %we skip dimensions with zero lenght but want to add dimensions from cells 461 indsize=find(varsize(i)==DimValue); 462 if length(indsize)>0 463 dims=[dims DimSize(indsize).index]; 464 else 465 indsize=length(DimSize)+1; 466 DimSize(indsize).index=netcdf.defDim(ncid,['DimNum' num2str(indsize)],varsize(i)); 467 [DimSize(indsize).name,DimSize(indsize).value]=netcdf.inqDim(ncid,DimSize(indsize).index); 468 DimValue(indsize)=DimSize(indsize).value; 469 dims=[dims DimSize(indsize).index]; 470 end 471 end 472 end 473 end 474 if isa(Var, 'cell') && isa(Var{1}, 'char'), 475 %if we have an cell variable with strings we need to add a stringlength 476 dims=[dims DimSize(4).index]; 477 end 478 % struct also need an extra dimension 2, but only if non empty 266 479 if isa(Var,'struct'), 267 if DimValue(3)~=2 268 if DimValue(2)~=2 269 dims=[dims DimSize(1).index]; 270 else 271 dims=[dims DimSize(2).index]; 272 end 273 else 274 dims=[dims DimSize(3).index]; 275 end 276 end 277 if isa(Var,'cell') || isa(Var,'struct'), 278 if DimValue(2)~=40 279 dims=[dims DimSize(1).index]; 280 else 281 dims=[dims DimSize(2).index]; 282 end 480 dims=[dims DimSize(3).index DimSize(4).index]; 283 481 end 284 482 end -
issm/trunk/src/m/contrib/defleurian/netCDF/export_netCDF.py
r26744 r27035 1 1 from netCDF4 import Dataset 2 2 import numpy as np 3 import numpy.ma as ma 3 4 import time 4 5 import collections … … 13 14 14 15 def update(self, stepvar): 15 #if we have a scalar we just add it to the en 16 #if we have a scalar we just add it to the end 16 17 #we save the size of the current step for further treatment 17 18 if len(np.shape(stepvar)) == 0: … … 21 22 #we save the size of the current step for further treatment 22 23 else: 23 self.sizes.append( len(stepvar))24 for r in stepvar:25 self.data.append(r)24 self.sizes.append([np.shape(stepvar)]) 25 stackdat = np.squeeze(stepvar.flatten()) 26 self.data = np.hstack((self.data, stackdat)) 26 27 27 28 def finalize(self, rows): 28 29 #we have more scalars than steps, so we have an array 29 30 if len(self.data) > rows: 31 datasize = np.squeeze(self.sizes) 32 maxsize = [] 33 try: 34 dims = np.arange(np.shape(datasize)[1]) 35 for dim in dims: 36 maxsize.append(np.nanmax(datasize[:, dim])) 37 except IndexError: 38 if datasize.ndim == 0: 39 maxsize.append(datasize) 40 else: 41 maxsize.append(np.nanmax(datasize[:])) 42 findim = np.insert(maxsize, 0, rows) 30 43 #first check if all steps are the same size 31 SameSize = np.sum(np.asarray(self.sizes) - self.sizes[0]) == 0 44 if datasize.ndim == 0: 45 SameSize = True 46 else: 47 SameSize = np.sum(np.abs(datasize - datasize[0])) == 0 32 48 if SameSize: 33 49 #same size for all steps, just reshape 34 return np.reshape(self.data, newshape=( rows, int(len(self.data) / rows)))50 return np.reshape(self.data, newshape=(findim)) 35 51 else: 36 52 #different sizes at each steps, first create a table big enough for the biggest step 37 53 startpoint = 0 38 datadim = len(np.shape(self.data)) 39 if datadim == 1: 40 outdat = np.nan * np.ones((rows, np.nanmax(self.sizes))) 41 for step in range(rows): 42 curlen = self.sizes[step] 43 outdat[step, :curlen] = self.data[startpoint: startpoint + curlen] 44 startpoint += curlen 45 elif datadim == 2: 46 outdat = np.nan * np.ones((rows, np.nanmax(self.sizes), np.shape(self.data)[1])) 47 for step in range(rows): 48 curlen = self.sizes[step] 49 outdat[step, :curlen, :] = self.data[startpoint: startpoint + curlen] 50 startpoint += curlen 51 52 else: 53 print("ERROR, reult treatment cant cope with dimensions above 2") 54 outdat = np.nan * np.ones(findim) 55 for step in range(rows): 56 #slicer is the data slice in the final array 57 slicer = [slice(0, d) for d in datasize[step, :]] 58 slicer = np.insert(slicer, 0, step) 59 curlen = int(np.prod(datasize[step, :])) 60 outdat[tuple(slicer)] = np.reshape(self.data[startpoint:startpoint + curlen], newshape=(datasize[step, :])) 61 startpoint += curlen 62 #outmasked = ma.masked_array(outdat, mask=np.where(np.isnan(outdat), 1, 0)) 54 63 return outdat 55 #as much scalars as st pes (or less) so just one value per step56 else: 57 return np. asarray(self.data)64 #as much scalars as steps (or less) so just one value per step 65 else: 66 return np.squeeze(np.asarray(self.data)) 58 67 59 68 … … 88 97 dimindex = 2 89 98 #add mesh related dimension that we know are needed 90 dimlist = [2, md.mesh.numberofelements, md.mesh.numberofvertices, np.shape(md.mesh.elements)[1]]91 dimnames = ['DictDummy', ' EltNum', 'VertNum', 'VertPerElt']99 dimlist = [2, 40, md.mesh.numberofelements, md.mesh.numberofvertices, np.shape(md.mesh.elements)[1]] 100 dimnames = ['DictDummy', 'StringLength', 'EltNum', 'VertNum', 'VertPerElt'] 92 101 if verbose > 0: 93 102 print('===Creating dimensions ===') … … 121 130 # looping on fields in each group 122 131 for field in fields: 132 Var = md.__dict__[group].__dict__[field] 123 133 # Special treatment for list fields 124 if type( md.__dict__[group].__dict__[field]) == list:134 if type(Var) == list: 125 135 StdList = False 126 if len( md.__dict__[group].__dict__[field]) == 0:136 if len(Var) == 0: 127 137 StdList = True #this is an empty list 128 138 else: 129 139 #returns False for exotic types (typicaly results) 130 StdList = type( md.__dict__[group].__dict__[field][0]) in typelist140 StdList = type(Var[0]) in typelist 131 141 klass = type(md.__dict__[group]).__module__ + '.' + type(md.__dict__[group]).__name__ 132 142 NCgroup.__setattr__('classtype', klass) … … 134 144 if verbose > 4: 135 145 print("=££=creating var for {}.{} with classtype : {}".format(group, field, klass)) 136 Var = md.__dict__[group].__dict__[field]137 146 Var = SqueezeVar(Var) 138 147 DimDict, ncvar = CreateVar(NCData, Var, field, NCgroup, DimDict) … … 141 150 else: # this is a list of fields, specific treatment needed (usually results or outputdefinitions) 142 151 if verbose > 4: 143 print(" list of fields happens for {}.{} with classtype : {}".format(group, field, klass))144 Listsize = len( md.__dict__[group].__dict__[field])152 print("=??=we have a list of fields for {}.{} with classtype : {}".format(group, field, klass)) 153 Listsize = len(Var) 145 154 if group == 'results': #for results we reshape the datas following time rather than subgrouping 146 155 Subgroup = NCgroup.createGroup(str(field)) … … 155 164 subfields = dict.keys(md.__dict__[group].__dict__[field].__getitem__(0)) 156 165 for subfield in subfields: 157 if subfield not in ['errlog', 'outlog']:166 if subfield not in ['errlog', 'outlog']: 158 167 StackedVar = ResTable() 159 168 #first loop over the field (result type) to find the index of the last subfield (variable) … … 172 181 StackedVar.update(Var) 173 182 if verbose > 4: 174 print("= $$=creating var for {}.{}.{}".format(group, field, subfield))183 print("=@@=creating var for {}.{}.{}".format(group, field, subfield)) 175 184 print("last index of the list is {}".format(lastindex)) 176 185 StackedVar = SqueezeVar(StackedVar.finalize(int(lastindex))) … … 238 247 subfields = dict.keys(md.__dict__[group].__dict__[field].__getitem__(0)) 239 248 for subfield in subfields: 240 if subfield not in ['errlog', 'outlog']:249 if subfield not in ['errlog', 'outlog']: 241 250 StackedVar = ResTable() 242 251 for listindex in range(0, Listsize): … … 245 254 lastindex = listindex + 1 246 255 except AttributeError: 247 Var = md.__dict__[group].__dict__[field].__getitem__(listindex)[subfield] 256 Var = md.__dict__[group].__dict__[field].__dict__[subfield] 257 lastindex = listindex 248 258 except KeyError: 249 259 #Some fields only exist for the first step 250 260 lastindex = listindex 251 continue261 break 252 262 Var = SqueezeVar(Var) 253 263 StackedVar.update(Var) … … 289 299 FillVar(ncvar, Var) 290 300 else: 291 print("WARNING, md.{}.{} is not treated as it does not fall in one of the existing cases.".format( str(group), str(field)))301 print("WARNING, md.{}.{} is not treated as it does not fall in one of the existing cases.".format(group, field)) 292 302 293 303 NCData.close() … … 305 315 if val_type.startswith('<U'): 306 316 val_type = 'stringarray' 317 print(var) 307 318 except AttributeError: 308 319 val_type = type(var) … … 329 340 if field == 'name': # it looks like netCDF does not like attributes that are called "name" 330 341 field = 'varname' 331 Group.__setattr__(str(field) .swapcase(), str(var))342 Group.__setattr__(str(field), str(var)) 332 343 ncvar = None 333 344 # numpy array of strings 334 345 elif val_type == "stringarray": 335 346 #if all strings are the same set it as an attribute 336 if all(var == var[0]): 347 try: 348 samestring = all(var == var[0]) 349 except IndexError: 350 #Only one string 351 samestring = True 352 if samestring: 337 353 if field == 'name': 338 354 field = 'varname' 339 Group.__setattr__(str(field).swapcase(), str(var[0])) 355 try: 356 Group.__setattr__(str(field), str(var[0])) 357 except IndexError: 358 Group.__setattr__(str(field), str(var)) 340 359 ncvar = None 341 360 else: … … 355 374 dimensions, DimDict = GetDim(NCData, val_shape, val_type, DimDict, val_dim) 356 375 ncvar = Group.createVariable(str(field), nctype, dimensions=dimensions, zlib=True) 357 # treating bool tables anddict as string tables358 elif val_type in [collections.OrderedDict, dict , 'bool']:376 # treating dict as string tables 377 elif val_type in [collections.OrderedDict, dict]: 359 378 if val_shape in [(), (0,), 0]: 360 379 ncvar = Group.createVariable(str(field), str, zlib=True) … … 362 381 dimensions, DimDict = GetDim(NCData, val_shape, val_type, DimDict, val_dim) 363 382 ncvar = Group.createVariable(str(field), str, dimensions=dimensions, zlib=True) 364 # Now dealing with numeric variables 365 elif val_type in [float, 'float64', np.float64, int, 'int64']: 383 # treating bool as integers 384 elif val_type == 'bool': 385 if val_shape in [(), (0,), 0]: 386 ncvar = Group.createVariable(str(field), int, zlib=True) 387 else: 388 dimensions, DimDict = GetDim(NCData, val_shape, val_type, DimDict, val_dim) 389 ncvar = Group.createVariable(str(field), int, dimensions=dimensions, zlib=True) 390 # Now dealing with doubles, we convert them to int if possible 391 elif val_type in [float, 'float64', np.float64]: 392 try: 393 #check if we are integer and under C long overflow also skip empty arrays 394 IsInt = np.sum(np.mod(var, 1)) == 0 and np.all(abs(var) < 2147483647) and len(var) > 0 395 except TypeError: 396 #check if we are integer and under C long overflow 397 IsInt = np.mod(var, 1) == 0 and abs(var) < 2147483647 398 if IsInt: 399 val_type = 'int64' 400 if val_shape in [(), (0,), 0] and not SupDim: 401 ncvar = Group.createVariable(str(field), TypeDict[val_type], zlib=True) 402 else: 403 dimensions, DimDict = GetDim(NCData, val_shape, val_type, DimDict, val_dim) 404 if SupDim: 405 dimensions = SupDim + dimensions 406 ncvar = Group.createVariable(str(field), TypeDict[val_type], dimensions=dimensions, zlib=True) 407 elif val_type in [int, 'int64']: 366 408 if val_shape in [(), (0,), 0] and not SupDim: 367 409 ncvar = Group.createVariable(str(field), TypeDict[val_type], zlib=True) … … 410 452 elif val_type == 'bool': 411 453 for elt in range(0, val_shape[0]): 412 ncvar[elt] = str(invar[elt])454 ncvar[elt] = int(invar[elt]) #str(invar[elt]) 413 455 # treating dictionaries as tables of strings 414 456 elif val_type in [collections.OrderedDict, dict]: -
issm/trunk/src/m/contrib/larour/mdanalysis.m
r25836 r27035 1600 1600 if strncmpi(fieldv,'Mask',4), 1601 1601 contourexp=[tempname '.exp']; 1602 expcontourlevelzero(md.icecaps{i},field,0,contourexp);1602 isoline(md.icecaps{i},field,'output',contourexp); 1603 1603 contourlevels=1; 1604 1604 1605 1605 if diff, 1606 1606 contourdiffexp=[tempname '.exp']; 1607 expcontourlevelzero(md.icecaps{i},dfield,0,contourdiffexp);1607 isoline(md.icecaps{i},dfield,'output',contourdiffexp); 1608 1608 end 1609 1609 end -
issm/trunk/src/m/contrib/morlighem/modeldata/interpBamber2001.m
r23873 r27035 8 8 bamber2001bedpath ='/home/ModelData/Greenland/Bamber2001/bedrock.mat'; 9 9 bamber2001thxpath ='/home/ModelData/Greenland/Bamber2001/thickness.mat'; 10 case {'totten'} 11 bamber2001bedpath ='/totten_1/ModelData/Greenland/Bamber2001/bedrock.mat'; 12 bamber2001thxpath ='/totten_1/ModelData/Greenland/Bamber2001/thickness.mat'; 10 13 otherwise 11 14 error('machine not supported yet'); -
issm/trunk/src/m/contrib/morlighem/modeldata/interpBamber2013.m
r23873 r27035 22 22 case {'ronne'} 23 23 bamber2013nc='/home/ModelData/Greenland/Bamber2013/Greenland_bedrock_topography_V3.nc'; 24 case {'totten'} 25 bamber2013nc='/totten_1/ModelData/Greenland/Bamber2013/Greenland_bedrock_topography_V3.nc'; 24 26 otherwise 25 27 error('machine not supported yet'); -
issm/trunk/src/m/contrib/morlighem/modeldata/interpBedmachineAntarctica.m
r26744 r27035 28 28 if nargin<5 29 29 ncdate='2020-07-15'; %BedMachine v2 30 ncdate='2021-11-16'; % BedMachine v230 ncdate='2021-11-16'; %new 31 31 end 32 32 basename = 'BedMachineAntarctica'; -
issm/trunk/src/m/contrib/morlighem/modeldata/interpBedmachineGreenland.m
r26744 r27035 30 30 ncdate='2017-09-25'; %BedMachine v3 31 31 ncdate='2020-04-14'; 32 ncdate='2021-08-27'; 33 ncdate='2022-03-17'; 32 34 end 33 35 basename = 'BedMachineGreenland'; -
issm/trunk/src/m/contrib/morlighem/modeldata/interpDhdt.m
r23873 r27035 4 4 case {'ronne'} 5 5 dhdtpath='/home/ModelData/Greenland/DHDT/dhdt0306.tif'; 6 case {'totten'} 7 dhdtpath='/totten_1/ModelData/Greenland/DHDT/dhdt0306.tif'; 6 8 otherwise 7 9 error('machine not supported yet'); -
issm/trunk/src/m/contrib/morlighem/modeldata/interpGimpdem.m
r23873 r27035 6 6 case {'ronne'} 7 7 howatpath='/home/ModelData/Greenland/gimpdem/gimpdem_90m.tif'; 8 case {'totten'} 9 howatpath='/totten_1/ModelData/Greenland/gimpdem/gimpdem_90m.tif'; 8 10 otherwise 9 11 error('machine not supported yet'); -
issm/trunk/src/m/contrib/morlighem/modeldata/interpJakobsson2020.m
r25836 r27035 4 4 case {'ronne'} 5 5 ncpath ='/home/ModelData/Greenland/IBCAO/IBCAO_v4_200m.nc'; 6 case {'totten'} 7 ncpath ='/totten_1/ModelData/Greenland/IBCAO/IBCAO_v4_200m.nc'; 6 8 otherwise 7 9 error('machine not supported yet'); … … 39 41 40 42 if nargout==2, 41 ncpath ='/ home/ModelData/Greenland/IBCAO/IBCAO_v4_200m_TID.nc';43 ncpath ='/totten_1/ModelData/Greenland/IBCAO/IBCAO_v4_200m_TID.nc'; 42 44 disp(' -- Jakobsson2020: loading source'); 43 45 data = double(ncread(ncpath,'z',[id1x id1y],[id2x-id1x+1 id2y-id1y+1],[1 1]))'; -
issm/trunk/src/m/contrib/morlighem/modeldata/interpMouginotAnt2019.m
r25836 r27035 5 5 case {'ronne'} 6 6 nc = '/home/ModelData/Antarctica/MouginotVel/v_mix.v13Mar2019.nc'; 7 case {'totten'} 8 nc = '/totten_1/ModelData/Antarctica/MouginotVel/v_mix.v8Jul2019.nc'; 7 9 otherwise 8 10 error('hostname not supported yet'); -
issm/trunk/src/m/contrib/morlighem/modeldata/interpRACMO1km.m
r23873 r27035 4 4 case {'ronne'} 5 5 rootname='/home/ModelData/Greenland/RACMO2_1km/SMB_MEAN1960-1989_150m.nc'; 6 case {'totten'} 7 rootname='/totten_1/ModelData/Greenland/RACMO2_1km/SMB_MEAN1960-1989_150m.nc'; 6 8 otherwise 7 9 error('machine not supported yet'); -
issm/trunk/src/m/contrib/morlighem/modeldata/interpRignotIceShelfMelt.m
r23873 r27035 4 4 case {'ronne'} 5 5 rignotmelt='/home/ModelData/Antarctica/RignotMeltingrate/Ant_MeltingRate.nc'; 6 case {'totten'} 7 rignotmelt='/totten_1/ModelData/Antarctica/RignotMeltingrate/Ant_MeltingRate.nc'; 6 8 case {'thwaites','murdo','astrid'} 7 9 rignotmelt=['/home/seroussi/Data/Ant_MeltingRate.nc']; -
issm/trunk/src/m/coordsystems/ll2xy.m
r26744 r27035 40 40 end 41 41 42 %Move to CoordTransform now... 43 if exist('CoordTransform_matlab')==3 44 disp('Calling CoordTransform instead, make sure to change your MATLAB script'); 45 if sgn==+1 46 assert(delta==45); assert(slat ==70); 47 [x y]=CoordTransform(lat,lon,'EPSG:4326','EPSG:3413'); 48 return; 49 else 50 assert(delta==0); assert(slat ==71); 51 [x y]=CoordTransform(lat,lon,'EPSG:4326','EPSG:3031'); 52 return; 53 end 54 end 55 42 56 % Conversion constant from degrees to radians 43 57 cde = 57.29577951; -
issm/trunk/src/m/coordsystems/xy2ll.m
r24313 r27035 34 34 help xy2ll 35 35 error('bad usage'); 36 end 37 38 %Move to CoordTransform now... 39 if exist('CoordTransform_matlab')==3 40 disp('Calling CoordTransform instead, make sure to change your MATLAB script'); 41 if sgn==+1 42 assert(delta==45); assert(slat ==70); 43 [lat lon]=CoordTransform(x, y,'EPSG:3413','EPSG:4326'); 44 return; 45 else 46 assert(delta==0); assert(slat ==71); 47 [lat lon]=CoordTransform(x, y,'EPSG:3031','EPSG:4326'); 48 return; 49 end 36 50 end 37 51 -
issm/trunk/src/m/dev/issmversion.m
r26744 r27035 17 17 disp(['Compiled on ' IssmConfig('HOST_VENDOR') ' ' IssmConfig('HOST_OS') ' ' IssmConfig('HOST_ARCH') ' by ' IssmConfig('USER_NAME')]); 18 18 disp([' ']); 19 disp(['Copyright (c) 2009-202 1California Institute of Technology']);19 disp(['Copyright (c) 2009-2022 California Institute of Technology']); 20 20 disp([' ']); 21 21 disp([' to get started type: issmdoc']); -
issm/trunk/src/m/dev/issmversion.py
r26744 r27035 16 16 print(' ') 17 17 print(('Build date: ' + IssmConfig('PACKAGE_BUILD_DATE')[0])) 18 print('Copyright (c) 2009-202 1California Institute of Technology')18 print('Copyright (c) 2009-2022 California Institute of Technology') 19 19 print(' ') 20 20 print(' to get started type: issmdoc') -
issm/trunk/src/m/exp/contourlevelzero.m
r26744 r27035 1 function contours=contourlevelzero(md,mask,level) 2 %CONTOURLEVELZERO - figure out the zero level (or offset thereof, specified by the level value) 3 % of a vectorial mask, and vectorialize it into an exp or shp compatible 4 %structure. 5 % 6 % Usage: 7 % contours=contourlevelzero(md,mask,level) 8 % 9 % See also: PLOT_CONTOUR 1 function contours=contourlevelzero(md,mask,level,varargin) 10 2 11 %process data 12 if dimension(md.mesh)==3, 13 % error('contourlevelzero error message: routine not supported for 3d meshes, project on a layer'); 14 x = md.mesh.x2d; 15 y = md.mesh.y2d; 16 index=md.mesh.elements2d; 17 else 18 x=md.mesh.x; 19 y=md.mesh.y; 20 index=md.mesh.elements; 21 end 22 23 if isprop(md.mesh,'z'), 24 z=md.mesh.z; 25 else 26 z=zeros(md.mesh.numberofvertices,1); 27 end 28 29 if isempty(mask), error('mask provided is empty'); end 30 if dimension(md.mesh)==3, 31 if length(mask)~=md.mesh.numberofvertices2d, error('mask provided should be specified at the vertices of the mesh'); end 32 else 33 if length(mask)~=md.mesh.numberofvertices, error('mask provided should be specified at the vertices of the mesh'); end 34 end 35 36 %initialization of some variables 37 numberofelements=size(index,1); 38 elementslist=1:numberofelements; 39 c=[]; 40 h=[]; 41 42 %get unique edges in mesh 43 %1: list of edges 44 edges=[index(:,[1,2]); index(:,[2,3]); index(:,[3,1])]; 45 %2: find unique edges 46 [edges,I,J]=unique(sort(edges,2),'rows'); 47 %3: unique edge numbers 48 vec=J; 49 %4: unique edges numbers in each triangle (2 triangles sharing the same edge will have 50 % the same edge number) 51 edges_tria=[vec(elementslist), vec(elementslist+numberofelements), vec(elementslist+2*numberofelements)]; 52 53 %segments [nodes1 nodes2] 54 Seg1=index(:,[1 2]); 55 Seg2=index(:,[2 3]); 56 Seg3=index(:,[3 1]); 57 58 %segment numbers [1;4;6;...] 59 Seg1_num=edges_tria(:,1); 60 Seg2_num=edges_tria(:,2); 61 Seg3_num=edges_tria(:,3); 62 63 %value of data on each tips of the segments 64 Data1=mask(Seg1); 65 Data2=mask(Seg2); 66 Data3=mask(Seg3); 67 68 %get the ranges for each segment 69 Range1=sort(Data1,2); 70 Range2=sort(Data2,2); 71 Range3=sort(Data3,2); 72 73 %find the segments that contain this value 74 pos1=(Range1(:,1)<level & Range1(:,2)>=level); 75 pos2=(Range2(:,1)<level & Range2(:,2)>=level); 76 pos3=(Range3(:,1)<level & Range3(:,2)>=level); 77 78 %get elements 79 poselem12=(pos1 & pos2); 80 poselem13=(pos1 & pos3); 81 poselem23=(pos2 & pos3); 82 poselem=find(poselem12 | poselem13 | poselem23); 83 numelems=length(poselem); 84 85 %if no element has been flagged, skip to the next level 86 if numelems==0, 87 warning('contourlevelzero warning message: no elements found with corresponding level value in mask'); 88 contours=struct([]); 89 return; 90 end 91 92 %go through the elements and build the coordinates for each segment (1 by element) 93 x1=zeros(numelems,1); 94 x2=zeros(numelems,1); 95 y1=zeros(numelems,1); 96 y2=zeros(numelems,1); 97 z1=zeros(numelems,1); 98 z2=zeros(numelems,1); 99 100 edge_l=zeros(numelems,2); 101 102 for j=1:numelems, 103 104 weight1=(level-Data1(poselem(j),1))/(Data1(poselem(j),2)-Data1(poselem(j),1)); 105 weight2=(level-Data2(poselem(j),1))/(Data2(poselem(j),2)-Data2(poselem(j),1)); 106 weight3=(level-Data3(poselem(j),1))/(Data3(poselem(j),2)-Data3(poselem(j),1)); 107 108 if poselem12(poselem(j)); 109 110 x1(j)=x(Seg1(poselem(j),1))+weight1*(x(Seg1(poselem(j),2))-x(Seg1(poselem(j),1))); 111 x2(j)=x(Seg2(poselem(j),1))+weight2*(x(Seg2(poselem(j),2))-x(Seg2(poselem(j),1))); 112 y1(j)=y(Seg1(poselem(j),1))+weight1*(y(Seg1(poselem(j),2))-y(Seg1(poselem(j),1))); 113 y2(j)=y(Seg2(poselem(j),1))+weight2*(y(Seg2(poselem(j),2))-y(Seg2(poselem(j),1))); 114 z1(j)=z(Seg1(poselem(j),1))+weight1*(z(Seg1(poselem(j),2))-z(Seg1(poselem(j),1))); 115 z2(j)=z(Seg2(poselem(j),1))+weight2*(z(Seg2(poselem(j),2))-z(Seg2(poselem(j),1))); 116 117 edge_l(j,1)=Seg1_num(poselem(j)); 118 edge_l(j,2)=Seg2_num(poselem(j)); 119 120 elseif poselem13(poselem(j)), 121 122 x1(j)=x(Seg1(poselem(j),1))+weight1*(x(Seg1(poselem(j),2))-x(Seg1(poselem(j),1))); 123 x2(j)=x(Seg3(poselem(j),1))+weight3*(x(Seg3(poselem(j),2))-x(Seg3(poselem(j),1))); 124 y1(j)=y(Seg1(poselem(j),1))+weight1*(y(Seg1(poselem(j),2))-y(Seg1(poselem(j),1))); 125 y2(j)=y(Seg3(poselem(j),1))+weight3*(y(Seg3(poselem(j),2))-y(Seg3(poselem(j),1))); 126 z1(j)=z(Seg1(poselem(j),1))+weight1*(z(Seg1(poselem(j),2))-z(Seg1(poselem(j),1))); 127 z2(j)=z(Seg3(poselem(j),1))+weight3*(z(Seg3(poselem(j),2))-z(Seg3(poselem(j),1))); 128 129 edge_l(j,1)=Seg1_num(poselem(j)); 130 edge_l(j,2)=Seg3_num(poselem(j)); 131 132 elseif poselem23(poselem(j)), 133 134 x1(j)=x(Seg2(poselem(j),1))+weight2*(x(Seg2(poselem(j),2))-x(Seg2(poselem(j),1))); 135 x2(j)=x(Seg3(poselem(j),1))+weight3*(x(Seg3(poselem(j),2))-x(Seg3(poselem(j),1))); 136 y1(j)=y(Seg2(poselem(j),1))+weight2*(y(Seg2(poselem(j),2))-y(Seg2(poselem(j),1))); 137 y2(j)=y(Seg3(poselem(j),1))+weight3*(y(Seg3(poselem(j),2))-y(Seg3(poselem(j),1))); 138 z1(j)=z(Seg2(poselem(j),1))+weight2*(z(Seg2(poselem(j),2))-z(Seg2(poselem(j),1))); 139 z2(j)=z(Seg3(poselem(j),1))+weight3*(z(Seg3(poselem(j),2))-z(Seg3(poselem(j),1))); 140 141 edge_l(j,1)=Seg2_num(poselem(j)); 142 edge_l(j,2)=Seg3_num(poselem(j)); 143 else 144 %it shoud not go here 145 end 146 end 147 148 %now that we have the segments, we must try to connect them... 149 150 %loop over the subcontours 151 contours=struct([]); 152 153 while ~isempty(edge_l), 154 155 %take the right edge of the second segment and connect it to the next segments if any 156 e1=edge_l(1,1); e2=edge_l(1,2); 157 xc=[x1(1);x2(1)]; yc=[y1(1);y2(1)]; zc=[z1(1);z2(1)]; 158 159 160 %erase the lines corresponding to this edge 161 edge_l(1,:)=[]; 162 x1(1)=[]; x2(1)=[]; 163 y1(1)=[]; y2(1)=[]; 164 z1(1)=[]; z2(1)=[]; 165 166 [ro1,co1]=find(edge_l==e1); 167 168 while ~isempty(ro1) 169 170 if co1==1, 171 xc=[x2(ro1);xc]; yc=[y2(ro1);yc];zc=[z2(ro1);zc]; 172 173 %next edge: 174 e1=edge_l(ro1,2); 175 176 else 177 xc=[x1(ro1);xc]; yc=[y1(ro1);yc];zc=[z1(ro1);zc]; 178 179 %next edge: 180 e1=edge_l(ro1,1); 181 end 182 183 %erase the lines of this 184 edge_l(ro1,:)=[]; 185 x1(ro1)=[]; x2(ro1)=[]; 186 y1(ro1)=[]; y2(ro1)=[]; 187 z1(ro1)=[]; z2(ro1)=[]; 188 189 %next connection 190 [ro1,co1]=find(edge_l==e1); 191 end 192 193 %same thing the other way (to the right) 194 [ro2,co2]=find(edge_l==e2); 195 196 while ~isempty(ro2) 197 198 if co2==1, 199 xc=[xc;x2(ro2)]; yc=[yc;y2(ro2)];zc=[zc;z2(ro2)]; 200 201 %next edge: 202 e2=edge_l(ro2,2); 203 else 204 xc=[xc;x1(ro2)]; yc=[yc;y1(ro2)]; zc=[zc;z1(ro2)]; 205 206 %next edge: 207 e2=edge_l(ro2,1); 208 end 209 210 %erase the lines of this 211 edge_l(ro2,:)=[]; 212 x1(ro2)=[]; x2(ro2)=[]; 213 y1(ro2)=[]; y2(ro2)=[]; 214 z1(ro2)=[]; z2(ro2)=[]; 215 216 %next connection 217 [ro2,co2]=find(edge_l==e2); 218 end 219 220 %save xc,yc contour: 221 contours(end+1).x=xc; 222 contours(end).y=yc; 223 contours(end).z=zc; 224 contours(end).name=''; 225 contours(end).nods=length(xc); 226 contours(end).density=1; 227 contours(end).closed=0; 228 229 end 3 error('this function has been renamed: A = isoline(md,mask);'); -
issm/trunk/src/m/exp/expcontourlevelzero.m
r26744 r27035 1 1 function expcontourlevelzero(md,mask,level,filename) 2 %EXPCONTOURLEVELZERO - write an Argus file from a structure recovered from running contourlevelzero3 %4 % Usage:5 % expcontourlevelzero(md,mask,level,filename)6 %7 % Example:8 % expcontourlevelzero(md,md.geometry.thickness,10, 'Level0.exp');9 % expcontourlevelzero(md,md.mask.ocean_levelset,0, 'Level0.exp');10 %11 % See also CONTOURLEVELZERO, EXPWRITE12 2 13 contours=contourlevelzero(md,mask,level); 14 expwrite(contours,filename); 3 error(['this function has been renamed: isoline(md,mask,''output'',''' filename ''');']); -
issm/trunk/src/m/exp/exptool.m
r24313 r27035 137 137 %plot existing profile if any 138 138 hold on 139 disableDefaultInteractivity(gca); %disables the built-in interactions for the specified axes 139 140 140 141 %Build backup structre for do and redo -
issm/trunk/src/m/exp/expwrite.py
r26744 r27035 7 7 This routine writes an Argus file from a dict containing the fields: 8 8 x and y of the coordinates of the points. 9 The first argument is the list containing the points coordinates and the 9 The first argument is the list containing the points coordinates and the 10 10 second one the file to be written. 11 11 … … 20 20 21 21 fid = open(filename, 'w') 22 for x, y in zip(contours['x'], contours['y']): 23 if len(x) != len(y): 24 raise RuntimeError('contours x and y coordinates must be of identical size') 25 26 if 'name' in contours: 27 fid.write('{}{}\n'.format('# Name:', contours['name'])) 22 #if it is a list we need to loop on several contours 23 if isinstance(contours, list): 24 for contour in contours: 25 #if it is some kind of array it is a contour and we loop on indexes 26 if isinstance(contour['x'], (list, tuple, np.ndarray)): 27 writegeomlist(contour, fid, filename) 28 #else it is an index and we just write it down 29 else: 30 writegeom(contour, fid, filename) 31 #if it is a dict type it means just one contour 32 else: 33 #if it is some kind of array it is a contour and we loop on indexes 34 if isinstance(contours['x'], (list, tuple, np.ndarray)): 35 writegeomlist(contours, fid, filename) 36 #else it is an index and we just write it down 28 37 else: 29 fid.write('{}{}\n'.format('# Name:', filename)) 30 31 fid.write('{}\n'.format('## Icon:0')) 32 fid.write('{}\n'.format('# Points Count Value')) 33 if 'density' in contours: 34 if isinstance(contours['density'], int): 35 fid.write('{} {}\n'.format(np.size(x), contours['density'])) 36 else: 37 fid.write('{} {}\n'.format(np.size(x), 1.)) 38 else: 39 fid.write('{} {}\n'.format(np.size(x), 1.)) 40 fid.write('{}\n'.format('# X pos Y pos')) 41 for xi, yi in zip(x, y): 42 fid.write('%10.10f %10.10f\n' % (xi, yi)) 43 fid.write('\n') 38 writegeom(contours, fid, filename) 44 39 45 40 fid.close() 41 42 43 def writegeomlist(contour, fid, filename): 44 if len(contour['x']) != len(contour['y']): 45 raise RuntimeError('contours x and y coordinates must be of identical size') 46 if 'name' in contour: 47 fid.write('{}{}\n'.format('## Name:', contour['name'])) 48 else: 49 fid.write('{}{}\n'.format('## Name:', filename)) 50 51 fid.write('{}\n'.format('## Icon:0')) 52 fid.write('{}\n'.format('# Points Count Value')) 53 if 'density' in contour: 54 if isinstance(contour['density'], int): 55 fid.write('{} {}\n'.format(np.size(contour['x']), contour['density'])) 56 else: 57 fid.write('{} {}\n'.format(np.size(contour['x']), 1.)) 58 else: 59 fid.write('{} {}\n'.format(np.size(contour['x']), 1.)) 60 fid.write('{}\n'.format('# X pos Y pos')) 61 for x, y in zip(contour['x'], contour['y']): 62 fid.write('%10.10f %10.10f\n' % (x, y)) 63 fid.write('\n') 64 65 66 def writegeom(contour, fid, filename): 67 if 'name' in contour: 68 fid.write('{}{}\n'.format('## Name:', contour['name'])) 69 else: 70 fid.write('{}{}\n'.format('## Name:', filename)) 71 72 fid.write('{}\n'.format('## Icon:0')) 73 fid.write('{}\n'.format('# Points Count Value')) 74 if 'density' in contour: 75 if isinstance(contour['density'], int): 76 fid.write('{} {}\n'.format(1, contour['density'])) 77 else: 78 fid.write('{} {}\n'.format(1, 1.)) 79 else: 80 fid.write('{} {}\n'.format(1, 1.)) 81 fid.write('{}\n'.format('# X pos Y pos')) 82 fid.write('%10.10f %10.10f\n' % (contour['x'], contour['y'])) 83 fid.write('\n') -
issm/trunk/src/m/exp/operation/exp_ginput.m
r24313 r27035 5 5 % [xi yi] = exp_ginput(numclicks,options); 6 6 7 8 ginputtype = getfieldvalue(options,'ginputtype','default'); 7 %ginputtype = getfieldvalue(options,'ginputtype','default'); 9 8 ginputtype = getfieldvalue(options,'ginputtype','myginput'); 10 9 … … 17 16 error('not supported yet'); 18 17 end 19 20 -
issm/trunk/src/m/geometry/VolumeAboveFloatation.m
r25836 r27035 1 function V = VolumeAboveFloatation(md )1 function V = VolumeAboveFloatation(md,step,flags) 2 2 %VOLUMEABOVEFLOATATION - returns volume above floatation 3 3 % 4 4 % Usage: 5 % V = VolumeAboveFloatation(md) 5 % V = VolumeAboveFloatation(md) % uses model fiels alone 6 % V = VolumeAboveFloatation(md,10) % Will look at step 10 of transient solution 7 % V = VolumeAboveFloatation(md,10,flags) % Will look at step 10 of transient solution, only flaged elements 6 8 7 9 %Special case if 3d … … 17 19 error('not supported yet'); 18 20 end 21 19 22 %1. get some parameters 20 23 rho_ice = md.materials.rho_ice; … … 22 25 23 26 %2. compute averages 24 base = mean(md.geometry.base(index),2); 25 surface = mean(md.geometry.surface(index),2); 26 bathymetry = mean(md.geometry.bed(index),2); 27 if nargin==1 28 base = mean(md.geometry.base(index),2); 29 surface = mean(md.geometry.surface(index),2); 30 bathymetry = mean(md.geometry.bed(index),2); 31 ice_levelset = md.mask.ice_levelset; 32 ocean_levelset = md.mask.ocean_levelset; 33 else 34 if isprop(md.results.TransientSolution(step),'MaskIceLevelset') 35 ice_levelset = md.results.TransientSolution(step).MaskIceLevelset; 36 else 37 ice_levelset = md.mask.ice_levelset; 38 end 39 ocean_levelset = md.results.TransientSolution(step).MaskOceanLevelset; 40 base = mean(md.results.TransientSolution(step).Base(index),2); 41 surface = mean(md.results.TransientSolution(step).Surface(index),2); 42 if isprop(md.results.TransientSolution(step),'Bed') 43 bathymetry = mean(md.results.TransientSolution(step).Bed(index),2); 44 else 45 bathymetry = mean(md.geometry.bed(index),2); 46 end 47 end 27 48 28 49 %3. get areas of all triangles … … 33 54 34 55 %5. take out the ones that are outside of levelset or floating 35 pos = find(min( md.mask.ice_levelset(index),[],2)>0 | min(md.mask.ocean_levelset(index),[],2)<0);56 pos = find(min(ice_levelset(index),[],2)>0 | min(ocean_levelset(index),[],2)<0); 36 57 V(pos) = 0; 58 59 %In case we are only looking at one portion of the domain... 60 if nargin==3 61 V(find(~flags)) = 0; 62 end 37 63 38 64 %sum individual contributions -
issm/trunk/src/m/inversions/marshallcostfunctions.py
r24313 r27035 14 14 505: 'ThicknessAcrossGradient'} 15 15 16 data = [cfDict[cf] for cf in cost_functions] 16 if type(cost_functions) == int: 17 data = [cfDict[cost_functions]] 18 else: 19 data = [cfDict[cf] for cf in cost_functions] 17 20 # #copy list first 18 21 # data = copy.deepcopy(cost_functions) -
issm/trunk/src/m/io/loadmodel.py
r25836 r27035 9 9 10 10 11 def loadmodel(path, onlylast=False):11 def loadmodel(path, singletime=None, singleres=None): 12 12 """LOADMODEL - load a model 13 13 … … 31 31 # try: 32 32 #recover model on file and name it md 33 struc = loadvars(path, onlylast=onlylast)33 struc = loadvars(path, singletime=singletime, singleres=singleres) 34 34 name = [key for key in list(struc.keys())] 35 35 if len(name) > 1: -
issm/trunk/src/m/io/loadvars.py
r26744 r27035 7 7 from re import findall, split 8 8 import shelve 9 from netCDF4 import Dataset 9 from netCDF4 import Dataset, chartostring 10 10 import numpy as np 11 import numpy.ma as ma 12 from importlib import import_module 11 13 from model import * 12 14 … … 30 32 filename = '' 31 33 nvdict = {} 32 debug = False #print messages if true34 verbose = 0 # 0 for silent 5 for chatty 33 35 34 36 if len(args) >= 1 and isinstance(args[0], str): … … 52 54 raise TypeError("Unrecognized input arguments.") 53 55 54 onlylast= False56 timeindex = False 55 57 56 58 for key, value in kwargs.items(): 57 if key == 'onlylast': 58 onlylast = value 59 if key == 'singletime': 60 timeindex = value 61 if key == 'singleres': 62 resname = value 59 63 60 64 if whichdb(filename): #We used python pickle for the save … … 87 91 for mod in dict.keys(classtype): 88 92 #==== First we create the model structure {{{ 89 if debug:93 if verbose > 0: 90 94 print(' ==== Now treating classtype {}'.format(mod)) 91 95 if mod not in classtree.keys(): … … 94 98 # this points to a subclass (results.TransientSolution for example) 95 99 curclass = NCFile.groups[classtree[mod][0]].groups[classtree[mod][1]] 96 if debug:100 if verbose > 0: 97 101 print(" ==> {} is of class {}".format(mod, classtype[mod])) 98 102 if classtype[mod][0] == 'results.solutionstep': #Treating results {{{ … … 100 104 #that is the current treatment 101 105 #here we have a more NC approach with time being a dimension 102 listtype = split(r'\.', classtype[mod][0])[0] 106 listtype = split(r'\.', classtype[mod][0])[1] 107 print(listtype) 103 108 if len(NCFile.dimensions['Time']) == 1: 104 109 nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = getattr(classtype[mod][1], listtype)() … … 106 111 else: 107 112 #Time dimension is in all the variables so we take that as stepnumber for the results 108 if onlylast: #we load only the last result to save on time and memory113 if timeindex: #we load only the last result to save on time and memory 109 114 nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(classtype[mod][1], listtype)()] 110 115 Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] … … 126 131 Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] 127 132 else: 128 if onlylast: #we load only the last result to save on time and memory133 if timeindex: #we load only the last result to save on time and memory 129 134 nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(classtype[mod][1], listtype)()] 130 135 Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] 131 136 else: 132 #nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(classtype[mod][1], listtype)() for i in range(max(1, len(NCFile.dimensions['Time'])))]133 #Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]][:]134 137 setattr(nvdict['md'].__dict__[classtree[mod][0]], classtree[mod][1], getattr(classtype[mod][1], 'solution')([])) 135 138 for i in range(max(1, stepnum)): … … 137 140 Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]][:] 138 141 #}}} 139 elif classtype[mod][0] == 'massfluxatgate': #this is for output definitions {{{ 142 #elif classtype[mod][0] == 'massfluxatgate.massfluxatgate': #this is for output definitions {{{ 143 elif mod.startswith('outputdefinition'): #this is for output definitions {{{ 140 144 defname = split('Output|[0-9]+', classtree[mod][1])[1] + 's' 141 145 defindex = int(findall('[0-9]+', classtree[mod][1])[0]) 142 nvdict['md'].__dict__[classtree[mod][0]].__dict__[defname].append(getattr(classtype[mod][1], classtype[mod][0])()) 146 outdeftype = split(r'\.', classtype[mod][0])[0] 147 nvdict['md'].__dict__[classtree[mod][0]].__dict__[defname].append(getattr(classtype[mod][1], outdeftype)()) 143 148 Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[defname][defindex - 1] 144 149 #}}} 145 150 else: 146 if debug:151 if verbose > 0: 147 152 print(" Using the default for md.{}.{}, is that right??".format(classtree[mod][0], classtree[mod][1])) 148 153 try: 149 154 modulename = split(r'\.', classtype[mod][0])[0] 150 if debug:155 if verbose > 0: 151 156 print(" trying to import {} from {}".format(classtype[mod][0], modulename)) 152 157 nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = getattr(classtype[mod][1], modulename)() … … 154 159 print("WARNING: md.{}.{} is not initialized, hopefully that was done in the main group:".format(classtree[mod][0], classtree[mod][1])) 155 160 Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] 161 elif classtype[mod][0] == 'SMBgemb.SMBgemb': 162 curclass = NCFile.groups[classtree[mod][0]] 163 modulename = split(r'\.', classtype[mod][0])[0] 164 nvdict['md'].__dict__[mod] = getattr(classtype[mod][1], modulename)(nvdict['md'].__dict__['mesh'], nvdict['md'].__dict__['geometry']) 165 Tree = nvdict['md'].__dict__[classtree[mod][0]] 156 166 else: 157 167 curclass = NCFile.groups[classtree[mod][0]] … … 159 169 nvdict['md'].__dict__[mod] = getattr(classtype[mod][1], modulename)() 160 170 Tree = nvdict['md'].__dict__[classtree[mod][0]] 161 if debug:171 if verbose > 0: 162 172 print(" for {} Tree is a {} with len {}".format(mod, Tree.__class__.__name__, len(curclass.groups))) 163 173 # }}} … … 165 175 #for i in range(0, max(1, len(curclass.groups))): 166 176 if len(curclass.groups) > 0: #that is presumably only for old style NC where each result step had its own group 167 if onlylast: 168 groupclass = [curclass.groups[keylist[len(curclass.groups) - 1]]] 177 if timeindex: 178 if timeindex < 0: 179 groupclass = [curclass.groups[keylist[len(curclass.groups) - timeindex]]] 180 else: 181 groupclass = [curclass.groups[keylist[timeindex]]] 169 182 else: 170 183 groupclass = [curclass.groups[key] for key in keylist] … … 174 187 for groupindex, listclass in enumerate(groupclass): 175 188 for var in listclass.variables: 176 if var not in ['errlog', 'outlog']: 177 varval = listclass.variables[str(var)] 178 vardim = varval.ndim 179 if debug: 180 print(" ==> treating var {} of dimension {}".format(var, vardim)) 181 #There is a special treatment for results to account for its specific structure 182 #that is the new export version where time is a named dimension 183 NewFormat = 'Time' in NCFile.dimensions 184 if type(Tree) == list: # and NewFormat: 185 if onlylast: 186 if NewFormat: 187 if vardim == 1: 188 Tree[0].__dict__[str(var)] = varval[-1].data 189 elif vardim == 2: 190 Tree[0].__dict__[str(var)] = varval[-1, :].data 191 elif vardim == 3: 192 Tree[0].__dict__[str(var)] = varval[-1, :, :].data 189 if not resname or var == resname: 190 if var not in ['errlog', 'outlog']: 191 varval = listclass.variables[str(var)] 192 vardim = varval.ndim 193 if verbose > 0: 194 print(" ==> treating var {} of dimension {}".format(var, vardim)) 195 #There is a special treatment for results to account for its specific structure 196 #that is the new export version where time is a named dimension 197 NewFormat = 'Time' in NCFile.dimensions 198 if type(Tree) == list: # and NewFormat: 199 if timeindex: 200 if NewFormat: 201 if vardim == 0: 202 try: 203 Tree[0].__dict__[str(var)] = varval[timeindex].data 204 except IndexError: 205 print('WARNING: No data on index {} for {} reverting to last time.'.format(timeindex, str(var))) 206 Tree[0].__dict__[str(var)] = varval[-1].data 207 elif vardim == 1: 208 try: 209 Tree[0].__dict__[str(var)] = varval[timeindex].data 210 except IndexError: 211 print('WARNING: No data on index {} for {} reverting to last time.'.format(timeindex, str(var))) 212 Tree[0].__dict__[str(var)] = varval[-1].data 213 elif vardim == 2: 214 Tree[0].__dict__[str(var)] = varval[timeindex, :].data 215 elif vardim == 3: 216 Tree[0].__dict__[str(var)] = varval[timeindex, :, :].data 217 else: 218 print('table dimension greater than 3 not implemented yet') 219 else: #old format had step sorted in difeerent group so last group is last time 220 Tree[0].__dict__[str(var)] = varval[:].data 221 else: 222 if NewFormat: 223 incomplete = 'Time' not in varval.dimensions 224 if incomplete: 225 try: 226 chosendim = varval.dimensions[0] 227 timelist = np.arange(0, len(NCFile.dimensions[chosendim])) 228 print('WARNING, {} is not present on every times, we chose {}({}) as the dimension to write it with'.format(var, chosendim, len(NCFile.dimensions[chosendim]))) 229 except IndexError: 230 #just one step, so no dimension, we just put it on the first solutionstep 231 timelist = [0] 232 else: 233 timelist = np.arange(0, len(NCFile.dimensions['Time'])) 234 for t in timelist: 235 if verbose > 5: 236 print("filing step {} for {}".format(t, var)) 237 if vardim == 0: 238 Tree[t].__dict__[str(var)] = varval[:].data 239 elif vardim == 1: 240 stepval = ma.masked_array(varval[t].data, mask=np.where(np.isnan(varval[t]), 1, 0)) 241 Tree[t].__dict__[str(var)] = ma.compressed(stepval) 242 elif vardim == 2: 243 stepval = ma.masked_array(varval[t, :].data, mask=np.where(np.isnan(varval[t, :]), 1, 0)) 244 Tree[t].__dict__[str(var)] = ma.compressed(stepval) 245 elif vardim == 3: 246 stepval = ma.masked_array(varval[t, :, :].data, mask=np.where(np.isnan(varval[t, :, :]), 1, 0)) 247 Tree[t].__dict__[str(var)] = ma.compressed(stepval).reshape((stepval.count(0)[0], stepval.count(1)[0])) 248 else: 249 print('table dimension greater than 3 not implemented yet') 193 250 else: 194 print('table dimension greater than 3 not implemented yet')195 else: #old format had step sorted in difeerent group so last group is last time196 Tree[0].__dict__[str(var)] = varval[:].data251 if verbose > 0: 252 print("filing step {} for {}".format(groupindex, var)) 253 Tree[groupindex].__dict__[str(var)] = varval[:].data 197 254 else: 198 if NewFormat: 199 incomplete = 'Time' not in varval.dimensions and NewFormat 200 if incomplete: 201 chosendim = varval.dimensions[0] 202 timelist = np.arange(0, len(NCFile.dimensions[chosendim])) 203 print('WARNING, {} is not present on every times, we chose {}({}) as the dimension to write it with'.format(var, chosendim, len(NCFile.dimensions[chosendim]))) 255 if vardim == 0: #that is a scalar 256 if str(varval[0]) in ['', '--', 'emptycell']: #no value 257 Tree.__dict__[str(var)] = [] 258 elif varval[0] == 'True': #treatin bool 259 Tree.__dict__[str(var)] = True 260 elif varval[0] == 'False': #treatin bool 261 Tree.__dict__[str(var)] = False 204 262 else: 205 timelist = np.arange(0, len(NCFile.dimensions['Time'])) 206 for t in timelist: 207 if debug: 208 print("filing step {} for {}".format(t, var)) 209 if vardim == 0: 210 Tree[t].__dict__[str(var)] = varval[:].data 211 elif vardim == 1: 212 Tree[t].__dict__[str(var)] = varval[t].data 213 elif vardim == 2: 214 Tree[t].__dict__[str(var)] = varval[t, :].data 215 elif vardim == 3: 216 Tree[t].__dict__[str(var)] = varval[t, :, :].data 217 else: 218 print('table dimension greater than 3 not implemented yet') 263 Tree.__dict__[str(var)] = varval[0].item() 264 265 elif vardim == 1: #that is a vector 266 if verbose > 0: 267 print(" for variable {} type is {}".format(str(var), varval.dtype)) 268 if varval.dtype == str: 269 if varval.shape[0] == 1: 270 Tree.__dict__[str(var)] = [str(varval[0]), ] 271 elif 'True' in varval[:] or 'False' in varval[:]: 272 Tree.__dict__[str(var)] = np.asarray([V == 'True' for V in varval[:]], dtype=bool) 273 else: 274 Tree.__dict__[str(var)] = [str(vallue) for vallue in varval[:]] 275 elif varval.dtype == "|S1": #that is for matlab chararcter arrays 276 stringlist = chartostring(varval[:]) 277 Tree.__dict__[str(var)] = [stringlist.tolist(), ] 278 else: 279 try: 280 #some thing specifically require a list 281 mdtype = type(Tree.__dict__[str(var)]) 282 except KeyError: 283 mdtype = float 284 if mdtype == list: 285 Tree.__dict__[str(var)] = [mdval for mdval in varval[:]] 286 else: 287 Tree.__dict__[str(var)] = varval[:].data 288 289 elif vardim == 2: 290 #dealling with dict 291 if verbose > 0: 292 print(" for variable {} type is {}".format(str(var), varval.dtype)) 293 if varval.dtype == str: #that is for dictionaries 294 if any(varval[:, 0] == 'toolkit'): #toolkit definition have to be first 295 Tree.__dict__[str(var)] = OrderedDict([('toolkit', str(varval[np.where(varval[:, 0] == 'toolkit')[0][0], 1]))]) 296 strings1 = [str(arg[0]) for arg in varval if arg[0] != 'toolkits'] 297 strings2 = [str(arg[1]) for arg in varval if arg[0] != 'toolkits'] 298 Tree.__dict__[str(var)].update(list(zip(strings1, strings2))) 299 else: 300 strings1 = [str(arg[0]) for arg in varval] 301 strings2 = [str(arg[1]) for arg in varval] 302 Tree.__dict__[str(var)] = OrderedDict(list(zip(strings1, strings2))) 303 elif varval.dtype == "|S1": #that is for matlab chararcter arrays 304 stringlist = chartostring(varval[:, :]) 305 stringlist = [string.strip() for string in stringlist] 306 Tree.__dict__[str(var)] = stringlist 307 else: 308 if type(Tree) == list: 309 t = indexlist[i] 310 if listtype == 'dict': 311 Tree[t][str(var)] = varval[:, :].data 312 else: 313 Tree[t].__dict__[str(var)] = varval[:, :].data 314 else: 315 Tree.__dict__[str(var)] = varval[:, :].data 316 elif vardim == 3: 317 Tree.__dict__[str(var)] = varval[:, :, :].data 219 318 else: 220 if debug: 221 print("filing step {} for {}".format(groupindex, var)) 222 Tree[groupindex].__dict__[str(var)] = varval[:].data 223 else: 224 if vardim == 0: #that is a scalar 225 if str(varval[0]) == '': #no value 226 Tree.__dict__[str(var)] = [] 227 elif varval[0] == 'True': #treatin bool 228 Tree.__dict__[str(var)] = True 229 elif varval[0] == 'False': #treatin bool 230 Tree.__dict__[str(var)] = False 231 else: 232 Tree.__dict__[str(var)] = varval[0].item() 233 234 elif vardim == 1: #that is a vector 235 if varval.dtype == str: 236 if varval.shape[0] == 1: 237 Tree.__dict__[str(var)] = [str(varval[0]), ] 238 elif 'True' in varval[:] or 'False' in varval[:]: 239 Tree.__dict__[str(var)] = np.asarray([V == 'True' for V in varval[:]], dtype=bool) 240 else: 241 Tree.__dict__[str(var)] = [str(vallue) for vallue in varval[:]] 242 else: 243 try: 244 #some thing specifically require a list 245 mdtype = type(Tree.__dict__[str(var)]) 246 except KeyError: 247 mdtype = float 248 if mdtype == list: 249 Tree.__dict__[str(var)] = [mdval for mdval in varval[:]] 250 else: 251 Tree.__dict__[str(var)] = varval[:].data 252 253 elif vardim == 2: 254 #dealling with dict 255 if varval.dtype == str: #that is for dictionaries 256 if any(varval[:, 0] == 'toolkit'): #toolkit definition have to be first 257 Tree.__dict__[str(var)] = OrderedDict([('toolkit', str(varval[np.where(varval[:, 0] == 'toolkit')[0][0], 1]))]) 258 strings1 = [str(arg[0]) for arg in varval if arg[0] != 'toolkits'] 259 strings2 = [str(arg[1]) for arg in varval if arg[0] != 'toolkits'] 260 Tree.__dict__[str(var)].update(list(zip(strings1, strings2))) 261 else: 262 strings1 = [str(arg[0]) for arg in varval] 263 strings2 = [str(arg[1]) for arg in varval] 264 Tree.__dict__[str(var)] = OrderedDict(list(zip(strings1, strings2))) 265 else: 266 if type(Tree) == list: 267 t = indexlist[i] 268 if listtype == 'dict': 269 Tree[t][str(var)] = varval[:, :].data 270 else: 271 Tree[t].__dict__[str(var)] = varval[:, :].data 272 else: 273 Tree.__dict__[str(var)] = varval[:, :].data 274 elif vardim == 3: 275 Tree.__dict__[str(var)] = varval[:, :, :].data 276 else: 277 print('table dimension greater than 3 not implemented yet') 319 print('table dimension greater than 3 not implemented yet') 278 320 # }}} 279 321 #==== And with atribute {{{ 280 322 for attr in listclass.ncattrs(): 281 if debug:323 if verbose > 0: 282 324 print(" ==> treating attribute {}".format(attr)) 283 325 if attr != 'classtype': #classtype is for treatment, don't get it back 284 attribute = str(attr).swapcase() #there is a reason for swapcase, no sure what it isanymore 285 if attr == 'VARNAME': 326 if attr == 'varname': 286 327 attribute = 'name' 328 else: 329 attribute = attr 287 330 if type(Tree) == list: 288 if debug:331 if verbose > 0: 289 332 print(" printing with index 0") 290 333 if listtype == 'dict': … … 293 336 Tree[0].__dict__[attribute] = str(listclass.getncattr(attr)) 294 337 else: 295 Tree.__dict__[attribute] = str(listclass.getncattr(attr))296 338 if listclass.getncattr(attr) == 'True': 297 339 Tree.__dict__[attribute] = True 298 340 elif listclass.getncattr(attr) == 'False': 299 341 Tree.__dict__[attribute] = False 342 elif listclass.getncattr(attr) == 'emptycell': 343 Tree.__dict__[attribute] = [] 344 else: 345 Tree.__dict__[attribute] = str(listclass.getncattr(attr)) 300 346 # }}} 301 347 # }}} … … 328 374 try: 329 375 modulename = split(r'\.', class_dict[classe][0])[0] 330 class_dict[classe].append( __import__(modulename))376 class_dict[classe].append(import_module(modulename)) 331 377 except ModuleNotFoundError: 332 378 #submodule probably has a different name 333 379 modulename = str(getattr(NCData.groups[group].groups[subgroup], 'classtype')) 334 380 print("WARNING importing {} rather than {}".format(modulename, class_dict[classe][0])) 335 class_dict[classe].append( __import__(modulename))381 class_dict[classe].append(import_module(modulename)) 336 382 class_tree[classe] = [group, subgroup] 337 383 else: … … 344 390 print("WARNING: module {} does not exist anymore and is skipped".format(modulename)) 345 391 else: 346 class_dict[classe].append( __import__(modulename))392 class_dict[classe].append(import_module(modulename)) 347 393 class_tree[classe] = [group, ] 348 394 except AttributeError: -
issm/trunk/src/m/mesh/meshconvert.m
r17806 r27035 40 40 md.mesh.numberofedges = size(md.mesh.edges,1); 41 41 md.mesh.vertexonboundary = zeros(md.mesh.numberofvertices,1); md.mesh.vertexonboundary(md.mesh.segments(:,1:2)) = 1; 42 md.mesh.elementconnectivity=md.private.bamg.mesh.ElementConnectivity; 43 md.mesh.elementconnectivity(find(isnan(md.mesh.elementconnectivity)))=0; -
issm/trunk/src/m/mesh/roundmesh.m
r22758 r27035 1 function md=roundmesh(md,radius,resolution )1 function md=roundmesh(md,radius,resolution,varargin) 2 2 %ROUNDMESH - create an unstructured round mesh 3 3 % … … 8 8 % Usage: 9 9 % md=roundmesh(md,radius,resolution) 10 % md=roundmesh(md,radius,resolution,'domain.exp') 10 11 11 12 %First we have to create the domain outline 12 expname = [tempname() '.exp']; 13 if nargin<4 14 expname = [tempname() '.exp']; 15 else 16 expname = varargin{1}; 17 end 13 18 14 19 %Get number of points on the circle … … 32 37 33 38 %delete domain 34 delete(expname); 39 if nargin<4 40 delete(expname); 41 end 35 42 end 36 43 -
issm/trunk/src/m/mesh/roundmesh.py
r24686 r27035 26 26 y_list = roundsigfig(radius * np.sin(theta), 12) 27 27 A = OrderedDict() 28 A['x'] = [x_list]29 A['y'] = [y_list]28 A['x'] = x_list 29 A['y'] = y_list 30 30 A['density'] = 1. 31 31 expwrite(A, 'RoundDomainOutline.exp') -
issm/trunk/src/m/miscellaneous/MatlabFuncs.py
r26744 r27035 2 2 functions of the same, respective name. 3 3 4 Where possible, users are encouraged to use native and/or the most efficient 5 methods in Python, but we provide these functions as a way to make translations 4 Where possible, users are encouraged to use native and/or the most efficient 5 methods in Python, but we provide these functions as a way to make translations 6 6 from the MATLAB to the Python ISSM API more seamless. 7 7 """ … … 82 82 83 83 def cosdsingle(x): # {{{ 84 """function cosdsingle - Helper function for cosd to reduce repetition of 84 """function cosdsingle - Helper function for cosd to reduce repetition of 85 85 logic 86 86 … … 162 162 NOTE: 163 163 - Only the following functionality is currently implemented: 164 - C = intersect(A,B) returns the data common to both A and B, with no 164 - C = intersect(A,B) returns the data common to both A and B, with no 165 165 repetitions. C is in sorted order. 166 166 … … 175 175 176 176 NOTE: 177 - Takes a type as its second argument (in contrast to the MATLAB function 177 - Takes a type as its second argument (in contrast to the MATLAB function 178 178 that it replicates, which takes a string representing the name of a type) 179 179 """ … … 204 204 def ismember(a, s): # {{{ 205 205 import numpy as np 206 207 206 if not isinstance(s, (tuple, list, dict, np.ndarray)): 208 207 s = [s] … … 215 214 else: 216 215 if not isinstance(s, np.ndarray): 217 b = np.empty_like(a) 216 b = np.empty_like(a).flat 218 217 for i, item in enumerate(a.flat): 219 b .flat[i] = item in s218 b[i] = item in s 220 219 else: 221 220 b = np.in1d(a.flat, s.flat).reshape(a.shape) 222 223 221 return b 224 222 # }}} … … 272 270 def oshostname(): # {{{ 273 271 import socket 274 275 return socket.gethostname() 272 hostname = socket.gethostname() 273 274 return hostname.lower() 276 275 # }}} 277 276 … … 298 297 299 298 def sindsingle(x): # {{{ 300 """function sindsingle - Helper function for sind to reduce repetition of 299 """function sindsingle - Helper function for sind to reduce repetition of 301 300 logic 302 301 -
issm/trunk/src/m/miscellaneous/diagnostics.m
r25836 r27035 35 35 %grounding line : 36 36 if getfieldvalue(options,'gl',0), 37 contours= contourlevelzero(md,md.mask.ocean_levelset,0);37 contours=isoline(md,md.mask.ocean_levelset); 38 38 expwrite(contours,[path '/groundingline.exp']); 39 39 exp2shp([path '/groundingline.shp'],[path '/groundingline.exp']); -
issm/trunk/src/m/miscellaneous/fielddisplay.py
r25836 r27035 110 110 111 111 112 def displayunit(offset, name, characterization, comment): #{{{112 def displayunit(offset, name, characterization, comment): #{{{ 113 113 #take care of name 114 114 if len(name) > 23: … … 116 116 117 117 #take care of characterization 118 if m.strcmp(characterization, "''") or m.strcmp(characterization, '""') or m.strcmpi(characterization, 'nan'):118 if characterization in ["''", '""', 'nan', np.nan, 'NaN', "[0x1]"]: 119 119 characterization = "N/A" 120 120 -
issm/trunk/src/m/modules/CoordTransform.m
r26744 r27035 4 4 % Usage: 5 5 % [xout,yout] = CoordTransform(xin,yin,projin,projout) 6 % 7 % xin, yin : input coordinates 8 % xout, yout: output coordinates (in new projection) 9 % projin,projout: input/output projection string (PROJ) 6 % - xin, yin : input coordinates 7 % - xout, yout: output coordinates (in new projection) 8 % - projin,projout: input/output projection string (PROJ) 9 % 10 % Examples: 11 % [md.mesh.lat md.mesh.long] = CoordTransform(md.mesh.x, md.mesh.y, 'EPSG:3413','EPSG:4326'); 12 % [md.mesh.x md.mesh.y] = CoordTransform(md.mesh.lat,md.mesh.long,'EPSG:4326','EPSG:3413'); 10 13 % 11 14 % Example of Projections: 15 % lat/lon = 'EPSG:4326' or lat/lon = '+proj=longlat +datum=WGS84' 16 % Greenland = 'EPSG:3413' (polar stereographic 70N 45W) 17 % Antarctica = 'EPSG:3031' (polar stereographic 71S 0E) 18 % 19 % ll2xy previous default equivalent (uses with Hugues Ellispoid S) 20 % Greenland = '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.448564109 +units=m +no_defs' 21 % Antarctica = '+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.448564109 +units=m +no_defs' 22 % Bamber Greenland = '+proj=stere +lat_0=90 +lat_ts=71 +lon_0=-39 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs' 12 23 % 13 % lat/lon = '+init=epsg:4326' 14 % lat/lon = '+proj=longlat +datum=WGS84' 15 % 16 % ll2xy default equivalent (uses with Hugues Ellispoid S) 17 % Greenland = '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.448564109 +units=m +no_defs' 18 % Antarctica = '+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.448564109 +units=m +no_defs' 19 % Bamber Greenland = '+proj=stere +lat_0=90 +lat_ts=71 +lon_0=-39 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs' 20 % 21 % For latitude/longitude, x is longitude and y latitude and the angles are in 22 % rad 23 % 24 % This function will only work if PROJ has been installed and --with-proj-dir 24 % This function will only work if PROJ has been installed and --with-proj-dir 25 25 % option has been set to its location in ISSM configuration 26 26 -
issm/trunk/src/m/os/issmscpin.py
r26744 r27035 22 22 pass 23 23 #if hostname and host are the same, do a simple copy 24 if hostname == host:24 if strcmpi(hostname, host): #hostname == host: 25 25 for package in packages: 26 26 try: -
issm/trunk/src/m/os/issmscpout.py
r26744 r27035 1 1 import os 2 from socket import gethostname3 2 import subprocess 4 3 from MatlabFuncs import * … … 17 16 #if hostname and host are the same, do a simple copy 18 17 19 if host == hostname:18 if strcmpi(host, hostname): #host == hostname: 20 19 for package in packages: 21 20 here = os.getcwd() -
issm/trunk/src/m/os/issmssh.py
r26744 r27035 37 37 subprocess.call('ssh -l %s -p %d localhost "%s"' % (login, port, command), shell=True) 38 38 else: 39 subprocess.call('ssh -l %s %s "%s"' %(login, host, command), shell=True)39 subprocess.call('ssh -l {} {} "{}"'.format(login, host, command), shell=True) 40 40 41 41 # The following code was added to fix: -
issm/trunk/src/m/parameterization/killberg.m
r25836 r27035 25 25 %do not go through elements that are grounded, mark flag as 1 (done) need at least 2 vertices! 26 26 %and initialize mask as 1 for all vertices of these elements 27 isgrounded=(sum(md.mask.ocean_levelset(md.mesh.elements)>0,2)> 1);27 isgrounded=(sum(md.mask.ocean_levelset(md.mesh.elements)>0,2)>2); 28 28 %isgrounded = max(md.mask.ocean_levelset(md.mesh.elements),[],2)>0; 29 29 pos = find(isgrounded); 30 element_flag(pos) = 1;30 %element_flag(pos) = 1; 31 31 mask(md.mesh.elements(pos,:)) = 1; 32 mask(md.mask.ice_levelset>=0) = 0; 32 33 33 34 iter = 1; -
issm/trunk/src/m/parameterization/reinitializelevelset.m
r24686 r27035 15 15 16 16 %First: extract segments 17 contours= contourlevelzero(md,levelset,0);17 contours=isoline(md,levelset,'value',0); 18 18 19 19 %Now, make this a distance field (might not be closed) -
issm/trunk/src/m/parameterization/setflowequation.js
r25836 r27035 3 3 // 4 4 // This routine works like plotmodel: it works with an even number of inputs 5 // 'SIA','SSA','L1L2','M LHO','HO','FS' and 'fill' are the possible options5 // 'SIA','SSA','L1L2','MOLHO','HO','FS' and 'fill' are the possible options 6 6 // that must be followed by the corresponding exp file or flags list 7 7 // It can either be a domain file (argus type, .exp extension), or an array of element flags. … … 11 11 // a string 'all' will be considered as the entire domain 12 12 // You can specify the type of coupling, 'penalties' or 'tiling', to use with the input 'coupling' 13 // NB: L1L2 and M LHO cannot currently be coupled to any other ice flow model13 // NB: L1L2 and MOLHO cannot currently be coupled to any other ice flow model 14 14 // 15 15 // Usage: … … 38 38 HOflag = FlagElements(md,options.getfieldvalue('HO','')); 39 39 L1L2flag = FlagElements(md,options.getfieldvalue('L1L2','')); 40 M LHOflag = FlagElements(md,options.getfieldvalue('MLHO',''));40 MOLHOflag = FlagElements(md,options.getfieldvalue('MOLHO','')); 41 41 FSflag = FlagElements(md,options.getfieldvalue('FS','')); 42 42 filltype = options.getfieldvalue('fill','none'); … … 55 55 56 56 //check that each element has at least one flag 57 for(var i=0;i<md.mesh.numberofelements;i++)if((SIAflag[i] + SSAflag[i] + HOflag[i] + L1L2flag[i] + M LHOflag[i] + FSflag[i])==0)57 for(var i=0;i<md.mesh.numberofelements;i++)if((SIAflag[i] + SSAflag[i] + HOflag[i] + L1L2flag[i] + MOLHOflag[i] + FSflag[i])==0) 58 58 throw Error("elements type not assigned, supported models are 'SIA','SSA','HO' and 'FS'"); 59 59 60 60 //check that each element has only one flag 61 if (ArrayAnyAboveStrict(ArrayXPY(SIAflag,SSAflag,HOflag,L1L2flag,M LHOflag),1)){61 if (ArrayAnyAboveStrict(ArrayXPY(SIAflag,SSAflag,HOflag,L1L2flag,MOLHOflag),1)){ 62 62 console.log('setflowequation warning message: some elements have several types, higher order type is used for them') 63 63 … … 71 71 //check that L1L2 is not coupled to any other model for now 72 72 if (ArrayAnyEqual(L1L2flag,1) & ArrayAnyEqual(ArrayOr(SIAflag,SSAflag,HOflag,FSflag),1)) throw Error('L1L2 cannot be coupled to any other model'); 73 if (ArrayAnyEqual(M LHOflag,1) & ArrayAnyEqual(ArrayOr(SIAflag,SSAflag,HOflag,FSflag),1)) throw Error('MLHO cannot be coupled to any other model');73 if (ArrayAnyEqual(MOLHOflag,1) & ArrayAnyEqual(ArrayOr(SIAflag,SSAflag,HOflag,FSflag),1)) throw Error('MOLHO cannot be coupled to any other model'); 74 74 75 75 //Check that no HO or FS for 2d mesh … … 100 100 for(var i=0;i<pos.length;i++) for(var j=0;j<md.mesh.elements[0].length;j++) nodeonL1L2[md.mesh.elements[pos[i]][j]-1]=1; 101 101 102 nodeonM LHO=NewArrayFill(md.mesh.numberofvertices,0);103 pos=ArrayFind(M LHOflag,1);104 for(var i=0;i<pos.length;i++) for(var j=0;j<md.mesh.elements[0].length;j++) nodeonM LHO[md.mesh.elements[pos[i]][j]-1]=1;102 nodeonMOLHO=NewArrayFill(md.mesh.numberofvertices,0); 103 pos=ArrayFind(MOLHOflag,1); 104 for(var i=0;i<pos.length;i++) for(var j=0;j<md.mesh.elements[0].length;j++) nodeonMOLHO[md.mesh.elements[pos[i]][j]-1]=1; 105 105 106 106 nodeonFS=NewArrayFill(md.mesh.numberofvertices,0); … … 262 262 pos=ArrayFind(SSAflag,1);for(var i=0;i<pos.length;i++)md.flowequation.element_equation[pos[i]]=2; 263 263 pos=ArrayFind(L1L2flag,1);for(var i=0;i<pos.length;i++)md.flowequation.element_equation[pos[i]]=3; 264 pos=ArrayFind(M LHOflag,1);for(var i=0;i<pos.length;i++)md.flowequation.element_equation[pos[i]]=4;264 pos=ArrayFind(MOLHOflag,1);for(var i=0;i<pos.length;i++)md.flowequation.element_equation[pos[i]]=4; 265 265 pos=ArrayFind(HOflag,1);for(var i=0;i<pos.length;i++)md.flowequation.element_equation[pos[i]]=5; 266 266 pos=ArrayFind(FSflag,1);for(var i=0;i<pos.length;i++)md.flowequation.element_equation[pos[i]]=6; … … 281 281 pos=ArrayFind(nodeonSSA,1);for(var i=0;i<pos.length;i++)md.flowequation.vertex_equation[pos[i]]=2; 282 282 pos=ArrayFind(nodeonL1L2,1);for(var i=0;i<pos.length;i++)md.flowequation.vertex_equation[pos[i]]=3; 283 pos=ArrayFind(nodeonM LHO,1);for(var i=0;i<pos.length;i++)md.flowequation.vertex_equation[pos[i]]=4;283 pos=ArrayFind(nodeonMOLHO,1);for(var i=0;i<pos.length;i++)md.flowequation.vertex_equation[pos[i]]=4; 284 284 pos=ArrayFind(nodeonHO,1);for(var i=0;i<pos.length;i++)md.flowequation.vertex_equation[pos[i]]=5; 285 285 pos=ArrayFind(nodeonFS,1);for(var i=0;i<pos.length;i++)md.flowequation.vertex_equation[pos[i]]=6; … … 301 301 md.flowequation.isSSA = ArrayAnyEqual(md.flowequation.element_equation,2); 302 302 md.flowequation.isL1L2 = ArrayAnyEqual(md.flowequation.element_equation,3); 303 md.flowequation.isM LHO = ArrayAnyEqual(md.flowequation.element_equation,4);303 md.flowequation.isMOLHO = ArrayAnyEqual(md.flowequation.element_equation,4); 304 304 md.flowequation.isHO = ArrayAnyEqual(md.flowequation.element_equation,5); 305 305 md.flowequation.isFS = ArrayAnyEqual(md.flowequation.element_equation,6); -
issm/trunk/src/m/parameterization/setflowequation.m
r26744 r27035 3 3 % 4 4 % This routine works like plotmodel: it works with an even number of inputs 5 % 'SIA','SSA','L1L2','M LHO','HO','FS' and 'fill' are the possible options5 % 'SIA','SSA','L1L2','MOLHO','HO','FS' and 'fill' are the possible options 6 6 % that must be followed by the corresponding exp file or flags list 7 7 % It can either be a domain file (argus type, .exp extension), or an array of element flags. … … 11 11 % a string 'all' will be considered as the entire domain 12 12 % You can specify the type of coupling, 'penalties' or 'tiling', to use with the input 'coupling' 13 % NB: L1L2 and M LHO cannot currently be coupled to any other ice flow model13 % NB: L1L2 and MOLHO cannot currently be coupled to any other ice flow model 14 14 % 15 15 % Usage: … … 39 39 HOflag = FlagElements(md,getfieldvalue(options,'HO','')); 40 40 L1L2flag = FlagElements(md,getfieldvalue(options,'L1L2','')); 41 M LHOflag = FlagElements(md,getfieldvalue(options,'MLHO',''));41 MOLHOflag = FlagElements(md,getfieldvalue(options,'MOLHO','')); 42 42 FSflag = FlagElements(md,getfieldvalue(options,'FS','')); 43 43 filltype = getfieldvalue(options,'fill','none'); … … 54 54 55 55 %check that each element has at least one flag 56 if any(SIAflag+SSAflag+HOflag+L1L2flag+M LHOflag+FSflag==0),56 if any(SIAflag+SSAflag+HOflag+L1L2flag+MOLHOflag+FSflag==0), 57 57 error('elements type not assigned, supported models are ''SIA'',''SSA'',''HO'' and ''FS''') 58 58 end 59 59 60 60 %check that each element has only one flag 61 if any(SIAflag+SSAflag+HOflag+L1L2flag+M LHOflag+FSflag>1),61 if any(SIAflag+SSAflag+HOflag+L1L2flag+MOLHOflag+FSflag>1), 62 62 disp('setflowequation.m: Warning: some elements have several types, higher order type is used for them') 63 63 SIAflag(find(SIAflag & SSAflag))=0; … … 70 70 error('L1L2 cannot be coupled to any other model'); 71 71 end 72 if any(M LHOflag) & any(SIAflag | SSAflag | HOflag | FSflag)73 error('M LHO cannot be coupled to any other model');72 if any(MOLHOflag) & any(SIAflag | SSAflag | HOflag | FSflag) 73 error('MOLHO cannot be coupled to any other model'); 74 74 end 75 75 … … 91 91 nodeonHO=zeros(md.mesh.numberofvertices,1); nodeonHO(md.mesh.elements(find(HOflag),:))=1; 92 92 nodeonL1L2=zeros(md.mesh.numberofvertices,1); nodeonL1L2(md.mesh.elements(find(L1L2flag),:))=1; 93 nodeonM LHO=zeros(md.mesh.numberofvertices,1); nodeonMLHO(md.mesh.elements(find(MLHOflag),:))=1;93 nodeonMOLHO=zeros(md.mesh.numberofvertices,1); nodeonMOLHO(md.mesh.elements(find(MOLHOflag),:))=1; 94 94 nodeonFS=zeros(md.mesh.numberofvertices,1); 95 95 noneflag=zeros(md.mesh.numberofelements,1); … … 248 248 md.flowequation.element_equation(find(SSAflag))=2; 249 249 md.flowequation.element_equation(find(L1L2flag))=3; 250 md.flowequation.element_equation(find(M LHOflag))=4;250 md.flowequation.element_equation(find(MOLHOflag))=4; 251 251 md.flowequation.element_equation(find(HOflag))=5; 252 252 md.flowequation.element_equation(find(FSflag))=6; … … 264 264 pos=find(nodeonSSA); md.flowequation.vertex_equation(pos)=2; 265 265 pos=find(nodeonL1L2); md.flowequation.vertex_equation(pos)=3; 266 pos=find(nodeonM LHO); md.flowequation.vertex_equation(pos)=4;266 pos=find(nodeonMOLHO); md.flowequation.vertex_equation(pos)=4; 267 267 pos=find(nodeonHO); md.flowequation.vertex_equation(pos)=5; 268 268 pos=find(nodeonFS); md.flowequation.vertex_equation(pos)=6; … … 287 287 md.flowequation.isSSA = double(any(md.flowequation.element_equation == 2)); 288 288 md.flowequation.isL1L2 = double(any(md.flowequation.element_equation == 3)); 289 md.flowequation.isM LHO = double(any(md.flowequation.element_equation == 4));289 md.flowequation.isMOLHO = double(any(md.flowequation.element_equation == 4)); 290 290 md.flowequation.isHO = double(any(md.flowequation.element_equation == 5)); 291 291 md.flowequation.isFS = double(any(md.flowequation.element_equation == 6)); -
issm/trunk/src/m/parameterization/setflowequation.py
r26744 r27035 9 9 10 10 This routine works like plotmodel: it works with an even number of inputs 11 'SIA', 'SSA', 'HO', 'L1L2', 'M LHO', 'FS' and 'fill' are the possible11 'SIA', 'SSA', 'HO', 'L1L2', 'MOLHO', 'FS' and 'fill' are the possible 12 12 options that must be followed by the corresponding exp file or flags list. 13 13 It can either be a domain file (argus type, .exp extension), or an array of … … 45 45 HOflag = FlagElements(md, options.getfieldvalue('HO', '')) 46 46 L1L2flag = FlagElements(md, options.getfieldvalue('L1L2', '')) 47 M LHOflag = FlagElements(md, options.getfieldvalue('MLHO', ''))47 MOLHOflag = FlagElements(md, options.getfieldvalue('MOLHO', '')) 48 48 FSflag = FlagElements(md, options.getfieldvalue('FS', '')) 49 49 filltype = options.getfieldvalue('fill', 'none') … … 57 57 HOflag = ~SIAflag & ~SSAflag & ~FSflag 58 58 #check that each element has at least one flag 59 if not any(SIAflag + SSAflag + L1L2flag + M LHOflag + HOflag + FSflag):59 if not any(SIAflag + SSAflag + L1L2flag + MOLHOflag + HOflag + FSflag): 60 60 raise TypeError("elements type not assigned, supported models are 'SIA', 'SSA', 'HO' and 'FS'") 61 61 62 62 #check that each element has only one flag 63 if any(SIAflag + SSAflag + L1L2flag + M LHOflag + HOflag + FSflag > 1):63 if any(SIAflag + SSAflag + L1L2flag + MOLHOflag + HOflag + FSflag > 1): 64 64 print('Warning: setflowequation.py: some elements have several types, higher order type is used for them') 65 65 SIAflag[np.where(np.logical_and(SIAflag, SSAflag))] = False … … 67 67 SSAflag[np.where(np.logical_and(SSAflag, HOflag))] = False 68 68 69 #check that L1L2 and M LHO is not coupled to any other model for now69 #check that L1L2 and MOLHO is not coupled to any other model for now 70 70 if any(L1L2flag) and any(SIAflag + SSAflag + HOflag + FSflag): 71 71 raise TypeError('L1L2 cannot be coupled to any other model') 72 if any(M LHOflag) and any(SIAflag + SSAflag + HOflag + FSflag):73 raise TypeError('M LHO cannot be coupled to any other model')72 if any(MOLHOflag) and any(SIAflag + SSAflag + HOflag + FSflag): 73 raise TypeError('MOLHO cannot be coupled to any other model') 74 74 75 75 #Check that no HO or FS for 2d mesh … … 89 89 nodeonL1L2 = np.zeros(md.mesh.numberofvertices, bool) 90 90 nodeonL1L2[md.mesh.elements[np.where(L1L2flag), :] - 1] = True 91 nodeonM LHO = np.zeros(md.mesh.numberofvertices, bool)92 nodeonM LHO[md.mesh.elements[np.where(MLHOflag), :] - 1] = True91 nodeonMOLHO = np.zeros(md.mesh.numberofvertices, bool) 92 nodeonMOLHO[md.mesh.elements[np.where(MOLHOflag), :] - 1] = True 93 93 nodeonHO = np.zeros(md.mesh.numberofvertices, bool) 94 94 nodeonHO[md.mesh.elements[np.where(HOflag), :] - 1] = True … … 241 241 md.flowequation.element_equation[np.where(SSAflag)] = 2 242 242 md.flowequation.element_equation[np.where(L1L2flag)] = 3 243 md.flowequation.element_equation[np.where(M LHOflag)] = 4243 md.flowequation.element_equation[np.where(MOLHOflag)] = 4 244 244 md.flowequation.element_equation[np.where(HOflag)] = 5 245 245 md.flowequation.element_equation[np.where(FSflag)] = 6 … … 259 259 pos = np.where(nodeonL1L2) 260 260 md.flowequation.vertex_equation[pos] = 3 261 pos = np.where(nodeonM LHO)261 pos = np.where(nodeonMOLHO) 262 262 md.flowequation.vertex_equation[pos] = 4 263 263 pos = np.where(nodeonHO) … … 283 283 md.flowequation.isSSA = any(md.flowequation.element_equation == 2) 284 284 md.flowequation.isL1L2= any(md.flowequation.element_equation == 3) 285 md.flowequation.isM LHO= any(md.flowequation.element_equation == 4)285 md.flowequation.isMOLHO= any(md.flowequation.element_equation == 4) 286 286 md.flowequation.isHO = any(md.flowequation.element_equation == 5) 287 287 md.flowequation.isFS = any(md.flowequation.element_equation == 6) -
issm/trunk/src/m/plot/applyoptions.py
r25836 r27035 53 53 #title font 54 54 titlefont = font.copy() 55 titlefont[' size'] = titlefontsize56 titlefont[' weight'] = titlefontweight55 titlefont['fontsize'] = titlefontsize 56 titlefont['fontweight'] = titlefontweight 57 57 ax.set_title(title, **titlefont) 58 58 # }}} -
issm/trunk/src/m/plot/plot_elementstype.m
r25836 r27035 37 37 end 38 38 end 39 legend(p,'None','SIA','SSA','L1L2','M LHO','HO',...39 legend(p,'None','SIA','SSA','L1L2','MOLHO','HO',... 40 40 'SSAHO','FS','SSAFS','HOFS'); 41 41 -
issm/trunk/src/m/plot/plot_manager.m
r25836 r27035 129 129 case 'transient_results', 130 130 plot_transient_results(md,options,subplotwidth,i); 131 return 131 132 case 'transient_field', 132 133 plot_transient_field(md,options,subplotwidth,i); 133 134 return; 134 135 otherwise, 135 if ismember(data,properties('model')), 136 if isfield(md.results,'TransientSolution') && isfield(md.results.TransientSolution,data) 137 plot_transient_movie(md,options,subplotwidth,i); 138 return 139 elseif ismember(data,properties('model')), 136 140 data=eval(['md.' data ';']); 137 141 else -
issm/trunk/src/m/plot/plot_transient_movie.m
r25836 r27035 12 12 if exist(options,'transient_movie_field'), 13 13 field=getfieldvalue(options,'transient_movie_field'); 14 elseif ischar(getfieldvalue(options,'data')) 15 field=getfieldvalue(options,'data'); 14 16 else 15 17 disp('List of available fields:'); … … 37 39 steps=[limit(1):limit(end)]; 38 40 elseif exist(options,'transient_movie_steps'), 41 warning('option ''transient_movie_steps'' is now ''steps'', please update your script'); 39 42 steps = getfieldvalue(options,'transient_movie_steps'); 43 elseif exist(options,'steps'), 44 steps = getfieldvalue(options,'steps'); 40 45 else 41 46 steps=1:length(results); 47 end 48 49 %Do we have an output? 50 isavi = 0; 51 isgif = 0; 52 ismp4 = 0; 53 if exist(options,'transient_movie_output'), 54 filename=getfieldvalue(options,'transient_movie_output'); 55 [pathstr,name,ext] = fileparts(filename); 56 if strcmp(ext,'.gif') 57 isgif = 1; 58 elseif strcmp(ext,'.mp4') 59 ismp4 = 1; 60 elseif strcmp(ext,'.avi') 61 isavi = 1; 62 end 63 end 64 if isavi || ismp4 65 vid=VideoWriter([filename(1:end-4),'.avi'],'Motion JPEG AVI'); 66 vid.FrameRate = 2; 67 open(vid); 42 68 end 43 69 … … 53 79 end 54 80 81 82 %Process mesh once for all 83 [x y z elements is2d isplanet]=processmesh(md,results(i).(field),options); 84 55 85 %display movie 56 86 nstep=1; … … 60 90 if ~isempty(results(i).(field)), 61 91 %process data 62 [x y z elements is2d isplanet]=processmesh(md,results(i).(field),options);63 92 [data datatype]=processdata(md,results(i).(field),options); 64 93 65 94 clf; 66 titlestring=[field ' at time ' num2str(results(i).time,'%7.2f') ' year'];95 titlestring=[field ' (time ' num2str(results(i).time,'%7.2f') ' yr)']; 67 96 plot_unit(x,y,z,elements,data,is2d,isplanet,datatype,options) 68 apply_options_movie(md, options,titlestring);97 apply_options_movie(md,data,options,titlestring); 69 98 70 if exist(options,'transient_movie_output'), 71 set(gcf,'Renderer','zbuffer','color','white'); %fixes a bug on Mac OS X (not needed in future Matlab version) 99 %Add grounding line 100 if exist(options,'groundingline') 101 if dimension(md.mesh)==2 102 contours=isoline(md, results(i).MaskOceanLevelset,'output','matrix'); 103 else 104 ocean = project2d(md, results(i).MaskOceanLevelset, 1); 105 contours=isoline(md, ocean,'output','matrix'); 106 end 107 hold on 108 plot(contours(:,1),contours(:,2),getfieldvalue(options,'groundingline')); 109 end 110 111 %Add ice front 112 if exist(options,'icefront') 113 if dimension(md.mesh)==2 114 contours=isoline(md, results(i).MaskIceLevelset,'output','matrix'); 115 else 116 ice = project2d(md, results(i).MaskIceLevelset, 1); 117 contours=isoline(md, ice,'output','matrix'); 118 end 119 hold on 120 plot(contours(:,1),contours(:,2),getfieldvalue(options,'icefront')); 121 end 122 123 if isgif 124 frame=getframe(gcf); 125 im = frame2im(frame); 126 [imind,cmap] = rgb2ind(im,256); 127 if i==1 128 imwrite(imind, cmap, filename, 'DelayTime',getfieldvalue(options,'transient_movie_time',.5), 'LoopCount',inf) 129 else 130 imwrite(imind, cmap, filename, 'WriteMode','append'); 131 end 132 elseif isavi || ismp4 133 F=getframe(gcf); 134 writeVideo(vid, F); 135 end 136 137 if exist(options,'transient_movie_output') 138 %set(gcf,'Renderer','zbuffer','color','white'); %fixes a bug on Mac OS X (not needed in future Matlab version) 72 139 if nstep==1, 73 140 %initialize images and frame … … 87 154 88 155 %output movie if requested. 89 if exist(options,'transient_movie_output'), 90 filename=getfieldvalue(options,'transient_movie_output'); 91 imwrite(images,map,filename,'DelayTime',getfieldvalue(options,'transient_movie_time',2),'LoopCount',inf) 156 if isavi || ismp4 157 close(vid); 158 end 159 if ismp4 160 filename = filename(1:end-4); 161 while(~exist([filename '.avi'])) 162 disp(['Waiting for ' filename '.avi']); 163 pause(1) 164 end 165 command=sprintf('ffmpeg -y -i %s.avi -c:v libx264 -crf 19 -preset slow -c:a libfaac -b:a 192k -ac 2 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" %s.mp4',filename,filename); 166 system(command); 167 end 168 if isgif 169 imwrite(images,map,filename,'DelayTime',getfieldvalue(options,'transient_movie_time',.5),'LoopCount',inf) 92 170 end 93 171 94 172 end %function 95 173 96 function apply_options_movie(md, options,titlestring)174 function apply_options_movie(md,data,options,titlestring) 97 175 %apply options 98 176 options=changefieldvalue(options,'title',titlestring); 99 177 options=addfielddefault(options,'colorbar',1); 100 applyoptions(md, [],options);178 applyoptions(md,data,options); 101 179 end -
issm/trunk/src/m/plot/plot_vertexnumbering.m
r17806 r27035 20 20 21 21 %numbering 22 text(x,y,z,num2str(vertexnumbers),... 23 'backgroundcolor',[0.8 0.9 0.8],'HorizontalAlignment','center','VerticalAlignment','middle'); 22 X = x; 23 Y = y; 24 NUM = vertexnumbers; 25 if exist(options,'axis') 26 AXIS = getfieldvalue(options,'axis'); 27 pos = find(X>AXIS(1) & X<AXIS(2) & Y>AXIS(3) & Y<AXIS(4)); 28 X = X(pos); Y=Y(pos); NUM=NUM(pos); 29 end 30 text(X,Y,num2str(NUM),'backgroundcolor',[0.8 0.9 0.8],'HorizontalAlignment','center','VerticalAlignment','middle'); 24 31 25 32 %Highlight … … 45 52 46 53 %numbering 47 text(x,y,z,num2str(vertexnumbers),... 48 'backgroundcolor',[0.8 0.9 0.8],'HorizontalAlignment','center','VerticalAlignment','middle'); 54 X = x; 55 Y = y; 56 Z = z; 57 NUM = vertexnumbers; 58 if exist(options,'axis') 59 AXIS = getfieldvalue(options,'axis'); 60 pos = find(X>AXIS(1) & X<AXIS(2) & Y>AXIS(3) & Y<AXIS(4)); 61 X = X(pos); Y=Y(pos); Z=Z(pos); NUM=NUM(pos); 62 end 63 text(X,Y,Z,num2str(NUM),'backgroundcolor',[0.8 0.9 0.8],'HorizontalAlignment','center','VerticalAlignment','middle'); 49 64 50 65 %Highlight -
issm/trunk/src/m/shp/shpread.py
r25836 r27035 1 import numpy as np 1 2 from collections import OrderedDict 2 3 from os import path … … 12 13 """SHPREAD - read a shapefile and build a list of shapes 13 14 14 This routine reads a shapefile and builds a list of OrderedDict objects 15 containing the fields x and y corresponding to the coordinates, one for the 16 filename of the shp file, for the density, for the nodes, and a field 17 closed to indicate if the domain is closed. If this initial shapefile is 18 point only, the fields closed and points are ommitted. The first argument 19 is the shapefile to be read and the second argument (optional) indicates if 15 This routine reads a shapefile and builds a list of OrderedDict objects 16 containing the fields x and y corresponding to the coordinates, one for the 17 filename of the shp file, for the density, for the nodes, and a field 18 closed to indicate if the domain is closed. If this initial shapefile is 19 point only, the fields closed and points are ommitted. The first argument 20 is the shapefile to be read and the second argument (optional) indicates if 20 21 the last point shall be read (1 to read it, 0 not to). 21 22 … … 26 27 27 28 Example: 28 From underling PyShp implementation, "The shapefile format is actually 29 a collection of three files. You specify the base filename of the 30 shapefile or the complete filename of any of the shapefile component 29 From underling PyShp implementation, "The shapefile format is actually 30 a collection of three files. You specify the base filename of the 31 shapefile or the complete filename of any of the shapefile component 31 32 files." 32 33 … … 37 38 list = shpread('domainoutline') 38 39 39 "OR any of the other 5+ formats which are potentially part of a 40 shapefile. The library does not care about file extensions". We do, 41 however, check that a file with the base filename or base filename with 40 "OR any of the other 5+ formats which are potentially part of a 41 shapefile. The library does not care about file extensions". We do, 42 however, check that a file with the base filename or base filename with 42 43 .shp extension exists. 43 44 … … 46 47 47 48 NOTE: 48 - OrderedDict objects are used instead of OrderedStruct objects (although 49 addressing in the latter case is closer to the MATLAB struct type) in order 49 - OrderedDict objects are used instead of OrderedStruct objects (although 50 addressing in the latter case is closer to the MATLAB struct type) in order 50 51 to remain consistent with the pattern established by src/m/exp/expread.py. 51 52 52 53 TODO: 53 - Create class that can be used to store and pretty print shape structs 54 - Create class that can be used to store and pretty print shape structs 54 55 (ala OrderedStruct from src/m/qmu/helpers.py). 55 - Convert returned data structure from list of OrderedDict objects to list 56 of OrderedStruct objects and remove corresponding note (see also 56 - Convert returned data structure from list of OrderedDict objects to list 57 of OrderedStruct objects and remove corresponding note (see also 57 58 src/m/exp/expread.py). Also, modify handling of returned data structure in, 58 59 - src/m/classes/basin.py … … 76 77 Structs = [] 77 78 shapes = sf.shapes() 78 for i in range(len(shapes)):79 for i, shape in enumerate(shapes): 79 80 Struct = OrderedDict() 80 shape = shapes[i]81 81 if shape.shapeType == shapefile.POINT: 82 82 Struct['x'] = shape.points[0][0] … … 88 88 x = [] 89 89 y = [] 90 for j in range(num_points): 91 point = shape.points[j] 90 for j, point in enumerate(shape.points): 92 91 x.append(point[0]) 93 92 y.append(point[1]) … … 103 102 x = [] 104 103 y = [] 105 for j in range(num_points): 106 point = shape.points[j] 104 for j, point in enumerate(shape.points): 107 105 x.append(point[0]) 108 106 y.append(point[1]) … … 115 113 Struct['Geometry'] = 'Polygon' 116 114 else: 117 # NOTE: We could do this once before looping over shapes as all 118 # shapes in the file must be of the same type, but we would 119 # need to have a second check anyway in order to know how to 120 # parse the points. So, let's just assume the file is not 115 # NOTE: We could do this once before looping over shapes as all 116 # shapes in the file must be of the same type, but we would 117 # need to have a second check anyway in order to know how to 118 # parse the points. So, let's just assume the file is not 121 119 # malformed. 122 120 # … … 125 123 name = '' 126 124 fields = sf.fields 127 for j in range(1, len(fields)): # skip over first field, which is "DeletionFlag"125 for j in range(1, len(fields)): # skip over first field, which is "DeletionFlag" 128 126 fieldname = fields[j][0] 129 127 # 'id' field gets special treatment 130 if fieldname == 'id':131 name = str(sf.record(i)[j - 1]) # record index is offset by one, again, because of "DeletionFlag"128 if fieldname in ['id', 'fid']: 129 name = str(sf.record(i)[j - 1]) # record index is offset by one, again, because of "DeletionFlag" 132 130 else: 133 setattr(Struct, str(fieldname), sf.record(i)[j - 1]) # cast to string removes "u" from "u'fieldname'"131 setattr(Struct, str(fieldname), sf.record(i)[j - 1]) # cast to string removes "u" from "u'fieldname'" 134 132 Struct['name'] = name 135 133 Structs.append(Struct) -
issm/trunk/src/m/shp/shpwrite.py
r25836 r27035 23 23 24 24 TODO: 25 - Should we check if there is only one element (see how MATLAB's shaperead 25 - Should we check if there is only one element (see how MATLAB's shaperead 26 26 and shapewrite handle single shapes versus multiple shapes)? 27 27 ''' … … 43 43 44 44 for i in range(len(shp)): 45 sf.field('name', 'C') # TODO: Allow shape ids/names to be passed through45 sf.field('name', 'C') # TODO: Allow shape ids/names to be passed through 46 46 if shapeType == 1: # POINT 47 47 sf.point(shp[i].x, shp[i].y) … … 51 51 points.append([shp[i].x[j], shp[i].y[j]]) 52 52 sf.line(line) 53 elif shapeType == 5: # POLYGON53 elif shapeType == 5: # POLYGON 54 54 points = [] 55 55 for j in range(len(shp[i].x)): -
issm/trunk/src/m/solve/parseresultsfromdisk.m
r26744 r27035 244 244 field = field*yts; 245 245 elseif strcmp(fieldname,'BasalforcingsFloatingiceMeltingRate'), 246 field = field*yts; 247 elseif strcmp(fieldname,'BasalforcingsSpatialDeepwaterMeltingRate'), 248 field = field*yts; 249 elseif strcmp(fieldname,'BasalforcingsSpatialUpperwaterMeltingRate'), 246 250 field = field*yts; 247 251 elseif strcmp(fieldname,'TotalFloatingBmb'), -
issm/trunk/src/m/solve/parseresultsfromdisk.py
r26744 r27035 195 195 field = field * yts 196 196 elif fieldname == 'BasalforcingsFloatingiceMeltingRate': 197 field = field * yts 198 elif fieldname == 'BasalforcingsSpatialDeepwaterMeltingRate': 199 field = field * yts 200 elif fieldname == 'BasalforcingsSpatialUpperwaterMeltingRate': 197 201 field = field * yts 198 202 elif fieldname == 'TotalFloatingBmb': -
issm/trunk/src/wrappers/CoordTransform/CoordTransform.cpp
r26744 r27035 65 65 } 66 66 67 PJ *P;68 67 size_t sx = sizeof(double); 69 68 size_t sy = sizeof(double); … … 71 70 size_t ny = size; 72 71 73 P = proj_create_crs_to_crs(PJ_DEFAULT_CTX,projin,projout,NULL);72 PJ* P = proj_create_crs_to_crs(PJ_DEFAULT_CTX,projin,projout,NULL); 74 73 75 if ( 0 == P ){74 if(P==0){ 76 75 proj_destroy(P); 77 _error_(" failed to initialize CRS transformation object");76 _error_("Projection string not recognized"); 78 77 } 79 78 80 79 int p = proj_trans_generic(P, PJ_FWD, xout, sx, nx, yout, sy, ny, 0, 0, 0, 0, 0, 0); 81 80 82 if ( 0 == p){81 if(p==0){ 83 82 proj_destroy(P); 84 _error_(" no successful transformations");83 _error_("projection failed"); 85 84 } 86 85 86 /*Cleanup*/ 87 87 proj_destroy(P); 88 88
Note:
See TracChangeset
for help on using the changeset viewer.