17 #include <precice/SolverInterface.hpp>
31 m_interface(
"participantName",
"configurationFileName", 0, 1)
45 gsPreCICE(std::string participantName, std::string configurationFileName)
47 m_interface(participantName, configurationFileName, 0, 1)
52 bool isCouplingOngoing()
const {
return m_interface.isCouplingOngoing(); }
54 bool isReadDataAvailable()
const {
return m_interface.isReadDataAvailable(); }
56 bool isWriteDataRequired(real_t computedTimestepLength)
const {
return m_interface.isWriteDataRequired(computedTimestepLength); }
58 bool isTimeWindowComplete()
const {
return m_interface.isTimeWindowComplete(); }
60 bool isActionRequired(
const std::string &action)
const {
return m_interface.isActionRequired(action); }
62 void markActionFulfilled(
const std::string &action) { m_interface.markActionFulfilled(action); }
66 const std::string actionWriteInitialData() {
return precice::constants::actionWriteInitialData(); }
68 const std::string actionWriteIterationCheckpoint() {
return precice::constants::actionWriteIterationCheckpoint(); }
70 const std::string actionReadIterationCheckpoint() {
return precice::constants::actionReadIterationCheckpoint(); }
82 m_precicedt = m_interface.initialize();
93 void addMesh(
const std::string & meshName,
const gsMatrix<T> & points)
95 m_meshNames.push_back(meshName);
96 m_meshIDs.push_back(m_interface.getMeshID(m_meshNames.back()));
98 gsMatrix<T> pointsTranspose = points;
99 pointsTranspose.blockTransposeInPlace(1);
100 m_sizes.push_back(points.cols());
101 m_positions.push_back(pointsTranspose.data());
104 m_interface.setMeshVertices(m_meshIDs.back(),m_sizes.back(),m_positions.back(),vertexIDs);
105 m_vertexIDs.push_back(vertexIDs);
120 m_precicedt = m_interface.advance(dt);
127 m_interface.finalize();
138 void readBlockScalarData(
const index_t & dataID,
const index_t & size,
const index_t * IDs, gsMatrix<T> & values)
const
140 T * values_ptr =
new T[size];
141 m_interface.readBlockScalarData(dataID,size,IDs,values_ptr);
154 void readBlockScalarData(
const index_t & meshID,
const index_t & dataID,
const gsMatrix<T> & coords, gsMatrix<T> & values)
const
157 this->getMeshVertexIDsFromPositions(meshID,coords,IDs);
159 this->readBlockScalarData(dataID,coords.cols(),IDs,values);
188 void writeBlockScalarData(
const index_t & dataID,
const index_t & size,
const index_t * IDs,
const gsMatrix<T> & values)
190 m_interface.writeBlockScalarData(dataID,size,IDs,values.data());
201 void writeBlockScalarData(
const index_t & meshID,
const index_t & dataID,
const gsMatrix<T> & coords,
const gsMatrix<T> & values)
204 this->getMeshVertexIDsFromPositions(meshID,coords,IDs);
206 this->writeBlockScalarData(dataID,coords.cols(),IDs,values);
229 void getMeshVertexIDsFromPositions(
const index_t & meshID,
const gsMatrix<T> & coords, gsMatrix<index_t> & IDs)
const
232 this->getMeshVertexIDsFromPositions(meshID,coords,ID_ptr);
233 for (
index_t k=0; k!=coords.cols(); k++)
234 gsDebugVar(ID_ptr[k]);
246 void getMeshVertexIDsFromPositions(
const index_t & meshID,
const gsMatrix<T> & coords,
index_t * ID_ptr)
const
248 gsMatrix<T> coordsTranspose = coords;
249 coordsTranspose.blockTransposeInPlace(1);
250 T * positions = coordsTranspose.data();
251 m_interface.getMeshVertexIDsFromPositions(meshID,coords.cols(),positions,ID_ptr);
261 index_t getMeshID(
const std::string &dataName)
const
263 return m_interface.getMeshID(dataName);
274 index_t getDataID(
const std::string &dataName,
int meshID)
const
276 return m_interface.getDataID(dataName,meshID);
280 virtual std::ostream &print(std::ostream &os)
const
282 os << precice::getVersionInformation()<<
"\n\n";
283 os <<
"Interface has the following meshes:\n";
284 for (
index_t k=0; k!=m_meshNames.size(); k++)
285 gsInfo<<m_meshNames[k]<<
"\t (ID="<<m_meshIDs[k]<<
")\n";
291 std::vector<std::string> m_meshNames;
293 std::vector<index_t> m_meshIDs;
295 std::vector<index_t> m_sizes;
297 std::vector<T *> m_positions;
299 std::vector<index_t *> m_vertexIDs;
301 precice::SolverInterface m_interface;
#define index_t
Definition: gsConfig.h:32
Provides preprocessor directives configuration of G+Smo.
#define gsInfo
Definition: gsDebug.h:43