Skip to content
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

rotating reference frames capability #850

Merged
merged 50 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a78c25c
adding rotational sources for mrf and srf
May 10, 2024
eb3d106
adding srf
hsitaram May 19, 2024
57eb1e4
coded in everything, need to fix build errors
hsitaram May 22, 2024
40cd1d2
build almost working
hsitaram May 28, 2024
0bc7392
build working
hsitaram May 28, 2024
da57af0
bug in riemann solve, pass left and right radii
hsitaram May 29, 2024
a87ebe0
adding switches for rotational frame schemes
hsitaram Jun 25, 2024
ac84db5
taylor couette flow case
hsitaram Jun 25, 2024
7076c35
clang-format mrf code
baperry2 Jun 25, 2024
18212cd
derive inertial frame velocity for rotating frame stuff
baperry2 Jun 26, 2024
a0d558f
some refactoring in hyp flux
hsitaram Jun 28, 2024
ed60922
input changes for taylor couette:
Jun 28, 2024
337da5b
Merge branch 'development' into mrf
baperry2 Jul 10, 2024
27e8a7f
update taylor couette for pelephysics changes
baperry2 Jul 10, 2024
28dde9f
adding 4 bladed rotor case
hsitaram Jul 15, 2024
d81ae73
fix gpu capture issue
Sep 24, 2024
01d6d50
matching submodules
Sep 25, 2024
b591e2d
Merge branch 'development' into mrf
Sep 25, 2024
9c9bb26
some filename changes
Sep 26, 2024
c66c6fd
adding documentation
Sep 27, 2024
92f7bdd
clang formatting
hsitaram Sep 27, 2024
1fe01c0
fixing some warnings
Sep 27, 2024
be3e345
fixing more warnings
Sep 27, 2024
b9b7346
cant to can't!!
Sep 27, 2024
17d4525
removing verbose
Sep 27, 2024
4ad1095
some fixes for 2D
Sep 27, 2024
1e24609
spelling error for D_DECL
Sep 27, 2024
6b4d0ff
clang formatting again
hsitaram Sep 27, 2024
83666f3
fixing cmake and warnings
hsitaram Sep 27, 2024
5094a2b
fixing warnings for 2D
hsitaram Sep 28, 2024
a17638d
fixing 2d bug
hsitaram Sep 28, 2024
ea86716
changing default axis value to 0
hsitaram Sep 28, 2024
a294a49
missed initializing radii before flux calcs
hsitaram Oct 8, 2024
360975d
clang formatting
hsitaram Oct 8, 2024
25b644f
error instead of FIXME for restart from plt with do_rf
baperry2 Oct 8, 2024
458c6e6
rename EB rotational frame cases to follow convention of other EB cases
baperry2 Oct 8, 2024
6469929
delete commented code
baperry2 Oct 8, 2024
8132171
use iv in rotor prob.H
baperry2 Oct 8, 2024
82e1e3d
eint1 derive for rf
baperry2 Oct 8, 2024
3fb76f0
no RF issues with soot as soot model doesn't deal with kinetic energy
baperry2 Oct 8, 2024
169a8a5
Add error checking to prevent RF in 2D or with MOL
baperry2 Oct 8, 2024
1bc26aa
revise note for srctoprim with RF
baperry2 Oct 8, 2024
d68b8d4
clang-tidy fixes for RF
baperry2 Oct 8, 2024
b2bee8b
use iv in EB-TaylorCouette case
baperry2 Oct 8, 2024
bd12db9
Merge branch 'development' into mrf
baperry2 Oct 8, 2024
089eaca
spelling
baperry2 Oct 8, 2024
83a6f4a
run RF cases in CI
baperry2 Oct 8, 2024
66e442e
clang-tidy fixes
baperry2 Oct 9, 2024
43fc968
Merge branch 'development' into mrf
baperry2 Oct 21, 2024
2ea8758
remove WIP comment in Godunov
baperry2 Oct 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMake/BuildPeleExe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function(build_pele_exe pele_exe_name pele_physics_lib_name)
${SRC_DIR}/Utilities.H
${SRC_DIR}/Utilities.cpp
${SRC_DIR}/WENO.H
${SRC_DIR}/RotSource.cpp
)

if(PELE_PHYSICS_ENABLE_SPRAY)
Expand Down
89 changes: 88 additions & 1 deletion Docs/sphinx/geometry/EB.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ the end of each time step. The re-redistribution is performed every time the ref
presented in `Pember et al. <https://www.sciencedirect.com/science/article/pii/S0021999185711655>`_. A forthcoming paper will describe the methodology for this procedure when using state redistribution.


Date Structures and utility functions
Data Structures and utility functions
-------------------------------------

Several structures exist to store geometry dependent information. These are populated on creation of a new AMRLevel and stored in the PeleC object so that they are available for computation. These facilitate accessing the EB data. The datatypes are:
Expand Down Expand Up @@ -205,3 +205,90 @@ Problem specific inflow conditions on an EB
It is possible for the user to define problem specific conditions on an EB surface. This is done by defining an ``problem_eb_state`` function and then including `pelec.eb_problem_state = 1` in the input file. An example of this is found in the ``EB-InflowBC`` case.

.. warning:: This is a beta feature. Currently this will only affect the calculation of the hydrodynamic fluxes so this works best for advection dominated EB conditions.

Rotational frames
------------------------------

.. warning:: PeleC has limited support for simulations using rotating frames using the single-reference-frame (SRF)
method only in 3D and needs the MOL scheme when using this feature.


Single-reference-frame implementation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PeleC currently supports a non-inertial frame based implementation
for rotating bodies, which are relevant for turbomachinery applications.
The source terms for momentum and energy equations
are applied in the non-inertial reference frame for cylindrically symmetric
embedded boundaries. The total energy in the non-inertial frame is
modified with the inclusion of rotatational kinetic energy:

.. math::
E = e + \frac{u^2+v^2+w^2}{2} - \frac{\omega^2 r^2}{2}

where E is the total specific energy, e is specific internal energy,
u,v,w are the velocity components, :math:`\omega` is the angular velocity, and
r is the distance from the rotational axis.
The momentum equation includes additional source terms for
Coriolis, centrifugal, and rotational acceleration:

.. math::

\frac{\partial}{\partial t} (\rho \mathbf{v})+ \mathbf{\nabla} \cdot (\rho V V)=-\mathbf{\nabla}P + \mathbf{\nabla} \cdot \bar{\bar{\tau}}
-\rho (2 \mathbf{\omega} \times \mathbf{V} + \mathbf{\omega} \times (\mathbf{\omega} \times r) + \dot{\mathbf{\omega}} \times r)

For further details, refer to Appendix A.3
*Navier-Stokes Equations in Rotating Frame of Reference*
in textbook *Computational fluid dynamics: principles and applications* by J. Blazek.

Single-reference-frame usage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Most often in turbomachinery applications, there is rotor and
a stator, which will be represented in PeleC as embedded boundaries.
The rotor will most often include blades and other components that are
not rotational symmetric like a cylindrical stator surface. This capability
will solve the governing equations in the non inertial frame where the
rotor boundary would then be a no-slip wall while the stator, which is rotationally
symmetric, will be a slip wall. Therefore, the user in this case
has to differentiate where the stator is using ``pelec.rf_rad`` parameter that
says anything beyond this radius will be a stator.
The rotational frame capability can be turned on by using these inputs:

::

pelec.do_rf=1 #turn on rotational frames
pelec.rf_omega=500.0 #rotational speed (rad/s)
pelec.rf_axis=2 #axis of rotation (0-x,1-y,2-z)
pelec.rf_axis_x=0.0 #x location of axis
pelec.rf_axis_y=0.0 #y location of axis
pelec.rf_axis_z=0.0 #z location of axis
pelec.rf_rad=20.0 #non-zero EB velocity beyond this radius
pelec.do_mol = 1 #rotational frames only implemented with MOL

The velocities in the plot files will be in the rotating frame.
But, one can turn on ``amr.derive_plot_vars`` to add new variables
that transform velocity back to inertial frame. These variable names
include ``x_velocity_if``, ``y_velocity_if`` , ``z_velocity_if`` and
``magvel_if``.

Some example test cases
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We have tested this SRF implementation using a Taylor-Couette example (see ``Exec/EB_TaylorCouette``)
for which we obtain solutions matching the analytic solution as shown in
Figure :ref:`rotational-frame-verification <rotframe>` (a).

We have also done a comparison with the incompressible SRF solver in OpenFOAM for a
4 bladed rotor case (see ``Exec/EB_Rotor4Blade``).
The solutions agree reasonably well, as shown in Figure :ref:`rotational-frame-verification <rotframe>` (b)
with minor differences due to the compressible formulation in PeleC.

.. _rotframe:

.. figure:: rotframetests.png
:alt: EB Cell
:width: 400

\(a) solution to Taylor-Couette flow compared to analytic solution and (b)
comparison of velocity magntiude for a 4 blade rotor case with incompressible
SRF solver from OpenFOAM.
Binary file added Docs/sphinx/geometry/rotframetests.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Exec/RegTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ if(PELE_DIM EQUAL 3)
add_subdirectory(EB-C7)
add_subdirectory(EB-C8)
add_subdirectory(EB-BluffBody)
add_subdirectory(EB-TaylorCouette)
add_subdirectory(EB-Rotor4Blade)
endif()
if(PELE_ENABLE_MASA)
add_subdirectory(MMS)
Expand Down
7 changes: 7 additions & 0 deletions Exec/RegTests/EB-Rotor4Blade/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(PELE_PHYSICS_EOS_MODEL GammaLaw)
set(PELE_PHYSICS_CHEMISTRY_MODEL Null)
set(PELE_PHYSICS_TRANSPORT_MODEL Constant)
set(PELE_PHYSICS_ENABLE_SPRAY OFF)
set(PELE_PHYSICS_SPRAY_FUEL_NUM 0)
set(PELE_PHYSICS_ENABLE_SOOT OFF)
include(BuildExeAndLib)
38 changes: 38 additions & 0 deletions Exec/RegTests/EB-Rotor4Blade/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# AMReX
DIM = 3
COMP = gnu
PRECISION = DOUBLE

# Profiling
PROFILE = FALSE
TINY_PROFILE = FALSE
COMM_PROFILE = FALSE
TRACE_PROFILE = FALSE
MEM_PROFILE = FALSE
USE_GPROF = FALSE

# Performance
USE_MPI = FALSE
USE_OMP = FALSE
USE_CUDA = FALSE
USE_HIP = FALSE
USE_SYCL = FALSE

# Debugging
DEBUG = FALSE
FSANITIZER = FALSE
THREAD_SANITIZER = FALSE

# PeleC
PELE_CVODE_FORCE_YCORDER = FALSE
PELE_USE_MAGMA = FALSE
PELE_COMPILE_AJACOBIAN = FALSE
Eos_Model := GammaLaw
Chemistry_Model := Null
Transport_Model := Constant

# GNU Make
Bpack := ./Make.package
Blocs := .
PELE_HOME := ../../..
include $(PELE_HOME)/Exec/Make.PeleC
3 changes: 3 additions & 0 deletions Exec/RegTests/EB-Rotor4Blade/Make.package
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CEXE_headers += prob.H
CEXE_headers += prob_parm.H
CEXE_sources += prob.cpp
111 changes: 111 additions & 0 deletions Exec/RegTests/EB-Rotor4Blade/prob.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#ifndef PROB_H
#define PROB_H

#include <AMReX_Print.H>
#include <AMReX_ParmParse.H>
#include <AMReX_Geometry.H>
#include <AMReX_FArrayBox.H>
#include <AMReX_REAL.H>
#include <AMReX_GpuMemory.H>

#include "mechanism.H"

#include "PeleC.H"
#include "IndexDefines.H"
#include "Constants.H"
#include "PelePhysics.H"
#include "EOS.H"

#include "Tagging.H"
#include "ProblemSpecificFunctions.H"
#include "prob_parm.H"
#include "EB.H"
#include <AMReX_EB2_IF_Rotation.H>
#include "Utilities.H"
#include "Geometry.H"

class EBConcCylinders : public pele::pelec::Geometry::Register<EBConcCylinders>
{
public:
static std::string identifier() { return "conc_cylinders"; }

void
build(const amrex::Geometry& geom, const int max_coarsening_level) override;
};

AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void
pc_initdata(
int i,
int j,
int k,
amrex::Array4<amrex::Real> const& state,
amrex::GeometryData const& geomdata,
ProbParmDevice const& prob_parm)
{
amrex::Real u = 0.0;
amrex::Real v = 0.0;
amrex::Real w = 0.0;
const amrex::Real p = prob_parm.p0;
const amrex::Real T = prob_parm.T0;
amrex::Real massfrac[NUM_SPECIES] = {1.0};
amrex::Real rho, eint;
auto eos = pele::physics::PhysicsType::eos();
eos.PYT2RE(p, massfrac, T, rho, eint);

if (prob_parm.do_rf) {
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> axis_loc = {
prob_parm.rf_axis_x, prob_parm.rf_axis_y, prob_parm.rf_axis_z};
amrex::IntVect iv(AMREX_D_DECL(i, j, k));
amrex::RealVect r = get_rotaxis_vec(iv, axis_loc, geomdata);
amrex::RealVect omgavec(0.0, 0.0, 0.0);
omgavec[prob_parm.rf_axis] = prob_parm.rf_omega;
amrex::RealVect w_cross_r = omgavec.crossProduct(r);
u = -w_cross_r[0];
v = -w_cross_r[1];
w = -w_cross_r[2];
}

state(i, j, k, URHO) = rho;
state(i, j, k, UMX) = rho * u;
state(i, j, k, UMY) = rho * v;
state(i, j, k, UMZ) = rho * w;
state(i, j, k, UEINT) = rho * eint;
state(i, j, k, UEDEN) = rho * (eint + 0.5 * (u * u + v * v + w * w));
state(i, j, k, UTEMP) = T;
for (int n = 0; n < NUM_SPECIES; n++) {
state(i, j, k, UFS + n) = rho * massfrac[n];
}

if (prob_parm.do_rf) {
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> axis_loc = {
prob_parm.rf_axis_x, prob_parm.rf_axis_y, prob_parm.rf_axis_z};
amrex::IntVect iv(AMREX_D_DECL(i, j, k));
amrex::Real rotenrg = get_rot_energy(
iv, prob_parm.rf_omega, prob_parm.rf_axis, axis_loc, geomdata);
state(i, j, k, UEDEN) -= rho * rotenrg;
}
}

AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void
bcnormal(
const amrex::Real* /*x[AMREX_SPACEDIM]*/,
const amrex::Real* /*s_int[NVAR]*/,
amrex::Real* /*s_ext[NVAR]*/,
const int /*idir*/,
const int /*sgn*/,
const amrex::Real /*time*/,
amrex::GeometryData const& /*geomdata*/,
ProbParmDevice const& /*prob_parm*/,
const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& /*turb_fluc*/)
{
}

void pc_prob_close();

using ProblemSpecificFunctions = DefaultProblemSpecificFunctions;

#endif
Loading
Loading