8#include "precice/impl/versions.hpp"
13#pragma GCC diagnostic push
14#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
17#pragma clang diagnostic push
18#pragma clang diagnostic ignored "-Wdeprecated-declarations"
25static std::string errormsg =
"preCICE has not been created properly. Be sure to call \"precicec_createParticipant\" or \"precicec_createParticipant_withCommunicator\" before any other call to preCICE.";
26static std::string errormsgCreate =
"preCICE has been created already! Be sure to call either \"precicec_createParticipant\" or \"precicec_createParticipant_withCommunicator\" exactly once.";
29 const char *participantName,
30 const char *configFileName,
31 int solverProcessIndex,
32 int solverProcessSize,
44 const char *participantName,
45 const char *configFileName,
46 int solverProcessIndex,
47 int solverProcessSize)
65 impl->advance(computedTimeStepSize);
78 return impl->getMeshDimensions(meshName);
84 return impl->getDataDimensions(meshName, dataName);
90 if (
impl->isCouplingOngoing()) {
99 if (
impl->isTimeWindowComplete()) {
107 return impl->getMaxTimeStepSize();
113 return impl->requiresInitialData() ? 1 : 0;
119 return impl->requiresWritingCheckpoint() ? 1 : 0;
125 return impl->requiresReadingCheckpoint() ? 1 : 0;
131 if (
impl->requiresMeshConnectivityFor(meshName)) {
138 const char * meshName,
139 const double *position)
142 auto size =
static_cast<long unsigned>(
impl->getMeshDimensions(meshName));
143 return impl->setMeshVertex(meshName, {position, size});
147 const char * meshName,
149 const double *positions,
153 auto idsSize =
static_cast<long unsigned>(size);
154 auto posSize =
static_cast<long unsigned>(
impl->getMeshDimensions(meshName) * size);
155 impl->setMeshVertices(meshName, {positions, posSize}, {ids, idsSize});
159 const char *meshName)
162 return impl->getMeshVertexSize(meshName);
166 const char *meshName,
171 impl->setMeshEdge(meshName, firstVertexID, secondVertexID);
175 const char *meshName,
177 const int * vertices)
180 auto verticesSize =
static_cast<long unsigned>(size) * 2;
181 impl->setMeshEdges(meshName, {vertices, verticesSize});
185 const char *meshName,
191 impl->setMeshTriangle(meshName, firstVertexID, secondVertexID, thirdVertexID);
195 const char *meshName,
197 const int * vertices)
200 auto verticesSize =
static_cast<long unsigned>(size) * 3;
201 impl->setMeshTriangles(meshName, {vertices, verticesSize});
205 const char *meshName,
212 impl->setMeshQuad(meshName, firstVertexID, secondVertexID, thirdVertexID, fourthVertexID);
216 const char *meshName,
218 const int * vertices)
221 auto verticesSize =
static_cast<long unsigned>(size) * 4;
222 impl->setMeshQuads(meshName, {vertices, verticesSize});
226 const char *meshName,
233 impl->setMeshTetrahedron(meshName, firstVertexID, secondVertexID, thirdVertexID, fourthVertexID);
237 const char *meshName,
239 const int * vertices)
242 auto verticesSize =
static_cast<long unsigned>(size) * 4;
243 impl->setMeshTetrahedra(meshName, {vertices, verticesSize});
247 const char * meshName,
248 const char * dataName,
250 const int * valueIndices,
251 const double *values)
254 auto dataSize = size *
impl->getDataDimensions(meshName, dataName);
255 impl->writeData(meshName, dataName, {valueIndices,
static_cast<unsigned long>(size)}, {values,
static_cast<unsigned long>(dataSize)});
259 const char *meshName,
260 const char *dataName,
262 const int * valueIndices,
263 double relativeReadTime,
267 auto dataSize = size *
impl->getDataDimensions(meshName, dataName);
268 impl->readData(meshName, dataName, {valueIndices,
static_cast<unsigned long>(size)}, relativeReadTime, {values,
static_cast<unsigned long>(dataSize)});
272 const char *dataName)
275 if (
impl->requiresGradientDataFor(meshName, dataName)) {
282 const char * meshName,
283 const char * dataName,
285 const int * valueIndices,
286 const double *gradients)
289 auto gradientComponents =
impl->getDataDimensions(meshName, dataName) *
impl->getMeshDimensions(meshName);
290 auto gradientSize = size * gradientComponents;
291 impl->writeGradientData(meshName, dataName, {valueIndices,
static_cast<unsigned long>(size)}, {gradients,
static_cast<unsigned long>(gradientSize)});
296 return precice::versionInformation;
300 const char * meshName,
301 const double *boundingBox)
303 auto bbSize =
static_cast<long unsigned>(
impl->getMeshDimensions(meshName)) * 2;
304 impl->setMeshAccessRegion(meshName, {boundingBox, bbSize});
308 const char *meshName,
311 double * coordinates)
313 auto coordinatesSize =
static_cast<long unsigned>(
impl->getMeshDimensions(meshName) * size);
314 impl->getMeshVertexIDsAndCoordinates(meshName, {ids,
static_cast<unsigned long>(size)}, {coordinates, coordinatesSize});
318#pragma GCC diagnostic pop
321#pragma clang diagnostic pop
#define PRECICE_CHECK(check,...)
Main Application Programming Interface of preCICE. Include using #include <precice/precice....
This class provides a lightweight logger.
double precicec_getMaxTimeStepSize()
Returns maximum allowed time step size.
static precice::logging::Logger _log("precicec")
void precicec_setMeshTriangles(const char *meshName, int size, const int *vertices)
Sets multiple mesh triangles from vertex IDs.
void precicec_setMeshTetrahedra(const char *meshName, int size, const int *vertices)
Sets multiple mesh tetrahedra from vertex IDs.
int precicec_requiresReadingCheckpoint()
int precicec_isTimeWindowComplete()
Returns true (->1), if the coupling time window is completed.
static std::string errormsgCreate
void precicec_writeData(const char *meshName, const char *dataName, int size, const int *valueIndices, const double *values)
Writes vector data values given as block.
void precicec_readData(const char *meshName, const char *dataName, int size, const int *valueIndices, double relativeReadTime, double *values)
Reads vector data values given as block.
int precicec_getDataDimensions(const char *meshName, const char *dataName)
Returns the spatial dimensionality of the given data on the given mesh.
void precicec_setMeshEdge(const char *meshName, int firstVertexID, int secondVertexID)
Sets mesh edge from vertex IDs.
void precicec_createParticipant(const char *participantName, const char *configFileName, int solverProcessIndex, int solverProcessSize)
Creates the coupling interface and configures it.
void precicec_setMeshQuad(const char *meshName, int firstVertexID, int secondVertexID, int thirdVertexID, int fourthVertexID)
Sets surface mesh quadrangle from vertex IDs.
static std::unique_ptr< precice::Participant > impl
int precicec_getMeshDimensions(const char *meshName)
Returns the spatial dimensionality of the given mesh.
void precicec_initialize()
Initiates the coupling to the coupling supervisor and initializes coupling data.
static std::string errormsg
void precicec_setMeshEdges(const char *meshName, int size, const int *vertices)
Sets multiple mesh edge from vertex IDs.
int precicec_requiresInitialData()
int precicec_isCouplingOngoing()
Returns true (->1), if the coupled simulation is ongoing.
int precicec_getMeshVertexSize(const char *meshName)
Returns the number of vertices of a mesh.
void precicec_writeGradientData(const char *meshName, const char *dataName, int size, const int *valueIndices, const double *gradients)
Writes vector gradient data to a mesh.
void precicec_setMeshAccessRegion(const char *meshName, const double *boundingBox)
See precice::Participant::setMeshAccessRegion().
void precicec_setMeshTriangle(const char *meshName, int firstVertexID, int secondVertexID, int thirdVertexID)
Sets a triangle from vertex IDs. Creates missing edges.
int precicec_setMeshVertex(const char *meshName, const double *position)
Creates a mesh vertex.
void precicec_finalize()
Finalizes the coupling to the coupling supervisor.
int precicec_requiresMeshConnectivityFor(const char *meshName)
Checks if the given mesh requires connectivity.
void precicec_setMeshVertices(const char *meshName, int size, const double *positions, int *ids)
Creates multiple mesh vertices.
void precicec_advance(double computedTimeStepSize)
Exchanges data between solver and coupling supervisor.
void precicec_createParticipant_withCommunicator(const char *participantName, const char *configFileName, int solverProcessIndex, int solverProcessSize, void *communicator)
void precicec_setMeshQuads(const char *meshName, int size, const int *vertices)
Sets multiple mesh quads from vertex IDs.
int precicec_requiresGradientDataFor(const char *meshName, const char *dataName)
Checks if the given data set requires gradient data. We check if the data object has been initialized...
void precicec_getMeshVertexIDsAndCoordinates(const char *meshName, const int size, int *ids, double *coordinates)
See precice::Participant::getMeshVertexIDsAndCoordinates().
int precicec_requiresWritingCheckpoint()
void precicec_setMeshTetrahedron(const char *meshName, int firstVertexID, int secondVertexID, int thirdVertexID, int fourthVertexID)
Sets mesh tetrahedron from vertex IDs.
const char * precicec_getVersionInformation()
Returns information on the version of preCICE.
C language bindings to main Application Programming Interface of preCICE.