From 600f8beabdfb76a8d0f2a9fed05a078d389ff06c Mon Sep 17 00:00:00 2001
From: Carl-Martin Pfeiler <carl-martin.pfeiler@asc.tuwien.ac.at>
Date: Fri, 5 Oct 2018 14:20:28 +0200
Subject: [PATCH] Structured mesh: fixed surface triangles orient.
+ Should fix problems with bem++
+ to be tested with sp4
---
.../_structuredMeshing/addMesh_Face.py | 47 +++++++++++++++++++
.../addStructuredMesh_BoundaryFaceCuboid.py | 36 +++++++-------
integrators/_integrator.py | 12 ++---
3 files changed, 68 insertions(+), 27 deletions(-)
create mode 100644 _setup/geometries/standardGeometries/_structuredMeshing/addMesh_Face.py
diff --git a/_setup/geometries/standardGeometries/_structuredMeshing/addMesh_Face.py b/_setup/geometries/standardGeometries/_structuredMeshing/addMesh_Face.py
new file mode 100644
index 0000000..1946e2c
--- /dev/null
+++ b/_setup/geometries/standardGeometries/_structuredMeshing/addMesh_Face.py
@@ -0,0 +1,47 @@
+from netgen.meshing import Element2D
+
+################################################################################
+
+#------------------------------------------------------------------------------#
+
+def AddMesh_TopFace(ngmesh, fd, p):
+ for j in range(p.shape[0]-1):
+ for k in range(p.shape[1]-1):
+ ngmesh.Add(Element2D(fd, [p[j,k], p[j+1, k+1], p[j, k+1]]))
+ ngmesh.Add(Element2D(fd, [p[j,k], p[j+1, k], p[j+1, k+1]]))
+
+#------------------------------------------------------------------------------#
+
+def AddMesh_BottomFace(ngmesh, fd, p):
+ for j in range(p.shape[0]-1):
+ for k in range(p.shape[1]-1):
+ ngmesh.Add(Element2D(fd, [p[j,k], p[j, k+1], p[j+1, k+1]]))
+ ngmesh.Add(Element2D(fd, [p[j,k], p[j+1, k+1], p[j+1, k]]))
+
+#------------------------------------------------------------------------------#
+
+def AddMesh_LeftFace(ngmesh, fd, p):
+ for j in range(p.shape[0]-1):
+ for k in range(p.shape[1]-1):
+ ngmesh.Add(Element2D(fd, [p[j+1,k], p[j, k+1], p[j+1, k+1]]))
+ ngmesh.Add(Element2D(fd, [p[j+1,k], p[j, k], p[j, k+1]]))
+
+#------------------------------------------------------------------------------#
+
+def AddMesh_RightFace(ngmesh, fd, p):
+ for j in range(p.shape[0]-1):
+ for k in range(p.shape[1]-1):
+ ngmesh.Add(Element2D(fd, [p[j+1,k], p[j+1, k+1], p[j, k+1]]))
+ ngmesh.Add(Element2D(fd, [p[j+1,k], p[j, k+1], p[j, k]]))
+
+#------------------------------------------------------------------------------#
+
+def AddMesh_FrontFace(ngmesh, fd, p): AddMesh_RightFace(ngmesh, fd, p)
+
+#------------------------------------------------------------------------------#
+
+def AddMesh_BackFace(ngmesh, fd, p): AddMesh_LeftFace(ngmesh, fd, p)
+
+#------------------------------------------------------------------------------#
+
+################################################################################
diff --git a/_setup/geometries/standardGeometries/_structuredMeshing/addStructuredMesh_BoundaryFaceCuboid.py b/_setup/geometries/standardGeometries/_structuredMeshing/addStructuredMesh_BoundaryFaceCuboid.py
index a689d01..3042f29 100644
--- a/_setup/geometries/standardGeometries/_structuredMeshing/addStructuredMesh_BoundaryFaceCuboid.py
+++ b/_setup/geometries/standardGeometries/_structuredMeshing/addStructuredMesh_BoundaryFaceCuboid.py
@@ -1,28 +1,28 @@
+from commix._setup.geometries.standardGeometries._structuredMeshing.addMesh_Face \
+ import AddMesh_LeftFace, AddMesh_RightFace, AddMesh_FrontFace \
+ , AddMesh_BackFace, AddMesh_BottomFace, AddMesh_TopFace
################################################################################
def AddStructuredMesh_BoundaryFaceCuboid(ngmesh, fd, p, side):
- from netgen.meshing import Element2D
-
- if side in ["xmin", "ymin", "xmax", "ymax"]:
- flag = False
- elif side in ["zmin", "zmax"]:
- flag = True
- else:
- raise AttributeError(side)
+ AddMesh_Face = \
+ { "xmin" : AddMesh_LeftFace \
+ , "xmax" : AddMesh_RightFace \
+ , "ymin" : AddMesh_FrontFace \
+ , "ymax" : AddMesh_BackFace \
+ , "zmin" : AddMesh_BottomFace \
+ , "zmax" : AddMesh_TopFace \
+ }
- if flag:
- for j in range(p.shape[0]-1):
- for k in range(p.shape[1]-1):
- ngmesh.Add(Element2D(fd, [p[j,k], p[j+1, k+1], p[j, k+1]]))
- ngmesh.Add(Element2D(fd, [p[j,k], p[j+1, k+1], p[j+1, k]]))
- else:
- for j in range(p.shape[0]-1):
- for k in range(p.shape[1]-1):
- ngmesh.Add(Element2D(fd, [p[j+1,k], p[j, k+1], p[j, k]]))
- ngmesh.Add(Element2D(fd, [p[j+1,k], p[j, k+1], p[j+1, k+1]]))
+ try:
+ AddMesh_Face[side](ngmesh, fd, p)
+ except(KeyError):
+ raise ValueError("side", side, "not valid. Form must be, e.g., \"xmin\"")
+
+
+#------------------------------------------------------------------------------#
################################################################################
diff --git a/integrators/_integrator.py b/integrators/_integrator.py
index d251ea1..4d44b56 100644
--- a/integrators/_integrator.py
+++ b/integrators/_integrator.py
@@ -102,15 +102,9 @@ class _Integrator( \
import sys
## TODO search for all the prints and sys.exits --> replace with raise(...)
-# if(self.parameters.maxwellCoupling == "oerstedField" \
-# or self.parameters.maxwellCoupling == "magnetostaticField"):
-# print("maxwellCoupling set to", self.parameters.maxwellCoupling)
-# print("Oersted field implementation is Work In Progress; not finished.")
-# sys.exit()
-
- if(self.parameters.maxwellCoupling != "none" \
- and self._geometry.structuredMesh == True):
- raise NotImplementedError("maxwellCoupling != none and structured mesh doesn't work for now")
+ if(False): #TODO
+ print("Oh no, something went wrong")
+ sys.exit()
#------------------------------------------------------------------------------#
--
GitLab