-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathchef_phasta_loop_stream_ur.cc
More file actions
81 lines (77 loc) · 2.08 KB
/
Copy pathchef_phasta_loop_stream_ur.cc
File metadata and controls
81 lines (77 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <PCU.h>
#include <chef.h>
#include <phasta.h>
#include <phstream.h>
#include <iostream>
#include <sstream>
#include <stdlib.h>
#include "chefPhasta.h"
/** \file chef_phasta_loop_stream_ur.cc
\brief Example in-memory driver for adaptive loops
\remark Runs Chef and then PHASTA until the user-specified maximum
PHASTA time step is reached. When Chef is ran on the output
of PHASTA step four uniform mesh refinement is applied.
*/
namespace {
void freeMesh(apf::Mesh* m) {
m->destroyNative();
apf::destroyMesh(m);
}
}
void setupChef(ph::Input& ctrl, int step) {
//don't split or tetrahedronize
ctrl.splitFactor = 1;
ctrl.tetrahedronize = 0;
ctrl.timeStepNumber = step;
ctrl.solutionMigration = 1;
if(!PCU_Comm_Self()) {
fprintf(stderr, "CAKE enabling UR at step %d\n", step);
fprintf(stderr, "CAKE ctrl.attributeFileName %s step %d\n",
ctrl.attributeFileName.c_str(), step);
}
if(4==step) {
ctrl.adaptStrategy = 7; //UR
ctrl.adaptFlag = 1;
} else {
ctrl.adaptFlag = 0;
}
std::stringstream meshname;
meshname << "bz2:t" << step << "p" << PCU_Comm_Peers() << "/";
ctrl.outMeshFileName = meshname.str();
}
int main(int argc, char** argv) {
MPI_Init(&argc, &argv);
PCU_Comm_Init();
PCU_Protect();
if( argc != 2 ) {
if(!PCU_Comm_Self())
fprintf(stderr, "Usage: %s <maxTimeStep>\n",argv[0]);
exit(EXIT_FAILURE);
}
int maxStep = atoi(argv[1]);
chefPhasta::initModelers();
gmi_model* g = 0;
apf::Mesh2* m = 0;
grstream grs = makeGRStream();
ph::Input ctrl;
ctrl.load("adapt.inp");
chef::cook(g,m,ctrl,grs);
rstream rs = makeRStream();
phSolver::Input inp("solver.inp", "input.config");
int step = 0;
do {
step = phasta(inp,grs,rs);
clearGRStream(grs);
if(!PCU_Comm_Self())
fprintf(stderr, "CAKE ran to step %d\n", step);
setupChef(ctrl,step);
chef::cook(g,m,ctrl,rs,grs);
clearRStream(rs);
} while( step < maxStep );
destroyGRStream(grs);
destroyRStream(rs);
freeMesh(m);
chefPhasta::finalizeModelers();
PCU_Comm_Free();
MPI_Finalize();
}