-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add passive scalars #263
Add passive scalars #263
Conversation
…teScalars add s1, s2 memory register members of PassiveScalars
Also use AddTask() for the NSCALARS > 0 case in the TimeIntegratorTaskList ctor.
Coordinates::CoordSrcTerms -> AddCoordTermsDivergence Hydro:: and Scalars::AddFluxDivergenceToAverage -> AddFluxDivergence (may rename to AddPhysicalFluxDivergence or AddQuantityFluxDivergence to explicitly distinguish from CoordTerms) (may rename to AddHydroFluxDivergence and AddScalarsFluxDivergence, if the implementations remain completely independent / no inheritance is used) See discussion: e3638f1
Declaring these implementations as function overloads of current Reconstruction class public members, for now. Ideally, these can be combined with the original functions to obey DRY principle. Would need to: - Replace NHYDRO and NWAVE by inferred nu=GetDim4()-1 and nu+2 (when MHD is active), respectively, as in the new "simple" variants - Extract initial step of loading from AthenaArray<Real> w, bcc inputs (when MHD is active) into generic combined "q", etc. scratch arrays. - Make it possible to pass only a single AthenaArray, or even separate Real variables? for shearing box, GR-RT, 4th order MHD face field reconstructions, etc. - Generalize Reconstruction::characteristic_reconstruction switch to a local copy so that it is always disabled if non-Hydro/MHD overload is invoked.
This is horrible, but necessary to prevent stalling / deadlock. Thoughts @tomidakn?
1x per scalar species / 3D array
…tput Might not be useful depending on the exact formulation of "s"
retest this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If STS is not enabled with passive scalar diffusion, we need a trap there. Also, as diffusion in hydrodynamics and in passive scalar can be different, there is a possible case where we may want to use STS for some physics and normal integrator for other physics.
As the passive scalar flux is always associated with the mass flux in hydrodynamics, technically it is possible to merge the computation and the boundary communication to hydrodynamics. For the computation (flux and divergence), I think it is better to keep them separate, mostly for the general execution model. But for the communication, you may save the MPI messages (and the tasks) if we combine the hydro and scalar communication. On the other hand, if we do so, we may lose the opportunity of computation-communication overlapping. I think the current implementation is fine, but just want to leave my comments here.
Somehow the multigrid boundary failed on Travis (Mac+Clang+OpenMPI) . Is this reproducible? And is it related to the change in the boundary?
Last but not least, Documentation must be updated.
Pass k,j,i even though x1 slices are the target arrays to enable position-dependent floors in the future.
|
CALC_SCLRFLX should only depend on DIFFUSE_SCLR if STS is NOT active. Also, skip INT_FLD in both task lists if fluid is set to background.
👍 🎉 |
Description
WIP. Closes #152.
Despite the discussions in that Issue, @jmstone, @tomidakn, and I decided to postpone acting on any algorithmic decisions for passive scalars in this pull request. Coming out of the UNLV Developer's Meeting, we have been uncertain about a couple of aspects:
AthenaArray<Real> s(NSCALARS, k, j, i)
as a relative concentration strictly in [0,1]? Or could we use an alternative formulation?Therefore, I have implemented only the simplest interpretation of passive scalars, whereby their fluxes are computed in
scalars/calculate_scalar_fluxes.cpp
by:sl_, sr_
face states along each directionHydro::flux[X1DIR]
is used to selects_upwind=
eithersl_
orsr_
and then it weights the flux by:Currently, there are no variable floors nor renormalization steps for the passive scalar integration. I was hoping that @jdolence and @pdmullen could weigh in with some of their hard-earned insights on these algorithmic choices. Patrick assures me that a new multimaterials implementation could easily be built on top of this branch by 1) adding user-defined source terms for volume fractions and 2) extending the
EquationOfState
class to allow the EOS to be dependent on volume fractions.In order to get my passive scalar slotted cylinder test to work, I needed to partially address #247, the ability to turn off fluid evolution. I took the approach I outlined in #247 (comment)
and added
to my 2x
hydro/athinput.slotted_cylinder2d*
input files. This switch is stored as apublic
constant i theMesh
class, and its default value istrue
. The other future option would befalse
ordisabled
(for an empty/dummy/nonexistentHydro
class). Since we still need the Hydro fluxes for the passive scalar fluxes, the only things thatbackground
disables intime_integrator.cpp
are the following function calls (inside the task functions, not in the task list construction):AddFluxDivergence()
AddCoordTermsDivergence()
AddSourceTermsHydro()
DiffuseHydro()
@tomidakn, I could use your input on this feature.
I haven't touched STS, etc. other task lists.Testing and validation
Passive scalar advection of a slotted cylinder profile with AMR (RK3+PPM):
![slotted_cylinder_AMR-86](https://user-images.githubusercontent.com/1410981/56783225-a9af6b80-67b8-11e9-9f15-ac286bb3b115.png)
![slotted_cylinder_AMR-zoom-86](https://user-images.githubusercontent.com/1410981/56783230-addb8900-67b8-11e9-9c63-eef84a059a18.png)
To-do
slotted_cylinder.cpp
. My original forked version used a copy of the 2x files from this open-source library: http://www.holoborodko.com/pavel/numerical-methods/numerical-integration/ .gsl/gintegration/glfixed.c
under GPLv3.gauss_legendre.cpp
,gauss_legendre.hpp
insrc/utils/
. The code provides:n
n
ingauss_legendre_tbl()
gauss_legendre()
for 1D andgauss_legendre_2D_cube
,utils/
for helping problem generators, like B-field initialization via a user-provided vector potential (including correction for SMR/AMR, etc.).slotted_cylinder.cpp
. ImplementMesh::UserWorkAfterLoop
to calculate errors likelinear_wave.cpp
(accounting forpmb->precon->correct_err
switch).correct_err
support and repeat calculation of GL quadrature-based initial condition. Max error increases for as the mesh is resolved given the default, unrefined input parameters.calculate_scalar_fluxes.cpp
totime/xorder=4
hydro/calculate_fluxes.cpp
could probably be improved.inputs/
subfolder (nothydro/
) for zero-fluid or background-fluid input files?PassiveScalars
and call them in:calculate_scalar_fluxes.cpp
for the reconstructed states (definitely PPM, but also PLM?)eos/
for the cell-centered scalarstst/regression/scripts/tests/scalars/
regression tests:analyze()
conditions should be, but we need to make sure things at least compile and run without problems.reconstruct/*_simple.cpp
with original*.cpp
reconstruction functions in a same way that is extensible to other uses.output[N]/variable = s[M], r[M]
hydro/active = true, background, disabled
,problem/nu_scalar_iso
,hydro/sfloor
(haven't added this)TimeIntegratorTaskList
ctor with conditionals that prevent deadlocking with MPI. See discussion: 742ec3fHydro
andPassiveScalars
classes into an inheritance hierarchy (that would accommodate future derived classes likeChemicalSpecies
, e.g.).Hydro
is very nearly a proper superset ofPassiveScalars
, includingadd_flux_divergence.cpp
andcalculate_fluxes.cpp
, once theRiemannSolver()
and flooring routines are abstracted.PassiveScalars
renamed to(@jmstone: mathematical connotation),Scalars
Abundances
,Species
?AddFluxDivergence()
toAddHydroFluxDivergence()
andAddScalarFluxDivergence()
?Hydro
class?). See Enumerate use-cases for zero-fluid configurations and design matching configure.py options #247.NSCALARS
NGHOST
More to-do:
(added on 4/30/19 when the correct dual formalism of conserved and primitive passive scalar quantities was properly incorporated):
PassiveScalars::s, r
, etc. (like Athena 4.2?) Other options:rho_c
andc
,C
andc
(for color)hydro/active=background
ordisabled
.src/bvals/bvals_refine.cpp
involves a lot of delicate switching between primitive and conserved variables, and much of it is only activated when physical boundaries (non-periodic) are encountered on a refined mesh (which never happens in the regression tests).DIFFUSE_SCLR
task totask_list.hpp
and associated function. Add to STS task list too?BValFunc
? This would break backwards-compatibility, so we seek a more general approach..rst
regression test. It was silently broken for a few weeks.