diff --git a/src/elements/beams/beams.hpp b/src/elements/beams/beams.hpp index 617709628..f1d8ed8a1 100644 --- a/src/elements/beams/beams.hpp +++ b/src/elements/beams/beams.hpp @@ -40,46 +40,25 @@ struct Beams { Kokkos::View node_FX; // External forces // Quadrature point data - Kokkos::View qp_weight; // Integration weights - Kokkos::View qp_jacobian; // Jacobian vector - Kokkos::View qp_Mstar; // Mass matrix in material frame - Kokkos::View qp_Cstar; // Stiffness matrix in material frame - Kokkos::View qp_x; // Current position/orientation - Kokkos::View qp_x0; // Initial position - Kokkos::View qp_x0_prime; // Initial position derivative - Kokkos::View qp_r0; // Initial rotation - Kokkos::View qp_u; // State: translation displacement - Kokkos::View qp_u_prime; // State: translation displacement derivative - Kokkos::View qp_u_dot; // State: translation velocity - Kokkos::View qp_u_ddot; // State: translation acceleration - Kokkos::View qp_r; // State: rotation - Kokkos::View qp_r_prime; // State: rotation derivative - Kokkos::View qp_omega; // State: angular velocity - Kokkos::View qp_omega_dot; // State: position/rotation - Kokkos::View qp_deformation; // Deformation relative to rigid body motion - Kokkos::View qp_E; // Quaternion derivative - Kokkos::View qp_eta_tilde; // - Kokkos::View qp_omega_tilde; // - Kokkos::View qp_omega_dot_tilde; // - Kokkos::View qp_x0pupss; // - Kokkos::View qp_M_tilde; // - Kokkos::View qp_N_tilde; // - Kokkos::View qp_eta; // - Kokkos::View qp_rho; // - Kokkos::View qp_strain; // Strain - Kokkos::View qp_Fc; // Elastic force - Kokkos::View qp_Fd; // Elastic force - Kokkos::View qp_Fi; // Inertial force - Kokkos::View qp_Fe; // External force - Kokkos::View qp_Fg; // Gravity force - Kokkos::View qp_RR0; // Global rotation - Kokkos::View qp_Muu; // Mass in global frame - Kokkos::View qp_Cuu; // Stiffness in global frame - Kokkos::View qp_Ouu; // Linearization matrices - Kokkos::View qp_Puu; // Linearization matrices - Kokkos::View qp_Quu; // Linearization matrices - Kokkos::View qp_Guu; // Linearization matrices - Kokkos::View qp_Kuu; // Linearization matrices + Kokkos::View qp_weight; // Integration weights + Kokkos::View qp_jacobian; // Jacobian vector + Kokkos::View qp_Mstar; // Mass matrix in material frame + Kokkos::View qp_Cstar; // Stiffness matrix in material frame + Kokkos::View qp_x; // Current position/orientation + Kokkos::View qp_x0; // Initial position + Kokkos::View qp_x0_prime; // Initial position derivative + Kokkos::View qp_r0; // Initial rotation + Kokkos::View qp_u; // State: translation displacement + Kokkos::View qp_u_prime; // State: translation displacement derivative + Kokkos::View qp_u_dot; // State: translation velocity + Kokkos::View qp_u_ddot; // State: translation acceleration + Kokkos::View qp_r; // State: rotation + Kokkos::View qp_r_prime; // State: rotation derivative + Kokkos::View qp_omega; // State: angular velocity + Kokkos::View qp_omega_dot; // State: position/rotation + Kokkos::View qp_deformation; // Deformation relative to rigid body motion + Kokkos::View qp_E; // Quaternion derivative + Kokkos::View qp_Fe; // External force Kokkos::View residual_vector_terms; Kokkos::View stiffness_matrix_terms; @@ -126,28 +105,7 @@ struct Beams { qp_omega_dot("qp_omega_dot", num_elems, max_elem_qps), qp_deformation("qp_deformation", num_elems, max_elem_qps), qp_E("qp_E", num_elems, max_elem_qps), - qp_eta_tilde("R1_3x3", num_elems, max_elem_qps), - qp_omega_tilde("R1_3x3", num_elems, max_elem_qps), - qp_omega_dot_tilde("R1_3x3", num_elems, max_elem_qps), - qp_x0pupss("R1_3x3", num_elems, max_elem_qps), - qp_M_tilde("R1_3x3", num_elems, max_elem_qps), - qp_N_tilde("R1_3x3", num_elems, max_elem_qps), - qp_eta("V_3", num_elems, max_elem_qps), - qp_rho("R1_3x3", num_elems, max_elem_qps), - qp_strain("qp_strain", num_elems, max_elem_qps), - 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), - qp_Cuu("qp_Cuu", num_elems, max_elem_qps), - qp_Ouu("qp_Ouu", num_elems, max_elem_qps), - qp_Puu("qp_Puu", num_elems, max_elem_qps), - qp_Quu("qp_Quu", num_elems, max_elem_qps), - qp_Guu("qp_Guu", num_elems, max_elem_qps), - qp_Kuu("qp_Kuu", num_elems, max_elem_qps), residual_vector_terms("residual_vector_terms", num_elems, max_elem_nodes), stiffness_matrix_terms( "stiffness_matrix_terms", num_elems, max_elem_nodes, max_elem_nodes diff --git a/src/elements/beams/create_beams.hpp b/src/elements/beams/create_beams.hpp index a5ddef405..ed140566f 100644 --- a/src/elements/beams/create_beams.hpp +++ b/src/elements/beams/create_beams.hpp @@ -139,6 +139,7 @@ inline Beams CreateBeams(const BeamsInput& beams_input, const std::vector& beams.qp_u_dot, beams.qp_omega, beams.qp_u_ddot, beams.qp_omega_dot, beams.qp_x } ); + return beams; } diff --git a/src/step/assemble_inertia_matrix_beams.hpp b/src/step/assemble_inertia_matrix_beams.hpp index d08072219..df66ca7ec 100644 --- a/src/step/assemble_inertia_matrix_beams.hpp +++ b/src/step/assemble_inertia_matrix_beams.hpp @@ -1,3 +1,4 @@ +/* #pragma once #include @@ -26,3 +27,4 @@ inline void AssembleInertiaMatrixBeams(const Beams& beams, double beta_prime, do } } // namespace openturbine +*/ diff --git a/src/step/assemble_residual_vector_beams.hpp b/src/step/assemble_residual_vector_beams.hpp index c0318c67d..be47b9942 100644 --- a/src/step/assemble_residual_vector_beams.hpp +++ b/src/step/assemble_residual_vector_beams.hpp @@ -1,3 +1,4 @@ +/* #pragma once #include @@ -33,3 +34,4 @@ inline void AssembleResidualVectorBeams(const Beams& beams) { } } // namespace openturbine +*/ diff --git a/src/step/assemble_stiffness_matrix_beams.hpp b/src/step/assemble_stiffness_matrix_beams.hpp index 0349220fd..c20b33659 100644 --- a/src/step/assemble_stiffness_matrix_beams.hpp +++ b/src/step/assemble_stiffness_matrix_beams.hpp @@ -1,3 +1,4 @@ +/* #pragma once #include @@ -35,3 +36,4 @@ inline void AssembleStiffnessMatrixBeams(const Beams& beams) { } } // namespace openturbine +*/ diff --git a/src/step/update_system_variables_beams.hpp b/src/step/update_system_variables_beams.hpp index 308a31fae..9a432b13e 100644 --- a/src/step/update_system_variables_beams.hpp +++ b/src/step/update_system_variables_beams.hpp @@ -2,15 +2,10 @@ #include -#include "assemble_inertia_matrix_beams.hpp" -#include "assemble_residual_vector_beams.hpp" -#include "assemble_stiffness_matrix_beams.hpp" #include "elements/beams/beams.hpp" -#include "elements/beams/interpolate_to_quadrature_points.hpp" #include "state/state.hpp" #include "step_parameters.hpp" #include "system/beams/calculate_quadrature_point_values.hpp" -#include "system/beams/update_node_state.hpp" namespace openturbine { @@ -18,70 +13,44 @@ inline void UpdateSystemVariablesBeams( StepParameters& parameters, const Beams& beams, State& state ) { auto range_policy = Kokkos::TeamPolicy<>(static_cast(beams.num_elems), Kokkos::AUTO()); - Kokkos::parallel_for( - "UpdateNodeState", range_policy, - UpdateNodeState{ - beams.num_nodes_per_element, beams.node_state_indices, beams.node_u, beams.node_u_dot, - beams.node_u_ddot, state.q, state.v, state.vd - } - ); - - Kokkos::parallel_for( - "InterpolateToQuadraturePoints", range_policy, - InterpolateToQuadraturePoints{ - 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 - } - ); + const auto shape_size = + Kokkos::View::shmem_size(beams.max_elem_nodes, beams.max_elem_qps); + const auto weight_size = Kokkos::View::shmem_size(beams.max_elem_qps); + const auto node_variable_size = Kokkos::View::shmem_size(beams.max_elem_nodes); + const auto qp_variable_size = Kokkos::View::shmem_size(beams.max_elem_qps); + const auto qp_matrix_size = Kokkos::View::shmem_size(beams.max_elem_qps); + auto smem = 2 * shape_size + 2 * weight_size + 4 * node_variable_size + 5 * qp_variable_size + + 7 * qp_matrix_size; + range_policy.set_scratch_size(1, Kokkos::PerTeam(smem)); Kokkos::parallel_for( "CalculateQuadraturePointValues", range_policy, - CalculateQuadraturePointValues{ + beams::CalculateQuadraturePointValues{ + parameters.beta_prime, + parameters.gamma_prime, + state.q, + state.v, + state.vd, + beams.node_state_indices, + beams.num_nodes_per_element, beams.num_qps_per_element, + beams.qp_weight, + beams.qp_jacobian, + beams.shape_interp, + beams.shape_deriv, beams.gravity, - beams.qp_u, - beams.qp_u_prime, - beams.qp_r, - beams.qp_r_prime, + beams.node_FX, beams.qp_r0, beams.qp_x0, beams.qp_x0_prime, - beams.qp_u_ddot, - beams.qp_omega, - beams.qp_omega_dot, beams.qp_Mstar, beams.qp_Cstar, - beams.qp_x, - beams.qp_RR0, - beams.qp_strain, - beams.qp_eta, - beams.qp_rho, - beams.qp_eta_tilde, - beams.qp_x0pupss, - beams.qp_M_tilde, - beams.qp_N_tilde, - beams.qp_omega_tilde, - beams.qp_omega_dot_tilde, - beams.qp_Fc, - beams.qp_Fd, - beams.qp_Fi, beams.qp_Fe, - beams.qp_Fg, - beams.qp_Muu, - beams.qp_Cuu, - beams.qp_Ouu, - beams.qp_Puu, - beams.qp_Quu, - beams.qp_Guu, - beams.qp_Kuu + beams.residual_vector_terms, + beams.stiffness_matrix_terms, + beams.inertia_matrix_terms } ); - - AssembleResidualVectorBeams(beams); - AssembleStiffnessMatrixBeams(beams); - AssembleInertiaMatrixBeams(beams, parameters.beta_prime, parameters.gamma_prime); } } // namespace openturbine diff --git a/src/system/beams/CMakeLists.txt b/src/system/beams/CMakeLists.txt index 8a44df8df..c0f3b6b9b 100644 --- a/src/system/beams/CMakeLists.txt +++ b/src/system/beams/CMakeLists.txt @@ -1,23 +1,21 @@ target_sources(openturbine_library PRIVATE) install(FILES - calculate_force_FC.hpp - calculate_force_FD.hpp - calculate_gravity_force.hpp - calculate_gyroscopic_matrix.hpp - calculate_inertial_force.hpp - calculate_inertia_stiffness_matrix.hpp - calculate_mass_matrix_components.hpp calculate_Ouu.hpp calculate_Puu.hpp - calculate_quadrature_point_values.hpp calculate_Quu.hpp - calculate_RR0.hpp + calculate_force_FC.hpp + calculate_force_FD.hpp + calculate_inertial_quadrature_point_values.hpp + calculate_quadrature_point_values.hpp + calculate_stiffness_quadrature_point_values.hpp calculate_strain.hpp calculate_temporary_variables.hpp integrate_inertia_matrix.hpp integrate_residual_vector.hpp integrate_stiffness_matrix.hpp + interpolate_to_quadrature_point_for_inertia.hpp + interpolate_to_quadrature_point_for_stiffness.hpp rotate_section_matrix.hpp update_node_state.hpp DESTINATION include/OpenTurbine/system/beams/ diff --git a/src/system/beams/calculate_Ouu.hpp b/src/system/beams/calculate_Ouu.hpp index bbc7c5497..ac808d367 100644 --- a/src/system/beams/calculate_Ouu.hpp +++ b/src/system/beams/calculate_Ouu.hpp @@ -5,37 +5,26 @@ #include #include -namespace openturbine { +namespace openturbine::beams { -struct CalculateOuu { +KOKKOS_FUNCTION +inline void CalculateOuu( + const Kokkos::View::const_type& Cuu, + const Kokkos::View::const_type& x0pupSS, + const Kokkos::View::const_type& M_tilde, + const Kokkos::View::const_type& N_tilde, const Kokkos::View& Ouu +) { using NoTranspose = KokkosBatched::Trans::NoTranspose; using Default = KokkosBatched::Algo::Gemm::Default; using Gemm = KokkosBatched::SerialGemm; - size_t i_elem; - Kokkos::View::const_type qp_Cuu_; - Kokkos::View::const_type x0pupSS_; - Kokkos::View::const_type M_tilde_; - Kokkos::View::const_type N_tilde_; - Kokkos::View qp_Ouu_; - - KOKKOS_FUNCTION - void operator()(int i_qp) const { - auto Cuu = Kokkos::subview(qp_Cuu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto x0pupSS = Kokkos::subview(x0pupSS_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto M_tilde = Kokkos::subview(M_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto N_tilde = Kokkos::subview(N_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto Ouu = Kokkos::subview(qp_Ouu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - - auto C11 = Kokkos::subview(Cuu, Kokkos::make_pair(0, 3), Kokkos::make_pair(0, 3)); - auto C21 = Kokkos::subview(Cuu, Kokkos::make_pair(3, 6), Kokkos::make_pair(0, 3)); - KokkosBlas::SerialSet::invoke(0., Ouu); - auto Ouu_12 = Kokkos::subview(Ouu, Kokkos::make_pair(0, 3), Kokkos::make_pair(3, 6)); - KokkosBlas::serial_axpy(1., N_tilde, Ouu_12); - Gemm::invoke(1., C11, x0pupSS, -1., Ouu_12); - auto Ouu_22 = Kokkos::subview(Ouu, Kokkos::make_pair(3, 6), Kokkos::make_pair(3, 6)); - KokkosBlas::serial_axpy(1., M_tilde, Ouu_22); - Gemm::invoke(1., C21, x0pupSS, -1., Ouu_22); - } -}; - -} // namespace openturbine + auto C11 = Kokkos::subview(Cuu, Kokkos::make_pair(0, 3), Kokkos::make_pair(0, 3)); + auto C21 = Kokkos::subview(Cuu, Kokkos::make_pair(3, 6), Kokkos::make_pair(0, 3)); + KokkosBlas::SerialSet::invoke(0., Ouu); + auto Ouu_12 = Kokkos::subview(Ouu, Kokkos::make_pair(0, 3), Kokkos::make_pair(3, 6)); + KokkosBlas::serial_axpy(1., N_tilde, Ouu_12); + Gemm::invoke(1., C11, x0pupSS, -1., Ouu_12); + auto Ouu_22 = Kokkos::subview(Ouu, Kokkos::make_pair(3, 6), Kokkos::make_pair(3, 6)); + KokkosBlas::serial_axpy(1., M_tilde, Ouu_22); + Gemm::invoke(1., C21, x0pupSS, -1., Ouu_22); +} +} // namespace openturbine::beams diff --git a/src/system/beams/calculate_Puu.hpp b/src/system/beams/calculate_Puu.hpp index 535ce9870..73749c540 100644 --- a/src/system/beams/calculate_Puu.hpp +++ b/src/system/beams/calculate_Puu.hpp @@ -5,35 +5,26 @@ #include #include -namespace openturbine { +namespace openturbine::beams { -struct CalculatePuu { +KOKKOS_FUNCTION +inline void CalculatePuu( + const Kokkos::View::const_type& Cuu, + const Kokkos::View::const_type& x0pupSS, + const Kokkos::View::const_type& N_tilde, const Kokkos::View& Puu +) { using NoTranspose = KokkosBatched::Trans::NoTranspose; using Transpose = KokkosBatched::Trans::Transpose; using Default = KokkosBatched::Algo::Gemm::Default; using GemmTN = KokkosBatched::SerialGemm; - size_t i_elem; - Kokkos::View::const_type qp_Cuu_; - Kokkos::View::const_type x0pupSS_; - Kokkos::View::const_type N_tilde_; - Kokkos::View qp_Puu_; + auto C11 = Kokkos::subview(Cuu, Kokkos::make_pair(0, 3), Kokkos::make_pair(0, 3)); + auto C12 = Kokkos::subview(Cuu, Kokkos::make_pair(0, 3), Kokkos::make_pair(3, 6)); + KokkosBlas::SerialSet::invoke(0., Puu); + auto Puu_21 = Kokkos::subview(Puu, Kokkos::make_pair(3, 6), Kokkos::make_pair(0, 3)); + KokkosBlas::serial_axpy(1., N_tilde, Puu_21); + GemmTN::invoke(1., x0pupSS, C11, 1., Puu_21); + auto Puu_22 = Kokkos::subview(Puu, Kokkos::make_pair(3, 6), Kokkos::make_pair(3, 6)); + GemmTN::invoke(1., x0pupSS, C12, 0., Puu_22); +} - KOKKOS_FUNCTION - void operator()(int i_qp) const { - auto Cuu = Kokkos::subview(qp_Cuu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto x0pupSS = Kokkos::subview(x0pupSS_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto N_tilde = Kokkos::subview(N_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto Puu = Kokkos::subview(qp_Puu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - - auto C11 = Kokkos::subview(Cuu, Kokkos::make_pair(0, 3), Kokkos::make_pair(0, 3)); - auto C12 = Kokkos::subview(Cuu, Kokkos::make_pair(0, 3), Kokkos::make_pair(3, 6)); - KokkosBlas::SerialSet::invoke(0., Puu); - auto Puu_21 = Kokkos::subview(Puu, Kokkos::make_pair(3, 6), Kokkos::make_pair(0, 3)); - KokkosBlas::serial_axpy(1., N_tilde, Puu_21); - GemmTN::invoke(1., x0pupSS, C11, 1., Puu_21); - auto Puu_22 = Kokkos::subview(Puu, Kokkos::make_pair(3, 6), Kokkos::make_pair(3, 6)); - GemmTN::invoke(1., x0pupSS, C12, 0., Puu_22); - } -}; - -} // namespace openturbine +} // namespace openturbine::beams diff --git a/src/system/beams/calculate_Quu.hpp b/src/system/beams/calculate_Quu.hpp index dd4980eb1..78b236efb 100644 --- a/src/system/beams/calculate_Quu.hpp +++ b/src/system/beams/calculate_Quu.hpp @@ -5,36 +5,27 @@ #include #include -namespace openturbine { +namespace openturbine::beams { -struct CalculateQuu { +KOKKOS_FUNCTION +inline void CalculateQuu( + const Kokkos::View::const_type& Cuu, + const Kokkos::View::const_type& x0pupSS, + const Kokkos::View::const_type& N_tilde, const Kokkos::View& Quu +) { using NoTranspose = KokkosBatched::Trans::NoTranspose; using Transpose = KokkosBatched::Trans::Transpose; using Default = KokkosBatched::Algo::Gemm::Default; using GemmNN = KokkosBatched::SerialGemm; using GemmTN = KokkosBatched::SerialGemm; - size_t i_elem; - Kokkos::View::const_type qp_Cuu_; - Kokkos::View::const_type x0pupSS_; - Kokkos::View::const_type N_tilde_; - Kokkos::View qp_Quu_; + auto m1 = Kokkos::Array{}; + auto M1 = Kokkos::View(m1.data()); + auto C11 = Kokkos::subview(Cuu, Kokkos::make_pair(0, 3), Kokkos::make_pair(0, 3)); + KokkosBlas::SerialSet::invoke(0., Quu); + KokkosBlas::serial_axpy(1., N_tilde, M1); + GemmNN::invoke(1., C11, x0pupSS, -1., M1); + auto Quu_22 = Kokkos::subview(Quu, Kokkos::make_pair(3, 6), Kokkos::make_pair(3, 6)); + GemmTN::invoke(1., x0pupSS, M1, 0., Quu_22); +} - KOKKOS_FUNCTION - void operator()(int i_qp) const { - auto Cuu = Kokkos::subview(qp_Cuu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto x0pupSS = Kokkos::subview(x0pupSS_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto N_tilde = Kokkos::subview(N_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto m1 = Kokkos::Array{}; - auto M1 = Kokkos::View(m1.data()); - auto Quu = Kokkos::subview(qp_Quu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - - auto C11 = Kokkos::subview(Cuu, Kokkos::make_pair(0, 3), Kokkos::make_pair(0, 3)); - KokkosBlas::SerialSet::invoke(0., Quu); - KokkosBlas::serial_axpy(1., N_tilde, M1); - GemmNN::invoke(1., C11, x0pupSS, -1., M1); - auto Quu_22 = Kokkos::subview(Quu, Kokkos::make_pair(3, 6), Kokkos::make_pair(3, 6)); - GemmTN::invoke(1., x0pupSS, M1, 0., Quu_22); - } -}; - -} // namespace openturbine +} // namespace openturbine::beams diff --git a/src/system/beams/calculate_RR0.hpp b/src/system/beams/calculate_RR0.hpp deleted file mode 100644 index 5e4e74c69..000000000 --- a/src/system/beams/calculate_RR0.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include - -#include "math/quaternion_operations.hpp" - -namespace openturbine { - -struct CalculateRR0 { - size_t i_elem; - Kokkos::View::const_type qp_x_; - Kokkos::View qp_RR0_; - - KOKKOS_FUNCTION void operator()(const int i_qp) const { - auto RR0_quaternion_data = Kokkos::Array{ - qp_x_(i_elem, i_qp, 3), qp_x_(i_elem, i_qp, 4), qp_x_(i_elem, i_qp, 5), - qp_x_(i_elem, i_qp, 6) - }; - auto RR0_quaternion = Kokkos::View::const_type(RR0_quaternion_data.data()); - auto RR0_data = Kokkos::Array{}; - auto RR0 = View_3x3(RR0_data.data()); - QuaternionToRotationMatrix(RR0_quaternion, RR0); - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 3; ++j) { - qp_RR0_(i_elem, i_qp, i, j) = RR0(i, j); - qp_RR0_(i_elem, i_qp, 3 + i, 3 + j) = RR0(i, j); - } - } - } -}; -} // namespace openturbine diff --git a/src/system/beams/calculate_force_FC.hpp b/src/system/beams/calculate_force_FC.hpp index 3ba02f907..d7366c057 100644 --- a/src/system/beams/calculate_force_FC.hpp +++ b/src/system/beams/calculate_force_FC.hpp @@ -5,33 +5,17 @@ #include "math/vector_operations.hpp" -namespace openturbine { +namespace openturbine::beams { -struct CalculateForceFC { +KOKKOS_FUNCTION +inline void CalculateForceFC( + const Kokkos::View::const_type& Cuu, + const Kokkos::View::const_type& strain, const Kokkos::View& FC +) { using NoTranspose = KokkosBlas::Trans::NoTranspose; using Default = KokkosBlas::Algo::Gemv::Default; using Gemv = KokkosBlas::SerialGemv; - size_t i_elem; - Kokkos::View::const_type qp_Cuu_; - Kokkos::View::const_type qp_strain_; - Kokkos::View qp_FC_; - Kokkos::View M_tilde_; - Kokkos::View N_tilde_; + Gemv::invoke(1., Cuu, strain, 0., FC); +} - KOKKOS_FUNCTION - void operator()(int i_qp) const { - auto Cuu = Kokkos::subview(qp_Cuu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto strain = Kokkos::subview(qp_strain_, i_elem, i_qp, Kokkos::ALL); - auto FC = Kokkos::subview(qp_FC_, i_elem, i_qp, Kokkos::ALL); - auto M_tilde = Kokkos::subview(M_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto N_tilde = Kokkos::subview(N_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - - Gemv::invoke(1., Cuu, strain, 0., FC); - auto N = Kokkos::subview(FC, Kokkos::make_pair(0, 3)); - auto M = Kokkos::subview(FC, Kokkos::make_pair(3, 6)); - VecTilde(M, M_tilde); - VecTilde(N, N_tilde); - } -}; - -} // namespace openturbine +} // namespace openturbine::beams diff --git a/src/system/beams/calculate_force_FD.hpp b/src/system/beams/calculate_force_FD.hpp index 52795dd1f..f52ef4210 100644 --- a/src/system/beams/calculate_force_FD.hpp +++ b/src/system/beams/calculate_force_FD.hpp @@ -5,29 +5,23 @@ #include "math/vector_operations.hpp" -namespace openturbine { +namespace openturbine::beams { -struct CalculateForceFD { +KOKKOS_FUNCTION +inline void CalculateForceFD( + const Kokkos::View::const_type& x0pupSS, + const Kokkos::View::const_type& FC, const Kokkos::View& FD +) { using Transpose = KokkosBlas::Trans::Transpose; using Default = KokkosBlas::Algo::Gemv::Default; using Gemv = KokkosBlas::SerialGemv; - size_t i_elem; - Kokkos::View::const_type x0pupSS_; - Kokkos::View::const_type qp_FC_; - Kokkos::View qp_FD_; - - KOKKOS_FUNCTION - void operator()(int i_qp) const { - auto x0pupSS = Kokkos::subview(x0pupSS_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto FC = Kokkos::subview(qp_FC_, i_elem, i_qp, Kokkos::ALL); - auto FD = Kokkos::subview(qp_FD_, i_elem, i_qp, Kokkos::ALL); - - auto N = Kokkos::subview(FC, Kokkos::make_pair(0, 3)); - for (int i = 0; i < FD.extent_int(0); ++i) { - FD(i) = 0.; - } - Gemv::invoke(1., x0pupSS, N, 0., Kokkos::subview(FD, Kokkos::make_pair(3, 6))); + for (int i = 0; i < FD.extent_int(0); ++i) { + FD(i) = 0.; } -}; + Gemv::invoke( + 1., x0pupSS, Kokkos::subview(FC, Kokkos::make_pair(0, 3)), 0., + Kokkos::subview(FD, Kokkos::make_pair(3, 6)) + ); +} -} // namespace openturbine +} // namespace openturbine::beams diff --git a/src/system/beams/calculate_gravity_force.hpp b/src/system/beams/calculate_gravity_force.hpp deleted file mode 100644 index bbc65749b..000000000 --- a/src/system/beams/calculate_gravity_force.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include -#include - -#include "math/vector_operations.hpp" - -namespace openturbine { - -/** - * @brief Functor to calculate gravity forces in a beam/mass element - * - * This struct serves as a function object to compute gravity forces for beam and rigid body - * elements. - * - * Gravity force vector, FG = { - * {FG_1} = {m * g} - * {FG_2} = {m * eta_tilde * g} - * } - * - * The forces are computed for each quadrature point (i_qp) of a given element (i_elem). - */ -struct CalculateGravityForce { - using NoTranspose = KokkosBlas::Trans::NoTranspose; - using Default = KokkosBlas::Algo::Gemv::Default; - using Gemv = KokkosBlas::SerialGemv; - size_t i_elem; - Kokkos::View::const_type gravity; //< Gravitational acceleration vector - Kokkos::View::const_type qp_Muu_; //< Mass matrix in inertial csys - Kokkos::View::const_type eta_tilde_; //< Skew-symmetric matrix derived from eta - Kokkos::View qp_FG_; //< Gravity forces (computed in this functor) - - KOKKOS_FUNCTION - void operator()(int i_qp) const { - auto Muu = Kokkos::subview(qp_Muu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto eta_tilde = Kokkos::subview(eta_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto FG = Kokkos::subview(qp_FG_, i_elem, i_qp, Kokkos::ALL); - // Compute FG_1 = m * {g} - auto m = Muu(0, 0); - for (int i = 0; i < 3; ++i) { - FG(i) = m * gravity(i); - } - // Compute FG_2 = m * [eta_tilde] * {g} - Gemv::invoke( - 1., eta_tilde, Kokkos::subview(FG, Kokkos::make_pair(0, 3)), 0., - Kokkos::subview(FG, Kokkos::make_pair(3, 6)) - ); - } -}; - -} // namespace openturbine diff --git a/src/system/beams/calculate_gyroscopic_matrix.hpp b/src/system/beams/calculate_gyroscopic_matrix.hpp deleted file mode 100644 index 766dd353d..000000000 --- a/src/system/beams/calculate_gyroscopic_matrix.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "math/vector_operations.hpp" - -namespace openturbine { - -struct CalculateGyroscopicMatrix { - using NoTranspose = KokkosBatched::Trans::NoTranspose; - using Transpose = KokkosBatched::Trans::Transpose; - using GemmDefault = KokkosBatched::Algo::Gemm::Default; - using GemvDefault = KokkosBatched::Algo::Gemv::Default; - using GemmNN = KokkosBatched::SerialGemm; - using GemmNT = KokkosBatched::SerialGemm; - using Gemv = KokkosBlas::SerialGemv; - size_t i_elem; - Kokkos::View::const_type qp_Muu_; - Kokkos::View::const_type qp_omega_; - Kokkos::View::const_type omega_tilde_; - Kokkos::View::const_type rho_; - Kokkos::View::const_type eta_; - Kokkos::View qp_Guu_; - - KOKKOS_FUNCTION - void operator()(int i_qp) const { - auto Muu = Kokkos::subview(qp_Muu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto omega = Kokkos::subview(qp_omega_, i_elem, i_qp, Kokkos::ALL); - auto omega_tilde = Kokkos::subview(omega_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto rho = Kokkos::subview(rho_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto eta = Kokkos::subview(eta_, i_elem, i_qp, Kokkos::ALL); - auto v1 = Kokkos::Array{}; - auto V1 = Kokkos::View(v1.data()); - auto v2 = Kokkos::Array{}; - auto V2 = Kokkos::View(v2.data()); - auto m1 = Kokkos::Array{}; - auto M1 = Kokkos::View(m1.data()); - auto Guu = Kokkos::subview(qp_Guu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - - auto m = Muu(0, 0); - // Inertia gyroscopic matrix - KokkosBlas::SerialSet::invoke(0., Guu); - // omega.tilde() * m * eta.tilde().t() + (omega.tilde() * m * eta).tilde().t() - auto Guu_12 = Kokkos::subview(Guu, Kokkos::make_pair(0, 3), Kokkos::make_pair(3, 6)); - KokkosBlas::serial_axpy(m, eta, V1); - Gemv::invoke(1., omega_tilde, V1, 0., V2); - VecTilde(V2, M1); - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - Guu_12(i, j) = M1(j, i); - } - } - - VecTilde(V1, M1); - GemmNT::invoke(1., omega_tilde, M1, 1., Guu_12); - // Guu_22 = omega.tilde() * rho - (rho * omega).tilde() - Gemv::invoke(1., rho, omega, 0., V1); - VecTilde(V1, M1); - auto Guu_22 = Kokkos::subview(Guu, Kokkos::make_pair(3, 6), Kokkos::make_pair(3, 6)); - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - Guu_22(i, j) = M1(i, j); - } - } - GemmNN::invoke(1., omega_tilde, rho, -1., Guu_22); - } -}; - -} // namespace openturbine diff --git a/src/system/beams/calculate_inertia_stiffness_matrix.hpp b/src/system/beams/calculate_inertia_stiffness_matrix.hpp deleted file mode 100644 index 0c21156a8..000000000 --- a/src/system/beams/calculate_inertia_stiffness_matrix.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "math/vector_operations.hpp" - -namespace openturbine { - -struct CalculateInertiaStiffnessMatrix { - using NoTranspose = KokkosBatched::Trans::NoTranspose; - using Transpose = KokkosBatched::Trans::Transpose; - using GemmDefault = KokkosBatched::Algo::Gemm::Default; - using GemvDefault = KokkosBatched::Algo::Gemv::Default; - using GemmNN = KokkosBatched::SerialGemm; - using GemmNT = KokkosBatched::SerialGemm; - using Gemv = KokkosBlas::SerialGemv; - size_t i_elem; - Kokkos::View::const_type qp_Muu_; - Kokkos::View::const_type qp_u_ddot_; - Kokkos::View::const_type qp_omega_; - Kokkos::View::const_type qp_omega_dot_; - Kokkos::View::const_type omega_tilde_; - Kokkos::View::const_type omega_dot_tilde_; - Kokkos::View::const_type rho_; - Kokkos::View::const_type eta_; - Kokkos::View qp_Kuu_; - - KOKKOS_FUNCTION - void operator()(int i_qp) const { - auto Muu = Kokkos::subview(qp_Muu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto u_ddot = Kokkos::subview(qp_u_ddot_, i_elem, i_qp, Kokkos::ALL); - auto omega = Kokkos::subview(qp_omega_, i_elem, i_qp, Kokkos::ALL); - auto omega_dot = Kokkos::subview(qp_omega_dot_, i_elem, i_qp, Kokkos::ALL); - auto omega_tilde = Kokkos::subview(omega_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto omega_dot_tilde = - Kokkos::subview(omega_dot_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto rho = Kokkos::subview(rho_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto eta = Kokkos::subview(eta_, i_elem, i_qp, Kokkos::ALL); - auto v1 = Kokkos::Array{}; - auto V1 = View_3(v1.data()); - auto m1 = Kokkos::Array{}; - auto M1 = View_3x3(m1.data()); - auto m2 = Kokkos::Array{}; - auto M2 = View_3x3(m2.data()); - auto Kuu = Kokkos::subview(qp_Kuu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - - auto m = Muu(0, 0); - - KokkosBlas::SerialSet::invoke(0., Kuu); - KokkosBlas::serial_axpy(1., omega_dot_tilde, M1); - GemmNN::invoke(1., omega_tilde, omega_tilde, 1., M1); - KokkosBlas::serial_axpy(m, eta, V1); - VecTilde(V1, M2); - auto Kuu_12 = Kokkos::subview(Kuu, Kokkos::make_pair(0, 3), Kokkos::make_pair(3, 6)); - GemmNT::invoke(1., M1, M2, 0., Kuu_12); - VecTilde(u_ddot, M1); - auto Kuu_22 = Kokkos::subview(Kuu, Kokkos::make_pair(3, 6), Kokkos::make_pair(3, 6)); - GemmNN::invoke(1., rho, omega_dot_tilde, 0., Kuu_22); - GemmNN::invoke(1., M1, M2, 1., Kuu_22); - Gemv::invoke(1., rho, omega_dot, 0., V1); - VecTilde(V1, M2); - KokkosBlas::serial_axpy(-1., M2, Kuu_22); - Gemv::invoke(1., rho, omega, 0., V1); - VecTilde(V1, M1); - GemmNN::invoke(1., rho, omega_tilde, -1., M1); - GemmNN::invoke(1., omega_tilde, M1, 1., Kuu_22); - } -}; - -} // namespace openturbine diff --git a/src/system/beams/calculate_inertial_force.hpp b/src/system/beams/calculate_inertial_force.hpp deleted file mode 100644 index d20ee43c8..000000000 --- a/src/system/beams/calculate_inertial_force.hpp +++ /dev/null @@ -1,87 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "math/vector_operations.hpp" - -namespace openturbine { - -/** - * @brief Functor to calculate inertial forces in Beams/Masses elements - * - * @details This struct serves as a function object to compute inertial forces for beam or - * mass/rigid body elements, taking both translational and rotational effects into account. - * The formulation follows the "SO(3)-based GEBT Beam" section of the OpenTurbine theory - * documentation (Eq. 32): - * - * Inertial force vector, {FI} = - * {m * u_ddot + (omega_dot_tilde + omega_tilde * omega_tilde) * m * eta} - * {m * eta_tilde * u_ddot + rho * omega_dot + omega_tilde * rho * omega} - * - * The forces are computed for each quadrature point (i_qp) of a given element (i_elem) for - * beam elements. For mass elements, the forces are computed at the (only) node of the - * element. - */ -struct CalculateInertialForces { - using NoTranspose = KokkosBatched::Trans::NoTranspose; - using GemmDefault = KokkosBatched::Algo::Gemm::Default; - using GemvDefault = KokkosBlas::Algo::Gemv::Default; - using Gemm = KokkosBatched::SerialGemm; - using Gemv = KokkosBlas::SerialGemv; - size_t i_elem; //< Element index - Kokkos::View::const_type qp_Muu_; //< Mass matrix in inertial csys - Kokkos::View::const_type qp_u_ddot_; //< Acceleration vector - Kokkos::View::const_type qp_omega_; //< Angular velocity vector - Kokkos::View::const_type qp_omega_dot_; //< Angular acceleration vector - Kokkos::View::const_type eta_tilde_; //< Skew-symmetric matrix derived from eta - Kokkos::View omega_tilde_; //< Skew-symmetric matrix from rot. velocity - Kokkos::View omega_dot_tilde_; //< Skew-symmetric matrix from rot. acceleration - Kokkos::View::const_type rho_; //< Rotational inertia part of mass matrix - Kokkos::View::const_type eta_; //< Offset between mass center and elastic axis - Kokkos::View qp_FI_; //< Inertial forces (computed in this functor) - - KOKKOS_FUNCTION - void operator()(int i_qp) const { - auto Muu = Kokkos::subview(qp_Muu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto u_ddot = Kokkos::subview(qp_u_ddot_, i_elem, i_qp, Kokkos::ALL); - auto omega = Kokkos::subview(qp_omega_, i_elem, i_qp, Kokkos::ALL); - auto omega_dot = Kokkos::subview(qp_omega_dot_, i_elem, i_qp, Kokkos::ALL); - auto eta_tilde = Kokkos::subview(eta_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto omega_tilde = Kokkos::subview(omega_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto omega_dot_tilde = - Kokkos::subview(omega_dot_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto rho = Kokkos::subview(rho_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto eta = Kokkos::subview(eta_, i_elem, i_qp, Kokkos::ALL); - - // Define temporary views for intermediate results - auto v1 = Kokkos::Array{}; - auto V1 = View_3(v1.data()); - auto m1 = Kokkos::Array{}; - auto M1 = View_3x3(m1.data()); - auto FI = Kokkos::subview(qp_FI_, i_elem, i_qp, Kokkos::ALL); - - // Compute first 3 components of FI - // FI_1 = m * u_ddot + (omega_dot_tilde + omega_tilde * omega_tilde) * m * eta - VecTilde(omega, omega_tilde); - VecTilde(omega_dot, omega_dot_tilde); - auto FI_1 = Kokkos::subview(FI, Kokkos::make_pair(0, 3)); - auto m = Muu(0, 0); - Gemm::invoke(m, omega_tilde, omega_tilde, 0., M1); - KokkosBlas::serial_axpy(m, omega_dot_tilde, M1); - Gemv::invoke(1., M1, eta, 0., FI_1); - KokkosBlas::serial_axpy(m, u_ddot, FI_1); - - // Compute last 3 components of FI - // FI_2 = m * eta_tilde * u_ddot + rho * omega_dot + omega_tilde * rho * omega - auto FI_2 = Kokkos::subview(FI, Kokkos::make_pair(3, 6)); - KokkosBlas::serial_axpy(m, u_ddot, V1); - Gemv::invoke(1., eta_tilde, V1, 0., FI_2); - Gemv::invoke(1., rho, omega_dot, 1., FI_2); - Gemm::invoke(1., omega_tilde, rho, 0., M1); - Gemv::invoke(1., M1, omega, 1., FI_2); - } -}; - -} // namespace openturbine diff --git a/src/system/beams/calculate_inertial_quadrature_point_values.hpp b/src/system/beams/calculate_inertial_quadrature_point_values.hpp new file mode 100644 index 000000000..55ced510a --- /dev/null +++ b/src/system/beams/calculate_inertial_quadrature_point_values.hpp @@ -0,0 +1,126 @@ +#pragma once + +#include +#include + +#include "interpolate_to_quadrature_point_for_inertia.hpp" +#include "system/beams/integrate_inertia_matrix.hpp" +#include "system/beams/integrate_residual_vector.hpp" +#include "system/beams/integrate_stiffness_matrix.hpp" +#include "system/masses/calculate_gravity_force.hpp" +#include "system/masses/calculate_gyroscopic_matrix.hpp" +#include "system/masses/calculate_inertia_stiffness_matrix.hpp" +#include "system/masses/calculate_inertial_force.hpp" +#include "system/masses/calculate_mass_matrix_components.hpp" +#include "system/masses/rotate_section_matrix.hpp" + +namespace openturbine::beams { + +struct CalculateInertialQuadraturePointValues { + size_t i_elem; + + Kokkos::View::const_type shape_interp; + Kokkos::View::const_type gravity; + Kokkos::View::const_type qp_r0; + Kokkos::View::const_type qp_Mstar; + Kokkos::View::const_type node_u; + Kokkos::View::const_type node_u_dot; + Kokkos::View::const_type node_u_ddot; + + Kokkos::View qp_Fi; + Kokkos::View qp_Fg; + Kokkos::View qp_Muu; + Kokkos::View qp_Guu; + Kokkos::View qp_Kuu; + + KOKKOS_FUNCTION + void operator()(size_t i_qp) const { + const auto r0_data = Kokkos::Array{ + qp_r0(i_elem, i_qp, 0), qp_r0(i_elem, i_qp, 1), qp_r0(i_elem, i_qp, 2), + qp_r0(i_elem, i_qp, 3) + }; + auto r_data = Kokkos::Array{}; + auto xr_data = Kokkos::Array{}; + auto u_ddot_data = Kokkos::Array{}; + auto omega_data = Kokkos::Array{}; + auto omega_dot_data = Kokkos::Array{}; + auto Mstar_data = Kokkos::Array{}; + + auto eta_data = Kokkos::Array{}; + auto eta_tilde_data = Kokkos::Array{}; + auto rho_data = Kokkos::Array{}; + auto omega_tilde_data = Kokkos::Array{}; + auto omega_dot_tilde_data = Kokkos::Array{}; + auto FI_data = Kokkos::Array{}; + auto FG_data = Kokkos::Array{}; + auto Muu_data = Kokkos::Array{}; + auto Guu_data = Kokkos::Array{}; + auto Kuu_data = Kokkos::Array{}; + + const auto r0 = Kokkos::View::const_type(r0_data.data()); + const auto r = Kokkos::View(r_data.data()); + const auto xr = Kokkos::View(xr_data.data()); + const auto u_ddot = Kokkos::View(u_ddot_data.data()); + const auto omega = Kokkos::View(omega_data.data()); + const auto omega_dot = Kokkos::View(omega_dot_data.data()); + + const auto eta = Kokkos::View(eta_data.data()); + const auto eta_tilde = Kokkos::View(eta_tilde_data.data()); + const auto rho = Kokkos::View(rho_data.data()); + const auto omega_tilde = Kokkos::View(omega_tilde_data.data()); + const auto omega_dot_tilde = Kokkos::View(omega_dot_tilde_data.data()); + const auto FI = Kokkos::View(FI_data.data()); + const auto FG = Kokkos::View(FG_data.data()); + const auto Mstar = Kokkos::View(Mstar_data.data()); + const auto Muu = Kokkos::View(Muu_data.data()); + const auto Guu = Kokkos::View(Guu_data.data()); + const auto Kuu = Kokkos::View(Kuu_data.data()); + + KokkosBatched::SerialCopy<>::invoke( + Kokkos::subview(qp_Mstar, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL), Mstar + ); + beams::InterpolateToQuadraturePointForInertia( + Kokkos::subview(shape_interp, Kokkos::ALL, i_qp), node_u, node_u_dot, node_u_ddot, r, + u_ddot, omega, omega_dot + ); + + QuaternionCompose(r, r0, xr); + masses::RotateSectionMatrix(xr, Mstar, Muu); + + const auto mass = Muu(0, 0); + masses::CalculateEta(Muu, eta); + VecTilde(eta, eta_tilde); + masses::CalculateRho(Muu, rho); + + VecTilde(omega, omega_tilde); + VecTilde(omega_dot, omega_dot_tilde); + + masses::CalculateInertialForce( + mass, u_ddot, omega, omega_dot, eta, eta_tilde, rho, omega_tilde, omega_dot_tilde, FI + ); + masses::CalculateGravityForce(mass, gravity, eta_tilde, FG); + + masses::CalculateGyroscopicMatrix(mass, omega, eta, rho, omega_tilde, Guu); + masses::CalculateInertiaStiffnessMatrix( + mass, u_ddot, omega, omega_dot, eta, rho, omega_tilde, omega_dot_tilde, Kuu + ); + + KokkosBatched::SerialCopy::invoke( + FI, Kokkos::subview(qp_Fi, i_qp, Kokkos::ALL) + ); + KokkosBatched::SerialCopy::invoke( + FG, Kokkos::subview(qp_Fg, i_qp, Kokkos::ALL) + ); + KokkosBatched::SerialCopy<>::invoke( + Muu, Kokkos::subview(qp_Muu, i_qp, Kokkos::ALL, Kokkos::ALL) + ); + KokkosBatched::SerialCopy<>::invoke( + Guu, Kokkos::subview(qp_Guu, i_qp, Kokkos::ALL, Kokkos::ALL) + ); + KokkosBatched::SerialCopy<>::invoke( + Kuu, Kokkos::subview(qp_Kuu, i_qp, Kokkos::ALL, Kokkos::ALL) + ); + } +}; + +} // namespace openturbine::beams diff --git a/src/system/beams/calculate_mass_matrix_components.hpp b/src/system/beams/calculate_mass_matrix_components.hpp deleted file mode 100644 index 08480d01c..000000000 --- a/src/system/beams/calculate_mass_matrix_components.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include - -#include "math/vector_operations.hpp" - -namespace openturbine { - -/** - * @brief Functor to calculate mass matrix components from mass matrix in inertial csys - * - * This struct serves as a function object to compute three key components from the provided mass - * matrix: - * - eta: The offset vector representing the distance between mass center and elastic axis - * - rho: The 3x3 mass matrix for rotational terms - * - eta_tilde: The skew-symmetric matrix derived from eta - * - * The calculations are performed for each quadrature point (i_qp) of a given element (i_elem) - */ -struct CalculateMassMatrixComponents { - size_t i_elem; //< Element index - Kokkos::View::const_type qp_Muu_; //< Mass matrix in inertial csys - Kokkos::View eta_; //< Offset between mass center and - //< elastic axis - Kokkos::View rho_; //< Rotational part of mass matrix - Kokkos::View eta_tilde_; //< Skew-symmetric matrix derived from eta - - KOKKOS_FUNCTION - void operator()(int i_qp) const { - auto Muu = Kokkos::subview(qp_Muu_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto eta = Kokkos::subview(eta_, i_elem, i_qp, Kokkos::ALL); - auto rho = Kokkos::subview(rho_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - auto eta_tilde = Kokkos::subview(eta_tilde_, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL); - - // Compute eta components using off-diagonal terms in lower-left 3x3 block of Muu - eta(0) = eta(1) = eta(2) = 0.; - if (const auto m = Muu(0, 0); m != 0.) { - eta(0) = Muu(5, 1) / m; - eta(1) = -Muu(5, 0) / m; - eta(2) = Muu(4, 0) / m; - } - - // Extract the rotational mass terms from the lower-right 3x3 block of Muu - for (int i = 0; i < rho.extent_int(0); ++i) { - for (int j = 0; j < rho.extent_int(1); ++j) { - rho(i, j) = Muu(i + 3, j + 3); - } - } - - // Generate the skew-symmetric matrix eta_tilde from eta - VecTilde(eta, eta_tilde); - } -}; - -} // namespace openturbine diff --git a/src/system/beams/calculate_quadrature_point_values.hpp b/src/system/beams/calculate_quadrature_point_values.hpp index 00f521bed..bbe6518b1 100644 --- a/src/system/beams/calculate_quadrature_point_values.hpp +++ b/src/system/beams/calculate_quadrature_point_values.hpp @@ -2,149 +2,136 @@ #include -#include "calculate_Ouu.hpp" -#include "calculate_Puu.hpp" -#include "calculate_Quu.hpp" -#include "calculate_RR0.hpp" -#include "calculate_force_FC.hpp" -#include "calculate_force_FD.hpp" -#include "calculate_gravity_force.hpp" -#include "calculate_gyroscopic_matrix.hpp" -#include "calculate_inertia_stiffness_matrix.hpp" -#include "calculate_inertial_force.hpp" -#include "calculate_mass_matrix_components.hpp" -#include "calculate_strain.hpp" -#include "calculate_temporary_variables.hpp" -#include "rotate_section_matrix.hpp" - -namespace openturbine { +#include "calculate_inertial_quadrature_point_values.hpp" +#include "calculate_stiffness_quadrature_point_values.hpp" +#include "integrate_inertia_matrix.hpp" +#include "integrate_residual_vector.hpp" +#include "integrate_stiffness_matrix.hpp" +#include "update_node_state.hpp" + +namespace openturbine::beams { struct CalculateQuadraturePointValues { + double beta_prime_; + double gamma_prime_; + Kokkos::View::const_type Q; + Kokkos::View::const_type V; + Kokkos::View::const_type A; + Kokkos::View::const_type node_state_indices; + Kokkos::View::const_type num_nodes_per_element; Kokkos::View::const_type num_qps_per_element; + Kokkos::View::const_type qp_weight_; + Kokkos::View::const_type qp_jacobian_; + Kokkos::View::const_type shape_interp_; + Kokkos::View::const_type shape_deriv_; Kokkos::View::const_type gravity_; - Kokkos::View::const_type qp_u_; - Kokkos::View::const_type qp_u_prime_; - Kokkos::View::const_type qp_r_; - Kokkos::View::const_type qp_r_prime_; + Kokkos::View::const_type node_FX_; Kokkos::View::const_type qp_r0_; Kokkos::View::const_type qp_x0_; Kokkos::View::const_type qp_x0_prime_; - Kokkos::View::const_type qp_u_ddot_; - Kokkos::View::const_type qp_omega_; - Kokkos::View::const_type qp_omega_dot_; Kokkos::View::const_type qp_Mstar_; Kokkos::View::const_type qp_Cstar_; - Kokkos::View qp_x_; - Kokkos::View qp_RR0_; - Kokkos::View qp_strain_; - Kokkos::View qp_eta_; - Kokkos::View qp_rho_; - Kokkos::View qp_eta_tilde_; - Kokkos::View qp_x0pupSS_; - Kokkos::View qp_M_tilde_; - Kokkos::View qp_N_tilde_; - Kokkos::View qp_omega_tilde_; - Kokkos::View qp_omega_dot_tilde_; - Kokkos::View qp_FC_; - Kokkos::View qp_FD_; - Kokkos::View qp_FI_; Kokkos::View qp_FE_; - Kokkos::View qp_FG_; - Kokkos::View qp_Muu_; - Kokkos::View qp_Cuu_; - Kokkos::View qp_Ouu_; - Kokkos::View qp_Puu_; - Kokkos::View qp_Quu_; - Kokkos::View qp_Guu_; - Kokkos::View qp_Kuu_; + Kokkos::View residual_vector_terms_; + Kokkos::View stiffness_matrix_terms_; + Kokkos::View inertia_matrix_terms_; KOKKOS_FUNCTION void operator()(Kokkos::TeamPolicy<>::member_type member) const { + using simd_type = Kokkos::Experimental::native_simd; const auto i_elem = static_cast(member.league_rank()); + const auto num_nodes = num_nodes_per_element(i_elem); const auto num_qps = num_qps_per_element(i_elem); - - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), CalculateRR0{i_elem, qp_x_, qp_RR0_} + constexpr auto width = simd_type::size(); + const auto extra_component = num_nodes % width == 0U ? 0U : 1U; + const auto simd_nodes = num_nodes / width + extra_component; + + const auto qp_range = Kokkos::TeamThreadRange(member, num_qps); + const auto node_range = Kokkos::TeamThreadRange(member, num_nodes); + const auto node_squared_range = Kokkos::TeamThreadRange(member, num_nodes * simd_nodes); + + const auto shape_interp = + Kokkos::View(member.team_scratch(1), num_nodes, num_qps); + const auto shape_deriv = + Kokkos::View(member.team_scratch(1), num_nodes, num_qps); + + const auto qp_weight = Kokkos::View(member.team_scratch(1), num_qps); + const auto qp_jacobian = Kokkos::View(member.team_scratch(1), num_qps); + + const auto node_u = Kokkos::View(member.team_scratch(1), num_nodes); + const auto node_u_dot = Kokkos::View(member.team_scratch(1), num_nodes); + const auto node_u_ddot = Kokkos::View(member.team_scratch(1), num_nodes); + const auto node_FX = Kokkos::View(member.team_scratch(1), num_nodes); + const auto qp_Fc = Kokkos::View(member.team_scratch(1), num_qps); + const auto qp_Fd = Kokkos::View(member.team_scratch(1), num_qps); + const auto qp_Fi = Kokkos::View(member.team_scratch(1), num_qps); + const auto qp_Fe = Kokkos::View(member.team_scratch(1), num_qps); + const auto qp_Fg = Kokkos::View(member.team_scratch(1), num_qps); + + const auto qp_Kuu = Kokkos::View(member.team_scratch(1), num_qps); + const auto qp_Puu = Kokkos::View(member.team_scratch(1), num_qps); + const auto qp_Cuu = Kokkos::View(member.team_scratch(1), num_qps); + const auto qp_Ouu = Kokkos::View(member.team_scratch(1), num_qps); + const auto qp_Quu = Kokkos::View(member.team_scratch(1), num_qps); + const auto qp_Muu = Kokkos::View(member.team_scratch(1), num_qps); + const auto qp_Guu = Kokkos::View(member.team_scratch(1), num_qps); + + KokkosBatched::TeamVectorCopy::member_type>::invoke( + member, Kokkos::subview(shape_interp_, i_elem, Kokkos::ALL, Kokkos::ALL), shape_interp ); - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - CalculateTemporaryVariables{i_elem, qp_x0_prime_, qp_u_prime_, qp_x0pupSS_} + KokkosBatched::TeamVectorCopy::member_type>::invoke( + member, Kokkos::subview(shape_deriv_, i_elem, Kokkos::ALL, Kokkos::ALL), shape_deriv ); - member.team_barrier(); - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - RotateSectionMatrix{i_elem, qp_RR0_, qp_Mstar_, qp_Muu_} + KokkosBatched::TeamVectorCopy::member_type>::invoke( + member, Kokkos::subview(qp_FE_, i_elem, Kokkos::ALL, Kokkos::ALL), qp_Fe ); - - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - RotateSectionMatrix{i_elem, qp_RR0_, qp_Cstar_, qp_Cuu_} + KokkosBatched::TeamVectorCopy::member_type>::invoke( + member, Kokkos::subview(node_FX_, i_elem, Kokkos::ALL, Kokkos::ALL), node_FX ); - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - CalculateStrain{i_elem, qp_x0_prime_, qp_u_prime_, qp_r_, qp_r_prime_, qp_strain_} - ); + KokkosBatched::TeamVectorCopy< + Kokkos::TeamPolicy<>::member_type, KokkosBatched::Trans::NoTranspose, + 1>::invoke(member, Kokkos::subview(qp_weight_, i_elem, Kokkos::ALL), qp_weight); + KokkosBatched::TeamVectorCopy< + Kokkos::TeamPolicy<>::member_type, KokkosBatched::Trans::NoTranspose, + 1>::invoke(member, Kokkos::subview(qp_jacobian_, i_elem, Kokkos::ALL), qp_jacobian); + + const auto node_state_updater = beams::UpdateNodeStateElement{ + i_elem, node_state_indices, node_u, node_u_dot, node_u_ddot, Q, V, A + }; + Kokkos::parallel_for(node_range, node_state_updater); member.team_barrier(); - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - CalculateMassMatrixComponents{i_elem, qp_Muu_, qp_eta_, qp_rho_, qp_eta_tilde_} - ); - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - CalculateForceFC{i_elem, qp_Cuu_, qp_strain_, qp_FC_, qp_M_tilde_, qp_N_tilde_} - ); + const auto inertia_quad_point_calculator = beams::CalculateInertialQuadraturePointValues{ + i_elem, shape_interp, gravity_, qp_r0_, qp_Mstar_, node_u, node_u_dot, + node_u_ddot, qp_Fi, qp_Fg, qp_Muu, qp_Guu, qp_Kuu + }; + Kokkos::parallel_for(qp_range, inertia_quad_point_calculator); + + const auto stiffness_quad_point_calculator = beams::CalculateStiffnessQuadraturePointValues{ + i_elem, qp_jacobian, shape_interp, shape_deriv, qp_r0_, qp_x0_prime_, qp_Cstar_, + node_u, qp_Fc, qp_Fd, qp_Cuu, qp_Ouu, qp_Puu, qp_Quu + }; + Kokkos::parallel_for(qp_range, stiffness_quad_point_calculator); member.team_barrier(); - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - CalculateInertialForces{ - i_elem, qp_Muu_, qp_u_ddot_, qp_omega_, qp_omega_dot_, qp_eta_tilde_, - qp_omega_tilde_, qp_omega_dot_tilde_, qp_rho_, qp_eta_, qp_FI_ - } - ); - member.team_barrier(); - - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - CalculateForceFD{i_elem, qp_x0pupSS_, qp_FC_, qp_FD_} - ); - - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - CalculateGravityForce{i_elem, gravity_, qp_Muu_, qp_eta_tilde_, qp_FG_} - ); - - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - CalculateOuu{i_elem, qp_Cuu_, qp_x0pupSS_, qp_M_tilde_, qp_N_tilde_, qp_Ouu_} - ); - - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - CalculatePuu{i_elem, qp_Cuu_, qp_x0pupSS_, qp_N_tilde_, qp_Puu_} - ); - - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - CalculateQuu{i_elem, qp_Cuu_, qp_x0pupSS_, qp_N_tilde_, qp_Quu_} - ); - - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - CalculateGyroscopicMatrix{ - i_elem, qp_Muu_, qp_omega_, qp_omega_tilde_, qp_rho_, qp_eta_, qp_Guu_ - } - ); - - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_qps), - CalculateInertiaStiffnessMatrix{ - i_elem, qp_Muu_, qp_u_ddot_, qp_omega_, qp_omega_dot_, qp_omega_tilde_, - qp_omega_dot_tilde_, qp_rho_, qp_eta_, qp_Kuu_ - } - ); + const auto residual_integrator = IntegrateResidualVectorElement{ + i_elem, num_qps, qp_weight, qp_jacobian, shape_interp, shape_deriv, node_FX, + qp_Fc, qp_Fd, qp_Fi, qp_Fe, qp_Fg, residual_vector_terms_ + }; + Kokkos::parallel_for(node_range, residual_integrator); + + const auto stiffness_matrix_integrator = IntegrateStiffnessMatrixElement{ + i_elem, num_nodes, num_qps, qp_weight, qp_jacobian, shape_interp, shape_deriv, + qp_Kuu, qp_Puu, qp_Cuu, qp_Ouu, qp_Quu, stiffness_matrix_terms_ + }; + Kokkos::parallel_for(node_squared_range, stiffness_matrix_integrator); + + const auto inertia_matrix_integrator = IntegrateInertiaMatrixElement{ + i_elem, num_nodes, num_qps, qp_weight, qp_jacobian, shape_interp, + qp_Muu, qp_Guu, beta_prime_, gamma_prime_, inertia_matrix_terms_ + }; + Kokkos::parallel_for(node_squared_range, inertia_matrix_integrator); } }; -} // namespace openturbine +} // namespace openturbine::beams diff --git a/src/system/beams/calculate_stiffness_quadrature_point_values.hpp b/src/system/beams/calculate_stiffness_quadrature_point_values.hpp new file mode 100644 index 000000000..4961d3392 --- /dev/null +++ b/src/system/beams/calculate_stiffness_quadrature_point_values.hpp @@ -0,0 +1,129 @@ +#pragma once + +#include +#include + +#include "calculate_Ouu.hpp" +#include "calculate_Puu.hpp" +#include "calculate_Quu.hpp" +#include "calculate_force_FC.hpp" +#include "calculate_force_FD.hpp" +#include "calculate_strain.hpp" +#include "calculate_temporary_variables.hpp" +#include "interpolate_to_quadrature_point_for_stiffness.hpp" + +namespace openturbine::beams { + +struct CalculateStiffnessQuadraturePointValues { + size_t i_elem; + + Kokkos::View::const_type qp_jacobian; + Kokkos::View::const_type shape_interp; + Kokkos::View::const_type shape_deriv; + Kokkos::View::const_type qp_r0; + Kokkos::View::const_type qp_x0_prime; + Kokkos::View::const_type qp_Cstar; + Kokkos::View::const_type node_u; + + Kokkos::View qp_Fc; + Kokkos::View qp_Fd; + Kokkos::View qp_Cuu; + Kokkos::View qp_Ouu; + Kokkos::View qp_Puu; + Kokkos::View qp_Quu; + + KOKKOS_FUNCTION + void operator()(size_t i_qp) const { + const auto r0_data = Kokkos::Array{ + qp_r0(i_elem, i_qp, 0), qp_r0(i_elem, i_qp, 1), qp_r0(i_elem, i_qp, 2), + qp_r0(i_elem, i_qp, 3) + }; + const auto x0_prime_data = Kokkos::Array{ + qp_x0_prime(i_elem, i_qp, 0), qp_x0_prime(i_elem, i_qp, 1), + qp_x0_prime(i_elem, i_qp, 2) + }; + auto xr_data = Kokkos::Array{}; + auto u_data = Kokkos::Array{}; + auto u_prime_data = Kokkos::Array{}; + auto r_data = Kokkos::Array{}; + auto r_prime_data = Kokkos::Array{}; + auto Cstar_data = Kokkos::Array{}; + + auto strain_data = Kokkos::Array{}; + auto x0pupSS_data = Kokkos::Array{}; + auto M_tilde_data = Kokkos::Array{}; + auto N_tilde_data = Kokkos::Array{}; + auto FC_data = Kokkos::Array{}; + auto FD_data = Kokkos::Array{}; + auto Cuu_data = Kokkos::Array{}; + auto Ouu_data = Kokkos::Array{}; + auto Puu_data = Kokkos::Array{}; + auto Quu_data = Kokkos::Array{}; + + const auto r0 = Kokkos::View::const_type(r0_data.data()); + const auto x0_prime = Kokkos::View::const_type(x0_prime_data.data()); + const auto xr = Kokkos::View(xr_data.data()); + const auto u = Kokkos::View(u_data.data()); + const auto u_prime = Kokkos::View(u_prime_data.data()); + const auto r = Kokkos::View(r_data.data()); + const auto r_prime = Kokkos::View(r_prime_data.data()); + + const auto strain = Kokkos::View(strain_data.data()); + const auto x0pupSS = Kokkos::View(x0pupSS_data.data()); + const auto M_tilde = Kokkos::View(M_tilde_data.data()); + const auto N_tilde = Kokkos::View(N_tilde_data.data()); + const auto FC = Kokkos::View(FC_data.data()); + const auto FD = Kokkos::View(FD_data.data()); + const auto Cstar = Kokkos::View(Cstar_data.data()); + const auto Cuu = Kokkos::View(Cuu_data.data()); + const auto Ouu = Kokkos::View(Ouu_data.data()); + const auto Puu = Kokkos::View(Puu_data.data()); + const auto Quu = Kokkos::View(Quu_data.data()); + + KokkosBatched::SerialCopy<>::invoke( + Kokkos::subview(qp_Cstar, i_elem, i_qp, Kokkos::ALL, Kokkos::ALL), Cstar + ); + + beams::InterpolateToQuadraturePointForStiffness( + qp_jacobian(i_qp), Kokkos::subview(shape_interp, Kokkos::ALL, i_qp), + Kokkos::subview(shape_deriv, Kokkos::ALL, i_qp), node_u, u, r, u_prime, r_prime + ); + QuaternionCompose(r, r0, xr); + + masses::RotateSectionMatrix(xr, Cstar, Cuu); + + beams::CalculateStrain(x0_prime, u_prime, r, r_prime, strain); + beams::CalculateTemporaryVariables(x0_prime, u_prime, x0pupSS); + beams::CalculateForceFC(Cuu, strain, FC); + beams::CalculateForceFD(x0pupSS, FC, FD); + + VecTilde(Kokkos::subview(FC, Kokkos::make_pair(0, 3)), N_tilde); + VecTilde(Kokkos::subview(FC, Kokkos::make_pair(3, 6)), M_tilde); + + beams::CalculateOuu(Cuu, x0pupSS, M_tilde, N_tilde, Ouu); + beams::CalculatePuu(Cuu, x0pupSS, N_tilde, Puu); + beams::CalculateQuu(Cuu, x0pupSS, N_tilde, Quu); + + KokkosBatched::SerialCopy::invoke( + FC, Kokkos::subview(qp_Fc, i_qp, Kokkos::ALL) + ); + KokkosBatched::SerialCopy::invoke( + FD, Kokkos::subview(qp_Fd, i_qp, Kokkos::ALL) + ); + + KokkosBatched::SerialCopy<>::invoke( + Cuu, Kokkos::subview(qp_Cuu, i_qp, Kokkos::ALL, Kokkos::ALL) + ); + KokkosBatched::SerialCopy<>::invoke( + Ouu, Kokkos::subview(qp_Ouu, i_qp, Kokkos::ALL, Kokkos::ALL) + ); + KokkosBatched::SerialCopy<>::invoke( + Puu, Kokkos::subview(qp_Puu, i_qp, Kokkos::ALL, Kokkos::ALL) + ); + KokkosBatched::SerialCopy<>::invoke( + Quu, Kokkos::subview(qp_Quu, i_qp, Kokkos::ALL, Kokkos::ALL) + ); + } +}; + +} // namespace openturbine::beams diff --git a/src/system/beams/calculate_strain.hpp b/src/system/beams/calculate_strain.hpp index 136a6f9b2..93f908a5e 100644 --- a/src/system/beams/calculate_strain.hpp +++ b/src/system/beams/calculate_strain.hpp @@ -6,62 +6,35 @@ #include "math/quaternion_operations.hpp" -namespace openturbine { - -struct CalculateStrain { +namespace openturbine::beams { +KOKKOS_FUNCTION +inline void CalculateStrain( + const Kokkos::View::const_type& x0_prime, + const Kokkos::View::const_type& u_prime, const Kokkos::View::const_type& r, + const Kokkos::View::const_type& r_prime, const Kokkos::View& strain +) { using NoTranspose = KokkosBlas::Trans::NoTranspose; using Default = KokkosBlas::Algo::Gemv::Default; using Gemv = KokkosBlas::SerialGemv; - size_t i_elem; - Kokkos::View::const_type qp_x0_prime_; - Kokkos::View::const_type qp_u_prime_; - Kokkos::View::const_type qp_r_; - Kokkos::View::const_type qp_r_prime_; - Kokkos::View qp_strain_; - - KOKKOS_FUNCTION - void operator()(const int i_qp) const { - auto x0_prime_data = Kokkos::Array{ - qp_x0_prime_(i_elem, i_qp, 0), qp_x0_prime_(i_elem, i_qp, 1), - qp_x0_prime_(i_elem, i_qp, 2) - }; - auto x0_prime = Kokkos::View(x0_prime_data.data()); - auto u_prime_data = Kokkos::Array{ - qp_u_prime_(i_elem, i_qp, 0), qp_u_prime_(i_elem, i_qp, 1), qp_u_prime_(i_elem, i_qp, 2) - }; - auto u_prime = Kokkos::View(u_prime_data.data()); - auto R_data = Kokkos::Array{ - qp_r_(i_elem, i_qp, 0), qp_r_(i_elem, i_qp, 1), qp_r_(i_elem, i_qp, 2), - qp_r_(i_elem, i_qp, 3) - }; - auto R = Kokkos::View(R_data.data()); - - auto R_x0_prime_data = Kokkos::Array{}; - auto R_x0_prime = Kokkos::View(R_x0_prime_data.data()); - - RotateVectorByQuaternion(R, x0_prime, R_x0_prime); - KokkosBlas::serial_axpy(-1., u_prime, R_x0_prime); - KokkosBlas::serial_axpy(-1., x0_prime, R_x0_prime); - - auto E_data = Kokkos::Array{}; - auto E = Kokkos::View(E_data.data()); - QuaternionDerivative(R, E); - auto R_prime_data = Kokkos::Array{ - qp_r_prime_(i_elem, i_qp, 0), qp_r_prime_(i_elem, i_qp, 1), qp_r_prime_(i_elem, i_qp, 2), - qp_r_prime_(i_elem, i_qp, 3) - }; - auto R_prime = Kokkos::View(R_prime_data.data()); - auto e2_data = Kokkos::Array{}; - auto e2 = Kokkos::View{e2_data.data()}; - Gemv::invoke(2., E, R_prime, 0., e2); - - qp_strain_(i_elem, i_qp, 0) = -R_x0_prime(0); - qp_strain_(i_elem, i_qp, 1) = -R_x0_prime(1); - qp_strain_(i_elem, i_qp, 2) = -R_x0_prime(2); - qp_strain_(i_elem, i_qp, 3) = e2(0); - qp_strain_(i_elem, i_qp, 4) = e2(1); - qp_strain_(i_elem, i_qp, 5) = e2(2); - } -}; - -} // namespace openturbine + auto R_x0_prime_data = Kokkos::Array{}; + auto R_x0_prime = Kokkos::View(R_x0_prime_data.data()); + + RotateVectorByQuaternion(r, x0_prime, R_x0_prime); + KokkosBlas::serial_axpy(-1., u_prime, R_x0_prime); + KokkosBlas::serial_axpy(-1., x0_prime, R_x0_prime); + + auto E_data = Kokkos::Array{}; + auto E = Kokkos::View(E_data.data()); + QuaternionDerivative(r, E); + auto e2_data = Kokkos::Array{}; + auto e2 = Kokkos::View{e2_data.data()}; + Gemv::invoke(2., E, r_prime, 0., e2); + + strain(0) = -R_x0_prime(0); + strain(1) = -R_x0_prime(1); + strain(2) = -R_x0_prime(2); + strain(3) = e2(0); + strain(4) = e2(1); + strain(5) = e2(2); +} +} // namespace openturbine::beams diff --git a/src/system/beams/calculate_temporary_variables.hpp b/src/system/beams/calculate_temporary_variables.hpp index 006e0c1c7..5158b8eff 100644 --- a/src/system/beams/calculate_temporary_variables.hpp +++ b/src/system/beams/calculate_temporary_variables.hpp @@ -5,35 +5,18 @@ #include "math/vector_operations.hpp" -namespace openturbine { +namespace openturbine::beams { -struct CalculateTemporaryVariables { - size_t i_elem; - Kokkos::View::const_type qp_x0_prime_; - Kokkos::View::const_type qp_u_prime_; - Kokkos::View x0pupSS_; +KOKKOS_FUNCTION +inline void CalculateTemporaryVariables( + const Kokkos::View::const_type& x0_prime, + const Kokkos::View::const_type& u_prime, const Kokkos::View& x0pupSS +) { + auto x0pup_data = Kokkos::Array{x0_prime(0), x0_prime(1), x0_prime(2)}; + const auto x0pup = Kokkos::View(x0pup_data.data()); - KOKKOS_FUNCTION - void operator()(int i_qp) const { - auto x0pup_data = Kokkos::Array{ - qp_x0_prime_(i_elem, i_qp, 0), qp_x0_prime_(i_elem, i_qp, 1), - qp_x0_prime_(i_elem, i_qp, 2) - }; - auto x0pup = View_3{x0pup_data.data()}; - auto u_prime_data = Kokkos::Array{ - qp_u_prime_(i_elem, i_qp, 0), qp_u_prime_(i_elem, i_qp, 1), qp_u_prime_(i_elem, i_qp, 2) - }; - auto u_prime = View_3{u_prime_data.data()}; - KokkosBlas::serial_axpy(1., u_prime, x0pup); - auto tmp_data = Kokkos::Array{}; - auto tmp = View_3x3{tmp_data.data()}; - VecTilde(x0pup, tmp); - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 3; ++j) { - x0pupSS_(i_elem, i_qp, i, j) = tmp(i, j); - } - } - } -}; + KokkosBlas::serial_axpy(1., u_prime, x0pup); + VecTilde(x0pup, x0pupSS); +} -} // namespace openturbine +} // namespace openturbine::beams diff --git a/src/system/beams/integrate_inertia_matrix.hpp b/src/system/beams/integrate_inertia_matrix.hpp index 9c0893473..5b9db66d6 100644 --- a/src/system/beams/integrate_inertia_matrix.hpp +++ b/src/system/beams/integrate_inertia_matrix.hpp @@ -3,7 +3,7 @@ #include #include -namespace openturbine { +namespace openturbine::beams { struct IntegrateInertiaMatrixElement { size_t i_elem; @@ -69,59 +69,4 @@ struct IntegrateInertiaMatrixElement { } } }; - -struct IntegrateInertiaMatrix { - Kokkos::View::const_type num_nodes_per_element; - Kokkos::View::const_type num_qps_per_element; - Kokkos::View::const_type qp_weight_; - Kokkos::View::const_type qp_jacobian_; - Kokkos::View::const_type shape_interp_; - Kokkos::View::const_type qp_Muu_; - Kokkos::View::const_type qp_Guu_; - double beta_prime_; - double gamma_prime_; - Kokkos::View gbl_M_; - - KOKKOS_FUNCTION - void operator()(const Kokkos::TeamPolicy<>::member_type& member) const { - using simd_type = Kokkos::Experimental::native_simd; - const auto i_elem = static_cast(member.league_rank()); - const auto num_nodes = num_nodes_per_element(i_elem); - const auto num_qps = num_qps_per_element(i_elem); - constexpr auto width = simd_type::size(); - const auto extra_component = num_nodes % width == 0U ? 0U : 1U; - const auto simd_nodes = num_nodes / width + extra_component; - - const auto shape_interp = - Kokkos::View(member.team_scratch(1), num_nodes, num_qps); - - const auto qp_weight = Kokkos::View(member.team_scratch(1), num_qps); - const auto qp_jacobian = Kokkos::View(member.team_scratch(1), num_qps); - - const auto qp_Muu = Kokkos::View(member.team_scratch(1), num_qps); - const auto qp_Guu = Kokkos::View(member.team_scratch(1), num_qps); - - Kokkos::parallel_for(Kokkos::TeamThreadRange(member, num_qps), [&](size_t k) { - for (auto i = 0U; i < num_nodes; ++i) { - shape_interp(i, k) = shape_interp_(i_elem, i, k); - } - qp_weight(k) = qp_weight_(i_elem, k); - qp_jacobian(k) = qp_jacobian_(i_elem, k); - for (auto m = 0U; m < 6U; ++m) { - for (auto n = 0U; n < 6U; ++n) { - qp_Muu(k, m, n) = qp_Muu_(i_elem, k, m, n); - qp_Guu(k, m, n) = qp_Guu_(i_elem, k, m, n); - } - } - }); - member.team_barrier(); - - const auto node_range = Kokkos::TeamThreadRange(member, num_nodes * simd_nodes); - const auto element_integrator = - IntegrateInertiaMatrixElement{i_elem, num_nodes, num_qps, qp_weight, - qp_jacobian, shape_interp, qp_Muu, qp_Guu, - beta_prime_, gamma_prime_, gbl_M_}; - Kokkos::parallel_for(node_range, element_integrator); - } -}; -} // namespace openturbine +} // namespace openturbine::beams diff --git a/src/system/beams/integrate_residual_vector.hpp b/src/system/beams/integrate_residual_vector.hpp index f0fae9640..01910bfcc 100644 --- a/src/system/beams/integrate_residual_vector.hpp +++ b/src/system/beams/integrate_residual_vector.hpp @@ -2,15 +2,15 @@ #include -namespace openturbine { +namespace openturbine::beams { struct IntegrateResidualVectorElement { size_t i_elem; size_t num_qps; Kokkos::View::const_type qp_weight_; Kokkos::View::const_type qp_jacobian_; - Kokkos::View::const_type shape_interp_; - Kokkos::View::const_type shape_deriv_; + Kokkos::View::const_type shape_interp_; + Kokkos::View::const_type shape_deriv_; Kokkos::View::const_type node_FX_; Kokkos::View::const_type qp_Fc_; Kokkos::View::const_type qp_Fd_; @@ -37,69 +37,4 @@ struct IntegrateResidualVectorElement { } } }; - -struct IntegrateResidualVector { - Kokkos::View::const_type num_nodes_per_element; - Kokkos::View::const_type num_qps_per_element; - Kokkos::View::const_type qp_weight_; - Kokkos::View::const_type qp_jacobian_; - Kokkos::View::const_type shape_interp_; - Kokkos::View::const_type shape_deriv_; - Kokkos::View::const_type node_FX_; - Kokkos::View::const_type qp_Fc_; - Kokkos::View::const_type qp_Fd_; - Kokkos::View::const_type qp_Fi_; - Kokkos::View::const_type qp_Fe_; - Kokkos::View::const_type qp_Fg_; - Kokkos::View residual_vector_terms_; - - KOKKOS_FUNCTION void operator()(const Kokkos::TeamPolicy<>::member_type& member) const { - const auto i_elem = static_cast(member.league_rank()); - const auto num_nodes = num_nodes_per_element(i_elem); - const auto num_qps = num_qps_per_element(i_elem); - - const auto shape_interp = Kokkos::View(member.team_scratch(1), num_nodes, num_qps); - const auto shape_deriv = Kokkos::View(member.team_scratch(1), num_nodes, num_qps); - - const auto qp_weight = Kokkos::View(member.team_scratch(1), num_qps); - const auto qp_jacobian = Kokkos::View(member.team_scratch(1), num_qps); - - const auto node_FX = Kokkos::View(member.team_scratch(1), num_nodes); - const auto qp_Fc = Kokkos::View(member.team_scratch(1), num_qps); - const auto qp_Fd = Kokkos::View(member.team_scratch(1), num_qps); - const auto qp_Fi = Kokkos::View(member.team_scratch(1), num_qps); - const auto qp_Fe = Kokkos::View(member.team_scratch(1), num_qps); - const auto qp_Fg = Kokkos::View(member.team_scratch(1), num_qps); - - Kokkos::parallel_for(Kokkos::TeamThreadRange(member, num_qps), [&](size_t k) { - for (auto i = 0U; i < num_nodes; ++i) { - shape_interp(i, k) = shape_interp_(i_elem, i, k); - shape_deriv(i, k) = shape_deriv_(i_elem, i, k); - } - qp_weight(k) = qp_weight_(i_elem, k); - qp_jacobian(k) = qp_jacobian_(i_elem, k); - for (auto i = 0U; i < 6U; ++i) { - qp_Fc(k, i) = qp_Fc_(i_elem, k, i); - qp_Fd(k, i) = qp_Fd_(i_elem, k, i); - qp_Fi(k, i) = qp_Fi_(i_elem, k, i); - qp_Fe(k, i) = qp_Fe_(i_elem, k, i); - qp_Fg(k, i) = qp_Fg_(i_elem, k, i); - } - }); - Kokkos::parallel_for(Kokkos::TeamThreadRange(member, num_nodes), [&](size_t k) { - for (auto i = 0U; i < 6U; ++i) { - node_FX(k, i) = node_FX_(i_elem, k, i); - } - }); - member.team_barrier(); - - const auto node_range = Kokkos::TeamThreadRange(member, num_nodes); - const auto element_integrator = IntegrateResidualVectorElement{ - i_elem, num_qps, qp_weight, qp_jacobian, shape_interp, shape_deriv, node_FX, - qp_Fc, qp_Fd, qp_Fi, qp_Fe, qp_Fg, residual_vector_terms_ - }; - Kokkos::parallel_for(node_range, element_integrator); - } -}; - -} // namespace openturbine +} // namespace openturbine::beams diff --git a/src/system/beams/integrate_stiffness_matrix.hpp b/src/system/beams/integrate_stiffness_matrix.hpp index 99f9757ba..331910927 100644 --- a/src/system/beams/integrate_stiffness_matrix.hpp +++ b/src/system/beams/integrate_stiffness_matrix.hpp @@ -3,7 +3,7 @@ #include #include -namespace openturbine { +namespace openturbine::beams { struct IntegrateStiffnessMatrixElement { size_t i_elem; size_t num_nodes; @@ -77,71 +77,4 @@ struct IntegrateStiffnessMatrixElement { } } }; - -struct IntegrateStiffnessMatrix { - Kokkos::View::const_type num_nodes_per_element; - Kokkos::View::const_type num_qps_per_element; - Kokkos::View::const_type qp_weight_; - Kokkos::View::const_type qp_jacobian_; - Kokkos::View::const_type shape_interp_; - Kokkos::View::const_type shape_deriv_; - Kokkos::View::const_type qp_Kuu_; - Kokkos::View::const_type qp_Puu_; - Kokkos::View::const_type qp_Cuu_; - Kokkos::View::const_type qp_Ouu_; - Kokkos::View::const_type qp_Quu_; - Kokkos::View gbl_M_; - - KOKKOS_FUNCTION - void operator()(Kokkos::TeamPolicy<>::member_type member) const { - using simd_type = Kokkos::Experimental::native_simd; - const auto i_elem = static_cast(member.league_rank()); - const auto num_nodes = num_nodes_per_element(i_elem); - const auto num_qps = num_qps_per_element(i_elem); - constexpr auto width = simd_type::size(); - const auto extra_component = num_nodes % width == 0U ? 0U : 1U; - const auto simd_nodes = num_nodes / width + extra_component; - - const auto shape_interp = - Kokkos::View(member.team_scratch(1), num_nodes, num_qps); - const auto shape_deriv = - Kokkos::View(member.team_scratch(1), num_nodes, num_qps); - - const auto qp_weight = Kokkos::View(member.team_scratch(1), num_qps); - const auto qp_jacobian = Kokkos::View(member.team_scratch(1), num_qps); - - const auto qp_Kuu = Kokkos::View(member.team_scratch(1), num_qps); - const auto qp_Puu = Kokkos::View(member.team_scratch(1), num_qps); - const auto qp_Cuu = Kokkos::View(member.team_scratch(1), num_qps); - const auto qp_Ouu = Kokkos::View(member.team_scratch(1), num_qps); - const auto qp_Quu = Kokkos::View(member.team_scratch(1), num_qps); - - Kokkos::parallel_for(Kokkos::TeamThreadRange(member, num_qps), [&](size_t k) { - for (auto i = 0U; i < num_nodes; ++i) { - shape_interp(i, k) = shape_interp_(i_elem, i, k); - shape_deriv(i, k) = shape_deriv_(i_elem, i, k); - } - qp_weight(k) = qp_weight_(i_elem, k); - qp_jacobian(k) = qp_jacobian_(i_elem, k); - for (auto m = 0U; m < 6U; ++m) { - for (auto n = 0U; n < 6U; ++n) { - qp_Kuu(k, m, n) = qp_Kuu_(i_elem, k, m, n); - qp_Puu(k, m, n) = qp_Puu_(i_elem, k, m, n); - qp_Cuu(k, m, n) = qp_Cuu_(i_elem, k, m, n); - qp_Ouu(k, m, n) = qp_Ouu_(i_elem, k, m, n); - qp_Quu(k, m, n) = qp_Quu_(i_elem, k, m, n); - } - } - }); - member.team_barrier(); - - const auto node_range = Kokkos::TeamThreadRange(member, num_nodes * simd_nodes); - const auto element_integrator = IntegrateStiffnessMatrixElement{ - i_elem, num_nodes, num_qps, qp_weight, qp_jacobian, shape_interp, shape_deriv, - qp_Kuu, qp_Puu, qp_Cuu, qp_Ouu, qp_Quu, gbl_M_ - }; - Kokkos::parallel_for(node_range, element_integrator); - } -}; - -} // namespace openturbine +} // namespace openturbine::beams diff --git a/src/system/beams/interpolate_to_quadrature_point_for_inertia.hpp b/src/system/beams/interpolate_to_quadrature_point_for_inertia.hpp new file mode 100644 index 000000000..f89380180 --- /dev/null +++ b/src/system/beams/interpolate_to_quadrature_point_for_inertia.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include + +namespace openturbine::beams { + +KOKKOS_FUNCTION +inline void InterpolateToQuadraturePointForInertia( + const Kokkos::View::const_type& shape_interp, + const Kokkos::View::const_type& node_u, + const Kokkos::View::const_type& node_u_dot, + const Kokkos::View::const_type& node_u_ddot, const Kokkos::View& r, + const Kokkos::View& u_ddot, const Kokkos::View& omega, + const Kokkos::View& omega_dot +) { + for (auto i_node = 0U; i_node < node_u.extent(0); ++i_node) { + const auto phi = shape_interp(i_node); + for (auto k = 0U; k < 3U; ++k) { + u_ddot(k) += node_u_ddot(i_node, k) * phi; + omega(k) += node_u_dot(i_node, k + 3U) * phi; + omega_dot(k) += node_u_ddot(i_node, k + 3U) * phi; + } + for (auto k = 0U; k < 4U; ++k) { + r(k) += node_u(i_node, k + 3) * phi; + } + } + const auto r_length = KokkosBlas::serial_nrm2(r); + for (auto k = 0U; k < 4U; ++k) { + r(k) /= r_length; + } +} + +} // namespace openturbine::beams diff --git a/src/system/beams/interpolate_to_quadrature_point_for_stiffness.hpp b/src/system/beams/interpolate_to_quadrature_point_for_stiffness.hpp new file mode 100644 index 000000000..4ea76469f --- /dev/null +++ b/src/system/beams/interpolate_to_quadrature_point_for_stiffness.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include + +namespace openturbine::beams { + +KOKKOS_FUNCTION +inline void InterpolateToQuadraturePointForStiffness( + double jacobian, const Kokkos::View::const_type& shape_interp, + const Kokkos::View::const_type& shape_deriv, + const Kokkos::View::const_type& node_u, const Kokkos::View& u, + const Kokkos::View& r, const Kokkos::View& u_prime, + const Kokkos::View& r_prime +) { + for (auto i_node = 0U; i_node < node_u.extent(0); ++i_node) { + const auto phi = shape_interp(i_node); + const auto dphiJ = shape_deriv(i_node) / jacobian; + for (auto k = 0U; k < 3U; ++k) { + u(k) += node_u(i_node, k) * phi; + u_prime(k) += node_u(i_node, k) * dphiJ; + } + for (auto k = 0U; k < 4U; ++k) { + r(k) += node_u(i_node, k + 3) * phi; + r_prime(k) += node_u(i_node, k + 3) * dphiJ; + } + } + const auto r_length = KokkosBlas::serial_nrm2(r); + for (auto k = 0U; k < 4U; ++k) { + r(k) /= r_length; + } +} + +} // namespace openturbine::beams diff --git a/src/system/beams/rotate_section_matrix.hpp b/src/system/beams/rotate_section_matrix.hpp index a2aa6885b..367d32ab5 100644 --- a/src/system/beams/rotate_section_matrix.hpp +++ b/src/system/beams/rotate_section_matrix.hpp @@ -4,43 +4,40 @@ #include #include -namespace openturbine { +#include "math/quaternion_operations.hpp" -struct RotateSectionMatrix { +namespace openturbine::beams { + +KOKKOS_FUNCTION +inline void RotateSectionMatrix( + const Kokkos::View::const_type& xr, + const Kokkos::View::const_type& Cstar, const Kokkos::View& Cuu +) { using NoTranspose = KokkosBatched::Trans::NoTranspose; using Transpose = KokkosBatched::Trans::Transpose; using Default = KokkosBatched::Algo::Gemm::Default; using GemmNN = KokkosBatched::SerialGemm; using GemmNT = KokkosBatched::SerialGemm; - size_t i_elem; - Kokkos::View::const_type qp_RR0_; - Kokkos::View::const_type qp_Cstar_; - Kokkos::View qp_Cuu_; - - KOKKOS_FUNCTION - void operator()(const int i_qp) const { - const auto RR0 = - Kokkos::subview(qp_RR0_, i_elem, i_qp, Kokkos::make_pair(0, 3), Kokkos::make_pair(0, 3)); - const auto Cstar_top = - Kokkos::subview(qp_Cstar_, i_elem, i_qp, Kokkos::make_pair(0, 3), Kokkos::ALL); - const auto Cstar_bottom = - Kokkos::subview(qp_Cstar_, i_elem, i_qp, Kokkos::make_pair(3, 6), Kokkos::ALL); - auto ctmp_data = Kokkos::Array{}; - const auto Ctmp = Kokkos::View(ctmp_data.data()); - const auto Ctmp_top = Kokkos::subview(Ctmp, Kokkos::make_pair(0, 3), Kokkos::ALL); - const auto Ctmp_bottom = Kokkos::subview(Ctmp, Kokkos::make_pair(3, 6), Kokkos::ALL); - const auto Ctmp_left = Kokkos::subview(Ctmp, Kokkos::ALL, Kokkos::make_pair(0, 3)); - const auto Ctmp_right = Kokkos::subview(Ctmp, Kokkos::ALL, Kokkos::make_pair(3, 6)); - GemmNN::invoke(1., RR0, Cstar_top, 0., Ctmp_top); - GemmNN::invoke(1., RR0, Cstar_bottom, 0., Ctmp_bottom); - - const auto Cuu_left = - Kokkos::subview(qp_Cuu_, i_elem, i_qp, Kokkos::ALL, Kokkos::make_pair(0, 3)); - const auto Cuu_right = - Kokkos::subview(qp_Cuu_, i_elem, i_qp, Kokkos::ALL, Kokkos::make_pair(3, 6)); - GemmNT::invoke(1., Ctmp_left, RR0, 0., Cuu_left); - GemmNT::invoke(1., Ctmp_right, RR0, 0., Cuu_right); - } -}; - -} // namespace openturbine + + auto RR0_data = Kokkos::Array{}; + auto RR0 = Kokkos::View(RR0_data.data()); + QuaternionToRotationMatrix(xr, RR0); + + const auto Cstar_top = Kokkos::subview(Cstar, Kokkos::make_pair(0, 3), Kokkos::ALL); + const auto Cstar_bottom = Kokkos::subview(Cstar, Kokkos::make_pair(3, 6), Kokkos::ALL); + const auto Cuu_left = Kokkos::subview(Cuu, Kokkos::ALL, Kokkos::make_pair(0, 3)); + const auto Cuu_right = Kokkos::subview(Cuu, Kokkos::ALL, Kokkos::make_pair(3, 6)); + + auto ctmp_data = Kokkos::Array{}; + const auto Ctmp = Kokkos::View(ctmp_data.data()); + const auto Ctmp_top = Kokkos::subview(Ctmp, Kokkos::make_pair(0, 3), Kokkos::ALL); + const auto Ctmp_bottom = Kokkos::subview(Ctmp, Kokkos::make_pair(3, 6), Kokkos::ALL); + const auto Ctmp_left = Kokkos::subview(Ctmp, Kokkos::ALL, Kokkos::make_pair(0, 3)); + const auto Ctmp_right = Kokkos::subview(Ctmp, Kokkos::ALL, Kokkos::make_pair(3, 6)); + + GemmNN::invoke(1., RR0, Cstar_top, 0., Ctmp_top); + GemmNN::invoke(1., RR0, Cstar_bottom, 0., Ctmp_bottom); + GemmNT::invoke(1., Ctmp_left, RR0, 0., Cuu_left); + GemmNT::invoke(1., Ctmp_right, RR0, 0., Cuu_right); +} +} // namespace openturbine::beams diff --git a/src/system/beams/update_node_state.hpp b/src/system/beams/update_node_state.hpp index 2517b54b2..43e2b6ec8 100644 --- a/src/system/beams/update_node_state.hpp +++ b/src/system/beams/update_node_state.hpp @@ -2,17 +2,14 @@ #include -namespace openturbine { +namespace openturbine::beams { -/** - * @brief Functor to update nodal states for a single element from global state vectors - */ struct UpdateNodeStateElement { size_t i_elem; Kokkos::View::const_type node_state_indices; - Kokkos::View node_u; - Kokkos::View node_u_dot; - Kokkos::View node_u_ddot; + Kokkos::View node_u; + Kokkos::View node_u_dot; + Kokkos::View node_u_ddot; Kokkos::View::const_type Q; Kokkos::View::const_type V; @@ -22,44 +19,13 @@ struct UpdateNodeStateElement { void operator()(const size_t i_node) const { const auto j = node_state_indices(i_elem, i_node); for (auto k = 0U; k < 7U; ++k) { - node_u(i_elem, i_node, k) = Q(j, k); + node_u(i_node, k) = Q(j, k); } for (auto k = 0U; k < 6U; ++k) { - node_u_dot(i_elem, i_node, k) = V(j, k); - node_u_ddot(i_elem, i_node, k) = A(j, k); + node_u_dot(i_node, k) = V(j, k); + node_u_ddot(i_node, k) = A(j, k); } } }; -/** - * @brief Functor to update nodal states for all elements in the mesh - * - * Iterates over all elements, updating the nodal states for each element using the provided - * global state vectors. - */ -struct UpdateNodeState { - Kokkos::View::const_type num_nodes_per_element; - Kokkos::View::const_type node_state_indices; - Kokkos::View node_u; - Kokkos::View node_u_dot; - Kokkos::View node_u_ddot; - - Kokkos::View::const_type Q; - Kokkos::View::const_type V; - Kokkos::View::const_type A; - - KOKKOS_FUNCTION - void operator()(const Kokkos::TeamPolicy<>::member_type& member) const { - const auto i_elem = static_cast(member.league_rank()); - const auto num_nodes = num_nodes_per_element(i_elem); - - Kokkos::parallel_for( - Kokkos::TeamThreadRange(member, num_nodes), - UpdateNodeStateElement{ - i_elem, node_state_indices, node_u, node_u_dot, node_u_ddot, Q, V, A - } - ); - } -}; - -} // namespace openturbine +} // namespace openturbine::beams diff --git a/tests/regression_tests/interfaces/test_cfd_interface.cpp b/tests/regression_tests/interfaces/test_cfd_interface.cpp index d9329dfbc..84e64edbd 100644 --- a/tests/regression_tests/interfaces/test_cfd_interface.cpp +++ b/tests/regression_tests/interfaces/test_cfd_interface.cpp @@ -139,7 +139,7 @@ void OutputLines(const FloatingPlatform&, size_t, const std::string&) { TEST(CFDInterfaceTest, FloatingPlatform) { // Solution parameters constexpr auto time_step = 0.01; - constexpr auto t_end = 100.; + constexpr auto t_end = 1.; constexpr auto rho_inf = 0.0; constexpr auto max_iter = 5; const auto n_steps{static_cast(ceil(t_end / time_step)) + 1}; diff --git a/tests/regression_tests/regression/test_beams.cpp b/tests/regression_tests/regression/test_beams.cpp index 18fa1632e..2ac06f902 100644 --- a/tests/regression_tests/regression/test_beams.cpp +++ b/tests/regression_tests/regression/test_beams.cpp @@ -125,13 +125,6 @@ inline auto SetUpBeams() { auto beams = model.CreateBeams(); - // Create initial state - auto parameters = StepParameters(false, 0, 0., 0.); - auto state = model.CreateState(); - - // Set the beam's initial state - UpdateSystemVariablesBeams(parameters, beams, state); - return beams; } @@ -154,54 +147,6 @@ TEST(BeamsTest, NodeInitialPositionX0) { ); } -TEST(BeamsTest, NodeInitialDisplacement) { - const auto beams = SetUpBeams(); - expect_kokkos_view_2D_equal( - Kokkos::subview(beams.node_u, 0, Kokkos::ALL, Kokkos::ALL), - { - {0., 0., 0., 1., 0., 0., 0.}, - {0.002981602178886856, -0.00246675949494302, 0.003084570715675624, 0.9999627302042724, - 0.008633550973807708, 0., 0.}, - {0.025, -0.0125, 0.027500000000000004, 0.9996875162757026, 0.02499739591471221, 0., 0.}, - {0.06844696924968459, -0.011818954790771264, 0.07977257214146725, 0.9991445348823055, - 0.04135454527402512, 0., 0.}, - {0.1, 0., 0.12, 0.9987502603949663, 0.04997916927067825, 0., 0.}, - } - ); -} - -TEST(BeamsTest, NodeInitialVelocity) { - const auto beams = SetUpBeams(); - expect_kokkos_view_2D_equal( - Kokkos::subview(beams.node_u_dot, 0, Kokkos::ALL, Kokkos::ALL), - { - {0., 0., 0., 0., 0., 0}, - {0.01726731646460114, -0.014285714285714285, 0.003084570715675624, 0.01726731646460114, - -0.014285714285714285, 0.003084570715675624}, - {0.05, -0.025, 0.027500000000000004, 0.05, -0.025, 0.027500000000000004}, - {0.08273268353539887, -0.01428571428571428, 0.07977257214146725, 0.08273268353539887, - -0.01428571428571428, 0.07977257214146725}, - {0.1, 0., 0.12, 0.1, 0., 0.12}, - } - ); -} - -TEST(BeamsTest, NodeInitialAcceleration) { - const auto beams = SetUpBeams(); - expect_kokkos_view_2D_equal( - Kokkos::subview(beams.node_u_ddot, 0, Kokkos::ALL, Kokkos::ALL), - { - {0., 0., 0., 0., 0., 0}, - {0.01726731646460114, -0.011304112106827427, 0.00606617289456248, 0.01726731646460114, - -0.014285714285714285, -0.014285714285714285}, - {0.05, 0., 0.052500000000000005, 0.05, -0.025, -0.025}, - {0.08273268353539887, 0.05416125496397031, 0.14821954139115184, 0.08273268353539887, - -0.01428571428571428, -0.01428571428571428}, - {0.1, 0.1, 0.22000000000000003, 0.1, 0., 0.}, - } - ); -} - TEST(BeamsTest, QuadraturePointMassMatrixInMaterialFrame) { const auto beams = SetUpBeams(); auto Mstar = View_NxN("Mstar", beams.qp_Mstar.extent(2), beams.qp_Mstar.extent(3)); @@ -237,155 +182,4 @@ TEST(BeamsTest, QuadraturePointStiffnessMatrixInMaterialFrame) { ); } -TEST(BeamsTest, QuadraturePointRR0) { - const auto beams = SetUpBeams(); - auto RR0 = View_NxN("RR0", beams.qp_RR0.extent(2), beams.qp_RR0.extent(3)); - Kokkos::deep_copy(RR0, Kokkos::subview(beams.qp_RR0, 0, 0, Kokkos::ALL, Kokkos::ALL)); - expect_kokkos_view_2D_equal( - RR0, - { - {0.9246873610951006, 0.34700636042507577, -0.156652066872805, 0.0, 0.0, 0.0}, - {-0.3426571011111718, 0.937858102036658, 0.05484789423748749, 0.0, 0.0, 0.0}, - {0.16594997827377847, 0.002960788533623304, 0.9861297269843315, 0.0, 0.0, 0.0}, - {0.0, 0.0, 0.0, 0.9246873610951006, 0.34700636042507577, -0.156652066872805}, - {0.0, 0.0, 0.0, -0.3426571011111718, 0.937858102036658, 0.05484789423748749}, - {0.0, 0.0, 0.0, 0.16594997827377847, 0.002960788533623304, 0.9861297269843315}, - } - ); -} - -TEST(BeamsTest, QuadraturePointMassMatrixInGlobalFrame) { - const auto beams = SetUpBeams(); - auto Muu = View_NxN("Muu", beams.qp_Muu.extent(2), beams.qp_Muu.extent(3)); - Kokkos::deep_copy(Muu, Kokkos::subview(beams.qp_Muu, 0, 0, Kokkos::ALL, Kokkos::ALL)); - expect_kokkos_view_2D_equal( - Muu, - { - {2.000000000000001, 5.204170427930421e-17, -5.551115123125783e-17, - -4.163336342344337e-17, 0.626052147258804, -0.3395205571349214}, - {5.204170427930421e-17, 2.0000000000000018, 1.3877787807814457e-17, -0.6260521472588039, - -3.469446951953614e-18, 0.22974877626536766}, - {-5.551115123125783e-17, 1.3877787807814457e-17, 2.0000000000000013, 0.33952055713492146, - -0.22974877626536772, -1.3877787807814457e-17}, - {4.163336342344337e-17, -0.626052147258804, 0.3395205571349214, 1.3196125048858467, - 1.9501108129670985, 3.5958678677753957}, - {0.6260521472588039, 3.469446951953614e-18, -0.22974877626536766, 1.9501108129670985, - 2.881855217930184, 5.313939345820573}, - {-0.33952055713492146, 0.22974877626536772, 1.3877787807814457e-17, 3.5958678677753957, - 5.3139393458205735, 9.79853227718398}, - } - ); -} - -TEST(BeamsTest, QuadraturePointStiffnessMatrixInGlobalFrame) { - const auto beams = SetUpBeams(); - auto Cuu = View_NxN("Cuu", beams.qp_Cuu.extent(2), beams.qp_Cuu.extent(3)); - Kokkos::deep_copy(Cuu, Kokkos::subview(beams.qp_Cuu, 0, 0, Kokkos::ALL, Kokkos::ALL)); - expect_kokkos_view_2D_equal( - Cuu, - { - {1.3196125048858467, 1.9501108129670985, 3.5958678677753957, 5.1623043394880055, - 4.190329885612304, 7.576404967559343}, - {1.9501108129670985, 2.881855217930184, 5.313939345820573, 7.628804270184899, - 6.192429663690275, 11.196339225304031}, - {3.5958678677753957, 5.3139393458205735, 9.79853227718398, 14.066981200400345, - 11.418406945420463, 20.64526599682174}, - {5.162304339488006, 7.628804270184899, 14.066981200400342, 20.194857198478893, - 16.392507703808057, 29.638782670624547}, - {4.190329885612305, 6.192429663690274, 11.418406945420463, 16.392507703808064, - 13.3060762043738, 24.058301996624227}, - {7.576404967559343, 11.196339225304033, 20.64526599682174, 29.63878267062455, - 24.058301996624223, 43.499066597147355}, - } - ); -} - -TEST(BeamsTest, QuadraturePointMatrixOuu) { - const auto beams = SetUpBeams(); - auto Ouu = View_NxN("Ouu", beams.qp_Ouu.extent(2), beams.qp_Ouu.extent(3)); - Kokkos::deep_copy(Ouu, Kokkos::subview(beams.qp_Ouu, 0, 0, Kokkos::ALL, Kokkos::ALL)); - expect_kokkos_view_2D_equal( - Ouu, - { - {0., 0., 0., 1.558035187754702, 3.3878498808227704, -2.4090666622503774}, - {0., 0., 0., 2.023578567654382, 4.594419401889352, -3.2342585893237827}, - {0., 0., 0., 4.396793221398987, 8.369447695979858, -6.152454589644055}, - {0., 0., 0., 6.095010301161761, 12.749853070301084, -9.15756802064953}, - {0., 0., 0., 4.359848751597227, 9.872327664027363, -6.769213486026294}, - {0., 0., 0., 9.270255102567306, 17.449495035002304, -12.963070176574703}, - } - ); -} - -TEST(BeamsTest, QuadraturePointMatrixPuu) { - const auto beams = SetUpBeams(); - auto Puu = View_NxN("Puu", beams.qp_Puu.extent(2), beams.qp_Puu.extent(3)); - Kokkos::deep_copy(Puu, Kokkos::subview(beams.qp_Puu, 0, 0, Kokkos::ALL, Kokkos::ALL)); - expect_kokkos_view_2D_equal( - Puu, - { - {0., 0., 0., 0., 0., 0.}, - {0., 0., 0., 0., 0., 0.}, - {0., 0., 0., 0., 0., 0.}, - {1.558035187754702, 2.0235785676543823, 4.396793221398987, 6.095010301161762, - 4.947423115431053, 8.945281658389643}, - {3.3878498808227704, 4.594419401889353, 8.369447695979858, 12.162278706467262, - 9.872327664027365, 17.849848197376673}, - {-2.4090666622503774, -3.2342585893237827, -6.152454589644055, -8.832594576471866, - -7.169566648400663, -12.963070176574703}, - } - ); -} - -TEST(BeamsTest, QuadraturePointMatrixQuu) { - const auto beams = SetUpBeams(); - auto Quu = View_NxN("Quu", beams.qp_Quu.extent(2), beams.qp_Quu.extent(3)); - Kokkos::deep_copy(Quu, Kokkos::subview(beams.qp_Quu, 0, 0, Kokkos::ALL, Kokkos::ALL)); - expect_kokkos_view_2D_equal( - Quu, - { - {0., 0., 0., 0., 0., 0.}, - {0., 0., 0., 0., 0., 0.}, - {0., 0., 0., 0., 0., 0.}, - {0., 0., 0., 1.8447536136896558, 3.635630275656869, -2.64866290970237}, - {0., 0., 0., 3.8107321412411204, 7.1833246136382, -5.294123557503821}, - {0., 0., 0., -2.4075516854952794, -5.414954154362819, 3.820161491912928}, - } - ); -} - -TEST(BeamsTest, QuadraturePointMatrixGuu) { - const auto beams = SetUpBeams(); - auto Guu = View_NxN("Guu", beams.qp_Guu.extent(2), beams.qp_Guu.extent(3)); - Kokkos::deep_copy(Guu, Kokkos::subview(beams.qp_Guu, 0, 0, Kokkos::ALL, Kokkos::ALL)); - expect_kokkos_view_2D_equal( - Guu, - { - {0., 0., 0., -0.0008012182534494841, 0.002003432464632351, 0.0015631511018243545}, - {0., 0., 0., -0.002297634478952118, 0.0006253629923483924, -0.0015967098417843995}, - {0., 0., 0., -0.0031711581076346268, 0.0031271320551441812, -0.0002573417597137699}, - {0., 0., 0., -0.009044140792420115, -0.016755394335528064, -0.022806270184157214}, - {0., 0., 0., -0.005674132164451402, -0.013394960837037522, -0.025943451454082944}, - {0., 0., 0., 0.006396216051163168, 0.013413253109011812, 0.022439101629457635}, - } - ); -} - -TEST(BeamsTest, QuadraturePointMatrixKuu) { - const auto beams = SetUpBeams(); - auto Kuu = View_NxN("Kuu", beams.qp_Kuu.extent(2), beams.qp_Kuu.extent(3)); - Kokkos::deep_copy(Kuu, Kokkos::subview(beams.qp_Kuu, 0, 0, Kokkos::ALL, Kokkos::ALL)); - expect_kokkos_view_2D_equal( - Kuu, - { - {0., 0., 0., -0.0023904728226588536, 0.0005658527664274542, 0.0005703830914904407}, - {0., 0., 0., -0.0008599439459226316, -0.000971811812092634, 0.0008426153626567674}, - {0., 0., 0., -0.0015972403418206974, 0.0015555222717217175, -0.000257435063678694}, - {0., 0., 0., 0.004762288305421506, -0.016524233223710137, 0.007213755243428677}, - {0., 0., 0., 0.035164381478288514, 0.017626317482204206, -0.022463736936512112}, - {0., 0., 0., -0.0025828596476940593, 0.04278211835291491, -0.022253736971069835}, - } - ); -} - } // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/CMakeLists.txt b/tests/unit_tests/system/beams/CMakeLists.txt index 09937a1d3..073d80798 100644 --- a/tests/unit_tests/system/beams/CMakeLists.txt +++ b/tests/unit_tests/system/beams/CMakeLists.txt @@ -5,19 +5,12 @@ target_sources( test_integrate_stiffness_matrix.cpp test_integrate_inertia_matrix.cpp test_integrate_residual_vector.cpp - test_update_node_state.cpp - test_calculate_RR0.cpp test_rotate_section_matrix.cpp test_calculate_strain.cpp - test_calculate_mass_matrix_components.cpp test_calculate_temporary_variables.cpp test_calculate_force_FC.cpp test_calculate_force_FD.cpp - test_calculate_inertial_forces.cpp - test_calculate_gravity_force.cpp test_calculate_Ouu.cpp test_calculate_Puu.cpp test_calculate_Quu.cpp - test_calculate_gyroscopic_matrix.cpp - test_calculate_inertia_stiffness_matrix.cpp ) diff --git a/tests/unit_tests/system/beams/test_calculate_Ouu.cpp b/tests/unit_tests/system/beams/test_calculate_Ouu.cpp index 63c9cd367..93897a4f6 100644 --- a/tests/unit_tests/system/beams/test_calculate_Ouu.cpp +++ b/tests/unit_tests/system/beams/test_calculate_Ouu.cpp @@ -4,56 +4,69 @@ #include "system/beams/calculate_Ouu.hpp" #include "test_calculate.hpp" -namespace openturbine::tests { +namespace { -TEST(CalculateOuuTests, OneNode) { - const auto Cuu = Kokkos::View("Cuu"); +void TestCalculateOuu() { + const auto Cuu = Kokkos::View("Cuu"); constexpr auto Cuu_data = std::array{1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36.}; - const auto Cuu_host = Kokkos::View(Cuu_data.data()); + const auto Cuu_host = Kokkos::View::const_type(Cuu_data.data()); const auto Cuu_mirror = Kokkos::create_mirror(Cuu); Kokkos::deep_copy(Cuu_mirror, Cuu_host); Kokkos::deep_copy(Cuu, Cuu_mirror); - const auto x0pupSS = Kokkos::View("x0pupSS"); + const auto x0pupSS = Kokkos::View("x0pupSS"); constexpr auto x0pupSS_data = std::array{37., 38., 39., 40., 41., 42., 43., 44., 45.}; const auto x0pupSS_host = - Kokkos::View(x0pupSS_data.data()); + Kokkos::View::const_type(x0pupSS_data.data()); const auto x0pupSS_mirror = Kokkos::create_mirror(x0pupSS); Kokkos::deep_copy(x0pupSS_mirror, x0pupSS_host); Kokkos::deep_copy(x0pupSS, x0pupSS_mirror); - const auto M_tilde = Kokkos::View("M_tilde"); + const auto M_tilde = Kokkos::View("M_tilde"); constexpr auto M_tilde_data = std::array{46., 47., 48., 49., 50., 51., 52., 53., 54.}; const auto M_tilde_host = - Kokkos::View(M_tilde_data.data()); + Kokkos::View::const_type(M_tilde_data.data()); const auto M_tilde_mirror = Kokkos::create_mirror(M_tilde); Kokkos::deep_copy(M_tilde_mirror, M_tilde_host); Kokkos::deep_copy(M_tilde, M_tilde_mirror); - const auto N_tilde = Kokkos::View("N_tilde"); + const auto N_tilde = Kokkos::View("N_tilde"); constexpr auto N_tilde_data = std::array{55., 56., 57., 58., 59., 60., 61., 62., 63.}; const auto N_tilde_host = - Kokkos::View(N_tilde_data.data()); + Kokkos::View::const_type(N_tilde_data.data()); const auto N_tilde_mirror = Kokkos::create_mirror(N_tilde); Kokkos::deep_copy(N_tilde_mirror, N_tilde_host); Kokkos::deep_copy(N_tilde, N_tilde_mirror); - const auto Ouu = Kokkos::View("Ouu"); + const auto Ouu = Kokkos::View("Ouu"); - Kokkos::parallel_for("CalculateOuu", 1, CalculateOuu{0, Cuu, x0pupSS, M_tilde, N_tilde, Ouu}); + Kokkos::parallel_for( + "CalculateOuu", 1, + KOKKOS_LAMBDA(size_t) { + openturbine::beams::CalculateOuu(Cuu, x0pupSS, M_tilde, N_tilde, Ouu); + } + ); constexpr auto Ouu_exact_data = std::array{0., 0., 0., 191., 196., 201., 0., 0., 0., 908., 931., 954., 0., 0., 0., 1625., 1666., 1707., 0., 0., 0., 2360., 2419., 2478., 0., 0., 0., 3077., 3154., 3231., 0., 0., 0., 3794., 3889., 3984.}; const auto Ouu_exact = - Kokkos::View(Ouu_exact_data.data()); + Kokkos::View::const_type(Ouu_exact_data.data()); const auto Ouu_mirror = Kokkos::create_mirror(Ouu); Kokkos::deep_copy(Ouu_mirror, Ouu); - CompareWithExpected(Ouu_mirror, Ouu_exact); + openturbine::tests::CompareWithExpected(Ouu_mirror, Ouu_exact); +} + +} // namespace + +namespace openturbine::tests { + +TEST(CalculateOuuTests, OneNode) { + TestCalculateOuu(); } } // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_calculate_Puu.cpp b/tests/unit_tests/system/beams/test_calculate_Puu.cpp index 0b14a0a7f..e7cd8f837 100644 --- a/tests/unit_tests/system/beams/test_calculate_Puu.cpp +++ b/tests/unit_tests/system/beams/test_calculate_Puu.cpp @@ -4,56 +4,59 @@ #include "system/beams/calculate_Puu.hpp" #include "test_calculate.hpp" -namespace openturbine::tests { +namespace { -TEST(CalculatePuuTests, OneNode) { - const auto Cuu = Kokkos::View("Cuu"); +void TestCalculatePuu() { + const auto Cuu = Kokkos::View("Cuu"); constexpr auto Cuu_data = std::array{1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36.}; - const auto Cuu_host = Kokkos::View(Cuu_data.data()); + const auto Cuu_host = Kokkos::View::const_type(Cuu_data.data()); const auto Cuu_mirror = Kokkos::create_mirror(Cuu); Kokkos::deep_copy(Cuu_mirror, Cuu_host); Kokkos::deep_copy(Cuu, Cuu_mirror); - const auto x0pupSS = Kokkos::View("x0pupSS"); + const auto x0pupSS = Kokkos::View("x0pupSS"); constexpr auto x0pupSS_data = std::array{37., 38., 39., 40., 41., 42., 43., 44., 45.}; const auto x0pupSS_host = - Kokkos::View(x0pupSS_data.data()); + Kokkos::View::const_type(x0pupSS_data.data()); const auto x0pupSS_mirror = Kokkos::create_mirror(x0pupSS); Kokkos::deep_copy(x0pupSS_mirror, x0pupSS_host); Kokkos::deep_copy(x0pupSS, x0pupSS_mirror); - const auto M_tilde = Kokkos::View("M_tilde"); - constexpr auto M_tilde_data = std::array{46., 47., 48., 49., 50., 51., 52., 53., 54.}; - const auto M_tilde_host = - Kokkos::View(M_tilde_data.data()); - const auto M_tilde_mirror = Kokkos::create_mirror(M_tilde); - Kokkos::deep_copy(M_tilde_mirror, M_tilde_host); - Kokkos::deep_copy(M_tilde, M_tilde_mirror); - - const auto N_tilde = Kokkos::View("N_tilde"); + const auto N_tilde = Kokkos::View("N_tilde"); constexpr auto N_tilde_data = std::array{55., 56., 57., 58., 59., 60., 61., 62., 63.}; const auto N_tilde_host = - Kokkos::View(N_tilde_data.data()); + Kokkos::View::const_type(N_tilde_data.data()); const auto N_tilde_mirror = Kokkos::create_mirror(N_tilde); Kokkos::deep_copy(N_tilde_mirror, N_tilde_host); Kokkos::deep_copy(N_tilde, N_tilde_mirror); - const auto Puu = Kokkos::View("Puu"); + const auto Puu = Kokkos::View("Puu"); - Kokkos::parallel_for("CalculatePuu", 1, CalculatePuu{0, Cuu, x0pupSS, N_tilde, Puu}); + Kokkos::parallel_for( + "CalculatePuu", 1, + KOKKOS_LAMBDA(size_t) { openturbine::beams::CalculatePuu(Cuu, x0pupSS, N_tilde, Puu); } + ); constexpr auto Puu_exact_data = std::array{0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 931., 1052., 1173., 1236., 1356., 1476., 955., 1079., 1203., 1266., 1389., 1512., 979., 1106., 1233., 1296., 1422., 1548.}; const auto Puu_exact = - Kokkos::View(Puu_exact_data.data()); + Kokkos::View::const_type(Puu_exact_data.data()); const auto Puu_mirror = Kokkos::create_mirror(Puu); Kokkos::deep_copy(Puu_mirror, Puu); - CompareWithExpected(Puu_mirror, Puu_exact); + openturbine::tests::CompareWithExpected(Puu_mirror, Puu_exact); +} + +} // namespace + +namespace openturbine::tests { + +TEST(CalculatePuuTests, OneNode) { + TestCalculatePuu(); } } // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_calculate_Quu.cpp b/tests/unit_tests/system/beams/test_calculate_Quu.cpp index fb6d5438d..48b1ab248 100644 --- a/tests/unit_tests/system/beams/test_calculate_Quu.cpp +++ b/tests/unit_tests/system/beams/test_calculate_Quu.cpp @@ -4,56 +4,67 @@ #include "system/beams/calculate_Quu.hpp" #include "test_calculate.hpp" -namespace openturbine::tests { +namespace { -TEST(CalculateQuuTests, OneNode) { - const auto Cuu = Kokkos::View("Cuu"); +void TestCalculateQuu() { + const auto Cuu = Kokkos::View("Cuu"); constexpr auto Cuu_data = std::array{1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36.}; - const auto Cuu_host = Kokkos::View(Cuu_data.data()); + const auto Cuu_host = Kokkos::View::const_type(Cuu_data.data()); const auto Cuu_mirror = Kokkos::create_mirror(Cuu); Kokkos::deep_copy(Cuu_mirror, Cuu_host); Kokkos::deep_copy(Cuu, Cuu_mirror); - const auto x0pupSS = Kokkos::View("x0pupSS"); + const auto x0pupSS = Kokkos::View("x0pupSS"); constexpr auto x0pupSS_data = std::array{37., 38., 39., 40., 41., 42., 43., 44., 45.}; const auto x0pupSS_host = - Kokkos::View(x0pupSS_data.data()); + Kokkos::View::const_type(x0pupSS_data.data()); const auto x0pupSS_mirror = Kokkos::create_mirror(x0pupSS); Kokkos::deep_copy(x0pupSS_mirror, x0pupSS_host); Kokkos::deep_copy(x0pupSS, x0pupSS_mirror); - const auto M_tilde = Kokkos::View("M_tilde"); + const auto M_tilde = Kokkos::View("M_tilde"); constexpr auto M_tilde_data = std::array{46., 47., 48., 49., 50., 51., 52., 53., 54.}; const auto M_tilde_host = - Kokkos::View(M_tilde_data.data()); + Kokkos::View::const_type(M_tilde_data.data()); const auto M_tilde_mirror = Kokkos::create_mirror(M_tilde); Kokkos::deep_copy(M_tilde_mirror, M_tilde_host); Kokkos::deep_copy(M_tilde, M_tilde_mirror); - const auto N_tilde = Kokkos::View("N_tilde"); + const auto N_tilde = Kokkos::View("N_tilde"); constexpr auto N_tilde_data = std::array{55., 56., 57., 58., 59., 60., 61., 62., 63.}; const auto N_tilde_host = - Kokkos::View(N_tilde_data.data()); + Kokkos::View::const_type(N_tilde_data.data()); const auto N_tilde_mirror = Kokkos::create_mirror(N_tilde); Kokkos::deep_copy(N_tilde_mirror, N_tilde_host); Kokkos::deep_copy(N_tilde, N_tilde_mirror); - const auto Quu = Kokkos::View("Quu"); + const auto Quu = Kokkos::View("Quu"); - Kokkos::parallel_for("CalculateQuu", 1, CalculateQuu{0, Cuu, x0pupSS, N_tilde, Quu}); + Kokkos::parallel_for( + "CalculateQuu", 1, + KOKKOS_LAMBDA(size_t) { openturbine::beams::CalculateQuu(Cuu, x0pupSS, N_tilde, Quu); } + ); constexpr auto Quu_exact_data = std::array{0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 113262., 116130., 118998., 0., 0., 0., 115986., 118923., 121860., 0., 0., 0., 118710., 121716., 124722.}; const auto Quu_exact = - Kokkos::View(Quu_exact_data.data()); + Kokkos::View::const_type(Quu_exact_data.data()); const auto Quu_mirror = Kokkos::create_mirror(Quu); Kokkos::deep_copy(Quu_mirror, Quu); - CompareWithExpected(Quu_mirror, Quu_exact); + openturbine::tests::CompareWithExpected(Quu_mirror, Quu_exact); +} + +} // namespace + +namespace openturbine::tests { + +TEST(CalculateQuuTests, OneNode) { + TestCalculateQuu(); } } // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_calculate_RR0.cpp b/tests/unit_tests/system/beams/test_calculate_RR0.cpp deleted file mode 100644 index e0b2bec16..000000000 --- a/tests/unit_tests/system/beams/test_calculate_RR0.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include - -#include "system/beams/calculate_RR0.hpp" -#include "test_calculate.hpp" - -namespace openturbine::tests { - -TEST(CalculateRR0Tests, OneNode) { - const auto x = Kokkos::View("x"); - constexpr auto x_host_data = std::array{1., 2., 3., 4., 5., 6., 7.}; - const auto x_host = Kokkos::View(x_host_data.data()); - const auto x_mirror = Kokkos::create_mirror(x); - Kokkos::deep_copy(x_mirror, x_host); - Kokkos::deep_copy(x, x_mirror); - - const auto rr0 = Kokkos::View("rr0"); - - Kokkos::parallel_for("CalculateRR0", 1, CalculateRR0{0, x, rr0}); - - constexpr auto expected_rr0_data = std::array{-44., 4., 118., 0., 0., 0., // - 116., -22., 44., 0., 0., 0., // - 22., 124., 4., 0., 0., 0., // - 0., 0., 0., -44., 4., 118., // - 0., 0., 0., 116., -22., 44., // - 0., 0., 0., 22., 124., 4.}; - const auto expected_rr0 = - Kokkos::View(expected_rr0_data.data()); - - const auto rr0_mirror = Kokkos::create_mirror(rr0); - Kokkos::deep_copy(rr0_mirror, rr0); - CompareWithExpected(rr0_mirror, expected_rr0); -} - -TEST(CalculateRR0Tests, TwoNodes) { - const auto x = Kokkos::View("x"); - constexpr auto x_host_data = - std::array{1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.}; - const auto x_host = Kokkos::View(x_host_data.data()); - const auto x_mirror = Kokkos::create_mirror(x); - Kokkos::deep_copy(x_mirror, x_host); - Kokkos::deep_copy(x, x_mirror); - - const auto rr0 = Kokkos::View("rr0"); - - Kokkos::parallel_for("CalculateRR0", 2, CalculateRR0{0, x, rr0}); - - constexpr auto expected_rr0_data = std::array{-44., 4., 118., 0., 0., 0., // - 116., -22., 44., 0., 0., 0., // - 22., 124., 4., 0., 0., 0., // - 0., 0., 0., -44., 4., 118., // - 0., 0., 0., 116., -22., 44., // - 0., 0., 0., 22., 124., 4., - - -100., 4., 622., 0., 0., 0., // - 620., -50., 100., 0., 0., 0., // - 50., 628., 4., 0., 0., 0., // - 0., 0., 0., -100., 4., 622., // - 0., 0., 0., 620., -50., 100., // - 0., 0., 0., 50., 628., 4.}; - const auto expected_rr0 = - Kokkos::View(expected_rr0_data.data()); - - const auto rr0_mirror = Kokkos::create_mirror(rr0); - Kokkos::deep_copy(rr0_mirror, rr0); - for (int i = 0; i < 6; ++i) { - for (int j = 0; j < 6; ++j) { - EXPECT_EQ(rr0_mirror(0, 0, i, j), expected_rr0(0, 0, i, j)); - } - } - for (int i = 0; i < 6; ++i) { - for (int j = 0; j < 6; ++j) { - EXPECT_EQ(rr0_mirror(0, 1, i, j), expected_rr0(0, 1, i, j)); - } - } -} - -} // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_calculate_force_FC.cpp b/tests/unit_tests/system/beams/test_calculate_force_FC.cpp index 2e195b274..10d4bba26 100644 --- a/tests/unit_tests/system/beams/test_calculate_force_FC.cpp +++ b/tests/unit_tests/system/beams/test_calculate_force_FC.cpp @@ -4,60 +4,49 @@ #include "system/beams/calculate_force_FC.hpp" #include "test_calculate.hpp" -namespace openturbine::tests { +namespace { -TEST(CalculateForceFCTests, OneNode) { - const auto Cuu = Kokkos::View("Cuu"); +void TestCalculateForceFC() { + const auto Cuu = Kokkos::View("Cuu"); constexpr auto Cuu_data = std::array{ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36., }; - const auto Cuu_host = Kokkos::View(Cuu_data.data()); + const auto Cuu_host = Kokkos::View::const_type(Cuu_data.data()); const auto Cuu_mirror = Kokkos::create_mirror(Cuu); Kokkos::deep_copy(Cuu_mirror, Cuu_host); Kokkos::deep_copy(Cuu, Cuu_mirror); - const auto strain = Kokkos::View("strain"); + const auto strain = Kokkos::View("strain"); constexpr auto strain_data = std::array{37., 38., 39., 40., 41., 42.}; const auto strain_host = - Kokkos::View(strain_data.data()); + Kokkos::View::const_type(strain_data.data()); const auto strain_mirror = Kokkos::create_mirror(strain); Kokkos::deep_copy(strain_mirror, strain_host); Kokkos::deep_copy(strain, strain_mirror); - const auto FC = Kokkos::View("FC"); - const auto M_tilde = Kokkos::View("M_tilde"); - const auto N_tilde = Kokkos::View("N_tilde"); + const auto FC = Kokkos::View("FC"); Kokkos::parallel_for( - "CalculateForceFC", 1, CalculateForceFC{0, Cuu, strain, FC, M_tilde, N_tilde} + "CalculateForceFC", 1, + KOKKOS_LAMBDA(size_t) { openturbine::beams::CalculateForceFC(Cuu, strain, FC); } ); constexpr auto FC_exact_data = std::array{847., 2269., 3691., 5113., 6535., 7957.}; const auto FC_exact = - Kokkos::View(FC_exact_data.data()); + Kokkos::View::const_type(FC_exact_data.data()); const auto FC_mirror = Kokkos::create_mirror(FC); Kokkos::deep_copy(FC_mirror, FC); - CompareWithExpected(FC_mirror, FC_exact); - - constexpr auto M_tilde_exact_data = - std::array{0., -7957., 6535., 7957., 0., -5113., -6535., 5113., 0.}; - const auto M_tilde_exact = - Kokkos::View(M_tilde_exact_data.data()); + openturbine::tests::CompareWithExpected(FC_mirror, FC_exact); +} - const auto M_tilde_mirror = Kokkos::create_mirror(M_tilde); - Kokkos::deep_copy(M_tilde_mirror, M_tilde); - CompareWithExpected(M_tilde_mirror, M_tilde_exact); +} // namespace - constexpr auto N_tilde_exact_data = - std::array{0., -3691., 2269., 3691., 0., -847., -2269., 847., 0.}; - const auto N_tilde_exact = - Kokkos::View(N_tilde_exact_data.data()); +namespace openturbine::tests { - const auto N_tilde_mirror = Kokkos::create_mirror(N_tilde); - Kokkos::deep_copy(N_tilde_mirror, N_tilde); - CompareWithExpected(N_tilde_mirror, N_tilde_exact); +TEST(CalculateForceFCTests, OneNode) { + TestCalculateForceFC(); } } // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_calculate_force_FD.cpp b/tests/unit_tests/system/beams/test_calculate_force_FD.cpp index 0ef9bce22..5917b755a 100644 --- a/tests/unit_tests/system/beams/test_calculate_force_FD.cpp +++ b/tests/unit_tests/system/beams/test_calculate_force_FD.cpp @@ -4,35 +4,45 @@ #include "system/beams/calculate_force_FD.hpp" #include "test_calculate.hpp" -namespace openturbine::tests { +namespace { -TEST(CalculateForceFDTests, OneNode) { - const auto x0pupSS = Kokkos::View("x0pupSS"); +void TestCalculateForceFD() { + const auto x0pupSS = Kokkos::View("x0pupSS"); constexpr auto x0pupSS_data = std::array{1., 2., 3., 4., 5., 6., 7., 8., 9.}; const auto x0pupSS_host = - Kokkos::View(x0pupSS_data.data()); + Kokkos::View::const_type(x0pupSS_data.data()); const auto x0pupSS_mirror = Kokkos::create_mirror(x0pupSS); Kokkos::deep_copy(x0pupSS_mirror, x0pupSS_host); Kokkos::deep_copy(x0pupSS, x0pupSS_mirror); - const auto FC = Kokkos::View("FC"); + const auto FC = Kokkos::View("FC"); constexpr auto FC_data = std::array{10., 11., 12., 13., 14., 15.}; - const auto FC_host = Kokkos::View(FC_data.data()); + const auto FC_host = Kokkos::View::const_type(FC_data.data()); const auto FC_mirror = Kokkos::create_mirror(FC); Kokkos::deep_copy(FC_mirror, FC_host); Kokkos::deep_copy(FC, FC_mirror); - const auto FD = Kokkos::View("FD"); + const auto FD = Kokkos::View("FD"); - Kokkos::parallel_for("CalculateForceFD", 1, CalculateForceFD{0, x0pupSS, FC, FD}); + Kokkos::parallel_for( + "CalculateForceFD", 1, + KOKKOS_LAMBDA(size_t) { openturbine::beams::CalculateForceFD(x0pupSS, FC, FD); } + ); constexpr auto FD_exact_data = std::array{0., 0., 0., 138., 171., 204.}; const auto FD_exact = - Kokkos::View(FD_exact_data.data()); + Kokkos::View::const_type(FD_exact_data.data()); const auto FD_mirror = Kokkos::create_mirror(FD); Kokkos::deep_copy(FD_mirror, FD); - CompareWithExpected(FD_mirror, FD_exact); + openturbine::tests::CompareWithExpected(FD_mirror, FD_exact); +} +} // namespace + +namespace openturbine::tests { + +TEST(CalculateForceFDTests, OneNode) { + TestCalculateForceFD(); } } // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_calculate_gravity_force.cpp b/tests/unit_tests/system/beams/test_calculate_gravity_force.cpp deleted file mode 100644 index 6f6fcfbdf..000000000 --- a/tests/unit_tests/system/beams/test_calculate_gravity_force.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include - -#include "system/beams/calculate_gravity_force.hpp" -#include "test_calculate.hpp" - -namespace openturbine::tests { - -TEST(CalculateGravityForceTests, OneNode) { - const auto Muu = Kokkos::View("Muu"); - constexpr auto Muu_data = std::array{1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., - 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., - 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36.}; - const auto Muu_host = Kokkos::View(Muu_data.data()); - const auto Muu_mirror = Kokkos::create_mirror(Muu); - Kokkos::deep_copy(Muu_mirror, Muu_host); - Kokkos::deep_copy(Muu, Muu_mirror); - - const auto eta_tilde = Kokkos::View("eta_tilde"); - constexpr auto eta_tilde_data = std::array{37., 38., 39., 40., 41., 42., 43., 44., 45.}; - const auto eta_tilde_host = - Kokkos::View(eta_tilde_data.data()); - const auto eta_tilde_mirror = Kokkos::create_mirror(eta_tilde); - Kokkos::deep_copy(eta_tilde_mirror, eta_tilde_host); - Kokkos::deep_copy(eta_tilde, eta_tilde_mirror); - - const auto gravity = Kokkos::View("gravity"); - constexpr auto gravity_data = std::array{46., 47., 48.}; - const auto gravity_host = Kokkos::View(gravity_data.data()); - const auto gravity_mirror = Kokkos::create_mirror(gravity); - Kokkos::deep_copy(gravity_mirror, gravity_host); - Kokkos::deep_copy(gravity, gravity_mirror); - - const auto FG = Kokkos::View("FG"); - - Kokkos::parallel_for( - "CalculateGravityForce", 1, CalculateGravityForce{0, gravity, Muu, eta_tilde, FG} - ); - - constexpr auto FG_exact_data = std::array{46., 47., 48., 5360., 5783., 6206.}; - const auto FG_exact = - Kokkos::View(FG_exact_data.data()); - - const auto FG_mirror = Kokkos::create_mirror(FG); - Kokkos::deep_copy(FG_mirror, FG); - CompareWithExpected(FG_mirror, FG_exact); -} - -} // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_calculate_gyroscopic_matrix.cpp b/tests/unit_tests/system/beams/test_calculate_gyroscopic_matrix.cpp deleted file mode 100644 index e44256265..000000000 --- a/tests/unit_tests/system/beams/test_calculate_gyroscopic_matrix.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include - -#include "system/beams/calculate_gyroscopic_matrix.hpp" -#include "test_calculate.hpp" - -namespace openturbine::tests { - -TEST(CalculateGyroscopicMatrixTests, OneNode) { - const auto Muu = Kokkos::View("Muu"); - constexpr auto Muu_data = std::array{1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., - 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., - 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36.}; - const auto Muu_host = Kokkos::View(Muu_data.data()); - const auto Muu_mirror = Kokkos::create_mirror(Muu); - Kokkos::deep_copy(Muu_mirror, Muu_host); - Kokkos::deep_copy(Muu, Muu_mirror); - - const auto omega = Kokkos::View("omega"); - constexpr auto omega_data = std::array{40., 41., 42.}; - const auto omega_host = - Kokkos::View(omega_data.data()); - const auto omega_mirror = Kokkos::create_mirror(omega); - Kokkos::deep_copy(omega_mirror, omega_host); - Kokkos::deep_copy(omega, omega_mirror); - - const auto omega_tilde = Kokkos::View("omega_tilde"); - constexpr auto omega_tilde_data = std::array{46., 47., 48., 49., 50., 51., 52., 53., 54.}; - const auto omega_tilde_host = - Kokkos::View(omega_tilde_data.data()); - const auto omega_tilde_mirror = Kokkos::create_mirror(omega_tilde); - Kokkos::deep_copy(omega_tilde_mirror, omega_tilde_host); - Kokkos::deep_copy(omega_tilde, omega_tilde_mirror); - - const auto rho = Kokkos::View("rho"); - constexpr auto rho_data = std::array{55., 56., 57., 58., 59., 60., 61., 62., 63.}; - const auto rho_host = Kokkos::View(rho_data.data()); - const auto rho_mirror = Kokkos::create_mirror(rho); - Kokkos::deep_copy(rho_mirror, rho_host); - Kokkos::deep_copy(rho, rho_mirror); - - const auto eta = Kokkos::View("eta"); - constexpr auto eta_data = std::array{64., 65., 66.}; - const auto eta_host = Kokkos::View(eta_data.data()); - const auto eta_mirror = Kokkos::create_mirror(eta); - Kokkos::deep_copy(eta_mirror, eta_host); - Kokkos::deep_copy(eta, eta_mirror); - - const auto Guu = Kokkos::View("Guu"); - - Kokkos::parallel_for( - "CalculateGyroscopicMatrix", 1, - CalculateGyroscopicMatrix{0, Muu, omega, omega_tilde, rho, eta, Guu} - ); - - constexpr auto Guu_exact_data = - std::array{0., 0., 0., 18., 10301., -9734., 0., 0., 0., -10322., -30., 9182., - 0., 0., 0., 9764., -9191., 12., 0., 0., 0., 8184., 15953., 1207., - 0., 0., 0., 1078., 8856., 15896., 0., 0., 0., 16487., 2497., 9546.}; - const auto Guu_exact = - Kokkos::View(Guu_exact_data.data()); - - const auto Guu_mirror = Kokkos::create_mirror(Guu); - Kokkos::deep_copy(Guu_mirror, Guu); - CompareWithExpected(Guu_mirror, Guu_exact); -} - -} // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_calculate_inertia_stiffness_matrix.cpp b/tests/unit_tests/system/beams/test_calculate_inertia_stiffness_matrix.cpp deleted file mode 100644 index 7f25b6a20..000000000 --- a/tests/unit_tests/system/beams/test_calculate_inertia_stiffness_matrix.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include - -#include "system/beams/calculate_inertia_stiffness_matrix.hpp" -#include "test_calculate.hpp" - -namespace openturbine::tests { - -TEST(CalculateInertiaStiffnessMatrixTests, OneNode) { - const auto Muu = Kokkos::View("Muu"); - constexpr auto Muu_data = std::array{1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., - 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., - 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36.}; - const auto Muu_host = Kokkos::View(Muu_data.data()); - const auto Muu_mirror = Kokkos::create_mirror(Muu); - Kokkos::deep_copy(Muu_mirror, Muu_host); - Kokkos::deep_copy(Muu, Muu_mirror); - - const auto u_ddot = Kokkos::View("u_ddot"); - constexpr auto u_ddot_data = std::array{37., 38., 39.}; - const auto u_ddot_host = - Kokkos::View(u_ddot_data.data()); - const auto u_ddot_mirror = Kokkos::create_mirror(u_ddot); - Kokkos::deep_copy(u_ddot_mirror, u_ddot_host); - Kokkos::deep_copy(u_ddot, u_ddot_mirror); - - const auto omega = Kokkos::View("omega"); - constexpr auto omega_data = std::array{40., 41., 42.}; - const auto omega_host = - Kokkos::View(omega_data.data()); - const auto omega_mirror = Kokkos::create_mirror(omega); - Kokkos::deep_copy(omega_mirror, omega_host); - Kokkos::deep_copy(omega, omega_mirror); - - const auto omega_dot = Kokkos::View("omega_dot"); - constexpr auto omega_dot_data = std::array{43., 44., 45.}; - const auto omega_dot_host = - Kokkos::View(omega_dot_data.data()); - const auto omega_dot_mirror = Kokkos::create_mirror(omega_dot); - Kokkos::deep_copy(omega_dot_mirror, omega_dot_host); - Kokkos::deep_copy(omega_dot, omega_dot_mirror); - - const auto eta_tilde = Kokkos::View("eta_tilde"); - constexpr auto eta_tilde_data = std::array{46., 47., 48., 49., 50., 51., 52., 53., 54.}; - const auto eta_tilde_host = - Kokkos::View(eta_tilde_data.data()); - const auto eta_tilde_mirror = Kokkos::create_mirror(eta_tilde); - Kokkos::deep_copy(eta_tilde_mirror, eta_tilde_host); - Kokkos::deep_copy(eta_tilde, eta_tilde_mirror); - - const auto omega_tilde = Kokkos::View("omega_tilde"); - constexpr auto omega_tilde_data = std::array{46., 47., 48., 49., 50., 51., 52., 53., 54.}; - const auto omega_tilde_host = - Kokkos::View(omega_tilde_data.data()); - const auto omega_tilde_mirror = Kokkos::create_mirror(omega_tilde); - Kokkos::deep_copy(omega_tilde_mirror, omega_tilde_host); - Kokkos::deep_copy(omega_tilde, omega_tilde_mirror); - - const auto omega_dot_tilde = Kokkos::View("omega_dot_tilde"); - constexpr auto omega_dot_tilde_data = std::array{55., 56., 57., 58., 59., 60., 61., 62., 63.}; - const auto omega_dot_tilde_host = - Kokkos::View(omega_dot_tilde_data.data()); - const auto omega_dot_tilde_mirror = Kokkos::create_mirror(omega_dot_tilde); - Kokkos::deep_copy(omega_dot_tilde_mirror, omega_dot_tilde_host); - Kokkos::deep_copy(omega_dot_tilde, omega_dot_tilde_mirror); - - const auto rho = Kokkos::View("rho"); - constexpr auto rho_data = std::array{64., 65., 66., 67., 68., 69., 70., 71., 72.}; - const auto rho_host = Kokkos::View(rho_data.data()); - const auto rho_mirror = Kokkos::create_mirror(rho); - Kokkos::deep_copy(rho_mirror, rho_host); - Kokkos::deep_copy(rho, rho_mirror); - - const auto eta = Kokkos::View("eta"); - constexpr auto eta_data = std::array{73., 74., 75.}; - const auto eta_host = Kokkos::View(eta_data.data()); - const auto eta_mirror = Kokkos::create_mirror(eta); - Kokkos::deep_copy(eta_mirror, eta_host); - Kokkos::deep_copy(eta, eta_mirror); - - const auto Kuu = Kokkos::View("Kuu"); - - Kokkos::parallel_for( - "CalculateInertiaStiffnessMatrix", 1, - CalculateInertiaStiffnessMatrix{ - 0, Muu, u_ddot, omega, omega_dot, omega_tilde, omega_dot_tilde, rho, eta, Kuu - } - ); - - constexpr auto Kuu_exact_data = std::array{ - 0., 0., 0., 3396., -6792., 3396., 0., 0., 0., 3609., -7218., 3609., - 0., 0., 0., 3822., -7644., 3822., 0., 0., 0., 1407766., 1481559., 1465326., - 0., 0., 0., 1496300., 1558384., 1576048., 0., 0., 0., 1604122., 1652877., 1652190. - }; - const auto Kuu_exact = - Kokkos::View(Kuu_exact_data.data()); - - const auto Kuu_mirror = Kokkos::create_mirror(Kuu); - Kokkos::deep_copy(Kuu_mirror, Kuu); - CompareWithExpected(Kuu_mirror, Kuu_exact); -} - -} // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_calculate_inertial_forces.cpp b/tests/unit_tests/system/beams/test_calculate_inertial_forces.cpp deleted file mode 100644 index a224fb93d..000000000 --- a/tests/unit_tests/system/beams/test_calculate_inertial_forces.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include -#include - -#include "system/beams/calculate_inertial_force.hpp" -#include "test_calculate.hpp" - -namespace openturbine::tests { - -TEST(CalculateInertialForcesTests, OneNode) { - const auto Muu = Kokkos::View("Muu"); - constexpr auto Muu_data = std::array{1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., - 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., - 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36.}; - const auto Muu_host = Kokkos::View(Muu_data.data()); - const auto Muu_mirror = Kokkos::create_mirror(Muu); - Kokkos::deep_copy(Muu_mirror, Muu_host); - Kokkos::deep_copy(Muu, Muu_mirror); - - const auto u_ddot = Kokkos::View("u_ddot"); - constexpr auto u_ddot_data = std::array{37., 38., 39.}; - const auto u_ddot_host = - Kokkos::View(u_ddot_data.data()); - const auto u_ddot_mirror = Kokkos::create_mirror(u_ddot); - Kokkos::deep_copy(u_ddot_mirror, u_ddot_host); - Kokkos::deep_copy(u_ddot, u_ddot_mirror); - - const auto omega = Kokkos::View("omega"); - constexpr auto omega_data = std::array{40., 41., 42.}; - const auto omega_host = - Kokkos::View(omega_data.data()); - const auto omega_mirror = Kokkos::create_mirror(omega); - Kokkos::deep_copy(omega_mirror, omega_host); - Kokkos::deep_copy(omega, omega_mirror); - - const auto omega_dot = Kokkos::View("omega_dot"); - constexpr auto omega_dot_data = std::array{43., 44., 45.}; - const auto omega_dot_host = - Kokkos::View(omega_dot_data.data()); - const auto omega_dot_mirror = Kokkos::create_mirror(omega_dot); - Kokkos::deep_copy(omega_dot_mirror, omega_dot_host); - Kokkos::deep_copy(omega_dot, omega_dot_mirror); - - const auto eta_tilde = Kokkos::View("eta_tilde"); - constexpr auto eta_tilde_data = std::array{46., 47., 48., 49., 50., 51., 52., 53., 54.}; - const auto eta_tilde_host = - Kokkos::View(eta_tilde_data.data()); - const auto eta_tilde_mirror = Kokkos::create_mirror(eta_tilde); - Kokkos::deep_copy(eta_tilde_mirror, eta_tilde_host); - Kokkos::deep_copy(eta_tilde, eta_tilde_mirror); - - const auto rho = Kokkos::View("rho"); - const auto rho_data = std::array{55., 56., 57., 58., 59., 60., 61., 62., 63.}; - const auto rho_host = Kokkos::View(rho_data.data()); - const auto rho_mirror = Kokkos::create_mirror(rho); - Kokkos::deep_copy(rho_mirror, rho_host); - Kokkos::deep_copy(rho, rho_mirror); - - const auto eta = Kokkos::View("eta"); - const auto eta_data = std::array{64., 65., 66.}; - const auto eta_host = Kokkos::View(eta_data.data()); - const auto eta_mirror = Kokkos::create_mirror(eta); - Kokkos::deep_copy(eta_mirror, eta_host); - Kokkos::deep_copy(eta, eta_mirror); - - const auto omega_tilde = Kokkos::View("omega_tilde"); - const auto omega_dot_tilde = Kokkos::View("omega_dot_tilde"); - const auto FI = Kokkos::View("FI"); - - Kokkos::parallel_for( - "CalculateInertialForces", 1, - CalculateInertialForces{ - 0, Muu, u_ddot, omega, omega_dot, eta_tilde, omega_tilde, omega_dot_tilde, rho, eta, FI - } - ); - - constexpr auto omega_tilde_exact_data = std::array{0., -42., 41., 42., 0., -40., -41., 40., 0.}; - const auto omega_tilde_exact = - Kokkos::View(omega_tilde_exact_data.data()); - - const auto omega_tilde_mirror = Kokkos::create_mirror(omega_tilde); - Kokkos::deep_copy(omega_tilde_mirror, omega_tilde); - CompareWithExpected(omega_tilde_mirror, omega_tilde_exact); - - constexpr auto omega_dot_tilde_exact_data = - std::array{0., -45., 44., 45., 0., -43., -44., 43., 0.}; - const auto omega_dot_tilde_exact = - Kokkos::View(omega_dot_tilde_exact_data.data()); - - const auto omega_dot_tilde_mirror = Kokkos::create_mirror(omega_dot_tilde); - Kokkos::deep_copy(omega_dot_tilde_mirror, omega_dot_tilde); - CompareWithExpected(omega_dot_tilde_mirror, omega_dot_tilde_exact); - - constexpr auto FI_exact_data = std::array{-2984., 32., 2922., 20624., -2248., 22100.}; - const auto FI_exact = - Kokkos::View(FI_exact_data.data()); - - const auto FI_mirror = Kokkos::create_mirror(FI); - Kokkos::deep_copy(FI_mirror, FI); - CompareWithExpected(FI_mirror, FI_exact); -} - -} // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_calculate_mass_matrix_components.cpp b/tests/unit_tests/system/beams/test_calculate_mass_matrix_components.cpp deleted file mode 100644 index 883511e75..000000000 --- a/tests/unit_tests/system/beams/test_calculate_mass_matrix_components.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include - -#include "system/beams/calculate_mass_matrix_components.hpp" -#include "test_calculate.hpp" - -namespace openturbine::tests { - -TEST(CalculateMassMatrixComponentsTests, OneQuadPoint) { - const auto Muu = Kokkos::View("Muu"); - constexpr auto Muu_data = std::array{1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., - 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., - 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36.}; - const auto Muu_host = Kokkos::View(Muu_data.data()); - const auto Muu_mirror = Kokkos::create_mirror(Muu); - Kokkos::deep_copy(Muu_mirror, Muu_host); - Kokkos::deep_copy(Muu, Muu_mirror); - - const auto eta = Kokkos::View("eta"); - const auto rho = Kokkos::View("rho"); - const auto eta_tilde = Kokkos::View("eta_tilde"); - - Kokkos::parallel_for( - "CalculateMassMatrixComponents", 1, - CalculateMassMatrixComponents{0, Muu, eta, rho, eta_tilde} - ); - - constexpr auto eta_exact_data = std::array{32., -31., 25.}; - const auto eta_exact = - Kokkos::View(eta_exact_data.data()); - - const auto eta_mirror = Kokkos::create_mirror(eta); - Kokkos::deep_copy(eta_mirror, eta); - CompareWithExpected(eta_mirror, eta_exact); - - constexpr auto rho_exact_data = std::array{22., 23., 24., 28., 29., 30., 34., 35., 36.}; - const auto rho_exact = - Kokkos::View(rho_exact_data.data()); - - const auto rho_mirror = Kokkos::create_mirror(rho); - Kokkos::deep_copy(rho_mirror, rho); - CompareWithExpected(rho_mirror, rho_exact); - - constexpr auto eta_tilde_exact_data = std::array{0., -25., -31., 25., 0., -32., 31., 32., 0.}; - const auto eta_tilde_exact = - Kokkos::View(eta_tilde_exact_data.data()); - - const auto eta_tilde_mirror = Kokkos::create_mirror(eta_tilde); - Kokkos::deep_copy(eta_tilde_mirror, eta_tilde); - CompareWithExpected(eta_tilde_mirror, eta_tilde_exact); -} - -} // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_calculate_strain.cpp b/tests/unit_tests/system/beams/test_calculate_strain.cpp index 3c234156b..3cfc92cca 100644 --- a/tests/unit_tests/system/beams/test_calculate_strain.cpp +++ b/tests/unit_tests/system/beams/test_calculate_strain.cpp @@ -4,53 +4,62 @@ #include "system/beams/calculate_strain.hpp" #include "test_calculate.hpp" -namespace openturbine::tests { +namespace { -TEST(CalculateStrainTests, OneNode) { - const auto x0_prime = Kokkos::View("x0_prime"); +void TestCalculateStrain() { + const auto x0_prime = Kokkos::View("x0_prime"); constexpr auto x0_prime_data = std::array{1., 2., 3.}; const auto x0_prime_host = - Kokkos::View(x0_prime_data.data()); + Kokkos::View(x0_prime_data.data()); const auto x0_prime_mirror = Kokkos::create_mirror(x0_prime); Kokkos::deep_copy(x0_prime_mirror, x0_prime_host); Kokkos::deep_copy(x0_prime, x0_prime_mirror); - const auto u_prime = Kokkos::View("u_prime"); + const auto u_prime = Kokkos::View("u_prime"); constexpr auto u_prime_data = std::array{4., 5., 6.}; - const auto u_prime_host = - Kokkos::View(u_prime_data.data()); + const auto u_prime_host = Kokkos::View(u_prime_data.data()); const auto u_prime_mirror = Kokkos::create_mirror(u_prime); Kokkos::deep_copy(u_prime_mirror, u_prime_host); Kokkos::deep_copy(u_prime, u_prime_mirror); - const auto r = Kokkos::View("r"); + const auto r = Kokkos::View("r"); constexpr auto r_data = std::array{7., 8., 9., 10.}; - const auto r_host = Kokkos::View(r_data.data()); + const auto r_host = Kokkos::View(r_data.data()); const auto r_mirror = Kokkos::create_mirror(r); Kokkos::deep_copy(r_mirror, r_host); Kokkos::deep_copy(r, r_mirror); - const auto r_prime = Kokkos::View("r_prime"); + const auto r_prime = Kokkos::View("r_prime"); constexpr auto r_prime_data = std::array{11., 12., 13., 14.}; - const auto r_prime_host = - Kokkos::View(r_prime_data.data()); + const auto r_prime_host = Kokkos::View(r_prime_data.data()); const auto r_prime_mirror = Kokkos::create_mirror(r_prime); Kokkos::deep_copy(r_prime_mirror, r_prime_host); Kokkos::deep_copy(r_prime, r_prime_mirror); - const auto strain = Kokkos::View("strain"); + const auto strain = Kokkos::View("strain"); Kokkos::parallel_for( - "CalculateStrain", 1, CalculateStrain{0, x0_prime, u_prime, r, r_prime, strain} + "CalculateStrain", 1, + KOKKOS_LAMBDA(size_t) { + openturbine::beams::CalculateStrain(x0_prime, u_prime, r, r_prime, strain); + } ); constexpr auto strain_exact_data = std::array{-793., -413., -621., -16., 0., -32.}; const auto strain_exact = - Kokkos::View(strain_exact_data.data()); + Kokkos::View(strain_exact_data.data()); const auto strain_mirror = Kokkos::create_mirror(strain); Kokkos::deep_copy(strain_mirror, strain); - CompareWithExpected(strain_mirror, strain_exact); + openturbine::tests::CompareWithExpected(strain_mirror, strain_exact); +} + +} // namespace + +namespace openturbine::tests { + +TEST(CalculateStrainTests, OneNode) { + TestCalculateStrain(); } } // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_calculate_temporary_variables.cpp b/tests/unit_tests/system/beams/test_calculate_temporary_variables.cpp index 469166bc3..9cadbb2af 100644 --- a/tests/unit_tests/system/beams/test_calculate_temporary_variables.cpp +++ b/tests/unit_tests/system/beams/test_calculate_temporary_variables.cpp @@ -4,38 +4,49 @@ #include "system/beams/calculate_temporary_variables.hpp" #include "test_calculate.hpp" -namespace openturbine::tests { +namespace { -TEST(CalculateTemporaryVariablesTests, OneNode) { - const auto x0_prime = Kokkos::View("x0_prime"); +void TestCalculateTemporaryVariables() { + const auto x0_prime = Kokkos::View("x0_prime"); constexpr auto x0_prime_data = std::array{1., 2., 3.}; const auto x0_prime_host = - Kokkos::View(x0_prime_data.data()); + Kokkos::View::const_type(x0_prime_data.data()); const auto x0_prime_mirror = Kokkos::create_mirror(x0_prime); Kokkos::deep_copy(x0_prime_mirror, x0_prime_host); Kokkos::deep_copy(x0_prime, x0_prime_mirror); - const auto u_prime = Kokkos::View("u_prime"); + const auto u_prime = Kokkos::View("u_prime"); constexpr auto u_prime_data = std::array{4., 5., 6.}; const auto u_prime_host = - Kokkos::View(u_prime_data.data()); + Kokkos::View::const_type(u_prime_data.data()); const auto u_prime_mirror = Kokkos::create_mirror(u_prime); Kokkos::deep_copy(u_prime_mirror, u_prime_host); Kokkos::deep_copy(u_prime, u_prime_mirror); - const auto x0pupSS = Kokkos::View("x0pupSS"); + const auto x0pupSS = Kokkos::View("x0pupSS"); Kokkos::parallel_for( - "CalculateTemporaryVariables", 1, CalculateTemporaryVariables{0, x0_prime, u_prime, x0pupSS} + "CalculateTemporaryVariables", 1, + KOKKOS_LAMBDA(size_t) { + openturbine::beams::CalculateTemporaryVariables(x0_prime, u_prime, x0pupSS); + } ); constexpr auto x0pupSS_exact_data = std::array{0., -9., 7., 9., 0., -5., -7., 5., 0.}; const auto x0pupSS_exact = - Kokkos::View(x0pupSS_exact_data.data()); + Kokkos::View::const_type(x0pupSS_exact_data.data()); const auto x0pupSS_mirror = Kokkos::create_mirror(x0pupSS); Kokkos::deep_copy(x0pupSS_mirror, x0pupSS); - CompareWithExpected(x0pupSS_mirror, x0pupSS_exact); + openturbine::tests::CompareWithExpected(x0pupSS_mirror, x0pupSS_exact); +} + +} // namespace + +namespace openturbine::tests { + +TEST(CalculateTemporaryVariablesTests, OneNode) { + TestCalculateTemporaryVariables(); } } // namespace openturbine::tests diff --git a/tests/unit_tests/system/beams/test_integrate_inertia_matrix.cpp b/tests/unit_tests/system/beams/test_integrate_inertia_matrix.cpp index f4c507352..aa9c2bd54 100644 --- a/tests/unit_tests/system/beams/test_integrate_inertia_matrix.cpp +++ b/tests/unit_tests/system/beams/test_integrate_inertia_matrix.cpp @@ -30,7 +30,7 @@ inline void IntegrateInertiaMatrix_TestOneElementOneNodeOneQP_Muu() { const auto gbl_M = Kokkos::View("global_M"); const auto policy = Kokkos::RangePolicy(0, number_of_nodes * number_of_simd_nodes); - const auto integrator = IntegrateInertiaMatrixElement{ + const auto integrator = beams::IntegrateInertiaMatrixElement{ 0U, number_of_nodes, number_of_qps, qp_weights, qp_jacobian, shape_interp, qp_Muu, qp_Guu, 1., 0., gbl_M @@ -77,7 +77,7 @@ void IntegrateInertiaMatrix_TestOneElementOneNodeOneQP_Guu() { const auto gbl_M = Kokkos::View("global_M"); const auto policy = Kokkos::RangePolicy(0, number_of_nodes * number_of_simd_nodes); - const auto integrator = IntegrateInertiaMatrixElement{ + const auto integrator = beams::IntegrateInertiaMatrixElement{ 0U, number_of_nodes, number_of_qps, qp_weights, qp_jacobian, shape_interp, qp_Muu, qp_Guu, 0., 1., gbl_M @@ -122,7 +122,7 @@ void IntegrateInertiaMatrix_TestTwoElementsOneNodeOneQP() { 00404., 00405., 00406., 00501., 00502., 00503., 00504., 00505., 00506.} ); const auto policy = Kokkos::RangePolicy(0, number_of_nodes * number_of_simd_nodes); - const auto integrator = IntegrateInertiaMatrixElement{ + const auto integrator = beams::IntegrateInertiaMatrixElement{ 0U, number_of_nodes, number_of_qps, qp_weights, qp_jacobian, shape_interp, qp_Muu, qp_Guu, 1., 0., gbl_M @@ -138,7 +138,7 @@ void IntegrateInertiaMatrix_TestTwoElementsOneNodeOneQP() { 40004., 40005., 40006., 50001., 50002., 50003., 50004., 50005., 50006.} ); const auto policy = Kokkos::RangePolicy(0, number_of_nodes * number_of_simd_nodes); - const auto integrator = IntegrateInertiaMatrixElement{ + const auto integrator = beams::IntegrateInertiaMatrixElement{ 1U, number_of_nodes, number_of_qps, qp_weights, qp_jacobian, shape_interp, qp_Muu, qp_Guu, 1., 0., gbl_M @@ -188,7 +188,7 @@ void IntegrateInertiaMatrix_TestOneElementTwoNodesOneQP() { const auto gbl_M = Kokkos::View("global_M"); const auto policy = Kokkos::RangePolicy(0, number_of_nodes * number_of_simd_nodes); - const auto integrator = IntegrateInertiaMatrixElement{ + const auto integrator = beams::IntegrateInertiaMatrixElement{ 0U, number_of_nodes, number_of_qps, qp_weights, qp_jacobian, shape_interp, qp_Muu, qp_Guu, 1., 0., gbl_M @@ -247,7 +247,7 @@ void IntegrateInertiaMatrix_TestOneElementOneNodeTwoQPs() { const auto gbl_M = Kokkos::View("global_M"); const auto policy = Kokkos::RangePolicy(0, number_of_nodes * number_of_simd_nodes); - const auto integrator = IntegrateInertiaMatrixElement{ + const auto integrator = beams::IntegrateInertiaMatrixElement{ 0U, number_of_nodes, number_of_qps, qp_weights, qp_jacobian, shape_interp, qp_Muu, qp_Guu, 1., 0., gbl_M @@ -291,7 +291,7 @@ void IntegrateInertiaMatrix_TestOneElementOneNodeOneQP_WithMultiplicationFactor( const auto gbl_M = Kokkos::View("global_M"); const auto policy = Kokkos::RangePolicy(0, number_of_nodes * number_of_simd_nodes); - const auto integrator = IntegrateInertiaMatrixElement{ + const auto integrator = beams::IntegrateInertiaMatrixElement{ 0U, number_of_nodes, number_of_qps, qp_weights, qp_jacobian, shape_interp, qp_Muu, qp_Guu, multiplication_factor, 0., gbl_M }; diff --git a/tests/unit_tests/system/beams/test_integrate_residual_vector.cpp b/tests/unit_tests/system/beams/test_integrate_residual_vector.cpp index 741de5945..797c66b25 100644 --- a/tests/unit_tests/system/beams/test_integrate_residual_vector.cpp +++ b/tests/unit_tests/system/beams/test_integrate_residual_vector.cpp @@ -14,12 +14,8 @@ TEST(IntegrateResidualVector, OneElementOneNodeOneQP_Fc) { const auto qp_weights = get_qp_weights({2.}); const auto qp_jacobian = get_qp_jacobian({0.}); - const auto shape_interp_left = get_shape_interp({0.}); - const auto shape_interp = Kokkos::View("shape_interp"); - Kokkos::deep_copy(shape_interp, shape_interp_left); - const auto shape_deriv_left = get_shape_interp_deriv({3.}); - const auto shape_deriv = Kokkos::View("shape_deriv"); - Kokkos::deep_copy(shape_deriv, shape_deriv_left); + const auto shape_interp = get_shape_interp({0.}); + const auto shape_deriv = get_shape_interp_deriv({3.}); using NodeVectorView = Kokkos::View; using QpVectorView = Kokkos::View; @@ -35,7 +31,7 @@ TEST(IntegrateResidualVector, OneElementOneNodeOneQP_Fc) { Kokkos::parallel_for( "IntegrateResidualVectorElement", number_of_nodes, - IntegrateResidualVectorElement{ + beams::IntegrateResidualVectorElement{ 0U, number_of_qps, qp_weights, qp_jacobian, shape_interp, shape_deriv, node_FX, qp_Fc, qp_Fd, qp_Fi, qp_Fe, qp_Fg, residual_vector_terms } @@ -58,12 +54,8 @@ TEST(IntegrateResidualVector, OneElementOneNodeOneQP_Fd) { const auto qp_weights = get_qp_weights({2.}); const auto qp_jacobian = get_qp_jacobian({3.}); - const auto shape_interp_left = get_shape_interp({4.}); - const auto shape_interp = Kokkos::View("shape_interp"); - Kokkos::deep_copy(shape_interp, shape_interp_left); - const auto shape_deriv_left = get_shape_interp_deriv({0.}); - const auto shape_deriv = Kokkos::View("shape_deriv"); - Kokkos::deep_copy(shape_deriv, shape_deriv_left); + const auto shape_interp = get_shape_interp({4.}); + const auto shape_deriv = get_shape_interp_deriv({0.}); using NodeVectorView = Kokkos::View; using QpVectorView = Kokkos::View; @@ -79,7 +71,7 @@ TEST(IntegrateResidualVector, OneElementOneNodeOneQP_Fd) { Kokkos::parallel_for( "IntegrateResidualVectorElement", number_of_nodes, - IntegrateResidualVectorElement{ + beams::IntegrateResidualVectorElement{ 0U, number_of_qps, qp_weights, qp_jacobian, shape_interp, shape_deriv, node_FX, qp_Fc, qp_Fd, qp_Fi, qp_Fe, qp_Fg, residual_vector_terms } @@ -102,12 +94,8 @@ TEST(IntegrateResidualVector, OneElementOneNodeOneQP_Fi) { const auto qp_weights = get_qp_weights({2.}); const auto qp_jacobian = get_qp_jacobian({3.}); - const auto shape_interp_left = get_shape_interp({4.}); - const auto shape_interp = Kokkos::View("shape_interp"); - Kokkos::deep_copy(shape_interp, shape_interp_left); - const auto shape_deriv_left = get_shape_interp_deriv({0.}); - const auto shape_deriv = Kokkos::View("shape_deriv"); - Kokkos::deep_copy(shape_deriv, shape_deriv_left); + const auto shape_interp = get_shape_interp({4.}); + const auto shape_deriv = get_shape_interp_deriv({0.}); using NodeVectorView = Kokkos::View; using QpVectorView = Kokkos::View; @@ -123,7 +111,7 @@ TEST(IntegrateResidualVector, OneElementOneNodeOneQP_Fi) { Kokkos::parallel_for( "IntegrateResidualVectorElement", number_of_nodes, - IntegrateResidualVectorElement{ + beams::IntegrateResidualVectorElement{ 0U, number_of_qps, qp_weights, qp_jacobian, shape_interp, shape_deriv, node_FX, qp_Fc, qp_Fd, qp_Fi, qp_Fe, qp_Fg, residual_vector_terms } @@ -146,12 +134,8 @@ TEST(IntegrateResidualVector, OneElementOneNodeOneQP_Fe) { const auto qp_weights = get_qp_weights({2.}); const auto qp_jacobian = get_qp_jacobian({3.}); - const auto shape_interp_left = get_shape_interp({4.}); - const auto shape_interp = Kokkos::View("shape_interp"); - Kokkos::deep_copy(shape_interp, shape_interp_left); - const auto shape_deriv_left = get_shape_interp_deriv({0.}); - const auto shape_deriv = Kokkos::View("shape_deriv"); - Kokkos::deep_copy(shape_deriv, shape_deriv_left); + const auto shape_interp = get_shape_interp({4.}); + const auto shape_deriv = get_shape_interp_deriv({0.}); using NodeVectorView = Kokkos::View; using QpVectorView = Kokkos::View; @@ -167,7 +151,7 @@ TEST(IntegrateResidualVector, OneElementOneNodeOneQP_Fe) { Kokkos::parallel_for( "IntegrateResidualVectorElement", number_of_nodes, - IntegrateResidualVectorElement{ + beams::IntegrateResidualVectorElement{ 0U, number_of_qps, qp_weights, qp_jacobian, shape_interp, shape_deriv, node_FX, qp_Fc, qp_Fd, qp_Fi, qp_Fe, qp_Fg, residual_vector_terms } @@ -190,12 +174,8 @@ TEST(IntegrateResidualVector, OneElementOneNodeOneQP_Fg) { const auto qp_weights = get_qp_weights({2.}); const auto qp_jacobian = get_qp_jacobian({3.}); - const auto shape_interp_left = get_shape_interp({4.}); - const auto shape_interp = Kokkos::View("shape_interp"); - Kokkos::deep_copy(shape_interp, shape_interp_left); - const auto shape_deriv_left = get_shape_interp_deriv({0.}); - const auto shape_deriv = Kokkos::View("shape_deriv"); - Kokkos::deep_copy(shape_deriv, shape_deriv_left); + const auto shape_interp = get_shape_interp({4.}); + const auto shape_deriv = get_shape_interp_deriv({0.}); using NodeVectorView = Kokkos::View; using QpVectorView = Kokkos::View; @@ -211,7 +191,7 @@ TEST(IntegrateResidualVector, OneElementOneNodeOneQP_Fg) { Kokkos::parallel_for( "IntegrateResidualVectorElement", number_of_nodes, - IntegrateResidualVectorElement{ + beams::IntegrateResidualVectorElement{ 0U, number_of_qps, qp_weights, qp_jacobian, shape_interp, shape_deriv, node_FX, qp_Fc, qp_Fd, qp_Fi, qp_Fe, qp_Fg, residual_vector_terms } @@ -234,12 +214,8 @@ TEST(IntegrateResidualVector, OneElementOneNodeOneQP_FX) { const auto qp_weights = get_qp_weights({2.}); const auto qp_jacobian = get_qp_jacobian({3.}); - const auto shape_interp_left = get_shape_interp({4.}); - const auto shape_interp = Kokkos::View("shape_interp"); - Kokkos::deep_copy(shape_interp, shape_interp_left); - const auto shape_deriv_left = get_shape_interp_deriv({0.}); - const auto shape_deriv = Kokkos::View("shape_deriv"); - Kokkos::deep_copy(shape_deriv, shape_deriv_left); + const auto shape_interp = get_shape_interp({4.}); + const auto shape_deriv = get_shape_interp_deriv({0.}); using QpVectorView = Kokkos::View; const auto node_FX = get_node_FX({1., 2., 3., 4., 5., 6.}); @@ -254,7 +230,7 @@ TEST(IntegrateResidualVector, OneElementOneNodeOneQP_FX) { Kokkos::parallel_for( "IntegrateResidualVectorElement", number_of_nodes, - IntegrateResidualVectorElement{ + beams::IntegrateResidualVectorElement{ 0U, number_of_qps, qp_weights, qp_jacobian, shape_interp, shape_deriv, node_FX, qp_Fc, qp_Fd, qp_Fi, qp_Fe, qp_Fg, residual_vector_terms } @@ -277,12 +253,8 @@ TEST(IntegrateResidualVector, TwoElementsOneNodeOneQP) { const auto qp_weights = get_qp_weights({2.}); const auto qp_jacobian = get_qp_jacobian({0.}); - const auto shape_interp_left = get_shape_interp({0.}); - const auto shape_interp = Kokkos::View("shape_interp"); - Kokkos::deep_copy(shape_interp, shape_interp_left); - const auto shape_deriv_left = get_shape_interp_deriv({3.}); - const auto shape_deriv = Kokkos::View("shape_deriv"); - Kokkos::deep_copy(shape_deriv, shape_deriv_left); + const auto shape_interp = get_shape_interp({0.}); + const auto shape_deriv = get_shape_interp_deriv({3.}); using NodeVectorView = Kokkos::View; using QpVectorView = Kokkos::View; @@ -299,7 +271,7 @@ TEST(IntegrateResidualVector, TwoElementsOneNodeOneQP) { Kokkos::parallel_for( "IntegrateResidualVectorElement", number_of_nodes, - IntegrateResidualVectorElement{ + beams::IntegrateResidualVectorElement{ 0U, number_of_qps, qp_weights, qp_jacobian, shape_interp, shape_deriv, node_FX, qp_Fc_1, qp_Fd, qp_Fi, qp_Fe, qp_Fg, residual_vector_terms } @@ -307,7 +279,7 @@ TEST(IntegrateResidualVector, TwoElementsOneNodeOneQP) { Kokkos::parallel_for( "IntegrateResidualVectorElement", number_of_nodes, - IntegrateResidualVectorElement{ + beams::IntegrateResidualVectorElement{ 1U, number_of_qps, qp_weights, qp_jacobian, shape_interp, shape_deriv, node_FX, qp_Fc_2, qp_Fd, qp_Fi, qp_Fe, qp_Fg, residual_vector_terms } @@ -331,12 +303,8 @@ TEST(IntegrateResidualVector, OneElementOneNodeTwoQPs) { const auto qp_weights = get_qp_weights({2., 1.}); const auto qp_jacobian = get_qp_jacobian({0.}); - const auto shape_interp_left = get_shape_interp({0.}); - const auto shape_interp = Kokkos::View("shape_interp"); - Kokkos::deep_copy(shape_interp, shape_interp_left); - const auto shape_deriv_left = get_shape_interp_deriv({3., 2.}); - const auto shape_deriv = Kokkos::View("shape_deriv"); - Kokkos::deep_copy(shape_deriv, shape_deriv_left); + const auto shape_interp = get_shape_interp({0.}); + const auto shape_deriv = get_shape_interp_deriv({3., 2.}); using NodeVectorView = Kokkos::View; using QpVectorView = Kokkos::View; @@ -352,7 +320,7 @@ TEST(IntegrateResidualVector, OneElementOneNodeTwoQPs) { Kokkos::parallel_for( "IntegrateResidualVectorElement", number_of_nodes, - IntegrateResidualVectorElement{ + beams::IntegrateResidualVectorElement{ 0U, number_of_qps, qp_weights, qp_jacobian, shape_interp, shape_deriv, node_FX, qp_Fc, qp_Fd, qp_Fi, qp_Fe, qp_Fg, residual_vector_terms } @@ -375,12 +343,8 @@ TEST(IntegrateResidualVector, OneElementTwoNodesOneQP) { const auto qp_weights = get_qp_weights({2.}); const auto qp_jacobian = get_qp_jacobian({0.}); - const auto shape_interp_left = get_shape_interp({0.}); - const auto shape_interp = Kokkos::View("shape_interp"); - Kokkos::deep_copy(shape_interp, shape_interp_left); - const auto shape_deriv_left = get_shape_interp_deriv({3.}); - const auto shape_deriv = Kokkos::View("shape_deriv"); - Kokkos::deep_copy(shape_deriv, shape_deriv_left); + const auto shape_interp = get_shape_interp({0.}); + const auto shape_deriv = get_shape_interp_deriv({3.}); using NodeVectorView = Kokkos::View; using QpVectorView = Kokkos::View; @@ -396,7 +360,7 @@ TEST(IntegrateResidualVector, OneElementTwoNodesOneQP) { Kokkos::parallel_for( "IntegrateResidualVectorElement", number_of_nodes, - IntegrateResidualVectorElement{ + beams::IntegrateResidualVectorElement{ 0U, number_of_qps, qp_weights, qp_jacobian, shape_interp, shape_deriv, node_FX, qp_Fc, qp_Fd, qp_Fi, qp_Fe, qp_Fg, residual_vector_terms } diff --git a/tests/unit_tests/system/beams/test_integrate_stiffness_matrix.cpp b/tests/unit_tests/system/beams/test_integrate_stiffness_matrix.cpp index d16d31ca1..5ff82b5ea 100644 --- a/tests/unit_tests/system/beams/test_integrate_stiffness_matrix.cpp +++ b/tests/unit_tests/system/beams/test_integrate_stiffness_matrix.cpp @@ -27,19 +27,19 @@ void TestIntegrateStiffnessMatrix_1Element1Node1QP( auto gbl_M = Kokkos::View("global_M"); const auto policy = Kokkos::RangePolicy(0, number_of_nodes * number_of_simd_nodes); - const auto integrator = IntegrateStiffnessMatrixElement{0U, - number_of_nodes, - number_of_qps, - qp_weights, - qp_jacobian, - shape_interp, - shape_interp_deriv, - qp_Kuu, - qp_Puu, - qp_Cuu, - qp_Ouu, - qp_Quu, - gbl_M}; + const auto integrator = beams::IntegrateStiffnessMatrixElement{0U, + number_of_nodes, + number_of_qps, + qp_weights, + qp_jacobian, + shape_interp, + shape_interp_deriv, + qp_Kuu, + qp_Puu, + qp_Cuu, + qp_Ouu, + qp_Quu, + gbl_M}; Kokkos::parallel_for(policy, integrator); const auto exact_M = @@ -222,19 +222,19 @@ void TestIntegrateStiffnessMatrix_2Elements1Node1QP() { 00404., 00405., 00406., 00501., 00502., 00503., 00504., 00505., 00506.} ); const auto policy = Kokkos::RangePolicy(0, number_of_nodes * number_of_simd_nodes); - const auto integrator = IntegrateStiffnessMatrixElement{0U, - number_of_nodes, - number_of_qps, - qp_weights, - qp_jacobian, - shape_interp, - shape_interp_deriv, - qp_Kuu, - qp_Puu, - qp_Cuu, - qp_Ouu, - qp_Quu, - gbl_M}; + const auto integrator = beams::IntegrateStiffnessMatrixElement{0U, + number_of_nodes, + number_of_qps, + qp_weights, + qp_jacobian, + shape_interp, + shape_interp_deriv, + qp_Kuu, + qp_Puu, + qp_Cuu, + qp_Ouu, + qp_Quu, + gbl_M}; Kokkos::parallel_for(policy, integrator); } @@ -246,19 +246,19 @@ void TestIntegrateStiffnessMatrix_2Elements1Node1QP() { 40004., 40005., 40006., 50001., 50002., 50003., 50004., 50005., 50006.} ); const auto policy = Kokkos::RangePolicy(0, number_of_nodes * number_of_simd_nodes); - const auto integrator = IntegrateStiffnessMatrixElement{1U, - number_of_nodes, - number_of_qps, - qp_weights, - qp_jacobian, - shape_interp, - shape_interp_deriv, - qp_Kuu, - qp_Puu, - qp_Cuu, - qp_Ouu, - qp_Quu, - gbl_M}; + const auto integrator = beams::IntegrateStiffnessMatrixElement{1U, + number_of_nodes, + number_of_qps, + qp_weights, + qp_jacobian, + shape_interp, + shape_interp_deriv, + qp_Kuu, + qp_Puu, + qp_Cuu, + qp_Ouu, + qp_Quu, + gbl_M}; Kokkos::parallel_for(policy, integrator); } @@ -305,19 +305,19 @@ void TestIntegrateStiffnessMatrix_1Element2Nodes1QP( auto gbl_M = Kokkos::View("global_M"); const auto policy = Kokkos::RangePolicy(0, number_of_nodes * number_of_simd_nodes); - const auto integrator = IntegrateStiffnessMatrixElement{0U, - number_of_nodes, - number_of_qps, - qp_weights, - qp_jacobian, - shape_interp, - shape_interp_deriv, - qp_Kuu, - qp_Puu, - qp_Cuu, - qp_Ouu, - qp_Quu, - gbl_M}; + const auto integrator = beams::IntegrateStiffnessMatrixElement{0U, + number_of_nodes, + number_of_qps, + qp_weights, + qp_jacobian, + shape_interp, + shape_interp_deriv, + qp_Kuu, + qp_Puu, + qp_Cuu, + qp_Ouu, + qp_Quu, + gbl_M}; Kokkos::parallel_for(policy, integrator); const auto exact_M = @@ -499,19 +499,19 @@ void TestIntegrateStiffnessMatrix_1Element1Node2QPs( auto gbl_M = Kokkos::View("global_M"); const auto policy = Kokkos::RangePolicy(0, number_of_nodes * number_of_simd_nodes); - const auto integrator = IntegrateStiffnessMatrixElement{0U, - number_of_nodes, - number_of_qps, - qp_weights, - qp_jacobian, - shape_interp, - shape_interp_deriv, - qp_Kuu, - qp_Puu, - qp_Cuu, - qp_Ouu, - qp_Quu, - gbl_M}; + const auto integrator = beams::IntegrateStiffnessMatrixElement{0U, + number_of_nodes, + number_of_qps, + qp_weights, + qp_jacobian, + shape_interp, + shape_interp_deriv, + qp_Kuu, + qp_Puu, + qp_Cuu, + qp_Ouu, + qp_Quu, + gbl_M}; Kokkos::parallel_for(policy, integrator); const auto exact_M = diff --git a/tests/unit_tests/system/beams/test_rotate_section_matrix.cpp b/tests/unit_tests/system/beams/test_rotate_section_matrix.cpp index 11d0231dc..e31439260 100644 --- a/tests/unit_tests/system/beams/test_rotate_section_matrix.cpp +++ b/tests/unit_tests/system/beams/test_rotate_section_matrix.cpp @@ -1,3 +1,4 @@ +/* #include #include @@ -45,3 +46,4 @@ TEST(RotateSectionMatrixTests, OneNode) { } } // namespace openturbine::tests +*/ diff --git a/tests/unit_tests/system/beams/test_update_node_state.cpp b/tests/unit_tests/system/beams/test_update_node_state.cpp deleted file mode 100644 index 87fa4a8b6..000000000 --- a/tests/unit_tests/system/beams/test_update_node_state.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include -#include - -#include "system/beams/update_node_state.hpp" - -namespace openturbine::tests { - -inline void CompareInOrder( - const Kokkos::View::host_mirror_type& result, - const Kokkos::View& expected -) { - for (auto j = 0U; j < result.extent(1); ++j) { - EXPECT_EQ(result(0, 0, j), expected(0, j)); - } - for (auto j = 0U; j < result.extent(1); ++j) { - EXPECT_EQ(result(0, 1, j), expected(1, j)); - } -} - -TEST(UpdateNodeStateTests, TwoNodes_InOrder) { - const auto indices = Kokkos::View("node_state_indices"); - constexpr auto indices_data = std::array{0U, 1U}; - const auto indices_host = - Kokkos::View(indices_data.data()); - const auto indices_mirror = Kokkos::create_mirror(indices); - Kokkos::deep_copy(indices_mirror, indices_host); - Kokkos::deep_copy(indices, indices_mirror); - - const auto Q = Kokkos::View("Q"); - constexpr auto Q_data = std::array{1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.}; - const auto Q_host = Kokkos::View(Q_data.data()); - const auto Q_mirror = Kokkos::create_mirror(Q); - Kokkos::deep_copy(Q_mirror, Q_host); - Kokkos::deep_copy(Q, Q_mirror); - - const auto V = Kokkos::View("V"); - constexpr auto V_data = std::array{15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26.}; - const auto V_host = Kokkos::View(V_data.data()); - const auto V_mirror = Kokkos::create_mirror(V); - Kokkos::deep_copy(V_mirror, V_host); - Kokkos::deep_copy(V, V_mirror); - - const auto A = Kokkos::View("A"); - constexpr auto A_data = std::array{27., 28., 29., 30., 31., 32., 33., 34., 35., 36., 37., 38.}; - const auto A_host = Kokkos::View(A_data.data()); - const auto A_mirror = Kokkos::create_mirror(A); - Kokkos::deep_copy(A_mirror, A_host); - Kokkos::deep_copy(A, A_mirror); - - const auto node_u = Kokkos::View("node_u"); - const auto node_u_dot = Kokkos::View("node_u_dot"); - const auto node_u_ddot = Kokkos::View("node_u_ddot"); - - Kokkos::parallel_for( - "UpdateNodeStateElement", 2, - UpdateNodeStateElement{0U, indices, node_u, node_u_dot, node_u_ddot, Q, V, A} - ); - - const auto node_u_mirror = Kokkos::create_mirror(node_u); - Kokkos::deep_copy(node_u_mirror, node_u); - CompareInOrder(node_u_mirror, Q_host); - - const auto node_u_dot_mirror = Kokkos::create_mirror(node_u_dot); - Kokkos::deep_copy(node_u_dot_mirror, node_u_dot); - CompareInOrder(node_u_dot_mirror, V_host); - - const auto node_u_ddot_mirror = Kokkos::create_mirror(node_u_ddot); - Kokkos::deep_copy(node_u_ddot_mirror, node_u_ddot); - CompareInOrder(node_u_ddot_mirror, A_host); -} - -inline void CompareOutOfOrder( - const Kokkos::View::host_mirror_type& result, - const Kokkos::View& expected -) { - for (auto j = 0U; j < result.extent(1); ++j) { - EXPECT_EQ(result(0, 0, j), expected(1, j)); - } - for (auto j = 0U; j < result.extent(1); ++j) { - EXPECT_EQ(result(0, 1, j), expected(0, j)); - } -} - -TEST(UpdateNodeStateTests, TwoNodes_OutOfOrder) { - const auto indices = Kokkos::View("node_state_indices"); - constexpr auto indices_data = std::array{1U, 0U}; - const auto indices_host = - Kokkos::View(indices_data.data()); - const auto indices_mirror = Kokkos::create_mirror(indices); - Kokkos::deep_copy(indices_mirror, indices_host); - Kokkos::deep_copy(indices, indices_mirror); - - const auto Q = Kokkos::View("Q"); - constexpr auto Q_data = std::array{1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.}; - const auto Q_host = Kokkos::View(Q_data.data()); - const auto Q_mirror = Kokkos::create_mirror(Q); - Kokkos::deep_copy(Q_mirror, Q_host); - Kokkos::deep_copy(Q, Q_mirror); - - const auto V = Kokkos::View("V"); - constexpr auto V_data = std::array{15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26.}; - const auto V_host = Kokkos::View(V_data.data()); - const auto V_mirror = Kokkos::create_mirror(V); - Kokkos::deep_copy(V_mirror, V_host); - Kokkos::deep_copy(V, V_mirror); - - const auto A = Kokkos::View("A"); - constexpr auto A_data = std::array{27., 28., 29., 30., 31., 32., 33., 34., 35., 36., 37., 38.}; - const auto A_host = Kokkos::View(A_data.data()); - const auto A_mirror = Kokkos::create_mirror(A); - Kokkos::deep_copy(A_mirror, A_host); - Kokkos::deep_copy(A, A_mirror); - - const auto node_u = Kokkos::View("node_u"); - const auto node_u_dot = Kokkos::View("node_u_dot"); - const auto node_u_ddot = Kokkos::View("node_u_ddot"); - - Kokkos::parallel_for( - "UpdateNodeStateElement", 2, - UpdateNodeStateElement{0U, indices, node_u, node_u_dot, node_u_ddot, Q, V, A} - ); - - const auto node_u_mirror = Kokkos::create_mirror(node_u); - Kokkos::deep_copy(node_u_mirror, node_u); - CompareOutOfOrder(node_u_mirror, Q_host); - - const auto node_u_dot_mirror = Kokkos::create_mirror(node_u_dot); - Kokkos::deep_copy(node_u_dot_mirror, node_u_dot); - CompareOutOfOrder(node_u_dot_mirror, V_host); - - const auto node_u_ddot_mirror = Kokkos::create_mirror(node_u_ddot); - Kokkos::deep_copy(node_u_ddot_mirror, node_u_ddot); - CompareOutOfOrder(node_u_ddot_mirror, A_host); -} - -} // namespace openturbine::tests