1 | /*!\file: ProcessResults.cpp
|
---|
2 | * \brief: go through results dataset, and for each result, process it for easier retrieval
|
---|
3 | * by the Matlab side. This usually means splitting the velocities from the g-size nodeset
|
---|
4 | * to the grid set (ug->vx,vy,vz), same for pressure (p_g->pressure), etc ... It also implies
|
---|
5 | * departitioning of the results.
|
---|
6 | * This phase is necessary prior to outputting the results on disk.
|
---|
7 | */
|
---|
8 |
|
---|
9 | #ifdef HAVE_CONFIG_H
|
---|
10 | #include "config.h"
|
---|
11 | #else
|
---|
12 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
13 | #endif
|
---|
14 |
|
---|
15 | #include "../DataSet/DataSet.h"
|
---|
16 | #include "../objects/objects.h"
|
---|
17 | #include "../EnumDefinitions/EnumDefinitions.h"
|
---|
18 | #include "../shared/shared.h"
|
---|
19 |
|
---|
20 | void ProcessResults(DataSet** pnewresults, DataSet* results,Model* model,int analysis_type){
|
---|
21 |
|
---|
22 | int i,n;
|
---|
23 | Result* result=NULL;
|
---|
24 | Result* newresult=NULL;
|
---|
25 |
|
---|
26 | /*output: */
|
---|
27 | DataSet* newresults=NULL;
|
---|
28 |
|
---|
29 | /*fem diagnostic models: */
|
---|
30 | FemModel* fem_dh=NULL;
|
---|
31 | FemModel* fem_dv=NULL;
|
---|
32 | FemModel* fem_dhu=NULL;
|
---|
33 | FemModel* fem_ds=NULL;
|
---|
34 | FemModel* fem_sl=NULL;
|
---|
35 |
|
---|
36 | /*fem thermal models: */
|
---|
37 | FemModel* fem_t=NULL;
|
---|
38 |
|
---|
39 | /*fem prognostic models: */
|
---|
40 | FemModel* fem_p=NULL;
|
---|
41 |
|
---|
42 | /*fem control models: */
|
---|
43 | FemModel* fem_c=NULL;
|
---|
44 |
|
---|
45 | /*some parameters*/
|
---|
46 | int ishutter;
|
---|
47 | int ismacayealpattyn;
|
---|
48 | int isstokes;
|
---|
49 | int dim;
|
---|
50 |
|
---|
51 | /*intermediary: */
|
---|
52 | Vec u_g=NULL;
|
---|
53 | double* u_g_serial=NULL;
|
---|
54 | double* vx=NULL;
|
---|
55 | double* vy=NULL;
|
---|
56 | double* vz=NULL;
|
---|
57 | double* vel=NULL;
|
---|
58 | Vec p_g=NULL;
|
---|
59 | double* p_g_serial=NULL;
|
---|
60 | double* pressure=NULL;
|
---|
61 | double* partition=NULL;
|
---|
62 | double yts;
|
---|
63 |
|
---|
64 | double* param_g=NULL;
|
---|
65 | double* parameter=NULL;
|
---|
66 | Vec riftproperties=NULL;
|
---|
67 | double* riftproperties_serial=NULL;
|
---|
68 | int numrifts=0;
|
---|
69 |
|
---|
70 | Vec s_g=NULL;
|
---|
71 | double* s_g_serial=NULL;
|
---|
72 | double* surface=NULL;
|
---|
73 |
|
---|
74 | Vec sx_g=NULL;
|
---|
75 | double* sx_g_serial=NULL;
|
---|
76 | double* slopex=NULL;
|
---|
77 |
|
---|
78 | Vec sy_g=NULL;
|
---|
79 | double* sy_g_serial=NULL;
|
---|
80 | double* slopey=NULL;
|
---|
81 |
|
---|
82 | Vec b_g=NULL;
|
---|
83 | double* b_g_serial=NULL;
|
---|
84 | double* bed=NULL;
|
---|
85 |
|
---|
86 | Vec h_g=NULL;
|
---|
87 | double* h_g_serial=NULL;
|
---|
88 | double* thickness=NULL;
|
---|
89 |
|
---|
90 | Vec t_g=NULL;
|
---|
91 | double* t_g_serial=NULL;
|
---|
92 | double* temperature=NULL;
|
---|
93 |
|
---|
94 | Vec m_g=NULL;
|
---|
95 | double* m_g_serial=NULL;
|
---|
96 | double* melting=NULL;
|
---|
97 |
|
---|
98 | Vec grad_g=NULL;
|
---|
99 | double* grad_g_serial=NULL;
|
---|
100 | double* gradient=NULL;
|
---|
101 |
|
---|
102 | Vec v_g=NULL;
|
---|
103 | double* v_g_serial=NULL;
|
---|
104 |
|
---|
105 | int numberofnodes;
|
---|
106 |
|
---|
107 | /*Initialize new results: */
|
---|
108 | newresults=new DataSet(ResultsEnum());
|
---|
109 |
|
---|
110 | /*some flags needed: */
|
---|
111 | model->FindParam(&dim,"dim");
|
---|
112 | model->FindParam(&ishutter,"ishutter");
|
---|
113 | model->FindParam(&isstokes,"isstokes");
|
---|
114 | model->FindParam(&ismacayealpattyn,"ismacayealpattyn");
|
---|
115 |
|
---|
116 | /*Recover femmodels first: */
|
---|
117 | fem_dh=model->GetFormulation(DiagnosticAnalysisEnum(),HorizAnalysisEnum());
|
---|
118 | fem_c=fem_dh;
|
---|
119 | fem_dv=model->GetFormulation(DiagnosticAnalysisEnum(),VertAnalysisEnum());
|
---|
120 | fem_ds=model->GetFormulation(DiagnosticAnalysisEnum(),StokesAnalysisEnum());
|
---|
121 | fem_dhu=model->GetFormulation(DiagnosticAnalysisEnum(),HutterAnalysisEnum());
|
---|
122 | fem_sl=model->GetFormulation(SlopecomputeAnalysisEnum());
|
---|
123 | if(analysis_type==PrognosticAnalysisEnum()){
|
---|
124 | fem_p=model->GetFormulation(PrognosticAnalysisEnum());
|
---|
125 | }
|
---|
126 | if(analysis_type==Prognostic2AnalysisEnum()){
|
---|
127 | fem_p=model->GetFormulation(Prognostic2AnalysisEnum());
|
---|
128 | }
|
---|
129 | if(analysis_type==TransientAnalysisEnum()){
|
---|
130 | fem_p=model->GetFormulation(PrognosticAnalysisEnum());
|
---|
131 | }
|
---|
132 | if(analysis_type==BalancedthicknessAnalysisEnum()){
|
---|
133 | fem_p=model->GetFormulation(BalancedthicknessAnalysisEnum());
|
---|
134 | }
|
---|
135 | if(analysis_type==BalancedvelocitiesAnalysisEnum()){
|
---|
136 | fem_p=model->GetFormulation(BalancedvelocitiesAnalysisEnum());
|
---|
137 | }
|
---|
138 | fem_t=model->GetFormulation(ThermalAnalysisEnum());
|
---|
139 |
|
---|
140 | for(n=0;n<results->Size();n++){
|
---|
141 | result=(Result*)results->GetObjectByOffset(n);
|
---|
142 |
|
---|
143 | if(strcmp(result->GetFieldName(),"u_g")==0){
|
---|
144 |
|
---|
145 | /*Ok, are we dealing with velocities coming from MacAyeal, Pattyin, Hutter, on 2,3 dofs or
|
---|
146 | *Stokes on 4 dofs: */
|
---|
147 | result->GetField(&u_g);
|
---|
148 | VecToMPISerial(&u_g_serial,u_g);
|
---|
149 |
|
---|
150 | //2d results -> 2 dofs per node
|
---|
151 | if (dim==2){
|
---|
152 | /*ok, 2 dofs, on number of nodes: */
|
---|
153 | if(ismacayealpattyn){
|
---|
154 | fem_dh->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
155 | VecToMPISerial(&partition,fem_dh->partition->vector);
|
---|
156 | fem_dh->parameters->FindParam(&yts,"yts");
|
---|
157 | }
|
---|
158 | else{
|
---|
159 | fem_dhu->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
160 | VecToMPISerial(&partition,fem_dhu->partition->vector);
|
---|
161 | fem_dhu->parameters->FindParam(&yts,"yts");
|
---|
162 | }
|
---|
163 | vx=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
164 | vy=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
165 | vz=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
166 | vel=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
167 |
|
---|
168 | for(i=0;i<numberofnodes;i++){
|
---|
169 | vx[i]=u_g_serial[2*(int)partition[i]+0]*yts;
|
---|
170 | vy[i]=u_g_serial[2*(int)partition[i]+1]*yts;
|
---|
171 | vz[i]=0;
|
---|
172 | vel[i]=sqrt(pow(vx[i],2)+pow(vy[i],2)+pow(vz[i],2));
|
---|
173 | }
|
---|
174 | }
|
---|
175 | //3d results -> 3 or 4 (stokes) dofs per node
|
---|
176 | else{
|
---|
177 | if(!isstokes){
|
---|
178 | /*ok, 3 dofs, on number of nodes: */
|
---|
179 | if(ismacayealpattyn){
|
---|
180 | fem_dh->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
181 | VecToMPISerial(&partition,fem_dh->partition->vector);
|
---|
182 | fem_dh->parameters->FindParam(&yts,"yts");
|
---|
183 | }
|
---|
184 | else{
|
---|
185 | fem_dhu->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
186 | VecToMPISerial(&partition,fem_dhu->partition->vector);
|
---|
187 | fem_dhu->parameters->FindParam(&yts,"yts");
|
---|
188 | }
|
---|
189 | vx=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
190 | vy=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
191 | vz=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
192 | vel=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
193 |
|
---|
194 | for(i=0;i<numberofnodes;i++){
|
---|
195 | vx[i]=u_g_serial[3*(int)partition[i]+0]*yts;
|
---|
196 | vy[i]=u_g_serial[3*(int)partition[i]+1]*yts;
|
---|
197 | vz[i]=u_g_serial[3*(int)partition[i]+2]*yts;
|
---|
198 | vel[i]=sqrt(pow(vx[i],2)+pow(vy[i],2)+pow(vz[i],2));
|
---|
199 | }
|
---|
200 | }
|
---|
201 | else{
|
---|
202 | /* 4 dofs on number of nodes. discard pressure: */
|
---|
203 | fem_ds->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
204 | VecToMPISerial(&partition,fem_ds->partition->vector);
|
---|
205 | fem_ds->parameters->FindParam(&yts,"yts");
|
---|
206 | vx=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
207 | vy=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
208 | vz=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
209 | vel=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
210 | for(i=0;i<numberofnodes;i++){
|
---|
211 | vx[i]=u_g_serial[4*(int)partition[i]+0]*yts;
|
---|
212 | vy[i]=u_g_serial[4*(int)partition[i]+1]*yts;
|
---|
213 | vz[i]=u_g_serial[4*(int)partition[i]+2]*yts;
|
---|
214 | vel[i]=sqrt(pow(vx[i],2)+pow(vy[i],2)+pow(vz[i],2));
|
---|
215 | }
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 | /*Ok, add vx,vy and vz to newresults: */
|
---|
220 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"vx",vx,numberofnodes);
|
---|
221 | newresults->AddObject(newresult);
|
---|
222 |
|
---|
223 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"vy",vy,numberofnodes);
|
---|
224 | newresults->AddObject(newresult);
|
---|
225 |
|
---|
226 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"vz",vz,numberofnodes);
|
---|
227 | newresults->AddObject(newresult);
|
---|
228 |
|
---|
229 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"vel",vel,numberofnodes);
|
---|
230 | newresults->AddObject(newresult);
|
---|
231 |
|
---|
232 | /*do some cleanup: */
|
---|
233 | xfree((void**)&u_g_serial);
|
---|
234 | xfree((void**)&partition);
|
---|
235 | xfree((void**)&vx);
|
---|
236 | xfree((void**)&vy);
|
---|
237 | xfree((void**)&vz);
|
---|
238 | xfree((void**)&vel);
|
---|
239 | VecFree(&u_g);
|
---|
240 | }
|
---|
241 | else if(strcmp(result->GetFieldName(),"p_g")==0){
|
---|
242 | /*easy, p_g is of size numberofnodes, on 1 dof, just repartition: */
|
---|
243 | result->GetField(&p_g);
|
---|
244 | VecToMPISerial(&p_g_serial,p_g);
|
---|
245 |
|
---|
246 | if(!isstokes){
|
---|
247 | if(ismacayealpattyn){
|
---|
248 | fem_dh->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
249 | VecToMPISerial(&partition,fem_dh->partition->vector);
|
---|
250 | }
|
---|
251 | else{
|
---|
252 | fem_dhu->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
253 | VecToMPISerial(&partition,fem_dhu->partition->vector);
|
---|
254 | }
|
---|
255 | }
|
---|
256 | else{
|
---|
257 | fem_ds->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
258 | VecToMPISerial(&partition,fem_ds->partition->vector);
|
---|
259 | }
|
---|
260 |
|
---|
261 | pressure=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
262 |
|
---|
263 | for(i=0;i<numberofnodes;i++){
|
---|
264 | pressure[i]=p_g_serial[(int)partition[i]];
|
---|
265 | }
|
---|
266 |
|
---|
267 | /*Ok, add pressure,vy and vz to newresults: */
|
---|
268 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"pressure",pressure,numberofnodes);
|
---|
269 | newresults->AddObject(newresult);
|
---|
270 |
|
---|
271 | /*do some cleanup: */
|
---|
272 | xfree((void**)&p_g_serial);
|
---|
273 | xfree((void**)&partition);
|
---|
274 | xfree((void**)&pressure);
|
---|
275 | VecFree(&p_g);
|
---|
276 | }
|
---|
277 | else if(strcmp(result->GetFieldName(),"t_g")==0){
|
---|
278 | /*easy, t_g is of size numberofnodes, on 1 dof, just repartition: */
|
---|
279 | result->GetField(&t_g);
|
---|
280 | VecToMPISerial(&t_g_serial,t_g);
|
---|
281 | fem_t->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
282 | VecToMPISerial(&partition,fem_t->partition->vector);
|
---|
283 |
|
---|
284 | temperature=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
285 |
|
---|
286 | for(i=0;i<numberofnodes;i++){
|
---|
287 | temperature[i]=t_g_serial[(int)partition[i]];
|
---|
288 | }
|
---|
289 |
|
---|
290 | /*Ok, add pressure to newresults: */
|
---|
291 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"temperature",temperature,numberofnodes);
|
---|
292 | newresults->AddObject(newresult);
|
---|
293 |
|
---|
294 | /*do some cleanup: */
|
---|
295 | xfree((void**)&t_g_serial);
|
---|
296 | xfree((void**)&partition);
|
---|
297 | xfree((void**)&temperature);
|
---|
298 | VecFree(&t_g);
|
---|
299 | }
|
---|
300 | else if(strcmp(result->GetFieldName(),"grad_g")==0){
|
---|
301 |
|
---|
302 | /*easy, grad_g is of size numberofnodes, on 1 dof, just repartition: */
|
---|
303 | result->GetField(&grad_g);
|
---|
304 | VecToMPISerial(&grad_g_serial,grad_g);
|
---|
305 | fem_c->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
306 | VecToMPISerial(&partition,fem_c->partition->vector);
|
---|
307 |
|
---|
308 | gradient=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
309 |
|
---|
310 | for(i=0;i<numberofnodes;i++){
|
---|
311 | gradient[i]=grad_g_serial[(int)partition[i]];
|
---|
312 | }
|
---|
313 |
|
---|
314 | /*Ok, add gradient to newresults: */
|
---|
315 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"gradient",gradient,numberofnodes);
|
---|
316 | newresults->AddObject(newresult);
|
---|
317 |
|
---|
318 | /*do some cleanup: */
|
---|
319 | xfree((void**)&grad_g_serial);
|
---|
320 | xfree((void**)&partition);
|
---|
321 | xfree((void**)&gradient);
|
---|
322 | VecFree(&grad_g);
|
---|
323 | }
|
---|
324 | else if(strcmp(result->GetFieldName(),"m_g")==0){
|
---|
325 | /*easy, m_g is of size numberofnodes, on 1 dof, just repartition: */
|
---|
326 | result->GetField(&m_g);
|
---|
327 | VecToMPISerial(&m_g_serial,m_g);
|
---|
328 | fem_t->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
329 | fem_t->parameters->FindParam(&yts,"yts");
|
---|
330 | VecToMPISerial(&partition,fem_t->partition->vector);
|
---|
331 |
|
---|
332 | melting=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
333 |
|
---|
334 | for(i=0;i<numberofnodes;i++){
|
---|
335 | melting[i]=m_g_serial[(int)partition[i]]*yts;
|
---|
336 | }
|
---|
337 |
|
---|
338 | /*Ok, add pressure to newresults: */
|
---|
339 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"melting",melting,numberofnodes);
|
---|
340 | newresults->AddObject(newresult);
|
---|
341 |
|
---|
342 | /*do some cleanup: */
|
---|
343 | xfree((void**)&m_g_serial);
|
---|
344 | xfree((void**)&partition);
|
---|
345 | xfree((void**)&melting);
|
---|
346 | VecFree(&m_g);
|
---|
347 | }
|
---|
348 | else if(strcmp(result->GetFieldName(),"h_g")==0){
|
---|
349 | /*easy, h_g is of size numberofnodes, on 1 dof, just repartition: */
|
---|
350 | result->GetField(&h_g);
|
---|
351 | VecToMPISerial(&h_g_serial,h_g);
|
---|
352 | fem_p->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
353 | VecToMPISerial(&partition,fem_p->partition->vector);
|
---|
354 |
|
---|
355 | thickness=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
356 |
|
---|
357 | for(i=0;i<numberofnodes;i++){
|
---|
358 | thickness[i]=h_g_serial[(int)partition[i]];
|
---|
359 | }
|
---|
360 |
|
---|
361 | /*Ok, add pressure to newresults: */
|
---|
362 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"thickness",thickness,numberofnodes);
|
---|
363 | newresults->AddObject(newresult);
|
---|
364 |
|
---|
365 | /*do some cleanup: */
|
---|
366 | xfree((void**)&h_g_serial);
|
---|
367 | xfree((void**)&thickness);
|
---|
368 | xfree((void**)&partition);
|
---|
369 | VecFree(&h_g);
|
---|
370 | }
|
---|
371 | else if(strcmp(result->GetFieldName(),"v_g")==0){
|
---|
372 | /*easy, v_g is of size numberofnodes, on 1 dof, just repartition: */
|
---|
373 | result->GetField(&v_g);
|
---|
374 | VecToMPISerial(&v_g_serial,v_g);
|
---|
375 | fem_p->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
376 | VecToMPISerial(&partition,fem_p->partition->vector);
|
---|
377 |
|
---|
378 | vel=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
379 |
|
---|
380 | for(i=0;i<numberofnodes;i++){
|
---|
381 | vel[i]=v_g_serial[(int)partition[i]];
|
---|
382 | }
|
---|
383 |
|
---|
384 | /*Ok, add pressure to newresults: */
|
---|
385 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"vel",vel,numberofnodes);
|
---|
386 | newresults->AddObject(newresult);
|
---|
387 |
|
---|
388 | /*do some cleanup: */
|
---|
389 | xfree((void**)&v_g_serial);
|
---|
390 | xfree((void**)&vel);
|
---|
391 | xfree((void**)&partition);
|
---|
392 | VecFree(&v_g);
|
---|
393 | }
|
---|
394 | else if(strcmp(result->GetFieldName(),"s_g")==0){
|
---|
395 | /*easy, s_g is of size numberofnodes, on 1 dof, just repartition: */
|
---|
396 | result->GetField(&s_g);
|
---|
397 | VecToMPISerial(&s_g_serial,s_g);
|
---|
398 | fem_p->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
399 | VecToMPISerial(&partition,fem_p->partition->vector);
|
---|
400 |
|
---|
401 | surface=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
402 |
|
---|
403 | for(i=0;i<numberofnodes;i++){
|
---|
404 | surface[i]=s_g_serial[(int)partition[i]];
|
---|
405 | }
|
---|
406 |
|
---|
407 | /*Ok, add pressure to newresults: */
|
---|
408 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"surface",surface,numberofnodes);
|
---|
409 | newresults->AddObject(newresult);
|
---|
410 |
|
---|
411 | /*do some cleanup: */
|
---|
412 | xfree((void**)&s_g_serial);
|
---|
413 | xfree((void**)&partition);
|
---|
414 | xfree((void**)&surface);
|
---|
415 | VecFree(&s_g);
|
---|
416 | }
|
---|
417 | else if(strcmp(result->GetFieldName(),"sx_g")==0){
|
---|
418 | /*easy, s_g is of size numberofnodes, on 1 dof, just repartition: */
|
---|
419 | result->GetField(&sx_g);
|
---|
420 | VecToMPISerial(&sx_g_serial,sx_g);
|
---|
421 | fem_sl->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
422 | VecToMPISerial(&partition,fem_sl->partition->vector);
|
---|
423 |
|
---|
424 | slopex=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
425 |
|
---|
426 | for(i=0;i<numberofnodes;i++){
|
---|
427 | slopex[i]=sx_g_serial[(int)partition[i]];
|
---|
428 | }
|
---|
429 |
|
---|
430 | /*Ok, add pressure to newresults: */
|
---|
431 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"slopex",slopex,numberofnodes);
|
---|
432 | newresults->AddObject(newresult);
|
---|
433 |
|
---|
434 | /*do some cleanup: */
|
---|
435 | xfree((void**)&sx_g_serial);
|
---|
436 | xfree((void**)&partition);
|
---|
437 | xfree((void**)&slopex);
|
---|
438 | VecFree(&sx_g);
|
---|
439 | }
|
---|
440 | else if(strcmp(result->GetFieldName(),"sy_g")==0){
|
---|
441 | /*easy, s_g is of size numberofnodes, on 1 dof, just repartition: */
|
---|
442 | result->GetField(&sy_g);
|
---|
443 | VecToMPISerial(&sy_g_serial,sy_g);
|
---|
444 | fem_sl->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
445 | VecToMPISerial(&partition,fem_sl->partition->vector);
|
---|
446 |
|
---|
447 | slopey=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
448 |
|
---|
449 | for(i=0;i<numberofnodes;i++){
|
---|
450 | slopey[i]=sy_g_serial[(int)partition[i]];
|
---|
451 | }
|
---|
452 |
|
---|
453 | /*Ok, add pressure to newresults: */
|
---|
454 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"slopey",slopey,numberofnodes);
|
---|
455 | newresults->AddObject(newresult);
|
---|
456 |
|
---|
457 | /*do some cleanup: */
|
---|
458 | xfree((void**)&sy_g_serial);
|
---|
459 | xfree((void**)&partition);
|
---|
460 | xfree((void**)&slopey);
|
---|
461 | VecFree(&sy_g);
|
---|
462 | }
|
---|
463 | else if(strcmp(result->GetFieldName(),"b_g")==0){
|
---|
464 | /*easy, b_g is of size numberofnodes, on 1 dof, just repartition: */
|
---|
465 | result->GetField(&b_g);
|
---|
466 | VecToMPISerial(&b_g_serial,b_g);
|
---|
467 | fem_p->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
468 | VecToMPISerial(&partition,fem_p->partition->vector);
|
---|
469 |
|
---|
470 | bed=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
471 |
|
---|
472 | for(i=0;i<numberofnodes;i++){
|
---|
473 | bed[i]=b_g_serial[(int)partition[i]];
|
---|
474 | }
|
---|
475 |
|
---|
476 | /*Ok, add pressure to newresults: */
|
---|
477 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"bed",bed,numberofnodes);
|
---|
478 | newresults->AddObject(newresult);
|
---|
479 |
|
---|
480 | /*do some cleanup: */
|
---|
481 | xfree((void**)&b_g_serial);
|
---|
482 | xfree((void**)&partition);
|
---|
483 | xfree((void**)&bed);
|
---|
484 | VecFree(&b_g);
|
---|
485 | }
|
---|
486 | else if(strcmp(result->GetFieldName(),"param_g")==0){
|
---|
487 | /*easy, param_g is of size numberofnodes, on 1 dof, just repartition: */
|
---|
488 | result->GetField(¶m_g);
|
---|
489 | fem_dh->parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
490 | VecToMPISerial(&partition,fem_dh->partition->vector);
|
---|
491 |
|
---|
492 | parameter=(double*)xmalloc(numberofnodes*sizeof(double));
|
---|
493 |
|
---|
494 | for(i=0;i<numberofnodes;i++){
|
---|
495 | parameter[i]=param_g[(int)partition[i]];
|
---|
496 | }
|
---|
497 |
|
---|
498 | /*Ok, add parameter to newresults: */
|
---|
499 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"parameter",parameter,numberofnodes);
|
---|
500 | newresults->AddObject(newresult);
|
---|
501 |
|
---|
502 | /*do some cleanup: */
|
---|
503 | xfree((void**)&partition);
|
---|
504 | xfree((void**)¶m_g);
|
---|
505 | xfree((void**)¶meter);
|
---|
506 | }
|
---|
507 | else if(strcmp(result->GetFieldName(),"riftproperties")==0){
|
---|
508 | result->GetField(&riftproperties);
|
---|
509 | fem_dh->parameters->FindParam(&numrifts,"numrifts");
|
---|
510 | VecToMPISerial(&riftproperties_serial,riftproperties);
|
---|
511 |
|
---|
512 | /*Ok, add parameter to newresults: */
|
---|
513 | newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"riftproperties",riftproperties_serial,numrifts);
|
---|
514 | newresults->AddObject(newresult);
|
---|
515 | xfree((void**)&riftproperties);
|
---|
516 |
|
---|
517 | }
|
---|
518 | else{
|
---|
519 | /*Just copy the result into the new results dataset: */
|
---|
520 | newresults->AddObject(result->copy());
|
---|
521 | }
|
---|
522 | }
|
---|
523 |
|
---|
524 | /*Assign output pointers:*/
|
---|
525 | *pnewresults=newresults;
|
---|
526 | }
|
---|