@@ -23,88 +23,84 @@ Please add breaking changes here when merged to the `develop` branch.
23
23
24
24
turnOnSolver(); //e.g. setup and partition mesh
25
25
26
- - precice::SolverInterface interface ("FluidSolver","precice-config.xml",rank,size); // constructor
27
- + precice::Participant participant("FluidSolver","precice-config.xml",rank,size); // constructor
26
+ - precice::SolverInterface participant ("FluidSolver","precice-config.xml",rank,size); // constructor
27
+ + precice::Participant participant("FluidSolver","precice-config.xml",rank,size); // constructor
28
28
29
29
- const std::string& coric = precice::constants::actionReadIterationCheckpoint();
30
30
- const std::string& cowic = precice::constants::actionWriteIterationCheckpoint();
31
31
- const std::string& cowid = precice::constants::actionWriteInitialData();
32
32
33
- - int dim = interface .getDimension();
33
+ - int dim = participant .getDimension();
34
34
+ int dim = participant.getMeshDimensions("FluidMesh");
35
35
- int meshID = precice.getMeshID("FluidMesh");
36
+
36
37
int vertexSize; // number of vertices at wet surface
37
-
38
- // determine vertexSize
39
- - double* coords = new double[vertexSize*dim]; // coords of vertices at wet surface
40
- + std::vector<double> coords(vertexSize*dim); // coords of vertices at wet surface
41
-
38
+ // determine vertex count
39
+
40
+ std::vector<double> coords(vertexSize*dim); // coords of vertices at wet surface
42
41
// determine coordinates
43
- - int* vertexIDs = new int[vertexSize];
44
- - precice.setMeshVertices(meshID, vertexSize, coords, vertexIDs);
45
- - delete[] coords;
46
- + std::vector<int> vertexIDs(vertexSize);
42
+
43
+ std::vector<int> vertexIDs(vertexSize);
44
+ - precice.setMeshVertices(meshID, vertexSize, coords.data(), vertexIDs.data());
47
45
+ precice.setMeshVertices("FluidMesh", coords, vertexIDs);
48
46
49
47
- int displID = precice.getDataID("Displacements", meshID);
50
48
- int forceID = precice.getDataID("Forces", meshID);
51
-
52
- std::vector<double> forces(vertexSize*dim);
53
- std::vector<double> displacements(vertexSize*dim);
49
+ - std::vector<double> forces(vertexSize*dim);
50
+ - std::vector<double> displacements(vertexSize*dim);
51
+ + const double forceDim = participant.getDataDimensions("FluidMesh", "Forces")
52
+ + const double displDim = participant.getDataDimensions("FluidMesh", "Displacements")
53
+ + std::vector<double> forces(vertexSize*forceDimn);
54
+ + std::vector<double> displacements(vertexSize*displDim);
54
55
55
56
double solverDt; // solver timestep size
56
57
double preciceDt; // maximum precice timestep size
57
58
double dt; // actual time step size
58
59
59
- - preciceDt = interface.initialize();
60
-
61
- - if(interface.isActionRequired(cowid)){
62
- - interface.writeBlockVectorData(forceID, vertexSize, vertexIDs, forces.data());
63
- - interface.markActionFulfilled(cowid);
60
+ - preciceDt = participant.initialize();
61
+ - if (participant.isActionRequired(cowid)) {
62
+ - participant.writeBlockVectorData(forceID, vertexSize, vertexIDs.data(), forces.data());
63
+ - participant.markActionFulfilled(cowid);
64
64
- }
65
- + if(participant.requiresInitialData()){
65
+ - participant.initializeData();
66
+ + if (participant.requiresInitialData()) {
66
67
+ participant.writeData("FluidMesh", "Forces", vertexIDs, forces);
67
68
+ }
68
-
69
- - interface.initializeData();
70
69
+ participant.initialize();
71
70
72
- - while (interface.isCouplingOngoing()){
73
- - if(interface.isActionRequired(cowic)){
74
- + while (participant.isCouplingOngoing()){
71
+ while (participant.isCouplingOngoing()){
72
+ - if(participant.isActionRequired(cowic)){
75
73
+ if(participant.requiresWritingCheckpoint()){
76
74
saveOldState(); // save checkpoint
77
- - interface .markActionFulfilled(cowic);
75
+ - participant .markActionFulfilled(cowic);
78
76
}
79
77
80
78
+ preciceDt = participant.getMaxTimeStepSize();
81
79
solverDt = beginTimeStep(); // e.g. compute adaptive dt
82
80
dt = min(preciceDt, solverDt);
83
81
84
- - interface .readBlockVectorData(displID, vertexSize, vertexIDs, displacements.data());
82
+ - participant .readBlockVectorData(displID, vertexSize, vertexIDs.data() , displacements.data());
85
83
+ participant.readData("FluidMesh", "Displacements", vertexIDs, dt, displacements);
86
84
setDisplacements(displacements);
87
85
solveTimeStep(dt);
88
86
computeForces(forces);
89
- - interface .writeBlockVectorData(forceID, vertexSize, vertexIDs, forces.data());
87
+ - participant .writeBlockVectorData(forceID, vertexSize, vertexIDs.data() , forces.data());
90
88
+ participant.writeData("FluidMesh", "Forces", vertexIDs, forces);
91
89
92
- - preciceDt = interface .advance(dt);
90
+ - preciceDt = participant .advance(dt);
93
91
+ participant.advance(dt);
94
92
95
- - if(interface .isActionRequired(coric)){ // timestep not converged
96
- + if(participant.requiresReadingCheckpoint()){
93
+ - if (participant .isActionRequired(coric)) { // timestep not converged
94
+ + if (participant.requiresReadingCheckpoint()) {
97
95
reloadOldState(); // set variables back to checkpoint
98
- - interface .markActionFulfilled(coric);
96
+ - participant .markActionFulfilled(coric);
99
97
}
100
- else{ // timestep converged
98
+ else { // timestep converged
101
99
endTimeStep(); // e.g. update variables, increment time
102
100
}
103
101
}
104
- - interface.finalize(); // frees data structures and closes communication channels
105
- + participant.finalize(); // frees data structures and closes communication channels
102
+ participant.finalize(); // frees data structures and closes communication channels
106
103
107
- - delete[] vertexIDs, forces, displacements;
108
104
turnOffSolver();
109
105
```
110
106
0 commit comments