Commit b883ce5a authored by Ashwin V. Mohanan's avatar Ashwin V. Mohanan
Browse files

Add skew symmetric form for Burgers equation

parent 8323323e0aa8
"""Burgers 1D solver skew-symmteric form (:mod:`fluidsim.solvers.burgers1d.skew_sym`)
=====================================================================================
Provides:
.. autosummary::
:toctree:
solver
"""
"""Burgers1D solver (:mod:`fluidsim.solvers.burgers1d.skew_sym.solver`)
=======================================================================
Provides:
.. autoclass:: Simul
:members:
:private-members:
"""
from fluidsim.base.setofvariables import SetOfVariables
from ..solver import Simul as SimulBurgers
class Simul(SimulBurgers):
def tendencies_nonlin(self, state_spect=None, old=None):
if state_spect is None:
u_fft = self.state.state_spect.get_var("u_fft")
signal = self.state.state_phys.get_var("u")
else:
u_fft = state_spect.get_var("u_fft")
signal = self.oper.ifft(u_fft)
pxu_fft = self.oper.pxffft_from_fft(u_fft)
pxu = self.oper.ifft(pxu_fft)
# Half from convective form (in physical space)
f_signal = -0.5 * signal * pxu
# Half from conservative form (in spectral space)
f_fft_cons = -0.25 * self.oper.pxffft_from_fft(self.oper.fft(signal ** 2))
if old is None:
tendencies_fft = SetOfVariables(
like=self.state.state_spect, info="tendencies_nonlin"
)
else:
tendencies_fft = old
f_fft = tendencies_fft.get_var("u_fft")
self.oper.fft_as_arg(f_signal, f_fft)
# Add the conservative form part to yield the skew symmetric form
f_fft[:] += f_fft_cons
self.oper.dealiasing(f_fft)
return tendencies_fft
import unittest
from fluiddyn.util import mpi
from fluidsim.util.testing import skip_if_no_fluidfft
from fluidsim.solvers.burgers1d.test_solver import TestSolverSquare1D
from fluidsim.solvers.burgers1d.skew_sym.solver import Simul
@skip_if_no_fluidfft
class TestSolverSkewSym1D(TestSolverSquare1D):
Simul = Simul
@classmethod
def init_params(cls):
params = cls.params = cls.Simul.create_default_params()
params.short_name_type_run = "test"
params.output.sub_directory = "unittests"
params.oper.nx = 40
params.oper.Lx = 1.0
params.time_stepping.type_time_scheme = "RK2"
params.nu_2 = 0.01
params.time_stepping.t_end = 0.4
params.time_stepping.USE_CFL = False
params.init_fields.type = "gaussian"
params.output.periods_print.print_stdout = 0.25
params.output.periods_save.phys_fields = 0.5
params.output.periods_plot.phys_fields = 0.0
params.output.phys_fields.field_to_plot = "u"
@unittest.skipIf(
mpi.nb_proc > 1, "MPI not implemented, for eg. sim.oper.gather_Xspace"
)
def test_simul(self):
sim = self.sim
sim.time_stepping.start()
import unittest
from .solver import Simul
from fluidsim.solvers.burgers1d.solver import Simul
from fluiddyn.util import mpi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment