Changeset 18659
- Timestamp:
- 10/20/14 09:14:10 (10 years ago)
- Location:
- issm/trunk-jpl/src/c/analyses
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/c/analyses/EnthalpyAnalysis.cpp ¶
r18656 r18659 1189 1189 }/*}}}*/ 1190 1190 void EnthalpyAnalysis::UpdateBasalConstraints(FemModel* femmodel){/*{{{*/ 1191 1191 1192 /*Update basal dirichlet BCs for enthalpy: */ 1193 Vector<IssmDouble>* spc = NULL; 1194 IssmDouble* serial_spc = NULL; 1195 1196 spc=new Vector<IssmDouble>(femmodel->nodes->NumberOfNodes(EnthalpyAnalysisEnum)); 1197 /*First create a vector to figure out what elements should be constrained*/ 1192 1198 for(int i=0;i<femmodel->elements->Size();i++){ 1193 1199 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 1194 UpdateBasalConstraints(element); 1195 } 1200 GetBasalConstraints(spc,element); 1201 } 1202 1203 /*Assemble and serialize*/ 1204 spc->Assemble(); 1205 serial_spc=spc->ToMPISerial(); 1206 delete spc; 1207 1208 /*Then update basal constraints nodes accordingly*/ 1209 for(int i=0;i<femmodel->elements->Size();i++){ 1210 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 1211 ApplyBasalConstraints(serial_spc,element); 1212 } 1213 1196 1214 femmodel->UpdateConstraintsx(); 1197 }/*}}}*/ 1198 void EnthalpyAnalysis::UpdateBasalConstraints(Element* element){/*{{{*/ 1215 1216 /*Delete*/ 1217 xDelete<IssmDouble>(serial_spc); 1218 }/*}}}*/ 1219 void EnthalpyAnalysis::ApplyBasalConstraints(IssmDouble* serial_spc,Element* element){/*{{{*/ 1220 1221 /* Check if ice in element */ 1222 if(!element->IsIceInElement()) return; 1223 1224 /* Only update Constraints at the base of grounded ice*/ 1225 if(!(element->IsOnBase()) || element->IsFloating()) return; 1226 1227 /*Intermediary*/ 1228 bool isdynamicbasalspc; 1229 int numindices; 1230 int *indices = NULL; 1231 Node* node = NULL; 1232 IssmDouble pressure; 1233 1234 /*Check wether dynamic basal boundary conditions are activated */ 1235 element->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum); 1236 if(!isdynamicbasalspc) return; 1237 1238 /*Get parameters and inputs: */ 1239 Input* pressure_input = element->GetInput(PressureEnum); _assert_(pressure_input); 1240 1241 /*Fetch indices of basal & surface nodes for this finite element*/ 1242 Penta *penta = (Penta *) element; // TODO: add Basal-/SurfaceNodeIndices to element.h, and change this to Element* 1243 penta->BasalNodeIndices(&numindices,&indices,element->GetElementType()); 1244 1245 GaussPenta* gauss=new GaussPenta(); 1246 for(int i=0;i<numindices;i++){ 1247 gauss->GaussNode(element->GetElementType(),indices[i]); 1248 1249 pressure_input->GetInputValue(&pressure,gauss); 1250 1251 /*apply or release spc*/ 1252 node=element->GetNode(indices[i]); 1253 if(serial_spc[node->Sid()]==1.){ 1254 pressure_input->GetInputValue(&pressure, gauss); 1255 node->ApplyConstraint(0,PureIceEnthalpy(element,pressure)); 1256 } 1257 else 1258 node->DofInFSet(0); 1259 } 1260 1261 /*Free ressources:*/ 1262 xDelete<int>(indices); 1263 delete gauss; 1264 }/*}}}*/ 1265 void EnthalpyAnalysis::GetBasalConstraints(Vector<IssmDouble>* vec_spc,Element* element){/*{{{*/ 1199 1266 1200 1267 /* Check if ice in element */ … … 1214 1281 element->FindParam(&dt,TimesteppingTimeStepEnum); 1215 1282 if(dt==0.){ 1216 UpdateBasalConstraintsSteadystate(element);1283 GetBasalConstraintsSteadystate(vec_spc,element); 1217 1284 } 1218 1285 else{ 1219 UpdateBasalConstraintsTransient(element);1220 } 1221 }/*}}}*/ 1222 void EnthalpyAnalysis:: UpdateBasalConstraintsTransient(Element* element){/*{{{*/1286 GetBasalConstraintsTransient(vec_spc,element); 1287 } 1288 }/*}}}*/ 1289 void EnthalpyAnalysis::GetBasalConstraintsTransient(Vector<IssmDouble>* vec_spc,Element* element){/*{{{*/ 1223 1290 1224 1291 /* Check if ice in element */ … … 1229 1296 1230 1297 /*Intermediary*/ 1231 bool isdynamicbasalspc,setspc;1232 1298 int numindices, numindicesup, state; 1233 1299 int *indices = NULL, *indicesup = NULL; 1234 Node* node = NULL;1235 1300 IssmDouble enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate; 1236 1237 /*Check wether dynamic basal boundary conditions are activated */1238 element->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum);1239 if(!isdynamicbasalspc) return;1240 1301 1241 1302 /*Get parameters and inputs: */ … … 1266 1327 state=GetThermalBasalCondition(element, enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate); 1267 1328 1268 setspc=false;1269 1329 switch (state) { 1270 1330 case 0: 1271 1331 // cold, dry base: apply basal surface forcing 1332 vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL); 1272 1333 break; 1273 1334 case 1: 1274 1335 // cold, wet base: keep at pressure melting point 1275 setspc=true;1336 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1276 1337 break; 1277 1338 case 2: 1278 1339 // temperate, thin refreezing base: release spc 1340 vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL); 1279 1341 break; 1280 1342 case 3: 1281 1343 // temperate, thin melting base: set spc 1282 setspc=true;1344 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1283 1345 break; 1284 1346 case 4: 1285 1347 // temperate, thick melting base: set grad H*n=0 1348 vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL); 1286 1349 break; 1287 1350 default: … … 1289 1352 } 1290 1353 1291 /*apply or release spc*/1292 node=element->GetNode(indices[i]);1293 if(setspc){1294 pressure_input->GetInputValue(&pressure, gauss);1295 node->ApplyConstraint(0,PureIceEnthalpy(element,pressure));1296 }1297 else1298 node->DofInFSet(0);1299 1354 } 1300 1355 … … 1305 1360 delete gaussup; 1306 1361 }/*}}}*/ 1307 void EnthalpyAnalysis:: UpdateBasalConstraintsSteadystate(Element* element){/*{{{*/1362 void EnthalpyAnalysis::GetBasalConstraintsSteadystate(Vector<IssmDouble>* vec_spc,Element* element){/*{{{*/ 1308 1363 1309 1364 /* Check if ice in element */ … … 1314 1369 1315 1370 /*Intermediary*/ 1316 bool isdynamicbasalspc,setspc;1317 1371 int numindices, numindicesup, state; 1318 1372 int *indices = NULL, *indicesup = NULL; 1319 Node* node = NULL;1320 1373 IssmDouble enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate; 1321 1322 /*Check wether dynamic basal boundary conditions are activated */1323 element->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum);1324 if(!isdynamicbasalspc) return;1325 1374 1326 1375 /*Get parameters and inputs: */ … … 1349 1398 1350 1399 state=GetThermalBasalCondition(element, enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate); 1351 setspc=false;1352 1400 switch (state) { 1353 1401 case 0: 1354 1402 // cold, dry base: apply basal surface forcing 1403 vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL); 1355 1404 break; 1356 1405 case 1: 1357 1406 // cold, wet base: keep at pressure melting point 1358 setspc=true;1407 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1359 1408 break; 1360 1409 case 2: 1361 1410 // temperate, thin refreezing base: release spc 1411 vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL); 1362 1412 break; 1363 1413 case 3: 1364 1414 // temperate, thin melting base: set spc 1365 setspc=true;1415 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1366 1416 break; 1367 1417 case 4: 1368 1418 // temperate, thick melting base: s 1369 setspc=true;1419 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1370 1420 break; 1371 1421 default: 1372 1422 _printf0_(" unknown thermal basal state found!"); 1373 1423 } 1374 1375 /*apply or release spc*/1376 node=element->GetNode(indices[i]);1377 if(setspc){1378 pressure_input->GetInputValue(&pressure, gauss);1379 node->ApplyConstraint(0,PureIceEnthalpy(element,pressure));1380 }1381 else1382 node->DofInFSet(0);1383 1424 } 1384 1425 -
TabularUnified issm/trunk-jpl/src/c/analyses/EnthalpyAnalysis.h ¶
r18620 r18659 48 48 static void DrainWaterfraction(Element* element, IssmDouble* pdrainrate_element); 49 49 static void UpdateBasalConstraints(FemModel* femmodel); 50 static void UpdateBasalConstraints(Element* element); 51 static void UpdateBasalConstraintsTransient(Element* element); 52 static void UpdateBasalConstraintsSteadystate(Element* element); 50 static void ApplyBasalConstraints(IssmDouble* serial_spc,Element* element); 51 static void GetBasalConstraints(Vector<IssmDouble>* vec_spc,Element* element); 52 static void GetBasalConstraintsTransient(Vector<IssmDouble>* vec_spc,Element* element); 53 static void GetBasalConstraintsSteadystate(Vector<IssmDouble>* vec_spc,Element* element); 53 54 static int GetThermalBasalCondition(Element* element, IssmDouble enthalpy, IssmDouble enthalpy_up, IssmDouble pressure, IssmDouble pressure_up, IssmDouble watercolumn, IssmDouble meltingrate); 54 55 static IssmDouble GetWetIceConductivity(Element* element, IssmDouble enthalpy, IssmDouble pressure);
Note:
See TracChangeset
for help on using the changeset viewer.