Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions amr-wind/boundary_conditions/wall_models/WallFunction.H
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "amr-wind/CFDSim.H"
#include "amr-wind/core/FieldBCOps.H"
#include "amr-wind/utilities/FieldPlaneAveragingFine.H"
#include "amr-wind/utilities/FieldPlaneAveraging.H"
#include "amr-wind/boundary_conditions/wall_models/LogLaw.H"
#include "amr-wind/boundary_conditions/wall_models/MOSD.H"

Expand Down Expand Up @@ -40,7 +40,7 @@ private:
//! LogLaw instance
LogLaw m_log_law;
int m_direction{2}; ///< Direction normal to wall, hardcoded to z
VelPlaneAveragingFine m_pa_vel;
VelPlaneAveraging m_pa_vel;

MOSD m_mosd;
};
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/boundary_conditions/wall_models/WallFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace amrex::literals;
namespace amr_wind {

WallFunction::WallFunction(CFDSim& sim)
: m_sim(sim), m_mesh(m_sim.mesh()), m_pa_vel(sim, m_direction)
: m_sim(sim), m_mesh(m_sim.mesh()), m_pa_vel(sim, m_direction, -1)
{
amrex::Real mu;
amrex::Real rho{1.0_rt};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "amr-wind/core/FieldRepo.H"
#include "amr-wind/equation_systems/icns/MomentumSource.H"
#include "amr-wind/core/SimTime.H"
#include "amr-wind/utilities/FieldPlaneAveragingFine.H"
#include "amr-wind/utilities/FieldPlaneAveraging.H"
#include "amr-wind/utilities/ncutils/nc_interface.H"
#include "amr-wind/wind_energy/ABLMesoscaleForcing.H"
#include "amr-wind/wind_energy/ABLMesoscaleInput.H"
Expand Down Expand Up @@ -41,13 +41,13 @@ public:
void mean_velocity_init(const ABLMesoscaleInput& ncfile);

void mean_velocity_init(
const VelPlaneAveragingFine& vavg, const ABLMesoscaleInput& ncfile);
const VelPlaneAveraging& vavg, const ABLMesoscaleInput& ncfile);

void
mean_velocity_heights(std::unique_ptr<ABLMesoscaleInput> const& ncfile);

void mean_velocity_heights(
const VelPlaneAveragingFine& vavg,
const VelPlaneAveraging& vavg,
std::unique_ptr<ABLMesoscaleInput> const& ncfile);

amrex::Vector<amrex::Real>& mom_u_error() { return m_err_U; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void ABLMesoForcingMom::mean_velocity_init(const ABLMesoscaleInput& ncfile)
}

void ABLMesoForcingMom::mean_velocity_init(
const VelPlaneAveragingFine& vavg, const ABLMesoscaleInput& ncfile)
const VelPlaneAveraging& vavg, const ABLMesoscaleInput& ncfile)
{
const int num_meso_ht = ncfile.nheights();
m_nht = vavg.ncell_line();
Expand Down Expand Up @@ -122,7 +122,7 @@ void ABLMesoForcingMom::mean_velocity_heights(
}

void ABLMesoForcingMom::mean_velocity_heights(
const VelPlaneAveragingFine& vavg,
const VelPlaneAveraging& vavg,
std::unique_ptr<ABLMesoscaleInput> const& ncfile)
{
if (m_forcing_scheme.empty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "amr-wind/core/FieldRepo.H"
#include "amr-wind/equation_systems/temperature/TemperatureSource.H"
#include "amr-wind/core/SimTime.H"
#include "amr-wind/utilities/FieldPlaneAveragingFine.H"
#include "amr-wind/utilities/FieldPlaneAveraging.H"
#include "amr-wind/utilities/ncutils/nc_interface.H"
#include "amr-wind/wind_energy/ABLMesoscaleForcing.H"
#include "amr-wind/wind_energy/ABLMesoscaleInput.H"
Expand Down Expand Up @@ -34,13 +34,13 @@ public:
void mean_temperature_init(const ABLMesoscaleInput& ncfile);

void mean_temperature_init(
const FieldPlaneAveragingFine& tavg, const ABLMesoscaleInput& ncfile);
const FieldPlaneAveraging& tavg, const ABLMesoscaleInput& ncfile);

amrex::Real
mean_temperature_heights(std::unique_ptr<ABLMesoscaleInput> const& ncfile);

amrex::Real mean_temperature_heights(
const FieldPlaneAveragingFine& tavg,
const FieldPlaneAveraging& tavg,
std::unique_ptr<ABLMesoscaleInput> const& ncfile);

amrex::Vector<amrex::Real>& theta_error() { return m_err_Theta; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void ABLMesoForcingTemp::mean_temperature_init(const ABLMesoscaleInput& ncfile)
ncfile.meso_heights().end(), m_meso_ht.begin());
}
void ABLMesoForcingTemp::mean_temperature_init(
const FieldPlaneAveragingFine& tavg, const ABLMesoscaleInput& ncfile)
const FieldPlaneAveraging& tavg, const ABLMesoscaleInput& ncfile)
{
const int num_meso_ht = ncfile.nheights();
m_nht = tavg.ncell_line();
Expand Down Expand Up @@ -116,7 +116,7 @@ amrex::Real ABLMesoForcingTemp::mean_temperature_heights(
}

amrex::Real ABLMesoForcingTemp::mean_temperature_heights(
const FieldPlaneAveragingFine& tavg,
const FieldPlaneAveraging& tavg,
std::unique_ptr<ABLMesoscaleInput> const& ncfile)
{
amrex::Real currtime;
Expand Down
5 changes: 3 additions & 2 deletions amr-wind/turbulence/LES/AMD.H
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <AMReX_GpuContainers.H>
#include <string>
#include "amr-wind/turbulence/TurbModelBase.H"
#include "amr-wind/utilities/FieldPlaneAveragingFine.H"
#include "amr-wind/utilities/FieldPlaneAveraging.H"
#include "amr-wind/core/FieldRepo.H"
#include "amr-wind/fvm/stencils.H"
#include "amr-wind/utilities/DirectionSelector.H"
Expand Down Expand Up @@ -59,7 +59,8 @@ private:
const Field& m_vel;
const Field& m_temperature;
const Field& m_rho;
FieldPlaneAveragingFine m_pa_temp;

FieldPlaneAveraging m_pa_temp;
amrex::Vector<amrex::Real> m_gravity{0.0_rt, 0.0_rt, -9.81_rt};
};

Expand Down
2 changes: 1 addition & 1 deletion amr-wind/turbulence/LES/AMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ AMD<Transport>::AMD(CFDSim& sim)
, m_vel(sim.repo().get_field("velocity"))
, m_temperature(sim.repo().get_field("temperature"))
, m_rho(sim.repo().get_field("density"))
, m_pa_temp(m_temperature, sim.time(), m_normal_dir, true)
, m_pa_temp(m_temperature, sim.time(), m_normal_dir, -1, true)
{
{
amrex::ParmParse pp("incflo");
Expand Down
1 change: 0 additions & 1 deletion amr-wind/utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ target_sources(${amr_wind_lib_name}
io_utils.cpp
IOManager.cpp
FieldPlaneAveraging.cpp
FieldPlaneAveragingFine.cpp
SecondMomentAveraging.cpp
ThirdMomentAveraging.cpp

Expand Down
60 changes: 27 additions & 33 deletions amr-wind/utilities/FieldPlaneAveraging.H
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,24 @@ public:
* \param field_in [in] Field to be averaged
* \param time [in] Time instance to determine output frequencies
* \param axis_in [in] Direction along which planes are computed
* \param max_level [in] Maximum mesh level to consider when calculating
* averages
* \param compute_deriv [in] Should the derivative of the averages be
* computed
*/
FPlaneAveraging(
const FType& field_in,
const amr_wind::SimTime& time,
int axis_in,
int max_level,
bool compute_deriv = false);

virtual ~FPlaneAveraging() = default;

virtual void operator()();

void convert_x_to_ind(amrex::Real x, int& ind, amrex::Real& c) const;

/** evaluate line average at specific location for any average component */
[[nodiscard]] amrex::Real
line_average_interpolated(amrex::Real x, int comp) const;
Expand All @@ -72,7 +77,7 @@ public:
[[nodiscard]] amrex::Real xlo() const { return m_xlo; };

[[nodiscard]] int axis() const { return m_axis; };
[[nodiscard]] int level() const { return m_level; };
[[nodiscard]] int level() const { return m_max_level; };
[[nodiscard]] int ncomp() const { return m_ncomp; };
[[nodiscard]] int ncell_plane() const { return m_ncell_plane; };
[[nodiscard]] int ncell_line() const { return m_ncell_line; };
Expand Down Expand Up @@ -110,27 +115,26 @@ protected:
of each cell along a line*/

amrex::Real m_dx; /** mesh spacing in axis direction*/
amrex::Real m_xlo; /** bottom of domain in axis direction */
amrex::Real m_xlo; /** bottom of line */
amrex::Real m_xhi; /** top of line */

int m_ncell_plane; /** number of cells in plane */
int m_ncell_line; /** number of cells along line */

int m_precision = 4; /** precision for line plot text file */
const int m_level =
0; /** level for plane averaging for now fixed at level=0 */
int m_precision = 6; /** precision for line plot text file */
int m_last_updated_index = -1; /** keep track of the last time index that
the operator was called */

const FType& m_field;
const SimTime& m_time;
const int m_axis;
int m_max_level;
const bool m_comp_deriv;

public: // public for GPU
/** fill line storage with averages */
template <typename IndexSelector>
void
compute_averages(const IndexSelector& idxOp, const amrex::MultiFab& mfab);
void compute_averages(const IndexSelector& idxOp);

/** fill derivatives of line storage */
void compute_line_derivatives();
Expand All @@ -145,7 +149,7 @@ using ScratchFieldPlaneAveraging = FPlaneAveraging<ScratchField>;
class VelPlaneAveraging : public FieldPlaneAveraging
{
public:
VelPlaneAveraging(CFDSim& sim, int axis_in);
VelPlaneAveraging(CFDSim& sim, int axis_in, int max_level);

~VelPlaneAveraging() override = default;

Expand All @@ -155,17 +159,19 @@ private:
amrex::Vector<amrex::Real>
m_line_hvelmag_average; /** line storage for the average horizontal
velocity magnitude */
//! line storage for the derivative of average horizontal velocity magnitude
amrex::Vector<amrex::Real> m_line_hvelmag_deriv;

amrex::Vector<amrex::Real>
m_line_Su_average; /** line storage for the average horizontal
velocity magnitude time x-velocity */

amrex::Vector<amrex::Real>
m_line_Sv_average; /** line storage for the average horizontal
velocity magnitude time y-velocity */

public: // public for GPU
/** fill line storage with horizontal velocity magnitude averages */
template <typename IndexSelector>
void compute_hvelmag_averages(
const IndexSelector& idx_op,
int h1_idx,
int h2_idx,
const amrex::MultiFab& mfab);
void compute_hvelmag_averages(const IndexSelector& idxOp);

/** return vector containing horizontal velocity magnitude average */
const amrex::Vector<amrex::Real>& line_hvelmag_average()
Expand All @@ -177,24 +183,12 @@ public: // public for GPU
* magnitude */
[[nodiscard]] amrex::Real
line_hvelmag_average_interpolated(amrex::Real x) const;
/** evaluate line average at specific cell for horizontal velocity magnitude
*/
[[nodiscard]] amrex::Real line_hvelmag_average_cell(int ind) const;

/** compute derivatives of horizontal velocity magnitude */
void compute_line_hvelmag_derivatives();
/** evaluate line average derivative at specific location for horizontal
velocity magnitude */
[[nodiscard]] amrex::Real
line_hvelmag_derivative_interpolated(amrex::Real x) const;
/** evaluate derivative of a line average at specific cell horizontal
velocity magnitude */
[[nodiscard]] amrex::Real
line_hvelmag_derivative_of_average_cell(int ind) const;

void output_line_average_ascii(
const std::string& filename, int step, amrex::Real time);
void output_line_average_ascii(int step, amrex::Real time);
/** evaluate line haverage at specific location for horizontal velocity
* magnitude times x-velocity */
[[nodiscard]] amrex::Real line_su_average_interpolated(amrex::Real x) const;
/** evaluate line haverage at specific location for horizontal velocity
* magnitude times y-velocity */
[[nodiscard]] amrex::Real line_sv_average_interpolated(amrex::Real x) const;
};

} // namespace amr_wind
Expand Down
Loading
Loading