GEOS
HybridFVMHelperKernels.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 Total, S.A
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_HYBRIDFVMHELPERKERNELS_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_HYBRIDFVMHELPERKERNELS_HPP
22 
23 #include "common/DataTypes.hpp"
24 
25 namespace geos
26 {
27 
28 namespace hybridFVMKernels
29 {
30 
31 
32 /******************************** CellConnectivity ********************************/
33 
35 {
36 
38  static bool
39  isNeighborFound( localIndex const (&localIds)[3],
40  localIndex const ifaceLoc,
41  arrayView2d< localIndex const > const & elemRegionList,
42  arrayView2d< localIndex const > const & elemSubRegionList,
43  arrayView2d< localIndex const > const & elemList,
44  SortedArrayView< localIndex const > const & regionFilter,
45  arraySlice1d< localIndex const > const & elemToFaces,
46  localIndex ( & neighborIds )[3] )
47  {
48  neighborIds[0] = localIds[0];
49  neighborIds[1] = localIds[1];
50  neighborIds[2] = localIds[2];
51 
52  // the face has at most two adjacent elements
53  // one of these two elements is the current element indexed by er, esr, ei
54  // but here we are interested in the indices of the other element
55  // this other element is "the neighbor" for this one-sided face
56  for( localIndex k=0; k<elemRegionList.size( 1 ); ++k )
57  {
58 
59  localIndex const erNeighbor = elemRegionList[elemToFaces[ifaceLoc]][k];
60  localIndex const esrNeighbor = elemSubRegionList[elemToFaces[ifaceLoc]][k];
61  localIndex const eiNeighbor = elemList[elemToFaces[ifaceLoc]][k];
62 
63  // this element is not the current element
64  // we have found the neighbor or we are at the boundary
65  if( erNeighbor != localIds[0] || esrNeighbor != localIds[1] || eiNeighbor != localIds[2] )
66  {
67  bool const onBoundary = (erNeighbor == -1 || esrNeighbor == -1 || eiNeighbor == -1);
68  bool const neighborInTarget = regionFilter.contains( erNeighbor );
69 
70  // if not on boundary, save the element indices
71  if( !onBoundary && neighborInTarget )
72  {
73  neighborIds[0] = erNeighbor;
74  neighborIds[1] = esrNeighbor;
75  neighborIds[2] = eiNeighbor;
76  }
77  // if the face is on the boundary, use the properties of the local elem
78  }
79  }
80  return !( localIds[0] == neighborIds[0] &&
81  localIds[1] == neighborIds[1] &&
82  localIds[2] == neighborIds[2] );
83  }
84 
85 };
86 
87 
88 } // namespace hybridFVMUpwindingKernels
89 
90 } // namespace geos
91 
92 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_HYBRIDFVMHELPERKERNELS_HPP
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
Definition: DataTypes.hpp:184
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Definition: DataTypes.hpp:271
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:196