Changeset 25024
- Timestamp:
- 06/12/20 08:22:16 (5 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/analyses/HydrologyDCEfficientAnalysis.cpp
r24933 r25024 299 299 /*Intermediaries */ 300 300 int smb_model; 301 int smb_averaging; 302 int smbsubstepping; 303 int hydrologysubstepping; 301 304 IssmDouble dt,scalar,water_head; 302 305 IssmDouble water_load,transfer,runoff_value; … … 307 310 IssmDouble *xyz_list = NULL; 308 311 Input2 *old_wh_input = NULL; 312 Input2 *dummy_input = NULL; 309 313 Input2 *surface_runoff_input = NULL; 310 314 … … 321 325 basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 322 326 basalelement ->FindParam(&smb_model,SmbEnum); 327 basalelement->FindParam(&smb_averaging,SmbAveragingEnum); 323 328 324 329 Input2* epl_thick_input = basalelement->GetInput2(HydrologydcEplThicknessSubstepEnum); _assert_(epl_thick_input); … … 329 334 Input2* base_input = basalelement->GetInput2(BaseEnum); _assert_(base_input); 330 335 336 IssmDouble time; 337 basalelement->FindParam(&time,TimeEnum); 338 331 339 if(dt!= 0.){ 332 340 old_wh_input = basalelement->GetInput2(EplHeadOldEnum); _assert_(old_wh_input); 333 341 } 334 342 if(smb_model==SMBgradientscomponentsEnum){ 335 surface_runoff_input = basalelement->GetInput2(SmbRunoffEnum); _assert_(surface_runoff_input); 343 basalelement->FindParam(&smbsubstepping,SmbStepsPerStepEnum); 344 basalelement->FindParam(&hydrologysubstepping,HydrologyStepsPerStepEnum); 345 346 if(smbsubstepping==1){ 347 //no substeping for the smb we take the result from there 348 dummy_input = basalelement->GetInput2(SmbRunoffEnum); _assert_(dummy_input); 349 } 350 else if(smbsubstepping>1 && smbsubstepping<=hydrologysubstepping){ 351 //finer hydro stepping, we take the value at the needed time 352 dummy_input = basalelement->GetInput2(SmbRunoffTransientEnum, time); _assert_(dummy_input); 353 } 354 else{ 355 //finer stepping in smb, we average the runoff from transient input 356 dummy_input = basalelement->GetInput2(SmbRunoffTransientEnum,time-dt,time,smb_averaging); _assert_(dummy_input); 357 } 358 surface_runoff_input=xDynamicCast<Input2*>(dummy_input); _assert_(surface_runoff_input); 336 359 } 337 360 -
issm/trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp
r24933 r25024 375 375 basalelement->FindParam(&time,TimeEnum); 376 376 377 378 377 if(dt!= 0.){ 379 378 old_wh_input = basalelement->GetInput2(SedimentHeadOldEnum); _assert_(old_wh_input); … … 384 383 385 384 if(smbsubstepping==1){ 385 //no substeping for the smb we take the result from there 386 386 dummy_input = basalelement->GetInput2(SmbRunoffEnum); _assert_(dummy_input); 387 387 } 388 388 else if(smbsubstepping>1 && smbsubstepping<=hydrologysubstepping){ 389 //finer hydro stepping, we take the value at the needed time 389 390 dummy_input = basalelement->GetInput2(SmbRunoffTransientEnum, time); _assert_(dummy_input); 390 391 } 391 392 else{ 393 //finer stepping in smb, we average the runoff from transient input 392 394 dummy_input = basalelement->GetInput2(SmbRunoffTransientEnum,time-dt,time,smb_averaging); _assert_(dummy_input); 393 395 } -
issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
r24933 r25024 1009 1009 /*}}}*/ 1010 1010 void Penta::CreateInputTimeAverage(int transientinput_enum,int averagedinput_enum,IssmDouble start_time,IssmDouble end_time,int averaging_method){/*{{{*/ 1011 1012 1011 _assert_(end_time>start_time); 1013 1012 1014 /*Intermediaries*/1015 IssmDouble averaged_values[NUMVERTICES];1016 IssmDouble current_values[NUMVERTICES];1017 IssmDouble dt;1018 int found,start_offset,end_offset;1019 1020 1013 /*Get transient input time steps*/ 1021 int numtimesteps;1022 IssmDouble *timesteps = NULL;1023 1014 TransientInput2* transient_input = this->inputs2->GetTransientInput(transientinput_enum); 1024 transient_input->GetAllTimes(×teps,&numtimesteps); 1025 1026 /*go through the timesteps, and grab offset for start and end*/ 1027 found=binary_search(&start_offset,start_time,timesteps,numtimesteps); 1028 if(!found) _error_("Input not found (is TransientInput sorted ?)"); 1029 found=binary_search(&end_offset,end_time,timesteps,numtimesteps); 1030 if(!found) _error_("Input not found (is TransientInput sorted ?)"); 1031 1032 Gauss* gauss=this->NewGauss(); 1033 1034 /*stack the input for each timestep in the slice*/ 1035 int offset = start_offset; 1036 while(offset < end_offset ){ 1037 1038 1039 if(offset==-1){ 1040 /*get values for the first time: */ 1041 _assert_(start_time<timesteps[0]); 1042 PentaInput2* input = transient_input->GetPentaInput(0); 1043 1044 int interpolation = input->GetInterpolation(); 1045 _assert_(interpolation==P1Enum); 1046 /*Intermediaries*/ 1047 int numindices; 1048 int indices[NUMVERTICES]; 1049 numindices = NUMVERTICES; 1050 for(int i=0;i<NUMVERTICES;i++) indices[i] = vertices[i]->lid; 1051 input->Serve(numindices,&indices[0]); 1052 1053 for(int iv=0;iv<NUMVERTICES;iv++){ 1054 gauss->GaussVertex(iv); 1055 input->GetInputValue(¤t_values[iv],gauss); 1056 } 1057 dt = timesteps[0] - start_time; _assert_(dt>0.); 1058 } 1059 else{ 1060 PentaInput2* input = transient_input->GetPentaInput(offset+1); 1061 int interpolation = input->GetInterpolation(); 1062 _assert_(interpolation==P1Enum); 1063 /*Intermediaries*/ 1064 int numindices; 1065 int indices[NUMVERTICES]; 1066 numindices = NUMVERTICES; 1067 for(int i=0;i<NUMVERTICES;i++) indices[i] = vertices[i]->lid; 1068 input->Serve(numindices,&indices[0]); 1069 1070 for(int iv=0;iv<NUMVERTICES;iv++){ 1071 gauss->GaussVertex(iv); 1072 input->GetInputValue(¤t_values[iv],gauss); 1073 } 1074 if(offset == numtimesteps-1){ 1075 dt = end_time - timesteps[offset]; _assert_(dt>0.); 1076 } 1077 else{ 1078 dt = timesteps[offset+1] - timesteps[offset]; _assert_(dt>0.); 1079 } 1080 } 1081 1082 switch(averaging_method){ 1083 case 0: /*Arithmetic mean*/ 1084 if(offset==start_offset){ 1085 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] = dt*current_values[iv]; 1086 } 1087 else{ 1088 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] += dt*current_values[iv]; 1089 } 1090 break; 1091 case 1: /*Geometric mean*/ 1092 if(offset==start_offset){ 1093 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] = dt*current_values[iv]; 1094 } 1095 else{ 1096 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] *= dt*current_values[iv]; 1097 } 1098 break; 1099 case 2: /*Harmonic mean*/ 1100 if(offset==start_offset){ 1101 for(int iv=0;iv<NUMVERTICES;iv++){ 1102 _assert_(current_values[iv]>1.e-50); 1103 averaged_values[iv] = dt*1./current_values[iv]; 1104 } 1105 } 1106 else{ 1107 for(int iv=0;iv<NUMVERTICES;iv++){ 1108 _assert_(current_values[iv]>1.e-50); 1109 averaged_values[iv] += dt*1./current_values[iv]; 1110 } 1111 } 1112 break; 1113 default: 1114 _error_("averaging method is not recognised"); 1115 } 1116 1117 offset+=1; 1118 } 1119 1120 /*Integration done, now normalize*/ 1121 switch(averaging_method){ 1122 case 0: //Arithmetic mean 1123 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] = averaged_values[iv]/(end_time - start_time); 1124 break; 1125 case 1: /*Geometric mean*/ 1126 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] = pow(averaged_values[iv], 1./(end_time - start_time)); 1127 break; 1128 case 2: /*Harmonic mean*/ 1129 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] = 1./(averaged_values[iv]/(end_time - start_time)); 1130 break; 1131 default: 1132 _error_("averaging method is not recognised"); 1133 } 1134 1135 this->AddInput2(averagedinput_enum,&averaged_values[0],P1Enum); 1136 1137 /*Cleanup*/ 1138 delete gauss; 1139 xDelete<IssmDouble>(timesteps); 1015 PentaInput2* averaged_input = transient_input->GetPentaInput(start_time,end_time,averaging_method); 1016 Input2* averaged_copy = averaged_input->copy(); 1017 1018 averaged_input->ChangeEnum(averagedinput_enum); 1019 this->inputs2->AddInput(averaged_copy); 1140 1020 } 1141 1021 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r24980 r25024 914 914 } 915 915 /*}}}*/ 916 void 916 void Tria::ComputeEsaStrainAndVorticity(){ /*{{{*/ 917 917 918 918 IssmDouble xyz_list[NUMVERTICES][3]; … … 1918 1918 /*Get Input from dataset*/ 1919 1919 if(this->iscollapsed){ 1920 _error_("Get Average input not implemented in Penta yet"); 1920 PentaInput2* input = this->inputs2->GetPentaInput(inputenum,start_time,end_time,averaging_method); 1921 if(!input) return input; 1922 1923 this->InputServe(input); 1924 return input; 1921 1925 } 1922 1926 else{ … … 2114 2118 _assert_(end_time>start_time); 2115 2119 2116 /*Intermediaries*/2117 IssmDouble averaged_values[NUMVERTICES];2118 IssmDouble current_values[NUMVERTICES];2119 IssmDouble dt;2120 int found,start_offset,end_offset;2121 2122 2120 /*Get transient input time steps*/ 2123 int numtimesteps;2124 IssmDouble *timesteps = NULL;2125 2121 TransientInput2* transient_input = this->inputs2->GetTransientInput(transientinput_enum); 2126 transient_input->GetAllTimes(×teps,&numtimesteps); 2127 2128 /*go through the timesteps, and grab offset for start and end*/ 2129 found=binary_search(&start_offset,start_time,timesteps,numtimesteps); 2130 if(!found) _error_("Input not found (is TransientInput sorted ?)"); 2131 found=binary_search(&end_offset,end_time,timesteps,numtimesteps); 2132 if(!found) _error_("Input not found (is TransientInput sorted ?)"); 2133 2134 Gauss* gauss=this->NewGauss(); 2135 2136 /*stack the input for each timestep in the slice*/ 2137 int offset = start_offset; 2138 while(offset < end_offset ){ 2139 if(offset==-1){ 2140 /*get values for the first time: */ 2141 _assert_(start_time<timesteps[0]); 2142 TriaInput2* input = transient_input->GetTriaInput(0); 2143 _assert_(input->GetInterpolation()==P1Enum); 2144 this->InputServe(input); 2145 for(int iv=0;iv<NUMVERTICES;iv++){ 2146 gauss->GaussVertex(iv); 2147 input->GetInputValue(¤t_values[iv],gauss); 2148 } 2149 dt = timesteps[0] - start_time; _assert_(dt>0.); 2150 } 2151 else{ 2152 TriaInput2* input = transient_input->GetTriaInput(offset+1); 2153 _assert_(input->GetInterpolation()==P1Enum); 2154 this->InputServe(input); 2155 for(int iv=0;iv<NUMVERTICES;iv++){ 2156 gauss->GaussVertex(iv); 2157 input->GetInputValue(¤t_values[iv],gauss); 2158 } 2159 if(offset == numtimesteps-1){ 2160 dt = end_time - timesteps[offset]; _assert_(dt>0.); 2161 } 2162 else{ 2163 dt = timesteps[offset+1] - timesteps[offset]; _assert_(dt>0.); 2164 } 2165 } 2166 2167 switch(averaging_method){ 2168 case 0: /*Arithmetic mean*/ 2169 if(offset==start_offset){ 2170 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] = dt*current_values[iv]; 2171 } 2172 else{ 2173 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] += dt*current_values[iv]; 2174 } 2175 break; 2176 case 1: /*Geometric mean*/ 2177 if(offset==start_offset){ 2178 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] = dt*current_values[iv]; 2179 } 2180 else{ 2181 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] *= dt*current_values[iv]; 2182 } 2183 break; 2184 case 2: /*Harmonic mean*/ 2185 if(offset==start_offset){ 2186 for(int iv=0;iv<NUMVERTICES;iv++){ 2187 _assert_(current_values[iv]>1.e-50); 2188 averaged_values[iv] = dt*1./current_values[iv]; 2189 } 2190 } 2191 else{ 2192 for(int iv=0;iv<NUMVERTICES;iv++){ 2193 _assert_(current_values[iv]>1.e-50); 2194 averaged_values[iv] += dt*1./current_values[iv]; 2195 } 2196 } 2197 break; 2198 default: 2199 _error_("averaging method is not recognised"); 2200 } 2201 2202 offset+=1; 2203 } 2204 2205 /*Integration done, now normalize*/ 2206 switch(averaging_method){ 2207 case 0: //Arithmetic mean 2208 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] = averaged_values[iv]/(end_time - start_time); 2209 break; 2210 case 1: /*Geometric mean*/ 2211 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] = pow(averaged_values[iv], 1./(end_time - start_time)); 2212 break; 2213 case 2: /*Harmonic mean*/ 2214 for(int iv=0;iv<NUMVERTICES;iv++) averaged_values[iv] = (end_time - start_time)/averaged_values[iv]; 2215 break; 2216 default: 2217 _error_("averaging method is not recognised"); 2218 } 2219 2220 this->AddInput2(averagedinput_enum,&averaged_values[0],P1Enum); 2221 2222 /*Cleanup*/ 2223 delete gauss; 2224 xDelete<IssmDouble>(timesteps); 2122 TriaInput2* averaged_input = transient_input->GetTriaInput(start_time,end_time,averaging_method); 2123 Input2* averaged_copy = averaged_input->copy(); 2124 2125 averaged_copy->ChangeEnum(averagedinput_enum); 2126 this->inputs2->AddInput(averaged_copy); 2225 2127 } 2226 2128 /*}}}*/ … … 5329 5231 rho_ice=FindParam(MaterialsRhoIceEnum); 5330 5232 rho_earth=FindParam(MaterialsEarthDensityEnum); 5331 5233 5332 5234 /*recover earth area: */ 5333 5235 this->parameters->FindParam(&planetarea,SealevelPlanetAreaEnum); … … 5356 5258 } 5357 5259 5358 // correction at the north pole: given longitude of the North pole a definition 5260 // correction at the north pole: given longitude of the North pole a definition 5359 5261 // closer to the other two vertices. 5360 5262 if(llr_list[0][0]==0)llr_list[0][1]=(llr_list[1][1]+llr_list[2][1])/2.0; … … 5362 5264 if(llr_list[2][0]==0)llr_list[2][1]=(llr_list[0][1]+llr_list[1][1])/2.0; 5363 5265 5364 // correction at the north pole: given longitude of the North pole a definition 5266 // correction at the north pole: given longitude of the North pole a definition 5365 5267 // closer to the other two vertices. 5366 5268 if(llr_list[0][0]==180)llr_list[0][1]=(llr_list[1][1]+llr_list[2][1])/2.0; … … 5569 5471 masks->isiceonly[this->lid]=this->IsIceOnlyInElement(); 5570 5472 masks->isoceanin[this->lid]=this->IsOceanInElement(); 5571 5473 5572 5474 /*are we fully floating:*/ 5573 5475 Input2* gr_input=this->GetInput2(MaskOceanLevelsetEnum); _assert_(gr_input); … … 5595 5497 IssmDouble x_element,y_element,z_element,x,y,z,dx,dy,dz,N_azim,E_azim; 5596 5498 5597 #ifdef _HAVE_RESTRICT_ 5499 #ifdef _HAVE_RESTRICT_ 5598 5500 IssmDouble* __restrict__ G=NULL; 5599 5501 IssmDouble* __restrict__ GU=NULL; … … 5616 5518 IssmDouble* indices=NULL; 5617 5519 #endif 5618 5520 5619 5521 /*elastic green function:*/ 5620 5522 int index; … … 5656 5558 GE=xNewZeroInit<IssmDouble>(gsize); 5657 5559 } 5658 5560 5659 5561 /*compute area:*/ 5660 5562 area=GetAreaSpherical(); … … 5676 5578 5677 5579 constant=3/rho_earth*area/planetarea; 5678 5580 5679 5581 for(int i=0;i<gsize;i++){ 5680 5582 IssmDouble alpha; … … 5687 5589 indices[i]=alpha/PI*reCast<IssmDouble,int>(M-1); 5688 5590 index=reCast<int,IssmDouble>(indices[i]); 5689 5591 5690 5592 /*Rigid earth gravitational perturbation: */ 5691 5593 if(computerigid){ … … 5695 5597 G[i]+=G_elastic_precomputed[index]; 5696 5598 } 5697 G[i]=G[i]*constant; 5599 G[i]=G[i]*constant; 5698 5600 5699 5601 /*Elastic components:*/ … … 5728 5630 5729 5631 /*Free allocations:*/ 5730 #ifdef _HAVE_RESTRICT_ 5731 delete indices; 5732 delete G; 5733 delete GU; 5632 #ifdef _HAVE_RESTRICT_ 5633 delete indices; 5634 delete G; 5635 delete GU; 5734 5636 if(horiz){ 5735 delete GN; 5637 delete GN; 5736 5638 delete GE; 5737 5639 } … … 5752 5654 5753 5655 int bp_compute_fingerprints= 0; 5754 5656 5755 5657 /*Compute bottom pressure contribution from ocean if requested:*/ 5756 5658 this->parameters->FindParam(&bp_compute_fingerprints,DslComputeFingerprintsEnum); … … 5795 5697 /*early return if we are fully floating:*/ 5796 5698 if (masks->isfullyfloating[this->lid]){ 5797 constant=0; 5699 constant=0; 5798 5700 #ifdef _ISSM_DEBUG_ 5799 5701 this->AddInput2(SealevelEustaticMaskEnum,&constant,P0Enum); 5800 #endif 5702 #endif 5801 5703 *peustatic=0; //do not forget to assign this pointer, otherwise, global eustatic will be garbage! 5802 5704 return; … … 5805 5707 /*If we are here, we are on ice that is fully grounded or half-way to floating:*/ 5806 5708 if (masks->notfullygrounded[this->lid]) notfullygrounded=true; //used later on. 5807 5709 5808 5710 /*Inform mask: */ 5809 constant=1; 5711 constant=1; 5810 5712 #ifdef _ISSM_DEBUG_ 5811 5713 this->AddInput2(SealevelEustaticMaskEnum,&constant,P0Enum); … … 5820 5722 5821 5723 /*retrieve precomputed G:*/ 5822 this->inputs2->GetArrayPtr(SealevelriseGEnum,this->lid,&G,&gsize); 5724 this->inputs2->GetArrayPtr(SealevelriseGEnum,this->lid,&G,&gsize); 5823 5725 5824 5726 /*Get area of element: precomputed in the sealevelrise_core_geometry:*/ … … 5826 5728 5827 5729 /*Compute fraction of the element that is grounded: */ 5828 if(notfullygrounded){ 5730 if(notfullygrounded){ 5829 5731 IssmDouble xyz_list[NUMVERTICES][3]; 5830 5732 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 5831 5733 5832 5734 phi=this->GetGroundedPortion(&xyz_list[0][0]); //watch out, this only works because of the Thales theorem! We are in 3D, but this routine is inherently for 2D trias 5833 } 5735 } 5834 5736 else phi=1.0; 5835 5737 … … 5892 5794 /*elastic green function:*/ 5893 5795 IssmDouble* G=NULL; 5894 5796 5895 5797 /*water properties: */ 5896 5798 IssmDouble rho_water; … … 5908 5810 5909 5811 /*retrieve precomputed G:*/ 5910 this->inputs2->GetArrayPtr(SealevelriseGEnum,this->lid,&G,&gsize); 5812 this->inputs2->GetArrayPtr(SealevelriseGEnum,this->lid,&G,&gsize); 5911 5813 5912 5814 /*Get area of element: precomputed in the sealevelrise_core_geometry:*/ … … 5943 5845 /*early return if we are not on the ocean:*/ 5944 5846 if (!masks->isoceanin[this->lid]){ 5945 constant=0; 5946 #ifdef _ISSM_DEBUG_ 5847 constant=0; 5848 #ifdef _ISSM_DEBUG_ 5947 5849 this->AddInput2(SealevelEustaticOceanMaskEnum,&constant,P0Enum); 5948 5850 #endif 5949 5851 return; 5950 5852 } 5951 constant=1; 5952 #ifdef _ISSM_DEBUG_ 5853 constant=1; 5854 #ifdef _ISSM_DEBUG_ 5953 5855 this->AddInput2(SealevelEustaticOceanMaskEnum,&constant,P0Enum); 5954 5856 #endif … … 5956 5858 /*how many dofs are we working with here? */ 5957 5859 this->parameters->FindParam(&gsize,MeshNumberofverticesEnum); 5958 5860 5959 5861 /*retrieve precomputed G:*/ 5960 5862 this->inputs2->GetArrayPtr(SealevelriseGEnum,this->lid,&G,&dummy); _assert_(dummy==gsize); … … 6004 5906 6005 5907 /*recover elastic Green's functions for displacement:*/ 6006 this->inputs2->GetArrayPtr(SealevelriseGUEnum,this->lid,&GU,&gsize); 5908 this->inputs2->GetArrayPtr(SealevelriseGUEnum,this->lid,&GU,&gsize); 6007 5909 if(horiz){ 6008 this->inputs2->GetArrayPtr(SealevelriseGEEnum,this->lid,&GE,&gsize); 6009 this->inputs2->GetArrayPtr(SealevelriseGNEnum,this->lid,&GN,&gsize); 5910 this->inputs2->GetArrayPtr(SealevelriseGEEnum,this->lid,&GE,&gsize); 5911 this->inputs2->GetArrayPtr(SealevelriseGNEnum,this->lid,&GN,&gsize); 6010 5912 } 6011 5913 -
issm/trunk-jpl/src/c/classes/Inputs2/Inputs2.cpp
r24935 r25024 388 388 } 389 389 }/*}}}*/ 390 PentaInput2* Inputs2::GetPentaInput(int enum_in,IssmDouble start_time,IssmDouble end_time,int averaging_method){/*{{{*/ 391 392 /*Get input id*/ 393 int id = EnumToIndex(enum_in); 394 395 /*Check that it has the right format*/ 396 Input2* input = this->inputs[id]; 397 if(!input) return NULL; 398 399 if(input->ObjectEnum()==TransientInput2Enum){ 400 return xDynamicCast<TransientInput2*>(input)->GetPentaInput(start_time,end_time,averaging_method); 401 } 402 else{ 403 _error_("Input "<<EnumToStringx(enum_in)<<" is not an TransientInput2"); 404 } 405 }/*}}}*/ 390 406 TransientInput2* Inputs2::GetTransientInput(int enum_in){/*{{{*/ 391 407 -
issm/trunk-jpl/src/c/classes/Inputs2/Inputs2.h
r24935 r25024 58 58 PentaInput2* GetPentaInput(int enum_type); 59 59 PentaInput2* GetPentaInput(int enum_type,IssmDouble time); 60 PentaInput2* GetPentaInput(int enum_in,IssmDouble start_time,IssmDouble end_time,int averaging_method); 60 61 TransientInput2* GetTransientInput(int enum_type); 61 62 ElementInput2* GetControlInput2Data(int enum_type,const char* data); -
issm/trunk-jpl/src/c/classes/Inputs2/TransientInput2.cpp
r24791 r25024 355 355 } 356 356 /*}}}*/ 357 PentaInput2* TransientInput2::GetPentaInput(IssmDouble start_time, IssmDouble end_time, int averaging_method){/*{{{*/ 358 359 /*Set current time input*/ 360 this->SetAverageAsCurrentTimeInput(start_time,end_time,averaging_method); 361 _assert_(this->current_input); 362 363 /*Cast and return*/ 364 if(this->current_input->ObjectEnum()!=PentaInput2Enum){ 365 _error_("Cannot return a PentaInput2"); 366 } 367 return xDynamicCast<PentaInput2*>(this->current_input); 368 369 } 370 /*}}}*/ 371 357 372 void TransientInput2::SetCurrentTimeInput(IssmDouble time){/*{{{*/ 358 373 … … 404 419 405 420 /*If already processed return*/ 406 if(this->current_step>this_step-1.e-5 && this->current_step<this_step+1.e-5) return; 421 if(abs(this->current_step-this_step)<1.e-5) return; 422 // if(this->current_step>this_step-1.e-5 && this->current_step<this_step+1.e-5) return; 407 423 408 424 /*Prepare input*/ … … 424 440 425 441 IssmDouble dt,durinv; 426 IssmPDouble eps=1.0e-6;427 442 IssmDouble dtsum=0; 428 int found,start_offset,end_offset; 443 IssmDouble timespan,mid_step; 444 int found,start_offset,end_offset,input_offset; 429 445 430 446 /*go through the timesteps, and grab offset for start and end*/ 431 IssmDouble temp = start_time-eps; 432 found=binary_search(&start_offset,temp,this->timesteps,this->numtimesteps); 447 found=binary_search(&start_offset,start_time,this->timesteps,this->numtimesteps); 433 448 if(!found) _error_("Input not found (is TransientInput sorted ?)"); 434 temp = end_time+eps; 435 found=binary_search(&end_offset,temp,this->timesteps,this->numtimesteps); 449 found=binary_search(&end_offset,end_time,this->timesteps,this->numtimesteps); 436 450 if(!found) _error_("Input not found (is TransientInput sorted ?)"); 437 451 452 if(start_offset==-1){ 453 timespan=this->timesteps[end_offset]-start_time; 454 } 455 else{ 456 timespan=this->timesteps[end_offset]-this->timesteps[start_offset]; 457 } 458 mid_step=reCast<IssmDouble>(start_offset)+0.5*timespan; 459 460 /*If already processed return, we set step in the middle of the interval*/ 461 if(abs(this->current_step-mid_step)<1.e-5) return; 462 /*If not processed set current_step*/ 463 if(this->current_input) delete this->current_input; 464 this->current_step = mid_step; 465 438 466 int offset=start_offset; 439 if(this->current_input) delete this->current_input;440 467 while(offset < end_offset){ 441 if (offset==-1){ 442 dt=this->timesteps[0]-start_time; 443 _assert_(start_time<this->timesteps[0]); 444 } 445 else if(offset==this->numtimesteps-1)dt=end_time-this->timesteps[offset]; 446 else if(offset==start_offset && this->timesteps[offset]<start_time) dt=this->timesteps[offset+1]-start_time; 447 else if(offset==end_offset && this->timesteps[offset]>end_time) dt=end_time-this->timesteps[offset]; 448 else dt=this->timesteps[offset+1]-this->timesteps[offset]; 449 _assert_(dt>0.); 450 468 if(offset==start_offset){ 469 dt=this->timesteps[offset+1]-start_time; 470 _assert_(dt>0.); 471 if(offset==end_offset-1){ 472 dt=end_time-start_time; 473 _assert_(dt>0.); 474 } 475 } 476 else if(offset==end_offset-1){ 477 dt=end_time-this->timesteps[offset]; 478 _assert_(dt>0.); 479 } 480 else{ 481 dt=this->timesteps[offset+1]-this->timesteps[offset]; 482 _assert_(dt>0.); 483 } 451 484 Input2* stepinput=this->inputs[offset+1]; 452 485 … … 454 487 case 0: /*Arithmetic mean*/ 455 488 if(offset==start_offset){ 456 this->current_input =stepinput->copy();489 this->current_input=stepinput->copy(); 457 490 this->current_input->Scale(dt); 458 491 } -
issm/trunk-jpl/src/c/classes/Inputs2/TransientInput2.h
r24790 r25024 55 55 PentaInput2* GetPentaInput(IssmDouble time); 56 56 PentaInput2* GetPentaInput(int offset); 57 PentaInput2* GetPentaInput(IssmDouble start_time,IssmDouble end_time,int averaging_method); 57 58 Input2* GetTimeInput(IssmDouble time){_error_("This should not happen!");}; 58 59 IssmDouble GetTimeByOffset(int offset); -
issm/trunk-jpl/src/c/cores/hydrology_core.cpp
r24816 r25024 76 76 substep=0; 77 77 femmodel->parameters->SetParam(subdt,TimesteppingTimeStepEnum); 78 femmodel->parameters->SetParam(subtime,TimeEnum); 78 79 79 80 /*intermiedaries to deal with averaging*/ … … 119 120 /*averaging the stack*/ 120 121 femmodel->AverageTransientInputx(&transientinput[0],&averagedinput[0],global_time-dt,subtime,numaveragedinput,hydro_averaging); 121 122 122 /*And reseting to global time*/ 123 123 femmodel->parameters->SetParam(dt,TimesteppingTimeStepEnum); -
issm/trunk-jpl/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp
r23636 r25024 9 9 void InputUpdateFromSolutionx(FemModel* femmodel,Vector<IssmDouble>* solution){ 10 10 11 /*Display message*/12 if(VerboseModule()) _printf0_(" Updating inputs from solution\n");13 14 11 /*GetAnalysis*/ 15 12 int analysisenum; 16 13 femmodel->parameters->FindParam(&analysisenum,AnalysisTypeEnum); 17 14 Analysis* analysis = EnumToAnalysis(analysisenum); 15 16 /*Display message*/ 17 if(VerboseModule()) _printf0_(" Updating inputs from solution for " << EnumToStringx(analysisenum) << "\n"); 18 18 19 19 /*Get local vector with both masters and slaves:*/ -
issm/trunk-jpl/src/m/classes/hydrologydc.m
r24803 r25024 1 1 2 %Hydrologydc class definition 2 3 % -
issm/trunk-jpl/test/NightlyRun/test905.m
r24575 r25024 33 33 34 34 md.hydrology.steps_per_step=5; 35 md.smb.steps_per_step= 7.;36 md.timestepping.time_step= 2.;35 md.smb.steps_per_step=10; 36 md.timestepping.time_step=1.; 37 37 md.timestepping.final_time=20.0; 38 38 … … 59 59 'SedimentWaterHead5','EplWaterHead5','SedimentHeadResidual5',... 60 60 'SedimentWaterHead9','EplWaterHead9','SedimentHeadResidual9',... 61 'EplWaterHead 10','EplWaterHeadSubstep10','SedimentWaterHead10',...62 'SedimentWaterHeadSubstep 10'}61 'EplWaterHead20','EplWaterHeadSubstep20','SedimentWaterHead20',... 62 'SedimentWaterHeadSubstep20'} 63 63 field_tolerances={1e-13,1e-13,1e-13,... 64 64 1e-13,1e-13,1e-13,... -
issm/trunk-jpl/test/NightlyRun/test905.py
r24575 r25024 42 42 md.initialization.epl_thickness = np.ones((md.mesh.numberofvertices)) 43 43 44 #try to keep the different steps as common multipliers of eachother 45 #for the sake of precision the values of the model used as input should be on a shorter time-step- 46 #you can plot the results of this test and check how the time stepping is doing (see bellow) 44 47 md.hydrology.steps_per_step = 5 45 md.smb.steps_per_step = 7#md.hydrology.steps_per_step46 md.timestepping.time_step = 2.48 md.smb.steps_per_step = 10 #md.hydrology.steps_per_step 49 md.timestepping.time_step = 1. 47 50 md.timestepping.final_time = 20.0 48 51 49 52 smb_step = md.timestepping.time_step / md.smb.steps_per_step 53 hydro_step = md.timestepping.time_step / md.hydrology.steps_per_step 50 54 duration = np.arange(md.timestepping.start_time, md.timestepping.final_time + smb_step, smb_step) 51 55 … … 55 59 md.smb.accugrad = 0.0 56 60 61 #md.smb.runoffref = 9. * ddf * np.ones(np.shape(duration)) #constant input for testing 57 62 md.smb.runoffref = 0.9 * duration * ddf 58 63 md.smb.runoffref = np.vstack((md.smb.runoffref, duration)) … … 64 69 65 70 md = solve(md, 'Transient') 66 67 71 field_names = ['SedimentWaterHead1', 'EplWaterHead1', 'SedimentHeadResidual1', 68 72 'SedimentWaterHead4', 'EplWaterHead4', 'SedimentHeadResidual4', 69 73 'SedimentWaterHead5', 'EplWaterHead5', 'SedimentHeadResidual5', 70 74 'SedimentWaterHead9', 'EplWaterHead9', 'SedimentHeadResidual9', 71 'EplWaterHead 10', 'EplWaterHeadSubstep10', 'SedimentWaterHead10',72 'SedimentWaterHeadSubstep 10']75 'EplWaterHead20', 'EplWaterHeadSubstep20', 'SedimentWaterHead20', 76 'SedimentWaterHeadSubstep20'] 73 77 field_tolerances = [1e-13, 1e-13, 1e-13, 74 78 1e-13, 1e-13, 1e-13, … … 93 97 md.results.TransientSolution[-1].SedimentHead, 94 98 md.results.TransientSolution[-1].SedimentHeadSubstep] 99 100 101 #===Stepping and plotting reference 102 # import matplotlib as mpl 103 # import matplotlib.pyplot as plt 104 105 # agregatedInput = np.zeros(len(md.results.TransientSolution)) 106 # agregatedInputSub = np.zeros(len(md.results.TransientSolution)) 107 # RefInput = np.zeros(len(md.results.TransientSolution)) 108 # RefInputSub = np.zeros(len(md.results.TransientSolution)) 109 # Input = np.zeros(len(md.results.TransientSolution)) 110 # InputSub = np.zeros(len(md.results.TransientSolution)) 111 # SedVol = np.zeros(len(md.results.TransientSolution)) 112 # SedVolSub = np.zeros(len(md.results.TransientSolution)) 113 # EplVol = np.zeros(len(md.results.TransientSolution)) 114 # EplVolSub = np.zeros(len(md.results.TransientSolution)) 115 # SmbTimer = np.zeros(len(md.results.TransientSolution)) 116 # HydroTimer = np.zeros(len(md.results.TransientSolution)) 117 # TimerSub = np.zeros(len(md.results.TransientSolution)) 118 # HeadEVol = np.zeros(len(md.results.TransientSolution)) 119 # sedstore = md.materials.rho_freshwater * md.constants.g * md.hydrology.sediment_porosity * md.hydrology.sediment_thickness * ((md.hydrology.sediment_compressibility / md.hydrology.sediment_porosity) + md.hydrology.water_compressibility) 120 # eplstore = md.materials.rho_freshwater * md.constants.g * md.hydrology.sediment_porosity * ((md.hydrology.sediment_compressibility / md.hydrology.sediment_porosity) + md.hydrology.water_compressibility) 121 122 # for i, res in enumerate(md.results.TransientSolution): 123 124 # TimerSub[i] = res.time 125 # RefInputSub[i] = max(0, res.time * 0.9 * ddf + (-6.5e-3 * 1000 * ddf)) 126 # try: 127 # InputSub[i] = np.nanmean(res.SmbRunoffSubstep) 128 # SedVolSub[i] = np.nanmean(res.SedimentHeadSubstep) * sedstore 129 # EplVolSub[i] = np.nanmean(res.EplHeadSubstep) * eplstore * np.nanmean(res.HydrologydcEplThicknessSubstep) 130 # substep = True 131 # if i > 0: 132 # agregatedInputSub[i:] += 0.5 * ((1 + smb_step) * np.nanmean(res.SmbRunoffSubstep) + (1 - smb_step) * np.nanmean(md.results.TransientSolution[i - 1].SmbRunoffSubstep)) * (TimerSub[i] - TimerSub[i - 1]) 133 # else: 134 # agregatedInputSub[i:] += np.nanmean(res.SmbRunoffSubstep) * TimerSub[i] 135 136 # except AttributeError: 137 # substep = False 138 # SmbTimer[i] = res.time - (0.5 * md.timestepping.time_step * (1 - smb_step)) 139 # HydroTimer[i] = res.time - (0.5 * md.timestepping.time_step * (1 - hydro_step)) 140 141 # RefInput[i] = max(0, (SmbTimer[i] * 0.9 * ddf + (-6.5e-3 * 1000 * ddf))) 142 # Input[i] = np.nanmean(res.SmbRunoff) 143 # SedVol[i] = np.nanmean(res.SedimentHead) * sedstore 144 # EplVol[i] = np.nanmean(res.EplHead) * eplstore * np.nanmean(res.HydrologydcEplThickness) 145 # if i > 0: 146 # agregatedInput[i:] += 0.5 * ((1 + hydro_step) * np.nanmean(res.SmbRunoff) + (1 - hydro_step) * np.nanmean(md.results.TransientSolution[i - 1].SmbRunoff)) * (SmbTimer[i] - SmbTimer[i - 1]) 147 # else: 148 # agregatedInput[i:] += np.nanmean(res.SmbRunoff) * SmbTimer[i] 149 150 151 # layout, ax = plt.subplots(2, 2, sharex=True, sharey=False, figsize=(10, 10)) 152 153 # DiffTimer = (TimerSub[:-1] + 0.5 * (smb_step + hydro_step)) 154 # Indiff = (DiffTimer) * 0.9 * ddf + (-6.5e-3 * 1000 * ddf) 155 # Indiff[np.where(Indiff < 0)] = 0 156 157 # ax[0, 0].plot(SmbTimer, RefInput - Input, 'g+') 158 # ax[0, 0].plot(DiffTimer, (Indiff - np.diff((SedVol+EplVol)) / md.timestepping.time_step), 'kx') 159 160 # ax[0, 1].plot(SmbTimer, RefInput, 'm+') 161 # ax[0, 1].plot(SmbTimer, Input, 'g+') 162 # ax[0, 1].plot(DiffTimer, np.diff(SedVol+EplVol) / md.timestepping.time_step, 'r') 163 164 # ax[1, 0].plot(HydroTimer, (agregatedInput - SedVol - EplVol), 'b+') 165 166 # ax[1, 1].plot(HydroTimer, SedVol + EplVol, 'r+') 167 # ax[1, 1].plot(SmbTimer, agregatedInput, 'b+') 168 169 # if substep: 170 # SubDiffTimer = (SmbTimer[1:]) 171 # SubIndiff = (SubDiffTimer) * 0.9 * ddf + (-6.5e-3 * 1000 * ddf) 172 # SubIndiff[np.where(SubIndiff < 0)] = 0 173 174 # ax[0, 0].plot(TimerSub, RefInputSub - InputSub, 'm') 175 # ax[0, 0].plot(SubDiffTimer, (SubIndiff - np.diff(SedVolSub + EplVolSub) / md.timestepping.time_step), 'y') 176 177 # ax[0, 1].plot(TimerSub, RefInputSub, 'm') 178 # ax[0, 1].plot(TimerSub, InputSub, 'g') 179 180 # ax[1, 0].plot(TimerSub, (agregatedInputSub - SedVolSub - EplVolSub), 'r') 181 182 # ax[1, 1].plot(TimerSub, SedVolSub + EplVolSub, 'r') 183 # ax[1, 1].plot(TimerSub, SedVolSub, 'r', alpha=0.5) 184 # ax[1, 1].plot(TimerSub, EplVolSub, 'r', alpha=0.5) 185 # ax[1, 1].plot(TimerSub, agregatedInputSub, 'b')
Note:
See TracChangeset
for help on using the changeset viewer.