Skip to content

Commit

Permalink
Merge branch 'main' into update_compile_documentation_hip
Browse files Browse the repository at this point in the history
  • Loading branch information
ddement committed Oct 15, 2024
2 parents 17b35a9 + 099ac49 commit 85147ed
Show file tree
Hide file tree
Showing 84 changed files with 7,035 additions and 220 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/correctness-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
matrix:
compiler: [g++, clang++]
build_type: [Release, Debug]
build_external: [all, none]
steps:
- name: Cache install Dependencies
id: cache-dependencies
Expand Down Expand Up @@ -47,13 +48,13 @@ jobs:
mkdir build
cd build
cmake .. \
-DOpenTurbine_ENABLE_SANITIZER_ADDRESS=ON \
-DOpenTurbine_ENABLE_SANITIZER_LEAK=ON \
-DOpenTurbine_ENABLE_SANITIZER_UNDEFINED=ON \
-DOpenTurbine_ENABLE_SANITIZER_ADDRESS=${{ matrix.build_external == 'none' }} \
-DOpenTurbine_ENABLE_SANITIZER_LEAK=${{ matrix.build_external == 'none' }} \
-DOpenTurbine_ENABLE_SANITIZER_UNDEFINED=${{ matrix.build_external == 'none' }} \
-DOpenTurbine_ENABLE_CPPCHECK=ON \
-DOpenTurbine_ENABLE_CLANG_TIDY=ON \
-DOpenTurbine_BUILD_OPENFAST_ADI=ON \
-DOpenTurbine_BUILD_ROSCO_CONTROLLER=ON \
-DOpenTurbine_BUILD_OPENFAST_ADI=${{ matrix.build_external == 'all' }} \
-DOpenTurbine_BUILD_ROSCO_CONTROLLER=${{ matrix.build_external == 'all' }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake --build .
ctest --output-on-failure
9 changes: 5 additions & 4 deletions .github/workflows/correctness-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
matrix:
compiler: [g++, clang++]
build_type: [Release, Debug]
build_external: [all, none]
steps:
- name: Cache install Dependencies
id: cache-dependencies
Expand Down Expand Up @@ -53,13 +54,13 @@ jobs:
mkdir build
cd build
cmake .. \
-DOpenTurbine_ENABLE_SANITIZER_ADDRESS=ON \
-DOpenTurbine_ENABLE_SANITIZER_UNDEFINED=ON \
-DOpenTurbine_ENABLE_SANITIZER_ADDRESS=${{ matrix.build_external == 'none' }} \
-DOpenTurbine_ENABLE_SANITIZER_UNDEFINED=${{ matrix.build_external == 'none' }} \
-DOpenTurbine_ENABLE_CPPCHECK=ON \
-DOpenTurbine_ENABLE_CLANG_TIDY=ON \
-DOpenTurbine_ENABLE_VTK=ON \
-DOpenTurbine_BUILD_OPENFAST_ADI=ON \
-DOpenTurbine_BUILD_ROSCO_CONTROLLER=ON \
-DOpenTurbine_BUILD_OPENFAST_ADI=${{ matrix.build_external == 'all' }} \
-DOpenTurbine_BUILD_ROSCO_CONTROLLER=${{ matrix.build_external == 'all' }} \
-DCMAKE_CXX_COMPILER=${{ matrix.compiler }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake --build .
Expand Down
12 changes: 7 additions & 5 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,29 @@ function(openturbine_setup_dependencies)
message(STATUS "Building OpenFAST AerodynInflow (ADI) library")
include(ExternalProject)
ExternalProject_Add(OpenFAST_ADI
PREFIX ${CMAKE_BINARY_DIR}/external/OpenFAST_ADI
PREFIX ${CMAKE_BINARY_DIR}/external
GIT_REPOSITORY https://github.com/OpenFAST/openfast.git
GIT_TAG dev # Use the "dev" branch
GIT_SHALLOW TRUE # Clone only the latest commit
GIT_SUBMODULES_RECURSE OFF # Avoid unnecessary submodule cloning
GIT_SUBMODULES "" # Skip downloading r-test
CMAKE_ARGS
-DBUILD_TESTING=OFF # Disable testing
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} # Use the same build type as the main project
BUILD_IN_SOURCE OFF # Build in a separate directory for cleaner output
BINARY_DIR ${CMAKE_BINARY_DIR}/OpenFAST_ADI_build
# Build only the aerodyn_inflow_c_binding target and do it sequentially (avoid parallel build)
BUILD_COMMAND ${CMAKE_COMMAND} --build . --target aerodyn_inflow_c_binding -- -j 1
INSTALL_COMMAND
# Copy the built library to the tests directory
${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/OpenFAST_ADI_build/modules/aerodyn/libaerodyn_inflow_c_binding${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/tests/unit_tests/
${CMAKE_BINARY_DIR}/OpenFAST_ADI_build/modules/aerodyn/${CMAKE_SHARED_LIBRARY_PREFIX}aerodyn_inflow_c_binding${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/tests/unit_tests/aerodyn_inflow_c_binding.dll
)
endif()

# Conditionally add external project to build the ROSCO Controller library
if(OpenTurbine_BUILD_ROSCO_CONTROLLER)
if (NOT ROSCO_BUILD_TAG)
if (NOT ROSCO_BUILD_TAG)
set(ROSCO_BUILD_TAG "v2.9.4")
endif()
message(STATUS "Building ROSCO Controller library")
Expand Down
2 changes: 2 additions & 0 deletions src/beams/beams.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct Beams {
Kokkos::View<double** [6]> qp_Fc; // Elastic force
Kokkos::View<double** [6]> qp_Fd; // Elastic force
Kokkos::View<double** [6]> qp_Fi; // Inertial force
Kokkos::View<double** [6]> qp_Fe; // External force
Kokkos::View<double** [6]> qp_Fg; // Gravity force
Kokkos::View<double** [6][6]> qp_RR0; // Global rotation
Kokkos::View<double** [6][6]> qp_Muu; // Mass in global frame
Expand Down Expand Up @@ -139,6 +140,7 @@ struct Beams {
qp_Fc("qp_Fc", num_elems, max_elem_qps),
qp_Fd("qp_Fd", num_elems, max_elem_qps),
qp_Fi("qp_Fi", num_elems, max_elem_qps),
qp_Fe("qp_Fe", num_elems, max_elem_qps),
qp_Fg("qp_Fg", num_elems, max_elem_qps),
qp_RR0("qp_RR0", num_elems, max_elem_qps),
qp_Muu("qp_Muu", num_elems, max_elem_qps),
Expand Down
76 changes: 48 additions & 28 deletions src/beams/beams_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,75 @@

namespace openturbine {

/**
* @brief Represents the input data for beam simulations
*
* This struct encapsulates all necessary input parameters for beam simulations,
* including the beam elements and environmental factors such as gravity.
* It also provides utility methods for accessing and computing various
* properties of the beam structure.
*/
struct BeamsInput {
std::vector<BeamElement> elements;
std::array<double, 3> gravity;
std::vector<BeamElement> elements; //< Elements in the beam
std::array<double, 3> gravity; //< Gravity vector

BeamsInput(std::vector<BeamElement> elems, std::array<double, 3> g)
: elements(std::move(elems)), gravity(g) {}

[[nodiscard]] size_t NumElements() const { return elements.size(); };
/// Returns the number of elements in the beam
[[nodiscard]] size_t NumElements() const { return elements.size(); }

[[nodiscard]] size_t NumNodes() const {
return std::transform_reduce(
elements.begin(), elements.end(), size_t{0U}, std::plus{},
[](const BeamElement& e) {
return e.nodes.size();
}
);
}

[[nodiscard]] size_t NumQuadraturePoints() const {
/// Computes the sum of a value across all elements
template <typename Accessor>
[[nodiscard]] size_t ComputeSum(Accessor accessor) const {
return std::transform_reduce(
elements.begin(), elements.end(), size_t{0U}, std::plus{},
[](const BeamElement& e) {
return e.quadrature.size();
[&accessor](const BeamElement& e) {
return accessor(e);
}
);
}

[[nodiscard]] size_t MaxElemNodes() const {
/// Computes the maximum of a value across all elements
template <typename Accessor>
[[nodiscard]] size_t ComputeMax(Accessor accessor) const {
return std::transform_reduce(
elements.begin(), elements.end(), size_t{0U},
[](size_t a, size_t b) {
[](auto a, auto b) {
return std::max(a, b);
},
[](const BeamElement& e) {
return e.nodes.size();
[&accessor](const auto& e) {
return accessor(e);
}
);
}

/// Returns the total number of nodes in the beam
[[nodiscard]] size_t NumNodes() const {
return ComputeSum([](const BeamElement& e) {
return e.nodes.size();
});
}

/// Returns the total number of quadrature points in the beam
[[nodiscard]] size_t NumQuadraturePoints() const {
return ComputeSum([](const BeamElement& e) {
return e.quadrature.size();
});
}

/// Returns the maximum number of nodes in any element of the beam
[[nodiscard]] size_t MaxElemNodes() const {
return ComputeMax([](const BeamElement& e) {
return e.nodes.size();
});
}

/// Returns the maximum number of quadrature points in any element of the beam
[[nodiscard]] size_t MaxElemQuadraturePoints() const {
return std::transform_reduce(
elements.begin(), elements.end(), size_t{0U},
[](size_t a, size_t b) {
return std::max(a, b);
},
[](const BeamElement& e) {
return e.quadrature.size();
}
);
return ComputeMax([](const BeamElement& e) {
return e.quadrature.size();
});
}
};

Expand Down
9 changes: 6 additions & 3 deletions src/beams/create_beams.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ inline Beams CreateBeams(const BeamsInput& beams_input) {
"InterpolateQPPosition", beams.num_elems,
InterpolateQPPosition{
beams.num_nodes_per_element, beams.num_qps_per_element, beams.shape_interp,
beams.node_x0, beams.qp_x0}
beams.node_x0, beams.qp_x0
}
);

Kokkos::parallel_for(
"InterpolateQPRotation", beams.num_elems,
InterpolateQPRotation{
beams.num_nodes_per_element, beams.num_qps_per_element, beams.shape_interp,
beams.node_x0, beams.qp_r0}
beams.node_x0, beams.qp_r0
}
);

Kokkos::parallel_for(
Expand All @@ -120,7 +122,8 @@ inline Beams CreateBeams(const BeamsInput& beams_input) {
beams.num_nodes_per_element, beams.num_qps_per_element, beams.shape_interp,
beams.shape_deriv, beams.qp_jacobian, beams.node_u, beams.node_u_dot, beams.node_u_ddot,
beams.qp_x0, beams.qp_r0, beams.qp_u, beams.qp_u_prime, beams.qp_r, beams.qp_r_prime,
beams.qp_u_dot, beams.qp_omega, beams.qp_u_ddot, beams.qp_omega_dot, beams.qp_x}
beams.qp_u_dot, beams.qp_omega, beams.qp_u_ddot, beams.qp_omega_dot, beams.qp_x
}
);
return beams;
}
Expand Down
13 changes: 8 additions & 5 deletions src/beams/interpolate_to_quadrature_points.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,30 @@ struct InterpolateToQuadraturePoints {
Kokkos::TeamThreadRange(member, num_qps),
InterpolateQPVector{
i_elem, num_nodes, shape_interp,
Kokkos::subview(node_u_dot, Kokkos::ALL, Kokkos::ALL, Kokkos::pair(0, 3)), qp_u_dot}
Kokkos::subview(node_u_dot, Kokkos::ALL, Kokkos::ALL, Kokkos::pair(0, 3)), qp_u_dot
}
);
Kokkos::parallel_for(
Kokkos::TeamThreadRange(member, num_qps),
InterpolateQPVector{
i_elem, num_nodes, shape_interp,
Kokkos::subview(node_u_dot, Kokkos::ALL, Kokkos::ALL, Kokkos::pair(3, 6)), qp_omega}
Kokkos::subview(node_u_dot, Kokkos::ALL, Kokkos::ALL, Kokkos::pair(3, 6)), qp_omega
}
);
Kokkos::parallel_for(
Kokkos::TeamThreadRange(member, num_qps),
InterpolateQPVector{
i_elem, num_nodes, shape_interp,
Kokkos::subview(node_u_ddot, Kokkos::ALL, Kokkos::ALL, Kokkos::pair(0, 3)),
qp_u_ddot}
Kokkos::subview(node_u_ddot, Kokkos::ALL, Kokkos::ALL, Kokkos::pair(0, 3)), qp_u_ddot
}
);
Kokkos::parallel_for(
Kokkos::TeamThreadRange(member, num_qps),
InterpolateQPVector{
i_elem, num_nodes, shape_interp,
Kokkos::subview(node_u_ddot, Kokkos::ALL, Kokkos::ALL, Kokkos::pair(3, 6)),
qp_omega_dot}
qp_omega_dot
}
);
Kokkos::parallel_for(
Kokkos::TeamThreadRange(member, num_qps),
Expand Down
3 changes: 2 additions & 1 deletion src/constraints/calculate_constraint_force.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ struct CalculateConstraintForce {
case ConstraintType::kRevoluteJoint: {
// Applies the torque from a revolute joint constraint to the system residual
CalculateRevoluteJointForce{
target_node_index, axes, inputs, node_u, system_residual_terms}(i_constraint);
target_node_index, axes, inputs, node_u, system_residual_terms
}(i_constraint);
} break;
default: {
// Do nothing
Expand Down
15 changes: 10 additions & 5 deletions src/constraints/calculate_constraint_output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,23 @@ struct CalculateConstraintOutput {
case ConstraintType::kRevoluteJoint: {
// Axis of rotation unit vector
const auto joint_axis0_data = Kokkos::Array<double, 3>{
axes(i_constraint, 0, 0), axes(i_constraint, 0, 1), axes(i_constraint, 0, 2)};
axes(i_constraint, 0, 0), axes(i_constraint, 0, 1), axes(i_constraint, 0, 2)
};
const auto joint_axis0 = View_3::const_type{joint_axis0_data.data()};

// Target node index
auto i_node = target_node_index(i_constraint);

// Target node initial rotation
const auto R0_data = Kokkos::Array<double, 4>{
node_u(i_node, 3), node_u(i_node, 4), node_u(i_node, 5), node_u(i_node, 6)};
node_u(i_node, 3), node_u(i_node, 4), node_u(i_node, 5), node_u(i_node, 6)
};
const auto R0 = View_Quaternion::const_type{R0_data.data()};

// Target node rotational displacement
const auto R_data = Kokkos::Array<double, 4>{
node_u(i_node, 3), node_u(i_node, 4), node_u(i_node, 5), node_u(i_node, 6)};
node_u(i_node, 3), node_u(i_node, 4), node_u(i_node, 5), node_u(i_node, 6)
};
const auto R = View_Quaternion::const_type{R_data.data()};

// Calculate current orientation
Expand All @@ -54,12 +57,14 @@ struct CalculateConstraintOutput {

// Target node rotational velocity vector
auto omega_data = Kokkos::Array<double, 3>{
node_udot(i_node, 3), node_udot(i_node, 4), node_udot(i_node, 5)};
node_udot(i_node, 3), node_udot(i_node, 4), node_udot(i_node, 5)
};
auto omega = View_3{omega_data.data()};

// Target node rotational acceleration vector
auto omega_dot_data = Kokkos::Array<double, 3>{
node_uddot(i_node, 3), node_uddot(i_node, 4), node_uddot(i_node, 5)};
node_uddot(i_node, 3), node_uddot(i_node, 4), node_uddot(i_node, 5)
};
auto omega_dot = View_3{omega_dot_data.data()};

// Calculate joint axis in current configuration
Expand Down
6 changes: 4 additions & 2 deletions src/constraints/calculate_fixed_bc_constraint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ struct CalculateFixedBCConstraint {

// Initial difference between nodes
const auto X0_data = Kokkos::Array<double, 3>{
X0_(i_constraint, 0), X0_(i_constraint, 1), X0_(i_constraint, 2)};
X0_(i_constraint, 0), X0_(i_constraint, 1), X0_(i_constraint, 2)
};
const auto X0 = View_3::const_type{X0_data.data()};

// Base node displacement
Expand All @@ -34,7 +35,8 @@ struct CalculateFixedBCConstraint {

// Target node displacement
const auto R2_data = Kokkos::Array<double, 4>{
node_u(i_node2, 3), node_u(i_node2, 4), node_u(i_node2, 5), node_u(i_node2, 6)};
node_u(i_node2, 3), node_u(i_node2, 4), node_u(i_node2, 5), node_u(i_node2, 6)
};
const auto R2 = Kokkos::View<double[4]>::const_type{R2_data.data()};
const auto u2_data =
Kokkos::Array<double, 3>{node_u(i_node2, 0), node_u(i_node2, 1), node_u(i_node2, 2)};
Expand Down
12 changes: 8 additions & 4 deletions src/constraints/calculate_prescribed_bc_constraint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,27 @@ struct CalculatePrescribedBCConstraint {

// Initial difference between nodes
const auto X0_data = Kokkos::Array<double, 3>{
X0_(i_constraint, 0), X0_(i_constraint, 1), X0_(i_constraint, 2)};
X0_(i_constraint, 0), X0_(i_constraint, 1), X0_(i_constraint, 2)
};
const auto X0 = View_3::const_type{X0_data.data()};

// Base node displacement
const auto u1_data = Kokkos::Array<double, 3>{
constraint_inputs(i_constraint, 0), constraint_inputs(i_constraint, 1),
constraint_inputs(i_constraint, 2)};
constraint_inputs(i_constraint, 2)
};
auto u1 = View_3::const_type{u1_data.data()};

const auto R1_data = Kokkos::Array<double, 4>{
constraint_inputs(i_constraint, 3), constraint_inputs(i_constraint, 4),
constraint_inputs(i_constraint, 5), constraint_inputs(i_constraint, 6)};
constraint_inputs(i_constraint, 5), constraint_inputs(i_constraint, 6)
};
const auto R1 = Kokkos::View<double[4]>::const_type{R1_data.data()};

// Target node displacement
const auto R2_data = Kokkos::Array<double, 4>{
node_u(i_node2, 3), node_u(i_node2, 4), node_u(i_node2, 5), node_u(i_node2, 6)};
node_u(i_node2, 3), node_u(i_node2, 4), node_u(i_node2, 5), node_u(i_node2, 6)
};
const auto R2 = Kokkos::View<double[4]>::const_type{R2_data.data()};
const auto u2_data =
Kokkos::Array<double, 3>{node_u(i_node2, 0), node_u(i_node2, 1), node_u(i_node2, 2)};
Expand Down
Loading

0 comments on commit 85147ed

Please sign in to comment.