From 081099d302ec829f20dac1f4f0f0a9cee0705b29 Mon Sep 17 00:00:00 2001 From: AlexanderMueller Date: Fri, 8 Mar 2024 07:37:21 +0100 Subject: [PATCH] fixes in python tests --- ikarus/python/test/linearelastictest.py | 10 +++++++--- ikarus/python/test/nonlinearelastictest.py | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ikarus/python/test/linearelastictest.py b/ikarus/python/test/linearelastictest.py index e309b114b..70c15b19f 100644 --- a/ikarus/python/test/linearelastictest.py +++ b/ikarus/python/test/linearelastictest.py @@ -64,10 +64,14 @@ def volumeLoad(x, lambdaVal): def neumannLoad(x, lambdaVal): return np.array([lambdaVal * 0, lambdaVal]) - neumannVertices = np.zeros(grid.size(2) * 2, dtype=bool) - assert len(neumannVertices) == len(flatBasis) + neumannVertices = np.zeros(grid.size(2), dtype=bool) - flatBasis.interpolate(neumannVertices, lambda x: True if x[1] > 0.9 else False) + def loadTopEdgePredicate(x): + return True if x[1] > 0.999 else False + + indexSet = grid.indexSet + for v in grid.vertices: + neumannVertices[indexSet.index(v)]=loadTopEdgePredicate(v.geometry.center) boundaryPatch = iks.utils.boundaryPatch(grid, neumannVertices) diff --git a/ikarus/python/test/nonlinearelastictest.py b/ikarus/python/test/nonlinearelastictest.py index 5c13d806e..5a3ffcc57 100644 --- a/ikarus/python/test/nonlinearelastictest.py +++ b/ikarus/python/test/nonlinearelastictest.py @@ -44,10 +44,14 @@ def volumeLoad(x, lambdaVal): def neumannLoad(x, lambdaVal): return np.array([lambdaVal * 0, lambdaVal]) - neumannVertices = np.zeros(grid.size(2) * 2, dtype=bool) - assert len(neumannVertices) == len(flatBasis) + neumannVertices = np.zeros(grid.size(2), dtype=bool) - flatBasis.interpolate(neumannVertices, lambda x: True if x[1] > 0.9 else False) + def loadTopEdgePredicate(x): + return True if x[1] > 0.9 else False + + indexSet = grid.indexSet + for v in grid.vertices: + neumannVertices[indexSet.index(v)]=loadTopEdgePredicate(v.geometry.center) boundaryPatch = iks.utils.boundaryPatch(grid, neumannVertices)