GEOS
CIcomputationKernel.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 
16 
20 #ifndef GEOS_MESH_UTILITIES_CICOMPUTATIONKERNEL_HPP_
21 #define GEOS_MESH_UTILITIES_CICOMPUTATIONKERNEL_HPP_
22 
23 #include "common/DataTypes.hpp"
24 #include "common/TimingMacros.hpp"
25 #include "finiteElement/FiniteElementDispatch.hpp"
26 #include "common/GEOS_RAJA_Interface.hpp"
28 #include "mesh/CellElementSubRegion.hpp"
29 #include "mesh/ElementType.hpp"
30 
31 
32 namespace geos
33 {
34 
40 template< typename FE_TYPE >
42 {
43 public:
52  CIcomputationKernel( FE_TYPE const & finiteElementSpace,
53  NodeManager const & nodeManager,
54  CellElementSubRegion const & elementSubRegion,
55  EmbeddedSurfaceSubRegion & embeddedSurfSubRegion ):
56  m_finiteElementSpace( finiteElementSpace ),
57  m_elementType( elementSubRegion.getElementType() ),
58  m_X( nodeManager.referencePosition() ),
59  m_elemsToNodes( elementSubRegion.nodeList().toViewConst() ),
60  m_fracturedElems( elementSubRegion.fracturedElementsList().toViewConst()),
61  m_cellsToEmbeddedSurfaces( elementSubRegion.embeddedSurfacesList().toViewConst() ),
62  m_normalVector( embeddedSurfSubRegion.getNormalVector().toViewConst()),
63  m_fracCenter( embeddedSurfSubRegion.getElementCenter().toViewConst()),
64  m_fractureSurfaceArea( embeddedSurfSubRegion.getElementArea().toViewConst() ),
65  m_connectivityIndex( embeddedSurfSubRegion.getConnectivityIndex() )
66  {}
67 
69  static constexpr int numNodesPerElem = FE_TYPE::maxSupportPoints;
70 
72  static constexpr int numSamplingPoints = FE_TYPE::numSamplingPoints;
73 
79  {
80 public:
81 
85  xLocal(),
87  {}
88 
91 
94  };
95 
103  template< typename POLICY,
104  typename KERNEL_TYPE >
105  static
106  void launchCIComputationKernel( KERNEL_TYPE & kernelComponent )
107  {
109  forAll< POLICY >( kernelComponent.m_fracturedElems.size(),
110  [=] GEOS_HOST_DEVICE ( localIndex const i )
111  {
112 
113  localIndex k = kernelComponent.m_fracturedElems[i];
114 
115  StackVariables stack;
116  kernelComponent.setup( k, stack );
117 
118  real64 averageDistance = 0.0;
119  for( integer np=0; np<numSamplingPoints; ++np )
120  {
121  kernelComponent.samplingPointCoord( np, stack );
122  averageDistance += kernelComponent.computeDistance( k, stack.samplingPointCoord );
123  }
124  averageDistance /= numSamplingPoints;
125  kernelComponent.setConnectivityIndex( k, averageDistance );
126  } );
127  }
128 
136  void setup( localIndex const k,
137  StackVariables & stack ) const
138  {
139  for( localIndex a=0; a<numNodesPerElem; ++a )
140  {
141  localIndex const localNodeIndex = m_elemsToNodes( k, a );
142 
143  for( int i=0; i<3; ++i )
144  {
145  stack.xLocal[ a ][ i ] = m_X[ localNodeIndex ][ i ];
146  }
147  }
148  }
149 
159  real64 const (&point)[3] ) const
160  {
161  localIndex const embSurfIndex = m_cellsToEmbeddedSurfaces[k][0];
162  real64 pointToFracCenter[3];
163  LvArray::tensorOps::copy< 3 >( pointToFracCenter, point );
164  LvArray::tensorOps::subtract< 3 >( pointToFracCenter, m_fracCenter[embSurfIndex] );
165  return LvArray::math::abs( LvArray::tensorOps::AiBi< 3 >( pointToFracCenter, m_normalVector[embSurfIndex] ));
166  }
167 
175  void samplingPointCoord( integer const np,
176  StackVariables & stack ) const
177  {
178  // Get sampling point coord in parent space.
179  real64 parentSamplingPointCoord[3] = {0.0, 0.0, 0.0};
180  FE_TYPE::getSamplingPointCoordInParentSpace( np, parentSamplingPointCoord );
181 
182  // Compute shape function values at sampling point
184  FE_TYPE::calcN( parentSamplingPointCoord, N );
185 
186  LvArray::tensorOps::fill< 3 >( stack.samplingPointCoord, 0.0 );
187 
188  // Compute sampling point coord in the physical space
189  for( localIndex a=0; a<numNodesPerElem; a++ )
190  {
191  for( int i =0; i < 3; i++ )
192  {
193  stack.samplingPointCoord[i] += stack.xLocal[a][i] * N[a];
194  }
195  }
196  }
197 
206  real64 const averageDistance ) const
207  {
208  localIndex const embSurfIndex = m_cellsToEmbeddedSurfaces[k][0];
209  m_connectivityIndex[embSurfIndex] = 2. * m_fractureSurfaceArea[embSurfIndex] / averageDistance;
210  }
211 
212 private:
213 
215  FE_TYPE const & m_finiteElementSpace;
216 
218  ElementType const m_elementType;
219 
222 
224  traits::ViewTypeConst< typename CellElementSubRegion::NodeMapType::base_type > const m_elemsToNodes;
225 
227  SortedArrayView< localIndex const > const m_fracturedElems;
228 
230  ArrayOfArraysView< localIndex const > const m_cellsToEmbeddedSurfaces;
231 
233  arrayView2d< real64 const > const m_normalVector;
234 
236  arrayView2d< real64 const > const m_fracCenter;
237 
239  arrayView1d< real64 const > const m_fractureSurfaceArea;
240 
242  arrayView1d< real64 > const m_connectivityIndex;
243 };
244 
245 }
246 
247 #endif /* GEOS_MESH_UTILITIES_CICOMPUTATIONKERNEL_HPP_ */
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
Kernel to compute EDFM connectivity index.
static constexpr int numNodesPerElem
number of nodes per element
GEOS_HOST_DEVICE void setConnectivityIndex(localIndex const k, real64 const averageDistance) const
Set the Connectivity Index.
static void launchCIComputationKernel(KERNEL_TYPE &kernelComponent)
launch of CI calculation
CIcomputationKernel(FE_TYPE const &finiteElementSpace, NodeManager const &nodeManager, CellElementSubRegion const &elementSubRegion, EmbeddedSurfaceSubRegion &embeddedSurfSubRegion)
Construct a new CIcomputationKernel object.
GEOS_HOST_DEVICE void setup(localIndex const k, StackVariables &stack) const
set up the kernel object by copying global values in the stack.
GEOS_HOST_DEVICE real64 computeDistance(localIndex const k, real64 const (&point)[3]) const
computes the distance between a point inside the element and the cut surface k.
static constexpr int numSamplingPoints
number of sampling points per element
GEOS_HOST_DEVICE void samplingPointCoord(integer const np, StackVariables &stack) const
computes coordinates of the sampling point in the physical space.
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:46
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:180
LvArray::ArrayOfArraysView< T, INDEX_TYPE const, CONST_SIZES, LvArray::ChaiBuffer > ArrayOfArraysView
View of array of variable-sized arrays. See LvArray::ArrayOfArraysView for details.
Definition: DataTypes.hpp:286
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
ElementType
Denotes type of cell/element shape.
Definition: ElementType.hpp:32
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
real64 xLocal[numNodesPerElem][3]
C-array stack storage for element local the nodal positions.
GEOS_HOST_DEVICE StackVariables()
Constructor.
real64 samplingPointCoord[3]
C-array stack storage for sampling points coordinates.