Skip to content
Snippets Groups Projects
Commit e33e4aac authored by Jean-Baptiste Keck's avatar Jean-Baptiste Keck
Browse files

3D periodic jet with levelset

parent 1c66eb32
No related branches found
No related tags found
1 merge request!10Resolve "Fix default parameters for the periodic bubble example"
Pipeline #
...@@ -21,11 +21,11 @@ def init_rho(data, coords): ...@@ -21,11 +21,11 @@ def init_rho(data, coords):
def init_phi(data, coords, L): def init_phi(data, coords, L):
phi = data[0] phi = data[0]
phi[...] = np.inf phi[...] = np.inf
Di = np.empty_like(phi) Di = np.ones_like(phi)
X,Y = coords X,Y = coords[:2]
Ly, Lx = L Ly, Lx = L[:2]
R = Lx*(0.15 - 0.05*np.sin(2*np.pi*Y/Ly) + 0.001*np.cos(2*np.pi*10*Y/Ly)) R = Lx*(0.15 - 0.05*np.sin(2*np.pi*Y/Ly) + 0.001*np.cos(2*np.pi*10*Y/Ly))
Di[...] = (X-0.5*Lx)**2 - R**2 Di[...] *= (X-0.5*Lx)**2 - R**2
mask = (np.abs(Di)<np.abs(phi)) mask = (np.abs(Di)<np.abs(phi))
phi[mask] = Di[mask] phi[mask] = Di[mask]
assert np.isfinite(phi).all() assert np.isfinite(phi).all()
...@@ -148,10 +148,32 @@ def compute(args): ...@@ -148,10 +148,32 @@ def compute(args):
diffuse = DirectionalDiffusion(implementation=impl, diffuse = DirectionalDiffusion(implementation=impl,
name='diffuse_{}'.format(vorti.name), name='diffuse_{}'.format(vorti.name),
pretty_name=u'D{}'.format(vorti.pretty_name.decode('utf-8')), pretty_name=u'D{}'.format(vorti.pretty_name.decode('utf-8')),
coeffs = (args.mu, args.mu/10.0), coeffs = (args.mu/10.0,),
fields = (vorti, phi), fields = (phi,),
variables = {vorti: npts , phi: npts}, variables = {vorti: npts , phi: npts},
dt=dt, **extra_op_kwds) dt=dt, **extra_op_kwds)
#> Directional stretching + diffusion
if (dim==3):
stretch_diffuse = DirectionalStretchingDiffusion(implementation=impl,
name='stretch_diffuse',
pretty_name=u'SD{}'.format(vorti.pretty_name.decode('utf-8')),
formulation = args.stretching_formulation,
viscosity = args.mu,
velocity = velo,
vorticity = vorti,
variables = {velo: npts, vorti: npts},
dt=dt, **extra_op_kwds)
elif (dim==2):
stretch_diffuse = DirectionalDiffusion(implementation=impl,
name='diffuse_{}'.format(vorti.name),
pretty_name=u'D{}'.format(vorti.pretty_name.decode('utf-8')),
coeffs = args.mu,
fields = vorti,
variables = {vorti: npts},
dt=dt, **extra_op_kwds)
else:
msg='Unsupported dimension {}.'.format(dim)
raise RuntimeError(msg)
#> External force rot(-rho*g) #> External force rot(-rho*g)
Fext = np.zeros(shape=(dim,), dtype=object).view(SymbolicTensor) Fext = np.zeros(shape=(dim,), dtype=object).view(SymbolicTensor)
...@@ -169,7 +191,7 @@ def compute(args): ...@@ -169,7 +191,7 @@ def compute(args):
#> Directional splitting operator subgraph #> Directional splitting operator subgraph
splitting = StrangSplitting(splitting_dim=dim, order=args.strang_order) splitting = StrangSplitting(splitting_dim=dim, order=args.strang_order)
splitting.push_operators(advec, diffuse, eval_fields, external_force) splitting.push_operators(advec, diffuse, stretch_diffuse, eval_fields, external_force)
### Build standard operators ### Build standard operators
#> Poisson operator to recover the velocity from the vorticity #> Poisson operator to recover the velocity from the vorticity
...@@ -310,8 +332,8 @@ if __name__=='__main__': ...@@ -310,8 +332,8 @@ if __name__=='__main__':
def _setup_parameters(self, args): def _setup_parameters(self, args):
dim = args.ndim dim = args.ndim
if (dim not in (2,)): if (dim not in (2,3)):
msg='Domain should be 2D.' msg='Domain should be 2D or 3D.'
self.error(msg) self.error(msg)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment