50 #ifndef PANZER_FACE_TO_ELEMENT_IMPL_HPP
51 #define PANZER_FACE_TO_ELEMENT_IMPL_HPP
66 template <
typename LocalOrdinal,
typename GlobalOrdinal>
72 template <
typename LocalOrdinal,
typename GlobalOrdinal>
79 template <
typename LocalOrdinal,
typename GlobalOrdinal>
85 std::vector<std::string> block_ids;
91 std::vector<shards::CellTopology> ebt;
93 dimension = ebt[0].getDimension();
96 int my_rank = comm->getRank();
98 int nprocs = comm->getSize();
101 std::vector<GlobalOrdinal> element_GIDS;
102 for (
size_t iblk = 0 ; iblk < block_ids.size(); ++iblk) {
105 if ( dimension == 1 ) {
108 }
else if ( dimension == 2 ){
116 const std::vector<LocalOrdinal> &block_elems = conn.
getElementBlock(block_ids[iblk]);
117 for (
size_t i=0; i<block_elems.size(); ++i) {
118 const GlobalOrdinal * connectivity = conn.
getConnectivity(block_elems[i]);
119 element_GIDS.push_back(*connectivity);
128 std::vector<GlobalOrdinal> face_GIDS;
129 std::set<GlobalOrdinal> set_of_face_GIDS;
130 for (
size_t iblk = 0 ; iblk < block_ids.size(); ++iblk) {
133 if ( dimension == 1 ) {
136 }
else if ( dimension == 2 ){
144 const std::vector<LocalOrdinal> &block_elems = conn.
getElementBlock(block_ids[iblk]);
145 for (
size_t i=0; i<block_elems.size(); ++i) {
147 const GlobalOrdinal * connectivity = conn.
getConnectivity(block_elems[i]);
148 for (
int iface=0; iface<n_conn; ++iface)
149 set_of_face_GIDS.insert(connectivity[iface]);
152 face_GIDS.insert(face_GIDS.begin(), set_of_face_GIDS.begin(), set_of_face_GIDS.end());
155 owned_face_map = Tpetra::createOneToOne(face_map);
164 face2elem_mv->putScalar(-1-shift);
165 auto b1 = face2elem_mv->getDataNonConst(0);
166 auto e1 = face2elem_mv->getDataNonConst(1);
167 auto p1 = face2elem_mv->getDataNonConst(2);
168 auto l1 = face2elem_mv->getDataNonConst(3);
169 auto b2 = face2elem_mv->getDataNonConst(4);
170 auto e2 = face2elem_mv->getDataNonConst(5);
171 auto p2 = face2elem_mv->getDataNonConst(6);
172 auto l2 = face2elem_mv->getDataNonConst(7);
174 GlobalOrdinal my_elem = 0;
175 for (
size_t iblk = 0 ; iblk < block_ids.size(); ++iblk) {
178 if ( dimension == 1 ) {
181 }
else if ( dimension == 2 ){
189 const std::vector<LocalOrdinal> &block_elems = conn.
getElementBlock(block_ids[iblk]);
190 for (
size_t i=0; i<block_elems.size(); ++i) {
192 const GlobalOrdinal * connectivity = conn.
getConnectivity(block_elems[i]);
193 for (
int iface=0; iface<n_conn; ++iface) {
194 LocalOrdinal f = face_map->getLocalElement(connectivity[iface]);
200 e1[f] = elem_map->getGlobalElement(my_elem)+shift;
201 p1[f] = my_rank+shift;
203 }
else if (b2[f] < 0){
205 e2[f] = elem_map->getGlobalElement(my_elem)+shift;
206 p2[f] = my_rank+shift;
216 Import imp(owned_face_map, face_map);
217 Export exp(face_map, owned_face_map);
218 owned_face2elem_mv->doExport(*face2elem_mv, exp, Tpetra::ADD);
220 auto ob1 = owned_face2elem_mv->getDataNonConst(0);
221 auto oe1 = owned_face2elem_mv->getDataNonConst(1);
222 auto op1 = owned_face2elem_mv->getDataNonConst(2);
223 auto ol1 = owned_face2elem_mv->getDataNonConst(3);
224 auto ob2 = owned_face2elem_mv->getDataNonConst(4);
225 auto oe2 = owned_face2elem_mv->getDataNonConst(5);
226 auto op2 = owned_face2elem_mv->getDataNonConst(6);
227 auto ol2 = owned_face2elem_mv->getDataNonConst(7);
232 for (
int i=0; i<ob1.size();++i){
235 assert(b1[i] >= shift);
237 LocalOrdinal shared_local_id = face_map->getLocalElement(owned_face_map->getGlobalElement(i));
239 if (ob1[i] == b1[shared_local_id] && ob2[i] == b2[shared_local_id] &&
240 oe1[i] == e1[shared_local_id] && oe2[i] == e2[shared_local_id]) {
247 if (ob1[i] < b1[shared_local_id] || oe1[i] < e1[shared_local_id]) {
251 if ( ob1[i] > b1[shared_local_id] || oe1[i] > e1[shared_local_id]) {
253 assert(ob2[i] < 0 && oe2[i] < 0);
254 ob2[i] = ob1[i] - b1[shared_local_id];
255 oe2[i] = oe1[i] - e1[shared_local_id];
256 op2[i] = op1[i] - p1[shared_local_id];
257 ol2[i] = ol1[i] - l1[shared_local_id];
259 ob1[i] = b1[shared_local_id];
260 oe1[i] = e1[shared_local_id];
261 op1[i] = p1[shared_local_id];
262 ol1[i] = l1[shared_local_id];
264 assert(op1[i] >=0 && op2[i] >= 0 && op1[i] < nprocs+shift && op2[i] < nprocs+shift);
267 face2elem_mv->doImport(*owned_face2elem_mv, imp, Tpetra::REPLACE);
272 face_map_ = face_map;
273 LocalOrdinal nfaces = face_map_->getNodeNumElements();
274 elems_by_face_ = Kokkos::View<GlobalOrdinal *[2]>(
"FaceToElement::elems_by_face_", nfaces);
275 lidx_by_face_ = Kokkos::View<int *[2]>(
"FaceToElement::elems_by_face_", nfaces);
276 blocks_by_face_ = Kokkos::View<int *[2]> (
"FaceToElement::blocks_by_face_", nfaces);
277 procs_by_face_ = Kokkos::View<int *[2]> (
"FaceToElement::procs_by_face_", nfaces);
280 for (LocalOrdinal i=0; i< nfaces; ++i) {
281 elems_by_face_ (i,0) = e1[i]-shift;
282 elems_by_face_ (i,1) = e2[i]-shift;
283 blocks_by_face_(i,0) = b1[i]-shift;
284 blocks_by_face_(i,1) = b2[i]-shift;
285 procs_by_face_ (i,0) = p1[i]-shift;
286 procs_by_face_ (i,1) = p2[i]-shift;
287 lidx_by_face_ (i,0) = l1[i]-shift;
288 lidx_by_face_ (i,1) = l2[i]-shift;
290 if(elems_by_face_ (i,0) < 0){
291 elems_by_face_ (i,0) = -1;
293 if(elems_by_face_ (i,1) < 0){
294 elems_by_face_ (i,1) = -1;
virtual void getElementBlockIds(std::vector< std::string > &elementBlockIds) const =0
Tpetra::Import< LocalOrdinal, GlobalOrdinal, NodeType > Import
virtual void getElementBlockTopologies(std::vector< shards::CellTopology > &elementBlockTopologies) const =0
Tpetra::Map< LocalOrdinal, GlobalOrdinal, NodeType > Map
virtual LocalOrdinal getConnectivitySize(LocalOrdinal localElmtId) const =0
virtual const GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const =0
virtual const std::vector< LocalOrdinal > & getElementBlock(const std::string &blockID) const =0
Tpetra::Export< LocalOrdinal, GlobalOrdinal, NodeType > Export
Tpetra::MultiVector< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, NodeType > GOMultiVector
virtual void buildConnectivity(const FieldPattern &fp)=0
void initialize(panzer::ConnManager< LocalOrdinal, GlobalOrdinal > &conn)