@@ -90,10 +90,10 @@ def __init__(self,
90
90
self .TD = TensorProductSpace (comm , (self .D0 , self .F1 ), modify_spaces_inplace = True ) # Streamwise velocity
91
91
self .TC = TensorProductSpace (comm , (self .C0 , self .F1 ), modify_spaces_inplace = True ) # No bc
92
92
self .BD = VectorSpace ([self .TB , self .TD ]) # Velocity vector space
93
- self .CD = VectorSpace (self .TD ) # Dirichlet vector space
93
+ self .CD = VectorSpace (self .TC ) # Dirichlet vector space
94
94
95
95
# Padded space for dealiasing
96
- self .TDp = self .TD .get_dealiased (padding_factor )
96
+ self .TDp = self .TC .get_dealiased (padding_factor )
97
97
98
98
self .u_ = Function (self .BD ) # Velocity vector solution
99
99
self .H_ = Function (self .CD ) # convection
@@ -110,9 +110,9 @@ def __init__(self,
110
110
# Classes for fast projections. All are not used except if self.conv=0
111
111
self .dudx = Project (Dx (self .u_ [0 ], 0 , 1 ), self .TD )
112
112
if self .conv == 0 :
113
- self .dudy = Project (Dx (self .u_ [0 ], 1 , 1 ), self .TB )
113
+ self .dudy = Project (Dx (self .u_ [0 ], 1 , 1 ), self .TC )
114
114
self .dvdx = Project (Dx (self .u_ [1 ], 0 , 1 ), self .TC )
115
- self .dvdy = Project (Dx (self .u_ [1 ], 1 , 1 ), self .TD )
115
+ self .dvdy = Project (Dx (self .u_ [1 ], 1 , 1 ), self .TC )
116
116
117
117
self .curl = Project (curl (self .u_ ), self .TC )
118
118
self .divu = Project (div (self .u_ ), self .TD )
@@ -130,8 +130,8 @@ def __init__(self,
130
130
v = TestFunction (self .TB )
131
131
132
132
# Chebyshev matrices are not sparse, so need a tailored solver. Legendre has simply 5 nonzero diagonals and can use generic solvers.
133
- # sol1 = chebyshev.la.Biharmonic if self.B0.family() == 'chebyshev' else la.SolverGeneric1ND
134
- sol1 = la .SolverGeneric1ND
133
+ sol1 = chebyshev .la .Biharmonic if self .B0 .family () == 'chebyshev' else la .SolverGeneric1ND
134
+ # sol1 = la.SolverGeneric1ND
135
135
136
136
self .pdes = {
137
137
@@ -151,7 +151,7 @@ def __init__(self,
151
151
# v. Momentum equation for Fourier wavenumber 0
152
152
if comm .Get_rank () == 0 :
153
153
v0 = TestFunction (self .D00 )
154
- self .h1 = Function (self .D00 ) # Copy from H_[1, :, 0, 0] (cannot use view since not contiguous)
154
+ self .h1 = Function (self .C00 ) # Copy from H_[1, :, 0, 0] (cannot use view since not contiguous)
155
155
source = Array (self .C00 )
156
156
source [:] = - self .dpdy # dpdy set by subclass
157
157
sol = chebyshev .la .Helmholtz if self .B0 .family () == 'chebyshev' else la .Solver
@@ -164,13 +164,14 @@ def __init__(self,
164
164
solver = sol ,
165
165
latex = r"\frac{\partial v}{\partial t} = \nu \frac{\partial^2 v}{\partial x^2} - N_y - \frac{\partial p}{\partial y}" ),
166
166
}
167
-
168
- def convection (self ):
167
+
168
+ def convection (self , rk ):
169
169
H = self .H_ .v
170
170
self .up = self .u_ .backward (padding_factor = self .padding_factor )
171
171
up = self .up .v
172
172
if self .conv == 0 :
173
- dudxp = self .dudx ().backward (padding_factor = self .padding_factor ).v
173
+ dudx = self .dudx () if rk == 0 else self .dudx .output_array
174
+ dudxp = dudx .backward (padding_factor = self .padding_factor ).v
174
175
dudyp = self .dudy ().backward (padding_factor = self .padding_factor ).v
175
176
dvdxp = self .dvdx ().backward (padding_factor = self .padding_factor ).v
176
177
dvdyp = self .dvdy ().backward (padding_factor = self .padding_factor ).v
@@ -192,7 +193,7 @@ def compute_v(self, rk):
192
193
193
194
# Find velocity components v from div. constraint
194
195
u [1 ] = 1j * self .dudx ()/ self .K [1 ]
195
-
196
+
196
197
# Still have to compute for wavenumber = 0, 0
197
198
if comm .Get_rank () == 0 :
198
199
# v component
@@ -206,7 +207,6 @@ def compute_pressure(self):
206
207
self .d2udx2 = Project (self .nu * Dx (self .u_ [0 ], 0 , 2 ), self .TC )
207
208
N0 = self .N0 = FunctionSpace (self .N [0 ], self .B0 .family (), bc = {'left' : {'N' : self .d2udx2 ()}, 'right' : {'N' : self .d2udx2 ()}})
208
209
TN = self .TN = TensorProductSpace (comm , (N0 , self .F1 ), modify_spaces_inplace = True )
209
- #sol = chebyshev.la.Helmholtz if self.B0.family() == 'chebyshev' else la.SolverGeneric1ND
210
210
sol = la .SolverGeneric1ND
211
211
self .divH = Inner (TestFunction (TN ), - div (self .H_ ))
212
212
self .solP = sol (inner (TestFunction (TN ), div (grad (TrialFunction (TN )))))
@@ -251,15 +251,15 @@ def tofile(self, tstep):
251
251
self .file_u .write (tstep , {'u' : [self .u_ .backward (mesh = 'uniform' )]}, as_scalar = True )
252
252
253
253
def prepare_step (self , rk ):
254
- self .convection ()
254
+ self .convection (rk )
255
255
256
256
def assemble (self ):
257
257
for pde in self .pdes .values ():
258
258
pde .assemble ()
259
259
if comm .Get_rank () == 0 :
260
260
for pde in self .pdes1d .values ():
261
261
pde .assemble ()
262
-
262
+
263
263
def solve (self , t = 0 , tstep = 0 , end_time = 1000 ):
264
264
self .assemble ()
265
265
while t < end_time - 1e-8 :
0 commit comments