Changeset 23066
- Timestamp:
- 08/07/18 10:22:46 (7 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 112 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/analyses/AdjointHorizAnalysis.cpp
r22105 r23066 1153 1153 /*Clean up and return*/ 1154 1154 xDelete<int>(responses); 1155 1155 1156 1156 }/*}}}*/ 1157 1157 void AdjointHorizAnalysis::GradientJBbarFS(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ … … 2112 2112 IssmDouble *xyz_list= NULL; 2113 2113 2114 2115 2114 /*Fetch number of vertices for this finite element*/ 2116 2115 int numvertices = basalelement->GetNumberOfVertices(); … … 2131 2130 Input* adjointx_input = basalelement->GetInput(AdjointxEnum); _assert_(adjointx_input); 2132 2131 Input* adjointy_input = basalelement->GetInput(AdjointyEnum); _assert_(adjointy_input); 2133 2134 2135 2132 2136 2133 IssmDouble q_exp; … … 2182 2179 Chi = vmag/(pow(C_param,n)*pow(Neff,n)*As); 2183 2180 Gamma = (Chi/(1.+alpha*pow(Chi,q_exp))); 2184 2181 2185 2182 Uder =Neff*C_param/(vmag*vmag*n) * 2186 2183 (Gamma-alpha*q_exp*pow(Chi,q_exp-1.)*Gamma*Gamma* pow(Gamma,(1.-n)/n) - 2187 2184 n* pow(Gamma,1./n)); 2188 2185 2189 2186 /*Build gradient vector (actually -dJ/dD): */ 2190 2187 for(int i=0;i<numvertices;i++){ … … 2318 2315 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 2319 2316 } 2320 2321 2317 2322 2318 /*Fetch number of nodes and dof for this finite element*/ -
issm/trunk-jpl/src/c/analyses/Balancethickness2Analysis.cpp
r22526 r23066 7 7 /*Model processing*/ 8 8 void Balancethickness2Analysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 10 9 11 10 int finiteelement = P1Enum; -
issm/trunk-jpl/src/c/analyses/BalancethicknessAnalysis.cpp
r20690 r23066 594 594 delete gauss; 595 595 596 597 596 }/*}}}*/ 598 597 void BalancethicknessAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ -
issm/trunk-jpl/src/c/analyses/BalancevelocityAnalysis.cpp
r20690 r23066 200 200 } 201 201 202 203 202 /* Start looping on the number of gaussian points: */ 204 203 Gauss* gauss=basalelement->NewGauss(2); -
issm/trunk-jpl/src/c/analyses/DamageEvolutionAnalysis.cpp
r22608 r23066 126 126 /*Add input*/ 127 127 element->AddInput(DamageFEnum,f,element->GetElementType()); 128 128 129 129 /*Clean up and return*/ 130 130 xDelete<IssmDouble>(f); … … 170 170 for (int i=0;i<numnodes;i++){ 171 171 gauss->GaussNode(element->GetElementType(),i); 172 172 173 173 eps_xx_input->GetInputValue(&eps_xx,gauss); 174 174 eps_xy_input->GetInputValue(&eps_xy,gauss); … … 177 177 n_input->GetInputValue(&n,gauss); 178 178 damage_input->GetInputValue(&damage,gauss); 179 179 180 180 /*Calculate principal effective strain rates*/ 181 181 eps1=(eps_xx+eps_yy)/2.+sqrt(pow((eps_xx-eps_yy)/2.,2)+pow(eps_xy,2)); … … 195 195 /*Add input*/ 196 196 element->AddInput(DamageFEnum,f,element->GetElementType()); 197 197 198 198 /*Clean up and return*/ 199 199 xDelete<IssmDouble>(f); … … 262 262 for (int i=0;i<numnodes;i++){ 263 263 gauss->GaussNode(element->GetElementType(),i); 264 264 265 265 damage_input->GetInputValue(&damage,gauss); 266 266 tau_xx_input->GetInputValue(&tau_xx,gauss); … … 314 314 /*Add input*/ 315 315 element->AddInput(DamageFEnum,f,element->GetElementType()); 316 316 317 317 /*Clean up and return*/ 318 318 xDelete<IssmDouble>(f); … … 375 375 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 376 376 element->NodalFunctions(basis,gauss); 377 377 378 378 vx_input->GetInputValue(&vx,gauss); 379 379 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); … … 538 538 } 539 539 540 541 540 /* Start looping on the number of gaussian points: */ 542 541 Gauss* gauss=element->NewGauss(2); -
issm/trunk-jpl/src/c/analyses/EnthalpyAnalysis.cpp
r22511 r23066 103 103 int frictionlaw,basalforcing_model,materialstype; 104 104 int FrictionCoupling; 105 105 106 106 /*Now, is the model 3d? otherwise, do nothing: */ 107 107 if(iomodel->domaintype==Domain2DhorizontalEnum)return; … … 189 189 _error_("not supported"); 190 190 } 191 191 192 192 /*Friction law variables*/ 193 193 switch(frictionlaw){ … … 805 805 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 806 806 element->NodalFunctions(basis,gauss); 807 807 808 808 /*viscous dissipation*/ 809 809 element->ViscousHeating(&phi,xyz_list,gauss,vx_input,vy_input,vz_input); … … 823 823 pressure_input->GetInputDerivativeValue(&d1pressure[0],xyz_list,gauss); 824 824 d2pressure=0.; // for linear elements, 2nd derivative is zero 825 825 826 826 d1H_d1P=0.; 827 827 for(i=0;i<3;i++) d1H_d1P+=d1enthalpypicard[i]*d1pressure[i]; … … 1056 1056 int* basalnodeindices=NULL; 1057 1057 Element* element= NULL; 1058 1058 1059 1059 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 1060 1060 … … 1388 1388 gauss->GaussNode(element->GetElementType(),indices[i]); 1389 1389 gaussup->GaussNode(element->GetElementType(),indicesup[i]); 1390 1390 1391 1391 enthalpy_input->GetInputValue(&enthalpy,gauss); 1392 1392 enthalpy_input->GetInputValue(&enthalpyup,gaussup); -
issm/trunk-jpl/src/c/analyses/EsaAnalysis.cpp
r22609 r23066 40 40 IssmDouble* love_h=NULL; 41 41 IssmDouble* love_l=NULL; 42 42 43 43 IssmDouble* U_elastic = NULL; 44 44 IssmDouble* U_elastic_local = NULL; … … 69 69 U_elastic=xNew<IssmDouble>(M); 70 70 H_elastic=xNew<IssmDouble>(M); 71 71 72 72 /*compute combined legendre + love number (elastic green function:*/ 73 73 m=DetermineLocalSize(M,IssmComm::GetComm()); … … 96 96 97 97 deltalove_U = (love_h[n]-love_h[nl-1]); 98 98 99 99 /*compute legendre polynomials: P_n(cos\theta) & d P_n(cos\theta)/ d\theta: */ 100 100 if(n==0){ … … 199 199 /*Default, do nothing*/ 200 200 return; 201 201 202 202 }/*}}}*/ 203 203 void EsaAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ -
issm/trunk-jpl/src/c/analyses/ExtrapolationAnalysis.cpp
r22461 r23066 145 145 GetB(B,workelement,xyz_list,gauss,dim); 146 146 GetBprime(Bprime,workelement,xyz_list,gauss,dim); 147 147 148 148 D_scalar=gauss->weight*Jdet; 149 149 … … 174 174 else 175 175 for(i=0;i<dim;i++) normal[i]=0.; 176 176 177 177 for(row=0;row<dim;row++) 178 178 for(col=0;col<dim;col++) … … 337 337 /* Get parameters */ 338 338 element->FindParam(&extvar_enum, ExtrapolationVariableEnum); 339 339 340 340 Input* active_input=element->GetInput(IceMaskNodeActivationEnum); _assert_(active_input); 341 341 Input* extvar_input=element->GetInput(extvar_enum); _assert_(extvar_input); -
issm/trunk-jpl/src/c/analyses/GLheightadvectionAnalysis.cpp
r23037 r23066 199 199 } 200 200 201 202 203 201 return; 204 202 }/*}}}*/ -
issm/trunk-jpl/src/c/analyses/HydrologyDCEfficientAnalysis.cpp
r22856 r23066 260 260 basis,1,numnodes,0, 261 261 &Ke->values[0],1); 262 263 262 264 263 /*Transfer EPL part*/ -
issm/trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp
r22902 r23066 213 213 return NULL; 214 214 } 215 216 215 217 216 /*Intermediaries */ … … 504 503 } 505 504 506 507 505 /*Fetch number of nodes for this finite element*/ 508 506 int numnodes = basalelement->GetNumberOfNodes(); -
issm/trunk-jpl/src/c/analyses/HydrologyShaktiAnalysis.cpp
r23020 r23066 295 295 n_input->GetInputValue(&n,gauss); 296 296 A=pow(B,-n); 297 297 298 298 /*Compute beta term*/ 299 299 if(gap<br) … … 324 324 meltrate = 1/latentheat*(G+frictionheat+rho_water*g*conductivity*(dh[0]*dh[0]+dh[1]*dh[1])-PMPheat); 325 325 _assert_(meltrate>0.); 326 326 327 327 for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight* 328 328 ( … … 398 398 /*Calculate effective pressure*/ 399 399 eff_pressure[i] = rho_ice*g*thickness[i] - rho_water*g*(values[i]-bed[i]); 400 400 401 401 if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in solution vector"); 402 402 if(xIsInf<IssmDouble>(values[i])) _error_("Inf found in solution vector"); … … 444 444 reynolds_input->GetInputAverage(&reynolds); 445 445 gap_input->GetInputAverage(&gap); 446 446 447 447 /*Compute conductivity*/ 448 448 IssmDouble conductivity = pow(gap,3)*g/(12.*NU*(1+OMEGA*reynolds)); … … 453 453 }/*}}}*/ 454 454 void HydrologyShaktiAnalysis::UpdateGapHeight(FemModel* femmodel){/*{{{*/ 455 456 455 457 456 for(int j=0;j<femmodel->elements->Size();j++){ … … 547 546 IssmDouble pressure_water = rho_water*g*(head-bed); 548 547 if(pressure_water>pressure_ice) pressure_water = pressure_ice; 549 548 550 549 /* Compute change in sensible heat due to changes in pressure melting point*/ 551 550 dpressure_water[0] = rho_water*g*(dh[0] - dbed[0]); … … 581 580 /*Add new gap as an input*/ 582 581 element->AddInput(HydrologyGapHeightEnum,&newgap,P0Enum); 583 582 584 583 /*Divide by connectivity, add basal flux as an input*/ 585 584 q = q/totalweights; -
issm/trunk-jpl/src/c/analyses/HydrologyShreveAnalysis.cpp
r22284 r23066 379 379 }/*}}}*/ 380 380 381 382 381 /*Needed changes to switch to the Johnson formulation*//*{{{*/ 383 382 /*All the changes are to be done in the velocity computation. -
issm/trunk-jpl/src/c/analyses/LevelsetAnalysis.cpp
r22987 r23066 43 43 } 44 44 } 45 45 46 46 iomodel->FetchDataToInput(elements,"md.mask.ice_levelset",MaskIceLevelsetEnum); 47 47 iomodel->FetchDataToInput(elements,"md.initialization.vx",VxEnum); … … 177 177 178 178 /*Calving threshold*/ 179 179 180 180 /*Fetch number of nodes and dof for this finite element*/ 181 181 int numnodes = basalelement->GetNumberOfNodes(); … … 326 326 } 327 327 break; 328 328 329 329 case CalvingLevermannEnum: 330 330 calvingratex_input->GetInputValue(&c[0],gauss); … … 357 357 } 358 358 break; 359 359 360 360 case CalvingHabEnum: 361 361 lsf_slopex_input->GetInputValue(&dlsf[0],gauss); … … 378 378 } 379 379 break; 380 380 381 381 case CalvingCrevasseDepthEnum: 382 382 lsf_slopex_input->GetInputValue(&dlsf[0],gauss); … … 385 385 386 386 if(groundedice<0) meltingrate = 0.; 387 387 388 388 norm_dlsf=0.; 389 389 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2); … … 516 516 }/*}}}*/ 517 517 ElementVector* LevelsetAnalysis::CreatePVector(Element* element){/*{{{*/ 518 518 519 519 if(!element->IsOnBase()) return NULL; 520 520 Element* basalelement = element->SpawnBasalElement(); … … 525 525 IssmDouble lsf; 526 526 IssmDouble* xyz_list = NULL; 527 527 528 528 /*Fetch number of nodes and dof for this finite element*/ 529 529 int numnodes = basalelement->GetNumberOfNodes(); … … 532 532 ElementVector* pe = basalelement->NewElementVector(); 533 533 basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 534 534 535 535 if(dt!=0.){ 536 536 /*Initialize basis vector*/ … … 623 623 // d=|a x b|/|b| 624 624 // with a=q-s0, b=s1-s0 625 625 626 626 /* Intermediaries */ 627 627 const int dim=2; … … 634 634 b[i]=s1[i]-s0[i]; 635 635 } 636 636 637 637 norm_b=0.; 638 638 for(i=0;i<dim;i++) … … 671 671 IssmDouble bed,water_depth; 672 672 IssmDouble levelset; 673 673 674 674 femmodel->parameters->FindParam(&calvinglaw,CalvingLawEnum); 675 675 … … 703 703 } 704 704 } 705 705 706 706 if(calvinglaw==CalvingHabEnum){ 707 707 … … 709 709 femmodel->elements->InputDuplicate(MaskIceLevelsetEnum, DistanceToCalvingfrontEnum); 710 710 femmodel->DistanceToFieldValue(MaskIceLevelsetEnum,0,DistanceToCalvingfrontEnum); 711 711 712 712 /*Loop over all elements of this partition*/ 713 713 for(int i=0;i<femmodel->elements->Size();i++){ 714 714 Element* element = xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 715 715 716 716 rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 717 717 rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum); … … 744 744 } 745 745 } 746 746 747 747 if(calvinglaw==CalvingCrevasseDepthEnum){ 748 748 749 749 int nflipped,local_nflipped; 750 750 Vector<IssmDouble>* vec_constraint_nodes = NULL; 751 751 IssmDouble* constraint_nodes = NULL; 752 752 753 753 /*Get the DistanceToCalvingfront*/ 754 754 femmodel->elements->InputDuplicate(MaskIceLevelsetEnum,DistanceToCalvingfrontEnum); … … 842 842 gauss->GaussNode(element->GetElementType(),in); 843 843 Node* node=element->GetNode(in); 844 844 845 845 if(constraint_nodes[node->Sid()]>0.){ 846 846 node->ApplyConstraint(0,+1.); -
issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp
r23014 r23066 165 165 iomodel->FetchDataToInput(elements,"md.initialization.vx",VxEnum); 166 166 iomodel->FetchDataToInput(elements,"md.initialization.vy",VyEnum); 167 167 168 168 /*Initialize cumdeltalthickness input*/ 169 169 InputUpdateFromConstantx(elements,0.,SealevelriseCumDeltathicknessEnum); … … 203 203 iomodel->FetchDataToInput(elements,"md.mesh.vertexonsurface",MeshVertexonsurfaceEnum); 204 204 } 205 205 206 206 }/*}}}*/ 207 207 void MasstransportAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ … … 221 221 if(numoutputs)parameters->AddObject(new StringArrayParam(MasstransportRequestedOutputsEnum,requestedoutputs,numoutputs)); 222 222 iomodel->DeleteData(&requestedoutputs,numoutputs,"md.masstransport.requested_outputs"); 223 224 225 223 226 224 }/*}}}*/ … … 805 803 xDelete<IssmDouble>(sealevel); 806 804 xDelete<IssmDouble>(bed); 807 805 808 806 xDelete<int>(doflist); 809 807 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; -
issm/trunk-jpl/src/c/analyses/SealevelriseAnalysis.cpp
r22968 r23066 69 69 IssmDouble* love_k=NULL; 70 70 IssmDouble* love_l=NULL; 71 71 72 72 bool elastic=false; 73 73 IssmDouble* G_elastic = NULL; … … 132 132 #endif 133 133 134 135 134 /*compute combined legendre + love number (elastic green function:*/ 136 135 m=DetermineLocalSize(M,IssmComm::GetComm()); … … 168 167 deltalove_G = (love_k[n]-love_k[nl-1]-love_h[n]+love_h[nl-1]); 169 168 deltalove_U = (love_h[n]-love_h[nl-1]); 170 169 171 170 /*compute legendre polynomials: P_n(cos\theta) & d P_n(cos\theta)/ d\theta: */ 172 171 if(n==0){ … … 230 229 xDelete<IssmDouble>(H_elastic_local); 231 230 } 232 231 233 232 /*Transitions: */ 234 233 iomodel->FetchData(&transitions,&transitions_M,&transitions_N,&ntransitions,"md.slr.transitions"); … … 250 249 iomodel->DeleteData(&requestedoutputs,numoutputs,"md.slr.requested_outputs"); 251 250 252 253 251 }/*}}}*/ 254 252 -
issm/trunk-jpl/src/c/analyses/SmbAnalysis.cpp
r22852 r23066 19 19 }/*}}}*/ 20 20 void SmbAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 21 21 22 22 int smb_model; 23 23 bool isdelta18o,ismungsm,isd18opd,issetpddfac,isprecipscaled,istemperaturescaled; 24 24 25 25 /*Update elements: */ 26 26 int counter=0; … … 32 32 } 33 33 } 34 34 35 35 /*Figure out smb model: */ 36 36 iomodel->FindConstant(&smb_model,"md.smb.model"); 37 37 38 38 switch(smb_model){ 39 39 case SMBforcingEnum: … … 142 142 _error_("Surface mass balance model "<<EnumToStringx(smb_model)<<" not supported yet"); 143 143 } 144 145 146 144 147 145 }/*}}}*/ … … 154 152 IssmDouble *temp = NULL; 155 153 int N,M; 156 154 157 155 parameters->AddObject(iomodel->CopyConstantObject("md.smb.model",SmbEnum)); 158 156 159 157 iomodel->FindConstant(&smb_model,"md.smb.model"); 160 158 iomodel->FindConstant(&interp,"md.timestepping.interp_forcings"); 161 159 162 160 switch(smb_model){ 163 161 case SMBforcingEnum: … … 198 196 parameters->AddObject(new TransientParam(SmbPfacEnum,&temp[0],&temp[M],interp,M)); 199 197 iomodel->DeleteData(temp,"md.smb.Pfac"); 200 198 201 199 iomodel->FetchData(&temp,&N,&M,"md.smb.Tdiff"); _assert_(N==2); 202 200 parameters->AddObject(new TransientParam(SmbTdiffEnum,&temp[0],&temp[M],interp,M)); … … 266 264 /*Figure out smb model: */ 267 265 femmodel->parameters->FindParam(&smb_model,SmbEnum); 268 266 269 267 /*branch to correct module*/ 270 268 switch(smb_model){ -
issm/trunk-jpl/src/c/analyses/SmoothAnalysis.cpp
r18930 r23066 153 153 } 154 154 155 156 155 /* Start looping on the number of gaussian points: */ 157 156 Gauss* gauss=element->NewGauss(2); … … 161 160 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 162 161 element->NodalFunctions(basis,gauss); 163 164 162 165 163 switch(input_enum){ -
issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp
r23014 r23066 2736 2736 } 2737 2737 2738 2739 2738 /*Clean-up*/ 2740 2739 xDelete<IssmDouble>(dbasis); -
issm/trunk-jpl/src/c/analyses/StressbalanceVerticalAnalysis.cpp
r22576 r23066 29 29 else 30 30 iscoupling = false; 31 32 31 33 32 /*If no coupling, call Regular IoModelToConstraintsx, else, use P1 elements only*/ … … 159 158 ElementMatrix* StressbalanceVerticalAnalysis::CreateKMatrixBase(Element* element){/*{{{*/ 160 159 161 162 160 if(!element->IsOnBase()) return NULL; 163 161 … … 199 197 }/*}}}*/ 200 198 ElementMatrix* StressbalanceVerticalAnalysis::CreateKMatrixSurface(Element* element){/*{{{*/ 201 202 199 203 200 if(!element->IsOnSurface()) return NULL; -
issm/trunk-jpl/src/c/bamg/BamgQuadtree.cpp
r21629 r23066 285 285 int yiv = b->v[k]->i.y; 286 286 287 288 287 int h0 = Norm(xi2,xiv,yi2,yiv); 289 288 -
issm/trunk-jpl/src/c/bamg/Mesh.cpp
r22380 r23066 501 501 int connectivitymax_1=0; 502 502 int verbose=0; 503 503 504 504 /*Check needed pointer*/ 505 505 _assert_(bamgmesh); … … 1034 1034 // s0 tt2 s1 1035 1035 //------------------------------- 1036 1036 1037 1037 /*Intermediaries*/ 1038 1038 Triangle* tt[3]; //the three triangles … … 1158 1158 int verbose=0; 1159 1159 double lminaniso = 1./ (Max(hminaniso*hminaniso,1e-100)); 1160 1160 1161 1161 //Get options 1162 1162 if(bamgopts) verbose=bamgopts->verbose; 1163 1163 1164 1164 //display info 1165 1165 if (verbose > 1) _printf_(" BoundAnisotropy by " << anisomax << "\n"); … … 1854 1854 /*Check pointer*/ 1855 1855 _assert_(bamgopts); 1856 1856 1857 1857 /*Recover options*/ 1858 1858 verbose=bamgopts->verbose; … … 2728 2728 if (verbose>4) _printf_(" Prime Number = "<<PrimeNumber<<"\n"); 2729 2729 if (verbose>4) _printf_(" k0 = "<<k0<<"\n"); 2730 2730 2731 2731 //Build orderedvertices 2732 2732 for (i=0; i<nbv; i++){ … … 2953 2953 void Mesh::MaxSubDivision(BamgOpts* bamgopts,double maxsubdiv) {/*{{{*/ 2954 2954 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/MaxSubDivision)*/ 2955 2955 2956 2956 /*Intermediaries*/ 2957 2957 int verbose=0; … … 3740 3740 void Mesh::SmoothingVertex(BamgOpts* bamgopts,int nbiter,double omega ) { /*{{{*/ 3741 3741 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/SmoothingVertex)*/ 3742 3742 3743 3743 /*Intermediaries*/ 3744 3744 int verbose=0; 3745 3745 3746 3746 /*Get options*/ 3747 3747 if(bamgopts) verbose=bamgopts->verbose; … … 3785 3785 void Mesh::SmoothMetric(BamgOpts* bamgopts,double raisonmax) { /*{{{*/ 3786 3786 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/SmoothMetric)*/ 3787 3787 3788 3788 /*Intermediaries*/ 3789 3789 int verbose=0; … … 4087 4087 int i; 4088 4088 Metric M1(1); 4089 4089 4090 4090 /*Get options*/ 4091 4091 if(bamgopts) verbose=bamgopts->verbose; -
issm/trunk-jpl/src/c/classes/AdaptiveMeshRefinement.cpp
r23065 r23066 101 101 /*Mesh refinement methods*/ 102 102 void AdaptiveMeshRefinement::ExecuteRefinement(double* gl_distance,double* if_distance,double* deviatoricerror,double* thicknesserror,int** pdatalist,double** pxylist,int** pelementslist){/*{{{*/ 103 103 104 104 /*IMPORTANT! pelementslist are in Matlab indexing*/ 105 105 /*NEOPZ works only in C indexing*/ … … 118 118 /*Intermediaries*/ 119 119 bool verbose=VerboseSolution(); 120 120 121 121 /*Execute refinement*/ 122 122 this->RefineMeshOneLevel(verbose,gl_distance,if_distance,deviatoricerror,thicknesserror); 123 123 124 124 /*Get new geometric mesh in ISSM data structure*/ 125 125 this->GetMesh(this->previousmesh,pdatalist,pxylist,pelementslist); … … 130 130 /*}}}*/ 131 131 void AdaptiveMeshRefinement::RefineMeshOneLevel(bool &verbose,double* gl_distance,double* if_distance,double* deviatoricerror,double* thicknesserror){/*{{{*/ 132 132 133 133 /*Intermediaries*/ 134 134 int nelem =-1; … … 204 204 } 205 205 /*}}}*/ 206 206 207 207 /*Now, detele the special elements{{{*/ 208 208 if(this->refinement_type==1) this->DeleteSpecialElements(verbose,gmesh); … … 216 216 } 217 217 /*}}}*/ 218 218 219 219 /*Unrefinement process: loop over level of refinements{{{*/ 220 220 if(verbose) _printf_("\tunrefinement process...\n"); 221 221 if(verbose) _printf_("\ttotal: "); 222 222 count=0; 223 223 224 224 nelem=gmesh->NElements();//must keep here 225 225 for(int i=0;i<nelem;i++){ … … 266 266 gmesh->BuildConnectivity(); 267 267 /*}}}*/ 268 268 269 269 /*Refinement process: loop over level of refinements{{{*/ 270 270 if(verbose) _printf_("\trefinement process (level max = "<<this->level_max<<")\n"); … … 320 320 * */ 321 321 if(!geoel) _error_("geoel is NULL!\n"); 322 322 323 323 /*Output*/ 324 324 int type=0; 325 325 int count=0; 326 326 327 327 /*Intermediaries*/ 328 328 TPZVec<TPZGeoEl*> sons; 329 329 330 330 /*Loop over neighboors (sides 3, 4 and 5)*/ 331 331 for(int j=3;j<6;j++){ … … 335 335 if(sons.size()>4) count++; //if neighbour's level is > element level+1 336 336 } 337 337 338 338 /*Verify and return*/ 339 339 if(count>1) type=2; 340 340 else type=count; 341 341 342 342 return type; 343 343 } … … 391 391 /*}}}*/ 392 392 void AdaptiveMeshRefinement::RefineMeshToAvoidHangingNodes(bool &verbose,TPZGeoMesh* gmesh){/*{{{*/ 393 393 394 394 /*Now, insert special elements to avoid hanging nodes*/ 395 395 if(verbose) _printf_("\trefining to avoid hanging nodes (total: "); 396 396 397 397 /*Intermediaries*/ 398 398 int nelem=-1; 399 399 int count= 1; 400 400 401 401 while(count>0){ 402 402 nelem=gmesh->NElements();//must keep here … … 468 468 this->index2sid.clear(); this->index2sid.resize(gmesh->NElements()); 469 469 this->sid2index.clear(); 470 470 471 471 /*Fill in the vertex_index2sid vector with non usual index value*/ 472 472 for(int i=0;i<gmesh->NNodes();i++) vertex_index2sid[i]=-1; 473 473 474 474 /*Fill in the this->index2sid vector with non usual index value*/ 475 475 for(int i=0;i<gmesh->NElements();i++) this->index2sid[i]=-1; 476 476 477 477 /*Get elements without sons and fill in the vertex_index2sid with used vertices (indexes) */ 478 478 sid=0; … … 511 511 newmeshXY[2*sid+1] = coords[1]; // Y 512 512 } 513 513 514 514 for(int i=0;i<this->sid2index.size();i++){//over the sid (fill the ISSM elements) 515 515 for(int j=0;j<this->GetNumberOfNodes();j++) { … … 533 533 534 534 detJ=(xb-xa)*(yc-ya)-(xc-xa)*(yb-ya); 535 535 536 536 /*verify and swap, if necessary*/ 537 537 if(detJ<0) { … … 545 545 *pxy = newmeshXY; 546 546 *pelements = newelements; 547 547 548 548 /*Cleanup*/ 549 549 xDelete<long>(vertex_index2sid); … … 554 554 /* IMPORTANT! elements come in Matlab indexing 555 555 NEOPZ works only in C indexing*/ 556 556 557 557 if(nvertices<=0) _error_("Impossible to create initial mesh: nvertices is <= 0!\n"); 558 558 if(nelements<=0) _error_("Impossible to create initial mesh: nelements is <= 0!\n"); … … 561 561 /*Verify and creating initial mesh*/ 562 562 if(this->fathermesh || this->previousmesh) _error_("Initial mesh already exists!"); 563 563 564 564 this->fathermesh = new TPZGeoMesh(); 565 565 this->fathermesh->NodeVec().Resize(nvertices); … … 576 576 this->fathermesh->NodeVec()[i].SetNodeId(i); 577 577 } 578 578 579 579 /*Generate the elements*/ 580 580 long index; … … 604 604 /*}}}*/ 605 605 TPZGeoMesh* AdaptiveMeshRefinement::CreateRefPatternMesh(TPZGeoMesh* gmesh){/*{{{*/ 606 606 607 607 TPZGeoMesh *newgmesh = new TPZGeoMesh(); 608 608 newgmesh->CleanUp(); 609 609 610 610 int nnodes = gmesh->NNodes(); 611 611 int nelem = gmesh->NElements(); … … 617 617 newgmesh->NodeVec().Resize(nnodes); 618 618 for(int i=0;i<nnodes;i++) newgmesh->NodeVec()[i] = gmesh->NodeVec()[i]; 619 619 620 620 //elements 621 621 for(int i=0;i<nelem;i++){ 622 622 TPZGeoEl * geoel = gmesh->Element(i); 623 623 624 624 if(!geoel){ 625 625 index=newgmesh->ElementVec().AllocateNewElement(); … … 627 627 continue; 628 628 } 629 629 630 630 TPZManVector<long> elem(3,0); 631 631 for(int j=0;j<3;j++) elem[j] = geoel->NodeIndex(j); 632 632 633 633 newgmesh->CreateGeoElement(ETriangle,elem,mat,index,reftype); 634 634 newgmesh->ElementVec()[index]->SetId(geoel->Id()); 635 635 636 636 TPZGeoElRefPattern<TPZGeoTriangle>* newgeoel = dynamic_cast<TPZGeoElRefPattern<TPZGeoTriangle>*>(newgmesh->ElementVec()[index]); 637 637 638 638 //old neighbourhood 639 639 const int nsides = TPZGeoTriangle::NSides; … … 654 654 } 655 655 } 656 656 657 657 //inserting in new element 658 658 for(int s = 0; s < nsides; s++){ … … 668 668 tempEl->SetNeighbour(byside, tempSide); 669 669 } 670 670 671 671 long fatherindex = geoel->FatherIndex(); 672 672 if(fatherindex>-1) newgeoel->SetFather(fatherindex); 673 673 674 674 if(!geoel->HasSubElement()) continue; 675 675 676 676 int nsons = geoel->NSubElements(); 677 677 678 678 TPZAutoPointer<TPZRefPattern> ref = gRefDBase.GetUniformRefPattern(ETriangle); 679 679 newgeoel->SetRefPattern(ref); 680 680 681 681 for(int j=0;j<nsons;j++){ 682 682 TPZGeoEl* son = geoel->SubElement(j); … … 690 690 /*Now, build connectivities*/ 691 691 newgmesh->BuildConnectivity(); 692 692 693 693 return newgmesh; 694 694 } … … 705 705 /*}}}*/ 706 706 void AdaptiveMeshRefinement::PrintGMeshVTK(TPZGeoMesh* gmesh,std::ofstream &file,bool matColor){/*{{{*/ 707 707 708 708 file.clear(); 709 709 long nelements = gmesh->NElements(); … … 731 731 MElementType elt = gel->Type(); 732 732 int elNnodes = MElementType_NNodes(elt); 733 733 734 734 size += (1+elNnodes); 735 735 connectivity << elNnodes; 736 736 737 737 for(int t = 0; t < elNnodes; t++) 738 738 { … … 743 743 } 744 744 node << std::endl; 745 745 746 746 actualNode++; 747 747 connectivity << " " << actualNode; 748 748 } 749 749 connectivity << std::endl; 750 750 751 751 int elType = this->GetVTK_ElType(gel); 752 752 type << elType << std::endl; 753 753 754 754 if(matColor == true) 755 755 { … … 760 760 material << gel->Index() << std::endl; 761 761 } 762 762 763 763 nVALIDelements++; 764 764 } … … 790 790 /*}}}*/ 791 791 int AdaptiveMeshRefinement::GetVTK_ElType(TPZGeoEl * gel){/*{{{*/ 792 792 793 793 MElementType pzElType = gel->Type(); 794 794 795 795 int elType = -1; 796 796 switch (pzElType) … … 849 849 DebugStop(); 850 850 } 851 851 852 852 return elType; 853 853 } 854 854 /*}}}*/ 855 -
issm/trunk-jpl/src/c/classes/AmrBamg.cpp
r23065 r23066 34 34 this->deviatoricerror_groupthreshold = -1; 35 35 this->deviatoricerror_maximum = -1; 36 36 37 37 /*Geometry and mesh as NULL*/ 38 38 this->geometry = NULL; … … 137 137 this->options->hmaxVerticesSize[0] = 0; 138 138 this->options->hmaxVerticesSize[1] = 0; 139 139 140 140 /*verify if the metric will be reseted or not*/ 141 141 if(this->keepmetric==0){ … … 155 155 IssmDouble *xylist= xNew<IssmDouble>(nbv*2); 156 156 int* elementslist = xNew<int>(nbt*3); 157 157 158 158 datalist[0] = nbv; 159 159 datalist[1] = nbt; 160 160 161 161 for(int i=0;i<nbv;i++){ 162 162 xylist[2*i] = meshout->Vertices[i*3+0]; 163 163 xylist[2*i+1] = meshout->Vertices[i*3+1]; 164 164 } 165 165 166 166 for(int i=0;i<nbt;i++){ 167 167 elementslist[3*i+0] = reCast<int>(meshout->Triangles[4*i+0]); … … 174 174 *pxylist = xylist; 175 175 *pelementslist = elementslist; 176 176 177 177 /*Cleanup and return*/ 178 178 delete geomout; … … 181 181 182 182 if(!this->options) _error_("AmrBamg->options is NULL!"); 183 183 184 184 this->options->hmin = hmin_in; 185 185 this->options->hmax = hmax_in; -
issm/trunk-jpl/src/c/classes/Cfdragcoeffabsgrad.cpp
r22971 r23066 23 23 #include "../classes/gauss/Gauss.h" 24 24 /*}}}*/ 25 25 26 26 /*Cfdragcoeffabsgrad constructors, destructors :*/ 27 27 Cfdragcoeffabsgrad::Cfdragcoeffabsgrad(){/*{{{*/ … … 40 40 41 41 this->definitionenum=in_definitionenum; 42 42 43 43 this->name = xNew<char>(strlen(in_name)+1); 44 44 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); … … 46 46 this->weights_enum=in_weights_enum; 47 47 this->timepassedflag=in_timepassedflag; 48 48 49 49 this->misfit=0; 50 50 this->lock=0; … … 102 102 /*diverse: */ 103 103 IssmDouble time; 104 104 105 105 /*recover time parameters: */ 106 106 int i; … … 116 116 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 117 117 J=J_sum; 118 118 119 119 timepassedflag = true; 120 120 return J; … … 183 183 return Jelem; 184 184 }/*}}}*/ 185 -
issm/trunk-jpl/src/c/classes/Cfsurfacelogvel.cpp
r22612 r23066 23 23 #include "../classes/gauss/Gauss.h" 24 24 /*}}}*/ 25 25 26 26 /*Cfsurfacelogvel constructors, destructors :*/ 27 27 Cfsurfacelogvel::Cfsurfacelogvel(){/*{{{*/ … … 40 40 41 41 this->definitionenum=in_definitionenum; 42 42 43 43 this->name = xNew<char>(strlen(in_name)+1); 44 44 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); … … 46 46 this->datatime=in_datatime; 47 47 this->timepassedflag=in_timepassedflag; 48 48 49 49 this->misfit=0; 50 50 this->lock=0; … … 100 100 /*}}}*/ 101 101 IssmDouble Cfsurfacelogvel::Response(FemModel* femmodel){/*{{{*/ 102 102 103 103 /*diverse: */ 104 104 IssmDouble time; 105 105 106 106 /*recover time parameters: */ 107 107 femmodel->parameters->FindParam(&time,TimeEnum); … … 112 112 IssmDouble J=0.; 113 113 IssmDouble J_sum=0.; 114 114 115 115 if(datatime<=time && !timepassedflag){ 116 116 for(i=0;i<femmodel->elements->Size();i++){ … … 122 122 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 123 123 J=J_sum; 124 124 125 125 timepassedflag = true; 126 126 return J; … … 139 139 IssmDouble vx,vy,vxobs,vyobs,weight; 140 140 IssmDouble* xyz_list = NULL; 141 141 142 142 /*Get basal element*/ 143 143 if(!element->IsOnSurface()) return 0.; … … 160 160 /* Get node coordinates*/ 161 161 topelement->GetVerticesCoordinates(&xyz_list); 162 162 163 163 /*Get model values*/ 164 164 Input* vx_input =topelement->GetInput(VxEnum); _assert_(vx_input); … … 174 174 if(tempinput->ObjectEnum()!=DatasetInputEnum) _error_("don't know what to do"); 175 175 datasetinput = (DatasetInput*)tempinput; 176 177 176 178 177 /* Start looping on the number of gaussian points: */ … … 222 221 return Jelem; 223 222 }/*}}}*/ 224 -
issm/trunk-jpl/src/c/classes/Cfsurfacesquare.cpp
r22612 r23066 23 23 #include "../classes/gauss/Gauss.h" 24 24 /*}}}*/ 25 25 26 26 /*Cfsurfacesquare constructors, destructors :*/ 27 27 Cfsurfacesquare::Cfsurfacesquare(){/*{{{*/ … … 43 43 44 44 this->definitionenum=in_definitionenum; 45 45 46 46 this->name = xNew<char>(strlen(in_name)+1); 47 47 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); … … 52 52 this->datatime=in_datatime; 53 53 this->timepassedflag=in_timepassedflag; 54 54 55 55 this->misfit=0; 56 56 this->lock=0; … … 111 111 /*diverse: */ 112 112 IssmDouble time; 113 113 114 114 /*recover time parameters: */ 115 115 femmodel->parameters->FindParam(&time,TimeEnum); … … 130 130 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 131 131 J=J_sum; 132 132 133 133 timepassedflag = true; 134 134 return J; … … 172 172 /*Get input if it already exists*/ 173 173 Input* tempinput = topelement->GetInput(definitionenum); 174 174 175 175 /*Cast it to a Datasetinput*/ 176 176 if(tempinput->ObjectEnum()!=DatasetInputEnum) _error_("don't know what to do"); … … 214 214 return Jelem; 215 215 }/*}}}*/ 216 -
issm/trunk-jpl/src/c/classes/Constraints/SpcStatic.cpp
r22361 r23066 37 37 /*Object virtual functions definitions:*/ 38 38 Object* SpcStatic::copy() {/*{{{*/ 39 39 40 40 SpcStatic* spcstat = new SpcStatic(*this); 41 41 -
issm/trunk-jpl/src/c/classes/Dakota/IssmParallelDirectApplicInterface.cpp
r22617 r23066 20 20 int world_rank; 21 21 ISSM_MPI_Comm_rank(ISSM_MPI_COMM_WORLD,&world_rank); 22 22 23 23 /*Build an femmodel if you are a slave, using the corresponding communicator:*/ 24 24 if(world_rank!=0){ … … 33 33 int world_rank; 34 34 ISSM_MPI_Comm_rank(ISSM_MPI_COMM_WORLD,&world_rank); 35 35 36 36 if(world_rank!=0){ 37 37 -
issm/trunk-jpl/src/c/classes/Elements/Element.cpp
r23059 r23066 1105 1105 void Element::GetInputLocalMinMaxOnNodes(IssmDouble* min,IssmDouble* max,IssmDouble* ug){/*{{{*/ 1106 1106 1107 1108 1107 /*Get number of nodes for this element*/ 1109 1108 int numnodes = this->GetNumberOfNodes(); … … 1121 1120 if(ug[nodes[i]->GetDof(0,GsetEnum)] > input_max) input_max = ug[nodes[i]->GetDof(0,GsetEnum)]; 1122 1121 } 1123 1124 1122 1125 1123 /*Second loop to reassign min and max with local extrema*/ … … 1389 1387 _error_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet"); 1390 1388 } 1391 1389 1392 1390 /*Clean up*/ 1393 1391 xDelete<int>(doflist); … … 1476 1474 parameters->FindParam(&num_controls,InversionNumControlParametersEnum); 1477 1475 parameters->FindParam(&isautodiff,AutodiffIsautodiffEnum); 1478 1479 1476 1480 1477 /*Get number of vertices*/ … … 1808 1805 } 1809 1806 1810 1811 1807 /*Branch on type of vector: nodal or elementary: */ 1812 1808 if(vector_type==1){ //nodal vector … … 2067 2063 this->GetInputListOnVertices(deepwaterel,BasalforcingsDeepwaterElevationEnum); 2068 2064 this->GetInputListOnVertices(upperwaterel,BasalforcingsUpperwaterElevationEnum); 2069 2065 2070 2066 for(int i=0;i<numvertices;i++){ 2071 2067 if(base[i]>upperwaterel[i]) values[i]=0; … … 2870 2866 if (!IsOnSurface()) return; 2871 2867 2872 2873 2868 /*Retrieve material properties and parameters:{{{ */ 2874 2869 rho_ice = matpar->GetMaterialParameter(MaterialsRhoIceEnum); … … 3072 3067 if(isalbedo)albedo(&a,aIdx,re,d,cldFrac,aIce,aSnow,aValue,adThresh,T,W,P,EC,t0wet,t0dry,K,smb_dt,rho_ice,m,this->Sid()); 3073 3068 3074 3075 3069 /*Distribution of absorbed short wave radation with depth:*/ 3076 3070 if(isshortwave)shortwave(&swf, swIdx, aIdx, dsw, a[0], d, dz, re,rho_ice,m,this->Sid()); -
issm/trunk-jpl/src/c/classes/Elements/ElementHook.cpp
r22004 r23066 104 104 105 105 if(marshall_direction==MARSHALLING_BACKWARD){ 106 106 107 107 if (!hnodes_null)this->hnodes = new Hook*[numanalyses]; 108 108 else this->hnodes=NULL; … … 140 140 _printf_(" ElementHook DeepEcho:\n"); 141 141 _printf_(" numanalyses : "<< this->numanalyses <<"\n"); 142 142 143 143 _printf_(" hnodes:\n"); 144 144 if(hnodes){ … … 149 149 } 150 150 else _printf_(" hnodes = NULL\n"); 151 151 152 152 _printf_(" hvertices:\n"); 153 153 if(hvertices) hvertices->DeepEcho(); 154 154 else _printf_(" hvertices = NULL\n"); 155 155 156 156 _printf_(" hmaterial:\n"); 157 157 if(hmaterial) hmaterial->DeepEcho(); … … 170 170 /*}}}*/ 171 171 void ElementHook::Echo(){/*{{{*/ 172 172 173 173 _printf_(" ElementHook Echo:\n"); 174 174 _printf_(" numanalyses : "<< this->numanalyses <<"\n"); 175 175 176 176 _printf_(" hnodes:\n"); 177 177 if(hnodes){ … … 181 181 } 182 182 else _printf_(" hnodes = NULL\n"); 183 183 184 184 _printf_(" hvertices:\n"); 185 185 if(hvertices) hvertices->Echo(); 186 186 else _printf_(" hvertices = NULL\n"); 187 187 188 188 _printf_(" hmaterial:\n"); 189 189 if(hmaterial) hmaterial->Echo(); -
issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
r23059 r23066 286 286 IssmDouble calvingratey[NUMVERTICES]; 287 287 IssmDouble calvingrate[NUMVERTICES]; 288 289 288 290 289 /* Get node coordinates and dof list: */ … … 1048 1047 /*}}}*/ 1049 1048 void Penta::GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 1050 1049 1051 1050 /* Intermediaries */ 1052 1051 const int dim=3; … … 1181 1180 if(!IsInputEnum(control_enum)) _error_("Enum "<<EnumToStringx(control_enum)<<" is not in IsInput"); 1182 1181 Input* input=(Input*)this->inputs->GetInput(control_enum); _assert_(input); 1183 1184 1182 1185 1183 /*Cast to Controlinput*/ … … 2595 2593 Penta* penta=this; 2596 2594 for(;;){ 2597 2595 2598 2596 IssmDouble xyz_list[NUMVERTICES][3]; 2599 2597 /* Get node coordinates and dof list: */ … … 2604 2602 Jdet[1]=(xyz_list[4][2]-xyz_list[1][2])*0.5; 2605 2603 Jdet[2]=(xyz_list[5][2]-xyz_list[2][2])*0.5; 2606 2604 2607 2605 /*Retrieve all inputs we will need*/ 2608 2606 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); … … 2615 2613 Input* surface_input=inputs->GetInput(SurfaceEnum); _assert_(surface_input); 2616 2614 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 2617 2615 2618 2616 /* Start looping on the number of 2D vertices: */ 2619 2617 for(int ig=0;ig<3;ig++){ … … 2644 2642 delete gauss; 2645 2643 } 2646 2644 2647 2645 /*Stop if we have reached the surface/base*/ 2648 2646 if(penta->IsOnSurface()) break; 2649 2647 2650 2648 /*get upper Penta*/ 2651 2649 penta=penta->GetUpperPenta(); -
issm/trunk-jpl/src/c/classes/Elements/Seg.cpp
r22647 r23066 104 104 return seg; 105 105 106 107 106 } 108 107 /*}}}*/ … … 141 140 /*}}}*/ 142 141 void Seg::GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 143 142 144 143 /* Intermediaries */ 145 144 int nrfrontnodes,index; -
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r23059 r23066 106 106 } 107 107 else tria->nodes = NULL; 108 108 109 109 tria->vertices = (Vertex**)this->hvertices->deliverp(); 110 110 tria->material = (Material*)this->hmaterial->delivers(); … … 115 115 /*}}}*/ 116 116 void Tria::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 117 117 118 118 MARSHALLING_ENUM(TriaEnum); 119 119 120 120 /*Call parent classes: */ 121 121 ElementHook::Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); … … 135 135 /*Call inputs method*/ 136 136 _assert_(this->inputs); 137 137 138 138 int domaintype; 139 139 parameters->FindParam(&domaintype,DomainTypeEnum); … … 185 185 186 186 int tria_vertex_ids[3]; 187 187 188 188 for(int k=0;k<3;k++){ 189 189 tria_vertex_ids[k]=reCast<int>(iomodel->elements[3*this->Sid()+k]); //ids for vertices are in the elements array from Matlab … … 328 328 /*}}}*/ 329 329 void Tria::CalvingCrevasseDepth(){/*{{{*/ 330 330 331 331 IssmDouble xyz_list[NUMVERTICES][3]; 332 332 IssmDouble calvingrate[NUMVERTICES]; … … 340 340 /* Get node coordinates and dof list: */ 341 341 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 342 342 343 343 /*Get the critical fraction of thickness surface and basal crevasses penetrate for calving onset*/ 344 344 this->parameters->FindParam(&critical_fraction,CalvingCrevasseDepthEnum); 345 345 346 346 IssmDouble rho_ice = this->GetMaterialParameter(MaterialsRhoIceEnum); 347 347 IssmDouble rho_seawater = this->GetMaterialParameter(MaterialsRhoSeawaterEnum); … … 361 361 Input* s_xy_input = inputs->GetInput(DeviatoricStressxyEnum); _assert_(s_xy_input); 362 362 Input* s_yy_input = inputs->GetInput(DeviatoricStressyyEnum); _assert_(s_yy_input); 363 363 364 364 /*Loop over all elements of this partition*/ 365 365 GaussTria* gauss=new GaussTria(); 366 366 for (int iv=0;iv<NUMVERTICES;iv++){ 367 367 gauss->GaussVertex(iv); 368 368 369 369 H_input->GetInputValue(&thickness,gauss); 370 370 bed_input->GetInputValue(&bed,gauss); … … 378 378 s_xy_input->GetInputValue(&s_xy,gauss); 379 379 s_yy_input->GetInputValue(&s_yy,gauss); 380 380 381 381 vel=sqrt(vx*vx+vy*vy)+1.e-14; 382 382 … … 384 384 s2=(s_xx+s_yy)/2.-sqrt(pow((s_xx-s_yy)/2.,2)+pow(s_xy,2)); 385 385 if(fabs(s2)>fabs(s1)){stmp=s2; s2=s1; s1=stmp;} 386 386 387 387 Ho = thickness - (rho_seawater/rho_ice) * (-bed); 388 388 if(Ho<0.) Ho=0.; … … 399 399 // water_height = surface_crevasse[iv]; 400 400 //} 401 401 402 402 /*basal crevasse*/ 403 403 //basal_crevasse[iv] = (rho_ice/(rho_seawater-rho_ice)) * (rheology_B * strainparallel * pow(straineffective,((1/rheology_n)-1)) / (rho_ice*constant_g) - Ho); … … 405 405 if (basal_crevasse[iv]<0.) basal_crevasse[iv]=0.; 406 406 if (bed>0.) basal_crevasse[iv] = 0.; 407 407 408 408 H_surf = surface_crevasse[iv] + (rho_freshwater/rho_ice)*water_height - critical_fraction*float_depth; 409 409 H_surfbasal = (surface_crevasse[iv] + (rho_freshwater/rho_ice)*water_height + basal_crevasse[iv])-(critical_fraction*thickness); 410 410 411 411 crevasse_depth[iv] = max(H_surf,H_surfbasal); 412 412 } 413 413 414 414 this->inputs->AddInput(new TriaInput(SurfaceCrevasseEnum,&surface_crevasse[0],P1Enum)); 415 415 this->inputs->AddInput(new TriaInput(BasalCrevasseEnum,&basal_crevasse[0],P1Enum)); … … 461 461 else 462 462 calvingrate[iv]=0.; 463 463 464 464 calvingratex[iv]=calvingrate[iv]*vx/(sqrt(vel)+1.e-14); 465 465 calvingratey[iv]=calvingrate[iv]*vy/(sqrt(vel)+1.e-14); … … 562 562 IssmDouble vorticity_xy[NUMVERTICES]; 563 563 GaussTria* gauss=NULL; 564 564 565 565 /* Get node coordinates and dof list: */ 566 566 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); … … 569 569 Input* vx_input=this->GetInput(EsaXmotionEnum); _assert_(vx_input); 570 570 Input* vy_input=this->GetInput(EsaYmotionEnum); _assert_(vy_input); 571 571 572 572 /* Start looping on the number of vertices: */ 573 573 gauss=new GaussTria(); … … 773 773 } 774 774 775 776 775 }/*}}}*/ 777 776 void Tria::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){/*{{{*/ … … 1400 1399 /*}}}*/ 1401 1400 void Tria::GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 1402 1401 1403 1402 /* Intermediaries */ 1404 1403 int i, dir,nrfrontnodes; … … 1489 1488 }/*}}}*/ 1490 1489 void Tria::GetLevelsetIntersection(int** pindices, int* pnumiceverts, IssmDouble* fraction, int levelset_enum, IssmDouble level){/*{{{*/ 1491 1490 1492 1491 /* GetLevelsetIntersection computes: 1493 1492 * 1. indices of element, sorted in [iceverts, noiceverts] in counterclockwise fashion, … … 1565 1564 /*}}}*/ 1566 1565 void Tria::GetLevelsetPositivePart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlynegative,IssmDouble* gl){/*{{{*/ 1567 1566 1568 1567 /*Computeportion of the element that has a positive levelset*/ 1569 1568 … … 1679 1678 1680 1679 parameters->FindParam(&M,NULL,ControlInputSizeMEnum); 1681 1680 1682 1681 /*Cast to Controlinput*/ 1683 1682 if(input->ObjectEnum()!=ControlInputEnum) _error_("input " << EnumToStringx(control_enum) << " is not a ControlInput"); 1684 1683 ControlInput* controlinput = xDynamicCast<ControlInput*>(input); 1685 1684 1686 1685 if(strcmp(data,"value")==0){ 1687 1686 input = controlinput->values; … … 1700 1699 } 1701 1700 /*Check what input we are dealing with*/ 1702 1701 1703 1702 switch(input->ObjectEnum()){ 1704 1703 case TriaInputEnum: … … 1717 1716 break; 1718 1717 } 1719 1718 1720 1719 case TransientInputEnum: 1721 1720 { … … 1982 1981 base_input->GetInputAverage(&bed); 1983 1982 bed_input->GetInputAverage(&bathymetry); 1984 1983 1985 1984 /*Return: */ 1986 1985 return base*(surface-bed+min(rho_water/rho_ice*bathymetry,0.)); … … 2026 2025 if(control_analysis && ad_analysis) iomodel->FindConstant(&num_control_type,"md.autodiff.num_independent_objects"); 2027 2026 if(control_analysis && ad_analysis) iomodel->FindConstant(&num_responses,"md.autodiff.num_dependent_objects"); 2028 2029 2030 2027 2031 2028 /*Recover vertices ids needed to initialize inputs*/ … … 2394 2391 IssmDouble Tria::Masscon(IssmDouble* levelset){ /*{{{*/ 2395 2392 2396 2397 2393 /*intermediary: */ 2398 2394 IssmDouble* values=NULL; … … 2407 2403 IssmDouble fraction1,fraction2; 2408 2404 bool mainlynegative=true; 2409 2405 2410 2406 /*Output:*/ 2411 2407 volume=0; … … 2416 2412 /*Retrieve inputs required:*/ 2417 2413 thickness_input=this->GetInput(ThicknessEnum); _assert_(thickness_input); 2418 2414 2419 2415 /*Retrieve material parameters: */ 2420 2416 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); … … 2425 2421 values[i]=levelset[this->vertices[i]->Sid()]; 2426 2422 } 2427 2423 2428 2424 /*Ok, use the level set values to figure out where we put our gaussian points:*/ 2429 2425 this->GetLevelsetPositivePart(&point1,&fraction1,&fraction2,&mainlynegative,values); … … 2877 2873 dist_cf_input->GetInputValue(&dist_cf,gauss); 2878 2874 delete gauss; 2879 2875 2880 2876 /*Ensure values are positive for floating ice*/ 2881 2877 dist_gl = fabs(dist_gl); … … 3197 3193 } 3198 3194 3199 3200 3195 } 3201 3196 /*}}}*/ … … 3278 3273 int idlist[NUMVERTICES],control_init; 3279 3274 3280 3281 3275 /*Get Domain type*/ 3282 3276 int domaintype; … … 3298 3292 /*Get out if this is not an element input*/ 3299 3293 if(!IsInputEnum(control_enum)) return; 3300 3294 3301 3295 Input* input = (Input*)this->inputs->GetInput(control_enum); _assert_(input); 3302 3296 if(input->ObjectEnum()!=ControlInputEnum){ … … 3330 3324 IssmDouble values[NUMVERTICES]; 3331 3325 int vertexpidlist[NUMVERTICES],control_init; 3332 3333 3326 3334 3327 /*Get Domain type*/ … … 4167 4160 IssmDouble* H_elastic_precomputed = NULL; 4168 4161 int M, hemi; 4169 4162 4170 4163 /*computation of Green functions:*/ 4171 4164 IssmDouble* U_elastic= NULL; … … 4174 4167 IssmDouble* X_elastic= NULL; 4175 4168 IssmDouble* Y_elastic= NULL; 4176 4169 4177 4170 /*optimization:*/ 4178 4171 bool store_green_functions=false; … … 4182 4175 if (!deltathickness_input)_error_("delta thickness input needed to compute elastic adjustment!"); 4183 4176 deltathickness_input->GetInputAverage(&I); 4184 4177 4185 4178 /*early return if we are not on the (ice) loading point: */ 4186 4179 if(I==0) return; … … 4195 4188 /*which hemisphere? for north-south, east-west components*/ 4196 4189 this->parameters->FindParam(&hemi,EsaHemisphereEnum); 4197 4190 4198 4191 /*compute area of element:*/ 4199 4192 area=GetArea(); … … 4254 4247 Y_values[i]+=3*rho_ice/rho_earth*area/(4*PI*pow(earth_radius,2))*I*Y_elastic[i]; 4255 4248 X_values[i]+=3*rho_ice/rho_earth*area/(4*PI*pow(earth_radius,2))*I*X_elastic[i]; 4256 4249 4257 4250 /*North-south, East-west components */ 4258 4251 if (hemi == -1) { … … 4277 4270 pX->SetValues(gsize,indices,X_values,ADD_VAL); 4278 4271 pY->SetValues(gsize,indices,Y_values,ADD_VAL); 4279 4272 4280 4273 /*free ressources:*/ 4281 4274 xDelete<int>(indices); … … 4307 4300 IssmDouble* H_elastic_precomputed = NULL; 4308 4301 int M; 4309 4302 4310 4303 /*computation of Green functions:*/ 4311 4304 IssmDouble* U_elastic= NULL; 4312 4305 IssmDouble* N_elastic= NULL; 4313 4306 IssmDouble* E_elastic= NULL; 4314 4307 4315 4308 /*optimization:*/ 4316 4309 bool store_green_functions=false; … … 4320 4313 if (!deltathickness_input)_error_("delta thickness input needed to compute elastic adjustment!"); 4321 4314 deltathickness_input->GetInputAverage(&I); 4322 4315 4323 4316 /*early return if we are not on the (ice) loading point: */ 4324 4317 if(I==0) return; … … 4419 4412 N_azim = (-z*x*dx-z*y*dy+(pow(x,2)+pow(y,2))*dz) /pow((pow(x,2)+pow(y,2))*(pow(x,2)+pow(y,2)+pow(z,2))*(pow(dx,2)+pow(dy,2)+pow(dz,2)),0.5); 4420 4413 E_azim = (-y*dx+x*dy) /pow((pow(x,2)+pow(y,2))*(pow(dx,2)+pow(dy,2)+pow(dz,2)),0.5); 4421 4414 4422 4415 /*Elastic component (from Eq 17 in Adhikari et al, GMD 2015): */ 4423 4416 int index=reCast<int,IssmDouble>(alpha/PI*(M-1)); … … 4434 4427 pNorth->SetValues(gsize,indices,N_values,ADD_VAL); 4435 4428 pEast->SetValues(gsize,indices,E_values,ADD_VAL); 4436 4429 4437 4430 /*free ressources:*/ 4438 4431 xDelete<int>(indices); … … 4455 4448 4456 4449 if(IsWaterInElement()){ 4457 4450 4458 4451 IssmDouble area; 4459 4452 … … 4528 4521 if(IsWaterInElement()){ 4529 4522 IssmDouble rho_water, S; 4530 4523 4531 4524 /*recover material parameters: */ 4532 4525 rho_water=matpar->GetMaterialParameter(MaterialsRhoFreshwaterEnum); 4533 4526 4534 4527 /*From Sg_old, recover water sea level rise:*/ 4535 4528 S=0; for(int i=0;i<NUMVERTICES;i++) S+=Sg_old[this->vertices[i]->Sid()]/NUMVERTICES; 4536 4529 4537 4530 /* Perturbation terms for moment of inertia (moi_list): 4538 4531 * computed analytically (see Wu & Peltier, eqs 10 & 32) … … 4546 4539 else if(this->inputs->Max(MaskIceLevelsetEnum)<0){ 4547 4540 IssmDouble rho_ice, I; 4548 4541 4549 4542 /*recover material parameters: */ 4550 4543 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 4551 4544 4552 4545 /*Compute ice thickness change: */ 4553 4546 Input* deltathickness_input=inputs->GetInput(SealevelriseDeltathicknessEnum); 4554 4547 if (!deltathickness_input)_error_("delta thickness input needed to compute sea level rise!"); 4555 4548 deltathickness_input->GetInputAverage(&I); 4556 4549 4557 4550 dI_list[0] = -4*PI*(rho_ice*I*area)*pow(re,4)*(sin(late)*cos(late)*cos(longe))/eartharea; 4558 4551 dI_list[1] = -4*PI*(rho_ice*I*area)*pow(re,4)*(sin(late)*cos(late)*sin(longe))/eartharea; 4559 4552 dI_list[2] = +4*PI*(rho_ice*I*area)*pow(re,4)*(1-pow(sin(late),2))/eartharea; 4560 4553 } 4561 4554 4562 4555 return; 4563 4556 }/*}}}*/ … … 4592 4585 bool computeelastic= true; 4593 4586 bool scaleoceanarea= false; 4594 4587 4595 4588 /*early return if we are not on an ice cap:*/ 4596 4589 if(!(this->inputs->Max(MaskIceLevelsetEnum)<=0)){ … … 4606 4599 return; 4607 4600 } 4608 4601 4609 4602 /*If we are here, we are on ice that is fully grounded or half-way to floating: */ 4610 4603 if ((this->inputs->Min(MaskGroundediceLevelsetEnum))<0){ 4611 4604 notfullygrounded=true; //used later on. 4612 4605 } 4613 4606 4614 4607 /*Inform mask: */ 4615 4608 constant=1; this->inputs->AddInput(new TriaInput(SealevelEustaticMaskEnum,&constant,P0Enum)); … … 4636 4629 4637 4630 /* Where is the centroid of this element?:{{{*/ 4638 4631 4639 4632 /*retrieve coordinates: */ 4640 4633 ::GetVerticesCoordinates(&llr_list[0][0],this->vertices,NUMVERTICES,spherical); 4641 4634 4642 4635 IssmDouble minlong=400; 4643 4636 IssmDouble maxlong=-20; … … 4653 4646 if (llr_list[2][1]==0)llr_list[2][1]=360; 4654 4647 } 4655 4648 4656 4649 // correction at the north pole 4657 4650 if(llr_list[0][0]==0)llr_list[0][1]=(llr_list[1][1]+llr_list[2][1])/2.0; 4658 4651 if(llr_list[1][0]==0)llr_list[1][1]=(llr_list[0][1]+llr_list[2][1])/2.0; 4659 4652 if(llr_list[2][0]==0)llr_list[2][1]=(llr_list[0][1]+llr_list[1][1])/2.0; 4660 4653 4661 4654 //correction at the south pole 4662 4655 if(llr_list[0][0]==180)llr_list[0][1]=(llr_list[1][1]+llr_list[2][1])/2.0; … … 4684 4677 area*=phi; 4685 4678 } 4686 4679 4687 4680 /*Compute ice thickness change: */ 4688 4681 Input* deltathickness_input=inputs->GetInput(SealevelriseDeltathicknessEnum); … … 4696 4689 int point1; 4697 4690 IssmDouble fraction1,fraction2; 4698 4691 4699 4692 /*Recover portion of element that is grounded*/ 4700 4693 this->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating); … … 4750 4743 } 4751 4744 pSgi->SetValues(gsize,indices,values,ADD_VAL); 4752 4745 4753 4746 /*free ressources:*/ 4754 4747 xDelete<IssmDouble>(values); 4755 4748 xDelete<int>(indices); 4756 4749 } 4757 4750 4758 4751 /*Assign output pointer:*/ 4759 4752 _assert_(!xIsNan<IssmDouble>(eustatic)); … … 4780 4773 IssmDouble* G_elastic_precomputed = NULL; 4781 4774 int M; 4782 4775 4783 4776 /*computation of Green functions:*/ 4784 4777 IssmDouble* G_elastic= NULL; … … 4857 4850 longe=longe/180*PI; 4858 4851 /*}}}*/ 4859 4852 4860 4853 if(computeelastic){ 4861 4854 4862 4855 /*recover elastic green function:*/ 4863 4856 DoubleVecParam* parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelriseGElasticEnum)); _assert_(parameter); … … 4897 4890 } 4898 4891 } 4899 4892 4900 4893 pSgo->SetValues(gsize,indices,values,ADD_VAL); 4901 4894 … … 4930 4923 IssmDouble* H_elastic_precomputed = NULL; 4931 4924 int M; 4932 4925 4933 4926 /*computation of Green functions:*/ 4934 4927 IssmDouble* U_elastic= NULL; … … 4957 4950 this->parameters->FindParam(&computerigid,SealevelriseRigidEnum); 4958 4951 this->parameters->FindParam(&computeelastic,SealevelriseElasticEnum); 4959 4952 4960 4953 /*early return if elastic not requested:*/ 4961 4954 if(!computeelastic) return; … … 5026 5019 /*From Sg, recover water sea level rise:*/ 5027 5020 S=0; for(int i=0;i<NUMVERTICES;i++) S+=Sg[this->vertices[i]->Sid()]/NUMVERTICES; 5028 5021 5029 5022 /*Compute ice thickness change: */ 5030 5023 Input* deltathickness_input=inputs->GetInput(SealevelriseDeltathicknessEnum); 5031 5024 if (!deltathickness_input)_error_("delta thickness input needed to compute sea level rise!"); 5032 5025 deltathickness_input->GetInputAverage(&I); 5033 5026 5034 5027 /*initialize: */ 5035 5028 U_elastic=xNewZeroInit<IssmDouble>(gsize); … … 5073 5066 E_azim = (-y*dx+x*dy) /pow((pow(x,2)+pow(y,2))*(pow(dx,2)+pow(dy,2)+pow(dz,2)),0.5); 5074 5067 } 5075 5068 5076 5069 /*Elastic component (from Eq 17 in Adhikari et al, GMD 2015): */ 5077 5070 int index=reCast<int,IssmDouble>(alpha/PI*(M-1)); -
issm/trunk-jpl/src/c/classes/FemModel.cpp
r23065 r23066 242 242 char *lockfilename = NULL; 243 243 bool waitonlock = false; 244 245 244 246 245 /*Write lock file if requested: */ … … 4393 4392 xDelete<IssmDouble>(RSLg_old); 4394 4393 4395 4396 4394 } 4397 4395 /*}}}*/ … … 4807 4805 size_t* poutputbuffersize; 4808 4806 4809 4810 4807 /*Before we delete the profiler, report statistics for this run: */ 4811 4808 profiler->Stop(TOTAL); //final tagging … … 4868 4865 }/*}}}*/ 4869 4866 #endif 4870 4871 4867 4872 4868 #if defined(_HAVE_BAMG_) && !defined(_HAVE_ADOLC_) … … 5246 5242 newy[i] = newxylist[2*i+1]; 5247 5243 } 5248 5244 5249 5245 /*Assign the pointers*/ 5250 5246 (*pnewelementslist) = newelementslist; //Matlab indexing -
issm/trunk-jpl/src/c/classes/IoModel.cpp
r22993 r23066 157 157 bool autodiff=false; 158 158 bool iscontrol=false; 159 159 160 160 /*First, keep track of the file handle: */ 161 161 this->fid=iomodel_handle; … … 422 422 this->FetchData(&autodiff,"md.autodiff.isautodiff"); 423 423 this->FetchData(&iscontrol,"md.inversion.iscontrol"); 424 424 425 425 if(trace || (autodiff && !iscontrol)){ 426 426 … … 506 506 507 507 char** stringarray=*pstringarray; 508 508 509 509 if(numstrings){ 510 510 for(int i=0;i<numstrings;i++){ … … 597 597 /*Read the integer and broadcast it to other cpus:*/ 598 598 if(fread(&integer,sizeof(int),1,this->fid)!=1) _error_("could not read integer "); 599 599 600 600 /*Convert codes to Enums if needed*/ 601 601 if(strcmp(record_name,"md.smb.model")==0) integer = IoCodeToEnumSMB(integer); … … 963 963 /*recover my_rank:*/ 964 964 int my_rank=IssmComm::GetRank(); 965 965 966 966 /*Set file pointer to beginning of the data: */ 967 967 fid=this->SetFilePointerToData(&code,NULL,data_name); … … 1134 1134 } 1135 1135 } 1136 1136 1137 1137 /*output: */ 1138 1138 int M,N; … … 1825 1825 /*check we are indeed finding a string, not something else: */ 1826 1826 if(codes[i]!=4)_error_("expecting a string for \""<<data_name<<"\""); 1827 1827 1828 1828 /*We have to read a string from disk. First read the dimensions of the string, then the string: */ 1829 1829 fsetpos(fid,file_positions+i); … … 1854 1854 xDelete<int>(codes); 1855 1855 xDelete<fpos_t>(file_positions); 1856 1856 1857 1857 /*Assign output pointers: */ 1858 1858 *pstrings=strings; … … 1875 1875 /*recover my_rank:*/ 1876 1876 int my_rank=IssmComm::GetRank(); 1877 1877 1878 1878 /*Get file pointers to beginning of the data (multiple instances of it): */ 1879 1879 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_name); … … 1890 1890 1891 1891 if(code!=2)_error_("expecting an integer for \""<<data_name<<"\""); 1892 1892 1893 1893 /*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */ 1894 1894 fsetpos(fid,file_positions+i); … … 1903 1903 } 1904 1904 } 1905 1905 1906 1906 /*Free ressources:*/ 1907 1907 xDelete<fpos_t>(file_positions); … … 1928 1928 /*recover my_rank:*/ 1929 1929 int my_rank=IssmComm::GetRank(); 1930 1930 1931 1931 /*Get file pointers to beginning of the data (multiple instances of it): */ 1932 1932 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_name); … … 1943 1943 1944 1944 if(code!=3)_error_("expecting a double for \""<<data_name<<"\""); 1945 1945 1946 1946 /*We have to read a double from disk: */ 1947 1947 fsetpos(fid,file_positions+i); … … 1956 1956 } 1957 1957 } 1958 1958 1959 1959 /*Free ressources:*/ 1960 1960 xDelete<fpos_t>(file_positions); … … 1985 1985 /*recover my_rank:*/ 1986 1986 int my_rank=IssmComm::GetRank(); 1987 1987 1988 1988 /*Get file pointers to beginning of the data (multiple instances of it): */ 1989 1989 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_name); … … 2014 2014 } 2015 2015 ISSM_MPI_Bcast(&N,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 2016 2017 2016 2018 2017 /*Now allocate matrix: */ … … 2039 2038 else 2040 2039 matrix=NULL; 2041 2042 2040 2043 2041 /*Assign: */ 2044 2042 mdims[i]=M; … … 2047 2045 } 2048 2046 } 2049 2047 2050 2048 /*Free ressources:*/ 2051 2049 xDelete<fpos_t>(file_positions); … … 2089 2087 /*recover my_rank:*/ 2090 2088 int my_rank=IssmComm::GetRank(); 2091 2089 2092 2090 /*Get file pointers to beginning of the data (multiple instances of it): */ 2093 2091 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_name); … … 2118 2116 } 2119 2117 ISSM_MPI_Bcast(&N,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 2120 2121 2118 2122 2119 /*Now allocate matrix: */ … … 2144 2141 else 2145 2142 integer_matrix=NULL; 2146 2147 2143 2148 2144 /*Assign: */ 2149 2145 mdims[i]=M; … … 2152 2148 } 2153 2149 } 2154 2150 2155 2151 /*Free ressources:*/ 2156 2152 xDelete<fpos_t>(file_positions); … … 2376 2372 vector_types = xNew<int>(num_instances); 2377 2373 } 2378 2374 2379 2375 /*Reset FILE* position to the beginning of the file, and start again, this time saving the data information 2380 2376 * as we find it: */ … … 2419 2415 vector_types[counter] = vector_type; 2420 2416 fgetpos(fid,file_positions+counter); 2421 2417 2422 2418 /*backup and skip over the record, as we have more work to do: */ 2423 2419 if(5<=record_code && record_code<=7) fseek(fid,-sizeof(int),SEEK_CUR); 2424 2420 fseek(fid,-sizeof(int),SEEK_CUR); 2425 2421 fseek(fid,-sizeof(int),SEEK_CUR); 2426 2422 2427 2423 /*increment counter: */ 2428 2424 counter++; -
issm/trunk-jpl/src/c/classes/Loads/Friction.cpp
r23020 r23066 196 196 if(vmag==0. && (s-1.)<0.) alpha_complement=0.; 197 197 else alpha_complement=pow(Neff,r)*pow(vmag,(s-1)); 198 198 199 199 _assert_(!xIsNan<IssmDouble>(alpha_complement)); 200 200 _assert_(!xIsInf<IssmDouble>(alpha_complement)); … … 270 270 r=drag_q/drag_p; 271 271 s=1./drag_p; 272 273 272 274 273 /*Get effective pressure*/ -
issm/trunk-jpl/src/c/classes/Loads/Moulin.cpp
r23020 r23066 178 178 179 179 switch(analysis_type){ 180 180 181 181 case HydrologyShaktiAnalysisEnum: 182 182 pe = this->CreatePVectorHydrologyShakti(); … … 395 395 IssmDouble moulin_load,dt; 396 396 ElementVector* pe=new ElementVector(&node,1,this->parameters); 397 397 398 398 this->element->GetInputValue(&moulin_load,node,HydrologydcBasalMoulinInputEnum); 399 399 parameters->FindParam(&dt,TimesteppingTimeStepEnum); 400 400 401 401 pe->values[0]=moulin_load*dt; 402 402 /*Clean up and return*/ -
issm/trunk-jpl/src/c/classes/Loads/Neumannflux.cpp
r23020 r23066 30 30 /*}}}*/ 31 31 Neumannflux::Neumannflux(int neumannflux_id,int i,IoModel* iomodel,int* segments,int in_analysis_type){/*{{{*/ 32 33 32 34 33 /*Some sanity checks*/ -
issm/trunk-jpl/src/c/classes/Materials/Matestar.cpp
r22306 r23066 109 109 110 110 if(marshall_direction==MARSHALLING_BACKWARD)helement=new Hook(); 111 111 112 112 MARSHALLING_ENUM(MatestarEnum); 113 113 MARSHALLING(mid); -
issm/trunk-jpl/src/c/classes/Materials/Matice.cpp
r22307 r23066 135 135 //if(helement) helement->DeepEcho(); 136 136 //else _printf_(" helement = NULL\n"); 137 137 138 138 _printf_(" element:\n"); 139 139 _printf_(" note: element not printed to avoid recursion.\n"); … … 143 143 /*}}}*/ 144 144 void Matice::Echo(void){/*{{{*/ 145 145 146 146 _printf_("Matice:\n"); 147 147 _printf_(" mid: " << mid << "\n"); 148 148 _printf_(" isdamaged: " << isdamaged << "\n"); 149 149 _printf_(" isenhanced: " << isenhanced << "\n"); 150 150 151 151 /*helement and element Echo were commented to avoid recursion.*/ 152 152 /*Example: element->Echo calls matice->Echo which calls element->Echo etc*/ … … 155 155 //if(helement) helement->Echo(); 156 156 //else _printf_(" helement = NULL\n"); 157 157 158 158 _printf_(" element:\n"); 159 159 _printf_(" note: element not printed to avoid recursion.\n"); … … 167 167 168 168 if(marshall_direction==MARSHALLING_BACKWARD)helement=new Hook(); 169 169 170 170 MARSHALLING_ENUM(MaticeEnum); 171 171 MARSHALLING(mid); … … 541 541 IssmDouble exx,eyy,exy,exz,eyz; 542 542 543 544 543 if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0) && 545 544 (epsilon[3]==0) && (epsilon[4]==0)){ -
issm/trunk-jpl/src/c/classes/Materials/Matlitho.cpp
r22004 r23066 37 37 this->radius=xNew<IssmDouble>(this->numlayers+1); 38 38 xMemCpy<IssmDouble>(this->radius, iomodel->Data("md.materials.radius"),this->numlayers+1); 39 39 40 40 this->viscosity=xNew<IssmDouble>(this->numlayers); 41 41 xMemCpy<IssmDouble>(this->viscosity, iomodel->Data("md.materials.viscosity"),this->numlayers); 42 42 43 43 this->lame_lambda=xNew<IssmDouble>(this->numlayers); 44 44 xMemCpy<IssmDouble>(this->lame_lambda, iomodel->Data("md.materials.lame_lambda"),this->numlayers); 45 45 46 46 this->lame_mu=xNew<IssmDouble>(this->numlayers); 47 47 xMemCpy<IssmDouble>(this->lame_mu, iomodel->Data("md.materials.lame_mu"),this->numlayers); … … 61 61 this->issolid=xNew<IssmDouble>(this->numlayers); 62 62 xMemCpy<IssmDouble>(this->issolid, iomodel->Data("md.materials.issolid"),this->numlayers); 63 63 64 64 /*isburgersd= xNew<IssmDouble>(this->numlayers); 65 65 this->isburgers=xNew<bool>(this->numlayers); 66 66 xMemCpy<IssmDouble>(isburgersd, iomodel->Data("md.materials.isburgers"),this->numlayers); 67 67 for (int i=0;i<this->numlayers;i++)this->isburgers[i]=reCast<bool,IssmDouble>(isburgersd[i]); 68 68 69 69 issolidd= xNew<IssmDouble>(this->numlayers); 70 70 this->issolid=xNew<bool>(this->numlayers); 71 71 xMemCpy<IssmDouble>(issolidd, iomodel->Data("md.materials.issolid"),this->numlayers); 72 72 for (int i=0;i<this->numlayers;i++)this->issolid[i]=reCast<bool,IssmDouble>(issolidd[i]);*/ 73 73 74 74 /*free ressources: */ 75 75 xDelete<IssmDouble>(isburgersd); … … 78 78 /*}}}*/ 79 79 Matlitho::~Matlitho(){/*{{{*/ 80 80 81 81 xDelete<IssmDouble>(radius); 82 82 xDelete<IssmDouble>(viscosity); -
issm/trunk-jpl/src/c/classes/Materials/Matpar.cpp
r23020 r23066 59 59 mantle_shear_modulus = 0; 60 60 mantle_density = 0; 61 61 62 62 earth_density = 0; 63 63 … … 338 338 matpar->mantle_shear_modulus=this->mantle_shear_modulus; 339 339 matpar->mantle_density=this->mantle_density; 340 340 341 341 matpar->earth_density=this->earth_density; 342 342 … … 439 439 MARSHALLING(mantle_shear_modulus); 440 440 MARSHALLING(mantle_density); 441 441 442 442 //slr: 443 443 MARSHALLING(earth_density); -
issm/trunk-jpl/src/c/classes/Misfit.cpp
r22438 r23066 23 23 #include "../classes/gauss/Gauss.h" 24 24 /*}}}*/ 25 25 26 26 /*Misfit constructors, destructors :*/ 27 27 Misfit::Misfit(){/*{{{*/ … … 42 42 43 43 this->definitionenum=in_definitionenum; 44 44 45 45 this->name = xNew<char>(strlen(in_name)+1); 46 46 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); … … 48 48 this->timeinterpolation = xNew<char>(strlen(in_timeinterpolation)+1); 49 49 xMemCpy<char>(this->timeinterpolation,in_timeinterpolation,strlen(in_timeinterpolation)+1); 50 50 51 51 this->model_enum=in_model_enum; 52 52 this->observation_enum=in_observation_enum; 53 53 this->weights_enum=in_weights_enum; 54 54 this->local=in_local; 55 55 56 56 this->misfit=0; 57 57 this->lock=0; … … 111 111 /*}}}*/ 112 112 IssmDouble Misfit::Response(FemModel* femmodel){/*{{{*/ 113 113 114 114 /*diverse: */ 115 115 IssmDouble time,starttime,finaltime; 116 116 IssmDouble dt; 117 117 118 118 /*recover time parameters: */ 119 119 femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum); … … 130 130 IssmDouble all_area_t; 131 131 132 133 132 /*If we are locked, return time average: */ 134 133 if(this->lock)return misfit/(time-starttime); … … 144 143 area_t=all_area_t; 145 144 misfit_t=all_misfit_t; 146 145 147 146 /*Divide by surface area if not nill!: */ 148 147 if (area_t!=0) misfit_t=misfit_t/area_t; … … 164 163 IssmDouble* weights= NULL; 165 164 int msize,osize,wsize; 166 165 167 166 /*Are we transient?:*/ 168 167 if (time==0){ 169 168 IssmDouble misfit_t=0.; 170 169 171 170 /*get global vectors: */ 172 171 GetVectorFromInputsx(&model,&msize,femmodel,model_enum); … … 190 189 } 191 190 else{ 192 191 193 192 IssmDouble misfit_t=0.; 194 193 IssmDouble all_misfit_t=0.; … … 201 200 GetVectorFromInputsx(&observation,&osize,femmodel,observation_enum);_assert_(msize==osize); 202 201 GetVectorFromInputsx(&weights,&wsize,femmodel,weights_enum); _assert_(wsize==msize); 203 202 204 203 int count=0; 205 204 for (int i=0;i<msize;i++){ … … 215 214 /*Do we lock? i.e. are we at final_time? :*/ 216 215 if(time==finaltime)this->lock=1; 217 216 218 217 /*Free ressources:*/ 219 218 xDelete<IssmDouble>(model); … … 227 226 } /*}}}*/ 228 227 else{ /*global computation: {{{ */ 229 228 230 229 IssmDouble model, observation; 231 230 232 231 /*If we are locked, return time average: */ 233 232 if(this->lock)return misfit/(time-starttime); … … 239 238 Input* input = element->GetInput(observation_enum); _assert_(input); 240 239 input->GetInputAverage(&observation); 241 240 242 241 /*Add this time's contribution to curent misfit: */ 243 242 misfit+=dt*(model-observation); 244 243 245 244 /*Do we lock? i.e. are we at final_time? :*/ 246 245 if(time==finaltime)this->lock=1; 247 246 248 247 /*What we return is the value of misfit / time: */ 249 248 return misfit/(time-starttime); -
issm/trunk-jpl/src/c/classes/Nodalvalue.cpp
r22427 r23066 87 87 /*}}}*/ 88 88 IssmDouble Nodalvalue::Response(FemModel* femmodel){/*{{{*/ 89 89 90 90 /*output:*/ 91 91 IssmDouble value; -
issm/trunk-jpl/src/c/classes/Node.cpp
r21509 r23066 498 498 /*}}}*/ 499 499 void Node::SetApproximation(int in_approximation){/*{{{*/ 500 500 501 501 this->approximation = in_approximation; 502 502 } -
issm/trunk-jpl/src/c/classes/Numberedcostfunction.cpp
r22423 r23066 8 8 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 9 9 #endif 10 11 10 12 11 /*Headers:*/ … … 30 29 31 30 /*}}}*/ 32 31 33 32 /*Numberedcostfunction constructors, destructors :*/ 34 33 Numberedcostfunction::Numberedcostfunction(){/*{{{*/ … … 110 109 /*}}}*/ 111 110 IssmDouble Numberedcostfunction::Response(FemModel* femmodel){/*{{{*/ 112 111 113 112 _assert_(number_cost_functions>0 && number_cost_functions<1e3); 114 113 … … 157 156 } 158 157 /*}}}*/ 159 -
issm/trunk-jpl/src/c/classes/Params/BoolParam.cpp
r20827 r23066 63 63 } 64 64 /*}}}*/ 65 -
issm/trunk-jpl/src/c/classes/Params/DataSetParam.cpp
r22588 r23066 55 55 56 56 if(marshall_direction==MARSHALLING_BACKWARD)value=new DataSet(); 57 57 58 58 MARSHALLING_ENUM(DataSetParamEnum); 59 59 MARSHALLING(enum_type); -
issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.cpp
r20827 r23066 233 233 } 234 234 /*}}}*/ 235 -
issm/trunk-jpl/src/c/classes/Params/DoubleMatParam.cpp
r20635 r23066 116 116 /*DoubleMatParam specific routines:*/ 117 117 void DoubleMatParam::GetParameterValueByPointer(IssmDouble** pIssmDoublearray,int* pM,int* pN){/*{{{*/ 118 118 119 119 /*Assign output pointers:*/ 120 120 if(pM) *pM=M; -
issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.cpp
r22628 r23066 116 116 /*DoubleVecParam specific routines:*/ 117 117 void DoubleVecParam::GetParameterValueByPointer(IssmDouble** pIssmDoublearray,int* pM){/*{{{*/ 118 118 119 119 /*Assign output pointers:*/ 120 120 if(pM) *pM=M; -
issm/trunk-jpl/src/c/classes/Params/IntParam.cpp
r20827 r23066 64 64 } 65 65 /*}}}*/ 66 -
issm/trunk-jpl/src/c/classes/Params/StringArrayParam.cpp
r21936 r23066 83 83 84 84 MARSHALLING_ENUM(StringArrayParamEnum); 85 85 86 86 MARSHALLING(enum_type); 87 87 MARSHALLING(numstrings); -
issm/trunk-jpl/src/c/classes/Params/StringParam.cpp
r21915 r23066 55 55 56 56 if(marshall_direction==MARSHALLING_FORWARD || marshall_direction == MARSHALLING_SIZE)size=strlen(value)+1; 57 57 58 58 MARSHALLING_ENUM(StringParamEnum); 59 59 MARSHALLING(enum_type); -
issm/trunk-jpl/src/c/classes/Profiler.cpp
r22554 r23066 100 100 if(this->running[tag]) _error_("Tag "<<tag<<" has not been stopped"); 101 101 102 103 102 #ifdef _HAVE_MPI_ 104 103 return this->time[tag]; … … 143 142 _assert_(tag<MAXIMUMSIZE); 144 143 if(this->running[tag]) _error_("Tag "<<tag<<" is already running"); 145 146 144 147 145 /*If mpisync requested, make sure all the cpus are at the same point in the execution: */ … … 184 182 if(!this->running[tag]) _error_("Tag "<<tag<<" is not running"); 185 183 186 187 184 /*If mpisync requested, make sure all the cpus are at the same point in the execution: */ 188 185 if(!dontmpisync){ -
issm/trunk-jpl/src/c/classes/Regionaloutput.cpp
r22438 r23066 155 155 } 156 156 /*}}}*/ 157 -
issm/trunk-jpl/src/c/classes/gauss/GaussSeg.cpp
r20827 r23066 31 31 this->numgauss = order; 32 32 GaussLegendreLinear(&pcoords1,&pweights,order); 33 33 34 34 this->coords1=xNew<IssmDouble>(numgauss); 35 35 this->weights=xNew<IssmDouble>(numgauss); -
issm/trunk-jpl/src/c/classes/kriging/Observations.cpp
r21915 r23066 741 741 xDelete<IssmPDouble>(counter); 742 742 }/*}}}*/ 743 -
issm/trunk-jpl/src/c/cores/ad_core.cpp
r22610 r23066 46 46 /*First, stop tracing: */ 47 47 trace_off(); 48 48 49 49 /*Print tape statistics so that user can kill this run if something is off already:*/ 50 50 if(VerboseAutodiff()){ /*{{{*/ … … 93 93 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 94 94 femmodel->parameters->FindParam(&num_independents,AutodiffNumIndependentsEnum); 95 95 96 96 /*if no dependents, no point in running a driver: */ 97 97 if(!(num_dependents*num_independents)) return; … … 101 101 num_dependents=0; num_independents=0; 102 102 } 103 103 104 104 /*retrieve state variable: */ 105 105 femmodel->parameters->FindParam(&axp,&dummy,AutodiffXpEnum); … … 117 117 femmodel->parameters->FindParam(&driver,AutodiffDriverEnum); 118 118 119 120 119 if (strcmp(driver,"fos_forward")==0){ /*{{{*/ 121 120 … … 140 139 anEDF_for_solverx_p->fos_forward=EDF_fos_forward_for_solverx; 141 140 #endif 142 143 141 144 142 /*call driver: */ … … 184 182 #endif 185 183 // anEDF_for_solverx_p->fov_reverse=EDF_fov_reverse_for_solverx; 186 187 184 188 185 /*seed matrix: */ … … 244 241 #endif 245 242 246 247 243 /*call driver: */ 248 244 fos_reverse(my_rank,num_dependents,num_independents, aWeightVector, weightVectorTimesJac ); … … 284 280 anEDF_for_solverx_p->fov_reverse=EDF_fov_reverse_for_solverx; 285 281 #endif 286 287 282 288 283 /*seed matrix: */ … … 317 312 else _error_("driver: " << driver << " not yet supported!"); 318 313 319 320 314 if(VerboseAutodiff())_printf0_(" end AD core\n"); 321 315 -
issm/trunk-jpl/src/c/cores/adgradient_core.cpp
r18940 r23066 39 39 IssmPDouble *aWeightVector=NULL; 40 40 IssmPDouble *weightVectorTimesJac=NULL; 41 41 42 42 /*output: */ 43 43 IssmPDouble *totalgradient=NULL; … … 53 53 /*First, stop tracing: */ 54 54 trace_off(); 55 55 56 56 if(VerboseAutodiff()){ /*{{{*/ 57 57 size_t tape_stats[15]; … … 96 96 delete [] sstats; 97 97 } /*}}}*/ 98 98 99 99 /*retrieve parameters: */ 100 100 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 101 101 femmodel->parameters->FindParam(&num_independents,AutodiffNumIndependentsEnum); 102 102 103 103 /*if no dependents, no point in running a driver: */ 104 104 if(!(num_dependents*num_independents)) return; … … 109 109 num_dependents=0; num_independents=0; 110 110 } 111 111 112 112 /*retrieve state variable: */ 113 113 femmodel->parameters->FindParam(&axp,&dummy,AutodiffXpEnum); 114 114 115 115 /* driver argument */ 116 116 xp=xNew<double>(num_independents); … … 131 131 /*Initialize outputs: */ 132 132 totalgradient=xNewZeroInit<IssmPDouble>(num_independents); 133 133 134 134 for(aDepIndex=0;aDepIndex<num_dependents_old;aDepIndex++){ 135 135 … … 137 137 aWeightVector=xNewZeroInit<IssmPDouble>(num_dependents); 138 138 if (my_rank==0) aWeightVector[aDepIndex]=1.0; 139 139 140 140 /*initialize output gradient: */ 141 141 weightVectorTimesJac=xNew<IssmPDouble>(num_independents); … … 162 162 xDelete(aWeightVector); 163 163 } 164 164 165 165 /*add totalgradient to results*/ 166 166 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,AutodiffJacobianEnum,totalgradient,num_independents,1,1,0.0)); 167 167 168 168 if(VerboseAutodiff())_printf0_(" end ad core\n"); 169 169 170 170 /* delete the allocated space for the parameters and free ressources:{{{*/ 171 171 xDelete(anEDF_for_solverx_p->dp_x); -
issm/trunk-jpl/src/c/cores/bmb_core.cpp
r22974 r23066 11 11 12 12 void bmb_core(FemModel* femmodel){ 13 14 13 15 14 /*First, get BMB model from parameters*/ -
issm/trunk-jpl/src/c/cores/controlad_core.cpp
r20803 r23066 105 105 default: _printf0_(" Unknown end condition\n"); 106 106 } 107 107 108 108 /*Save results:*/ 109 109 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,AutodiffJacobianEnum,G,n,1,0,0.0)); … … 130 130 IssmPDouble* X=NULL; 131 131 int i; 132 132 133 133 /*Now things get complicated. The femmodel we recovered did not initialize an AD trace, so we can't compute gradients with it. We are going to recreate 134 134 *a new femmodel, identical in all aspects to the first one, with trace on though, which will allow us to run the forward mode and get the gradient … … 143 143 femmodel=new FemModel(rootpath, inputfilename, outputfilename, toolkitsfilename, lockfilename, restartfilename,IssmComm::GetComm(), femmodel->solution_type,NULL); 144 144 145 146 145 /*Get initial guess:*/ 147 146 femmodel->parameters->FindParam(&Xd,&intn,AutodiffXpEnum); … … 175 174 IssmDouble pfd; 176 175 int i; 177 176 178 177 /*Recover Femmodel*/ 179 178 femmodel = (FemModel*)dzs; … … 195 194 femmodel->CostFunctionx(&pfd,&Jlist,NULL); *pf=reCast<IssmPDouble>(pfd); 196 195 _printf0_("f(x) = "<<setw(12)<<setprecision(7)<<*pf<<" | "); 197 196 198 197 /*Compute gradient using AD. Gradient is in the results after the ad_core is called*/ 199 198 adgradient_core(femmodel); … … 211 210 /*MPI broadcast results:*/ 212 211 ISSM_MPI_Bcast(G2,*n,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 213 212 214 213 /*Send gradient to m1qn3 core: */ 215 214 for(long i=0;i<*n;i++) G[i] = G2[i]; 216 215 217 216 /*Constrain X and G*/ 218 217 IssmDouble Gnorm = 0.; … … 228 227 xDelete<IssmDouble>(Jlist); 229 228 xDelete<IssmPDouble>(G2); 230 229 231 230 xDelete<char>(rootpath); 232 231 xDelete<char>(inputfilename); … … 251 250 IssmDouble pfd; 252 251 int i; 253 252 254 253 /*Recover Femmodel*/ 255 254 femmodel = (FemModel*)dzs; … … 271 270 femmodelad=new FemModel(rootpath, inputfilename, outputfilename, toolkitsfilename, lockfilename, restartfilename,IssmComm::GetComm(), femmodel->solution_type,X); 272 271 femmodel=femmodelad; //We can do this, because femmodel is being called from outside, not by reference, so we won't erase it 273 272 274 273 /*Recover some parameters*/ 275 274 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum); … … 284 283 femmodel->CostFunctionx(&pfd,&Jlist,NULL); *pf=reCast<IssmPDouble>(pfd); 285 284 _printf0_("f(x) = "<<setw(12)<<setprecision(7)<<*pf<<" | "); 286 285 287 286 /*Compute gradient using AD. Gradient is in the results after the ad_core is called*/ 288 287 adgradient_core(femmodel); … … 300 299 /*MPI broadcast results:*/ 301 300 ISSM_MPI_Bcast(G2,*n,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 302 301 303 302 /*Send gradient to m1qn3 core: */ 304 303 for(long i=0;i<*n;i++) G[i] = G2[i]; 305 304 306 305 /*Recover Gnorm: */ 307 306 IssmDouble Gnorm = 0.; … … 317 316 xDelete<IssmDouble>(Jlist); 318 317 xDelete<IssmPDouble>(G2); 319 320 318 xDelete<char>(rootpath); 321 319 xDelete<char>(inputfilename); -
issm/trunk-jpl/src/c/cores/controladm1qn3_core.cpp
r23052 r23066 126 126 SetControlInputsFromVectorx(femmodel,aX); 127 127 xDelete<IssmDouble>(aX); 128 128 129 129 /*Compute solution (forward)*/ 130 130 void (*solutioncore)(FemModel*)=NULL; … … 392 392 long niter = long(maxsteps); /*Maximum number of iterations*/ 393 393 long nsim = long(maxiter);/*Maximum number of function calls*/ 394 394 395 395 /*Get initial guess*/ 396 396 Vector<double> *Xpetsc = NULL; … … 401 401 delete Xpetsc; 402 402 //_assert_(intn==numberofvertices*num_controls); 403 403 404 404 /*Get problem dimension and initialize gradient and initial guess*/ 405 405 long n = long(intn); … … 415 415 N_add+=N[c]; 416 416 } 417 417 418 418 /*Allocate m1qn3 working arrays (see documentation)*/ 419 419 long m = 100; … … 471 471 N_add +=N[c]; 472 472 } 473 473 474 474 /*Set X as our new control*/ 475 475 IssmDouble* aX=xNew<IssmDouble>(intn); … … 483 483 ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,aG); 484 484 SetControlInputsFromVectorx(femmodel,aX); 485 485 486 486 xDelete(aX); 487 488 487 489 488 if (solution_type == TransientSolutionEnum){ … … 506 505 femmodel->results->AddObject(G_output); 507 506 femmodel->results->AddObject(X_output); 508 507 509 508 offset += N[i]*numberofvertices; 510 509 } -
issm/trunk-jpl/src/c/cores/dakota_core.cpp
r19634 r23066 235 235 void dakota_core(FemModel* femmodel){ /*{{{*/ 236 236 237 238 237 int my_rank; 239 238 char *dakota_input_file = NULL; -
issm/trunk-jpl/src/c/cores/damage_core.cpp
r19527 r23066 19 19 char **requested_outputs = NULL; 20 20 21 22 21 //first recover parameters common to all solutions 23 22 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); -
issm/trunk-jpl/src/c/cores/esa_core.cpp
r22349 r23066 23 23 int numoutputs = 0; 24 24 char **requested_outputs = NULL; 25 25 26 26 /*additional parameters: */ 27 27 int gsize; … … 80 80 U_x = new Vector<IssmDouble>(gsize); 81 81 U_y = new Vector<IssmDouble>(gsize); 82 82 83 83 /*call the geodetic main modlule:*/ 84 84 if(domaintype==Domain3DsurfaceEnum){ … … 95 95 InputUpdateFromVectorx(femmodel,U_north,EsaNmotionEnum,VertexSIdEnum); // north motion 96 96 InputUpdateFromVectorx(femmodel,U_east,EsaEmotionEnum,VertexSIdEnum); // east motion 97 97 98 98 if(save_results){ 99 99 if(VerboseSolution()) _printf0_(" saving results\n"); … … 101 101 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs); 102 102 } 103 103 104 104 if(solution_type==EsaSolutionEnum)femmodel->RequestedDependentsx(); 105 105 … … 115 115 } 116 116 /*}}}*/ 117 -
issm/trunk-jpl/src/c/cores/gia_core.cpp
r22009 r23066 53 53 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],2); 54 54 } 55 55 56 56 xDelete<IssmDouble>(x); 57 57 xDelete<IssmDouble>(y); -
issm/trunk-jpl/src/c/cores/love_core.cpp
r22382 r23066 28 28 /*parameters: */ 29 29 bool save_results; 30 30 31 31 if(VerboseSolution()) _printf0_(" computing LOVE numbers\n"); 32 32 33 33 /*Recover some parameters: */ 34 34 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); 35 35 36 36 /*recover love number parameters: */ 37 37 femmodel->parameters->FindParam(&nfreq,LoveNfreqEnum); … … 45 45 femmodel->parameters->FindParam(&love_kernels,LoveKernelsEnum); 46 46 femmodel->parameters->FindParam(&forcing_type,LoveForcingTypeEnum); 47 47 48 48 /*recover materials parameters: there is only one Matlitho, chase it down the hard way:*/ 49 49 Matlitho* matlitho=NULL; -
issm/trunk-jpl/src/c/cores/masstransport_core.cpp
r21077 r23066 31 31 femmodel->parameters->FindParam(&stabilization,MasstransportStabilizationEnum); 32 32 if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,MasstransportRequestedOutputsEnum); 33 33 34 34 if(VerboseSolution()) _printf0_(" computing mass transport\n"); 35 35 -
issm/trunk-jpl/src/c/cores/sealevelrise_core.cpp
r22982 r23066 13 13 void sealevelrise_core(FemModel* femmodel){ /*{{{*/ 14 14 15 16 15 /*Parameters, variables:*/ 17 16 bool save_results; 18 17 bool isslr=0; 19 18 int solution_type; 20 19 21 20 /*Retrieve parameters:*/ 22 21 femmodel->parameters->FindParam(&isslr,TransientIsslrEnum); 23 22 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum); 24 23 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); 25 24 26 25 /*in case we are running SealevelriseSolutionEnum, then bypass transient settings:*/ 27 26 if(solution_type==SealevelriseSolutionEnum)isslr=1; … … 41 40 /*Run steric core for sure:*/ 42 41 steric_core(femmodel); 43 42 44 43 /*Save results: */ 45 44 if(save_results){ … … 58 57 /*}}}*/ 59 58 void geodetic_core(FemModel* femmodel){ /*{{{*/ 60 61 59 62 60 /*variables:*/ … … 88 86 /*Should we even be here?:*/ 89 87 femmodel->parameters->FindParam(&geodetic,SealevelriseGeodeticEnum); if(!geodetic)return; 90 88 91 89 /*Verbose: */ 92 90 if(VerboseSolution()) _printf0_(" computing geodetic sea level rise\n"); … … 155 153 /*recover N_esa = U_esa + RSLg:*/ 156 154 N_esa=U_esa->Duplicate(); U_esa->Copy(N_esa); N_esa->AXPY(RSLg,1); 157 155 158 156 /*transform these values into rates (as we only run this once each frequency turn:*/ 159 157 N_esa_rate=N_esa->Duplicate(); N_esa->Copy(N_esa_rate); N_esa_rate->Scale(1/(dt*frequency)); … … 162 160 U_gia_rate=U_gia->Duplicate(); U_gia->Copy(U_gia_rate); U_gia_rate->Scale(1/(dt*frequency)); 163 161 RSLg_rate=RSLg->Duplicate(); RSLg->Copy(RSLg_rate); RSLg_rate->Scale(1/(dt*frequency)); 164 162 165 163 /*get some results into elements:{{{*/ 166 164 InputUpdateFromVectorx(femmodel,U_esa_rate,SealevelUEsaRateEnum,VertexSIdEnum); … … 182 180 } 183 181 184 185 182 if(iscoupler){ 186 183 /*transfer sea level back to ice caps:*/ … … 228 225 Vector<IssmDouble> *U_gia_rate= NULL; 229 226 Vector<IssmDouble> *N_gia_rate= NULL; 230 227 231 228 /*parameters: */ 232 229 bool isslr=0; … … 243 240 /*in case we are running SealevelriseSolutionEnum, then bypass transient settings:*/ 244 241 if(solution_type==SealevelriseSolutionEnum)isslr=1; 245 242 246 243 /*Should we be here?:*/ 247 244 if(!isslr)return; … … 291 288 /*}}}*/ 292 289 Vector<IssmDouble>* sealevelrise_core_eustatic(FemModel* femmodel){ /*{{{*/ 293 290 294 291 /*Eustatic core of the SLR solution (terms that are constant with respect to sea-level)*/ 295 292 … … 318 315 /*Figure out size of g-set deflection vector and allocate solution vector: */ 319 316 gsize = femmodel->nodes->NumberOfDofs(configuration_type,GsetEnum); 320 317 321 318 /*Initialize:*/ 322 319 RSLgi = new Vector<IssmDouble>(gsize); … … 331 328 * presence of ice (terms 1 and 4 in Eq.4 of Farrel and Clarke):*/ 332 329 RSLgi->Shift(-eustatic-RSLgi_oceanaverage); 333 330 334 331 /*save eustatic value for results: */ 335 332 femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,SealevelRSLEustaticEnum,-eustatic)); 336 337 333 338 334 /*clean up and return:*/ … … 346 342 /*sealevelrise_core_noneustatic.cpp //this computes the contributions from Eq.4 of Farrel and Clarke, rhs terms 2 and 5. 347 343 non eustatic core of the SLR solution */ 348 349 344 350 345 Vector<IssmDouble> *RSLg = NULL; … … 380 375 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 381 376 femmodel->parameters->FindParam(&loop,SealevelriseLoopIncrementEnum); 382 377 383 378 /*computational flag: */ 384 379 femmodel->parameters->FindParam(&rotation,SealevelriseRotationEnum); … … 389 384 /*Figure out size of g-set deflection vector and allocate solution vector: */ 390 385 gsize = femmodel->nodes->NumberOfDofs(configuration_type,GsetEnum); 391 386 392 387 /*Initialize:*/ 393 388 RSLg = new Vector<IssmDouble>(gsize); … … 400 395 count=1; 401 396 converged=false; 402 397 403 398 /*Start loop: */ 404 399 for(;;){ … … 413 408 /*call the non eustatic module: */ 414 409 femmodel->SealevelriseNonEustatic(RSLgo, RSLg_old, latitude, longitude, radius,verboseconvolution,loop); 415 410 416 411 /*assemble solution vector: */ 417 412 RSLgo->Assemble(); … … 423 418 femmodel->SealevelriseRotationalFeedback(RSLgo_rot,RSLg_old,&Ixz,&Iyz,&Izz,latitude,longitude,radius); 424 419 RSLgo_rot->Assemble(); 425 420 426 421 /*save changes in inertia tensor as results: */ 427 422 femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,SealevelInertiaTensorXZEnum,Ixz)); … … 431 426 RSLgo->AXPY(RSLgo_rot,1); 432 427 } 433 428 434 429 /*we need to average RSLgo over the ocean: RHS term 5 in Eq.4 of Farrel and clarke. Only the elements can do that: */ 435 430 RSLgo_oceanaverage=femmodel->SealevelriseOceanAverage(RSLgo); 436 431 437 432 /*RSLg is the sum of the eustatic term, and the ocean terms: */ 438 433 RSLg_eustatic->Copy(RSLg); RSLg->AXPY(RSLgo,1); … … 455 450 break; 456 451 } 457 452 458 453 /*some minor verbosing adjustment:*/ 459 454 if(count>1)verboseconvolution=false; 460 455 461 456 } 462 457 if(VerboseConvergence()) _printf0_("\n total number of iterations: " << count-1 << "\n"); … … 474 469 Vector<IssmDouble> *U_north_esa = NULL; 475 470 Vector<IssmDouble> *U_east_esa = NULL; 476 471 477 472 /*parameters: */ 478 473 int configuration_type; … … 507 502 VertexCoordinatesx(&latitude,&longitude,&radius,femmodel->vertices,spherical); 508 503 VertexCoordinatesx(&xx,&yy,&zz,femmodel->vertices); 509 504 510 505 /*call the elastic main modlule:*/ 511 506 femmodel->SealevelriseElastic(U_esa,U_north_esa,U_east_esa,RSLg,latitude,longitude,radius,xx,yy,zz,loop,horiz); … … 532 527 Vector<IssmDouble> *U_gia = NULL; 533 528 Vector<IssmDouble> *N_gia = NULL; 534 529 535 530 /*parameters:*/ 536 531 int frequency; … … 570 565 Vector<IssmDouble>* forcingglobal=NULL; 571 566 int* nvs=NULL; 572 567 573 568 /*transition vectors:*/ 574 569 IssmDouble** transitions=NULL; … … 577 572 int* transitions_n=NULL; 578 573 int nv; 579 574 580 575 /*communicators:*/ 581 576 ISSM_MPI_Comm tocomm; … … 591 586 femmodel->parameters->FindParam(&nummodels,NumModelsEnum); 592 587 my_rank=IssmComm::GetRank(); 593 588 594 589 /*retrieve the inter communicators that will be used to send data from each ice cap to the earth: */ 595 590 if(modelid==earthid){ … … 620 615 ISSM_MPI_Recv(forcings[i], nvs[i], ISSM_MPI_DOUBLE, 0,i, fromcomms[i], &status); 621 616 } 622 617 623 618 } 624 619 else{ … … 631 626 /*On the earth model, consolidate all the forcings into one, and update the elements dataset accordingly: {{{*/ 632 627 if(modelid==earthid){ 633 628 634 629 /*Out of all the delta thicknesses, build one delta thickness vector made of all the ice cap contributions. 635 630 *First, build the global delta thickness vector in the earth model: */ … … 652 647 /*build index to plug values: */ 653 648 int* index=xNew<int>(M); for(int i=0;i<M;i++)index[i]=reCast<int>(transition[i])-1; //matlab indexing! 654 655 649 656 650 /*We are going to plug this vector into the earth model, at the right vertices corresponding to this particular … … 663 657 /*Assemble vector:*/ 664 658 forcingglobal->Assemble(); 665 659 666 660 /*Plug into elements:*/ 667 661 InputUpdateFromVectorx(femmodel,forcingglobal,forcingenum,VertexSIdEnum); … … 696 690 IssmDouble* forcing=NULL; 697 691 IssmDouble* forcingglobal=NULL; 698 692 699 693 /*transition vectors:*/ 700 694 IssmDouble** transitions=NULL; … … 703 697 int* transitions_n=NULL; 704 698 int nv; 705 699 706 700 /*communicators:*/ 707 701 ISSM_MPI_Comm fromcomm; … … 718 712 femmodel->parameters->FindParam(&nummodels,NumModelsEnum); 719 713 my_rank=IssmComm::GetRank(); 720 714 721 715 /*retrieve the inter communicators that will be used to send data from earth to ice caps:*/ 722 716 if(modelid==earthid){ … … 733 727 } 734 728 735 736 729 /*Retrieve sea-level on earth model: */ 737 730 if(modelid==earthid){ … … 742 735 /*Send the forcing to the ice caps:{{{*/ 743 736 if(my_rank==0){ 744 737 745 738 if(modelid==earthid){ 746 739 747 740 /*Retrieve transition vectors, used to figure out global forcing contribution to each ice cap's own elements: */ 748 741 femmodel->parameters->FindParam(&transitions,&ntransitions,&transitions_m,&transitions_n,SealevelriseTransitionsEnum); 749 742 750 743 if(ntransitions!=earthid)_error_("TransferSeaLevel error message: number of transition vectors is not equal to the number of icecaps!"); 751 744 … … 804 797 Vector<IssmDouble> *cumdeltathickness = NULL; 805 798 int nv; 806 799 807 800 if(VerboseSolution()) _printf0_(" computing earth mass transport\n"); 808 801 … … 840 833 } /*}}}*/ 841 834 void slrconvergence(bool* pconverged, Vector<IssmDouble>* RSLg,Vector<IssmDouble>* RSLg_old,IssmDouble eps_rel,IssmDouble eps_abs){ /*{{{*/ 842 835 843 836 bool converged=true; 844 837 IssmDouble ndS,nS; … … 848 841 dRSLg=RSLg_old->Duplicate(); RSLg_old->Copy(dRSLg); dRSLg->AYPX(RSLg,-1.0); 849 842 ndS=dRSLg->Norm(NORM_TWO); 850 843 851 844 if (xIsNan<IssmDouble>(ndS)) _error_("convergence criterion is NaN!"); 852 845 853 846 if(!xIsNan<IssmDouble>(eps_rel)){ 854 847 nS=RSLg_old->Norm(NORM_TWO); 855 848 if (xIsNan<IssmDouble>(nS)) _error_("convergence criterion is NaN!"); 856 849 } 857 858 850 859 851 //clean up -
issm/trunk-jpl/src/c/cores/smb_core.cpp
r19528 r23066 29 29 femmodel->parameters->FindParam(&numoutputs,SmbNumRequestedOutputsEnum); 30 30 if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,SmbRequestedOutputsEnum); 31 31 32 32 if(VerboseSolution()) _printf0_(" computing smb \n"); 33 33 34 34 analysis = new SmbAnalysis(); 35 35 analysis->Core(femmodel); -
issm/trunk-jpl/src/c/cores/stressbalance_core.cpp
r23030 r23066 22 22 char **requested_outputs = NULL; 23 23 Analysis *analysis = NULL; 24 25 24 26 25 /* recover parameters:*/ … … 36 35 femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum); 37 36 if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,StressbalanceRequestedOutputsEnum); 38 37 39 38 if(VerboseSolution()) _printf0_(" computing new velocity\n"); 40 39 … … 79 78 } 80 79 81 82 80 if(save_results){ 83 81 if(VerboseSolution()) _printf0_(" saving results\n"); 84 82 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs); 85 83 } 86 84 87 85 if(solution_type==StressbalanceSolutionEnum && !control_analysis)femmodel->RequestedDependentsx(); 88 86 -
issm/trunk-jpl/src/c/datastructures/DataSet.cpp
r21701 r23066 92 92 /*Specific methods*/ 93 93 void DataSet::Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 94 94 95 95 vector<Object*>::iterator obj; 96 96 int obj_size=0; -
issm/trunk-jpl/src/c/main/esmfbinders.cpp
r20972 r23066 2 2 * \brief: ESMF binders for ISSM. Binders developed initially for the GEOS-5 framework. 3 3 */ 4 5 4 6 5 #include "./issm.h" … … 36 35 /*Some specific code here for the binding: */ 37 36 femmodel->parameters->SetParam(SMBgcmEnum,SmbEnum); //bypass SMB model, will be provided by GCM! 38 37 39 38 /*Restart file: */ 40 39 femmodel->Restart(); … … 113 112 114 113 IssmDouble surface; 115 114 116 115 /*Recover surface from the ISSM element: */ 117 116 Input* surface_input = element->GetInput(SurfaceEnum); _assert_(surface_input); 118 117 surface_input->GetInputAverage(&surface); 119 118 120 119 *(issmoutputs+f*numberofelements+i) = surface; 121 120 … … 147 146 /*Output results: */ 148 147 OutputResultsx(femmodel); 149 148 150 149 /*Check point: */ 151 150 femmodel->CheckPoint(); -
issm/trunk-jpl/src/c/main/issm_dakota.cpp
r21876 r23066 16 16 int main(int argc,char **argv){ 17 17 18 19 18 #if defined(_HAVE_DAKOTA_) && _DAKOTA_MAJOR_ >= 6 20 19 … … 29 28 /*Initialize MPI: */ 30 29 ISSM_MPI_Init(&argc, &argv); // initialize MPI 31 30 32 31 /*Recover file name for dakota input file:*/ 33 32 dakota_input_file=xNew<char>((strlen(argv[2])+strlen(argv[3])+strlen(".qmu.in")+2)); 34 33 sprintf(dakota_input_file,"%s/%s%s",argv[2],argv[3],".qmu.in"); 35 34 36 35 dakota_output_file=xNew<char>((strlen(argv[2])+strlen(argv[3])+strlen(".qmu.out")+2)); 37 36 sprintf(dakota_output_file,"%s/%s%s",argv[2],argv[3],".qmu.out"); … … 57 56 Dakota::abort_handler(-1); 58 57 } 59 58 60 59 Dakota::ProblemDescDB& problem_db = env.problem_description_db(); 61 60 Dakota::ModelLIter ml_iter; -
issm/trunk-jpl/src/c/main/issm_ocean.cpp
r22656 r23066 22 22 /*Initialize environment (MPI, PETSC, MUMPS, etc ...)*/ 23 23 worldcomm=EnvironmentInit(argc,argv); 24 24 25 25 /*What is my rank?:*/ 26 26 ISSM_MPI_Comm_rank(worldcomm,&my_rank); … … 39 39 40 40 FemModel *femmodel = new FemModel(argc,argv,modelcomm); 41 41 42 42 /*Now that the models are initialized, keep communicator information in the parameters datasets of each model: */ 43 43 femmodel->parameters->AddObject(new GenericParam<ISSM_MPI_Comm>(worldcomm,WorldCommEnum)); -
issm/trunk-jpl/src/c/main/issm_slr.cpp
r22190 r23066 28 28 /*Initialize environment (MPI, PETSC, MUMPS, etc ...)*/ 29 29 worldcomm=EnvironmentInit(argc,argv); 30 30 31 31 /*What is my rank?:*/ 32 32 ISSM_MPI_Comm_rank(worldcomm,&my_rank); … … 40 40 for(int i=0;i<nummodels;i++){ 41 41 char* string=NULL; 42 42 43 43 string=xNew<char>(strlen(argv[5+3*i])+1); 44 44 xMemCpy<char>(string,argv[5+3*i],strlen(argv[5+3*i])+1); 45 45 dirnames[i]=string; 46 46 47 47 string=xNew<char>(strlen(argv[5+3*i+1])+1); 48 48 xMemCpy<char>(string,argv[5+3*i+1],strlen(argv[5+3*i+1])+1); … … 94 94 /*Initialize femmodel from arguments provided command line: */ 95 95 FemModel *femmodel = new FemModel(4,arguments,modelcomm); 96 96 97 97 /*Now that the models are initialized, keep communicator information in the parameters datasets of each model: */ 98 98 femmodel->parameters->AddObject(new GenericParam<ISSM_MPI_Comm>(worldcomm,WorldCommEnum)); -
issm/trunk-jpl/src/c/modules/AllocateSystemMatricesx/AllocateSystemMatricesx.cpp
r21889 r23066 78 78 if(ppf) pf =new Vector<IssmDouble>(flocalsize,fsize); 79 79 } 80 80 81 81 /*Free ressources: */ 82 82 xDelete<char>(toolkittype); -
issm/trunk-jpl/src/c/modules/DistanceToMaskBoundaryx/DistanceToMaskBoundaryxt.cpp
r22379 r23066 39 39 IssmDouble d0=1.e+10; 40 40 IssmDouble xi,yi; 41 41 42 42 //recover vertex position: 43 43 xi=x[i]; yi=y[i]; -
issm/trunk-jpl/src/c/modules/ExpToLevelSetx/ExpToLevelSetxt.cpp
r22458 r23066 52 52 double x2,y2; 53 53 double mind; 54 54 55 55 for(int i=i0;i<i1;i++){ 56 56 … … 93 93 return sqrt(pow(x2-x0,2)+pow(y2-y0,2)); 94 94 } 95 95 96 96 /*Projection falls on segment*/ 97 97 double projx= x1 + t* (x2-x1); -
issm/trunk-jpl/src/c/modules/FloatingiceMeltingRatePicox/FloatingiceMeltingRatePicox.cpp
r23053 r23066 107 107 femmodel->parameters->FindParam(&num_basins,BasalforcingsPicoNumBasinsEnum); 108 108 femmodel->parameters->FindParam(&maxbox,BasalforcingsPicoMaxboxcountEnum); 109 109 110 110 IssmDouble* boxareas=xNewZeroInit<IssmDouble>(num_basins*maxbox); 111 111 … … 122 122 ISSM_MPI_Allreduce(boxareas,sumareas,num_basins*maxbox,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 123 123 //if(sumareas[0]==0){_error_("No elements in box 0, basal meltrates will be 0. Consider decreasing md.basalforcings.maxboxcount or refining your mesh!");} 124 124 125 125 /*Update parameters to keep track of the new areas in future calculations*/ 126 126 femmodel->parameters->AddObject(new DoubleVecParam(BasalforcingsPicoBoxAreaEnum,sumareas,maxbox*num_basins)); -
issm/trunk-jpl/src/c/modules/FloatingiceMeltingRatex/FloatingiceMeltingRatex.cpp
r22953 r23066 67 67 } 68 68 /*}}}*/ 69 -
issm/trunk-jpl/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp
r22828 r23066 27 27 int size = 0; 28 28 for(int i=0;i<num_controls;i++) size+=M[i]*N[i]; 29 30 29 31 30 /*2. Allocate vector*/ … … 59 58 parameters->FindParam(&num_controls,InversionNumControlParametersEnum); 60 59 parameters->FindParam(&control_type,NULL,InversionControlParametersEnum); 61 62 60 63 61 /*2. Allocate vector*/ -
issm/trunk-jpl/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp
r22952 r23066 84 84 /*this one is special: we don't specify the type, but let the nature of the inputs dictace. 85 85 * P0 -> ElementSIdEnum, P1 ->VertexSIdEnum: */ 86 86 87 87 /*We go find the input of the first element, and query its interpolation type: */ 88 88 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(0)); -
issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
r23035 r23066 15 15 Element *element = NULL; 16 16 17 18 17 /*retrieve parameters: */ 19 18 parameters->FindParam(&migration_style,GroundinglineMigrationEnum); … … 21 20 22 21 if(migration_style==NoneEnum) return; 23 22 24 23 if(VerboseModule()) _printf0_(" Migrating grounding line\n"); 25 24 -
issm/trunk-jpl/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp
r21915 r23066 166 166 167 167 /*edge can be either IntersectEnum (one and only one intersection between the edge and the segment), ColinearEnum (edge and segment are collinear) and SeparateEnum (no intersection): */ 168 168 169 169 /*if (el==318 && contouri==9){ 170 170 _printf_(edge1 << " " << edge2 << " " << edge3 << " " << alpha1 << " " << alpha2 << " " << beta1 << " " << beta2 << " " << gamma1 << " " << gamma2 << " " << xsegment[0] << " " << xsegment[1] << " " << ysegment[0] << " " << ysegment[1] << " " << xnodes[0] << " " << xnodes[1] << " " << xnodes[2] << " " << ynodes[0] << " " << ynodes[1] << " " << ynodes[2]); 171 171 172 172 _printf_("Bool" << (edge1==IntersectEnum) || (edge2==IntersectEnum) || (edge3==IntersectEnum)); 173 173 }*/ … … 199 199 segments_dataset->AddObject(new Segment<double>(el+1,xfinal[0],yfinal[0],xfinal[1],yfinal[1])); 200 200 201 202 201 /*This case is impossible: not quite! */ 203 202 //_printf_(alpha1 << " " << alpha2 << " " << beta1 << " " << beta2 << " " << gamma1 << " " << gamma2 << " " << xsegment[0] << " " << xsegment[1] << " " << ysegment[0] << " " << ysegment[1] << " " << xnodes[0] << " " << xnodes[1] << " " << xnodes[2] << " " << ynodes[0] << " " << ynodes[1] << " " << ynodes[2]); … … 226 225 } 227 226 else if( (edge1==IntersectEnum) || (edge2==IntersectEnum) || (edge3==IntersectEnum) ){ 228 227 229 228 /*if (el==318 && contouri==9){ 230 229 _printf_("hello" << " NodeInElement 0 " << (NodeInElement(xnodes,ynodes,xsegment[0],ysegment[0])) << " NodeInElement 1 " << (NodeInElement(xnodes,ynodes,xsegment[1],ysegment[1]))); … … 251 250 IsIdenticalNode(xnodes[1],ynodes[1],xsegment[0],ysegment[0],tolerance) || 252 251 IsIdenticalNode(xnodes[2],ynodes[2],xsegment[0],ysegment[0],tolerance)){ 253 252 254 253 /*ok, segments[0] is common to one of our vertices: */ 255 254 coord1=0; -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
r22612 r23066 69 69 int num_independent_objects,M; 70 70 char** names = NULL; 71 71 72 72 /*this is done somewhere else*/ 73 73 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.num_independent_objects",InversionNumControlParametersEnum)); 74 74 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.num_dependent_objects",InversionNumCostFunctionsEnum)); 75 75 76 76 /*Step1: create controls (independents)*/ 77 77 iomodel->FetchData(&num_independent_objects,"md.autodiff.num_independent_objects"); … … 96 96 xDelete<char*>(cm_responses); 97 97 parameters->AddObject(new IntVecParam(InversionCostFunctionsEnum,costfunc_enums,num_costfunc)); 98 98 99 99 iomodel->FetchData(&control_scaling_factors,NULL,NULL,"md.autodiff.independent_scaling_factors"); 100 100 parameters->AddObject(new DoubleVecParam(InversionControlScalingFactorsEnum,control_scaling_factors,num_independent_objects)); 101 101 102 102 /*cleanup*/ 103 103 for(int i=0;i<num_independent_objects;i++){ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp
r22753 r23066 8 8 #include "../../MeshPartitionx/MeshPartitionx.h" 9 9 #include "../ModelProcessorx.h" 10 11 10 12 11 #if !defined(_HAVE_ADOLC_) … … 22 21 char **cost_functions = NULL; 23 22 24 25 23 /*Fetch parameters: */ 26 24 iomodel->FindConstant(&control_analysis,"md.inversion.iscontrol"); … … 29 27 /*Now, return if no control*/ 30 28 if(!control_analysis) return; 31 29 32 30 /*Process controls and convert from string to enums*/ 33 31 iomodel->FindConstant(&controls,&num_controls,"md.inversion.control_parameters"); … … 48 46 49 47 iomodel->FetchData(3,"md.inversion.cost_functions_coefficients","md.inversion.min_parameters","md.inversion.max_parameters"); 50 48 51 49 /*Fetch Observations */ 52 50 iomodel->FindConstant(&domaintype,"md.mesh.domain_type"); … … 154 152 iomodel->FetchData(&types,NULL,NULL,"md.autodiff.independent_object_types"); 155 153 156 157 154 M_all = xNew<int>(num_independent_objects); 158 155 … … 162 159 iomodel->FetchData(&independents_fullmax,&M_par,&N_par,"md.autodiff.independent_max_parameters"); 163 160 iomodel->FetchData(&control_sizes,NULL,NULL,"md.autodiff.independent_control_sizes"); 164 161 165 162 int* start_point = NULL; 166 163 start_point = xNew<int>(num_independent_objects); … … 180 177 IssmDouble* independents_min = NULL; 181 178 IssmDouble* independents_max = NULL; 182 179 183 180 FieldAndEnumFromCode(&input_enum,&iofieldname,names[i]); 184 181 … … 187 184 _assert_(independent); 188 185 _assert_(N==control_sizes[i]); 189 186 190 187 independents_min = NULL; independents_min = xNew<IssmDouble>(M*N); 191 188 independents_max = NULL; independents_max = xNew<IssmDouble>(M*N); … … 206 203 xDelete<IssmDouble>(independents_min); 207 204 xDelete<IssmDouble>(independents_max); 208 205 209 206 } 210 207 else{ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp
r23053 r23066 35 35 /*Create elements*/ 36 36 if(control_analysis && !adolc_analysis)iomodel->FetchData(2,"md.inversion.min_parameters","md.inversion.max_parameters"); 37 37 38 38 switch(iomodel->meshelementtype){ 39 39 case TriaEnum: … … 123 123 break; 124 124 case MaterialsEnum: 125 125 126 126 //we have several types of materials. Retrieve this info first: 127 127 iomodel->FetchData(&nature,&nnat,&dummy,"md.materials.nature"); … … 235 235 else iomodel->FetchDataToInput(elements,"md.mesh.scale_factor",MeshScaleFactorEnum,1.); 236 236 if (isoceancoupling) iomodel->FetchData(2,"md.mesh.lat","md.mesh.long"); 237 237 238 238 CreateNumberNodeToElementConnectivity(iomodel,solution_type); 239 239 -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp
r22971 r23066 11 11 12 12 int i,j; 13 13 14 14 DataSet* output_definitions = NULL; 15 15 int* output_definition_enums = NULL; … … 65 65 else if (output_definition_enums[i]==MisfitEnum){ 66 66 /*Deal with misfits: {{{*/ 67 67 68 68 /*misfit variables: */ 69 69 int nummisfits; … … 115 115 _error_("misfit weight size not supported yet"); 116 116 117 118 117 /*First create a misfit object for that specific string (misfit_model_string_s[j]):*/ 119 118 output_definitions->AddObject(new Misfit(misfit_name_s[j],StringToEnumx(misfit_definitionstring_s[j]),StringToEnumx(misfit_model_string_s[j]),StringToEnumx(misfit_observation_string_s[j]),misfit_timeinterpolation_s[j],misfit_local_s[j],StringToEnumx(misfit_weights_string_s[j]))); … … 159 158 else if (output_definition_enums[i]==CfsurfacesquareEnum){ 160 159 /*Deal with cfsurfacesquare: {{{*/ 161 160 162 161 /*cfsurfacesquare variables: */ 163 162 int num_cfsurfacesquares; … … 214 213 215 214 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(k)); 216 215 217 216 element->DatasetInputAdd(StringToEnumx(cfsurfacesquare_definitionstring_s[j]),cfsurfacesquare_observation_s[j], iomodel,cfsurfacesquare_observation_M_s[j],cfsurfacesquare_observation_N_s[j],obs_vector_type,StringToEnumx(cfsurfacesquare_observation_string_s[j]),7,SurfaceObservationEnum); 218 217 element->DatasetInputAdd(StringToEnumx(cfsurfacesquare_definitionstring_s[j]),cfsurfacesquare_weights_s[j], iomodel,cfsurfacesquare_weights_M_s[j],cfsurfacesquare_weights_N_s[j],weight_vector_type,StringToEnumx(cfsurfacesquare_weights_string_s[j]),7,WeightsSurfaceObservationEnum); … … 251 250 else if (output_definition_enums[i]==CfdragcoeffabsgradEnum){ 252 251 /*Deal with cfdragcoeffabsgrad: {{{*/ 253 252 254 253 /*cfdragcoeffabsgrad variables: */ 255 254 int num_cfdragcoeffabsgrads; … … 286 285 287 286 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(k)); 288 287 289 288 element->DatasetInputAdd(StringToEnumx(cfdragcoeffabsgrad_definitionstring_s[j]),cfdragcoeffabsgrad_weights_s[j], iomodel,cfdragcoeffabsgrad_weights_M_s[j],cfdragcoeffabsgrad_weights_N_s[j],weight_vector_type,StringToEnumx(cfdragcoeffabsgrad_weights_string_s[j]),7,WeightsSurfaceObservationEnum); 290 289 … … 313 312 else if (output_definition_enums[i]==CfsurfacelogvelEnum){ 314 313 /*Deal with cfsurfacelogvel: {{{*/ 315 314 316 315 /*cfsurfacelogvel variables: */ 317 316 int num_cfsurfacelogvels; … … 369 368 370 369 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(k)); 371 370 372 371 element->DatasetInputAdd(StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_vxobs[j], iomodel,cfsurfacelogvel_observation_M[j],cfsurfacelogvel_observation_N[j],obs_vector_type,StringToEnumx(cfsurfacelogvel_vxobs_string[j]),7,VxObsEnum); 373 372 element->DatasetInputAdd(StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_vyobs[j], iomodel,cfsurfacelogvel_observation_M[j],cfsurfacelogvel_observation_N[j],obs_vector_type,StringToEnumx(cfsurfacelogvel_vyobs_string[j]),7,VyObsEnum); … … 409 408 else if (output_definition_enums[i]==NodalvalueEnum){ 410 409 /*Deal with nodal values: {{{*/ 411 410 412 411 /*nodal value variables: */ 413 412 int numnodalvalues; … … 428 427 output_definitions->AddObject(new Nodalvalue(nodalvalue_name_s[j],StringToEnumx(nodalvalue_definitionstrings[j]),StringToEnumx(nodalvalue_modelstrings[j]),nodalvalue_node_s[j]-1)); //-1 because matlab to c indexing. 429 428 } 430 429 431 430 /*Free ressources:*/ 432 431 for(j=0;j<numnodalvalues;j++){ … … 482 481 else if (output_definition_enums[i]==MassconaxpbyEnum){ 483 482 /*Deal with masscon combinations: {{{*/ 484 483 485 484 /*masscon variables: */ 486 485 char** masscon_name_s = NULL; … … 617 616 output_definitions->AddObject(new Numberedcostfunction(ncf_name_s[j],StringToEnumx(ncf_definitionstring_s[j]),num_cost_functions,cost_function_enums)); 618 617 } 619 618 620 619 /*Free data: */ 621 620 iomodel->DeleteData(2,"md.numberedcostfunction.name","md.numberedcostfunction.definitionstring"); -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp
r22993 r23066 23 23 char* fieldname = NULL; 24 24 IssmDouble time; 25 25 26 26 /*parameters for mass flux:*/ 27 27 int mass_flux_num_profiles = 0; … … 62 62 parameters->AddObject(iomodel->CopyConstantObject("md.calving.law",CalvingLawEnum)); 63 63 parameters->AddObject(new IntParam(SealevelriseRunCountEnum,1)); 64 65 64 66 65 {/*This is specific to ice...*/ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
r22739 r23066 55 55 delete analysis; 56 56 57 58 57 /* Update counters, because we have created more nodes, loads and 59 58 * constraints, and ids for objects created in next call to CreateDataSets -
issm/trunk-jpl/src/c/modules/NodalValuex/NodalValuex.cpp
r20038 r23066 21 21 cpu_found=-1; 22 22 found=0; 23 23 24 24 for(int i=0;i<elements->Size();i++){ 25 25 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); -
issm/trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp
r22386 r23066 22 22 /*This is the object that we have been chasing for. compute the response and return: */ 23 23 IssmDouble return_value=definition->Response(femmodel); 24 24 25 25 /*cleanup: */ 26 26 xDelete<char>(name); … … 31 31 xDelete<char>(name); 32 32 } 33 33 34 34 /*If we are here, did not find the definition for this response, not good!: */ 35 35 _error_("Could not find the response for output definition " << output_string << " because could not find the definition itself!"); … … 44 44 /*Now, go through the output definitions, and retrieve the object which corresponds to our requested response, output_enum: */ 45 45 for(int i=0;i<output_definitions->Size();i++){ 46 46 47 47 //Definition* definition=xDynamicCast<Definition*>(output_definitions->GetObjectByOffset(i)); 48 48 Definition* definition=dynamic_cast<Definition*>(output_definitions->GetObjectByOffset(i)); … … 53 53 /*This is the object that we have been chasing for. compute the response and return: */ 54 54 IssmDouble return_value=definition->Response(femmodel); 55 55 56 56 /*return:*/ 57 57 return return_value; 58 58 } 59 59 } 60 60 61 61 /*If we are here, did not find the definition for this response, not good!: */ 62 62 _error_("Could not find the response for output definition " << EnumToStringx(output_enum) -
issm/trunk-jpl/src/c/modules/SetActiveNodesLSMx/SetActiveNodesLSMx.cpp
r22004 r23066 92 92 /* Intermediaries */ 93 93 int numvertices = element->GetNumberOfVertices(); 94 94 95 95 if(element->IsIceInElement()){ 96 96 for(int i = 0;i<numvertices;i++){ -
issm/trunk-jpl/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp
r22739 r23066 32 32 } 33 33 34 35 34 xDelete<int>(control_type); 36 35 } -
issm/trunk-jpl/src/c/modules/SurfaceMassBalancex/Gembx.cpp
r22840 r23066 107 107 xDelete(dzT); 108 108 xDelete(dzB); 109 109 110 110 //---------NEED TO IMPLEMENT A PROPER GRID STRECHING ALGORITHM------------ 111 111 … … 202 202 gdn=*pgdn; 203 203 gsp=*pgsp; 204 204 205 205 /*only when aIdx = 1 or 2 do we run grainGrowth: */ 206 206 if(aIdx!=1 & aIdx!=2){ … … 220 220 //set maximum water content by mass to 9 percent (Brun, 1980) 221 221 for(int i=0;i<m;i++)if(lwc[i]>9.0-Wtol) lwc[i]=9.0; 222 223 222 224 223 /* Calculate temperature gradiant across grid cells … … 244 243 // take absolute value of temperature gradient 245 244 for(int i=0;i<m;i++)dT[i]=fabs(dT[i]); 246 245 247 246 /*Snow metamorphism. Depends on value of snow dendricity and wetness of the snowpack: */ 248 247 for(int i=0;i<m;i++){ … … 324 323 re[i]=gsz[i]/2.0; 325 324 } 326 325 327 326 /*Free ressources:*/ 328 327 xDelete<IssmDouble>(gsz); … … 348 347 //// Inputs 349 348 // aIdx = albedo method to use 350 349 351 350 // Method 0 352 351 // aValue = direct input value for albedo, override all changes to albedo … … 397 396 /*Recover pointers: */ 398 397 a=*pa; 399 398 400 399 //some constants: 401 400 const IssmDouble dSnow = 300; // density of fresh snow [kg m-3] … … 513 512 514 513 /* ENGLACIAL THERMODYNAMICS*/ 515 514 516 515 /* Description: 517 516 computes new temperature profile accounting for energy absorption and … … 537 536 // T: grid cell temperature [k] 538 537 // EC: evaporation/condensation [kg] 539 538 540 539 /*intermediary: */ 541 540 IssmDouble* K = NULL; … … 580 579 IssmDouble dlw=0.0; 581 580 IssmDouble dT_dlw=0.0; 582 581 583 582 /*outputs:*/ 584 583 IssmDouble EC=0.0; … … 597 596 //initialize Evaporation - Condenstation 598 597 EC = 0.0; 599 598 600 599 // check if all SW applied to surface or distributed throught subsurface 601 600 // swIdx = length(swf) > 1 … … 609 608 // if V = 0 goes to infinity therfore if V = 0 change 610 609 if(V<0.01-Dtol)V=0.01; 611 610 612 611 // Bulk-transfer coefficient for turbulent fluxes 613 612 An = pow(0.4,2) / pow(log(Tz/z0),2); // Bulk-transfer coefficient … … 627 626 628 627 // THERMAL DIFFUSION COEFFICIENTS 629 628 630 629 // A discretization scheme which truncates the Taylor-Series expansion 631 630 // after the 3rd term is used. See Patankar 1980, Ch. 3&4 632 631 633 632 // discretized heat equation: 634 633 635 634 // Tp = (Au*Tu° + Ad*Td° + (Ap-Au-Ad)Tp° + S) / Ap 636 635 637 636 // where neighbor coefficients Au, Ap, & Ad are 638 637 639 638 // Au = [dz_u/2KP + dz_p/2KE]^-1 640 639 // Ad = [dz_d/2KP + dz_d/2KD]^-1 … … 649 648 KD = xNew<IssmDouble>(m); 650 649 KP = xNew<IssmDouble>(m); 651 650 652 651 KU[0] = UNDEF; 653 652 KD[m-1] = UNDEF; … … 661 660 dzU[0]=UNDEF; 662 661 dzD[m-1]=UNDEF; 663 662 664 663 for(int i=1;i<m;i++) dzU[i]= dz[i-1]; 665 664 for(int i=0;i<m-1;i++) dzD[i] = dz[i+1]; … … 693 692 Ap[i] = (d[i]*dz[i]*CI)/dt; 694 693 } 695 694 696 695 // create "neighbor" coefficient matrix 697 696 Nu = xNew<IssmDouble>(m); … … 703 702 Np[i]= 1.0 - Nu[i] - Nd[i]; 704 703 } 705 704 706 705 // specify boundary conditions: constant flux at bottom 707 706 Nu[m-1] = 0.0; 708 707 Np[m-1] = 1.0; 709 708 710 709 // zero flux at surface 711 710 Np[0] = 1.0 - Nd[0]; 712 711 713 712 // Create neighbor arrays for diffusion calculations instead of a tridiagonal matrix 714 713 Nu[0] = 0.0; 715 714 Nd[m-1] = 0.0; 716 715 717 716 /* RADIATIVE FLUXES*/ 718 717 … … 720 719 sw = xNew<IssmDouble>(m); 721 720 for(int i=0;i<m;i++) sw[i]= swf[i] * dt; 722 721 723 722 // temperature change due to SW 724 723 dT_sw = xNew<IssmDouble>(m); … … 746 745 // store initial temperature 747 746 //T_init = T; 748 747 749 748 // calculate temperature of snow surface (Ts) 750 749 // when incoming SW radition is allowed to penetrate the surface, … … 754 753 Ts = (T[0] + T[1])/2.0; 755 754 Ts = fmin(CtoK,Ts); // don't allow Ts to exceed 273.15 K (0 degC) 756 755 757 756 //TURBULENT HEAT FLUX 758 757 759 758 // Monin-Obukhov Stability Correction 760 759 // Reference: … … 764 763 // calculate the Bulk Richardson Number (Ri) 765 764 Ri = (2.0*9.81* (Vz - z0) * (Ta - Ts)) / ((Ta + Ts)* pow(V,2.0)); 766 765 767 766 // calculate Monin-Obukhov stability factors 'coefM' and 'coefH' 768 767 769 768 // do not allow Ri to exceed 0.19 770 769 Ri = fmin(Ri, 0.19); … … 778 777 coefM =pow (1.0-18*Ri,-0.25); 779 778 } 780 779 781 780 // calculate heat/wind 'coef_H' stability factor 782 781 if (Ri <= -0.03+Ttol) coefH = coefM/1.3; 783 782 else coefH = coefM; 784 783 785 784 //// Sensible Heat 786 785 // calculate the sensible heat flux [W m-2](Patterson, 1998) … … 801 800 else{ 802 801 L = LS; // latent heat of sublimation 803 802 804 803 // for an ice surface Murphy and Koop, 2005 [Equation 7] 805 804 eS = exp(9.550426 - 5723.265/Ts + 3.53068 * log(Ts) - 0.00728332 * Ts); … … 823 822 ulw = - (SB * pow(Ts,4.0)* teValue) * dt ; 824 823 dT_ulw = ulw / TCs; 825 824 826 825 // new grid point temperature 827 826 828 827 //SW penetrates surface 829 828 for(int j=0;j<m;j++) T[j] = T[j] + dT_sw[j]; 830 829 T[0] = T[0] + dT_dlw + dT_ulw + dT_turb; 831 830 832 831 // temperature diffusion 833 832 for(int j=0;j<m;j++) T0[1+j]=T[j]; … … 835 834 for(int j=0;j<m;j++) Td[j] = T0[2+j]; 836 835 for(int j=0;j<m;j++) T[j] = (Np[j] * T[j]) + (Nu[j] * Tu[j]) + (Nd[j] * Td[j]); 837 836 838 837 // calculate cumulative evaporation (+)/condensation(-) 839 838 EC = EC + (EC_day/dts)*dt; … … 873 872 xDelete<IssmDouble>(Td); 874 873 875 876 874 /*Assign output pointers:*/ 877 875 *pEC=EC; … … 901 899 // swf = absorbed shortwave radiation [W m-2] 902 900 // 903 901 904 902 /*outputs: */ 905 903 IssmDouble* swf=NULL; … … 910 908 swf=xNewZeroInit<IssmDouble>(m); 911 909 912 913 910 // SHORTWAVE FUNCTION 914 911 if (swIdx == 0) {// all sw radation is absorbed in by the top grid cell 915 912 916 913 // calculate surface shortwave radiation fluxes [W m-2] 917 914 swf[0] = (1.0 - as) * dsw; … … 948 945 } 949 946 950 951 947 // spectral albedos: 952 948 // 0.3 - 0.8um … … 988 984 B2_cum[i+1]=cum2; 989 985 } 990 991 986 992 987 // flux across grid cell boundaries … … 1015 1010 xDelete<IssmDouble>(Qs1); 1016 1011 xDelete<IssmDouble>(Qs2); 1017 1018 1012 1019 1013 } 1020 1014 else{ //function of grid cell density … … 1144 1138 1145 1139 if (P > 0.0+Dtol){ 1146 1147 1140 1148 1141 if (T_air <= CtoK+Ttol){ // if snow … … 1210 1203 1211 1204 mass_diff = mass - massinit - P; 1212 1205 1213 1206 #ifndef _HAVE_ADOLC_ //avoid round operation. only check in forward mode. 1214 1207 mass_diff = round(mass_diff * 100.0)/100.0; … … 1253 1246 IssmDouble* M=NULL; 1254 1247 int* D=NULL; 1255 1248 1256 1249 IssmDouble sumM=0.0; 1257 1250 IssmDouble sumER=0.0; … … 1265 1258 IssmDouble X=0.0; 1266 1259 IssmDouble Wi=0.0; 1267 1260 1268 1261 IssmDouble Ztot=0.0; 1269 1262 IssmDouble T_bot=0.0; … … 1279 1272 IssmDouble EW_bot=0.0; 1280 1273 bool top=false; 1281 1274 1282 1275 IssmDouble* Zcum=NULL; 1283 1276 IssmDouble* dzMin2=NULL; … … 1286 1279 int X1=0; 1287 1280 int X2=0; 1288 1281 1289 1282 int D_size = 0; 1290 1283 … … 1303 1296 int n=*pn; 1304 1297 IssmDouble* R=NULL; 1305 1298 1306 1299 if(VerboseSmb() && sid==0 && IssmComm::GetRank()==0)_printf0_(" melt module\n"); 1307 1300 … … 1335 1328 // for(int i=0;i<n;i++) T[i]-=exsT[i]; 1336 1329 for(int i=0;i<n;i++) T[i]=fmin(T[i],CtoK); 1337 1330 1338 1331 // specify irreducible water content saturation [fraction] 1339 1332 const IssmDouble Swi = 0.07; // assumed constant after Colbeck, 1974 … … 1493 1486 T[i] = T[i] + ((F1+F2)*(LF+(CtoK - T[i])*CI)/(m[i]*CI));// change in temperature 1494 1487 1495 1496 1488 // check if an ice layer forms 1497 1489 if (fabs(d[i] - dIce) < Dtol){ … … 1505 1497 } 1506 1498 1507 1508 1499 //// GRID CELL SPACING AND MODEL DEPTH 1509 1500 for(int i=0;i<n;i++)if (W[i] < 0.0 - Wtol) _error_("negative pore water generated in melt equations"); 1510 1501 1511 1502 // delete all cells with zero mass 1512 1503 // adjust pore water … … 1533 1524 n=D_size; 1534 1525 xDelete<int>(D); 1535 1526 1536 1527 // calculate new grid lengths 1537 1528 for(int i=0;i<n;i++)dz[i] = m[i] / d[i]; … … 1545 1536 Zcum=xNew<IssmDouble>(n); 1546 1537 dzMin2=xNew<IssmDouble>(n); 1547 1538 1548 1539 Zcum[0]=dz[0]; // Compute a cumulative depth vector 1549 1540 1550 1541 for (int i=1;i<n;i++){ 1551 1542 Zcum[i]=Zcum[i-1]+dz[i]; 1552 1543 } 1553 1544 1554 1545 for (int i=0;i<n;i++){ 1555 1546 if (Zcum[i]<=zTop+Dtol){ … … 1569 1560 } 1570 1561 } 1571 1562 1572 1563 //Last cell has to be treated separately if has to be merged (no underlying cell so need to merge with overlying cell) 1573 1564 if(X==n-1){ … … 1589 1580 gdn[i+1] = (gdn[i]*m[i] + gdn[i+1]*m[i+1]) / m_new; 1590 1581 gsp[i+1] = (gsp[i]*m[i] + gsp[i+1]*m[i+1]) / m_new; 1591 1582 1592 1583 // merge with underlying grid cell and delete old cell 1593 1584 dz[i+1] = dz[i] + dz[i+1]; // combine cell depths … … 1595 1586 W[i+1] = W[i+1] + W[i]; // combine liquid water 1596 1587 m[i+1] = m_new; // combine top masses 1597 1588 1598 1589 // set cell to 99999 for deletion 1599 1590 m[i] = -99999; … … 1611 1602 } 1612 1603 } 1613 1604 1614 1605 // adjust variables as a linearly weighted function of mass 1615 1606 IssmDouble m_new = m[X2] + m[X1]; … … 1619 1610 gdn[X1] = (gdn[X2]*m[X2] + gdn[X1]*m[X1]) / m_new; 1620 1611 gsp[X1] = (gsp[X2]*m[X2] + gsp[X1]*m[X1]) / m_new; 1621 1612 1622 1613 // merge with underlying grid cell and delete old cell 1623 1614 dz[X1] = dz[X2] + dz[X1]; // combine cell depths … … 1625 1616 W[X1] = W[X1] + W[X2]; // combine liquid water 1626 1617 m[X1] = m_new; // combine top masses 1627 1618 1628 1619 // set cell to 99999 for deletion 1629 1620 m[X2] = -99999; … … 1648 1639 n=D_size; 1649 1640 xDelete<int>(D); 1650 1641 1651 1642 // check if any of the top 10 cell depths are too large 1652 1643 X=0; … … 1657 1648 } 1658 1649 } 1659 1650 1660 1651 int j=0; 1661 1652 while(j<=X){ … … 1686 1677 // calculate total model depth 1687 1678 Ztot = cellsum(dz,n); 1688 1679 1689 1680 if (Ztot < zMin-Dtol){ 1690 1681 // printf("Total depth < zMin %f \n", Ztot); … … 1692 1683 mAdd = m[n-1]+W[n-1]; 1693 1684 addE = T[n-1]*m[n-1]*CI + W[n-1]*(LF+CtoK*CI); 1694 1685 1695 1686 // add a grid cell of the same size and temperature to the bottom 1696 1687 dz_bot=dz[n-1]; … … 1705 1696 EI_bot=EI[n-1]; 1706 1697 EW_bot=EW[n-1]; 1707 1698 1708 1699 dz_add=dz_bot; 1709 1700 1710 1701 newcell(&dz,dz_bot,top,n); 1711 1702 newcell(&T,T_bot,top,n); … … 1727 1718 addE = -(T[n-1]*m[n-1]*CI) - (W[n-1]*(LF+CtoK*CI)); 1728 1719 dz_add=-(dz[n-1]); 1729 1720 1730 1721 // remove a grid cell from the bottom 1731 1722 D_size=n-1; 1732 1723 D=xNew<int>(D_size); 1733 1724 1734 1725 for(int i=0;i<n-1;i++) D[i]=i; 1735 1726 celldelete(&dz,n,D,D_size); … … 1768 1759 << "dm: " << dm << " dE: " << dE << "\n"); 1769 1760 #endif 1770 1761 1771 1762 /*Free ressources:*/ 1772 1763 if(m)xDelete<IssmDouble>(m); … … 1784 1775 xDelete<IssmDouble>(Zcum); 1785 1776 xDelete<IssmDouble>(dzMin2); 1786 1777 1787 1778 /*Assign output pointers:*/ 1788 1779 *pM=sumM; … … 1862 1853 IssmDouble* dz=NULL; 1863 1854 IssmDouble* d=NULL; 1864 1855 1865 1856 if(VerboseSmb() && sid==0 && IssmComm::GetRank()==0)_printf0_(" densification module\n"); 1866 1857 … … 1871 1862 // initial mass 1872 1863 IssmDouble* mass_init = xNew<IssmDouble>(m);for(int i=0;i<m;i++) mass_init[i]=d[i] * dz[i]; 1873 1864 1874 1865 /*allocations and initialization of overburden pressure and factor H: */ 1875 1866 IssmDouble* cumdz = xNew<IssmDouble>(m-1); … … 1880 1871 obp[0]=0.0; 1881 1872 for(int i=1;i<m;i++)obp[i]=cumdz[i-1]*d[i-1]; 1882 1873 1883 1874 // calculate new snow/firn density for: 1884 1875 // snow with densities <= 550 [kg m-3] 1885 1876 // snow with densities > 550 [kg m-3] 1886 1887 1877 1888 1878 for(int i=0;i<m;i++){ 1889 1879 switch (denIdx){ … … 2004 1994 IssmDouble lhf=0.0; 2005 1995 IssmDouble EC=0.0; 2006 1996 2007 1997 if(VerboseSmb() && sid==0 && IssmComm::GetRank()==0)_printf0_(" turbulentFlux module\n"); 2008 1998 … … 2029 2019 2030 2020 // calculate Monin-Obukhov stability factors 'coef_M' and 'coef_H' 2031 2021 2032 2022 // do not allow Ri to exceed 0.19 2033 2023 Ri = fmin(Ri, 0.19); … … 2073 2063 } 2074 2064 2075 2076 2065 // Latent heat flux [W m-2] 2077 2066 lhf = C * L * (eAir - eS) * 0.622 / pAir; -
issm/trunk-jpl/src/c/modules/SurfaceMassBalancex/SurfaceMassBalancex.cpp
r22448 r23066 6 6 #include "../../shared/shared.h" 7 7 #include "../../toolkits/toolkits.h" 8 9 8 10 9 void SmbGradientsx(FemModel* femmodel){/*{{{*/ … … 318 317 smb = smb/yts + anomaly; 319 318 320 321 319 /*Update array accordingly*/ 322 320 smblist[v] = smb; -
issm/trunk-jpl/src/c/shared/Elements/ComputeD18OTemperaturePrecipitationFromPD.cpp
r22852 r23066 11 11 IssmDouble* PrecipitationReconstructed,IssmDouble* TemperatureReconstructed, IssmDouble* monthlytemperaturesout, 12 12 IssmDouble* monthlyprecout){ 13 13 14 14 IssmDouble monthlytemperaturestmp[12],monthlyprectmp[12]; 15 15 IssmDouble deltaTemp; 16 16 17 17 /* Constants */ 18 18 // dpermil = 2.4;/*degrees C per mil*/ 19 19 20 20 /*Create Delta Temp to be applied to monthly temps and used in precip scaling*/ 21 21 deltaTemp = dpermil * (d018+34.83); 22 22 23 23 for (int imonth = 0; imonth<12; imonth++){ 24 24 25 25 if (isTemperatureScaled)monthlytemperaturestmp[imonth] = TemperaturePresentday[imonth] + deltaTemp; 26 26 else{ … … 31 31 if (isPrecipScaled)monthlyprectmp[imonth] = PrecipitationPresentday[imonth]*exp((f/dpermil)*deltaTemp); 32 32 else monthlyprectmp[imonth] = PrecipitationReconstructed[imonth]; 33 33 34 34 /*Assign output pointer*/ 35 35 *(monthlytemperaturesout+imonth) = monthlytemperaturestmp[imonth]; -
issm/trunk-jpl/src/c/shared/Elements/ComputeMungsmTemperaturePrecipitation.cpp
r19268 r23066 16 16 IssmDouble tdiffh; 17 17 18 19 18 for (int imonth = 0; imonth<12; imonth++){ 20 19 tdiffh = TdiffTime*( TemperaturesLgm[imonth] - TemperaturesPresentday[imonth] ); … … 29 28 // printf(" tempera %f\n",monthlytemperaturestmp[1]); 30 29 } 31 -
issm/trunk-jpl/src/c/shared/Elements/DrainageFunctionWaterfraction.cpp
r18063 r23066 19 19 if((w0==w1)||(w1==w2)||(w0==w2)) 20 20 _error_("Error: equal ordinates in DrainageFunctionWaterfraction -> division by zero. Abort"); 21 21 22 22 if(waterfraction<=w0) 23 23 Dret=D0; -
issm/trunk-jpl/src/c/shared/Elements/EstarComponents.cpp
r21826 r23066 66 66 /*Get norm of epsprime*/ 67 67 epsprime_norm = sqrt(epsprime[0]*epsprime[0] + epsprime[1]*epsprime[1] + epsprime[2]*epsprime[2]); 68 68 69 69 /*Assign output pointers*/ 70 70 *pepsprime_norm=epsprime_norm; -
issm/trunk-jpl/src/c/shared/Elements/Paterson.cpp
r17457 r23066 15 15 /*Switch to celsius from Kelvin: */ 16 16 T=temperature-273.15; 17 18 17 19 18 if(T<=-45.0){ -
issm/trunk-jpl/src/c/shared/Elements/PddSurfaceMassBalance.cpp
r22448 r23066 83 83 for (iqj = 0; iqj < 12; iqj++){ 84 84 imonth = ismon[iqj]; 85 85 86 86 /*********compute lapse rate ****************/ 87 87 st=(s-s0t)/1000.; 88 88 rtlaps=TdiffTime*rlapslgm + (1.-TdiffTime)*rlaps; // lapse rate 89 89 90 90 /*********compute Surface temperature *******/ 91 91 monthlytemperatures[imonth]=monthlytemperatures[imonth] - rtlaps *max(st,sealevTime*0.001); … … 99 99 else { 100 100 pd = 0.;} 101 101 102 102 /******exp des/elev precip reduction*******/ 103 103 sp=(s-s0p)/1000.-deselcut; // deselev effect is wrt chng in topo 104 104 if (sp>0.0){q = exp(-desfac*sp);} 105 105 else {q = 1.0;} 106 106 107 107 qmt= qmt + monthlyprec[imonth]*sconv; //*sconv to convert in m of ice equivalent per month 108 108 qmpt= q*monthlyprec[imonth]*sconv; … … 114 114 // gaussian=T_m, so ndd=-(Tsurf-pdd) 115 115 if (iqj>5 && iqj<9){ Tsum=Tsum+tstar;} 116 116 117 117 if (tstar >= siglim) {pdd = pdd + tstar*deltm;} 118 118 else if (tstar> -siglim){ … … 121 121 frzndd = frzndd - (tstar-pddsig)*deltm;} 122 122 else{frzndd = frzndd - tstar*deltm; } 123 123 124 124 /*Assign output pointer*/ 125 125 *(monthlytemperatures+imonth) = monthlytemperatures[imonth]; … … 150 150 } 151 151 } 152 152 153 153 /***** determine PDD factors *****/ 154 154 if(Tsum< -1.) { … … 166 166 snwmf=0.95*snwmf; 167 167 smf=0.95*smf; 168 168 169 169 /***** compute PDD ablation and refreezing *****/ 170 170 pddt = pdd *365; 171 171 snwm = snwmf*pddt; // snow that could have been melted in a year 172 172 hmx2 = min(h,dfrz); // refreeze active layer max depth: dfrz 173 173 174 174 if(snwm < saccu) { 175 175 water=prect-saccu + snwm; //water=rain + snowmelt -
issm/trunk-jpl/src/c/shared/Matrix/MatrixUtils.cpp
r21216 r23066 63 63 dtemp = &dtemp_static[0]; 64 64 } 65 65 66 66 /* perform the matrix triple product in the order that minimizes the 67 67 number of multiplies and the temporary space used, noting that … … 335 335 Matrix2x2Determinant(&det,A); 336 336 if (fabs(det) < DBL_EPSILON) _error_("Determinant smaller than machine epsilon"); 337 337 338 338 /*Multiplication is faster than divsion, so we multiply by the reciprocal*/ 339 339 det_reciprocal = 1./det; … … 427 427 *pvy = vy; 428 428 429 430 429 }/*}}}*/ 431 430 … … 577 576 578 577 void newcell(IssmDouble** pcell, IssmDouble newvalue, bool top, int m){ /*{{{*/ 579 578 580 579 IssmDouble* cell=NULL; 581 580 IssmDouble* dummy=NULL; 582 581 583 582 /*recover pointer: */ 584 583 cell=*pcell; 585 584 586 585 /*reallocate:*/ 587 586 dummy=xNew<IssmDouble>(m+1); 588 587 589 588 /*copy data:*/ 590 589 if(top){ … … 596 595 for(int i=0;i<m;i++)dummy[i]=cell[i]; 597 596 } 598 597 599 598 /*delete and reassign: */ 600 599 xDelete<IssmDouble>(cell); cell=dummy; 601 600 602 601 /*assign output pointer:*/ 603 602 *pcell=cell; … … 615 614 /*input: */ 616 615 IssmDouble* cell=*pcell; 617 616 618 617 /*output: */ 619 618 IssmDouble* newcell=xNew<IssmDouble>(nind); … … 622 621 newcell[i]=cell[indices[i]]; 623 622 } 624 623 625 624 /*free allocation:*/ 626 625 xDelete<IssmDouble>(cell); … … 633 632 /*input: */ 634 633 IssmDouble* cell=*pcell; 635 634 636 635 /*output: */ 637 636 IssmDouble* newcell=xNew<IssmDouble>(m+1); … … 641 640 newcell[i+1]=scale* cell[i]; 642 641 for(int j=i+2;j<m+1;j++)newcell[j]=cell[j-1]; 643 642 644 643 /*free allocation:*/ 645 644 xDelete<IssmDouble>(cell); … … 662 661 } 663 662 va_end ( arguments ); 664 663 665 664 _printf_("Echo of cell: \n"); 666 665 for(int i=0;i<m;i++){ -
issm/trunk-jpl/src/c/shared/Numerics/BrentSearch.cpp
r18137 r23066 68 68 _printf0_(" x = "<<setw(9)<<xmin<<" | "); 69 69 fxmin = (*g)(&G,X0,usr); if(xIsNan<IssmDouble>(fxmin)) _error_("Function evaluation returned NaN"); 70 70 71 71 /*Get f(xmax)*/ 72 72 _printf0_(" x = "<<setw(9)<<xmax<<" | "); … … 244 244 J[n]=fxbest; 245 245 } 246 246 247 247 /*return*/ 248 248 xDelete<IssmDouble>(X); -
issm/trunk-jpl/src/c/shared/Numerics/legendre.cpp
r20033 r23066 121 121 122 122 for i = 2 : n 123 123 124 124 v(:,i+1) = ( ( 2 * i - 1 ) * x .* v(:,i) ... 125 125 - ( i - 1 ) * v(:,i-1) ) ... 126 126 / ( i ); 127 127 128 128 end 129 129 }}} */ … … 240 240 polynomials of order 0 through N. 241 241 }}}*/ 242 242 243 243 int i,j; 244 244 … … 254 254 for ( i = 0; i < m; i++ ) { 255 255 for ( j = 2; j <= n; j++ ) { 256 256 257 257 v[j+i*(n+1)] = ( ( IssmDouble ) ( 2 * j - 1 ) * x[i] * v[(j-1)+i*(n+1)] 258 258 - ( IssmDouble ) ( j - 1 ) * v[(j-2)+i*(n+1)] ) -
issm/trunk-jpl/src/c/solutionsequences/solutionsequence_fct.cpp
r22551 r23066 185 185 /*Initial guess*/ 186 186 VecZeroEntries(udot); 187 187 188 188 /*Richardson's iterations*/ 189 189 for(int i=0;i<5;i++){ … … 402 402 CreateRHS(&RHS,K_petsc,D_petsc,Ml_petsc,uf->pvector->vector,theta,deltat,dmax,femmodel,configuration_type); 403 403 delete uf; 404 404 405 405 /*Go solve lower order solution*/ 406 406 femmodel->profiler->Start(SOLVER); -
issm/trunk-jpl/src/c/solutionsequences/solutionsequence_linear.cpp
r22551 r23066 20 20 int configuration_type; 21 21 IssmDouble solver_residue_threshold; 22 22 23 23 /*solver convergence test: */ 24 24 IssmDouble nKUF; … … 39 39 Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); 40 40 femmodel->profiler->Stop(SOLVER); 41 41 42 42 /*Check that the solver converged nicely: */ 43 43 44 44 //compute KUF = KU - F = K*U - F 45 45 KU=uf->Duplicate(); Kff->MatMult(uf,KU); … … 53 53 if(!xIsNan(solver_residue_threshold) && solver_residue>solver_residue_threshold)_error_(" solver residue too high!: norm(KU-F)/norm(F)=" << solver_residue << "\n"); 54 54 55 56 55 //clean up 57 56 delete KU; delete KUF; … … 63 62 // } 64 63 //#endif 65 64 66 65 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);delete uf; delete ys; 67 66 InputUpdateFromSolutionx(femmodel,ug); -
issm/trunk-jpl/src/c/solutionsequences/solutionsequence_thermal_nonlinear.cpp
r22551 r23066 61 61 62 62 count=1; 63 63 64 64 for(;;){ 65 65 delete tf_old;tf_old=tf; -
issm/trunk-jpl/src/c/toolkits/mumps/MumpsSolve.cpp
r23044 r23066 178 178 #endif 179 179 180 181 180 recvcounts=xNew<int>(num_procs); 182 181 displs=xNew<int>(num_procs); … … 262 261 rhs=xNew<IssmDouble>(pf_M); 263 262 #endif 264 265 263 266 264 recvcounts=xNew<int>(num_procs);
Note:
See TracChangeset
for help on using the changeset viewer.