-
Notifications
You must be signed in to change notification settings - Fork 0
/
Interface.H
109 lines (79 loc) · 2.63 KB
/
Interface.H
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef INTERFACE_H
#define INTERFACE_H
#include <string>
#include <vector>
#include "fvCFD.H"
#include "CouplingDataUser.H"
#include "precice/SolverInterface.hpp"
namespace preciceAdapter
{
class Interface
{
protected:
//- preCICE solver interface
precice::SolverInterface & precice_;
//- Mesh name used in the preCICE configuration
std::string meshName_;
//- Point locations type (faceCenters vs faceNodes)
std::string locationsType_;
//- Mesh ID assigned by preCICE to the interface
int meshID_;
//- Names of the OpenFOAM patches that form the interface
std::vector<std::string> patchNames_;
//- OpenFOAM patches that form the interface
std::vector<int> patchIDs_;
//- Number of data points (cell centers) on the interface
int numDataLocations_ = 0;
//- Vertex IDs assigned by preCICE
int * vertexIDs_;
//- Buffer for the coupling data
double * dataBuffer_;
//- Vector of CouplingDataReaders
std::vector<CouplingDataUser*> couplingDataReaders_;
//- Vector of CouplingDataWriters
std::vector<CouplingDataUser*> couplingDataWriters_;
//Switch for faceTriangulation (nearest projection)
bool meshConnectivity_;
// Simulation dimension
unsigned int dim_;
//- Extracts the locations of the face centers or face nodes
// and exposes them to preCICE with setMeshVertices
void configureMesh(const Foam::fvMesh& mesh);
public:
//- Constructor
Interface
(
precice::SolverInterface & precice,
const Foam::fvMesh& mesh,
std::string meshName,
std::string locationsType,
std::vector<std::string> patchNames,
bool meshConnectivity
);
//- Add a CouplingDataUser to read data from the interface
void addCouplingDataReader
(
std::string dataName,
CouplingDataUser * couplingDataReader
);
//- Add a CouplingDataUser to write data on the interface
void addCouplingDataWriter
(
std::string dataName,
CouplingDataUser * couplingDataWriter
);
//- Allocate an appropriate buffer for scalar or vector data.
// If at least one couplingDataUser has vector data, then
// define a buffer for 3D data. Otherwise, for 1D data.
void createBuffer();
//- Call read() on each registered couplingDataReader to read the coupling
// data from the buffer and apply the boundary conditions
void readCouplingData();
//- Call write() on each registered couplingDataWriter to extract the boundary
// data and write them into the buffer
void writeCouplingData();
//- Destructor
~Interface();
};
}
#endif