From 644d428771eece2bc0f789f28e2b788a3c09493f Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Wed, 18 Apr 2018 18:35:34 +0200 Subject: [PATCH] begining of BC externalization --- src/main.cpp | 12 +++++++ src/mesh/Mesh.hpp | 1 + src/scheme/AcousticSolver.hpp | 10 +++--- src/scheme/BoundaryCondition.hpp | 60 ++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 src/scheme/BoundaryCondition.hpp diff --git a/src/main.cpp b/src/main.cpp index cf56b5daa..c4ff74d54 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,7 @@ #include <Connectivity1D.hpp> #include <Mesh.hpp> +#include <BoundaryCondition.hpp> #include <AcousticSolver.hpp> #include <TinyVector.hpp> @@ -125,6 +126,17 @@ int main(int argc, char *argv[]) MeshType mesh(connectivity); MeshDataType mesh_data(mesh); + + std::vector<FacesBoundaryCondition> faces_bc_list; + { // quite dirty! + FacesBoundaryCondition bc0(FacesBoundaryCondition::symmetry, 0, + std::vector<unsigned int>({0u})); + faces_bc_list.push_back(bc0); + FacesBoundaryCondition bc1(FacesBoundaryCondition::symmetry, 0, + std::vector<unsigned int>({static_cast<unsigned int>(mesh.numberOfCells())})); + faces_bc_list.push_back(bc1); + } + UnknownsType unknowns(mesh_data); unknowns.initializeSod(); diff --git a/src/mesh/Mesh.hpp b/src/mesh/Mesh.hpp index cf199a9d5..53b593c78 100644 --- a/src/mesh/Mesh.hpp +++ b/src/mesh/Mesh.hpp @@ -43,6 +43,7 @@ public: return m_xr; } + KOKKOS_INLINE_FUNCTION Mesh(const Connectivity& connectivity) : m_connectivity(connectivity), m_xr("xr", connectivity.numberOfNodes()) diff --git a/src/scheme/AcousticSolver.hpp b/src/scheme/AcousticSolver.hpp index 6c6fcdeae..1889f9f83 100644 --- a/src/scheme/AcousticSolver.hpp +++ b/src/scheme/AcousticSolver.hpp @@ -40,17 +40,17 @@ private: typedef Kokkos::View<const double*>::size_type size_type; - KOKKOS_INLINE_FUNCTION void - operator() (const size_type i, value_type& update) const + KOKKOS_INLINE_FUNCTION + void operator() (const size_type i, value_type& update) const { if (x_(i) < update) { update = x_(i); } } - KOKKOS_INLINE_FUNCTION void - join (volatile value_type& dst, - const volatile value_type& src) const + KOKKOS_INLINE_FUNCTION + void join (volatile value_type& dst, + const volatile value_type& src) const { if (src < dst) { dst = src; diff --git a/src/scheme/BoundaryCondition.hpp b/src/scheme/BoundaryCondition.hpp new file mode 100644 index 000000000..17186a72b --- /dev/null +++ b/src/scheme/BoundaryCondition.hpp @@ -0,0 +1,60 @@ +#ifndef FACES_BOUNDARY_CONDITION_HPP +#define FACES_BOUNDARY_CONDITION_HPP + +#include <vector> + +class FacesBoundaryCondition +{ +public: + enum Type + { + velocity, + normal_velocity, + pressure, + symmetry + }; + +private: + const Type m_type; + const double m_value; + const size_t m_number_of_faces; + Kokkos::View<unsigned int*> m_face_list; + +public: + const size_t& numberOfFaces() const + { + return m_number_of_faces; + } + + const Kokkos::View<const unsigned int*> faceList() const + { + return m_face_list; + } + + const Type& type() const + { + return m_type; + } + + double value() const + { + return m_value; + } + + KOKKOS_INLINE_FUNCTION + FacesBoundaryCondition(const Type& type, + const double& value, + const std::vector<unsigned int>& faces) + : m_type(type), + m_value(value), + m_number_of_faces(faces.size()), + m_face_list("face_list", m_number_of_faces) + { + Kokkos::parallel_for(m_number_of_faces, KOKKOS_LAMBDA(const int& f){ + m_face_list[f]=faces[f]; + }); + } + ~FacesBoundaryCondition() = default; +}; + +#endif // FACES_BOUNDARY_CONDITION_HPP -- GitLab