Skip to content

Commit

Permalink
Actuator source prototype (Exawind#298)
Browse files Browse the repository at this point in the history
- Use AMR particles to perform search and interpolation of velocities for use with actuator line/disk simulations

- Introduces skeleton data structures that will be used to create different actuator source types (wing, turbine) and combined with different types of actuator forcing representations (line, disk)
  • Loading branch information
sayerhs authored Dec 24, 2020
1 parent cde0240 commit bfbbc9e
Show file tree
Hide file tree
Showing 15 changed files with 1,244 additions and 0 deletions.
21 changes: 21 additions & 0 deletions amr-wind/core/gpu_utils.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef GPU_UTILS_H
#define GPU_UTILS_H

#include "AMReX_Gpu.H"

namespace amr_wind {
namespace gpu {

template <typename T>
inline amrex::Gpu::DeviceVector<T> device_view(const amrex::Vector<T>& hview)
{
amrex::Gpu::DeviceVector<T> dview(hview.size());
amrex::Gpu::copy(
amrex::Gpu::hostToDevice, hview.begin(), hview.end(), dview.begin());
return dview;
}

} // namespace gpu
} // namespace amr_wind

#endif /* GPU_UTILS_H */
2 changes: 2 additions & 0 deletions amr-wind/wind_energy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ target_sources(${amr_wind_lib_name}
ABLBoundaryPlane.cpp
MOData.cpp
)

add_subdirectory(actuator)
103 changes: 103 additions & 0 deletions amr-wind/wind_energy/actuator/ActuatorContainer.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#ifndef ACTUATORCONTAINER_H
#define ACTUATORCONTAINER_H

#include "amr-wind/core/vs/vector_space.H"

#include "AMReX_AmrParticles.H"

namespace amr_wind {

class Field;

namespace actuator {

/** Cloud of actuator points
*
* Holds the position vector and velocity information for a cloud of actuator
* points belonging to all the turbines within a given MPI rank.
*/
struct ActuatorCloud
{
//! Number of nodes per turbine on this MPI rank
amrex::Vector<int> num_pts;

//! Position vectors of all actuator nodes belonging to this MPI rank
amrex::Vector<vs::Vector> position;

//! Velocity vectors of all actuator nodes belonging to this MPI rank
amrex::Vector<vs::Vector> velocity;

//! Total number of turbines located on this MPI rank
int num_objects;

explicit ActuatorCloud(const int nobjects);
};

//! Number or real entries in Array of Structs (AOS)
static constexpr int NumPStructReal = AMREX_SPACEDIM;
//! Number of integer entries in Array of Structs (AOS)
static constexpr int NumPStructInt = 0;
//! Number of real entries in Struct of Arrays (SOA)
static constexpr int NumPArrayReal = 0;
//! Number of int entries in Struct of Arrays (SOA)
static constexpr int NumPArrayInt = 0;

/** Specialization of AmrParticleContainer for sampling velocities
*/
class ActuatorContainer
: public amrex::AmrParticleContainer<
NumPStructReal,
NumPStructInt,
NumPArrayReal,
NumPArrayInt>
{
public:
explicit ActuatorContainer(amrex::AmrCore& mesh, const int num_objects);

void post_regrid_actions();

void initialize_container();

void update_positions();

void sample_velocities(const Field& vel);

int num_actuator_points() const { return m_data.position.size(); }

// public for CUDA, not safe for general access

void interpolate_velocities(const Field& vel);

void populate_vel_buffer();

protected:
void compute_local_coordinates();

// Accessor to allow unit testing
ActuatorCloud& point_data() { return m_data; }

private:
amrex::AmrCore& m_mesh;

// Object that holds the position and velocity information
ActuatorCloud m_data;

//! Coordinates of points that are contained within boxes assigned to each
//! MPI rank
amrex::Vector<vs::Vector> m_proc_pos;

//! Device view of the process position vectors
amrex::Gpu::DeviceVector<vs::Vector> m_pos_device;

//! Flag indicating whether memory has allocated for all data structures
bool m_container_initialized{false};

//! Flag indicating whether the particles are scattered throughout the
//! domain, or if they have been recalled to the original MPI rank
bool m_is_scattered{false};
};

} // namespace actuator
} // namespace amr_wind

#endif /* ACTUATORCONTAINER_H */
Loading

0 comments on commit bfbbc9e

Please sign in to comment.