1 #ifndef VERTEXCFD_MESH_GEOMETRYDATA_HPP
2 #define VERTEXCFD_MESH_GEOMETRYDATA_HPP
4 #include <Panzer_CellData.hpp>
5 #include <Panzer_CommonArrayFactories.hpp>
6 #include <Panzer_STK_Interface.hpp>
7 #include <Panzer_STK_SetupUtilities.hpp>
9 #include <Intrepid2_CellData.hpp>
10 #include <Intrepid2_CellTools_Serial.hpp>
12 #include <Shards_BasicTopologies.hpp>
13 #include <Shards_CellTopology.hpp>
17 #include <Kokkos_Core.hpp>
20 #include <type_traits>
37 std::vector<std::string> walls)
40 std::vector<std::string> sideset_block_names;
41 mesh->getSidesetNames(sideset_block_names);
42 if (sideset_block_names.size() == 0)
45 std::vector<std::string> e_block_names;
46 mesh->getElementBlockNames(e_block_names);
49 for (
long unsigned int block = 0; block < e_block_names.size(); ++block)
51 _topology = mesh->getCellTopology(e_block_names[block]);
52 if (_topology->getKey() != shards::Tetrahedron<4>::key
53 && _topology->getKey() != shards::Hexahedron<8>::key
54 && _topology->getKey() != shards::Triangle<3>::key
55 && _topology->getKey() != shards::Quadrilateral<4>::key)
57 const std::string msg =
"Block topology is not Tet4 or Tri3";
58 throw std::runtime_error(msg);
64 std::vector<stk::mesh::Entity> local_side_entities;
65 for (
const auto& sb : sideset_block_names)
67 for (
long unsigned int i = 0; i < walls.size(); ++i)
71 std::vector<stk::mesh::Entity> sideset_sides;
72 mesh->getMySides(sb, sideset_sides);
73 local_side_entities.insert(std::end(local_side_entities),
74 std::begin(sideset_sides),
75 std::end(sideset_sides));
81 Kokkos::DynRankView<double, PHX::Device> local_sides;
82 mesh->getElementVertices(local_side_entities, local_sides);
85 auto comm = mesh->getComm();
86 MPI_Comm mpi_comm = Teuchos::getRawMpiComm(*comm);
89 const int num_space_dim = _topology->getDimension();
90 const int nodes_per_side
91 = _topology->getVertexCount(num_space_dim - 1, 0);
92 const int side_data_count = nodes_per_side * num_space_dim;
95 std::vector<int> global_counts(comm->getSize(), 0);
97 receive_counts = local_sides.extent(0);
98 MPI_Allgather(&receive_counts,
101 global_counts.data(),
105 std::vector<int> receive_displacements(comm->getSize(), 0);
106 int global_num_side = 0;
107 for (
int r = 0; r < comm->getSize(); ++r)
109 receive_displacements[r] = global_num_side * side_data_count;
110 global_num_side += global_counts[r];
113 for (
int rank = 0; rank < comm->getSize(); ++rank)
115 global_counts[rank] *= side_data_count;
121 _global_sides = Kokkos::View<double***, PHX::Device>(
122 Kokkos::ViewAllocateWithoutInitializing(
"Global side Nodes"),
128 auto local_sides_host = Kokkos::create_mirror_view(local_sides);
129 Kokkos::deep_copy(local_sides_host, local_sides);
130 auto global_sides_host = Kokkos::create_mirror_view(_global_sides);
132 MPI_Allgatherv(local_sides_host.data(),
133 local_sides_host.size(),
135 global_sides_host.data(),
136 global_counts.data(),
137 receive_displacements.data(),
140 Kokkos::deep_copy(_global_sides, global_sides_host);
144 Teuchos::RCP<const shards::CellTopology> topology()
const
150 Kokkos::View<double***, PHX::Device> sides()
const
152 return _global_sides;
157 Teuchos::RCP<const shards::CellTopology> _topology;
160 Kokkos::View<double***, PHX::Device> _global_sides;
167 #endif // end VERTEXCFD_MESH_GEOMETRYDATA