Mod: trying to fix issue
This commit is contained in:
parent
8f4c664a74
commit
c22aa7f3f2
@ -6,6 +6,7 @@ from netgen.occ import *
|
|||||||
import numpy
|
import numpy
|
||||||
from numpy import pi, sqrt, arccos
|
from numpy import pi, sqrt, arccos
|
||||||
|
|
||||||
|
from .occExtended import *
|
||||||
from . import Periodic
|
from . import Periodic
|
||||||
|
|
||||||
class BodyCentered(Periodic):
|
class BodyCentered(Periodic):
|
||||||
@ -136,16 +137,21 @@ class BodyCentered(Periodic):
|
|||||||
|
|
||||||
vecFlow = self.normal(inletface)
|
vecFlow = self.normal(inletface)
|
||||||
self.cell = inletface.Extrude(extr)
|
self.cell = inletface.Extrude(extr)
|
||||||
|
self.cell = reconstruct(self.cell)
|
||||||
|
|
||||||
# Boundaries
|
# Boundaries
|
||||||
symetryId = 0
|
symetryId = 0
|
||||||
|
|
||||||
for face in self.cell.faces:
|
for face in self.cell.faces:
|
||||||
fNorm = self.normal(face)
|
fNorm = self.normal(face)
|
||||||
fAngle = self.angle(vecFlow, fNorm)
|
fAngle = self.angle(vecFlow, fNorm)
|
||||||
|
|
||||||
|
if fAngle == 0:
|
||||||
|
if (face.center.pos() == inletface.center.pos()).prod():
|
||||||
|
face.name = "inlet"
|
||||||
|
|
||||||
if fAngle == 0 and not face.center == inletface.center:
|
else:
|
||||||
face.name = "outlet"
|
face.name = "outlet"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
face.name = f"symetry{ symetryId }"
|
face.name = f"symetry{ symetryId }"
|
||||||
|
@ -6,6 +6,7 @@ from netgen.occ import *
|
|||||||
import numpy
|
import numpy
|
||||||
from numpy import pi, sqrt
|
from numpy import pi, sqrt
|
||||||
|
|
||||||
|
from .occExtended import *
|
||||||
from . import Periodic
|
from . import Periodic
|
||||||
|
|
||||||
class FaceCentered(Periodic):
|
class FaceCentered(Periodic):
|
||||||
@ -143,17 +144,21 @@ class FaceCentered(Periodic):
|
|||||||
|
|
||||||
vecFlow = self.normal(inletface)
|
vecFlow = self.normal(inletface)
|
||||||
self.cell = inletface.Extrude(extr)
|
self.cell = inletface.Extrude(extr)
|
||||||
|
self.cell = reconstruct(self.cell)
|
||||||
|
|
||||||
# Boundaries
|
# Boundaries
|
||||||
symetryId = 0
|
symetryId = 0
|
||||||
|
|
||||||
# ISSUE: inlet and outlet faces have the same name and normal vector after extrusion
|
|
||||||
for face in self.cell.faces:
|
for face in self.cell.faces:
|
||||||
fNorm = self.normal(face)
|
fNorm = self.normal(face)
|
||||||
fAngle = self.angle(vecFlow, fNorm)
|
fAngle = self.angle(vecFlow, fNorm)
|
||||||
|
|
||||||
|
if fAngle == 0:
|
||||||
|
if (face.center.pos() == inletface.center.pos()).prod():
|
||||||
|
face.name = "inlet"
|
||||||
|
|
||||||
if fAngle == 0 and not face.center == inletface.center:
|
else:
|
||||||
face.name = "outlet"
|
face.name = "outlet"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
face.name = f"symetry{ symetryId }"
|
face.name = f"symetry{ symetryId }"
|
||||||
|
@ -25,3 +25,25 @@ def add_method(cls):
|
|||||||
def pos(self) -> numpy.array:
|
def pos(self) -> numpy.array:
|
||||||
return numpy.array([self.x, self.y, self.z])
|
return numpy.array([self.x, self.y, self.z])
|
||||||
|
|
||||||
|
|
||||||
|
# ISSUE: netgen.occ.Face.Extrude: the opposite face has the same name and normal vector as an initial face.
|
||||||
|
def reconstruct(shape):
|
||||||
|
"""Reconstruct shape with new objects.
|
||||||
|
|
||||||
|
Warning: not works with curved edges.
|
||||||
|
"""
|
||||||
|
facesNew = []
|
||||||
|
|
||||||
|
for face in shape.faces:
|
||||||
|
edgesNew = []
|
||||||
|
for edge in face.edges:
|
||||||
|
v = edge.vertices
|
||||||
|
edgesNew.append(occ.Segment(v[0].p, v[1].p))
|
||||||
|
|
||||||
|
faceNew = occ.Face(occ.Wire(edgesNew))
|
||||||
|
faceNew.name = face.name
|
||||||
|
facesNew.append(faceNew)
|
||||||
|
|
||||||
|
return numpy.array(facesNew).sum()
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,22 +9,6 @@ from numpy import pi, sqrt
|
|||||||
from .occExtended import *
|
from .occExtended import *
|
||||||
from . import Periodic
|
from . import Periodic
|
||||||
|
|
||||||
def reconstruct(solid):
|
|
||||||
solidNew = []
|
|
||||||
|
|
||||||
for face in solid.faces:
|
|
||||||
vertices = numpy.array([ v.p.pos() for v in face.vertices ])
|
|
||||||
# TODO: correct following vertices
|
|
||||||
vertices = numpy.unique(vertices, axis = 0)
|
|
||||||
|
|
||||||
circuit = Wire([ Segment(Pnt(*v1), Pnt(*v2)) for v1, v2 in zip(vertices, numpy.roll(vertices, -1, axis = 0)) ])
|
|
||||||
faceNew = Face(circuit)
|
|
||||||
faceNew.name = face.name
|
|
||||||
|
|
||||||
solidNew.append(faceNew)
|
|
||||||
|
|
||||||
return numpy.array(solidNew).sum()
|
|
||||||
|
|
||||||
|
|
||||||
class Simple(Periodic):
|
class Simple(Periodic):
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -147,18 +131,16 @@ class Simple(Periodic):
|
|||||||
inletface.name = "inlet"
|
inletface.name = "inlet"
|
||||||
|
|
||||||
vecFlow = self.normal(inletface)
|
vecFlow = self.normal(inletface)
|
||||||
# ISSUE: netgen.occ.Face.Extrude: the opposite face has the same name and normal vector as an initial face.
|
self.cell = inletface.Extrude(extr * Vec(*vecFlow))
|
||||||
self.cell = inletface.Extrude(extr)
|
#self.cell = reconstruct(self.cell)
|
||||||
self.cell = reconstruct(self.cell)
|
|
||||||
print([ f.name for f in self.cell.faces ])
|
|
||||||
# Boundaries
|
# Boundaries
|
||||||
symetryId = 0
|
symetryId = 0
|
||||||
|
|
||||||
for face in self.cell.faces:
|
for face in self.cell.faces:
|
||||||
fNorm = self.normal(face)
|
fNorm = self.normal(face)
|
||||||
fAngle = self.angle(vecFlow, fNorm)
|
fAngle = self.angle(vecFlow, fNorm)
|
||||||
print((face.center.pos() == inletface.center.pos()))
|
|
||||||
print(fAngle)
|
|
||||||
if fAngle == 0:
|
if fAngle == 0:
|
||||||
if (face.center.pos() == inletface.center.pos()).prod():
|
if (face.center.pos() == inletface.center.pos()).prod():
|
||||||
face.name = "inlet"
|
face.name = "inlet"
|
||||||
|
Loading…
Reference in New Issue
Block a user