Skip to content

Commit

Permalink
Changing Freesurface post-processing routine to a Sampler (#1187)
Browse files Browse the repository at this point in the history
* remove incomplete, unused python script
* add FreeSurfaceSampler to reg test
* documentation
* python scripts that pass with ctest (to be added later)
  • Loading branch information
mbkuhn authored Aug 20, 2024
1 parent 2fdce14 commit f867288
Show file tree
Hide file tree
Showing 19 changed files with 594 additions and 464 deletions.
2 changes: 1 addition & 1 deletion amr-wind/utilities/sampling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ target_sources(${amr_wind_lib_name}
FieldNorms.cpp
KineticEnergy.cpp
Enstrophy.cpp
FreeSurface.cpp
FreeSurfaceSampler.cpp
VolumeSampler.cpp
WaveEnergy.cpp
)
133 changes: 0 additions & 133 deletions amr-wind/utilities/sampling/FreeSurface.H

This file was deleted.

114 changes: 114 additions & 0 deletions amr-wind/utilities/sampling/FreeSurfaceSampler.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#ifndef FREESURFACESAMPLER_H
#define FREESURFACESAMPLER_H

#include "amr-wind/CFDSim.H"
#include "amr-wind/utilities/sampling/SamplerBase.H"

namespace amr_wind::sampling {

class FreeSurfaceSampler : public SamplerBase::Register<FreeSurfaceSampler>
{
public:
static std::string identifier() { return "FreeSurfaceSampler"; }

FreeSurfaceSampler(CFDSim& /*sim*/);

~FreeSurfaceSampler() override;

//! Read user inputs and create mesh-based information for locating
//! interface
void initialize(const std::string& key) override;

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

//! Find heights associated with 2D sample locations
void update_sampling_locations() override;

//! Redo some of the initialization work when the grid changes
void post_regrid_actions() override;

void
define_netcdf_metadata(const ncutils::NCGroup& /*unused*/) const override;
void
populate_netcdf_metadata(const ncutils::NCGroup& /*unused*/) const override;
void output_netcdf_data(
const ncutils::NCGroup& /*unused*/,
const size_t /*unused*/) const override;

//! Name of this sampling object
std::string label() const override { return m_label; }
std::string& label() override { return m_label; }

//! Type of this sampling object
std::string sampletype() const override { return identifier(); }

//! Unique identifier for this set of probe locations
int id() const override { return m_id; }
int& id() override { return m_id; }

//! Output functions for private variables
//! Number of 2D grid points
int num_gridpoints() const { return m_npts; }
//! Number of instances
int num_instances() const { return m_ninst; }
//! Number of points, total
long num_points() const override
{
return static_cast<long>(m_npts) * m_ninst;
}
long num_output_points() const override
{
return static_cast<long>(m_npts) * m_ninst;
}
//! Locations
amrex::Vector<amrex::Array<amrex::Real, 2>> grid_locations() const
{
return m_grid_locs;
}
//! Outputs (heights)
amrex::Vector<amrex::Real> heights() const { return m_out; }

private:
CFDSim& m_sim;

//! reference to VOF
const Field& m_vof;

//! Number or points on 2D grid in each direction
amrex::Vector<int> m_npts_dir;
int m_npts{0};
//! Number of instances (possible sampling points per location, like in the
//! case of a breaking wave)
int m_ninst{1};

//! Coordinate direction to search along, default is z
//! (this also determines the meaning of start and end points)
int m_coorddir{2};
//! Grid coordinates, determined as a function of m_coorddir
int m_gc0 = 0;
int m_gc1 = 1;

//! Parameters to set up plane
amrex::Vector<amrex::Real> m_start, m_end;
//! Locations of points in 2D grid
amrex::Vector<amrex::Array<amrex::Real, 2>> m_grid_locs;
//! Output coordinate
amrex::Vector<amrex::Real> m_out;

//! Max number of sample points found in a single cell
int m_ncomp{1};
//! Max number of sample points allowed in a single cell
int m_ncmax{8};

std::string m_label;
int m_id{-1};
};

} // namespace amr_wind::sampling

#endif /* FREESURFACESAMPLER_H */
Loading

0 comments on commit f867288

Please sign in to comment.