20 #ifndef GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_SIMPLEINNERPRODUCT_HPP_
21 #define GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_SIMPLEINNERPRODUCT_HPP_
29 namespace mimeticInnerProduct
55 template< localIndex NF >
64 real64 const (&elemPerm)[ 3 ],
65 real64 const & lengthTolerance,
70 template< localIndex NF >
79 real64 const (&elemPerm)[ 3 ],
80 real64 const & lengthTolerance,
83 real64 const areaTolerance = lengthTolerance * lengthTolerance;
84 real64 const weightToleranceInv = 1e30 / lengthTolerance;
86 real64 cellToFaceMat[ NF ][ 3 ] = {{ 0 }};
87 real64 normalsMat[ NF ][ 3 ] = {{ 0 }};
88 real64 permMat[ 3 ][ 3 ] = {{ 0 }};
90 real64 work_dimByNumFaces[ 3 ][ NF ] = {{ 0 }};
91 real64 worka_numFacesByNumFaces[ NF ][ NF ] = {{ 0 }};
92 real64 workb_numFacesByNumFaces[ NF ][ NF ] = {{ 0 }};
93 real64 workc_numFacesByNumFaces[ NF ][ NF ] = {{ 0 }};
95 real64 tpTransInv[ NF ] = { 0.0 };
97 real64 q0[ NF ], q1[ NF ], q2[ NF ];
105 for(
localIndex ifaceLoc = 0; ifaceLoc < NF; ++ifaceLoc )
107 real64 faceCenter[ 3 ], faceNormal[ 3 ], cellToFaceVec[ 3 ];
109 faceArea[ ifaceLoc ] =
110 computationalGeometry::centroid_3DPolygon( faceToNodes[elemToFaces[ifaceLoc]],
116 LvArray::tensorOps::copy< 3 >( cellToFaceVec, faceCenter );
117 LvArray::tensorOps::subtract< 3 >( cellToFaceVec, elemCenter );
119 q0[ ifaceLoc ] = faceArea[ ifaceLoc ] * cellToFaceVec[ 0 ];
120 q1[ ifaceLoc ] = faceArea[ ifaceLoc ] * cellToFaceVec[ 1 ];
121 q2[ ifaceLoc ] = faceArea[ ifaceLoc ] * cellToFaceVec[ 2 ];
123 if( LvArray::tensorOps::AiBi< 3 >( cellToFaceVec, faceNormal ) < 0.0 )
125 LvArray::tensorOps::scale< 3 >( faceNormal, -1 );
132 MimeticInnerProductHelpers::computeInvTPFATransWithMultiplier< NF >( elemPerm,
135 transMultiplier[elemToFaces[ifaceLoc]],
139 tpTransInv[ifaceLoc] = diagEntry;
141 LvArray::tensorOps::scale< 3 >( faceNormal, faceArea[ ifaceLoc ] );
142 normalsMat[ ifaceLoc ][ 0 ] = faceNormal[ 0 ];
143 normalsMat[ ifaceLoc ][ 1 ] = faceNormal[ 1 ];
144 normalsMat[ ifaceLoc ][ 2 ] = faceNormal[ 2 ];
149 real64 const tParam = 2 * LvArray::tensorOps::trace< 3 >( permMat );
152 LvArray::tensorOps::Rij_eq_AikBjk< 3, NF, 3 >( work_dimByNumFaces,
155 LvArray::tensorOps::Rij_eq_AikBkj< NF, NF, 3 >( transMatrix,
157 work_dimByNumFaces );
160 MimeticInnerProductHelpers::orthonormalize< NF >( q0, q1, q2, cellToFaceMat );
164 LvArray::tensorOps::addIdentity< NF >( worka_numFacesByNumFaces, -1 );
165 LvArray::tensorOps::Rij_add_AikAjk< NF, 3 >( worka_numFacesByNumFaces,
172 workb_numFacesByNumFaces[ i ][ i ] = faceArea[ i ];
175 LvArray::tensorOps::Rij_eq_AikBkj< NF, NF, NF >( workc_numFacesByNumFaces,
176 workb_numFacesByNumFaces,
177 worka_numFacesByNumFaces );
180 LvArray::tensorOps::scale< NF, NF >( transMatrix, 1 / elemVolume );
181 LvArray::tensorOps::scale< NF, NF >( workc_numFacesByNumFaces, -tParam / elemVolume );
182 LvArray::tensorOps::Rij_add_AikBkj< NF, NF, NF >( transMatrix,
183 workc_numFacesByNumFaces,
184 workb_numFacesByNumFaces );
190 if( !isZero( LvArray::tensorOps::l2NormSquared< NF >( tpTransInv ) ) )
192 MimeticInnerProductHelpers::computeTransMatrixWithMultipliers< NF >( tpTransInv,
#define GEOS_HOST_DEVICE
Marks a host-device function.
static GEOS_HOST_DEVICE void compute(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 &lengthTolerance, arraySlice2d< real64 > const &transMatrix)
In a given element, recompute the transmissibility matrix in a cell using the Simple inner product.
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.