Skip to content
Snippets Groups Projects
Commit c5e13607 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

improved symmetry BC's code. Not yet satisfactory.

parent fd010b49
No related branches found
No related tags found
No related merge requests found
...@@ -129,9 +129,10 @@ int main(int argc, char *argv[]) ...@@ -129,9 +129,10 @@ int main(int argc, char *argv[])
std::vector<BoundaryConditionHandler> bc_list; std::vector<BoundaryConditionHandler> bc_list;
{ // quite dirty! { // quite dirty!
SymmetryBoundaryCondition* sym_bc0 SymmetryBoundaryCondition<MeshType::dimension>* sym_bc0
= new SymmetryBoundaryCondition(std::vector<unsigned int>({0u})); = new SymmetryBoundaryCondition<MeshType::dimension>(std::vector<unsigned int>({0u}),
std::shared_ptr<SymmetryBoundaryCondition> bc0(sym_bc0); TinyVector<1>(-1));
std::shared_ptr<SymmetryBoundaryCondition<1>> bc0(sym_bc0);
bc_list.push_back(BoundaryConditionHandler(bc0)); bc_list.push_back(BoundaryConditionHandler(bc0));
PressureBoundaryCondition* pres_bc1 PressureBoundaryCondition* pres_bc1
......
...@@ -174,29 +174,20 @@ private: ...@@ -174,29 +174,20 @@ private:
break; break;
} }
case BoundaryCondition::symmetry: { case BoundaryCondition::symmetry: {
const SymmetryBoundaryCondition& symmetry_bc const SymmetryBoundaryCondition<dimension>& symmetry_bc
= dynamic_cast<const SymmetryBoundaryCondition&>(handler.boundaryCondition()); = dynamic_cast<const SymmetryBoundaryCondition<dimension>&>(handler.boundaryCondition());
const Rdd I = identity;
const Kokkos::View<const unsigned int**> face_cells
= m_connectivity.faceCells();
const Kokkos::View<const unsigned short**> face_cell_local_face
= m_connectivity.faceCellLocalFace();
const Kokkos::View<const Rd**> njr
= m_mesh_data.njr();
Kokkos::parallel_for(symmetry_bc.numberOfFaces(), KOKKOS_LAMBDA(const int& l_number) {
// quite ugly: node/faces are melt in a bad way... at least works in 1d...
const int l = symmetry_bc.faceList()[l_number];
assert(m_connectivity.faceNbCells() == 1);
const unsigned int j = face_cells(l,0);
const unsigned int L = face_cell_local_face(l,0);
const Rd& n = njr(j,L); const Rd& n = symmetry_bc.outgoingNormal();
const Rdd I = identity;
const Rdd nxn = tensorProduct(n,n); const Rdd nxn = tensorProduct(n,n);
const Rdd P = I-nxn; const Rdd P = I-nxn;
m_Ar(l) = P*m_Ar(l)*P + nxn; Kokkos::parallel_for(symmetry_bc.numberOfNodes(), KOKKOS_LAMBDA(const int& r_number) {
m_br(l) = P*m_br(l); const int r = symmetry_bc.nodeList()[r_number];
assert(m_connectivity.nodeNbCells() == 1);
m_Ar(r) = P*m_Ar(r)*P + nxn;
m_br(r) = P*m_br(r);
}); });
break; break;
} }
......
...@@ -72,31 +72,39 @@ public: ...@@ -72,31 +72,39 @@ public:
~PressureBoundaryCondition() = default; ~PressureBoundaryCondition() = default;
}; };
template <size_t dimension>
class SymmetryBoundaryCondition class SymmetryBoundaryCondition
: public BoundaryCondition : public BoundaryCondition
{ {
private: public:
const size_t m_number_of_faces; typedef TinyVector<dimension, double> Rd;
Kokkos::View<unsigned int*> m_face_list;
private:
Kokkos::View<unsigned int*> m_node_list;
const Rd m_outgoing_normal;
public: public:
const size_t& numberOfFaces() const const Rd& outgoingNormal() const
{ {
return m_number_of_faces; return m_outgoing_normal;
}
size_t numberOfNodes() const
{
return m_node_list.size();
} }
const Kokkos::View<const unsigned int*> faceList() const const Kokkos::View<const unsigned int*> nodeList() const
{ {
return m_face_list; return m_node_list;
} }
SymmetryBoundaryCondition(const std::vector<unsigned int>& faces) SymmetryBoundaryCondition(const std::vector<unsigned int>& nodes,
const Rd& outgoing_normal)
: BoundaryCondition(BoundaryCondition::symmetry), : BoundaryCondition(BoundaryCondition::symmetry),
m_number_of_faces(faces.size()), m_node_list("node_list", nodes.size()),
m_face_list("faces_list", m_number_of_faces) m_outgoing_normal(outgoing_normal)
{ {
Kokkos::parallel_for(m_number_of_faces, KOKKOS_LAMBDA(const int& f){ Kokkos::parallel_for(m_node_list.size(), KOKKOS_LAMBDA(const int& f){
m_face_list[f]=faces[f]; m_node_list[f]=nodes[f];
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment