...
 
Commits (2)
......@@ -109,35 +109,20 @@ class RootCap(object):
self.domain = Domain()
p = CoonsPatch(ni=self.patch_cons[0].ni, nj=self.patch_cons[3].ni, name='cap_base-0000')
p.add_edge(0, self.patch_cons[0].copy())
p.add_edge(1, self.patch_cons[2].copy())
p.add_edge(2, self.patch_cons[3].copy())
p.add_edge(3, self.patch_cons[1].copy())
p.update()
p = CoonsPatch(edge0=self.patch_cons[0].copy(), edge1=(self.patch_cons[2].copy()), edge2=(self.patch_cons[3].copy()), edge3=(self.patch_cons[1].copy()), name='cap_base-0000')
self.patches = []
self.patches.append(p)
p.P._flip_block()
self.domain.add_blocks(p.P.split(33))
p._flip_block()
self.domain.add_blocks(p.split(33))
for i in [0, 1]:
p = CoonsPatch(ni=self.collar_ps[i].ni, nj=self.base_cons[i].ni, name='cap-%04d' % i)
p.add_edge(0, self.collar_ps[i].copy())
p.add_edge(1, self.collar_ps[i+1].copy())
p.add_edge(2, self.base_cons[i].copy())
p.add_edge(3, self.patch_cons[i].copy())
p.update()
p.P._flip_block()
p = CoonsPatch(edge0=(self.collar_ps[i].copy()), edge1=(self.collar_ps[i+1].copy()), edge2=(self.base_cons[i].copy()), edge3=(self.patch_cons[i].copy()), name='cap-%04d' % i)
p._flip_block()
self.patches.append(p)
self.domain.add_blocks(p.P)
self.domain.add_blocks(p)
for i in [2, 3]:
p = CoonsPatch(ni=self.collar_ps[i+1].ni, nj=self.base_cons[i].ni, name='cap-%04d' % i)
p.add_edge(0, self.collar_ps[i+1])
p.add_edge(1, self.collar_ps[i])
p.add_edge(2, self.base_cons[i])
p.add_edge(3, self.patch_cons[i])
p.update()
p = CoonsPatch(edge0=self.collar_ps[i+1], edge1=self.collar_ps[i], edge2=self.base_cons[i], edge3=self.patch_cons[i], name='cap-%04d' % i)
self.patches.append(p)
self.domain.add_blocks(p.P)
self.domain.add_blocks(p)
if self.direction == -1:
self.domain.flip_all()
self.domain.join_blocks('cap-0000', 'cap-0001', newname='root')
......
This diff is collapsed.
......@@ -113,7 +113,7 @@ class CylinderMesh(Domain):
@n_cyl_per_bsize.setter
def n_cyl_per_bsize(self, val):
self._set_new_val("_n_cyl_per_bsize", val, "_n_cyl")
self._set_new_val("_n_cyl_per_bsize", val)
# cyl_dist
@property
......@@ -186,7 +186,7 @@ class CylinderMesh(Domain):
@n_outer_per_bsize.setter
def n_outer_per_bsize(self, val):
self._set_new_val("_n_outer_per_bsize", val, "_n_outer")
self._set_new_val("_n_outer_per_bsize", val)
# outer_dist
@property
......@@ -243,7 +243,7 @@ class CylinderMesh(Domain):
@n_up_per_bsize.setter
def n_up_per_bsize(self, val):
self._set_new_val("_n_up_per_bsize", val, "_n_up")
self._set_new_val("_n_up_per_bsize", val)
@property
def up_dist(self):
......@@ -290,7 +290,7 @@ class CylinderMesh(Domain):
@n_down_per_bsize.setter
def n_down_per_bsize(self, val):
self._set_new_val("_n_down_per_bsize", val, "_n_down")
self._set_new_val("_n_down_per_bsize", val)
@property
def down_dist(self):
......
......@@ -204,14 +204,9 @@ class CoonsNacelle(object):
self.collar_vs.append(self.collar_vs[0])
for i in range(8):
p = CoonsPatch(ni=self.collar_u0s[i].ni, nj=self.collar_vs[i].ni, name='hub_collar' + str(i))
p.add_edge(0, self.collar_u0s[i].copy())
p.add_edge(1, self.collar_u1s[i].copy())
p.add_edge(2, self.collar_vs[i].copy())
p.add_edge(3, self.collar_vs[i+1].copy())
p.update()
p = CoonsPatch(edge0=(self.collar_u0s[i].copy()), edge1=(self.collar_u1s[i].copy()), edge2=(self.collar_vs[i].copy()), edge3=(self.collar_vs[i+1].copy()), name='hub_collar' + str(i))
self.patches.append(p)
self.domain.add_blocks(p.P)
self.domain.add_blocks(p)
# hub base grid
# u - curves along the base of the hub
......@@ -266,23 +261,18 @@ class CoonsNacelle(object):
self.base_vs.append(self.base_vs[0])
for n in range(nb):
p = CoonsPatch(ni=self.base_u0s[n].ni, nj=self.base_vs[n].ni, name='hub_base' + str(n), interpolant='linear')
p.add_edge(0, self.base_u0s[n].copy())
p.add_edge(1, self.collar_u0s[n].copy())
p.add_edge(2, self.base_vs[n].copy())
p.add_edge(3, self.base_vs[n+1].copy())
p.update()
p = CoonsPatch(edge0=(self.base_u0s[n].copy()), edge1=(self.collar_u0s[n].copy()), edge2=(self.base_vs[n].copy()), edge3=(self.base_vs[n+1].copy()), name='hub_base' + str(n), interpolant='linear')
P = np.zeros(3)
for j in range(p.P.nj):
for i in range(p.P.ni):
P[0] = p.P.x[i, j, 0]
P[1] = p.P.y[i, j, 0]
P[2] = p.P.z[i, j, 0]
for j in range(p.nj):
for i in range(p.ni):
P[0] = p.x[i, j, 0]
P[1] = p.y[i, j, 0]
P[2] = p.z[i, j, 0]
P1 = self.correct_nacelle_surface(self.nacelle_curve, P)
p.P.y[i, j, 0] = P1[1]
p.P.z[i, j, 0] = P1[2]
p.y[i, j, 0] = P1[1]
p.z[i, j, 0] = P1[2]
self.patches.append(p)
self.domain.add_blocks(p.P)
self.domain.add_blocks(p)
def add_nacelle_dist_point(self, s, ds, index, x=None):
"""
......@@ -389,48 +379,23 @@ class CoonsNacelle(object):
l8 = Curve(points=self.cnu1.points.copy())
l8.points = l8.points[::-1]
p = CoonsPatch(ni=self.base_u0s[-1].ni, nj=self.cu0.ni, name='nacelle_front0')
p.add_edge(0, self.base_u0s[-1].copy())
p.add_edge(1, self.cv0.copy())
p.add_edge(2, self.cu0.copy())
p.add_edge(3, self.cu1.copy())
p.update()
p = CoonsPatch(edge0=(self.base_u0s[-1].copy()), edge1=(self.cv0.copy()), edge2=(self.cu0.copy()), edge3=(self.cu1.copy()), name='nacelle_front0')
self.patches.append(p)
self.domain.add_blocks(p.P)
p = CoonsPatch(ni=self.base_u0s[0].ni, nj=self.cu1.copy().ni, name='nacelle_front1')
p.add_edge(0, self.base_u0s[0].copy())
p.add_edge(1, self.cv1.copy())
p.add_edge(2, self.cu1.copy())
p.add_edge(3, self.cu2.copy())
p.update()
self.domain.add_blocks(p)
p = CoonsPatch(edge0=(self.base_u0s[0].copy()), edge1=(self.cv1.copy()), edge2=(self.cu1.copy()), edge3=(self.cu2.copy()), name='nacelle_front1')
self.patches.append(p)
self.domain.add_blocks(p.P)
p = CoonsPatch(ni=self.cnu0.ni, nj=l3.ni, name='nacelle_collar0')
p.add_edge(0, self.cnu0.copy())
p.add_edge(1, self.cv0.copy())
p.add_edge(2, l3.copy())
p.add_edge(3, l4.copy())
p.update()
self.domain.add_blocks(p)
p = CoonsPatch(edge0=(self.cnu0.copy()), edge1=(self.cv0.copy()), edge2=(l3.copy()), edge3=(l4.copy()), name='nacelle_collar0')
self.patches.append(p)
self.domain.add_blocks(p.P)
p = CoonsPatch(ni=self.cnu1.ni, nj=l4.ni, name='nacelle_collar1')
p.add_edge(0, self.cnu1.copy())
p.add_edge(1, self.cv1.copy())
p.add_edge(2, l4.copy())
p.add_edge(3, l5.copy())
p.update()
self.domain.add_blocks(p)
p = CoonsPatch(edge0=(self.cnu1.copy()), edge1=(self.cv1.copy()), edge2=(l4.copy()), edge3=(l5.copy()), name='nacelle_collar1')
self.patches.append(p)
self.domain.add_blocks(p.P)
p = CoonsPatch(ni=l7.ni, nj=l6.ni, name='nacelle_rear')
p.add_edge(0, l7.copy())
p.add_edge(1, self.cnu0.copy())
p.add_edge(2, l6.copy())
p.add_edge(3, l8.copy())
p.update()
self.domain.add_blocks(p)
p = CoonsPatch(edge0=(l7.copy()), edge1=(self.cnu0.copy()), edge2=(l6.copy()), edge3=(l8.copy()), name='nacelle_rear')
self.patches.append(p)
self.domain.add_blocks(p.P)
self.domain.add_blocks(p)
def build_spinner(self):
......@@ -483,62 +448,47 @@ class CoonsNacelle(object):
self.spinner_cons.append(cu1)
self.spinner_cons.append(cu2)
p = CoonsPatch(ni=cv0s[1].ni, nj=cv1s[1].ni, name='spinner_tip')
p.add_edge(0, cv0s[1].copy())
p.add_edge(1, cu2.copy())
p.add_edge(2, cv1s[1].copy())
p.add_edge(3, cu1.copy())
p.update()
p = CoonsPatch(edge0=(cv0s[1].copy()), edge1=(cu2.copy()), edge2=(cv1s[1].copy()), edge3=(cu1.copy()), name='spinner_tip')
self.patches.append(p)
P = np.zeros(3)
for j in range(1, p.P.nj-1):
for i in range(1, p.P.ni-1):
P[0] = p.P.x[i, j, 0]
P[1] = p.P.y[i, j, 0]
P[2] = p.P.z[i, j, 0]
for j in range(1, p.nj-1):
for i in range(1, p.ni-1):
P[0] = p.x[i, j, 0]
P[1] = p.y[i, j, 0]
P[2] = p.z[i, j, 0]
P1 = self.correct_spinner_surface(self.spinner_curve, P)
p.P.y[i, j, 0] = P1[1]
p.P.z[i, j, 0] = P1[2]
self.domain.add_blocks(p.P)
p.y[i, j, 0] = P1[1]
p.z[i, j, 0] = P1[2]
self.domain.add_blocks(p)
cbase0 = Curve(points=self.base_u0s[4].points.copy())
cbase0.points = cbase0.points[::-1]
p = CoonsPatch(ni=cbase0.ni, nj=cv0s[0].ni, name='spinner_base0')
p.add_edge(0, cbase0.copy())
p.add_edge(1, cu1.copy())
p.add_edge(2, cv0s[0].copy())
p.add_edge(3, cvm0.copy())
p.update()
p = CoonsPatch(edge0=(cbase0.copy()), edge1=(cu1.copy()), edge2=(cv0s[0].copy()), edge3=(cvm0.copy()), name='spinner_base0')
self.patches.append(p)
P = np.zeros(3)
for j in range(1, p.P.nj-1):
for i in range(1, p.P.ni-1):
P[0] = p.P.x[i, j, 0]
P[1] = p.P.y[i, j, 0]
P[2] = p.P.z[i, j, 0]
for j in range(1, p.nj-1):
for i in range(1, p.ni-1):
P[0] = p.x[i, j, 0]
P[1] = p.y[i, j, 0]
P[2] = p.z[i, j, 0]
P1 = self.correct_spinner_surface(self.spinner_curve, P)
p.P.y[i, j, 0] = P1[1]
p.P.z[i, j, 0] = P1[2]
self.domain.add_blocks(p.P)
p = CoonsPatch(ni=cv1s[0].ni, nj=self.base_u0s[3].ni, name='spinner_base1')
p.add_edge(0, cv1s[0].copy())
p.add_edge(1, cvm0.copy())
p.add_edge(2, self.base_u0s[3].copy())
p.add_edge(3, cu2.copy())
p.update()
p.y[i, j, 0] = P1[1]
p.z[i, j, 0] = P1[2]
self.domain.add_blocks(p)
p = CoonsPatch(edge0=(cv1s[0].copy()), edge1=(cvm0.copy()), edge2=(self.base_u0s[3].copy()), edge3=(cu2.copy()), name='spinner_base1')
self.patches.append(p)
P = np.zeros(3)
for j in range(1, p.P.nj-1):
for i in range(1, p.P.ni-1):
P[0] = p.P.x[i, j, 0]
P[1] = p.P.y[i, j, 0]
P[2] = p.P.z[i, j, 0]
for j in range(1, p.nj-1):
for i in range(1, p.ni-1):
P[0] = p.x[i, j, 0]
P[1] = p.y[i, j, 0]
P[2] = p.z[i, j, 0]
P1 = self.correct_spinner_surface(self.spinner_curve, P)
p.P.y[i, j, 0] = P1[1]
p.P.z[i, j, 0] = P1[2]
self.domain.add_blocks(p.P)
p.y[i, j, 0] = P1[1]
p.z[i, j, 0] = P1[2]
self.domain.add_blocks(p)
def compute_cylinder_intersection(self, b, P0, P1, ni):
"""
......
......@@ -188,13 +188,8 @@ class VGMesher(PGLMesher):
u1 = Curve(self.domain.blocks['af0'].get_edge(0))
v0 = Line(u0.points[0], u1.points[0], self.nte)
v1 = Line(u0.points[-1], u1.points[-1], self.nte)
p = CoonsPatch(self.bsize, self.nte)
p.add_edge(0, u0)
p.add_edge(1, u1)
p.add_edge(2, v0)
p.add_edge(3, v1)
p.update()
ds = p.P.jsplit((self.nte+1)//2)
p = CoonsPatch(edge0=u0, edge1=u1, edge2=v0, edge3=v1)
ds = p.jsplit((self.nte+1)//2)
self.domain.add_blocks(ds[0], ['airfoilTEu'])
self.domain.add_blocks(ds[1], ['airfoilTEl'])
self.domain.join_blocks('airfoilTEl', 'af0')
......
This diff is collapsed.
......@@ -18,8 +18,8 @@ class CoonsPatch(Block):
---------------------------
edge0
"""
def __init__(self, ni=None, nj=None, edge0=None, edge1=None, edge2=None, edge3=None, name="coons",
interpolant="linear", edge_check=True, rtol_edges=1e5, atol_edges=1e-8):
def __init__(self, edge0=None, edge1=None, edge2=None, edge3=None, name="coons",
interpolant="linear", edge_check=True, rtol_edges=1e5, atol_edges=1e-8, ni=None, nj=None):
# Common parameters to both old and new construction style
self._name = name
......@@ -32,11 +32,15 @@ class CoonsPatch(Block):
self._atol_edges = atol_edges
if (ni is not None) or (nj is not None): # Old construction style
warnings.warn("Coons-Patch: The use of ni and nj arguments is depreciated, and they will be removed in "
"future versions, ni and nj is inferred from edge0/egde1 and edge2/edge3 respectively",
if (isinstance(edge0, int) or isinstance(edge1, int)) or ((ni is not None) or (nj is not None)): # Old construction style
warnings.warn("Coons-Patch: The use of interger arguments for edge0 and edge1 indicates that the old style "
"CoonsPatch is used (later using add_edge to append edges). The new style CoonsPatch uses "
"edges at initilazation. See more in Coons-Patch documentation",
PendingDeprecationWarning, stacklevel=2)
x = np.ones([ni * nj, 3])
if isinstance(edge0, int) or isinstance(edge1, int):
x = np.ones([edge0 * edge1, 3])
else:
x = np.ones([ni * nj, 3])
y = np.ones_like(x)
z = np.ones_like(x)
super(CoonsPatch, self).__init__(x=x, y=y, z=z, name=self._name)
......@@ -166,7 +170,7 @@ class CoonsPatch(Block):
def P(self):
warnings.warn("Coons-Patch: Use of P attribute is depreciated. Coons-Patch is now a child-class of Block so "
"block attributes should be used directly",
PendingDeprecationWarning)
PendingDeprecationWarning, stacklevel=2)
return self
def print_edge_connetivity(self):
......
......@@ -83,11 +83,7 @@ class CoonsExtrusion(object):
# create patches
self.patches = []
for i in range(self.np * 2):
p = CoonsPatch(self.c0[i].ni, self.cs[i].ni, interpolant=self.interpolant)
p.add_edge(0, self.c0[i])
p.add_edge(1, self.c1[i])
p.add_edge(2, self.cs[i])
p.add_edge(3, self.cs[i + 1])
p = CoonsPatch(edge0=self.c0[i], edge1=self.c1[i], edge2=self.cs[i], edge3=self.cs[i + 1], interpolant=self.interpolant)
self.patches.append(p)
def update_patches(self):
......@@ -95,7 +91,7 @@ class CoonsExtrusion(object):
self.domain = Domain()
for p in self.patches:
p.update()
self.domain.add_blocks(p.P)
self.domain.add_blocks(p)
for i in range(1, self.np * 2):
self.domain.join_blocks('coons-%04d'%i, 'coons', newname='coons')
......@@ -126,12 +122,12 @@ class CoonsExtrusion(object):
self.cs[i].redistribute(dist=self.cs[i].dist)
elif edge == 1:
for i in range(self.np * 2 + 1):
if sdir == 'z':
if isinstance(sdir, str) and sdir == 'z':
self.cs[i].CPs[-2][:2] = self.cs[i].CPs[-1][:2]
elif sdir == 'y':
elif isinstance(sdir, str) and sdir == 'y':
self.cs[i].CPs[-2][0] = self.cs[i].CPs[-1][0]
self.cs[i].CPs[-2][2] = self.cs[i].CPs[-1][2]
elif sdir == 'x':
elif isinstance(sdir, str) and sdir == 'x':
self.cs[i].CPs[-2][1] = self.cs[i].CPs[-1][1]
self.cs[i].CPs[-2][2] = self.cs[i].CPs[-1][2]
elif isinstance(sdir, np.ndarray):
......
......@@ -44,7 +44,7 @@ class NaturalCubicSpline(object):
# l[-1] = 0.0
# solve for second derivatives
fpp = solve_banded((1, 1), np.matrix([u, d, l]), b)
fpp = solve_banded((1, 1), np.array([u, d, l]), b)
self.fpp = np.concatenate([[0.0], fpp, [0.0]]) # natural spline
self.xp = xp
self.yp = yp
......
This diff is collapsed.