Skip to content

Commit

Permalink
new class method for boxes, use it
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf committed Sep 20, 2024
1 parent 31e6e99 commit c99cba2
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 8 deletions.
6 changes: 6 additions & 0 deletions amr-wind/utilities/sampling/FreeSurfaceSampler.H
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public:

//! Populate and return a vector of probe locations to be sampled
void sampling_locations(SampleLocType& /*sample_locs**/) const override;

//! Populate the vector with coordinates of the sampling locations inside
//! boxes
void sampling_locations(
SampleLocType&, const amrex::Vector<amrex::Box>&) const override;

Check warning on line 31 in amr-wind/utilities/sampling/FreeSurfaceSampler.H

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

all parameters should be named in a function [readability-named-parameter]

void output_locations(SampleLocType& sample_locs) const override
{
return sampling_locations(sample_locs);
Expand Down
14 changes: 13 additions & 1 deletion amr-wind/utilities/sampling/FreeSurfaceSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,19 @@ void FreeSurfaceSampler::check_bounds()
void FreeSurfaceSampler::sampling_locations(SampleLocType& sample_locs) const
{
AMREX_ALWAYS_ASSERT(sample_locs.locations().empty());

const int lev = 0;
const auto domain = m_sim.mesh().Geom(lev).Domain();
sampling_locations(sample_locs, {domain});

AMREX_ALWAYS_ASSERT(sample_locs.locations().size() == num_points());
}

void FreeSurfaceSampler::sampling_locations(
SampleLocType& sample_locs, const amrex::Vector<amrex::Box>& boxes) const

Check warning on line 380 in amr-wind/utilities/sampling/FreeSurfaceSampler.cpp

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

unused parameter 'boxes' [-Wunused-parameter]

Check warning on line 380 in amr-wind/utilities/sampling/FreeSurfaceSampler.cpp

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

unused parameter 'boxes' [clang-diagnostic-unused-parameter]

Check warning on line 380 in amr-wind/utilities/sampling/FreeSurfaceSampler.cpp

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

unused parameter 'boxes' [-Wunused-parameter]

Check warning on line 380 in amr-wind/utilities/sampling/FreeSurfaceSampler.cpp

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

unused parameter 'boxes' [-Wunused-parameter]
{
AMREX_ALWAYS_ASSERT(sample_locs.locations().empty());

int idx = 0;
for (int j = 0; j < m_npts_dir[1]; ++j) {
for (int i = 0; i < m_npts_dir[0]; ++i) {
Expand All @@ -381,7 +394,6 @@ void FreeSurfaceSampler::sampling_locations(SampleLocType& sample_locs) const
++idx;
}
}
AMREX_ALWAYS_ASSERT(sample_locs.locations().size() == num_points());
}

bool FreeSurfaceSampler::update_sampling_locations()
Expand Down
5 changes: 5 additions & 0 deletions amr-wind/utilities/sampling/LineSampler.H
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public:
//! Populate and return a vector of probe locations to be sampled
void sampling_locations(SampleLocType& /*sample_locs**/) const override;

//! Populate the vector with coordinates of the sampling locations inside
//! boxes
void sampling_locations(
SampleLocType&, const amrex::Vector<amrex::Box>&) const override;

Check warning on line 39 in amr-wind/utilities/sampling/LineSampler.H

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

all parameters should be named in a function [readability-named-parameter]

void output_locations(SampleLocType& sample_locs) const override
{
return sampling_locations(sample_locs);
Expand Down
14 changes: 12 additions & 2 deletions amr-wind/utilities/sampling/LineSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ void LineSampler::sampling_locations(SampleLocType& sample_locs) const
{
AMREX_ALWAYS_ASSERT(sample_locs.locations().empty());

const int lev = 0;
const auto domain = m_sim.mesh().Geom(lev).Domain();
sampling_locations(sample_locs, {domain});

AMREX_ALWAYS_ASSERT(sample_locs.locations().size() == num_points());
}

void LineSampler::sampling_locations(
SampleLocType& sample_locs, const amrex::Vector<amrex::Box>& boxes) const

Check warning on line 68 in amr-wind/utilities/sampling/LineSampler.cpp

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

unused parameter 'boxes' [-Wunused-parameter]

Check warning on line 68 in amr-wind/utilities/sampling/LineSampler.cpp

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

unused parameter 'boxes' [clang-diagnostic-unused-parameter]

Check warning on line 68 in amr-wind/utilities/sampling/LineSampler.cpp

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

unused parameter 'boxes' [-Wunused-parameter]

Check warning on line 68 in amr-wind/utilities/sampling/LineSampler.cpp

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

unused parameter 'boxes' [-Wunused-parameter]
{
AMREX_ALWAYS_ASSERT(sample_locs.locations().empty());

const amrex::Real ndiv = amrex::max(m_npts - 1, 1);
amrex::Array<amrex::Real, AMREX_SPACEDIM> dx;

Expand All @@ -70,8 +82,6 @@ void LineSampler::sampling_locations(SampleLocType& sample_locs) const
m_start[2] + i * dx[2])};
sample_locs.push_back(loc, i);
}

AMREX_ALWAYS_ASSERT(sample_locs.locations().size() == num_points());
}

#ifdef AMR_WIND_USE_NETCDF
Expand Down
5 changes: 5 additions & 0 deletions amr-wind/utilities/sampling/PlaneSampler.H
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public:
//! Populate and return a vector of probe locations to be sampled
void sampling_locations(SampleLocType& /*sample_locs**/) const override;

//! Populate the vector with coordinates of the sampling locations inside
//! boxes
void sampling_locations(
SampleLocType&, const amrex::Vector<amrex::Box>&) const override;

Check warning on line 50 in amr-wind/utilities/sampling/PlaneSampler.H

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

all parameters should be named in a function [readability-named-parameter]

void output_locations(SampleLocType& sample_locs) const override
{
return sampling_locations(sample_locs);
Expand Down
14 changes: 12 additions & 2 deletions amr-wind/utilities/sampling/PlaneSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ void PlaneSampler::sampling_locations(SampleLocType& sample_locs) const
{
AMREX_ALWAYS_ASSERT(sample_locs.locations().empty());

const int lev = 0;
const auto domain = m_sim.mesh().Geom(lev).Domain();
sampling_locations(sample_locs, {domain});

AMREX_ALWAYS_ASSERT(sample_locs.locations().size() == num_points());
}

void PlaneSampler::sampling_locations(
SampleLocType& sample_locs, const amrex::Vector<amrex::Box>& boxes) const

Check warning on line 90 in amr-wind/utilities/sampling/PlaneSampler.cpp

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

unused parameter 'boxes' [-Wunused-parameter]

Check warning on line 90 in amr-wind/utilities/sampling/PlaneSampler.cpp

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

unused parameter 'boxes' [clang-diagnostic-unused-parameter]

Check warning on line 90 in amr-wind/utilities/sampling/PlaneSampler.cpp

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

unused parameter 'boxes' [-Wunused-parameter]

Check warning on line 90 in amr-wind/utilities/sampling/PlaneSampler.cpp

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

unused parameter 'boxes' [-Wunused-parameter]
{
AMREX_ALWAYS_ASSERT(sample_locs.locations().empty());

amrex::Array<amrex::Real, AMREX_SPACEDIM> dx;
amrex::Array<amrex::Real, AMREX_SPACEDIM> dy;

Expand All @@ -102,8 +114,6 @@ void PlaneSampler::sampling_locations(SampleLocType& sample_locs) const
}
}
}

AMREX_ALWAYS_ASSERT(sample_locs.locations().size() == num_points());
}

#ifdef AMR_WIND_USE_NETCDF
Expand Down
6 changes: 6 additions & 0 deletions amr-wind/utilities/sampling/ProbeSampler.H
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ public:
//! Check and fix the bounds of the sampler so the probes are in the domain
void check_bounds() override;

//! Populate the vector with coordinates of the sampling locations
void sampling_locations(SampleLocType& /*sample_locs**/) const override;

//! Populate the vector with coordinates of the sampling locations inside
//! boxes
void sampling_locations(
SampleLocType&, const amrex::Vector<amrex::Box>&) const override;

Check warning on line 37 in amr-wind/utilities/sampling/ProbeSampler.H

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

all parameters should be named in a function [readability-named-parameter]

void output_locations(SampleLocType& sample_locs) const override
{
return sampling_locations(sample_locs);
Expand Down
14 changes: 13 additions & 1 deletion amr-wind/utilities/sampling/ProbeSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ void ProbeSampler::check_bounds()
void ProbeSampler::sampling_locations(SampleLocType& sample_locs) const
{
AMREX_ALWAYS_ASSERT(sample_locs.locations().empty());

const int lev = 0;
const auto domain = m_sim.mesh().Geom(lev).Domain();
sampling_locations(sample_locs, {domain});

AMREX_ALWAYS_ASSERT(sample_locs.locations().size() == num_points());
}

void ProbeSampler::sampling_locations(
SampleLocType& sample_locs, const amrex::Vector<amrex::Box>& boxes) const

Check warning on line 72 in amr-wind/utilities/sampling/ProbeSampler.cpp

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

unused parameter 'boxes' [-Wunused-parameter]

Check warning on line 72 in amr-wind/utilities/sampling/ProbeSampler.cpp

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

unused parameter 'boxes' [-Wunused-parameter]
{
AMREX_ALWAYS_ASSERT(sample_locs.locations().empty());

const auto& probe_locs = m_probes.locations();
for (int i = 0; i < m_npts; ++i) {
for (int d = 0; d < AMREX_SPACEDIM; ++d) {
Expand All @@ -68,7 +81,6 @@ void ProbeSampler::sampling_locations(SampleLocType& sample_locs) const
sample_locs.push_back(loc, i);
}
}
AMREX_ALWAYS_ASSERT(sample_locs.locations().size() == num_points());
}

#ifdef AMR_WIND_USE_NETCDF
Expand Down
6 changes: 6 additions & 0 deletions amr-wind/utilities/sampling/RadarSampler.H
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public:

//! Populate and return a vector of probe locations to be sampled
void sampling_locations(SampleLocType& /*sample_locs**/) const override;

//! Populate the vector with coordinates of the sampling locations inside
//! boxes
void sampling_locations(
SampleLocType&, const amrex::Vector<amrex::Box>&) const override;

bool update_sampling_locations() override;
void cone_axis_locations(SampleLocType& /*sample_locs**/) const;
void output_locations(SampleLocType& sample_locs) const override
Expand Down
13 changes: 12 additions & 1 deletion amr-wind/utilities/sampling/RadarSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,18 @@ void RadarSampler::sampling_locations(SampleLocType& sample_locs) const
{
AMREX_ALWAYS_ASSERT(sample_locs.locations().empty());

const int lev = 0;
const auto domain = m_sim.mesh().Geom(lev).Domain();
sampling_locations(sample_locs, {domain});

AMREX_ALWAYS_ASSERT(sample_locs.locations().size() == num_points());
}

void RadarSampler::sampling_locations(
SampleLocType& sample_locs, const amrex::Vector<amrex::Box>& boxes) const

Check warning on line 475 in amr-wind/utilities/sampling/RadarSampler.cpp

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

unused parameter 'boxes' [-Wunused-parameter]

Check warning on line 475 in amr-wind/utilities/sampling/RadarSampler.cpp

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

unused parameter 'boxes' [-Wunused-parameter]
{
AMREX_ALWAYS_ASSERT(sample_locs.locations().empty());

for (int i = 0; i < num_points_scan(); ++i) {
const amrex::Array<amrex::Real, AMREX_SPACEDIM> loc = {AMREX_D_DECL(
(m_radar_iter > 0) ? m_prior_cones[i][0] : m_fill_val,
Expand All @@ -479,7 +491,6 @@ void RadarSampler::sampling_locations(SampleLocType& sample_locs) const
m_current_cones[i][2])};
sample_locs.push_back(loc, ioff);
}
AMREX_ALWAYS_ASSERT(sample_locs.locations().size() == num_points());
}

// TODO: Create test for this calculation
Expand Down
5 changes: 5 additions & 0 deletions amr-wind/utilities/sampling/SamplerBase.H
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public:
//! Populate the vector with coordinates of the sampling locations
virtual void sampling_locations(SampleLocType&) const = 0;

//! Populate the vector with coordinates of the sampling locations inside
//! boxes
virtual void sampling_locations(
SampleLocType&, const amrex::Vector<amrex::Box>&) const = 0;

//! Check and fix the bounds of the sampler so the probes are in the domain
virtual void check_bounds() = 0;

Expand Down
5 changes: 5 additions & 0 deletions amr-wind/utilities/sampling/VolumeSampler.H
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public:
//! Populate and return a vector of probe locations to be sampled
void sampling_locations(SampleLocType& /*sample_locs**/) const override;

//! Populate the vector with coordinates of the sampling locations inside
//! boxes
void sampling_locations(
SampleLocType&, const amrex::Vector<amrex::Box>&) const override;

void output_locations(SampleLocType& sample_locs) const override
{
return sampling_locations(sample_locs);
Expand Down
13 changes: 12 additions & 1 deletion amr-wind/utilities/sampling/VolumeSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ void VolumeSampler::sampling_locations(SampleLocType& sample_locs) const
{
AMREX_ALWAYS_ASSERT(sample_locs.locations().empty());

const int lev = 0;
const auto domain = m_sim.mesh().Geom(lev).Domain();
sampling_locations(sample_locs, {domain});

AMREX_ALWAYS_ASSERT(sample_locs.locations().size() == num_points());
}

void VolumeSampler::sampling_locations(
SampleLocType& sample_locs, const amrex::Vector<amrex::Box>& boxes) const

Check warning on line 81 in amr-wind/utilities/sampling/VolumeSampler.cpp

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

unused parameter 'boxes' [-Wunused-parameter]

Check warning on line 81 in amr-wind/utilities/sampling/VolumeSampler.cpp

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

unused parameter 'boxes' [-Wunused-parameter]
{
AMREX_ALWAYS_ASSERT(sample_locs.locations().empty());

const amrex::Array<amrex::Real, AMREX_SPACEDIM> dx = {
(m_hi[0] - m_lo[0]) / m_npts_dir[0],
(m_hi[1] - m_lo[1]) / m_npts_dir[1],
Expand All @@ -88,7 +100,6 @@ void VolumeSampler::sampling_locations(SampleLocType& sample_locs) const
}
}
}
AMREX_ALWAYS_ASSERT(sample_locs.locations().size() == num_points());
}

#ifdef AMR_WIND_USE_NETCDF
Expand Down

0 comments on commit c99cba2

Please sign in to comment.