20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_THERMALHYDROSTATICPRESSUREKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_THERMALHYDROSTATICPRESSUREKERNEL_HPP
24 #include "common/GEOS_RAJA_Interface.hpp"
25 #include "constitutive/fluid/singlefluid/SingleFluidBase.hpp"
30 namespace thermalSinglePhaseBaseKernels
38 template<
typename FLUID_WRAPPER >
40 computeHydrostaticPressure(
integer const maxNumEquilIterations,
41 real64 const & equilTolerance,
42 real64 const (&gravVector)[ 3 ],
43 FLUID_WRAPPER fluidWrapper,
45 real64 const & refElevation,
48 real64 const & newElevation,
54 real64 const gravCoef = gravVector[2] * ( refElevation - newElevation );
55 real64 const temp = tempTableWrapper.
compute( &newElevation );
56 real64 pres0 = refPres - refDens * gravCoef;
63 constitutive::SingleFluidBaseUpdate::computeThermalValues( fluidWrapper,
68 pres1 = refPres - 0.5 * ( refDens + dens ) * gravCoef;
72 bool equilHasConverged =
false;
73 for(
localIndex eqIter = 0; eqIter < maxNumEquilIterations; ++eqIter )
77 equilHasConverged = ( LvArray::math::abs( pres0 - pres1 ) < equilTolerance );
81 if( equilHasConverged )
87 constitutive::SingleFluidBaseUpdate::computeThermalValues( fluidWrapper,
92 pres1 = refPres - 0.5 * ( refDens + dens ) * gravCoef;
100 return equilHasConverged;
104 template<
typename FLUID_WRAPPER >
107 integer const maxNumEquilIterations,
108 real64 const equilTolerance,
109 real64 const (&gravVector)[ 3 ],
110 real64 const & minElevation,
111 real64 const & elevationIncrement,
112 real64 const & datumElevation,
114 FLUID_WRAPPER fluidWrapper,
119 bool hasConverged =
true;
125 real64 const datumTemp = tempTableWrapper.
compute( &datumElevation );
127 constitutive::SingleFluidBaseUpdate::computeThermalValues( fluidWrapper,
135 forAll< parallelHostPolicy >( size, [=] (
localIndex const i )
137 real64 const elevation = minElevation + i * elevationIncrement;
138 elevationValues[0][i] = elevation;
140 integer const iRef = LvArray::sortedArrayManipulation::find( elevationValues[0].begin(),
141 elevationValues[0].size(),
149 bool const hasConvergedRef =
150 computeHydrostaticPressure( maxNumEquilIterations,
158 elevationValues[0][iRef],
159 pressureValues[iRef],
161 if( !hasConvergedRef )
169 localIndex const numEntriesAboveRef = size - iRef - 1;
170 forAll< serialPolicy >( numEntriesAboveRef, [=, &hasConverged] (
localIndex const i )
172 bool const hasConvergedAboveRef =
173 computeHydrostaticPressure( maxNumEquilIterations,
178 elevationValues[0][iRef+i],
179 pressureValues[iRef+i],
181 elevationValues[0][iRef+i+1],
182 pressureValues[iRef+i+1],
184 if( !hasConvergedAboveRef )
186 hasConverged =
false;
195 forAll< serialPolicy >( numEntriesBelowRef, [=, &hasConverged] (
localIndex const i )
197 bool const hasConvergedBelowRef =
198 computeHydrostaticPressure( maxNumEquilIterations,
203 elevationValues[0][iRef-i],
204 pressureValues[iRef-i],
206 elevationValues[0][iRef-i-1],
207 pressureValues[iRef-i-1],
209 if( !hasConvergedBelowRef )
211 hasConverged =
false;
GEOS_HOST_DEVICE real64 compute(IN_ARRAY const &input) const
Interpolate in the table.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
int integer
Signed integer type.
Array< T, 1 > array1d
Alias for 1D array.