Skip to content

Commit 51d655f

Browse files
authored
Merge pull request #22 from precice/update-bindings-v2.2.0.2
Update adapter to use python-bindings v2.2.0.2
2 parents 5d640f0 + 2da6b61 commit 51d655f

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# preCICE-adapter for the CSM code Code_Aster
22

3-
This adapter was implemented as part of the [master thesis of Lucia Cheung](https://www5.in.tum.de/pub/Cheung2016_Thesis.pdf) in cooperation with [SimScale](https://www.simscale.com/). Currently only conjugate heat transfer is supported.
3+
This adapter was implemented as part of the [master thesis of Lucia Cheung](https://www5.in.tum.de/pub/Cheung2016_Thesis.pdf) in cooperation with [SimScale](https://www.simscale.com/). Currently only conjugate heat transfer is supported. Documentation is available in the `cht` subfolder, and [also here](https://www.precice.org/adapter-code_aster.html).
44

5-
The adapter currently supports preCICE v1.4.1 and Code_Aster v14.4. The following tutorials are available.
5+
The adapter currently supports preCICE v2.2.0 and Code_Aster v14.6. The following tutorials is available:
66

7-
* Flow over plate OpenFoam-Code_Aster ([wiki](https://github.com/precice/code_aster-adapter/wiki/Flow-over-plate-Code_Aster-Tutorial))
8-
9-
A documentation is available in the `cht` subfolder, and in the [wiki](https://github.com/precice/code_aster-adapter/wiki).
7+
* [Flow over plate steady state OpenFoam-Code_Aster](https://www.precice.org/tutorials-flow-over-heated-plate-steady-state.html))

cht/adapter.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,9 @@ def __init__(self, precice, participantName, names, MESH, SHMESH, MODEL, MAT, is
116116
self.writeHCoeffDataID = 0
117117
self.writeTempDataID = 0
118118

119-
self.readTemp = []
120-
self.readHCoeff = []
121119
self.writeTemp = []
122120
self.writeHCoeff = []
123121

124-
self.readDataSize = 0
125-
self.writeDataSize = 0
126-
127122
self.MESH = MESH
128123
# Shifted mesh (contains only the interface, and is shifted by delta in the direction opposite to the normal)
129124
self.SHMESH = SHMESH
@@ -147,8 +142,10 @@ def configure(self, names):
147142

148143
self.computeNormals()
149144

145+
dims = self.precice.get_dimensions()
146+
150147
self.nodeCoordinates = np.array([p for p in self.SHMESH.sdj.COORDO.VALE.get()])
151-
self.nodeCoordinates = np.resize(self.nodeCoordinates, (int(len(self.nodeCoordinates)/3), 3))
148+
self.nodeCoordinates = np.resize(self.nodeCoordinates, (int(len(self.nodeCoordinates)/dims), dims))
152149
self.shiftMesh()
153150

154151
self.faces = [self.mesh.correspondance_mailles[idx] for idx in self.mesh.gma[self.groupName]]
@@ -158,12 +155,6 @@ def configure(self, names):
158155

159156
self.setDataIDs(names)
160157

161-
self.readDataSize = len(self.faces)
162-
self.writeDataSize = len(self.nodeCoordinates)
163-
164-
self.readHCoeff = np.zeros(self.readDataSize)
165-
self.readTemp = np.zeros(self.readDataSize)
166-
167158
def computeNormals(self):
168159
# Get normals at the nodes
169160
DUMMY = AFFE_MODELE(
@@ -181,7 +172,10 @@ def computeNormals(self):
181172
OPERATION='NORMALE'
182173
)
183174
self.normals = N.EXTR_COMP().valeurs
184-
self.normals = np.resize(np.array(self.normals), (int(len(self.normals)/3), 3))
175+
176+
dims = self.precice.get_dimensions()
177+
178+
self.normals = np.resize(np.array(self.normals), (int(len(self.normals)/dims), dims))
185179
DETRUIRE(CONCEPT=({"NOM": N}, {"NOM": DUMMY}))
186180

187181
def setVertices(self):
@@ -251,9 +245,9 @@ def updateBCs(self, temp, hCoeff):
251245
1)
252246

253247
def readAndUpdateBCs(self):
254-
self.precice.read_block_scalar_data(self.readHCoeffDataID, self.preciceFaceCenterIndices)
255-
self.precice.read_block_scalar_data(self.readTempDataID, self.preciceFaceCenterIndices)
256-
self.updateBCs(self.readTemp, self.readHCoeff)
248+
readHCoeff = self.precice.read_block_scalar_data(self.readHCoeffDataID, self.preciceFaceCenterIndices)
249+
readTemp = self.precice.read_block_scalar_data(self.readTempDataID, self.preciceFaceCenterIndices)
250+
self.updateBCs(readTemp, readHCoeff)
257251

258252
def writeBCs(self, TEMP):
259253
writeTemp, writeHCoeff = self.getBoundaryValues(TEMP)
@@ -277,10 +271,11 @@ def setLoad(self, LOAD):
277271
self.LOAD = LOAD
278272

279273
def shiftMesh(self):
274+
dims = self.precice.get_dimensions()
280275
coords = [p for p in self.SHMESH.sdj.COORDO.VALE.get()]
281276
for i in range(len(self.normals)):
282-
for c in range(3):
283-
coords[i*3 + c] = coords[i*3 + c] - self.normals[i][c] * self.delta
277+
for c in range(dims):
278+
coords[i*dims + c] = coords[i*dims + c] - self.normals[i][c] * self.delta
284279
self.SHMESH.sdj.COORDO.VALE.changeJeveuxValues(len(coords), tuple(range(1, len(coords)+1)), tuple(coords), tuple(coords), 1)
285280

286281
def updateConductivity(self, T):

0 commit comments

Comments
 (0)