forked from precice/openfoam-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Interface.H
113 lines (84 loc) · 3.18 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
110
111
112
113
#ifndef INTERFACE_H
#define INTERFACE_H
#include <string>
#include <vector>
#include "fvCFD.H"
#include "CouplingDataUser.H"
#include <precice/precice.hpp>
#include "pointPatchField.H"
namespace preciceAdapter
{
class Interface
{
protected:
//- preCICE solver interface
precice::Participant& precice_;
//- Mesh name used in the preCICE configuration
std::string meshName_;
//- Point locations type (faceCenters vs faceNodes)
LocationType locationType_ {LocationType::none};
//- 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_;
//- Names of the OpenFOAM cell sets to be coupled (for volume coupling)
std::vector<std::string> cellSetNames_;
//- Number of data points (cell centers) on the interface
int numDataLocations_ = 0;
//- Vertex IDs assigned by preCICE
std::vector<int> vertexIDs_;
//- Buffer for the coupling data
std::vector<double> dataBuffer_;
//- Vector of CouplingDataReaders
std::vector<CouplingDataUser*> couplingDataReaders_;
//- Vector of CouplingDataWriters
std::vector<CouplingDataUser*> couplingDataWriters_;
//Switch for faceTriangulation (nearest projection)
bool meshConnectivity_;
//- Reset the displacement during interface definition
bool restartFromDeformed_;
// 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,
const std::string& namePointDisplacement,
const std::string& nameCellDisplacement);
public:
//- Constructor
Interface(
precice::Participant& precice,
const Foam::fvMesh& mesh,
std::string meshName,
std::string locationsType,
std::vector<std::string> patchNames,
std::vector<std::string> cellSetNames,
bool meshConnectivity,
bool restartFromDeformed,
const std::string& namePointDisplacement,
const std::string& nameCellDisplacement);
//- 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(double relativeReadTime);
//- Call write() on each registered couplingDataWriter to extract the boundary
// data and write them into the buffer
void writeCouplingData();
//- Destructor
~Interface();
};
}
#endif