Skip to content

Commit

Permalink
Fixed mesh configuration 2D coupling with Face meshes (#94)
Browse files Browse the repository at this point in the history
* Fixed mesh config for face mesh

* Removed dead code
  • Loading branch information
boris-martin authored Apr 13, 2022
1 parent a71ceae commit 069d377
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
19 changes: 18 additions & 1 deletion adapter/PreciceInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,24 @@ void PreciceInterface_ConfigureFaceCentersMesh(PreciceInterface *interface, Simu
interface->faceCentersMeshID = precicec_getMeshID(interface->faceCentersMeshName);
interface->preciceFaceCenterIDs = malloc(interface->numElements * sizeof(int));

precicec_setMeshVertices(interface->faceCentersMeshID, interface->numElements, interface->faceCenterCoordinates, interface->preciceFaceCenterIDs);
sendFaceCentersVertices(interface);
}

void sendFaceCentersVertices(PreciceInterface *interface)
{
// Send the data of face centers to preCICE. If 2D coupling is used, skip the z component!

if (!isQuasi2D3D(interface->quasi2D3D)) {
precicec_setMeshVertices(interface->faceCentersMeshID, interface->numElements, interface->faceCenterCoordinates, interface->preciceFaceCenterIDs);
} else {
double *coordinates2D = malloc(interface->numElements * 2 * sizeof(double));
for (int i = 0; i < interface->numElements; ++i) {
coordinates2D[2 * i] = interface->faceCenterCoordinates[3 * i];
coordinates2D[2 * i + 1] = interface->faceCenterCoordinates[3 * i + 1];
}
precicec_setMeshVertices(interface->faceCentersMeshID, interface->numElements, coordinates2D, interface->preciceFaceCenterIDs);
free(coordinates2D);
}
}

void PreciceInterface_ConfigureNodesMesh(PreciceInterface *interface, SimulationData *sim)
Expand Down
10 changes: 9 additions & 1 deletion adapter/PreciceInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,20 @@ void Precice_FreeData(SimulationData *sim);
void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, InterfaceConfig const *config);

/**
* @brief Configures the face centers mesh and calls setMeshVertices on preCICE
* @brief Configures the face centers mesh and calls sendFaceCentersVertices,
* who is responsible for calling preCICE
* @param interface
* @param sim
*/
void PreciceInterface_ConfigureFaceCentersMesh(PreciceInterface *interface, SimulationData *sim);

/**
* @brief Send the faces centers to preCICE.
*
* @param interface
*/
void sendFaceCentersVertices(PreciceInterface *interface);

/**
* @brief Configures the nodes mesh
* @param interface
Expand Down

0 comments on commit 069d377

Please sign in to comment.