[19984] | 1 | #include "./SealevelriseAnalysis.h"
|
---|
[24959] | 2 | #include <math.h>
|
---|
[19984] | 3 | #include "../toolkits/toolkits.h"
|
---|
| 4 | #include "../classes/classes.h"
|
---|
[25379] | 5 | #include "../classes/Inputs/TransientInput.h"
|
---|
[19984] | 6 | #include "../shared/shared.h"
|
---|
| 7 | #include "../modules/modules.h"
|
---|
| 8 |
|
---|
| 9 | /*Model processing*/
|
---|
| 10 | void SealevelriseAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/
|
---|
| 11 | /*No constraints*/
|
---|
| 12 | }/*}}}*/
|
---|
| 13 | void SealevelriseAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/
|
---|
| 14 | /*No loads*/
|
---|
| 15 | }/*}}}*/
|
---|
[23585] | 16 | void SealevelriseAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel,bool isamr){/*{{{*/
|
---|
[19984] | 17 | ::CreateNodes(nodes,iomodel,SealevelriseAnalysisEnum,P1Enum);
|
---|
| 18 | }/*}}}*/
|
---|
| 19 | int SealevelriseAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/
|
---|
| 20 | return 1;
|
---|
| 21 | }/*}}}*/
|
---|
[25379] | 22 | void SealevelriseAnalysis::UpdateElements(Elements* elements,Inputs* inputs,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/
|
---|
[19984] | 23 |
|
---|
[22955] | 24 | int geodetic=0;
|
---|
[24469] | 25 | int dslmodel=0;
|
---|
[22955] | 26 |
|
---|
[19984] | 27 | /*Update elements: */
|
---|
| 28 | int counter=0;
|
---|
| 29 | for(int i=0;i<iomodel->numberofelements;i++){
|
---|
| 30 | if(iomodel->my_elements[i]){
|
---|
| 31 | Element* element=(Element*)elements->GetObjectByOffset(counter);
|
---|
[25379] | 32 | element->Update(inputs,i,iomodel,analysis_counter,analysis_type,P1Enum);
|
---|
[19984] | 33 | counter++;
|
---|
| 34 | }
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | /*Create inputs: */
|
---|
[25379] | 38 | iomodel->FetchDataToInput(inputs,elements,"md.mask.ocean_levelset",MaskOceanLevelsetEnum);
|
---|
| 39 | iomodel->FetchDataToInput(inputs,elements,"md.mask.ice_levelset",MaskIceLevelsetEnum);
|
---|
[25118] | 40 | iomodel->FetchData(&geodetic,"md.solidearth.settings.computesealevelchange");
|
---|
[25379] | 41 | iomodel->FetchDataToInput(inputs,elements,"md.solidearth.surfaceload.icethicknesschange",SurfaceloadIceThicknessChangeEnum);
|
---|
| 42 | iomodel->FetchDataToInput(inputs,elements,"md.solidearth.sealevel",SealevelEnum,0);
|
---|
| 43 | iomodel->FetchDataToInput(inputs,elements,"md.geometry.bed",BedEnum);
|
---|
| 44 | iomodel->FetchDataToInput(inputs,elements,"md.solidearth.surfaceload.waterheightchange",SurfaceloadWaterHeightChangeEnum);
|
---|
[24469] | 45 |
|
---|
| 46 | /*dynamic sea level: */
|
---|
| 47 | iomodel->FetchData(&dslmodel,"md.dsl.model");
|
---|
[24505] | 48 | if (dslmodel==1){ /*standard dsl model:{{{*/
|
---|
[24481] | 49 |
|
---|
| 50 | /*deal with global mean steric rate: */
|
---|
| 51 | IssmDouble* str=NULL;
|
---|
| 52 | IssmDouble* times = NULL;
|
---|
| 53 | int M,N;
|
---|
| 54 |
|
---|
| 55 | /*fetch str vector:*/
|
---|
| 56 | iomodel->FetchData(&str,&M,&N,"md.dsl.global_average_thermosteric_sea_level_change"); _assert_(M==2);
|
---|
| 57 |
|
---|
| 58 | //recover time vector:
|
---|
| 59 | times=xNew<IssmDouble>(N);
|
---|
| 60 | for(int t=0;t<N;t++) times[t] = str[N+t];
|
---|
| 61 |
|
---|
| 62 | /*create transient input: */
|
---|
[25379] | 63 | inputs->SetTransientInput(DslGlobalAverageThermostericSeaLevelChangeEnum,times,N);
|
---|
| 64 | TransientInput* transientinput = inputs->GetTransientInput(DslGlobalAverageThermostericSeaLevelChangeEnum);
|
---|
[24481] | 65 |
|
---|
| 66 |
|
---|
[25539] | 67 | for(Object* & object : elements->objects){
|
---|
| 68 | Element* element=xDynamicCast<Element*>(object);
|
---|
[24481] | 69 |
|
---|
| 70 | for(int t=0;t<N;t++){
|
---|
| 71 | switch(element->ObjectEnum()){
|
---|
| 72 | case TriaEnum: transientinput->AddTriaTimeInput( t,1,&element->lid,&str[t],P0Enum); break;
|
---|
| 73 | case PentaEnum: transientinput->AddPentaTimeInput(t,1,&element->lid,&str[t],P0Enum); break;
|
---|
| 74 | default: _error_("Not implemented yet");
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | /*cleanup:*/
|
---|
| 80 | xDelete<IssmDouble>(times);
|
---|
| 81 | iomodel->DeleteData(str,"md.dsl.global_average_thermosteric_sea_level_change");
|
---|
| 82 |
|
---|
| 83 | /*deal with dynamic sea level fields: */
|
---|
[25379] | 84 | iomodel->FetchDataToInput(inputs,elements,"md.dsl.sea_surface_height_change_above_geoid", DslSeaSurfaceHeightChangeAboveGeoidEnum);
|
---|
| 85 | iomodel->FetchDataToInput(inputs,elements,"md.dsl.sea_water_pressure_change_at_sea_floor", DslSeaWaterPressureChangeAtSeaFloorEnum);
|
---|
[24481] | 86 |
|
---|
[24505] | 87 | } /*}}}*/
|
---|
| 88 | else if (dslmodel==2){ /*multi-model ensemble dsl model:{{{*/
|
---|
| 89 |
|
---|
| 90 | /*variables:*/
|
---|
| 91 | int nummodels;
|
---|
| 92 | IssmDouble** pstr=NULL;
|
---|
| 93 | IssmDouble* str=NULL;
|
---|
| 94 | IssmDouble* times = NULL;
|
---|
| 95 | int* pM = NULL;
|
---|
| 96 | int* pN = NULL;
|
---|
| 97 | int M,N;
|
---|
| 98 |
|
---|
[25275] | 99 | /*deal with dsl.global_average_thermosteric_sea_level_change {{{*/
|
---|
[24505] | 100 | iomodel->FetchData(&pstr,&pM,&pN,&nummodels,"md.dsl.global_average_thermosteric_sea_level_change");
|
---|
| 101 |
|
---|
| 102 | /*go through the mat array and create a dataset of transient inputs:*/
|
---|
| 103 | for (int i=0;i<nummodels;i++){
|
---|
| 104 |
|
---|
| 105 | M=pM[i];
|
---|
| 106 | N=pN[i];
|
---|
| 107 | str=pstr[i];
|
---|
| 108 |
|
---|
| 109 | //recover time vector:
|
---|
| 110 | times=xNew<IssmDouble>(N);
|
---|
| 111 | for(int t=0;t<N;t++) times[t] = str[(M-1)*N+t];
|
---|
| 112 |
|
---|
[25379] | 113 | TransientInput* transientinput=inputs->SetDatasetTransientInput(DslGlobalAverageThermostericSeaLevelChangeEnum,i, times,N);
|
---|
[24505] | 114 |
|
---|
[25539] | 115 | for(Object* & object : elements->objects){
|
---|
| 116 | Element* element=xDynamicCast<Element*>(object);
|
---|
[24505] | 117 |
|
---|
| 118 | for(int t=0;t<N;t++){
|
---|
| 119 | switch(element->ObjectEnum()){
|
---|
| 120 | case TriaEnum: transientinput->AddTriaTimeInput( t,1,&element->lid,&str[t],P0Enum); break;
|
---|
| 121 | case PentaEnum: transientinput->AddPentaTimeInput(t,1,&element->lid,&str[t],P0Enum); break;
|
---|
| 122 | default: _error_("Not implemented yet");
|
---|
| 123 | }
|
---|
| 124 | }
|
---|
| 125 | }
|
---|
| 126 | xDelete<IssmDouble>(times);
|
---|
| 127 | }
|
---|
| 128 | /*Delete data:*/
|
---|
| 129 | for(int i=0;i<nummodels;i++){
|
---|
| 130 | IssmDouble* str=pstr[i];
|
---|
| 131 | xDelete<IssmDouble>(str);
|
---|
| 132 | }
|
---|
| 133 | xDelete<IssmDouble*>(pstr);
|
---|
| 134 | xDelete<int>(pM);
|
---|
| 135 | xDelete<int>(pN);
|
---|
| 136 | /*}}}*/
|
---|
[25379] | 137 | iomodel->FetchDataToInput(inputs,elements,"md.dsl.sea_surface_height_change_above_geoid",DslSeaSurfaceHeightChangeAboveGeoidEnum);
|
---|
| 138 | iomodel->FetchDataToInput(inputs,elements,"md.dsl.sea_water_pressure_change_at_sea_floor",DslSeaWaterPressureChangeAtSeaFloorEnum);
|
---|
[24505] | 139 |
|
---|
| 140 | } /*}}}*/
|
---|
[24469] | 141 | else _error_("Dsl model " << dslmodel << " not implemented yet!");
|
---|
[25060] | 142 |
|
---|
[25066] | 143 |
|
---|
[25060] | 144 |
|
---|
[22968] | 145 | /*Initialize cumdeltalthickness and sealevel rise rate input*/
|
---|
[25379] | 146 | InputUpdateFromConstantx(inputs,elements,0.,SealevelriseCumDeltathicknessEnum);
|
---|
| 147 | InputUpdateFromConstantx(inputs,elements,0.,SealevelNEsaRateEnum);
|
---|
| 148 | InputUpdateFromConstantx(inputs,elements,0.,SealevelUEsaRateEnum);
|
---|
| 149 | InputUpdateFromConstantx(inputs,elements,0.,SealevelRSLRateEnum);
|
---|
| 150 | InputUpdateFromConstantx(inputs,elements,0.,SealevelEustaticMaskEnum);
|
---|
| 151 | InputUpdateFromConstantx(inputs,elements,0.,SealevelEustaticOceanMaskEnum);
|
---|
[22968] | 152 |
|
---|
[19984] | 153 | }/*}}}*/
|
---|
| 154 | void SealevelriseAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/
|
---|
| 155 |
|
---|
[19986] | 156 | int nl;
|
---|
[19984] | 157 | IssmDouble* love_h=NULL;
|
---|
| 158 | IssmDouble* love_k=NULL;
|
---|
[20999] | 159 | IssmDouble* love_l=NULL;
|
---|
[25139] | 160 | IssmDouble* love_th=NULL;
|
---|
| 161 | IssmDouble* love_tk=NULL;
|
---|
| 162 | IssmDouble* love_tl=NULL;
|
---|
[24469] | 163 | int dslmodel=0;
|
---|
[23066] | 164 |
|
---|
[24921] | 165 | IssmDouble* G_rigid = NULL;
|
---|
| 166 | IssmDouble* G_rigid_local = NULL;
|
---|
[20028] | 167 | IssmDouble* G_elastic = NULL;
|
---|
[20033] | 168 | IssmDouble* G_elastic_local = NULL;
|
---|
[20999] | 169 | IssmDouble* U_elastic = NULL;
|
---|
| 170 | IssmDouble* U_elastic_local = NULL;
|
---|
| 171 | IssmDouble* H_elastic = NULL;
|
---|
| 172 | IssmDouble* H_elastic_local = NULL;
|
---|
[20033] | 173 | int M,m,lower_row,upper_row;
|
---|
| 174 | IssmDouble degacc=.01;
|
---|
[24959] | 175 | IssmDouble planetradius=0;
|
---|
| 176 | IssmDouble planetarea=0;
|
---|
[25655] | 177 | bool elastic=false;
|
---|
[19984] | 178 |
|
---|
[20036] | 179 | int numoutputs;
|
---|
| 180 | char** requestedoutputs = NULL;
|
---|
| 181 |
|
---|
[20136] | 182 | /*transition vectors: */
|
---|
| 183 | IssmDouble **transitions = NULL;
|
---|
| 184 | int *transitions_M = NULL;
|
---|
| 185 | int *transitions_N = NULL;
|
---|
| 186 | int ntransitions;
|
---|
[25754] | 187 | IssmDouble* partitionice=NULL;
|
---|
| 188 | IssmDouble* partitionhydro=NULL;
|
---|
| 189 | IssmDouble* bslrice_partition=NULL;
|
---|
| 190 | IssmDouble* bslrhydro_partition=NULL;
|
---|
| 191 | int npartice,nparthydro,nel;
|
---|
[20136] | 192 |
|
---|
[25754] | 193 |
|
---|
[19986] | 194 | /*some constant parameters: */
|
---|
[24531] | 195 | parameters->AddObject(iomodel->CopyConstantObject("md.dsl.model",DslModelEnum));
|
---|
[25118] | 196 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.runfrequency",SolidearthSettingsRunFrequencyEnum));
|
---|
| 197 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.reltol",SolidearthSettingsReltolEnum));
|
---|
| 198 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.abstol",SolidearthSettingsAbstolEnum));
|
---|
| 199 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.maxiter",SolidearthSettingsMaxiterEnum));
|
---|
| 200 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.rigid",SolidearthSettingsRigidEnum));
|
---|
| 201 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.horiz",SolidearthSettingsHorizEnum));
|
---|
| 202 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.elastic",SolidearthSettingsElasticEnum));
|
---|
| 203 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.rotation",SolidearthSettingsRotationEnum));
|
---|
| 204 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.rotational.equatorialmoi",RotationalEquatorialMoiEnum));
|
---|
| 205 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.rotational.polarmoi",RotationalPolarMoiEnum));
|
---|
| 206 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.rotational.angularvelocity",RotationalAngularVelocityEnum));
|
---|
| 207 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.ocean_area_scaling",SolidearthSettingsOceanAreaScalingEnum));
|
---|
| 208 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.computesealevelchange",SolidearthSettingsComputesealevelchangeEnum));
|
---|
| 209 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.planetradius",SolidearthPlanetRadiusEnum));
|
---|
[25751] | 210 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.glfraction",SolidearthSettingsGlfractionEnum));
|
---|
[25627] | 211 | parameters->AddObject(new DoubleParam(CumBslrEnum,0.0));
|
---|
| 212 | parameters->AddObject(new DoubleParam(CumBslrIceEnum,0.0));
|
---|
| 213 | parameters->AddObject(new DoubleParam(CumBslrHydroEnum,0.0));
|
---|
| 214 | parameters->AddObject(new DoubleParam(CumGmtslrEnum,0.0));
|
---|
[19986] | 215 |
|
---|
[24959] | 216 | /*compute planet area and plug into parameters:*/
|
---|
[25118] | 217 | iomodel->FetchData(&planetradius,"md.solidearth.planetradius");
|
---|
[24959] | 218 | planetarea=4*PI*planetradius*planetradius;
|
---|
[25118] | 219 | parameters->AddObject(new DoubleParam(SolidearthPlanetAreaEnum,planetarea));
|
---|
[24959] | 220 |
|
---|
[25751] | 221 | /*Deal with partition of the barystatic contribution:*/
|
---|
| 222 | iomodel->FetchData(&npartice,"md.solidearth.npartice");
|
---|
| 223 | parameters->AddObject(new IntParam(SolidearthNpartIceEnum,npartice));
|
---|
| 224 | if(npartice){
|
---|
| 225 | iomodel->FetchData(&partitionice,&nel,NULL,"md.solidearth.partitionice");
|
---|
| 226 | parameters->AddObject(new DoubleMatParam(SolidearthPartitionIceEnum,partitionice,nel,1));
|
---|
| 227 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.npartice",SolidearthNpartIceEnum));
|
---|
| 228 | bslrice_partition=xNewZeroInit<IssmDouble>(npartice);
|
---|
| 229 | parameters->AddObject(new DoubleMatParam(CumBslrIcePartitionEnum,bslrice_partition,npartice,1));
|
---|
| 230 | xDelete<IssmDouble>(partitionice);
|
---|
| 231 | }
|
---|
| 232 | iomodel->FetchData(&nparthydro,"md.solidearth.nparthydro");
|
---|
| 233 | parameters->AddObject(new IntParam(SolidearthNpartHydroEnum,nparthydro));
|
---|
| 234 | if(nparthydro){
|
---|
| 235 | iomodel->FetchData(&partitionhydro,&nel,NULL,"md.solidearth.partitionhydro");
|
---|
| 236 | parameters->AddObject(new DoubleMatParam(SolidearthPartitionHydroEnum,partitionhydro,nel,1));
|
---|
| 237 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.nparthydro",SolidearthNpartHydroEnum));
|
---|
| 238 | bslrhydro_partition=xNewZeroInit<IssmDouble>(nparthydro);
|
---|
| 239 | parameters->AddObject(new DoubleMatParam(CumBslrHydroPartitionEnum,bslrhydro_partition,nparthydro,1));
|
---|
| 240 | xDelete<IssmDouble>(partitionhydro);
|
---|
| 241 | }
|
---|
| 242 |
|
---|
[24505] | 243 | /*Deal with dsl multi-model ensembles: {{{*/
|
---|
| 244 | iomodel->FetchData(&dslmodel,"md.dsl.model");
|
---|
| 245 | parameters->AddObject(iomodel->CopyConstantObject("md.dsl.compute_fingerprints",DslComputeFingerprintsEnum));
|
---|
| 246 | if(dslmodel==2){
|
---|
[25273] | 247 | IssmDouble modelid;
|
---|
[24505] | 248 | int nummodels;
|
---|
[25273] | 249 |
|
---|
| 250 | /*create double param, not int param, because Dakota will be updating it as
|
---|
| 251 | * a double potentially: */
|
---|
| 252 | iomodel->FetchData(&modelid,"md.dsl.modelid");
|
---|
[25274] | 253 | parameters->AddObject(new DoubleParam(DslModelidEnum,modelid));
|
---|
[24505] | 254 | parameters->AddObject(iomodel->CopyConstantObject("md.dsl.nummodels",DslNummodelsEnum));
|
---|
| 255 | iomodel->FetchData(&nummodels,"md.dsl.nummodels");
|
---|
| 256 |
|
---|
| 257 | /*quick checks: */
|
---|
| 258 | if(nummodels<=0)_error_("dslmme object in md.dsl field should contain at least 1 ensemble model!");
|
---|
| 259 | if(modelid<=0 || modelid>nummodels)_error_("modelid field in dslmme object of md.dsl field should be between 1 and the number of ensemble runs!");
|
---|
| 260 | } /*}}}*/
|
---|
[24481] | 261 | /*Deal with elasticity {{{*/
|
---|
[25627] | 262 | iomodel->FetchData(&elastic,"md.solidearth.settings.elastic");
|
---|
[25751] | 263 | if(elastic){
|
---|
[25758] | 264 | /*love numbers: */
|
---|
[25751] | 265 | iomodel->FetchData(&love_h,&nl,NULL,"md.solidearth.lovenumbers.h");
|
---|
| 266 | iomodel->FetchData(&love_k,&nl,NULL,"md.solidearth.lovenumbers.k");
|
---|
| 267 | iomodel->FetchData(&love_l,&nl,NULL,"md.solidearth.lovenumbers.l");
|
---|
| 268 | iomodel->FetchData(&love_th,&nl,NULL,"md.solidearth.lovenumbers.th");
|
---|
| 269 | iomodel->FetchData(&love_tk,&nl,NULL,"md.solidearth.lovenumbers.tk");
|
---|
| 270 | iomodel->FetchData(&love_tl,&nl,NULL,"md.solidearth.lovenumbers.tl");
|
---|
[25758] | 271 | parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.lovenumbers.tk2secular",TidalLoveK2SecularEnum));
|
---|
[20022] | 272 |
|
---|
[25751] | 273 | parameters->AddObject(new DoubleMatParam(LoadLoveHEnum,love_h,nl,1));
|
---|
| 274 | parameters->AddObject(new DoubleMatParam(LoadLoveKEnum,love_k,nl,1));
|
---|
| 275 | parameters->AddObject(new DoubleMatParam(LoadLoveLEnum,love_l,nl,1));
|
---|
| 276 | parameters->AddObject(new DoubleMatParam(TidalLoveHEnum,love_th,nl,1));
|
---|
| 277 | parameters->AddObject(new DoubleMatParam(TidalLoveKEnum,love_tk,nl,1));
|
---|
| 278 | parameters->AddObject(new DoubleMatParam(TidalLoveLEnum,love_tl,nl,1));
|
---|
[21742] | 279 |
|
---|
[25758] | 280 | /*compute elastic green function for a range of angles*/
|
---|
| 281 | iomodel->FetchData(°acc,"md.solidearth.settings.degacc");
|
---|
| 282 | M=reCast<int,IssmDouble>(180./degacc+1.);
|
---|
| 283 |
|
---|
[25751] | 284 | // AD performance is sensitive to calls to ensurecontiguous.
|
---|
| 285 | // // Providing "t" will cause ensurecontiguous to be called.
|
---|
| 286 | #ifdef _HAVE_AD_
|
---|
[25758] | 287 | G_rigid=xNew<IssmDouble>(M,"t");
|
---|
[25751] | 288 | G_elastic=xNew<IssmDouble>(M,"t");
|
---|
| 289 | U_elastic=xNew<IssmDouble>(M,"t");
|
---|
| 290 | H_elastic=xNew<IssmDouble>(M,"t");
|
---|
| 291 | #else
|
---|
[25758] | 292 | G_rigid=xNew<IssmDouble>(M);
|
---|
[25751] | 293 | G_elastic=xNew<IssmDouble>(M);
|
---|
| 294 | U_elastic=xNew<IssmDouble>(M);
|
---|
| 295 | H_elastic=xNew<IssmDouble>(M);
|
---|
| 296 | #endif
|
---|
[21742] | 297 |
|
---|
[25751] | 298 | /*compute combined legendre + love number (elastic green function:*/
|
---|
| 299 | m=DetermineLocalSize(M,IssmComm::GetComm());
|
---|
| 300 | GetOwnershipBoundariesFromRange(&lower_row,&upper_row,m,IssmComm::GetComm());
|
---|
[25758] | 301 | // AD performance is sensitive to calls to ensurecontiguous.
|
---|
| 302 | // // Providing "t" will cause ensurecontiguous to be called.
|
---|
[25751] | 303 | #ifdef _HAVE_AD_
|
---|
| 304 | G_elastic_local=xNew<IssmDouble>(m,"t");
|
---|
[25758] | 305 | G_rigid_local=xNew<IssmDouble>(m,"t");
|
---|
[25751] | 306 | U_elastic_local=xNew<IssmDouble>(m,"t");
|
---|
| 307 | H_elastic_local=xNew<IssmDouble>(m,"t");
|
---|
| 308 | #else
|
---|
| 309 | G_elastic_local=xNew<IssmDouble>(m);
|
---|
[25758] | 310 | G_rigid_local=xNew<IssmDouble>(m);
|
---|
[25751] | 311 | U_elastic_local=xNew<IssmDouble>(m);
|
---|
| 312 | H_elastic_local=xNew<IssmDouble>(m);
|
---|
| 313 | #endif
|
---|
[20029] | 314 |
|
---|
[25751] | 315 | for(int i=lower_row;i<upper_row;i++){
|
---|
| 316 | IssmDouble alpha,x;
|
---|
| 317 | alpha= reCast<IssmDouble>(i)*degacc * PI / 180.0;
|
---|
[25758] | 318 |
|
---|
[25751] | 319 | G_rigid_local[i-lower_row]= .5/sin(alpha/2.0);
|
---|
| 320 | G_elastic_local[i-lower_row]= (love_k[nl-1]-love_h[nl-1])*G_rigid_local[i-lower_row];
|
---|
| 321 | U_elastic_local[i-lower_row]= (love_h[nl-1])*G_rigid_local[i-lower_row];
|
---|
| 322 | H_elastic_local[i-lower_row]= 0;
|
---|
| 323 | IssmDouble Pn = 0.;
|
---|
| 324 | IssmDouble Pn1 = 0.;
|
---|
| 325 | IssmDouble Pn2 = 0.;
|
---|
| 326 | IssmDouble Pn_p = 0.;
|
---|
| 327 | IssmDouble Pn_p1 = 0.;
|
---|
| 328 | IssmDouble Pn_p2 = 0.;
|
---|
[20033] | 329 |
|
---|
[25751] | 330 | for (int n=0;n<nl;n++) {
|
---|
| 331 | IssmDouble deltalove_G;
|
---|
| 332 | IssmDouble deltalove_U;
|
---|
[25655] | 333 |
|
---|
[25751] | 334 | deltalove_G = (love_k[n]-love_k[nl-1]-love_h[n]+love_h[nl-1]);
|
---|
| 335 | deltalove_U = (love_h[n]-love_h[nl-1]);
|
---|
| 336 |
|
---|
| 337 | /*compute legendre polynomials: P_n(cos\theta) & d P_n(cos\theta)/ d\theta: */
|
---|
| 338 | if(n==0){
|
---|
| 339 | Pn=1;
|
---|
| 340 | Pn_p=0;
|
---|
[25627] | 341 | }
|
---|
[25751] | 342 | else if(n==1){
|
---|
| 343 | Pn = cos(alpha);
|
---|
| 344 | Pn_p = 1;
|
---|
| 345 | }
|
---|
| 346 | else{
|
---|
| 347 | Pn = ( (2*n-1)*cos(alpha)*Pn1 - (n-1)*Pn2 ) /n;
|
---|
| 348 | Pn_p = ( (2*n-1)*(Pn1+cos(alpha)*Pn_p1) - (n-1)*Pn_p2 ) /n;
|
---|
| 349 | }
|
---|
| 350 | Pn2=Pn1; Pn1=Pn;
|
---|
| 351 | Pn_p2=Pn_p1; Pn_p1=Pn_p;
|
---|
| 352 |
|
---|
| 353 | G_elastic_local[i-lower_row] += deltalove_G*Pn; // gravitational potential
|
---|
| 354 | U_elastic_local[i-lower_row] += deltalove_U*Pn; // vertical (up) displacement
|
---|
| 355 | H_elastic_local[i-lower_row] += sin(alpha)*love_l[n]*Pn_p; // horizontal displacements
|
---|
[25655] | 356 | }
|
---|
[25751] | 357 | }
|
---|
[25627] | 358 |
|
---|
[25751] | 359 | /*merge G_elastic_local into G_elastic; U_elastic_local into U_elastic; H_elastic_local to H_elastic:{{{*/
|
---|
| 360 | int* recvcounts=xNew<int>(IssmComm::GetSize());
|
---|
| 361 | int* displs=xNew<int>(IssmComm::GetSize());
|
---|
[25655] | 362 |
|
---|
[25751] | 363 | //recvcounts:
|
---|
| 364 | ISSM_MPI_Allgather(&m,1,ISSM_MPI_INT,recvcounts,1,ISSM_MPI_INT,IssmComm::GetComm());
|
---|
[25655] | 365 |
|
---|
[25751] | 366 | /*displs: */
|
---|
| 367 | ISSM_MPI_Allgather(&lower_row,1,ISSM_MPI_INT,displs,1,ISSM_MPI_INT,IssmComm::GetComm());
|
---|
[25655] | 368 |
|
---|
[25751] | 369 | /*All gather:*/
|
---|
| 370 | ISSM_MPI_Allgatherv(G_rigid_local, m, ISSM_MPI_DOUBLE, G_rigid, recvcounts, displs, ISSM_MPI_DOUBLE,IssmComm::GetComm());
|
---|
[25758] | 371 | ISSM_MPI_Allgatherv(G_elastic_local, m, ISSM_MPI_DOUBLE, G_elastic, recvcounts, displs, ISSM_MPI_DOUBLE,IssmComm::GetComm());
|
---|
| 372 | ISSM_MPI_Allgatherv(U_elastic_local, m, ISSM_MPI_DOUBLE, U_elastic, recvcounts, displs, ISSM_MPI_DOUBLE,IssmComm::GetComm());
|
---|
| 373 | ISSM_MPI_Allgatherv(H_elastic_local, m, ISSM_MPI_DOUBLE, H_elastic, recvcounts, displs, ISSM_MPI_DOUBLE,IssmComm::GetComm());
|
---|
| 374 |
|
---|
[25751] | 375 | /*free resources: */
|
---|
| 376 | xDelete<int>(recvcounts);
|
---|
| 377 | xDelete<int>(displs);
|
---|
[25758] | 378 | /*}}}*/
|
---|
[25655] | 379 |
|
---|
[25751] | 380 | /*Avoid singularity at 0: */
|
---|
| 381 | G_rigid[0]=G_rigid[1];
|
---|
[25758] | 382 | parameters->AddObject(new DoubleVecParam(SealevelriseGRigidEnum,G_rigid,M));
|
---|
[25751] | 383 | G_elastic[0]=G_elastic[1];
|
---|
[25758] | 384 | parameters->AddObject(new DoubleVecParam(SealevelriseGElasticEnum,G_elastic,M));
|
---|
[25751] | 385 | U_elastic[0]=U_elastic[1];
|
---|
[25758] | 386 | parameters->AddObject(new DoubleVecParam(SealevelriseUElasticEnum,U_elastic,M));
|
---|
[25751] | 387 | H_elastic[0]=H_elastic[1];
|
---|
[25758] | 388 | parameters->AddObject(new DoubleVecParam(SealevelriseHElasticEnum,H_elastic,M));
|
---|
[25655] | 389 |
|
---|
[25751] | 390 | /*free resources: */
|
---|
[25758] | 391 | xDelete<IssmDouble>(love_h);
|
---|
| 392 | xDelete<IssmDouble>(love_k);
|
---|
| 393 | xDelete<IssmDouble>(love_l);
|
---|
| 394 | xDelete<IssmDouble>(love_th);
|
---|
| 395 | xDelete<IssmDouble>(love_tk);
|
---|
| 396 | xDelete<IssmDouble>(love_tl);
|
---|
[25751] | 397 | xDelete<IssmDouble>(G_rigid);
|
---|
| 398 | xDelete<IssmDouble>(G_rigid_local);
|
---|
[25758] | 399 | xDelete<IssmDouble>(G_elastic);
|
---|
| 400 | xDelete<IssmDouble>(G_elastic_local);
|
---|
| 401 | xDelete<IssmDouble>(U_elastic);
|
---|
| 402 | xDelete<IssmDouble>(U_elastic_local);
|
---|
| 403 | xDelete<IssmDouble>(H_elastic);
|
---|
| 404 | xDelete<IssmDouble>(H_elastic_local);
|
---|
[25655] | 405 | }
|
---|
[25751] | 406 |
|
---|
[25655] | 407 | /*Indicate we have not yet run the Geometry Core module: */
|
---|
[24977] | 408 | parameters->AddObject(new BoolParam(SealevelriseGeometryDoneEnum,false));
|
---|
[25758] | 409 | /*}}}*/
|
---|
[24977] | 410 |
|
---|
[24481] | 411 | /*Transitions:{{{ */
|
---|
[25118] | 412 | iomodel->FetchData(&transitions,&transitions_M,&transitions_N,&ntransitions,"md.solidearth.transitions");
|
---|
[20136] | 413 | if(transitions){
|
---|
| 414 | parameters->AddObject(new DoubleMatArrayParam(SealevelriseTransitionsEnum,transitions,ntransitions,transitions_M,transitions_N));
|
---|
| 415 |
|
---|
| 416 | for(int i=0;i<ntransitions;i++){
|
---|
| 417 | IssmDouble* transition=transitions[i];
|
---|
| 418 | xDelete<IssmDouble>(transition);
|
---|
| 419 | }
|
---|
| 420 | xDelete<IssmDouble*>(transitions);
|
---|
[20138] | 421 | xDelete<int>(transitions_M);
|
---|
| 422 | xDelete<int>(transitions_N);
|
---|
[24481] | 423 | } /*}}}*/
|
---|
| 424 | /*Requested outputs {{{*/
|
---|
[25118] | 425 | iomodel->FindConstant(&requestedoutputs,&numoutputs,"md.solidearth.requested_outputs");
|
---|
[20036] | 426 | if(numoutputs)parameters->AddObject(new StringArrayParam(SealevelriseRequestedOutputsEnum,requestedoutputs,numoutputs));
|
---|
[25118] | 427 | iomodel->DeleteData(&requestedoutputs,numoutputs,"md.solidearth.requested_outputs");
|
---|
[24481] | 428 | /*}}}*/
|
---|
[20029] | 429 |
|
---|
[19984] | 430 | }/*}}}*/
|
---|
| 431 |
|
---|
| 432 | /*Finite Element Analysis*/
|
---|
| 433 | void SealevelriseAnalysis::Core(FemModel* femmodel){/*{{{*/
|
---|
| 434 | _error_("not implemented");
|
---|
| 435 | }/*}}}*/
|
---|
| 436 | ElementVector* SealevelriseAnalysis::CreateDVector(Element* element){/*{{{*/
|
---|
| 437 | /*Default, return NULL*/
|
---|
| 438 | return NULL;
|
---|
| 439 | }/*}}}*/
|
---|
| 440 | ElementMatrix* SealevelriseAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/
|
---|
| 441 | _error_("Not implemented");
|
---|
| 442 | }/*}}}*/
|
---|
| 443 | ElementMatrix* SealevelriseAnalysis::CreateKMatrix(Element* element){/*{{{*/
|
---|
| 444 | _error_("not implemented yet");
|
---|
| 445 | }/*}}}*/
|
---|
| 446 | ElementVector* SealevelriseAnalysis::CreatePVector(Element* element){/*{{{*/
|
---|
| 447 | _error_("not implemented yet");
|
---|
| 448 | }/*}}}*/
|
---|
| 449 | void SealevelriseAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/
|
---|
| 450 | _error_("not implemented yet");
|
---|
| 451 | }/*}}}*/
|
---|
[25317] | 452 | void SealevelriseAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_interp,int control_index){/*{{{*/
|
---|
[19984] | 453 | _error_("Not implemented yet");
|
---|
| 454 | }/*}}}*/
|
---|
| 455 | void SealevelriseAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/
|
---|
[22955] | 456 | _error_("not implemeneted yet!");
|
---|
[20153] | 457 |
|
---|
[19984] | 458 | }/*}}}*/
|
---|
| 459 | void SealevelriseAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/
|
---|
| 460 | /*Default, do nothing*/
|
---|
| 461 | return;
|
---|
| 462 | }/*}}}*/
|
---|