Skip to content

Commit

Permalink
Data Sampler for Plane/Line Output (#1897)
Browse files Browse the repository at this point in the history
* Super rough but it plotted a line.

* Need to test on multi-proc.

* codespell fix.

* Plot T and Wsp and clean up the realBox location.

* Bump AMReX hash.
  • Loading branch information
AMLattanzi authored Oct 21, 2024
1 parent e3adba1 commit be89c40
Show file tree
Hide file tree
Showing 7 changed files with 578 additions and 1 deletion.
68 changes: 68 additions & 0 deletions Docs/sphinx_doc/Inputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,74 @@ The requested output files have the following columns:
#. SGS turbulence dissipation, :math:`\epsilon` (m2/s3)


Data Sampling Outputs
==================

Data along query lines or planes may be output during the simulation if
``erf.do_line_sampling = true`` or ``erf.do_plane_sampling = true``, respectively.
The potential temperature and wind-speed will be written to native ``plt_line/plane``
at the step frequency dictated by ``erf.sampler_interval = <int>``. For line sampling,
users must prescribe ``sample_line_lo`` and ``sample_line_hi`` inputs which are 3 integer
values corresponding to the (i,j,k) indices at the beginning and end of the line.
Additionally, users must specify ``sample_line_dir`` to prescribed the direction of
the line. The same inputs are used for the plane sampling except that ``sample_plane_lo/hi``
must be the physical locations of the plane corners. This output functionality has
not been implemented for terrain.

.. _list-of-parameters-10b:


List of Parameters
------------------

+-------------------------------+------------------+----------------+----------------+
| Parameter | Definition | Acceptable | Default |
| | | Values | |
+===============================+==================+================+================+
| **erf.sampler_interval** | Output | Integer | -1 |
| | frequency | | |
+-------------------------------+------------------+----------------+----------------+
| **erf.do_line_sampling** | Flag to do line | Boolean | false |
| | sampling | | |
| | | | |
+-------------------------------+------------------+----------------+----------------+
| **erf.do_plane_sampling** | Flag to do plane | Boolean | false |
| | sampling | | |
| | | | |
+-------------------------------+------------------+----------------+----------------+
| **erf.sample_line_dir** | Directionality | Integer | None |
| | of the line | | |
+-------------------------------+------------------+----------------+----------------+
| **erf.sample_plane_dir** | Directionality | Integer | None |
| | of the plane | | |
+-------------------------------+------------------+----------------+----------------+
| **erf.sample_line_lo/hi** | Bounding (i,j,k) | 3 Integers per | None |
| | on the line(s) | line | |
+-------------------------------+------------------+----------------+----------------+
| **erf.sample_plane_lo/hi** | Bounding point | 3 Reals per | None |
| | on the plane(s) | plane | |
+-------------------------------+------------------+----------------+----------------+

.. _examples-of-usage-10b:

Example of Usage
-----------------

::

erf.sampler_interval = 1 # Write plt files every step

erf.do_line_sampling = true # Do line sampling
erf.sample_line_lo = 5 32 5 10 32 5 # Lo points for two lines
erf.sample_line_hi = 5 32 25 1000 32 5 # Hi points for two lines
erf.sample_line_dir = 2 0 # One line in z and one in x

erf.do_plane_sampling = true # Do plane sampling
erf.sample_plane_lo = 48.0 48.0 32.0 # Lo points for one plane
erf.sample_plane_hi = 320.0 320.0 32.0 # Hi points for one plane
erf.sample_plane_dir = 2 # One plane with z normal


Advection Schemes
=================

Expand Down
74 changes: 74 additions & 0 deletions Exec/ABL/inputs_DataSampler
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 4000

amrex.fpe_trap_invalid = 1

fabarray.mfiter_tile_size = 1024 1024 1024

# PROBLEM SIZE & GEOMETRY
geometry.prob_extent = 1024 1024 1024
amr.n_cell = 64 64 64

geometry.is_periodic = 1 1 0

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

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

# DIAGNOSTICS & VERBOSITY
erf.sum_interval = 1 # timesteps between computing mass
erf.v = 1 # verbosity in ERF.cpp
amr.v = 1 # verbosity in Amr.cpp

erf.data_log = my_data_file

erf.sampler_interval = 1
erf.do_line_sampling = true
erf.sample_line_lo = 5 32 5 10 32 5
erf.sample_line_hi = 5 32 25 1000 32 5
erf.sample_line_dir = 2 0

erf.do_plane_sampling = true
erf.sample_plane_lo = 48.0 48.0 32.0
erf.sample_plane_hi = 320.0 320.0 32.0
erf.sample_plane_dir = 2

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

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

# PLOTFILES
erf.plot_file_1 = plt # prefix of plotfile name
erf.plot_int_1 = 10 # number of timesteps between plotfiles
erf.plot_vars_1 = density rhoadv_0 x_velocity y_velocity z_velocity pressure temp theta

# SOLVER CHOICE
erf.alpha_T = 0.0
erf.alpha_C = 1.0
erf.use_gravity = false

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

erf.init_type = "uniform"

# PROBLEM PARAMETERS
prob.rho_0 = 1.0
prob.A_0 = 1.0

prob.U_0 = 10.0
prob.V_0 = 0.0
prob.W_0 = 0.0
prob.T_0 = 300.0

# Higher values of perturbations lead to instability
# Instability seems to be coming from BC
prob.U_0_Pert_Mag = 0.08
prob.V_0_Pert_Mag = 0.08 #
prob.W_0_Pert_Mag = 0.0
6 changes: 6 additions & 0 deletions Source/ERF.H
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <ERF_MRI.H>
#include <ERF_PhysBCFunct.H>
#include <ERF_FillPatcher.H>
#include <ERF_SampleData.H>

#ifdef ERF_USE_PARTICLES
#include "ERF_ParticleData.H"
Expand Down Expand Up @@ -1263,6 +1264,11 @@ private:
amrex::ParallelDescriptor::Barrier("ERF::setRecordSampleLineInfo");
}

// Data sampler for line and plane output
int sampler_interval = -1;
amrex::Real sampler_per = -1.0;
std::unique_ptr<SampleData> data_sampler = nullptr;

amrex::Vector<std::unique_ptr<std::fstream> > datalog;
amrex::Vector<std::string> datalogname;

Expand Down
15 changes: 15 additions & 0 deletions Source/ERF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,12 @@ ERF::post_timestep (int nstep, Real time, Real dt_lev0)
}
}

// Write plane/line sampler data
if (is_it_time_for_action(nstep, time, dt_lev0, sampler_interval, sampler_per) && (data_sampler) ) {
data_sampler->get_sample_data(geom, vars_new);
data_sampler->write_sample_data(t_new, istep, ref_ratio, geom);
}

// Moving terrain
if ( solverChoice.use_terrain && (solverChoice.terrain_type == TerrainType::Moving) )
{
Expand Down Expand Up @@ -1167,6 +1173,11 @@ ERF::InitData_post ()

}

// Create object to do line and plane sampling if needed
bool do_line = false; bool do_plane = false;
pp.query("do_line_sampling",do_line); pp.query("do_plane_sampling",do_plane);
if (do_line || do_plane) { data_sampler = std::make_unique<SampleData>(do_line, do_plane); }

#ifdef ERF_USE_EB
bool write_eb_surface = false;
pp.query("write_eb_surface", write_eb_surface);
Expand Down Expand Up @@ -1495,6 +1506,10 @@ ERF::ReadParameters ()
pp.query("column_loc_y", column_loc_y);
pp.query("column_file_name", column_file_name);

// Sampler output frequency
pp.query("sampler_per", sampler_per);
pp.query("sampler_interval", sampler_interval);

// Specify information about outputting planes of data
pp.query("output_bndry_planes", output_bndry_planes);
pp.query("bndry_output_planes_interval", bndry_output_planes_interval);
Expand Down
Loading

0 comments on commit be89c40

Please sign in to comment.