Skip to content

Commit

Permalink
Merge branch 'development' into make_1d_cart_mom_have_p
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale authored Oct 5, 2023
2 parents 07fc88d + 104a57d commit 951b28c
Show file tree
Hide file tree
Showing 215 changed files with 34,535 additions and 22,720 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ Checks: >
mpi-*,
openmp-*
HeaderFilterRegex: '(/Source/*/|/Util/model_parser_cxx|^\./|^tmp_build_dir/castro_sources/*/).*\.H$'
HeaderFilterRegex: '(/Source/*/|/Util/model_parser|^\./|^tmp_build_dir/castro_sources/*/).*\.H$'
2 changes: 1 addition & 1 deletion .github/workflows/c-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
python3 external/cpp-linter-action/run_on_changed_files.py ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \
-ignore-files="amrex|Microphysics" \
-config-file="${GITHUB_WORKSPACE}/.clang-tidy" \
-header-filter='/Source/|/Util/model_parser_cxx|^\./' \
-header-filter='/Source/|/Util/model_parser|^\./' \
-run-linter
- name: Archive clang tidy report
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/check-params.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: check runtime params

on:
push:
branches:
- development
- main
pull_request:
branches:
- development

jobs:
check-runtime-params:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get submodules
run: |
git submodule update --init
cd external/Microphysics
git fetch; git checkout development
cd ../amrex
git fetch; git checkout development
cd ../..
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Cache pip
uses: actions/cache@v3
with:
# this path is specific to Ubuntu
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Run check-params
run: |
PYTHONPATH=external/Microphysics/util/build_scripts python .github/workflows/check_params.py .
76 changes: 76 additions & 0 deletions .github/workflows/check_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import argparse
import importlib
import os
import re
from pathlib import Path
import sys

# some parameters that are not defined in _cpp_parameters

whitelist = ["castro.lo_bc",
"castro.hi_bc",
"gravity.abs_tol",
"gravity.rel_tol"]

# we don't have all of the radiation parametrs in the _cpp_parameters
# yet, so we won't check these namespaces

namespace_ignore = ["radiation", "radsolve"]

def doit(castro_dir):

castro = Path(os.path.abspath(castro_dir))

# import the module that defines the Castro runtime params
sys.path.append(str(castro / "Source" / "driver/"))
import parse_castro_params

# read in the parameters defined in _cpp_parameters
param_file = castro / "Source" / "driver" / "_cpp_parameters"
params = parse_castro_params.read_param_file(str(param_file))

namespaces = set(p.namespace for p in params)
runtime_parameters = [f"{p.namespace}.{p.name}" for p in params]

pattern = re.compile(r"[A-Za-z0-9_]+\.[A-Za-z0-9_]+", re.IGNORECASE)

# loop over all the inputs files
exec_path = castro / "Exec"
for f in exec_path.glob("**/inputs*"):

if os.path.isdir(f):
continue

# find all the params in each namespace
with open(f) as infile:
print(f"working on {f}")
for line in infile:
# remove comments
idx = line.find("#")
if idx > 0:
line = line[idx:]

found_param = pattern.match(line)
if not found_param:
continue

p = found_param.group(0)
nm = p.split(".")[0]
if nm in namespaces and nm not in namespace_ignore:
if not (p in runtime_parameters or p in whitelist):
sys.exit(f"Error: {p} not valid")


if __name__ == "__main__":

# we need the top-level Castro directory

p = argparse.ArgumentParser()
p.add_argument("castro_dir", type=str, nargs=1,
help="top level Castro directory")

args = p.parse_args()

doit(args.castro_dir[0])


3 changes: 2 additions & 1 deletion .github/workflows/good_defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BL_FORT_USE_UPPERCASE
BL_LANG_FORT
BL_LAZY
BL_USE_SETBUF
CXX_MODEL_PARSER
MODEL_PARSER
DIFFUSION
DO_PROBLEM_POST_INIT
DO_PROBLEM_POST_RESTART
Expand All @@ -34,6 +34,7 @@ NSE_TABLE
RADIATION
RAD_INTERP
REACTIONS
RNG_STATE_INIT
ROTATION
SCREENING
SHOCK_VAR
Expand Down
21 changes: 20 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# 23.10

* True-SDC no longer evolves density as part of the reaction system
and now uses the same ODE code path as simplified-SDC. This means
we don't need our own custom VODE righthand side functions (#2559,
#2560, #2567, #2578, #2580, #2584)

* The true SDC runtime parameter `sdc_solve_for_rhoe` has been
removed. (#2572)

* The true SDC runtime parameters `sdc_solver_tol_spec`,
`sdc_solver_tol_ener`, `sdc_solver_atol` have been removed.
Instead the Microphysics integration tolerance parameters should
be used. (#2571)

* The true SDC runtime parameter `sdc_newton_use_analytic_jac` has
been removed. Instead the Microphysics integrator `jacobian`
parameter should be used (#2573)

# 23.08

* Time evolution without subcycling on the fine levels, which is enabled via
Expand Down Expand Up @@ -29,7 +48,7 @@
# 23.06

* The job_info file now reports the integrator used (#2463)

* 1-d cylindrical geometry was fixed (#2465, #2470)

# 23.05
Expand Down
5 changes: 3 additions & 2 deletions Diagnostics/Sedov/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ std::pair<Real, Real> get_coord_info(const Array<Real, AMREX_SPACEDIM>& p,
AMREX_ASSERT(coord == 2);

r_zone = p[0] - center[0];
Real r_r = problo[0]+static_cast<Real>(i+1)*dx_level[0];
Real r_l = problo[0]+static_cast<Real>(i)*dx_level[0];

Real r_r = p[0] + 0.5_rt * dx_level[0];
Real r_l = p[0] - 0.5_rt * dx_level[0];
vol = (4.0_rt/3.0_rt) * M_PI * dx_level[0] *
(r_r*r_r + r_l*r_r + r_l*r_l);

Expand Down
26 changes: 16 additions & 10 deletions Docs/source/FlowChart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -662,12 +662,13 @@ The overall evolution appears as:

#. *Initialization* (``initialize_advance``)

Here we create the ``MultiFab`` s that store the needed information
We first do a ``clean_state`` on the old data (``S_old``).

We next create the ``MultiFab`` s that store the needed information
at the different time nodes. Each of the quantities below is a
vector of size ``SDC_NODES``, whose components are the ``MultiFab``
for that time node:


* ``k_new`` : the current solution at this time node.

Note that
Expand Down Expand Up @@ -700,14 +701,15 @@ SDC Single Iteration Flowchart

.. index:: do_advance_sdc

The update through all time nodes for a single iteration is done by
``do_advance_sdc``. The basic update appears as:

Throughout this driver we use the ``State_Type`` ``StateData`` as
storage for the current node. In particular, we use the new time slot
in the ``StateData`` (which we refer to as ``S_new``) to allow us to
do ``FillPatch`` operations.

The update through all time nodes for a single iteration is done by
``do_advance_sdc``. The basic update appears as:


#. *Initialize*

We allocate ``Sborder``. Just like with the Strang CTU driver, we
Expand Down Expand Up @@ -756,18 +758,18 @@ do ``FillPatch`` operations.

Then fill all other time nodes as: ``R_old[n]`` = ``R_old[0]``

* Do the SDC update from node ``m`` to ``m+1``.
* Do the SDC update from node ``m`` to ``m+1``.

We call ``do_sdc_update()`` to do the update in time to the next
node. This solves the nonlinear system (when we have reactions)
and stores the solution in ``k_new[m+1]``.
We call ``do_sdc_update()`` to do the update in time to the next
node. This solves the nonlinear system (when we have reactions)
and stores the solution in ``k_new[m+1]``.

#. Store the advective terms for the next iteration.

Since we are done with this iteration, we do: ``A_old[n]``
:math:`\leftarrow` ``A_new[n]``.

We also store ``R_old`` for the next iteration. We do this by
#. Store ``R_old`` for the next iteration. We do this by
calling the reaction source one last time using the data for each
time node.

Expand All @@ -777,6 +779,10 @@ do ``FillPatch`` operations.

``S_new`` :math:`\leftarrow` ``k_new[SDC_NODES-1]``

#. Store the old and new sources in the State Data.

#. Store the reaction information for the plotfiles.

#. Call ``finalize_do_advance`` to clean up the memory.


Expand Down
3 changes: 0 additions & 3 deletions Docs/source/Particles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ the same time and each line corresponds to each particle info. while
in the other output file for the other 6 particles, 6 lines are stored
at the same time.

If ``particles.write_in_plotfile`` = 1, the particle data are stored
in a binary file along with the main CASTRO output plotfile in
directories ``pltXXXXX/Tracer/``.

Run-time Screen Output
----------------------
Expand Down
2 changes: 1 addition & 1 deletion Docs/source/Verification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ Light Front

The light front problem tests the ability of the radiation solver to
operate in the free-streaming limit. A radiation front is
estabilished by initializing one end of the computational domain with
established by initializing one end of the computational domain with
a finite radiation field, and zero radiation field everywhere else.
The speed of propagation of the radiation front is keep in check by
the flux-limiters, to prevent it from exceeding :math:`c`.
Expand Down
2 changes: 1 addition & 1 deletion Docs/source/creating_a_problem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ Many problem setups begin with a 1-d initial model that is mapped onto
the grid. The ``model_parser.H`` provides the functions that read in
the initial model and map it on the Castro grid. To enable this, add::

USE_CXX_MODEL_PARSER = TRUE
USE_MODEL_PARSER = TRUE

to the problem ``GNUmakefile``. There are 2 other parameters that can
be set in the makefile to control the initial model storage:
Expand Down
22 changes: 6 additions & 16 deletions Docs/source/sdc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,13 @@ The options that affect the nonlinear solve are:
* 3 : use VODE for the first iteration and then Newton for the
subsequent iterations.

* ``sdc_solver_tol_dens`` : the relative error on the density in solving the nonlinear system.
The tolerances for both the Newton and VODE solver are controlled by
the usual Microphysics parameters: ``integrator.rtol_spec``,
``integrator.atol_spec``, ``integrator.rtol_enuc``,
``integrator.atol_enuc``.

* ``sdc_solver_tol_spec`` : the relative error on the partial densities, :math:`(\rho X_k)`
in the nonlinear solve.

* ``sdc_solver_tol_ener`` : the relative error of the energy in the nonlinear solve.

* ``sdc_solver_atol`` : the absolute error in the mass fractions during the nonlinear solve.

* ``sdc_solver_relax_factor`` : the factor by which to relax the
tolerances (i.e. increase them) for earlier iterations. We reach
the desired tolerances on the final iteration.

* ``sdc_solve_for_rhoe`` : whether we solve the system in terms of :math:`(\rho e)` or :math:`(\rho E)`.

* ``sdc_newton_use_analytic_jac`` : whether we use the analytic Jacobian when doing Newton iterations for
the reaction part of the system or compute it numerically.
In all cases, the type of Jacobian (analytic or numerical) is determined by
``integrator.jacobian``.



Expand Down
2 changes: 1 addition & 1 deletion Docs/source/software.rst
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ get a sense of these is to look at the ``.H`` files in the
------------------

There is a ``Geometry`` object, ``geom`` for each level as part of
the ``Castro`` object (this is inhereted through ``AmrLevel``).
the ``Castro`` object (this is inherited through ``AmrLevel``).

``ParmParse`` class
-------------------
Expand Down
18 changes: 13 additions & 5 deletions Exec/Make.Castro
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ ifeq ($(USE_SDC), TRUE)
$(error USE_SDC is no longer supported. Use with USE_SIMPLIFIED_SDC or USE_TRUE_SDC)
endif

ifeq ($(USE_SIMPLIFIED_SDC), TRUE)
ifeq ($(USE_TRUE_SDC), TRUE)
$(error USE_SIMPLIFIED_SDC cannot be combined with USE_TRUE_SDC)
endif
endif

# need to put any build suffices before Make.defs
ifeq ($(USE_SIMPLIFIED_SDC), TRUE)
USERSuffix = .SMPLSDC
Expand Down Expand Up @@ -161,9 +167,13 @@ endif
MAX_NPTS_MODEL ?= 10000
NUM_MODELS ?= 1

ifeq ($(USE_CXX_MODEL_PARSER), TRUE)
Bdirs += Util/model_parser_cxx
DEFINES += -DCXX_MODEL_PARSER -DNPTS_MODEL=$(MAX_NPTS_MODEL) -DNUM_MODELS=$(NUM_MODELS)
ifeq ($(USE_MODEL_PARSER), TRUE)
Bdirs += Util/model_parser
DEFINES += -DMODEL_PARSER -DNPTS_MODEL=$(MAX_NPTS_MODEL) -DNUM_MODELS=$(NUM_MODELS)
endif

ifeq ($(USE_RNG_STATE_INIT), TRUE)
DEFINES += -DRNG_STATE_INIT
endif

# add / define any special physics we need
Expand Down Expand Up @@ -298,8 +308,6 @@ Bpack += $(foreach dir, $(Pdirs), $(AMREX_HOME)/Src/$(dir)/Make.package)
# directory
NETWORK_OUTPUT_PATH = $(CASTRO_AUTO_SOURCE_DIR)

USE_CXX_EOS := TRUE

include $(MICROPHYSICS_HOME)/Make.Microphysics_extern

Bpack += $(foreach dir, $(EXTERN_CORE), $(dir)/Make.package)
Expand Down
2 changes: 1 addition & 1 deletion Exec/gravity_tests/StarGrav/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ USE_MPI = TRUE
USE_GRAV = TRUE
USE_REACT = FALSE

USE_CXX_MODEL_PARSER = TRUE
USE_MODEL_PARSER = TRUE

# This sets the EOS directory in $(MICROPHYSICS_HOME)/eos
EOS_DIR := helmholtz
Expand Down
2 changes: 1 addition & 1 deletion Exec/gravity_tests/advecting_white_dwarf/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DIM ?= 3

USE_GRAV ?= TRUE

USE_CXX_MODEL_PARSER = TRUE
USE_MODEL_PARSER = TRUE
NUM_MODELS = 1

COMP ?= gnu
Expand Down
Loading

0 comments on commit 951b28c

Please sign in to comment.