GEOSX
CIcomputationKernel.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 TotalEnergies
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
15 
19 #ifndef GEOS_MESH_UTILITIES_CICOMPUTATIONKERNEL_HPP_
20 #define GEOS_MESH_UTILITIES_CICOMPUTATIONKERNEL_HPP_
21 
22 #include "common/DataTypes.hpp"
23 #include "common/TimingMacros.hpp"
24 #include "finiteElement/FiniteElementDispatch.hpp"
25 #include "common/GEOS_RAJA_Interface.hpp"
27 #include "mesh/CellElementSubRegion.hpp"
28 #include "mesh/ElementType.hpp"
29 
30 
31 namespace geos
32 {
33 
39 template< typename FE_TYPE >
41 {
42 public:
51  CIcomputationKernel( FE_TYPE const & finiteElementSpace,
52  NodeManager const & nodeManager,
53  CellElementSubRegion const & elementSubRegion,
54  EmbeddedSurfaceSubRegion & embeddedSurfSubRegion ):
55  m_finiteElementSpace( finiteElementSpace ),
56  m_elementType( elementSubRegion.getElementType() ),
57  m_X( nodeManager.referencePosition() ),
58  m_elemsToNodes( elementSubRegion.nodeList().toViewConst() ),
59  m_fracturedElems( elementSubRegion.fracturedElementsList().toViewConst()),
60  m_cellsToEmbeddedSurfaces( elementSubRegion.embeddedSurfacesList().toViewConst() ),
61  m_normalVector( embeddedSurfSubRegion.getNormalVector().toViewConst()),
62  m_fracCenter( embeddedSurfSubRegion.getElementCenter().toViewConst()),
63  m_fractureSurfaceArea( embeddedSurfSubRegion.getElementArea().toViewConst() ),
64  m_connectivityIndex( embeddedSurfSubRegion.getConnectivityIndex() )
65  {}
66 
68  static constexpr int numNodesPerElem = FE_TYPE::maxSupportPoints;
69 
71  static constexpr int numSamplingPoints = FE_TYPE::numSamplingPoints;
72 
78  {
79 public:
80 
84  xLocal(),
86  {}
87 
90 
93  };
94 
102  template< typename POLICY,
103  typename KERNEL_TYPE >
104  static
105  void launchCIComputationKernel( KERNEL_TYPE & kernelComponent )
106  {
108  forAll< POLICY >( kernelComponent.m_fracturedElems.size(),
109  [=] GEOS_HOST_DEVICE ( localIndex const i )
110  {
111 
112  localIndex k = kernelComponent.m_fracturedElems[i];
113 
114  StackVariables stack;
115  kernelComponent.setup( k, stack );
116 
117  real64 averageDistance = 0.0;
118  for( integer np=0; np<numSamplingPoints; ++np )
119  {
120  kernelComponent.samplingPointCoord( np, stack );
121  averageDistance += kernelComponent.computeDistance( k, stack.samplingPointCoord );
122  }
123  averageDistance /= numSamplingPoints;
124  kernelComponent.setConnectivityIndex( k, averageDistance );
125  } );
126  }
127 
135  void setup( localIndex const k,
136  StackVariables & stack ) const
137  {
138  for( localIndex a=0; a<numNodesPerElem; ++a )
139  {
140  localIndex const localNodeIndex = m_elemsToNodes( k, a );
141 
142  for( int i=0; i<3; ++i )
143  {
144  stack.xLocal[ a ][ i ] = m_X[ localNodeIndex ][ i ];
145  }
146  }
147  }
148 
158  real64 const (&point)[3] ) const
159  {
160  localIndex const embSurfIndex = m_cellsToEmbeddedSurfaces[k][0];
161  real64 pointToFracCenter[3];
162  LvArray::tensorOps::copy< 3 >( pointToFracCenter, point );
163  LvArray::tensorOps::subtract< 3 >( pointToFracCenter, m_fracCenter[embSurfIndex] );
164  return LvArray::math::abs( LvArray::tensorOps::AiBi< 3 >( pointToFracCenter, m_normalVector[embSurfIndex] ));
165  }
166 
174  void samplingPointCoord( integer const np,
175  StackVariables & stack ) const
176  {
177  // Get sampling point coord in parent space.
178  real64 parentSamplingPointCoord[3] = {0.0, 0.0, 0.0};
179  FE_TYPE::getSamplingPointCoordInParentSpace( np, parentSamplingPointCoord );
180 
181  // Compute shape function values at sampling point
183  FE_TYPE::calcN( parentSamplingPointCoord, N );
184 
185  LvArray::tensorOps::fill< 3 >( stack.samplingPointCoord, 0.0 );
186 
187  // Compute sampling point coord in the physical space
188  for( localIndex a=0; a<numNodesPerElem; a++ )
189  {
190  for( int i =0; i < 3; i++ )
191  {
192  stack.samplingPointCoord[i] += stack.xLocal[a][i] * N[a];
193  }
194  }
195  }
196 
205  real64 const averageDistance ) const
206  {
207  localIndex const embSurfIndex = m_cellsToEmbeddedSurfaces[k][0];
208  m_connectivityIndex[embSurfIndex] = 2. * m_fractureSurfaceArea[embSurfIndex] / averageDistance;
209  }
210 
211 private:
212 
214  FE_TYPE const & m_finiteElementSpace;
215 
217  ElementType const m_elementType;
218 
221 
223  traits::ViewTypeConst< typename CellElementSubRegion::NodeMapType::base_type > const m_elemsToNodes;
224 
226  SortedArrayView< localIndex const > const m_fracturedElems;
227 
229  ArrayOfArraysView< localIndex const > const m_cellsToEmbeddedSurfaces;
230 
232  arrayView2d< real64 const > const m_normalVector;
233 
235  arrayView2d< real64 const > const m_fracCenter;
236 
238  arrayView1d< real64 const > const m_fractureSurfaceArea;
239 
241  arrayView1d< real64 > const m_connectivityIndex;
242 };
243 
244 }
245 
246 #endif /* GEOS_MESH_UTILITIES_CICOMPUTATIONKERNEL_HPP_ */
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:48
#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:45
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:220
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:326
double real64
64-bit floating point type.
Definition: DataTypes.hpp:139
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
ElementType
Denotes type of cell/element shape.
Definition: ElementType.hpp:31
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Definition: DataTypes.hpp:311
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:236
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
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.