19 #ifndef GEOS_FINITEVOLUME_CELLELEMENTSTENCILTPFA_HPP_
20 #define GEOS_FINITEVOLUME_CELLELEMENTSTENCILTPFA_HPP_
22 #include "StencilBase.hpp"
35 template<
typename VIEWTYPE >
71 real64 ( &dWeight_dVar )[1][2] )
const;
84 real64 ( &dWeight_dVar )[1][2] )
const;
93 real64 ( &stabilizationWeight )[1][2] )
const;
154 localIndex const *
const elementRegionIndices,
155 localIndex const *
const elementSubRegionIndices,
157 real64 const *
const weights,
168 real64 const & geometricStabilizationCoef,
169 real64 const (&faceNormal)[3],
170 real64 const (&cellToFaceVec)[2][3] );
220 real64 (& dWeight_dVar )[1][2] )
const
223 real64 dHalfWeight_dVar[2];
234 dHalfWeight_dVar[i] =
m_weights[iconn][i];
238 LvArray::tensorOps::copy< 3 >( faceNormal, m_faceNormal[iconn] );
239 if( LvArray::tensorOps::AiBi< 3 >( m_cellToFaceVec[iconn][i], faceNormal ) < 0.0 )
241 LvArray::tensorOps::scale< 3 >( faceNormal, -1 );
245 real64 dFaceConormal_dVar[3];
246 LvArray::tensorOps::hadamardProduct< 3 >( faceConormal, coefficient[er][esr][ei][0], faceNormal );
247 LvArray::tensorOps::hadamardProduct< 3 >( dFaceConormal_dVar, dCoeff_dVar[er][esr][ei][0], faceNormal );
248 halfWeight[i] *= LvArray::tensorOps::AiBi< 3 >( m_cellToFaceVec[iconn][i], faceConormal );
249 dHalfWeight_dVar[i] *= LvArray::tensorOps::AiBi< 3 >( m_cellToFaceVec[iconn][i], dFaceConormal_dVar );
252 if( halfWeight[i] < 0.0 )
254 LvArray::tensorOps::hadamardProduct< 3 >( faceConormal,
255 coefficient[er][esr][ei][0],
256 m_cellToFaceVec[iconn][i] );
257 LvArray::tensorOps::hadamardProduct< 3 >( dFaceConormal_dVar,
258 dCoeff_dVar[er][esr][ei][0],
259 m_cellToFaceVec[iconn][i] );
261 dHalfWeight_dVar[i] =
m_weights[iconn][i];
262 halfWeight[i] *= LvArray::tensorOps::AiBi< 3 >( m_cellToFaceVec[iconn][i], faceConormal );
263 dHalfWeight_dVar[i] *= LvArray::tensorOps::AiBi< 3 >( m_cellToFaceVec[iconn][i], dFaceConormal_dVar );
268 real64 const product = halfWeight[0]*halfWeight[1];
269 real64 const sum = halfWeight[0]+halfWeight[1];
271 real64 const harmonicWeight = sum > 0 ? product / sum : 0.0;
272 real64 const arithmeticWeight = sum / 2;
274 real64 dHarmonicWeight_dVar[2];
275 real64 dArithmeticWeight_dVar[2];
277 dHarmonicWeight_dVar[0] = sum > 0 ? (dHalfWeight_dVar[0]*sum*halfWeight[1] - dHalfWeight_dVar[0]*halfWeight[0]*halfWeight[1]) / ( sum*sum ) : 0.0;
278 dHarmonicWeight_dVar[1] = sum > 0 ? (dHalfWeight_dVar[1]*sum*halfWeight[0] - dHalfWeight_dVar[1]*halfWeight[1]*halfWeight[0]) / ( sum*sum ) : 0.0;
280 dArithmeticWeight_dVar[0] = dHalfWeight_dVar[0] / 2;
281 dArithmeticWeight_dVar[1] = dHalfWeight_dVar[1] / 2;
283 real64 const meanPermCoeff = 1.0;
285 real64 const value = meanPermCoeff * harmonicWeight + (1 - meanPermCoeff) * arithmeticWeight;
288 weight[0][ke] = m_transMultiplier[iconn] * value * (ke == 0 ? 1 : -1);
290 real64 const dValue_dVar = meanPermCoeff * dHarmonicWeight_dVar[ke] + (1 - meanPermCoeff) * dArithmeticWeight_dVar[ke];
291 dWeight_dVar[0][ke] = m_transMultiplier[iconn] * dValue_dVar;
300 real64 (& dWeight_dVar )[1][2] )
const
313 LvArray::tensorOps::copy< 3 >( faceNormal, m_faceNormal[iconn] );
315 if( LvArray::tensorOps::AiBi< 3 >( m_cellToFaceVec[iconn][i], faceNormal ) < 0.0 )
317 LvArray::tensorOps::scale< 3 >( faceNormal, -1 );
320 halfWeight[i] *= LvArray::tensorOps::AiBi< 3 >( m_cellToFaceVec[iconn][i], faceNormal );
323 if( halfWeight[i] < 0.0 )
326 halfWeight[i] *= LvArray::tensorOps::AiBi< 3 >( m_cellToFaceVec[iconn][i], m_cellToFaceVec[iconn][i] );
331 real64 const product = halfWeight[0]*halfWeight[1];
332 real64 const sum = halfWeight[0]+halfWeight[1];
334 real64 const harmonicWeight = sum > 0 ? product / sum : 0.0;
335 real64 const arithmeticWeight = sum / 2;
337 real64 const meanPermCoeff = 1.0;
339 real64 const value = meanPermCoeff * harmonicWeight + (1 - meanPermCoeff) * arithmeticWeight;
342 weight[0][ke] = m_transMultiplier[iconn] * value * (ke == 0 ? 1 : -1);
345 dWeight_dVar[0][0] = 0.0;
346 dWeight_dVar[0][1] = 0.0;
353 real64 ( & stabilizationWeight )[1][2] )
const
355 stabilizationWeight[0][0] = m_geometricStabilizationCoef[iconn];
356 stabilizationWeight[0][1] = -m_geometricStabilizationCoef[iconn];
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
#define GEOS_FORCE_INLINE
Marks a function or lambda for inlining.
virtual void add(localIndex const numPts, localIndex const *const elementRegionIndices, localIndex const *const elementSubRegionIndices, localIndex const *const elementIndices, real64 const *const weights, localIndex const connectorIndex) override
Add an entry to the stencil.
virtual localIndex size() const override
Return the stencil size.
constexpr localIndex stencilSize(localIndex index) const
Give the number of points in a stencil entry.
void addVectors(real64 const &transMultiplier, real64 const &geometricStabilizationCoef, real64 const (&faceNormal)[3], real64 const (&cellToFaceVec)[2][3])
Add the vectors need to compute the transmissiblity to the Stencil.
KernelWrapper createKernelWrapper() const
Create an update kernel wrapper.
CellElementStencilTPFA()
Default constructor.
virtual void reserve(localIndex const size) override
Reserve the size of the stencil.
ElementRegionManager::ElementViewConst< VIEWTYPE > CoefficientAccessor
Coefficient view accessory type.
GEOS_HOST_DEVICE GEOS_FORCE_INLINE localIndex stencilSize(localIndex const index) const
Give the number of points in a stencil entry.
GEOS_HOST_DEVICE void computeWeights(localIndex const iconn, CoefficientAccessor< arrayView3d< real64 const > > const &coefficient, CoefficientAccessor< arrayView3d< real64 const > > const &dCoeff_dVar, real64(&weight)[1][2], real64(&dWeight_dVar)[1][2]) const
Compute weights and derivatives w.r.t to one variable.
localIndex size() const
Give the number of stencil entries.
CellElementStencilTPFAWrapper(IndexContainerType const &elementRegionIndices, IndexContainerType const &elementSubRegionIndices, IndexContainerType const &elementIndices, WeightContainerType const &weights, arrayView2d< real64 > const &faceNormal, arrayView3d< real64 > const &cellToFaceVec, arrayView1d< real64 > const &transMultiplier, arrayView1d< real64 > const &geometricStabilizationCoef)
Constructor.
GEOS_HOST_DEVICE GEOS_FORCE_INLINE localIndex numPointsInFlux(localIndex const index) const
Give the number of points between which the flux is.
GEOS_HOST_DEVICE void computeStabilizationWeights(localIndex iconn, real64(&stabilizationWeight)[1][2]) const
Compute the stabilization weights.
typename ElementViewAccessor< VIEWTYPE >::NestedViewTypeConst ElementViewConst
The ElementViewAccessor at the ElementRegionManager level is the type resulting from ElementViewAcces...
Provides management of the interior stencil points when using Two-Point flux approximation.
TRAITS::IndexContainerType m_elementRegionIndices
The container for the element region indices for each point in each stencil.
TRAITS::IndexContainerViewConstType m_elementRegionIndices
The container for the element region indices for each point in each stencil.
TRAITS::IndexContainerViewConstType m_elementSubRegionIndices
The container for the element sub region indices for each point in each stencil.
TRAITS::WeightContainerViewType m_weights
The container for the weights for each point in each stencil.
TRAITS::IndexContainerViewConstType m_elementIndices
The container for the element indices for each point in each stencil.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Array< T, 3, PERMUTATION > array3d
Alias for 3D array.
double real64
64-bit floating point type.
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Array< T, 1 > array1d
Alias for 1D array.
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
CONTAINER< localIndex > IndexContainerType
The array type that will be used to store the indices of the stencil contributors.
static constexpr localIndex maxStencilSize
Maximum number of points in a stencil.
CONTAINER< real64 > WeightContainerType
The array type that is used to store the weights of the stencil contributors.
static constexpr localIndex maxNumPointsInFlux
Maximum number of points the flux.