Changeset 3388
- Timestamp:
- 04/05/10 09:43:05 (15 years ago)
- Location:
- issm/trunk/src/c/objects
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/ParameterInputs.cpp
r3332 r3388 385 385 } 386 386 387 ISSMERROR("create UpdateFromDakota routine, to call UpdateFromDakota in the elements, so it does not conflict 388 with UpdateFromInputs! in the elements"); 389 390 387 391 /*Free ressources:*/ 388 392 xfree((void**)&distributed_values); -
issm/trunk/src/c/objects/Tria.cpp
r3383 r3388 67 67 /*}}}*/ 68 68 69 /*Object marshalling*/ 69 /*Object management: */ 70 /*FUNCTION Configure {{{1*/ 71 void Tria::Configure(void* ploadsin,void* pnodesin,void* pmaterialsin,void* pparametersin){ 72 73 int i; 74 75 DataSet* loadsin=NULL; 76 DataSet* nodesin=NULL; 77 DataSet* materialsin=NULL; 78 DataSet* parametersin=NULL; 79 80 /*Recover pointers :*/ 81 loadsin=(DataSet*)ploadsin; 82 nodesin=(DataSet*)pnodesin; 83 materialsin=(DataSet*)pmaterialsin; 84 parametersin=(DataSet*)pparametersin; 85 86 /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 87 * datasets, using internal ids and offsets hidden in hooks: */ 88 hnodes.configure(nodesin); 89 hmatice.configure(materialsin); 90 hmatpar.configure(materialsin); 91 hnumpar.configure(parametersin); 92 93 } 94 /*}}}*/ 95 /*FUNCTION copy {{{1*/ 96 Object* Tria::copy() { 97 98 return new Tria(this->id,this->hnodes,this->hmatice,this->hmatpar,this->hnumpar,this->properties); 99 100 } 101 102 /*}}}*/ 103 /*FUNCTION Demarshall {{{1*/ 104 void Tria::Demarshall(char** pmarshalled_dataset){ 105 106 char* marshalled_dataset=NULL; 107 int i; 108 109 /*recover marshalled_dataset: */ 110 marshalled_dataset=*pmarshalled_dataset; 111 112 /*this time, no need to get enum type, the pointer directly points to the beginning of the 113 *object data (thanks to DataSet::Demarshall):*/ 114 115 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id); 116 117 /*demarshall hooks: */ 118 hnodes.Demarshall(&marshalled_dataset); 119 hmatice.Demarshall(&marshalled_dataset); 120 hmatpar.Demarshall(&marshalled_dataset); 121 hnumpar.Demarshall(&marshalled_dataset); 122 123 /*demarshall properties: */ 124 properties.Demarshall(&marshalled_dataset); 125 126 /*return: */ 127 *pmarshalled_dataset=marshalled_dataset; 128 return; 129 } 130 /*}}}*/ 131 /*FUNCTION DeepEcho{{{1*/ 132 133 void Tria::DeepEcho(void){ 134 135 printf("Tria:\n"); 136 printf(" id: %i\n",id); 137 hnodes.DeepEcho(); 138 hmatice.DeepEcho(); 139 hmatpar.DeepEcho(); 140 hnumpar.DeepEcho(); 141 properties.DeepEcho(); 142 143 return; 144 } 145 /*}}}*/ 146 /*FUNCTION Echo{{{1*/ 147 148 void Tria::Echo(void){ 149 150 printf("Tria:\n"); 151 printf(" id: %i\n",id); 152 hnodes.Echo(); 153 hmatice.Echo(); 154 hmatpar.Echo(); 155 hnumpar.Echo(); 156 properties.Echo(); 157 158 return; 159 } 160 /*}}}*/ 70 161 /*FUNCTION Marshall {{{1*/ 71 162 void Tria::Marshall(char** pmarshalled_dataset){ … … 111 202 } 112 203 /*}}}*/ 113 /*FUNCTION Demarshall {{{1*/ 114 void Tria::Demarshall(char** pmarshalled_dataset){ 115 116 char* marshalled_dataset=NULL; 117 int i; 118 119 /*recover marshalled_dataset: */ 120 marshalled_dataset=*pmarshalled_dataset; 121 122 /*this time, no need to get enum type, the pointer directly points to the beginning of the 123 *object data (thanks to DataSet::Demarshall):*/ 124 125 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id); 126 127 /*demarshall hooks: */ 128 hnodes.Demarshall(&marshalled_dataset); 129 hmatice.Demarshall(&marshalled_dataset); 130 hmatpar.Demarshall(&marshalled_dataset); 131 hnumpar.Demarshall(&marshalled_dataset); 132 133 /*demarshall properties: */ 134 properties.Demarshall(&marshalled_dataset); 135 136 /*return: */ 137 *pmarshalled_dataset=marshalled_dataset; 138 return; 139 } 140 /*}}}*/ 141 142 /*Object processing: */ 143 /*FUNCTION Echo{{{1*/ 144 145 void Tria::Echo(void){ 146 147 printf("Tria:\n"); 148 printf(" id: %i\n",id); 149 hnodes.Echo(); 150 hmatice.Echo(); 151 hmatpar.Echo(); 152 hnumpar.Echo(); 153 properties.Echo(); 154 155 return; 156 } 157 /*}}}*/ 158 /*FUNCTION DeepEcho{{{1*/ 159 160 void Tria::DeepEcho(void){ 161 162 printf("Tria:\n"); 163 printf(" id: %i\n",id); 164 hnodes.DeepEcho(); 165 hmatice.DeepEcho(); 166 hmatpar.DeepEcho(); 167 hnumpar.DeepEcho(); 168 properties.DeepEcho(); 169 170 return; 171 } 172 /*}}}*/ 173 /*FUNCTION Configure {{{1*/ 174 void Tria::Configure(void* ploadsin,void* pnodesin,void* pmaterialsin,void* pparametersin){ 175 176 int i; 177 178 DataSet* loadsin=NULL; 179 DataSet* nodesin=NULL; 180 DataSet* materialsin=NULL; 181 DataSet* parametersin=NULL; 182 183 /*Recover pointers :*/ 184 loadsin=(DataSet*)ploadsin; 185 nodesin=(DataSet*)pnodesin; 186 materialsin=(DataSet*)pmaterialsin; 187 parametersin=(DataSet*)pparametersin; 188 189 /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 190 * datasets, using internal ids and offsets hidden in hooks: */ 191 hnodes.configure(nodesin); 192 hmatice.configure(materialsin); 193 hmatpar.configure(materialsin); 194 hnumpar.configure(parametersin); 204 /*FUNCTION UpdateFromInputs {{{1*/ 205 void Tria::UpdateFromInputs(void* vinputs){ 206 207 int i; 208 int dofs[1]={0}; 209 double temperature_list[3]; 210 double temperature_average; 211 double B_list[3]; 212 double B_average; 213 double new_h[3]; 214 215 /*dynamic objects pointed to by hooks: */ 216 Node** nodes=NULL; 217 Matpar* matpar=NULL; 218 Matice* matice=NULL; 219 Numpar* numpar=NULL; 220 221 ParameterInputs* inputs=NULL; 222 223 /*recover pointers: */ 224 inputs=(ParameterInputs*)vinputs; 225 226 /*recover objects from hooks: */ 227 nodes=(Node**)hnodes.deliverp(); 228 matpar=(Matpar*)hmatpar.delivers(); 229 matice=(Matice*)hmatice.delivers(); 230 numpar=(Numpar*)hnumpar.delivers(); 231 232 /*Update internal data if inputs holds new values: */ 233 //if (id==1) printf("WARNING if QMU: no hydrostatic equilibrium is applied here (conflict with prognostic, which does not have matpar)\n"); 234 //For now 235 inputs->Recover("thickness",&this->properties.h[0],1,dofs,3,(void**)nodes); 236 //Later 237 /* 238 if(inputs->Recover("thickness",&new_h[0],1,dofs,3,(void**)nodes)){ 239 //density, needed later: 240 double di=(this->matpar->GetRhoIce()/this->matpar->GetRhoWater()); 241 //Go through grids: 242 for (i=0;i<3;i++){ 243 if(nodes[i]->IsOnShelf()){ 244 this->b[i]=this->b[i]-di*(new_h[i]-h[i]); //hydrostatic equilibrium; 245 } 246 this->s[i]=this->b[i]+new_h[i]; 247 this->h[i]=new_h[i]; 248 } 249 } 250 */ 251 inputs->Recover("surface",&this->properties.s[0],1,dofs,3,(void**)nodes); 252 inputs->Recover("bed",&this->properties.b[0],1,dofs,3,(void**)nodes); 253 inputs->Recover("drag",&this->properties.k[0],1,dofs,3,(void**)nodes); 254 inputs->Recover("melting",&this->properties.melting[0],1,dofs,3,(void**)nodes); 255 inputs->Recover("accumulation",&this->properties.accumulation[0],1,dofs,3,(void**)nodes); 256 inputs->Recover("geothermalflux",&this->properties.geothermalflux[0],1,dofs,3,(void**)nodes); 257 258 //Update material if necessary 259 if(inputs->Recover("temperature_average",&temperature_list[0],1,dofs,3,(void**)nodes)){ 260 temperature_average=(temperature_list[0]+temperature_list[1]+temperature_list[2])/3.0; 261 B_average=Paterson(temperature_average); 262 matice->SetB(B_average); 263 } 264 265 if(inputs->Recover("B",&B_list[0],1,dofs,3,(void**)nodes)){ 266 B_average=(B_list[0]+B_list[1]+B_list[2])/3.0; 267 matice->SetB(B_average); 268 } 269 270 } 271 /*}}}*/ 272 /*FUNCTION UpdateFromDakota {{{1*/ 273 void Tria::UpdateFromDakota(void* vinputs){ 274 275 int i; 276 int dofs[1]={0}; 277 double temperature_list[3]; 278 double temperature_average; 279 double B_list[3]; 280 double B_average; 281 double new_h[3]; 282 283 /*dynamic objects pointed to by hooks: */ 284 Node** nodes=NULL; 285 Matpar* matpar=NULL; 286 Matice* matice=NULL; 287 Numpar* numpar=NULL; 288 289 ParameterInputs* inputs=NULL; 290 291 /*recover pointers: */ 292 inputs=(ParameterInputs*)vinputs; 293 294 /*recover objects from hooks: */ 295 nodes=(Node**)hnodes.deliverp(); 296 matpar=(Matpar*)hmatpar.delivers(); 297 matice=(Matice*)hmatice.delivers(); 298 numpar=(Numpar*)hnumpar.delivers(); 299 300 /*Update internal data if inputs holds new values: */ 301 inputs->Recover("thickness",&this->properties.h[0],1,dofs,3,(void**)nodes); 302 if(inputs->Recover("thickness",&new_h[0],1,dofs,3,(void**)nodes)){ 303 //density, needed later: 304 double di=(this->matpar->GetRhoIce()/this->matpar->GetRhoWater()); 305 //Go through grids: 306 for (i=0;i<3;i++){ 307 if(nodes[i]->IsOnShelf()){ 308 this->b[i]=this->b[i]-di*(new_h[i]-h[i]); //hydrostatic equilibrium; 309 } 310 this->s[i]=this->b[i]+new_h[i]; 311 this->h[i]=new_h[i]; 312 } 313 } 314 315 ISSMERROR("not supported yet!"); 195 316 196 317 } … … 232 353 /*plug local pressure values into global pressure vector: */ 233 354 VecSetValues(pg,numgrids,doflist,(const double*)pressure,INSERT_VALUES); 234 235 }236 /*}}}*/237 /*FUNCTION copy {{{1*/238 Object* Tria::copy() {239 240 return new Tria(*this);241 355 242 356 } … … 5206 5320 } 5207 5321 /*}}}*/ 5208 /*FUNCTION UpdateFromInputs {{{1*/5209 void Tria::UpdateFromInputs(void* vinputs){5210 5211 int i;5212 int dofs[1]={0};5213 double temperature_list[3];5214 double temperature_average;5215 double B_list[3];5216 double B_average;5217 double new_h[3];5218 5219 /*dynamic objects pointed to by hooks: */5220 Node** nodes=NULL;5221 Matpar* matpar=NULL;5222 Matice* matice=NULL;5223 Numpar* numpar=NULL;5224 5225 ParameterInputs* inputs=NULL;5226 5227 /*recover pointers: */5228 inputs=(ParameterInputs*)vinputs;5229 5230 /*recover objects from hooks: */5231 nodes=(Node**)hnodes.deliverp();5232 matpar=(Matpar*)hmatpar.delivers();5233 matice=(Matice*)hmatice.delivers();5234 numpar=(Numpar*)hnumpar.delivers();5235 5236 /*Update internal data if inputs holds new values: */5237 //if (id==1) printf("WARNING if QMU: no hydrostatic equilibrium is applied here (conflict with prognostic, which does not have matpar)\n");5238 //For now5239 inputs->Recover("thickness",&this->properties.h[0],1,dofs,3,(void**)nodes);5240 //Later5241 /*5242 if(inputs->Recover("thickness",&new_h[0],1,dofs,3,(void**)nodes)){5243 //density, needed later:5244 double di=(this->matpar->GetRhoIce()/this->matpar->GetRhoWater());5245 //Go through grids:5246 for (i=0;i<3;i++){5247 if(nodes[i]->IsOnShelf()){5248 this->b[i]=this->b[i]-di*(new_h[i]-h[i]); //hydrostatic equilibrium;5249 }5250 this->s[i]=this->b[i]+new_h[i];5251 this->h[i]=new_h[i];5252 }5253 }5254 */5255 inputs->Recover("surface",&this->properties.s[0],1,dofs,3,(void**)nodes);5256 inputs->Recover("bed",&this->properties.b[0],1,dofs,3,(void**)nodes);5257 inputs->Recover("drag",&this->properties.k[0],1,dofs,3,(void**)nodes);5258 inputs->Recover("melting",&this->properties.melting[0],1,dofs,3,(void**)nodes);5259 inputs->Recover("accumulation",&this->properties.accumulation[0],1,dofs,3,(void**)nodes);5260 inputs->Recover("geothermalflux",&this->properties.geothermalflux[0],1,dofs,3,(void**)nodes);5261 5262 //Update material if necessary5263 if(inputs->Recover("temperature_average",&temperature_list[0],1,dofs,3,(void**)nodes)){5264 temperature_average=(temperature_list[0]+temperature_list[1]+temperature_list[2])/3.0;5265 B_average=Paterson(temperature_average);5266 matice->SetB(B_average);5267 }5268 5269 if(inputs->Recover("B",&B_list[0],1,dofs,3,(void**)nodes)){5270 B_average=(B_list[0]+B_list[1]+B_list[2])/3.0;5271 matice->SetB(B_average);5272 }5273 5274 }5275 /*}}}*/ -
issm/trunk/src/c/objects/Tria.h
r3383 r3388 45 45 /*}}}*/ 46 46 /*FUNCTION object management {{{1*/ 47 void Configure(void* loads,void* nodes,void* materials,void* parameters); 48 Object* copy(); 49 void DeepEcho(); 50 void Demarshall(char** pmarshalled_dataset); 47 51 void Echo(); 48 void DeepEcho(); 52 int Enum(); 53 int GetId(); 54 char* GetName(); 49 55 void Marshall(char** pmarshalled_dataset); 50 56 int MarshallSize(); 51 char* GetName();52 void Demarshall(char** pmarshalled_dataset);53 int Enum();54 int GetId();55 57 int MyRank(); 56 /*}}}*/ 58 void UpdateFromDakota(void* inputs); 59 void UpdateFromInputs(void* inputs); 60 /*}}}*/ 57 61 /*FUNCTION element numerical routines {{{1*/ 58 void Configure(void* loads,void* nodes,void* materials,void* parameters);59 62 void CreateKMatrix(Mat Kgg,void* inputs,int analysis_type,int sub_analysis_type); 60 63 void CreatePVector(Vec pg, void* inputs, int analysis_type,int sub_analysis_type); 61 void UpdateFromInputs(void* inputs); 62 void GetDofList(int* doflist,int* pnumberofdofs); 64 void GetDofList(int* doflist,int* pnumberofdofs); 63 65 void GetDofList1(int* doflist); 64 66 void CreateKMatrixDiagnosticHoriz(Mat Kgg,void* inputs,int analysis_type,int sub_analysis_type); … … 101 103 void GetThicknessList(double* thickness_list); 102 104 void GetBedList(double* bed_list); 103 Object* copy();104 105 void NodeConfiguration(int* tria_node_ids,Node* tria_nodes[3],int* tria_node_offsets); 105 106 void MaticeConfiguration(Matice* matice,int matice_offset);
Note:
See TracChangeset
for help on using the changeset viewer.