Skip to content

Commit

Permalink
Fix input name for offset vector specification in the inputs (#1137)
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf authored Sep 6, 2024
1 parent 08c2485 commit af8231a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion amr-wind/utilities/sampling/PlaneSampler.H
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private:
amrex::Vector<amrex::Real> m_axis1;
amrex::Vector<amrex::Real> m_axis2;
amrex::Vector<amrex::Real> m_origin;
amrex::Vector<amrex::Real> m_normal{0.0, 0.0, 0.0};
amrex::Vector<amrex::Real> m_offset_vector{0.0, 0.0, 0.0};
amrex::Vector<amrex::Real> m_poffsets;
amrex::Vector<int> m_npts_dir;

Expand Down
14 changes: 10 additions & 4 deletions amr-wind/utilities/sampling/PlaneSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ void PlaneSampler::initialize(const std::string& key)
pp.queryarr("offsets", m_poffsets);
int noffsets = static_cast<int>(m_poffsets.size());
if (noffsets > 0) {
pp.getarr("normal", m_normal);
if (pp.contains("normal")) {
amrex::Abort(
"PlaneSampler: option normal is deprecated and renamed to "
"offset_vector");
}

pp.getarr("offset_vector", m_offset_vector);
AMREX_ALWAYS_ASSERT(
static_cast<int>(m_normal.size()) == AMREX_SPACEDIM);
static_cast<int>(m_offset_vector.size()) == AMREX_SPACEDIM);
} else {
m_poffsets.push_back(0.0);
}
Expand Down Expand Up @@ -62,7 +68,7 @@ void PlaneSampler::sampling_locations(SampleLocType& locs) const
for (int i = 0; i < m_npts_dir[0]; ++i) {
for (int d = 0; d < AMREX_SPACEDIM; ++d) {
locs[idx][d] = m_origin[d] + dx[d] * i + dy[d] * j +
m_poffsets[k] * m_normal[d];
m_poffsets[k] * m_offset_vector[d];
}
++idx;
}
Expand All @@ -80,7 +86,7 @@ void PlaneSampler::define_netcdf_metadata(const ncutils::NCGroup& grp) const
grp.put_attr("origin", m_origin);
grp.put_attr("axis1", m_axis1);
grp.put_attr("axis2", m_axis2);
grp.put_attr("axis3", m_normal);
grp.put_attr("offset_vector", m_offset_vector);
grp.put_attr("offsets", m_poffsets);
}

Expand Down
24 changes: 16 additions & 8 deletions docs/sphinx/user/inputs_Sampling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,26 @@ The ``PlaneSampler`` samples the flow-field on two-dimensional planes defined by
two axes: ``axis1`` and ``axis2`` with the bottom corner located at ``origin``
and is divided into equally spaced nodes defined by the two entries in
``num_points`` vector. Multiple planes parallel to the reference planes can be
sampled by specifying the ``normal`` vector along which the the planes are
sampled by specifying the ``offset_vector`` vector along which the the planes are
offset for as many planes as there are entries in the ``offset`` array.

Example::

sampling.plane1.type = PlaneSampler
sampling.plane1.axis1 = 0.0 1.0 0.0
sampling.plane1.axis2 = 0.0 0.0 1.0
sampling.plane1.origin = 0.0 0.0 0.0
sampling.plane1.num_points = 10 10
sampling.plane1.normal = 1.0 0.0 0.0
sampling.plane1.offsets = -10.0 0.0 10.0
sampling.plane1.type = PlaneSampler
sampling.plane1.axis1 = 1.0 0.0 0.0
sampling.plane1.axis2 = 0.0 0.0 1.0
sampling.plane1.origin = 0.0 0.0 0.0
sampling.plane1.num_points = 10 10
sampling.plane1.offset_vector = 1.0 0.0 0.0
sampling.plane1.offsets = 0.0 2.0 3.0

Illustration of this example:

.. figure:: planesampler.png
:alt: PlaneSampler
:width: 800

Example of sampling on planes.

Sampling at arbitrary locations
````````````````````````````````
Expand Down
Binary file added docs/sphinx/user/planesampler.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion unit_tests/utilities/test_sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ TEST_F(SamplingTest, plane_sampler)
pp.addarr("origin", amrex::Vector<double>{0.0, 0.0, 0.0});
pp.addarr("num_points", amrex::Vector<int>{3, 3});
pp.addarr("offsets", amrex::Vector<double>{-1.0, 1.0});
pp.addarr("normal", amrex::Vector<double>{1.0, 0.0, 0.0});
pp.addarr("offset_vector", amrex::Vector<double>{1.0, 0.0, 0.0});
}

amr_wind::sampling::PlaneSampler plane(sim());
Expand Down

0 comments on commit af8231a

Please sign in to comment.