@@ -58,7 +58,8 @@ def __init__(
5858 BCs = None ,
5959 dealiasing = 3 / 2 ,
6060 comm = None ,
61- Lx = 8 ,
61+ Lx = 4 ,
62+ Lz = 1 ,
6263 ** kwargs ,
6364 ):
6465 """
@@ -77,7 +78,7 @@ def __init__(
7778 BCs = {} if BCs is None else BCs
7879 BCs = {
7980 'T_top' : 0 ,
80- 'T_bottom' : 2 ,
81+ 'T_bottom' : 1 ,
8182 'v_top' : 0 ,
8283 'v_bottom' : 0 ,
8384 'u_top' : 0 ,
@@ -101,11 +102,15 @@ def __init__(
101102 'dealiasing' ,
102103 'comm' ,
103104 'Lx' ,
105+ 'Lz' ,
104106 localVars = locals (),
105107 readOnly = True ,
106108 )
107109
108- bases = [{'base' : 'fft' , 'N' : nx , 'x0' : 0 , 'x1' : self .Lx }, {'base' : 'ultraspherical' , 'N' : nz }]
110+ bases = [
111+ {'base' : 'fft' , 'N' : nx , 'x0' : 0 , 'x1' : self .Lx },
112+ {'base' : 'ultraspherical' , 'N' : nz , 'x0' : 0 , 'x1' : self .Lz },
113+ ]
109114 components = ['u' , 'v' , 'T' , 'p' ]
110115 super ().__init__ (bases , components , comm = comm , ** kwargs )
111116
@@ -370,12 +375,13 @@ def compute_vorticity(self, u):
370375 u_hat = u .copy ()
371376 else :
372377 u_hat = self .transform (u )
378+
373379 Dz = self .Dz
374380 Dx = self .Dx
375381 iu , iv = self .index (['u' , 'v' ])
376382
377383 vorticity_hat = self .spectral .u_init_forward
378- vorticity_hat [0 ] = (Dx * u_hat [iv ].flatten () + Dz @ u_hat [iu ].flatten ()).reshape (u [iu ].shape )
384+ vorticity_hat [0 ] = (Dx * u_hat [iv ].flatten () + Dz @ u_hat [iu ].flatten ()).reshape (u_hat [iu ].shape )
379385 return self .itransform (vorticity_hat )[0 ].real
380386
381387 def getOutputFile (self , fileName ):
@@ -418,14 +424,14 @@ def compute_Nusselt_numbers(self, u):
418424 dict: Nusselt number averaged over the entire volume and horizontally averaged at the top and bottom.
419425 """
420426 iv , iT = self .index (['v' , 'T' ])
421-
422- DzT_hat = self .spectral .u_init_forward
427+ zAxis = self .spectral .axes [- 1 ]
423428
424429 if self .spectral_space :
425430 u_hat = u .copy ()
426431 else :
427432 u_hat = self .transform (u )
428433
434+ DzT_hat = self .spectral .u_init_forward
429435 DzT_hat [iT ] = (self .Dz @ u_hat [iT ].flatten ()).reshape (DzT_hat [iT ].shape )
430436
431437 # compute vT with dealiasing
@@ -435,21 +441,25 @@ def compute_Nusselt_numbers(self, u):
435441 _me [0 ] = u_pad [iv ] * u_pad [iT ]
436442 vT_hat = self .transform (_me , padding = padding )[0 ]
437443
438- # nusselt_hat = (vT_hat - DzT_hat[iT]) / self.nx
444+ if not hasattr (self , '_zInt' ):
445+ self ._zInt = zAxis .get_integration_matrix ()
446+
439447 nusselt_hat = (vT_hat / self .kappa - DzT_hat ) * self .axes [- 1 ].L
440448
441- integral_z = self .xp .sum (nusselt_hat * self .spectral .axes [1 ].get_BC (kind = 'integral' ), axis = - 1 ).real
442- integral_V = (
443- integral_z [0 ] * self .axes [0 ].L
444- ) # only the first Fourier mode has non-zero integral with periodic BCs
445- Nusselt_V = self .comm .bcast (integral_V / self .spectral .V , root = 0 )
449+ # get coefficients for evaluation on the boundary
450+ top = zAxis .get_BC (kind = 'Dirichlet' , x = 1 )
451+ bot = zAxis .get_BC (kind = 'Dirichlet' , x = - 1 )
446452
447- Nusselt_t = self .comm .bcast (
448- self .xp .sum (nusselt_hat * self .spectral .axes [1 ].get_BC (kind = 'Dirichlet' , x = 1 ), axis = - 1 ).real [0 ], root = 0
449- )
450- Nusselt_b = self .comm .bcast (
451- self .xp .sum (nusselt_hat * self .spectral .axes [1 ].get_BC (kind = 'Dirichlet' , x = - 1 ), axis = - 1 ).real [0 ], root = 0
452- )
453+ integral_V = 0
454+ if self .comm .rank == 0 :
455+
456+ integral_z = (self ._zInt @ nusselt_hat [0 , 0 ]).real
457+ integral_z [0 ] = zAxis .get_integration_constant (integral_z , axis = - 1 )
458+ integral_V = ((top - bot ) * integral_z ).sum () * self .axes [0 ].L / self .nx
459+
460+ Nusselt_V = self .comm .bcast (integral_V / self .spectral .V , root = 0 )
461+ Nusselt_t = self .comm .bcast (self .xp .sum (nusselt_hat .real [0 , 0 ] * top , axis = - 1 ) / self .nx , root = 0 )
462+ Nusselt_b = self .comm .bcast (self .xp .sum (nusselt_hat .real [0 , 0 ] * bot , axis = - 1 ) / self .nx , root = 0 )
453463
454464 return {
455465 'V' : Nusselt_V ,
0 commit comments