GEOSX
ImplicitKernelBase.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 #include "KernelBase.hpp"
16 
21 #ifndef GEOS_FINITEELEMENT_IMPLICITKERNELBASE_HPP_
22 #define GEOS_FINITEELEMENT_IMPLICITKERNELBASE_HPP_
23 
24 
25 
26 namespace geos
27 {
28 
29 namespace finiteElement
30 {
31 
32 //*****************************************************************************
33 //*****************************************************************************
34 //*****************************************************************************
45 template< typename SUBREGION_TYPE,
46  typename CONSTITUTIVE_TYPE,
47  typename FE_TYPE,
48  int NUM_DOF_PER_TEST_SP,
49  int NUM_DOF_PER_TRIAL_SP >
50 class ImplicitKernelBase : public KernelBase< SUBREGION_TYPE,
51  CONSTITUTIVE_TYPE,
52  FE_TYPE,
53  NUM_DOF_PER_TEST_SP,
54  NUM_DOF_PER_TRIAL_SP >
55 {
56 public:
58  using Base = KernelBase< SUBREGION_TYPE,
59  CONSTITUTIVE_TYPE,
60  FE_TYPE,
61  NUM_DOF_PER_TEST_SP,
62  NUM_DOF_PER_TRIAL_SP >;
63 
70 
71 
85  ImplicitKernelBase( NodeManager const & nodeManager,
86  EdgeManager const & edgeManager,
87  FaceManager const & faceManager,
88  localIndex const targetRegionIndex,
89  SUBREGION_TYPE const & elementSubRegion,
90  FE_TYPE const & finiteElementSpace,
91  CONSTITUTIVE_TYPE & inputConstitutiveType,
92  arrayView1d< globalIndex const > const & inputDofNumber,
93  globalIndex const rankOffset,
95  arrayView1d< real64 > const & inputRhs,
96  real64 const inputDt ):
97  Base( elementSubRegion,
98  finiteElementSpace,
99  inputConstitutiveType ),
100  m_dofNumber( inputDofNumber ),
101  m_dofRankOffset( rankOffset ),
102  m_matrix( inputMatrix ),
103  m_rhs( inputRhs ),
104  m_dt( inputDt )
105  {
106  FiniteElementBase::initialize< FE_TYPE >( nodeManager,
107  edgeManager,
108  faceManager,
109  elementSubRegion,
110  m_meshData );
111  GEOS_UNUSED_VAR( targetRegionIndex );
112  }
113 
114 
115  //***************************************************************************
120  {
123 
126 
132  localRowDofIndex{ 0 },
133  localColDofIndex{ 0 },
134  localResidual{ 0.0 },
135  localJacobian{ {0.0} }
136  {
137  for( int ii = 0; ii < maxNumRows; ++ii )
138  {
139  for( int jj = 0; jj < maxNumCols; ++jj )
140  {
141  localJacobian[ii][jj] = 0.0;
142  }
143  }
144  }
145 
148 
151 
153  globalIndex localRowDofIndex[maxNumRows];
154 
156  globalIndex localColDofIndex[maxNumCols];
157 
159  real64 localResidual[maxNumRows];
160 
162  real64 localJacobian[maxNumRows][maxNumCols];
163 
165  typename FE_TYPE::StackVariables feStack;
166  };
167  //***************************************************************************
168 
181  inline
182  void setup( localIndex const k,
183  StackVariables & stack ) const
184  {
185  m_finiteElementSpace.template setup< FE_TYPE >( k, m_meshData, stack.feStack );
186  localIndex numTestSupportPoints = m_finiteElementSpace.template numSupportPoints< FE_TYPE >( stack.feStack );
187  localIndex numTrialSupportPoints = numTestSupportPoints;
188  stack.numRows = numTestSupportPoints * numDofPerTestSupportPoint;
189  stack.numCols = numTrialSupportPoints * numDofPerTrialSupportPoint;
190  for( localIndex a=0; a<numTestSupportPoints; ++a )
191  {
192  localIndex const localNodeIndex = m_elemsToNodes[k][a];
193  for( int i=0; i<numDofPerTestSupportPoint; ++i )
194  {
195  stack.localRowDofIndex[a*numDofPerTestSupportPoint+i] = m_dofNumber[localNodeIndex]+i;
196  }
197  }
198 
199  for( localIndex a=0; a<numTrialSupportPoints; ++a )
200  {
201  localIndex const localNodeIndex = m_elemsToNodes[k][a];
202  for( int i=0; i<numDofPerTrialSupportPoint; ++i )
203  {
204  stack.localColDofIndex[a*numDofPerTrialSupportPoint+i] = m_dofNumber[localNodeIndex]+i;
205  }
206  }
207  }
208 
209 
210 protected:
213 
216 
219 
222 
224  typename FE_TYPE::template MeshData< SUBREGION_TYPE > m_meshData;
225 
227  real64 const m_dt;
228 
229 };
230 
231 }
232 }
233 
234 
235 
236 #endif /* GEOS_FINITEELEMENT_IMPLICITKERNELBASE_HPP_ */
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:48
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:83
This class provides an interface to ObjectManagerBase in order to manage edge data.
Definition: EdgeManager.hpp:42
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
Definition: FaceManager.hpp:43
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:45
Define the base interface for implicit finite element kernels.
globalIndex const m_dofRankOffset
The global rank offset.
CRSMatrixView< real64, globalIndex const > const m_matrix
The global Jacobian matrix.
FE_TYPE::template MeshData< SUBREGION_TYPE > m_meshData
Data structure containing mesh data used to setup the finite element.
static constexpr int numDofPerTestSupportPoint
Definition: KernelBase.hpp:98
ImplicitKernelBase(NodeManager const &nodeManager, EdgeManager const &edgeManager, FaceManager const &faceManager, localIndex const targetRegionIndex, SUBREGION_TYPE const &elementSubRegion, FE_TYPE const &finiteElementSpace, CONSTITUTIVE_TYPE &inputConstitutiveType, arrayView1d< globalIndex const > const &inputDofNumber, globalIndex const rankOffset, CRSMatrixView< real64, globalIndex const > const &inputMatrix, arrayView1d< real64 > const &inputRhs, real64 const inputDt)
Constructor.
static constexpr int numDofPerTrialSupportPoint
Definition: KernelBase.hpp:102
GEOS_HOST_DEVICE void setup(localIndex const k, StackVariables &stack) const
Performs the setup phase for the kernel.
arrayView1d< globalIndex const > const m_dofNumber
The global degree of freedom number.
static constexpr int maxNumTrialSupportPointsPerElem
Definition: KernelBase.hpp:94
static constexpr int maxNumTestSupportPointsPerElem
Definition: KernelBase.hpp:90
arrayView1d< real64 > const m_rhs
The global residaul vector.
Define the base interface for finite element kernels.
Definition: KernelBase.hpp:86
traits::ViewTypeConst< typename SUBREGION_TYPE::NodeMapType::base_type > const m_elemsToNodes
The element to nodes map.
Definition: KernelBase.hpp:256
static constexpr int numDofPerTestSupportPoint
Definition: KernelBase.hpp:98
static constexpr int numDofPerTrialSupportPoint
Definition: KernelBase.hpp:102
static constexpr int maxNumTrialSupportPointsPerElem
Definition: KernelBase.hpp:94
FE_TYPE const & m_finiteElementSpace
Definition: KernelBase.hpp:267
static constexpr int maxNumTestSupportPointsPerElem
Definition: KernelBase.hpp:90
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:220
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:350
double real64
64-bit floating point type.
Definition: DataTypes.hpp:139
GEOSX_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:128
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
localIndex numCols
The actual number of columns in the element local jacobian matrix (<= maxNumCols).
real64 localJacobian[maxNumRows][maxNumCols]
C-array storage for the element local Jacobian matrix.
globalIndex localRowDofIndex[maxNumRows]
C-array storage for the element local row degrees of freedom.
globalIndex localColDofIndex[maxNumCols]
C-array storage for the element local column degrees of freedom.
FE_TYPE::StackVariables feStack
Stack variables needed for the underlying FEM type.
static constexpr int maxNumRows
The number of rows in the pre-allocated element local jacobian matrix (upper bound for numRows).
real64 localResidual[maxNumRows]
C-array storage for the element local residual vector.
static constexpr int maxNumCols
The number of columns in the pre-allocated element local jacobian matrix (upper bound for numCols).
localIndex numRows
The actual number of rows in the element local jacobian matrix (<= maxNumRows).
Kernel variables allocated on the stack.
Definition: KernelBase.hpp:136