Skip to content

Commit

Permalink
Merge branch 'develop' into multiscale-update
Browse files Browse the repository at this point in the history
  • Loading branch information
IshaanDesai committed Apr 1, 2024
2 parents dc01332 + b8205b4 commit 6ce3ef1
Show file tree
Hide file tree
Showing 15 changed files with 708 additions and 809 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/ubuntu_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@ jobs:
include:
- os: ubuntu-20.04
name: focal
flags: -fallow-argument-mismatch
- os: ubuntu-22.04
name: jammy
flags: -fallow-argument-mismatch

runs-on: ${{matrix.os}}
container: precice/precice:develop
continue-on-error: true
env: # Versioning is "calculix-preciceX_2.YY-Z[...]" with X the major preCICE version, YY the minor CCX version and Z the package version
PACKAGE_NAME: "calculix-precice2_2.20.0-1_amd64"
PACKAGE_NAME: "calculix-precice3_2.20.1-1_amd64"

steps:
- name: Update system
run: sudo apt update && sudo apt upgrade -y
run: |
apt-get -qq update
apt-get -qq install sudo
sudo apt update && sudo apt upgrade -y
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: Get preCICE v2.5.0
run: wget https://github.com/precice/precice/releases/download/v2.5.0/libprecice2_2.5.0_${{matrix.name}}.deb &&
sudo apt install ./libprecice2_2.5.0_${{matrix.name}}.deb -y
- name: install dependencies
run: sudo apt install libarpack2-dev libspooles-dev libyaml-cpp-dev -y
- name: Download CalculiX
Expand All @@ -43,8 +45,8 @@ jobs:
run: sudo apt install lintian pandoc -y
- name: Create Debian Package
run: |
mkdir -p "packaging/calculix-precice2_2.20.0-1_amd64/usr/bin" &&
cp ./bin/ccx_preCICE ./packaging/calculix-precice2_2.20.0-1_amd64/usr/bin/ccx_preCICE &&
mkdir -p "packaging/calculix-precice3_2.20.1-1_amd64/usr/bin" &&
cp ./bin/ccx_preCICE ./packaging/calculix-precice3_2.20.1-1_amd64/usr/bin/ccx_preCICE &&
cd packaging && pwd && bash ./make_deb.sh ${{matrix.name}}
- name: Store Debian package artifact
uses: actions/upload-artifact@v2
Expand Down
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ repos:
- id: check-xml
- id: check-merge-conflict
- id: mixed-line-ending
files: "^(adapter|README.md)"
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
files: "^(adapter|README.md)"
- id: end-of-file-fixer
files: "^(adapter|README.md)"
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ $(OBJDIR)/%.o : %.c
$(OBJDIR)/%.o : %.f
$(FC) $(FFLAGS) -c $< -o $@
$(OBJDIR)/%.o : adapter/%.c
$(CC) $(CFLAGS) -c $< -o $@
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(OBJDIR)/%.o : adapter/%.cpp
g++ -std=c++11 $(YAML_INCLUDE) -c $< -o $@ $(LIBS)
g++ -std=c++11 $(CFLAGS) $(INCLUDES) -c $< -o $@ $(LIBS)
#$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ $(LIBS)

# Source files in the $(CCX) folder
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
The adapter was initially developed for conjugate heat transfer (CHT) simulations via preCICE by Lucia Cheung in the scope of her master’s thesis [[1]](https://www5.in.tum.de/pub/Cheung2016_Thesis.pdf) in cooperation with [SimScale](https://www.simscale.com/). For running the adapter for CHT simulations refer to this thesis. The adapter was extended to fluid-structure interaction by Alexander Rusch [[2]](https://www.gacm2017.uni-stuttgart.de/registration/Upload/ExtendedAbstracts/ExtendedAbstract_0138.pdf).

The latest version of the adapter is based on **CalculiX version 2.20.**
Legacy versions of the adapter for older versions of CalculiX are supported on various branches. Branches for CalculiX version older than 2.15 require **preCICE v1.x**, whereas newer versions rely on **preCICE v2.x**.
Legacy versions of the adapter for older versions of CalculiX are supported on various branches. Branches for CalculiX version older than 2.15 require **preCICE v1.x**, whereas newer versions rely on **preCICE v2.x**. The release [v2.20.1](https://github.com/precice/calculix-adapter/releases/tag/v2.20.1) relies on **preCICE v3.0.x**.

## Start here

Go to the [adapter documentation](https://precice.org/adapter-calculix-overview.html)
Go to the [adapter documentation](https://precice.org/adapter-calculix-overview.html)

## References

[1] Lucia Cheung Yau. Conjugate heat transfer with the multiphysics coupling library precice. Master’s thesis, Department of Informatics, Technical University of Munich, 2016.

[2] Benjamin Uekermann, Hans-Joachim Bungartz, Lucia Cheung Yau, Gerasimos Chourdakis and Alexander Rusch. Official preCICE Adapters for Standard Open-Source Solvers. In Proceedings of the _7th GACM Colloquium on Computational Mechanics for Young Scientists from Academia_, 2017.
[2] Benjamin Uekermann, Hans-Joachim Bungartz, Lucia Cheung Yau, Gerasimos Chourdakis and Alexander Rusch. Official preCICE Adapters for Standard Open-Source Solvers. In Proceedings of the _7th GACM Colloquium on Computational Mechanics for Young Scientists from Academia_, 2017.

## License

Expand Down
62 changes: 19 additions & 43 deletions adapter/2D3DCoupling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <cstdlib>
#include <map>
#include <vector>
#include "precice/SolverInterfaceC.h"
#include "precice/preciceC.h"

namespace MappingHelper {

Expand Down Expand Up @@ -55,7 +55,7 @@ static void setDoubleArrayZero(double *values, const int length, const int dim)
}
}

Mapping2D3D *createMapping(const double *nodeCoordinates, int num3Dnodes, int nodesMeshID)
Mapping2D3D *createMapping(const double *nodeCoordinates, int num3Dnodes, char *nodesMeshName)
{

Mapping2D3D *map = (Mapping2D3D *) malloc(sizeof(Mapping2D3D));
Expand Down Expand Up @@ -100,7 +100,7 @@ Mapping2D3D *createMapping(const double *nodeCoordinates, int num3Dnodes, int no

// Setup preCICE mesh
map->preciceNodesIDs = (int *) malloc(map->num2DNodes * sizeof(int));
precicec_setMeshVertices(nodesMeshID, map->num2DNodes, map->pos2D, map->preciceNodesIDs);
precicec_setMeshVertices(nodesMeshName, map->num2DNodes, map->pos2D, map->preciceNodesIDs);

// Initialize buffers
map->bufferScalar2D = (double *) malloc(map->num2DNodes * sizeof(double));
Expand All @@ -127,25 +127,19 @@ void freeMapping(Mapping2D3D *map)
free(map);
}

void consistentScalarRead(Mapping2D3D *map, int dataID)
void consistentScalarRead(Mapping2D3D *map, const char *meshName, const char *dataName, const double dt)
{
precicec_readBlockScalarData(dataID,
map->num2DNodes,
map->preciceNodesIDs,
map->bufferScalar2D);
precicec_readData(meshName, dataName, map->num2DNodes, map->preciceNodesIDs, dt, map->bufferScalar2D);

// For each 3D point, copy the 2D counterpart
for (int i = 0; i < map->num3DNodes; ++i) {
map->bufferScalar3D[i] = map->bufferScalar2D[map->mapping3D2D[i]];
}
}

void consistentVectorRead(Mapping2D3D *map, int dataID)
void consistentVectorRead(Mapping2D3D *map, const char *meshName, const char *dataName, const double dt)
{
precicec_readBlockVectorData(dataID,
map->num2DNodes,
map->preciceNodesIDs,
map->bufferVector2D);
precicec_readData(meshName, dataName, map->num2DNodes, map->preciceNodesIDs, dt, map->bufferVector2D);

// For each 3D point, copy the 2D counterpart, component-wise
for (int i = 0; i < map->num3DNodes; ++i) {
Expand All @@ -154,25 +148,19 @@ void consistentVectorRead(Mapping2D3D *map, int dataID)
}
}

void conservativeScalarRead(Mapping2D3D *map, int dataID)
void conservativeScalarRead(Mapping2D3D *map, const char *meshName, const char *dataName, const double dt)
{
precicec_readBlockScalarData(dataID,
map->num2DNodes,
map->preciceNodesIDs,
map->bufferScalar2D);
precicec_readData(meshName, dataName, map->num2DNodes, map->preciceNodesIDs, dt, map->bufferScalar2D);

// For each 3D point, take a fraction of the value in 2D
for (int i = 0; i < map->num3DNodes; ++i) {
map->bufferScalar3D[i] = map->bufferScalar2D[map->mapping3D2D[i]] / map->numParentNodes[map->mapping3D2D[i]];
}
}

void conservativeVectorRead(Mapping2D3D *map, int dataID)
void conservativeVectorRead(Mapping2D3D *map, const char *meshName, const char *dataName, const double dt)
{
precicec_readBlockVectorData(dataID,
map->num2DNodes,
map->preciceNodesIDs,
map->bufferVector2D);
precicec_readData(meshName, dataName, map->num2DNodes, map->preciceNodesIDs, dt, map->bufferVector2D);

// For each 3D point, take a fraction of the value in 2D
for (int i = 0; i < map->num3DNodes; ++i) {
Expand All @@ -181,7 +169,7 @@ void conservativeVectorRead(Mapping2D3D *map, int dataID)
}
}

void consistentScalarWrite(Mapping2D3D *map, int dataID)
void consistentScalarWrite(Mapping2D3D *map, const char *meshName, const char *dataName)
{
// For each 2D point, write the average of the relevant 3D points,
// in two steps: sum then divide
Expand All @@ -197,13 +185,10 @@ void consistentScalarWrite(Mapping2D3D *map, int dataID)
map->bufferScalar2D[i2d] /= map->numParentNodes[i2d];
}

precicec_writeBlockScalarData(dataID,
map->num2DNodes,
map->preciceNodesIDs,
map->bufferScalar2D);
precicec_writeData(meshName, dataName, map->num2DNodes, map->preciceNodesIDs, map->bufferScalar2D);
}

void consistentVectorWrite(Mapping2D3D *map, int dataID)
void consistentVectorWrite(Mapping2D3D *map, const char *meshName, const char *dataName)
{
// For each 2D point, write the average of the relevant 3D points,
// in two steps: sum then divide
Expand All @@ -220,13 +205,10 @@ void consistentVectorWrite(Mapping2D3D *map, int dataID)
map->bufferVector2D[2 * i2d + 1] /= map->numParentNodes[i2d];
}

precicec_writeBlockVectorData(dataID,
map->num2DNodes,
map->preciceNodesIDs,
map->bufferVector2D);
precicec_writeData(meshName, dataName, map->num2DNodes, map->preciceNodesIDs, map->bufferVector2D);
}

void conservativeScalarWrite(Mapping2D3D *map, int dataID)
void conservativeScalarWrite(Mapping2D3D *map, const char *meshName, const char *dataName)
{
// For each 2D point, write the sum of the relevant 3D points,
setDoubleArrayZero(map->bufferScalar2D, map->num2DNodes, 1);
Expand All @@ -237,13 +219,10 @@ void conservativeScalarWrite(Mapping2D3D *map, int dataID)
map->bufferScalar2D[map->mapping3D2D[i]] += map->bufferScalar3D[i];
}

precicec_writeBlockScalarData(dataID,
map->num2DNodes,
map->preciceNodesIDs,
map->bufferScalar2D);
precicec_writeData(meshName, dataName, map->num2DNodes, map->preciceNodesIDs, map->bufferScalar2D);
}

void conservativeVectorWrite(Mapping2D3D *map, int dataID)
void conservativeVectorWrite(Mapping2D3D *map, const char *meshName, const char *dataName)
{
// For each 2D point, write the sum of the relevant 3D points,
setDoubleArrayZero(map->bufferVector2D, map->num2DNodes, 2);
Expand All @@ -254,8 +233,5 @@ void conservativeVectorWrite(Mapping2D3D *map, int dataID)
map->bufferVector2D[2 * map->mapping3D2D[i] + 1] += map->bufferVector3D[3 * i + 1];
}

precicec_writeBlockVectorData(dataID,
map->num2DNodes,
map->preciceNodesIDs,
map->bufferVector2D);
precicec_writeData(meshName, dataName, map->num2DNodes, map->preciceNodesIDs, map->bufferVector2D);
}
18 changes: 9 additions & 9 deletions adapter/2D3DCoupling.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ typedef struct {

} Mapping2D3D;

Mapping2D3D *createMapping(const double *nodeCoordinates, int num3Dnodes, int nodesMeshID);
Mapping2D3D *createMapping(const double *nodeCoordinates, int num3Dnodes, char *nodesMeshName);
void freeMapping(Mapping2D3D *);
void consistentScalarRead(Mapping2D3D *map, int dataID);
void consistentVectorRead(Mapping2D3D *map, int dataID);
void conservativeScalarRead(Mapping2D3D *map, int dataID);
void conservativeVectorRead(Mapping2D3D *map, int dataID);
void consistentScalarWrite(Mapping2D3D *map, int dataID);
void consistentVectorWrite(Mapping2D3D *map, int dataID);
void conservativeScalarWrite(Mapping2D3D *map, int dataID);
void conservativeVectorWrite(Mapping2D3D *map, int dataID);
void consistentScalarRead(Mapping2D3D *map, const char *meshName, const char *dataName, const double dt);
void consistentVectorRead(Mapping2D3D *map, const char *meshName, const char *dataName, const double dt);
void conservativeScalarRead(Mapping2D3D *map, const char *meshName, const char *dataName, const double dt);
void conservativeVectorRead(Mapping2D3D *map, const char *meshName, const char *dataName, const double dt);
void consistentScalarWrite(Mapping2D3D *map, const char *meshName, const char *dataName);
void consistentVectorWrite(Mapping2D3D *map, const char *meshName, const char *dataName);
void conservativeScalarWrite(Mapping2D3D *map, const char *meshName, const char *dataName);
void conservativeVectorWrite(Mapping2D3D *map, const char *meshName, const char *dataName);

#endif
2 changes: 1 addition & 1 deletion adapter/OutputBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ void BufferClear(outputBuffer *buffer)
unsigned BufferStoredStates(outputBuffer *buffer)
{
return buffer->states.size();
}
}
46 changes: 23 additions & 23 deletions adapter/OutputBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Code defining buffering mechanism for the output.
CalculiX outputs .frd file using the frd() function, which takes many parameters.
When doing implicit coupling with subcycling in preCICE, only the sub-steps of the final iteration of
When doing implicit coupling with subcycling in preCICE, only the sub-steps of the final iteration of
a time window must be outputted. Thus, it is necessary to store data until the end of the time window:
- If the window converged, the stored steps can be outputted all at once.
- If the window must be restarted, the buffer should be cleared.
Expand All @@ -29,22 +29,22 @@ typedef struct outputBuffer outputBuffer;

/**
* @brief Get a handle to a buffer object, valid in C parts of the code
*
*
* @return pointer to a buffer
*/
outputBuffer *BufferCreate();

/**
* @brief Free the buffer object
*
* @param buffer
*
* @param buffer
*/
void BufferFree(outputBuffer *buffer);

/**
* @brief Saves an array of "double" at the current step, under a given name
*
* @param buffer handle to the buffer
*
* @param buffer handle to the buffer
* @param name name of the data to save
* @param data array of values
* @param length size of the array
Expand All @@ -53,8 +53,8 @@ void BufferSaveDouble(outputBuffer *buffer, const char *name, double *data, unsi

/**
* @brief Saves an array of "ITG" at the current step, under a given name
*
* @param buffer handle to the buffer
*
* @param buffer handle to the buffer
* @param name name of the data to save
* @param data array of values
* @param length size of the array
Expand All @@ -63,55 +63,55 @@ void BufferSaveITG(outputBuffer *buffer, const char *name, ITG *data, unsigned l

/**
* @brief Loads an array of "double" at the current step (modified through ReadNext and Clear) with a given name
*
* @param buffer handle to the buffer
*
* @param buffer handle to the buffer
* @param name name of the data to save
* @param data array of values
*
*
* @pre data is long enough
*/
void BufferLoadDouble(outputBuffer *buffer, const char *name, double *data);

/**
* @brief Loads an array of "ITG" at the current step (modified through ReadNext and Clear) with a given name
*
* @param buffer handle to the buffer
*
* @param buffer handle to the buffer
* @param name name of the data to save
* @param data array of values
*
*
* @pre data is long enough
*/
void BufferLoadITG(outputBuffer *buffer, const char *name, ITG *data);

/**
* @brief Returns true (1) if BufferLoadX can be called (i.e. if there is still a step to read)
*
*
*/
int BufferCanRead(outputBuffer *buffer);
/**
* @brief Increment the step counter of data to read
*
* @param buffer
*
* @param buffer
*/
void BufferReadNext(outputBuffer *buffer);
/**
* @brief Start to store a new step
*
* @param buffer
*
* @param buffer
*/
void BufferWriteNewStep(outputBuffer *buffer);

/**
* @brief Clear the buffer and reset the reading counter
*
* @param buffer
*
* @param buffer
*/
void BufferClear(outputBuffer *buffer);

/**
* @brief Check how many states are stored
*
* @param buffer
*
* @param buffer
* @return unsigned number of states that can be read
*/
unsigned BufferStoredStates(outputBuffer *buffer);
Expand Down
Loading

0 comments on commit 6ce3ef1

Please sign in to comment.