Skip to content

Commit 74b9d3e

Browse files
committed
Passing dimensions from preCICE config to adapter
1 parent ba0defd commit 74b9d3e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

cht/adapter.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ def configure(self, names):
142142

143143
self.computeNormals()
144144

145+
dims = self.precice.get_dimensions()
146+
145147
self.nodeCoordinates = np.array([p for p in self.SHMESH.sdj.COORDO.VALE.get()])
146-
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))
147149
self.shiftMesh()
148150

149151
self.faces = [self.mesh.correspondance_mailles[idx] for idx in self.mesh.gma[self.groupName]]
@@ -170,7 +172,10 @@ def computeNormals(self):
170172
OPERATION='NORMALE'
171173
)
172174
self.normals = N.EXTR_COMP().valeurs
173-
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))
174179
DETRUIRE(CONCEPT=({"NOM": N}, {"NOM": DUMMY}))
175180

176181
def setVertices(self):
@@ -266,10 +271,11 @@ def setLoad(self, LOAD):
266271
self.LOAD = LOAD
267272

268273
def shiftMesh(self):
274+
dims = self.precice.get_dimensions()
269275
coords = [p for p in self.SHMESH.sdj.COORDO.VALE.get()]
270276
for i in range(len(self.normals)):
271-
for c in range(3):
272-
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
273279
self.SHMESH.sdj.COORDO.VALE.changeJeveuxValues(len(coords), tuple(range(1, len(coords)+1)), tuple(coords), tuple(coords), 1)
274280

275281
def updateConductivity(self, T):

0 commit comments

Comments
 (0)