Skip to content

Commit

Permalink
Merge pull request #122 from precice/calculix-adapter-v2.20.1
Browse files Browse the repository at this point in the history
Release v2.20.1
  • Loading branch information
IshaanDesai authored Mar 20, 2024
2 parents 9057470 + a4581fd commit 51cf777
Show file tree
Hide file tree
Showing 15 changed files with 458 additions and 543 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.4.0
run: wget https://github.com/precice/precice/releases/download/v2.4.0/libprecice2_2.4.0_${{matrix.name}}.deb &&
sudo apt install ./libprecice2_2.4.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
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
# Official repo for the clang-format hook
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: 'v8.0.1'
hooks:
- id: clang-format
files: "^adapter"
# Official repo for default hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.3.0'
hooks:
- 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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ The adapter was initially developed for conjugate heat transfer (CHT) simulation

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**.

## 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 consservativeVectorWrite(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 consservativeVectorWrite(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();
}
}
Loading

0 comments on commit 51cf777

Please sign in to comment.