Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
mukul1992 committed Oct 18, 2024
1 parent 5027d26 commit be4a319
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 38 deletions.
2 changes: 1 addition & 1 deletion amr-wind/CFDSim.H
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private:

#ifdef ERF_AW_MULTIBLOCK
MultiBlockContainer* m_mbc = nullptr;
ReadERFFunction m_read_erf {nullptr};
ReadERFFunction m_read_erf{nullptr};
#endif
};

Expand Down
4 changes: 2 additions & 2 deletions amr-wind/incflo.H
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ public:
void ReadCheckpointFile();

#ifdef ERF_AW_MULTIBLOCK
void SetMultiBlockPointer(MultiBlockContainer *mbc) { m_sim.set_mbc(mbc); }
void set_read_erf(ReadERFFunction fcn) {m_sim.set_read_erf(fcn);}
void SetMultiBlockPointer(MultiBlockContainer* mbc) { m_sim.set_mbc(mbc); }
void set_read_erf(ReadERFFunction fcn) { m_sim.set_read_erf(fcn); }
#endif

private:
Expand Down
4 changes: 3 additions & 1 deletion amr-wind/incflo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ incflo::incflo()
// But the arrays for them have been resized.

#ifdef ERF_AW_MULTIBLOCK
amrex::Print() << std::endl << "AMR-Wind is initializing.. "<< std::endl << std::endl;
amrex::Print() << std::endl
<< "AMR-Wind is initializing.. " << std::endl
<< std::endl;
#endif

// Check if dry run is requested and set up if so
Expand Down
14 changes: 8 additions & 6 deletions amr-wind/utilities/index_operations.H
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace amr_wind::utils {

//! Return closest index (from lower) of value in vector, lbound verion for ERF coupling
AMREX_FORCE_INLINE int
closest_index_ubound(const amrex::Vector<amrex::Real>& vec, const amrex::Real value)
//! Return closest index (from lower) of value in vector
//! lbound verion is required for ERF coupling
AMREX_FORCE_INLINE int closest_index_ubound(
const amrex::Vector<amrex::Real>& vec, const amrex::Real value)
{
auto const it = std::upper_bound(vec.begin(), vec.end(), value);
AMREX_ALWAYS_ASSERT(it != vec.end());
Expand All @@ -19,11 +20,12 @@ closest_index_ubound(const amrex::Vector<amrex::Real>& vec, const amrex::Real va
return std::max(idx - 1, 0);
}

AMREX_FORCE_INLINE int
closest_index_lbound(const amrex::Vector<amrex::Real>& vec, const amrex::Real value)
AMREX_FORCE_INLINE int closest_index_lbound(
const amrex::Vector<amrex::Real>& vec, const amrex::Real value)
{
amrex::Real one_minus_eps = 1.0 - 1.e-8;
auto const it = std::lower_bound(vec.begin(), vec.end(), one_minus_eps*value);
auto const it =
std::lower_bound(vec.begin(), vec.end(), one_minus_eps * value);
AMREX_ALWAYS_ASSERT(it != vec.end());

const int idx = static_cast<int>(std::distance(vec.begin(), it));
Expand Down
10 changes: 5 additions & 5 deletions amr-wind/wind_energy/ABLBoundaryPlane.H
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public:
io_mode mode() const { return m_io_mode; }

#ifdef ERF_AW_MULTIBLOCK
MultiBlockContainer* mbc() {return *m_mbc;}
MultiBlockContainer* mbc() { return *m_mbc; }
#endif

private:
Expand All @@ -174,11 +174,11 @@ private:

#ifdef ERF_AW_MULTIBLOCK
// pointer to pointer : when ABL boundary plane gets intiialized, amr-wind
// CFDsim does not yet have the up to date pointer to the mbc or the read_erf function
// be careful: if this is used before amr-wind gets the mbc pointer set
// bad things will happen
// CFDsim does not yet have the up to date pointer to the mbc or the
// read_erf function, be careful: if this is used before amr-wind gets the
// mbc pointer set bad things will happen
MultiBlockContainer** m_mbc;
ReadERFFunction* m_read_erf {nullptr};
ReadERFFunction* m_read_erf{nullptr};
#endif

#ifdef AMR_WIND_USE_NETCDF
Expand Down
24 changes: 15 additions & 9 deletions amr-wind/wind_energy/ABLBoundaryPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ void InletData::read_data_native(
auto ori = oit();

amrex::Real one_plus_eps = 1.0 + 1.e-8;
AMREX_ALWAYS_ASSERT(((m_tn <= one_plus_eps*time) && (time <= one_plus_eps*m_tnp1)));
AMREX_ALWAYS_ASSERT(
((m_tn <= one_plus_eps * time) && (time <= one_plus_eps * m_tnp1)));
AMREX_ALWAYS_ASSERT(fld->num_comp() == bndry_n[ori].nComp());
AMREX_ASSERT(bndry_n[ori].boxArray() == bndry_np1[ori].boxArray());

Expand Down Expand Up @@ -254,9 +255,12 @@ bool InletData::is_populated(amrex::Orientation ori) const
}

ABLBoundaryPlane::ABLBoundaryPlane(CFDSim& sim)
: m_time(sim.time()), m_repo(sim.repo()), m_mesh(sim.mesh())
: m_time(sim.time())
, m_repo(sim.repo())
, m_mesh(sim.mesh())
#ifdef ERF_AW_MULTIBLOCK
, m_mbc(sim.mbc()), m_read_erf(sim.get_read_erf())
, m_mbc(sim.mbc())
, m_read_erf(sim.get_read_erf())
#endif
{
amrex::ParmParse pp("ABL");
Expand Down Expand Up @@ -294,7 +298,8 @@ ABLBoundaryPlane::ABLBoundaryPlane(CFDSim& sim)
}
#endif

if (!(m_out_fmt == "native" || m_out_fmt == "netcdf" || m_out_fmt == "erf-multiblock")) {
if (!((m_out_fmt == "native") || (m_out_fmt == "netcdf") ||
(m_out_fmt == "erf-multiblock"))) {
amrex::Print() << "Warning: boundary output format not recognized, "
"changing to native format"
<< std::endl;
Expand Down Expand Up @@ -350,7 +355,8 @@ void ABLBoundaryPlane::initialize_data()
}
}
if ((m_io_mode == io_mode::output) && (m_out_fmt == "erf-multiblock")) {
amrex::Abort("ABLBoundaryPlane: can't output data in erf-multiblock mode");
amrex::Abort(
"ABLBoundaryPlane: can't output data in erf-multiblock mode");
}
}

Expand Down Expand Up @@ -766,7 +772,8 @@ void ABLBoundaryPlane::read_header()
}
} else if (m_out_fmt == "erf-multiblock") {

m_in_times.push_back(-1.0e13); // create space for storing time at erf old and new timestep
m_in_times.push_back(-1.0e13); // create space for storing time at erf
// old and new timestep
m_in_times.push_back(-1.0e13);

int nc = 0;
Expand Down Expand Up @@ -804,10 +811,9 @@ void ABLBoundaryPlane::read_file()

#ifdef ERF_AW_MULTIBLOCK
if (m_out_fmt == "erf-multiblock") {
//m_read_erf = sim.get_read_erf();
// m_read_erf = sim.get_read_erf();
ReadERFFunction read_erf = *m_read_erf;
if (read_erf)
{
if (read_erf) {
read_erf(m_time, m_in_times, m_in_data, m_fields, mbc());
} else {
amrex::Abort("read_erf function is undefined.");
Expand Down
18 changes: 11 additions & 7 deletions amr-wind/wind_energy/ABLFieldInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ void ABLFieldInit::initialize_from_inputfile()
// ABL-with-bubble
pp_abl.query("use_bubble", m_use_bubble);
if (m_use_bubble) {
amrex::Print() << "Initializing with bubble" << std::endl;
pp_abl.getarr("bubble_loc", m_bubble_loc);
pp_abl.query("bubble_radius", m_bubble_radius);
pp_abl.query("bubble_temp_ratio", m_bubble_temp_ratio);
amrex::Print() << "Initializing with bubble" << std::endl;
pp_abl.getarr("bubble_loc", m_bubble_loc);
pp_abl.query("bubble_radius", m_bubble_radius);
pp_abl.query("bubble_temp_ratio", m_bubble_temp_ratio);
} else {
amrex::Print() << "Not initializing with bubble" << std::endl;
amrex::Print() << "Not initializing with bubble" << std::endl;
}

// Temperature variation as a function of height
Expand Down Expand Up @@ -259,8 +259,12 @@ void ABLFieldInit::operator()(

amrex::Real ratio = 1.0;
if (m_use_bubble) {
amrex::Real radius = std::sqrt((x-bcx)*(x-bcx) + (y-bcy)*(y-bcy) + (z-bcz)*(z-bcz));
ratio = 1.0 + (m_bubble_temp_ratio - 1.0) * exp(-0.5 * radius* radius / (m_bubble_radius * m_bubble_radius));
amrex::Real radius = std::sqrt(
(x - bcx) * (x - bcx) + (y - bcy) * (y - bcy) +
(z - bcz) * (z - bcz));
ratio = 1.0 + (m_bubble_temp_ratio - 1.0) *
exp(-0.5 * radius * radius /
(m_bubble_radius * m_bubble_radius));
}
temperature(i, j, k, 0) *= ratio;

Expand Down
14 changes: 7 additions & 7 deletions amr-wind/wind_energy/ABLReadERFFcn.H
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

class MultiBlockContainer;
namespace amr_wind {
class InletData;
class InletData;
}

using ReadERFFunction = std::function <void (
const amr_wind::SimTime&,
amrex::Vector<amrex::Real>&,
amr_wind::InletData&,
const amrex::Vector<amr_wind::Field*>&,
MultiBlockContainer* )>;
using ReadERFFunction = std::function<void(
const amr_wind::SimTime&,
amrex::Vector<amrex::Real>&,
amr_wind::InletData&,
const amrex::Vector<amr_wind::Field*>&,
MultiBlockContainer*)>;

#endif /* ABLREADERFFCN_H */

0 comments on commit be4a319

Please sign in to comment.