Skip to content

Commit

Permalink
1) Add Projections directory from amrex - we will deprecate the one i…
Browse files Browse the repository at this point in the history
…n amrex soon.

2) Remove trailing white spaces and tabs.
  • Loading branch information
asalmgren committed Nov 1, 2021
1 parent 999f877 commit 71adbdf
Show file tree
Hide file tree
Showing 48 changed files with 2,172 additions and 667 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
echo "Installing python packages for docs..."
pip3 install sphinx sphinx_rtd_theme breathe
- name: Build Doxygen Docs
- name: Build Doxygen Docs
run: |
./build_doxygen_docs.sh
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/style/check_tabs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -eu -o pipefail

find . -type d \( -name .git \
-o -path ./paper \
-o -name build -o -name install \
-o -name tmp_build_dir -o -name tmp_install_dir \
\) -prune -o \
-type f \( \( -name "*.H" -o -name "*.h" -o -name "*.hh" -o -name "*.hpp" \
-o -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" \
-o -name "*.f" -o -name "*.F" -o -name "*.f90" -o -name "*.F90" \
-o -name "*.py" \
-o -name "*.md" -o -name "*.rst" \
-o -name "*.sh" \
-o -name "*.tex" \
-o -name "*.txt" \
-o -name "*.yml" \) \
-a \( ! -name "*.tab.h" -a ! -name "*.tab.cpp" \
-a ! -name "*.lex.h" -a ! -name "*.lex.cpp" \) \
\) \
-exec grep -Iq . {} \; \
-exec sed -i 's/\t/\ \ \ \ /g' {} +

gitdiff=`git diff`

if [ -z "$gitdiff" ]
then
exit 0
else
echo -e "\nTabs are not allowed. Changes suggested by"
echo -e " ${0}\n"
git --no-pager diff
echo ""
exit 1
fi
36 changes: 36 additions & 0 deletions .github/workflows/style/check_trailing_whitespaces.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -eu -o pipefail

find . -type d \( -name .git \
-o -path ./paper \
-o -name build -o -name install \
-o -name tmp_build_dir -o -name tmp_install_dir \
\) -prune -o \
-type f \( \( -name "*.H" -o -name "*.h" -o -name "*.hh" -o -name "*.hpp" \
-o -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" \
-o -name "*.f" -o -name "*.F" -o -name "*.f90" -o -name "*.F90" \
-o -name "*.py" \
-o -name "*.rst" \
-o -name "*.sh" \
-o -name "*.tex" \
-o -name "*.txt" \
-o -name "*.yml" \) \
-a \( ! -name "*.tab.h" -a ! -name "*.tab.cpp" \
-a ! -name "*.lex.h" -a ! -name "*.lex.cpp" \) \
\) \
-exec grep -Iq . {} \; \
-exec sed -i 's/[[:blank:]]\+$//g' {} +

gitdiff=`git diff`

if [ -z "$gitdiff" ]
then
exit 0
else
echo -e "\nTrailing whitespaces at the end of a line are not allowed. Changes suggested by"
echo -e " ${0}\n"
git --no-pager diff
echo ""
exit 1
fi
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ add_subdirectory(Slopes)
add_subdirectory(Utils)
add_subdirectory(MOL)
add_subdirectory(Godunov)
add_subdirectory(Projections)

if (HYDRO_EB)
add_subdirectory(EBMOL)
Expand Down
50 changes: 25 additions & 25 deletions Docs/source/EBGodunov.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ extrapolated from :math:`(i,j,k)`, where
.. math::
:label: eq1-ebg2
\hat{u}_{i+\frac{1}{2},j,k}^{L} = u_{i,j,k}^n +
\left( \delta x - \frac{dt}{2} u_{i,j,k}^n \right)
\hat{u}_{i+\frac{1}{2},j,k}^{L} = u_{i,j,k}^n +
\left( \delta x - \frac{dt}{2} u_{i,j,k}^n \right)
\; {u^x}_{i,j,k} + \delta y \; {u^y}_{i,j,k} + \delta z \; {u^z}_{i,j,k}
and
Expand All @@ -55,23 +55,23 @@ and
\tilde{u}_{i+\frac{1}{2},j,k}^{R,\frac{1}{2}} = \hat{u}_{i+\frac{1}{2},j,k}^{R} +
\frac{dt}{2} (-(\widehat{v u_y})_{i+1,j,k} - (\widehat{w u_z})_{i+1,j,k} + f_{x,i+1,j,k}^n)
extrapolated from :math:`(i+1,j,k),` where
extrapolated from :math:`(i+1,j,k),` where

.. math::
:label: eq2-ebg2
\hat{u}_{i+\frac{1}{2},j,k}^{R} = u_{i+1,j,k}^n +
\left(\delta_x - \frac{dt}{2} u_{i,j,k}^n \right)
\hat{u}_{i+\frac{1}{2},j,k}^{R} = u_{i+1,j,k}^n +
\left(\delta_x - \frac{dt}{2} u_{i,j,k}^n \right)
\; {u^x}_{i+1,j,k} + \delta y \; {u^y}_{i+1,j,k} + \delta z \; {u^z}_{i+1,j,k}
Here, :math:`f` is the sum of external forces, discussed later.

Here the slopes :math:`(u^x,u^y,u^z)` are calculated using a least-squares fit to available data and
:math:`\delta_x,` :math:`\delta_y` and :math:`\delta_z` are the components of the distance vector
from the cell centroid to the face centroid of the :math:`x`-face at :math:`(i-\frac{1}{2},j,k)`.
These slopes are limited with a Barth-Jesperson type of limiter that enforces no new maxima or minima
when the state is predicted to the face centroids. (If sufficient data is available for cells
with unit volume fraction, this computation instead uses a standard second- or fourth-order
Here the slopes :math:`(u^x,u^y,u^z)` are calculated using a least-squares fit to available data and
:math:`\delta_x,` :math:`\delta_y` and :math:`\delta_z` are the components of the distance vector
from the cell centroid to the face centroid of the :math:`x`-face at :math:`(i-\frac{1}{2},j,k)`.
These slopes are limited with a Barth-Jesperson type of limiter that enforces no new maxima or minima
when the state is predicted to the face centroids. (If sufficient data is available for cells
with unit volume fraction, this computation instead uses a standard second- or fourth-order
slope calculation with limiting as described in Colella (1985).)

We note that if any of the four faces that contribute to the transverse derivatives for a particular cell have zero area, all of the transverse *and* forcing terms are identically set to 0. For example, when constructing :math:`\tilde{u}_{i+\half,j,k}^{L,\nph}`, if any of the areas :math:`a_{i,\jph,k}, a_{i,\jmh,k}, a_{i,j,\kmh}` or :math:`a_{i,j,\kph}` are zero, then we simply define
Expand All @@ -82,19 +82,19 @@ We note that if any of the four faces that contribute to the transverse derivati
\tilde{u}_{i+\half,j,k}^{L,\nph} = \hat{u}_{i+\half,j,k}^{L}
The transverse derivative terms ( :math:`\widehat{v u_y}` and :math:`\widehat{w u_z}` in this case)
are evaluated by first extrapolating all velocity components
to the face centroids of the transverse faces from the cell centers on either side,
are evaluated by first extrapolating all velocity components
to the face centroids of the transverse faces from the cell centers on either side,
then choosing between these states using the upwinding procedure
defined below. In particular, in the :math:`y` direction we define
:math:`\widehat{\boldsymbol{U}}^F_{i,j+\frac{1}{2},k}` and
:math:`\widehat{\boldsymbol{U}}^F_{i,j+\frac{1}{2},k}` and
:math:`\widehat{\boldsymbol{U}}^T_{i,j+\frac{1}{2},k}`
analogously to how we defined
:math:`\hat{u}_{i+\frac{1}{2},j,k}^{R}` and :math:`\hat{u}_{i+\frac{1}{2},j,k}^{L}`,
analogously to how we defined
:math:`\hat{u}_{i+\frac{1}{2},j,k}^{R}` and :math:`\hat{u}_{i+\frac{1}{2},j,k}^{L}`,
but here on the y-faces and including all three velocity components.
Values are similarly traced from :math:`(i,j,k)` and :math:`(i,j,k+1)`
to the :math:`(i,j,k+\frac{1}{2})` faces to define
:math:`\widehat{\boldsymbol{U}}^D_{i,j,k+\frac{1}{2}}` and
:math:`\widehat{\boldsymbol{U}}^{U}_{i,j,k+\frac{1}{2}}`, respectively.
:math:`\widehat{\boldsymbol{U}}^D_{i,j,k+\frac{1}{2}}` and
:math:`\widehat{\boldsymbol{U}}^{U}_{i,j,k+\frac{1}{2}}`, respectively.

In this upwinding procedure we first define a normal advective
velocity on the face
Expand Down Expand Up @@ -203,8 +203,8 @@ extrapolated from :math:`(i,j,k)`, where
.. math::
:label: postebg-eq2
\hat{s}_{i+\half,j,k}^{L} = s_{i,j,k}^n +
\left( \delta_x - \frac{dt}{2} u_{i,j,k}^n \right)
\hat{s}_{i+\half,j,k}^{L} = s_{i,j,k}^n +
\left( \delta_x - \frac{dt}{2} u_{i,j,k}^n \right)
\; {s^x}_{i,j,k} + \delta_y \; {s^y}_{i,j,k} + \delta_z \; {s^z}_{i,j,k}
and
Expand All @@ -218,11 +218,11 @@ extrapolated from :math:`(i+1,j,k),` where
.. math::
:label: postebg-eq3
\hat{u}_{i+\half,j,k}^{R} = u_{i+1,j,k}^n +
\left(\delta_x - \frac{dt}{2} u_{i,j,k}^n \right)
\hat{u}_{i+\half,j,k}^{R} = u_{i+1,j,k}^n +
\left(\delta_x - \frac{dt}{2} u_{i,j,k}^n \right)
\; {s^x}_{i+1,j,k} + \delta_y \; {s^y}_{i+1,j,k} + \delta_z \; {s^z}_{i+1,j,k}
Here again the slopes :math:`(s^x,s^y,s^z)` are calculated using a least-squares fit to available data and
Here again the slopes :math:`(s^x,s^y,s^z)` are calculated using a least-squares fit to available data and
:math:`\delta_x,` :math:`\delta_y` and :math:`\delta_z` are the components of the distance vector from the cell centroid to the face centroid of the :math:`x`-face at :math:`(i-\half,j,k).` The transverse terms are computed exactly as described earlier except for the upwinding process; where we previously used the predicted states themselves to upwind, we now use the component of :math:`\U^{MAC}` normal to the face in question.

We note again that if any of the four faces that contribute to the transverse derivatives for a particular cell have zero area, all of the transverse *and* forcing terms are identically set to 0. For example, when constructing :math:`\tilde{s}_{i+\half,j,k}^{L,\nph}`, if any of the areas :math:`a_{i,\jph,k}, a_{i,\jmh,k}, a_{i,j,\kmh}` or :math:`a_{i,j,\kph}` are zero, then we simply define
Expand All @@ -232,15 +232,15 @@ We note again that if any of the four faces that contribute to the transverse de
\tilde{s}_{i+\half,j,k}^{L,\nph} = \hat{s}_{i+\half,j,k}^{L}
We upwind :math:`\tilde{s}_{i+\half,j,k}^{L,\nph}` and :math:`\tilde{s}_{i+\half,j,k}^{L,\nph}` using the normal component of :math:`\U^{MAC}` to define :math:`\tilde{s}_{i+\half,j,k}^{\nph}.` Again, suppressing the subscripts, we define
We upwind :math:`\tilde{s}_{i+\half,j,k}^{L,\nph}` and :math:`\tilde{s}_{i+\half,j,k}^{L,\nph}` using the normal component of :math:`\U^{MAC}` to define :math:`\tilde{s}_{i+\half,j,k}^{\nph}.` Again, suppressing the subscripts, we define

.. math::
:label: postebg-eq5
\tilde{s}^{\nph} = \left\{\begin{array}{lll}
\tilde{s}^{L,\nph} & \mbox{if $u^{MAC} > 0$} \\
\frac{1}{2} (\tilde{s}^{L,\nph} + \tilde{s}^{R,\nph}) & \mbox{if $u^{MAC} = 0$} \\
\tilde{s}^{R,\nph} & \mbox{if $u^{MAC} < 0$}
\tilde{s}^{R,\nph} & \mbox{if $u^{MAC} < 0$}
\end{array} \right.
Computing the Fluxes (`ComputeFluxes`_)
Expand Down
26 changes: 13 additions & 13 deletions Docs/source/EBMOL.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
EBMOL
=====

The procedure for computing MAC velocities and edge states with EB-aware MOL
The procedure for computing MAC velocities and edge states with EB-aware MOL
does not involve any time derivatives. All slope computations use
second-order limited slopes as described in
`Slopes`_.

.. _`Slopes`: https://amrex-codes.github.io/amrex/hydro_html/Slopes.html

.. note::
Note: if a cell and all of its immediate neighbors have volume fraction of 1 (i.e. they

Note: if a cell and all of its immediate neighbors have volume fraction of 1 (i.e. they
are not cut cells), the EBMOL methodology will return exactly the same answer (to machine
precision) as the MOL methodology.

Expand All @@ -19,8 +19,8 @@ We define :math:`\varepsilon = 1.e-8` in **Utils / hydro_constants.H**
Notation
--------

For every cut cell we define :math:`a_x`, :math:`a_y,` and :math:`a_z` to be the area fractions of the faces
and :math:`V` is the volume fraction of the cell. All area and volume fractions are greater than or equal to zero
For every cut cell we define :math:`a_x`, :math:`a_y,` and :math:`a_z` to be the area fractions of the faces
and :math:`V` is the volume fraction of the cell. All area and volume fractions are greater than or equal to zero
and less than or equal to 1.

Pre-MAC (`ExtrapVelToFaces`_)
Expand All @@ -38,14 +38,14 @@ For computing the pre-MAC edge states to be MAC-projected, we define on every x-
where we calculate :math:`u^x`, :math:`u^y` and :math:`u^z` simultaneously using a least squares approach,
as described in `Slopes`_,
and :math:`\delta_x`, :math:`\delta_y`, and :math:`\delta_z` are the components of the distance vector from
and :math:`\delta_x`, :math:`\delta_y`, and :math:`\delta_z` are the components of the distance vector from
the cell centroid to the face centroid of the face at :math:`(i-\frac{1}{2},j,k).`

At each face we then upwind based on :math:`u_L` and :math:`u_R`

.. math::
u_{i-\frac{1}{2},j,k} =
u_{i-\frac{1}{2},j,k} =
\begin{cases}
0, & \mathrm{if} \; u_L < 0 \;\; \mathrm{and} \;\; u_R > 0 \; \mathrm{else} \\
u_L, & \mathrm{if} \; u_L + u_R \ge \varepsilon \; \mathrm{else} \\
Expand All @@ -56,7 +56,7 @@ At each face we then upwind based on :math:`u_L` and :math:`u_R`
We similarly compute :math:`v_{i,j-\frac{1}{2},k}` on y-faces and
:math:`w_{i,j,k-\frac{1}{2}}` on z-faces.

Boundary conditions (`SetXEdgeBCs`_, `SetYEdgeBCs`_, `SetZEdgeBCs`_)
Boundary conditions (`SetXEdgeBCs`_, `SetYEdgeBCs`_, `SetZEdgeBCs`_)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. _`SetXEdgeBCs`: https://amrex-codes.github.io/amrex-hydro/Doxygen/html/namespaceHydroBC.html#ab90f8ce229a7ebbc521dc27d65f2db9a
Expand All @@ -70,8 +70,8 @@ adjacent to the domain boundary (see `Slopes`_).

(2) Second, if the face is on a domain boundary and the boundary
condition type is extdir, we set both :math:`u_L` and :math:`u_R` to the
boundary value. If the boundary condition type is foextrap, hoextrap, or
reflecteven on the low side of the domain,
boundary value. If the boundary condition type is foextrap, hoextrap, or
reflecteven on the low side of the domain,
we set :math:`u_L = u_R.` (If on the high side then we
set :math:`u_R = u_L.`) If the boundary condition type is reflectodd , we set
:math:`u_L = u_R = 0.`
Expand Down Expand Up @@ -100,7 +100,7 @@ Once we have the MAC-projected velocities, we predict all quantities to faces wi
where we calculate :math:`s^x`, :math:`s^y` and :math:`s^z` simultaneously using a least squares approach,
as described in `Slopes`_,
and :math:`\delta_x`, :math:`\delta_y`, and :math:`\delta_z` are the components of the distance vector from
and :math:`\delta_x`, :math:`\delta_y`, and :math:`\delta_z` are the components of the distance vector from
the cell centroid to the face centroid of the face at :math:`(i-\frac{1}{2},j,k).`

The domain boundary conditions affect the solution as described above in
Expand All @@ -118,11 +118,11 @@ At each face we then upwind based on :math:`u^{MAC}_{i-\frac{1}{2},j,k}`

.. math::
s_{i-\frac{1}{2},j,k} =
s_{i-\frac{1}{2},j,k} =
\begin{cases}
s_L, & \mathrm{if} \; u^{MAC}_{i-\frac{1}{2},j,k}\; \ge \; \varepsilon \; \mathrm{else} \\
s_R, & \mathrm{if} \; u^{MAC}_{i-\frac{1}{2},j,k}\; \le \; -\varepsilon \; \mathrm{else} \\
\frac{1}{2}(s_L + s_R),
\frac{1}{2}(s_L + s_R),
\end{cases}
Computing the Fluxes (`ComputeFluxes`_)
Expand Down
6 changes: 3 additions & 3 deletions Docs/source/FluxRedistribution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ of the convective fluxes, :math:`F`

.. math:: (\nabla \cdot {F})^c_i = \dfrac{1}{\mathcal{V}_i} \sum_{f=1}^{N_f} ({F}_f\cdot{n}_f) A_f

Here :math:`N_f` is the number of faces of cell :math:`i`, :math:`\vec{n}_f` and :math:`A_f`
Here :math:`N_f` is the number of faces of cell :math:`i`, :math:`\vec{n}_f` and :math:`A_f`
are the unit normal and area of the :math:`f` -th face respectively,
and :math:`\mathcal{V}_i` is the volume of cell :math:`i` given by

.. math:: \mathcal{V}_i = (\Delta x \Delta y \Delta z)\cdot \mathcal{K}_i
.. math:: \mathcal{V}_i = (\Delta x \Delta y \Delta z)\cdot \mathcal{K}_i

where :math:`\mathcal{K}_i` is the volume fraction of cell :math:`i` .

Expand Down Expand Up @@ -51,6 +51,6 @@ and the weights, :math:`w_{ij}` , are

Note that :math:`\nabla \cdot{F}_i^{EB}` gives an update for :math:`\rho \phi` ; i.e.,

.. math:: \frac{\phi_i^{n+1} - \phi_i^{n} }{\Delta t} = - \nabla \cdot{F}^{EB}_i
.. math:: \frac{\phi_i^{n+1} - \phi_i^{n} }{\Delta t} = - \nabla \cdot{F}^{EB}_i


16 changes: 8 additions & 8 deletions Docs/source/MOL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ At each face we then upwind based on :math:`u_L` and :math:`u_R`

.. math::
u_{i-\frac{1}{2},j,k} =
u_{i-\frac{1}{2},j,k} =
\begin{cases}
0, & \mathrm{if} \; u_L < 0 \;\; \mathrm{and} \;\; u_R > 0 \; \mathrm{else} \\
u_L, & \mathrm{if} \; u_L + u_R \ge \varepsilon \; \mathrm{else} \\
Expand All @@ -55,8 +55,8 @@ adjacent to the domain boundary (see `Slopes`_).

(2) Second, if the face is on a domain boundary and the boundary
condition type is extdir, we set both :math:`u_L` and :math:`u_R` to the
boundary value. If the boundary condition type is foextrap, hoextrap, or
reflecteven on the low side of the domain,
boundary value. If the boundary condition type is foextrap, hoextrap, or
reflecteven on the low side of the domain,
we set :math:`u_L = u_R.` (If on the high side then we
set :math:`u_R = u_L.`) If the boundary condition type is reflectodd , we set
:math:`u_L = u_R = 0.`
Expand Down Expand Up @@ -101,25 +101,25 @@ At each face we then upwind based on :math:`u^{MAC}_{i-\frac{1}{2},j,k}`

.. math::
s_{i-\frac{1}{2},j,k} =
s_{i-\frac{1}{2},j,k} =
\begin{cases}
s_L, & \mathrm{if} \; u^{MAC}_{i-\frac{1}{2},j,k}\; \ge \; \varepsilon \; \mathrm{else} \\
s_R, & \mathrm{if} \; u^{MAC}_{i-\frac{1}{2},j,k}\; \le \; -\varepsilon \; \mathrm{else} \\
\frac{1}{2}(s_L + s_R),
\frac{1}{2}(s_L + s_R),
\end{cases}
Computing the Fluxes (`ComputeFluxes`_)
---------------------------------------

.. _`ComputeFluxes`: https://amrex-codes.github.io/amrex-hydro/Doxygen/html/namespaceHydroUtils.html#ab70f040557a658e70ba076c9d105bab7

The fluxes are computed from the edge states above by defining, e.g.
The fluxes are computed from the edge states above by defining, e.g.

.. math::
F_{i-\frac{1}{2},j,k}^{x,n} = u^{MAC}_{i-\frac{1}{2},j,k}\; s_{i-\frac{1}{2},j,k}^{n}
on all x-faces,
on all x-faces,

.. math::
Expand Down Expand Up @@ -164,7 +164,7 @@ where
|
|
These alogrithms are applied in the MOL namespace. For API documentation, see
These alogrithms are applied in the MOL namespace. For API documentation, see
`Doxygen: MOL Namespace`_.

.. _`Doxygen: MOL Namespace`: https://amrex-codes.github.io/amrex-hydro/Doxygen/html/namespaceMOL.html
4 changes: 2 additions & 2 deletions Docs/source/MOL_namespace.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
MOL Namespace
=============

Example Doxygen XML integration with Sphinx.
Example Doxygen XML integration with Sphinx.


.. doxygennamespace:: MOL
.. doxygennamespace:: MOL
:project: amrex-hydro
Loading

0 comments on commit 71adbdf

Please sign in to comment.