Skip to content

Commit

Permalink
Merge branch 'development' into LSM
Browse files Browse the repository at this point in the history
  • Loading branch information
AMLattanzi authored Jan 31, 2024
2 parents 06d0ab4 + f872012 commit 524753f
Show file tree
Hide file tree
Showing 35 changed files with 1,256 additions and 487 deletions.
24 changes: 24 additions & 0 deletions Docs/sphinx_doc/Inputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,30 @@ List of Parameters
| | Rayleigh damping | | |
+----------------------------------+-------------------+-------------------+-------------+

In addition, custom forcings or tendencies may be defined on a problem-specific
basis. This affords additional flexibility in defining the RHS source term as
a function of time and/or height. Implementation entails modifying problem
source code inside the Exec directory and overriding the ``update_*_sources()``
function(s).

+--------------------------------------------+-------------------+-------------------+-------------+
| Parameter | Definition | Acceptable | Default |
| | | Values | |
+============================================+===================+===================+=============+
| **erf.custom_forcing_uses_primitive_vars** | User-defined | true or false | false |
| | source terms set | | |
| | the tendency of | | |
| | primitive | | |
| | variables instead | | |
| | of conserved | | |
| | quantities | | |
| | (rho*prim_var) | | |
+--------------------------------------------+-------------------+-------------------+-------------+
| **erf.add_custom_rhotheta_forcing** | Apply the | true or false | false |
| | user-defined | | |
| | temperature source| | |
| | term | | |
+--------------------------------------------+-------------------+-------------------+-------------+

Initialization
==============
Expand Down
1 change: 1 addition & 0 deletions Exec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ else ()
add_subdirectory(DevTests/MiguelDev)
add_subdirectory(DevTests/MetGrid)
add_subdirectory(DevTests/LandSurfaceModel)
add_subdirectory(DevTests/TemperatureSource)
endif()
13 changes: 6 additions & 7 deletions Exec/DevTests/MetGrid/inputs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ zlo.type = "NoSlipWall"
zhi.type = "SlipWall"

# TIME STEP CONTROL
erf.fixed_dt = 1.0 # fixed time step depending on grid resolution
erf.fixed_dt = 0.5 # fixed time step depending on grid resolution

erf.use_terrain = true
erf.terrain_smoothing = 2
Expand All @@ -39,8 +39,8 @@ erf.check_int = 100 # number of timesteps between checkpoints

# PLOTFILES
erf.plot_file_1 = plt # prefix of plotfile name
erf.plot_int_1 = 1 # number of timesteps between plotfiles
erf.plot_vars_1 = qv Rhoqv density dens_hse rhoadv_0 x_velocity y_velocity z_velocity pressure temp theta z_phys mapfac pres_hse pert_pres KE QKE
erf.plot_int_1 = 10 # number of timesteps between plotfiles
erf.plot_vars_1 = density dens_hse rhoadv_0 x_velocity y_velocity z_velocity pressure temp theta z_phys mapfac pres_hse pert_pres

# SOLVER CHOICE
erf.alpha_T = 1.0
Expand All @@ -49,18 +49,17 @@ erf.use_gravity = true

erf.molec_diff_type = "None"
erf.les_type = "Smagorinsky"
#erf.les_type = "Deardorff"
erf.Cs = 0.1

erf.moisture_model = "SAM"
erf.moisture_model = "NullMoist"

#erf.terrain_z_levels = 0 130 354 583 816 1054 1549 2068 2615 3193 3803 4450 5142 5892 6709 7603 8591 9702 10967 12442 14230 16610 18711 20752 22133 23960 26579 28493 31236 33699 36068 40000

# INITIALIZATION WITH ATM DATA
erf.metgrid_bdy_width = 5
erf.metgrid_bdy_width = 7
erf.metgrid_bdy_set_width = 1
erf.init_type = "metgrid"
erf.nc_init_file_0 = "met_em.d01.2022-06-18_00:00:00.nc" "met_em.d01.2022-06-18_06:00:00.nc" "met_em.d01.2022-06-18_12:00:00.nc" "met_em.d01.2022-06-18_18:00:00.nc"
erf.nc_init_file_0 = "met_em.d01.2022-06-18_00_00_00.nc" "met_em.d01.2022-06-18_06_00_00.nc"

#There will be no OpenMP tiling
fabarray.mfiter_tile_size = 1024 1024 1024
14 changes: 7 additions & 7 deletions Exec/DevTests/MetGrid/inputs_fitch_flowmas
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 100
max_step = 1000

amrex.fpe_trap_invalid = 1
amrex.fpe_trap_zero = 1
Expand All @@ -19,7 +19,7 @@ zlo.type = "NoSlipWall"
zhi.type = "SlipWall"

# TIME STEP CONTROL
erf.fixed_dt = 1.0 # fixed time step depending on grid resolution
erf.fixed_dt = 1.0 # fixed time step depending on grid resolution

erf.use_terrain = true
erf.terrain_smoothing = 2
Expand All @@ -34,12 +34,12 @@ amr.max_level = 0 # maximum level number allowed

# CHECKPOINT FILES
erf.check_file = chk # root name of checkpoint file
erf.check_int = 1 # number of timesteps between checkpoints
erf.check_int = 25 # number of timesteps between checkpoints

# PLOTFILES
erf.plot_file_1 = plt # prefix of plotfile name
erf.plot_int_1 = 1 # number of timesteps between plotfiles
erf.plot_vars_1 = qv Rhoqv density dens_hse rhoadv_0 x_velocity y_velocity z_velocity pressure temp theta z_phys mapfac pres_hse pert_pres KE QKE
erf.plot_int_1 = 25 # number of timesteps between plotfiles
erf.plot_vars_1 = density dens_hse rhoadv_0 x_velocity y_velocity z_velocity pressure temp theta z_phys mapfac pres_hse pert_pres

# SOLVER CHOICE
erf.alpha_T = 1.0
Expand All @@ -50,10 +50,10 @@ erf.molec_diff_type = "None"
erf.les_type = "Smagorinsky"
erf.Cs = 0.1

erf.moisture_model = "Kessler"
erf.moisture_model = "NullMoist"

# INITIALIZATION WITH ATM DATA
erf.metgrid_bdy_width = 5
erf.metgrid_bdy_width = 7
erf.metgrid_bdy_set_width = 1
erf.init_type = "metgrid"
erf.nc_init_file_0 = "met_em.d01.2015-04-01_00_00_00.nc" "met_em.d01.2015-04-01_08_00_00.nc"
Expand Down
12 changes: 12 additions & 0 deletions Exec/DevTests/TemperatureSource/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(erf_exe_name erf_abl_with_temperature_source)

add_executable(${erf_exe_name} "")
target_sources(${erf_exe_name}
PRIVATE
prob.cpp
)

target_include_directories(${erf_exe_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

include(${CMAKE_SOURCE_DIR}/CMake/BuildERFExe.cmake)
build_erf_exe(${erf_exe_name})
34 changes: 34 additions & 0 deletions Exec/DevTests/TemperatureSource/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# AMReX
COMP = gnu
PRECISION = DOUBLE

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

# Performance
USE_MPI = TRUE
USE_OMP = FALSE

USE_CUDA = FALSE
USE_HIP = FALSE
USE_SYCL = FALSE

# Debugging
DEBUG = FALSE

TEST = TRUE
USE_ASSERTION = TRUE

#USE_POISSON_SOLVE = TRUE

# GNU Make
Bpack := ./Make.package
Blocs := .
ERF_HOME := ../..
ERF_PROBLEM_DIR = $(ERF_HOME)/Exec/DevTests/TemperatureSource
include $(ERF_HOME)/Exec/Make.ERF
2 changes: 2 additions & 0 deletions Exec/DevTests/TemperatureSource/Make.package
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CEXE_headers += prob.H
CEXE_sources += prob.cpp
1 change: 1 addition & 0 deletions Exec/DevTests/TemperatureSource/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a copy of the ABL problem, but with update_rhotheta_sources defined
3 changes: 3 additions & 0 deletions Exec/DevTests/TemperatureSource/input_sounding
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1000.0 300.0 0.0
0.0 300.0 0.0 10.0 0.0
1000.0 300.0 0.0 10.0 0.0
50 changes: 50 additions & 0 deletions Exec/DevTests/TemperatureSource/neutral_column.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
stop_time = 999.9
max_step = 20

amrex.fpe_trap_invalid = 1

fabarray.mfiter_tile_size = 1024 1024 1024

# PROBLEM SIZE & GEOMETRY
geometry.prob_extent = 40. 40. 640.
amr.n_cell = 4 4 64

geometry.is_periodic = 1 1 0

zlo.type = "SlipWall"
zhi.type = "SlipWall"

# INITIALIZATION
erf.init_type = input_sounding
erf.init_sounding_ideal = true

# TIME STEP CONTROL
erf.fixed_dt = 0.1

# DIAGNOSTICS & VERBOSITY
amr.v = 1 # verbosity in Amr.cpp
erf.v = 1 # verbosity in ERF.cpp -- needs to be 1 to write out data_log files
erf.sum_interval = 1 # timesteps between computing mass

# REFINEMENT / REGRIDDING
amr.max_level = 0 # maximum level number allowed

# CHECKPOINT FILES
erf.check_file = chk # root name of checkpoint file
erf.check_int = -1 # number of timesteps between checkpoints

# PLOTFILES
erf.plot_file_1 = plt # prefix of plotfile name
erf.plot_int_1 = 5 # number of timesteps between plotfiles (DEBUG)
erf.plot_vars_1 = density x_velocity y_velocity z_velocity pressure theta

# SOLVER CHOICES
erf.use_gravity = true
erf.use_coriolis = false

erf.molec_diff_type = "None"
erf.les_type = "None"

erf.add_custom_rhotheta_forcing = true
erf.custom_forcing_uses_primitive_vars = true
85 changes: 85 additions & 0 deletions Exec/DevTests/TemperatureSource/prob.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#ifndef _PROB_H_
#define _PROB_H_

#include <string>

#include "AMReX_REAL.H"

#include "prob_common.H"

struct ProbParm : ProbParmDefaults {
amrex::Real rho_0 = 0.0;
amrex::Real T_0 = 0.0;
amrex::Real A_0 = 1.0;
amrex::Real QKE_0 = 0.1;

amrex::Real U_0 = 0.0;
amrex::Real V_0 = 0.0;
amrex::Real W_0 = 0.0;

// random initial perturbations (legacy code)
amrex::Real U_0_Pert_Mag = 0.0;
amrex::Real V_0_Pert_Mag = 0.0;
amrex::Real W_0_Pert_Mag = 0.0;
amrex::Real T_0_Pert_Mag = 0.0; // perturbation to rho*Theta

// divergence-free initial perturbations
amrex::Real pert_deltaU = 0.0;
amrex::Real pert_deltaV = 0.0;
amrex::Real pert_periods_U = 5.0;
amrex::Real pert_periods_V = 5.0;
amrex::Real pert_ref_height = 100.0;

// rayleigh damping
amrex::Real dampcoef = 0.2; // inverse time scale [1/s]
amrex::Real zdamp = 500.0; // damping depth [m] from model top

// helper vars
amrex::Real aval;
amrex::Real bval;
amrex::Real ufac;
amrex::Real vfac;
}; // namespace ProbParm

class Problem : public ProblemBase
{
public:
Problem(const amrex::Real* problo, const amrex::Real* probhi);

#include "Prob/init_constant_density_hse.H"
#include "Prob/init_rayleigh_damping.H"

void init_custom_pert (
const amrex::Box& bx,
const amrex::Box& xbx,
const amrex::Box& ybx,
const amrex::Box& zbx,
amrex::Array4<amrex::Real > const& state,
amrex::Array4<amrex::Real > const& x_vel,
amrex::Array4<amrex::Real > const& y_vel,
amrex::Array4<amrex::Real > const& z_vel,
amrex::Array4<amrex::Real > const& r_hse,
amrex::Array4<amrex::Real > const& p_hse,
amrex::Array4<amrex::Real const> const& z_nd,
amrex::Array4<amrex::Real const> const& z_cc,
amrex::GeometryData const& geomdata,
amrex::Array4<amrex::Real const> const& mf_m,
amrex::Array4<amrex::Real const> const& mf_u,
amrex::Array4<amrex::Real const> const& mf_v,
const SolverChoice& sc) override;

void update_rhotheta_sources (
const amrex::Real& time,
amrex::Vector<amrex::Real>& src,
amrex::Gpu::DeviceVector<amrex::Real>& d_src,
const amrex::Geometry& geom,
std::unique_ptr<amrex::MultiFab>& z_phys_cc) override;

protected:
std::string name() override { return "ABL"; }

private:
ProbParm parms;
};

#endif
Loading

0 comments on commit 524753f

Please sign in to comment.