Loading...
Searching...
No Matches
patch_kernel_parallel.tpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2022 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24#if BITPIT_ENABLE_MPI==1
25
26namespace bitpit {
27
40template<typename ExcludeList>
41bool PatchKernel::confirmCellHaloLayer(const Cell &cell, int haloLayer, const ExcludeList &excludeList) const
42{
43 // Search if a face neighbour is in the previous halo layer
44 //
45 // We first search in the face neighbours only, because its faster than
46 // searching among all the neighbours.
47 //
48 // Searching for neighbours in the previous layer works also for ghosts in
49 // the first layer, because inner cells has a layer equal to minus one.
50 const long *adjacencies = cell.getAdjacencies();
51 int nCellAdjacencies = cell.getAdjacencyCount();
52 for (int i = 0; i < nCellAdjacencies; ++i) {
53 long neighId = adjacencies[i];
54 if (excludeList.count(neighId) > 0) {
55 continue;
56 } else if (getCellHaloLayer(neighId) == (haloLayer - 1)) {
57 return true;
58 }
59 }
60
61 // Search if a generic neighbour is in the previous halo layer
62 //
63 // If we haven't found a cell in the previous layer among the face neighbours,
64 // we perform a more expensive search among all the neighbours. a search among
65 // all the neighbours.
66 //
67 // Searching for neighbours in the previous layer works also for ghosts in the
68 // first layer, because inner cells has a layer equal to minus one.
69 std::vector<long> neighIds;
70 findCellNeighs(cell.getId(), &neighIds);
71 for (long neighId : neighIds) {
72 if (excludeList.count(neighId) > 0) {
73 continue;
74 } else if (getCellHaloLayer(neighId) == (haloLayer - 1)) {
75 return true;
76 }
77 }
78
79 // There are no neighbours in the previous halo layer
80 return false;
81}
82
83}
84
85#endif
std::vector< long > findCellNeighs(long id) const
int getCellHaloLayer(long id) const
--- layout: doxygen_footer ---