Changeset 24313 for issm/trunk/src/c/classes/Loads/Moulin.cpp
- Timestamp:
- 11/01/19 12:01:57 (5 years ago)
- Location:
- issm/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/c
- Property svn:ignore
-
issm/trunk/src/c/classes/Loads/Moulin.cpp
r23189 r24313 23 23 this->parameters=NULL; 24 24 this->hnode=NULL; 25 this->hvertex=NULL; 25 26 this->node=NULL; 26 27 this->helement=NULL; 27 28 this->element=NULL; 28 this->hmatpar=NULL; 29 this->matpar=NULL; 30 } 31 /*}}}*/ 32 Moulin::Moulin(int id, int index, IoModel* iomodel, int in_analysis_type){ //i is the element index/*{{{*/ 29 } 30 /*}}}*/ 31 Moulin::Moulin(int id, int index, IoModel* iomodel){ /*{{{*/ 33 32 34 33 int pengrid_node_id; 35 int pengrid_matpar_id;36 34 int pengrid_element_id; 37 35 … … 43 41 /*id: */ 44 42 this->id=id; 45 this->analysis_type=in_analysis_type;46 43 47 44 /*hooks: */ 48 pengrid_node_id=i omodel->nodecounter+index+1;45 pengrid_node_id=index+1; 49 46 pengrid_element_id=iomodel->singlenodetoelementconnectivity[index]; 50 47 _assert_(pengrid_element_id); 51 pengrid_matpar_id=iomodel->numberofelements+1; //refers to the constant material parameters object52 48 53 49 this->hnode=new Hook(&pengrid_node_id,1); 50 this->hvertex=new Hook(&pengrid_node_id,1); 54 51 this->helement=new Hook(&pengrid_element_id,1); 55 this->hmatpar=new Hook(&pengrid_matpar_id,1);56 52 57 53 //this->parameters: we still can't point to it, it may not even exist. Configure will handle this. 58 54 this->parameters=NULL; 59 55 this->node=NULL; 56 this->vertex=NULL; 60 57 this->element=NULL; 61 this->matpar=NULL;62 58 } 63 59 /*}}}*/ 64 60 Moulin::~Moulin(){/*{{{*/ 65 61 delete hnode; 62 delete hvertex; 66 63 delete helement; 67 delete hmatpar;68 64 return; 69 65 } … … 79 75 /*copy fields: */ 80 76 pengrid->id=this->id; 81 pengrid->analysis_type=this->analysis_type;82 77 83 78 /*point parameters: */ … … 86 81 /*now deal with hooks and objects: */ 87 82 pengrid->hnode=(Hook*)this->hnode->copy(); 88 pengrid->h matpar=(Hook*)this->hmatpar->copy();83 pengrid->hvertex=(Hook*)this->hvertex->copy(); 89 84 pengrid->helement=(Hook*)this->helement->copy(); 90 85 91 86 /*corresponding fields*/ 92 87 pengrid->node =(Node*)pengrid->hnode->delivers(); 93 pengrid-> matpar =(Matpar*)pengrid->hmatpar->delivers();88 pengrid->vertex=(Vertex*)pengrid->hvertex->delivers(); 94 89 pengrid->element=(Element*)pengrid->helement->delivers(); 95 90 … … 101 96 _printf_("Moulin:\n"); 102 97 _printf_(" id: " << id << "\n"); 103 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n");104 98 hnode->DeepEcho(); 99 hvertex->DeepEcho(); 105 100 helement->DeepEcho(); 106 hmatpar->DeepEcho();107 101 _printf_(" parameters\n"); 108 102 parameters->DeepEcho(); … … 122 116 MARSHALLING_ENUM(MoulinEnum); 123 117 MARSHALLING(id); 124 MARSHALLING(analysis_type);125 118 126 119 if(marshall_direction==MARSHALLING_BACKWARD){ 127 120 this->hnode = new Hook(); 121 this->hvertex = new Hook(); 128 122 this->helement = new Hook(); 129 this->hmatpar = new Hook();130 123 } 131 124 132 125 this->hnode->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 126 this->hvertex->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 133 127 this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 134 this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);135 128 136 129 /*corresponding fields*/ 137 130 node =(Node*)this->hnode->delivers(); 138 matpar =(Matpar*)this->hmatpar->delivers();131 vertex =(Vertex*)this->hvertex->delivers(); 139 132 element=(Element*)this->helement->delivers(); 140 133 } … … 152 145 * datasets, using internal ids and offsets hidden in hooks: */ 153 146 hnode->configure(nodesin); 147 hvertex->configure(verticesin); 154 148 helement->configure(elementsin); 155 hmatpar->configure(materialsin);156 149 157 150 /*Get corresponding fields*/ 158 151 node=(Node*)hnode->delivers(); 152 vertex=(Vertex*)hvertex->delivers(); 159 153 element=(Element*)helement->delivers(); 160 matpar=(Matpar*)hmatpar->delivers();161 154 162 155 /*point parameters to real dataset: */ … … 166 159 void Moulin::CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs){/*{{{*/ 167 160 168 /*No loads applied, do nothing: */ 169 return; 161 /*recover some parameters*/ 162 ElementMatrix* Ke=NULL; 163 int analysis_type; 164 this->parameters->FindParam(&analysis_type,AnalysisTypeEnum); 165 166 switch(analysis_type){ 167 case HydrologyGlaDSAnalysisEnum: 168 Ke = this->CreateKMatrixHydrologyGlaDS(); 169 break; 170 case HydrologyShaktiAnalysisEnum: 171 /*do nothing: */ 172 return; 173 case HydrologyDCInefficientAnalysisEnum: 174 /*do nothing: */ 175 return; 176 case HydrologyDCEfficientAnalysisEnum: 177 /*do nothing: */ 178 return; 179 default: 180 _error_("Don't know why we should be here"); 181 182 } 183 /*Add to global matrix*/ 184 if(Ke){ 185 Ke->AddToGlobal(Kff,Kfs); 186 delete Ke; 187 } 170 188 171 189 } … … 178 196 179 197 switch(analysis_type){ 180 181 case HydrologyShaktiAnalysisEnum: 182 pe = this->CreatePVectorHydrologyShakti(); 183 break; 184 case HydrologyDCInefficientAnalysisEnum: 185 pe = CreatePVectorHydrologyDCInefficient(); 186 break; 187 case HydrologyDCEfficientAnalysisEnum: 188 pe = CreatePVectorHydrologyDCEfficient(); 189 break; 190 default: 191 _error_("Don't know why we should be here"); 192 /*No loads applied, do nothing: */ 193 return; 198 case HydrologyGlaDSAnalysisEnum: 199 pe = this->CreatePVectorHydrologyGlaDS(); 200 break; 201 case HydrologyShaktiAnalysisEnum: 202 pe = this->CreatePVectorHydrologyShakti(); 203 break; 204 case HydrologyDCInefficientAnalysisEnum: 205 pe = CreatePVectorHydrologyDCInefficient(); 206 break; 207 case HydrologyDCEfficientAnalysisEnum: 208 pe = CreatePVectorHydrologyDCEfficient(); 209 break; 210 default: 211 _error_("Don't know why we should be here"); 212 /*No loads applied, do nothing: */ 213 return; 194 214 } 195 215 if(pe){ … … 221 241 } 222 242 /*}}}*/ 223 bool Moulin::InAnalysis(int in_analysis_type){/*{{{*/224 if (in_analysis_type==this->analysis_type)return true;225 else return false;226 }227 /*}}}*/228 243 bool Moulin::IsPenalty(void){/*{{{*/ 229 return true;244 return false; 230 245 } 231 246 /*}}}*/ … … 245 260 this->node=NULL; 246 261 this->element=NULL; 247 this->matpar=NULL;248 262 this->parameters=NULL; 249 263 250 264 /*Get Element type*/ 251 265 this->hnode->reset(); 266 this->hvertex->reset(); 252 267 this->helement->reset(); 253 this->hmatpar->reset();254 268 255 269 } … … 277 291 switch(set2_enum){ 278 292 case FsetEnum: 279 if(node-> indexing.fsize){293 if(node->fsize){ 280 294 if(this->node->IsClone()) 281 295 o_nz += 1; … … 285 299 break; 286 300 case GsetEnum: 287 if(node-> indexing.gsize){301 if(node->gsize){ 288 302 if(this->node->IsClone()) 289 303 o_nz += 1; … … 293 307 break; 294 308 case SsetEnum: 295 if(node-> indexing.ssize){309 if(node->ssize){ 296 310 if(this->node->IsClone()) 297 311 o_nz += 1; … … 337 351 /*}}}*/ 338 352 353 ElementMatrix* Moulin::CreateKMatrixHydrologyGlaDS(void){/*{{{*/ 354 355 /*If this node is not the master node (belongs to another partition of the 356 * mesh), don't add the moulin input a second time*/ 357 if(node->IsClone()) return NULL; 358 359 /*Initialize Element matrix*/ 360 ElementMatrix* Ke=new ElementMatrix(&node,1,this->parameters); 361 362 /*Get all inputs and parameters*/ 363 IssmDouble dt = element->FindParam(TimesteppingTimeStepEnum); 364 IssmDouble rho_water = element->FindParam(MaterialsRhoFreshwaterEnum); 365 IssmDouble g = element->FindParam(ConstantsGEnum); 366 IssmDouble Am = 0.; //For now... 367 368 /*Load vector*/ 369 Ke->values[0] = - Am/(rho_water*g)/dt; 370 371 /*Clean up and return*/ 372 return Ke; 373 } 374 /*}}}*/ 375 ElementVector* Moulin::CreatePVectorHydrologyGlaDS(void){/*{{{*/ 376 377 /*If this node is not the master node (belongs to another partition of the 378 * mesh), don't add the moulin input a second time*/ 379 if(node->IsClone()) return NULL; 380 381 /*Initialize Element vector*/ 382 ElementVector* pe=new ElementVector(&node,1,this->parameters); 383 384 /*Get all inputs and parameters*/ 385 IssmDouble dt = element->FindParam(TimesteppingTimeStepEnum); 386 IssmDouble rho_water = element->FindParam(MaterialsRhoFreshwaterEnum); 387 IssmDouble g = element->FindParam(ConstantsGEnum); 388 IssmDouble Am = 0.; //For now... 389 390 /*Get hydraulic potential*/ 391 IssmDouble phi_old,moulin_load; 392 element->GetInputValue(&phi_old,node,HydraulicPotentialOldEnum); 393 element->GetInputValue(&moulin_load,node,HydrologyMoulinInputEnum); 394 395 pe->values[0] = moulin_load -Am/(rho_water*g) * phi_old/dt; 396 397 /*Clean up and return*/ 398 return pe; 399 } 400 /*}}}*/ 339 401 ElementVector* Moulin::CreatePVectorHydrologyShakti(void){/*{{{*/ 340 402
Note:
See TracChangeset
for help on using the changeset viewer.