forked from Exawind/amr-wind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actuator source prototype (Exawind#298)
- 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
Showing
15 changed files
with
1,244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ target_sources(${amr_wind_lib_name} | |
ABLBoundaryPlane.cpp | ||
MOData.cpp | ||
) | ||
|
||
add_subdirectory(actuator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ |
Oops, something went wrong.