20 #ifndef GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_MIMETICINNERPRODUCTBASE_HPP_
21 #define GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_MIMETICINNERPRODUCTBASE_HPP_
23 #include "codingUtilities/Utilities.hpp"
29 namespace mimeticInnerProduct
86 template< localIndex NF >
95 real64 const (&elemPerm)[ 3 ],
97 real64 const & lengthTolerance,
102 template< localIndex NF >
110 real64 const & elemVolume,
111 real64 const (&elemPerm)[ 3 ],
113 real64 const & lengthTolerance,
116 real64 const areaTolerance = lengthTolerance * lengthTolerance;
117 real64 const weightToleranceInv = 1e30 / lengthTolerance;
119 real64 cellToFaceMat[ NF ][ 3 ] = {{ 0 }};
120 real64 normalsMat[ NF ][ 3 ] = {{ 0 }};
121 real64 permMat[ 3 ][ 3 ] = {{ 0 }};
123 real64 work_dimByNumFaces[ 3 ][ NF ] = {{ 0 }};
124 real64 worka_numFacesByNumFaces[ NF ][ NF ] = {{ 0 }};
125 real64 workb_numFacesByNumFaces[ NF ][ NF ] = {{ 0 }};
126 real64 workc_numFacesByNumFaces[ NF ][ NF ] = {{ 0 }};
128 real64 tpTransInv[ NF ] = { 0.0 };
130 real64 q0[ NF ], q1[ NF ], q2[ NF ];
136 for(
localIndex ifaceLoc = 0; ifaceLoc < NF; ++ifaceLoc )
138 real64 faceCenter[ 3 ], faceNormal[ 3 ], cellToFaceVec[ 3 ];
141 computationalGeometry::centroid_3DPolygon( faceToNodes[elemToFaces[ifaceLoc]],
147 LvArray::tensorOps::copy< 3 >( cellToFaceVec, faceCenter );
148 LvArray::tensorOps::subtract< 3 >( cellToFaceVec, elemCenter );
151 q0[ ifaceLoc ] = cellToFaceVec[0];
152 q1[ ifaceLoc ] = cellToFaceVec[1];
153 q2[ ifaceLoc ] = cellToFaceVec[2];
155 if( LvArray::tensorOps::AiBi< 3 >( cellToFaceVec, faceNormal ) < 0.0 )
157 LvArray::tensorOps::scale< 3 >( faceNormal, -1 );
164 MimeticInnerProductHelpers::computeInvTPFATransWithMultiplier< NF >( elemPerm,
167 transMultiplier[elemToFaces[ifaceLoc]],
171 tpTransInv[ifaceLoc] = diagEntry;
173 LvArray::tensorOps::scale< 3 >( faceNormal, faceArea );
174 normalsMat[ ifaceLoc ][ 0 ] = faceNormal[ 0 ];
175 normalsMat[ ifaceLoc ][ 1 ] = faceNormal[ 1 ];
176 normalsMat[ ifaceLoc ][ 2 ] = faceNormal[ 2 ];
181 LvArray::tensorOps::Rij_eq_AikBjk< 3, NF, 3 >( work_dimByNumFaces,
184 LvArray::tensorOps::Rij_eq_AikBkj< NF, NF, 3 >( transMatrix,
186 work_dimByNumFaces );
189 MimeticInnerProductHelpers::orthonormalize< NF >( q0, q1, q2, cellToFaceMat );
193 LvArray::tensorOps::addIdentity< NF >( worka_numFacesByNumFaces, -1 );
194 LvArray::tensorOps::Rij_add_AikAjk< NF, 3 >( worka_numFacesByNumFaces,
199 real64 const scale = tParam / elemVolume;
202 workb_numFacesByNumFaces[ i ][ i ] = scale * transMatrix[ i ][ i ];
205 LvArray::tensorOps::Rij_eq_AikBkj< NF, NF, NF >( workc_numFacesByNumFaces,
206 workb_numFacesByNumFaces,
207 worka_numFacesByNumFaces );
208 LvArray::tensorOps::scale< NF, NF >( transMatrix, 1 / elemVolume );
209 LvArray::tensorOps::Rij_add_AikBkj< NF, NF, NF >( transMatrix,
210 worka_numFacesByNumFaces,
211 workc_numFacesByNumFaces );
217 if( !isZero( LvArray::tensorOps::l2NormSquared< NF >( tpTransInv ) ) )
219 MimeticInnerProductHelpers::computeTransMatrixWithMultipliers< NF >( tpTransInv,
#define GEOS_HOST_DEVICE
Marks a host-device function.
static GEOS_HOST_DEVICE void computeParametricInnerProduct(arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &nodePosition, arrayView1d< real64 const > const &transMultiplier, ArrayOfArraysView< localIndex const > const &faceToNodes, arraySlice1d< localIndex const > const &elemToFaces, arraySlice1d< real64 const > const &elemCenter, real64 const &elemVolume, real64 const (&elemPerm)[3], real64 const &tParam, real64 const &lengthTolerance, arraySlice2d< real64 > const &transMatrix)
In a given element, recompute the transmissibility matrix using a consistent inner product.
MimeticInnerProductBase(MimeticInnerProductBase const &source)=default
Copy Constructor.
MimeticInnerProductBase & operator=(MimeticInnerProductBase &&)=delete
Deleted move assignment operator.
MimeticInnerProductBase & operator=(MimeticInnerProductBase const &)=delete
Deleted copy assignment operator.
virtual ~MimeticInnerProductBase()=default
Destructor.
MimeticInnerProductBase(MimeticInnerProductBase &&)=default
Default Move constructor.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
LvArray::ArrayOfArraysView< T, INDEX_TYPE const, CONST_SIZES, LvArray::ChaiBuffer > ArrayOfArraysView
View of array of variable-sized arrays. See LvArray::ArrayOfArraysView for details.
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
static GEOS_HOST_DEVICE void makeFullTensor(real64 const (&values)[3], real64(&result)[3][3])
Create a full tensor from an array.