GEOS
ThermalMultiphasePoromechanics_impl.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_PHYSICSSOLVERS_MULTIPHYSICS_POROMECHANICSKERNELS_THERMALMULTIPHASEPOROMECHANICS_IMPL_HPP_
21 #define GEOS_PHYSICSSOLVERS_MULTIPHYSICS_POROMECHANICSKERNELS_THERMALMULTIPHASEPOROMECHANICS_IMPL_HPP_
22 
23 #include "constitutive/fluid/multifluid/MultiFluidBase.hpp"
28 
29 namespace geos
30 {
31 
32 namespace thermalPoromechanicsKernels
33 {
34 
35 template< typename SUBREGION_TYPE,
36  typename CONSTITUTIVE_TYPE,
37  typename FE_TYPE >
39 ThermalMultiphasePoromechanics( NodeManager const & nodeManager,
40  EdgeManager const & edgeManager,
41  FaceManager const & faceManager,
42  localIndex const targetRegionIndex,
43  SUBREGION_TYPE const & elementSubRegion,
44  FE_TYPE const & finiteElementSpace,
45  CONSTITUTIVE_TYPE & inputConstitutiveType,
46  arrayView1d< globalIndex const > const inputDispDofNumber,
47  globalIndex const rankOffset,
49  arrayView1d< real64 > const inputRhs,
50  real64 const inputDt,
51  real64 const (&gravityVector)[3],
52  string const inputFlowDofKey,
53  localIndex const numComponents,
54  localIndex const numPhases,
55  integer const useTotalMassEquation,
56  integer const performStressInitialization,
57  string const fluidModelKey ):
58  Base( nodeManager,
59  edgeManager,
60  faceManager,
61  targetRegionIndex,
62  elementSubRegion,
63  finiteElementSpace,
64  inputConstitutiveType,
65  inputDispDofNumber,
66  rankOffset,
67  inputMatrix,
68  inputRhs,
69  inputDt,
70  gravityVector,
71  inputFlowDofKey,
72  numComponents,
73  numPhases,
74  false, // do not use simple accumulation form
75  useTotalMassEquation,
76  performStressInitialization,
77  fluidModelKey ),
78  m_rockInternalEnergy_n( inputConstitutiveType.getInternalEnergy_n() ),
79  m_rockInternalEnergy( inputConstitutiveType.getInternalEnergy() ),
80  m_dRockInternalEnergy_dTemperature( inputConstitutiveType.getDinternalEnergy_dTemperature() ),
81  m_referenceTemperature( elementSubRegion.template getField< fields::flow::initialTemperature >() ),
82  m_temperature_n( elementSubRegion.template getField< fields::flow::temperature_n >() ),
83  m_temperature( elementSubRegion.template getField< fields::flow::temperature >() )
84 {
85  // extract fluid constitutive data views
86  {
87  string const & fluidModelName = elementSubRegion.template getReference< string >( fluidModelKey );
88  constitutive::MultiFluidBase const & fluid =
89  elementSubRegion.template getConstitutiveModel< constitutive::MultiFluidBase >( fluidModelName );
90 
91  m_fluidPhaseInternalEnergy_n = fluid.phaseInternalEnergy_n();
92  m_fluidPhaseInternalEnergy = fluid.phaseInternalEnergy();
93  m_dFluidPhaseInternalEnergy = fluid.dPhaseInternalEnergy();
94  }
95 }
96 
97 
98 template< typename SUBREGION_TYPE,
99  typename CONSTITUTIVE_TYPE,
100  typename FE_TYPE >
104 setup( localIndex const k,
105  StackVariables & stack ) const
106 {
107  // initialize displacement, pressure, temperature and fluid components degree of freedom
108  Base::setup( k, stack );
109 
110  stack.localTemperatureDofIndex = stack.localPressureDofIndex + m_numComponents + 1;
111  stack.temperature = m_temperature[k];
112  stack.deltaTemperatureFromLastStep = m_temperature[k] - m_temperature_n[k];
113  stack.deltaTemperature = m_temperature[k] - m_referenceTemperature[k];
114 }
115 
116 template< typename SUBREGION_TYPE,
117  typename CONSTITUTIVE_TYPE,
118  typename FE_TYPE >
123  localIndex const q,
124  StackVariables & stack ) const
125 {
126  real64 porosity = 0.0;
127  real64 porosity_n = 0.0;
128  real64 dPorosity_dVolStrain = 0.0;
129  real64 dPorosity_dPressure = 0.0;
130  real64 dPorosity_dTemperature = 0.0;
131  real64 dSolidDensity_dPressure = 0.0;
132 
133  // Step 1: call the constitutive model to update the total stress, the porosity and their derivatives
134  m_constitutiveUpdate.smallStrainUpdatePoromechanics( k, q,
135  m_dt,
136  m_pressure[k],
137  m_pressure_n[k],
138  stack.deltaTemperature,
140  stack.strainIncrement,
141  stack.totalStress,
144  stack.stiffness,
145  m_performStressInitialization,
146  porosity,
147  porosity_n,
148  dPorosity_dVolStrain,
149  dPorosity_dPressure,
150  dPorosity_dTemperature,
151  dSolidDensity_dPressure );
152 
153  // Step 2: compute the body force
154  computeBodyForce( k, q,
155  porosity,
156  dPorosity_dVolStrain,
157  dPorosity_dPressure,
158  dPorosity_dTemperature,
159  dSolidDensity_dPressure,
160  stack );
161 
162  // Step 3: compute fluid mass increment
163  computeFluidIncrement( k, q,
164  porosity,
165  porosity_n,
166  dPorosity_dVolStrain,
167  dPorosity_dPressure,
168  dPorosity_dTemperature,
169  stack );
170 
171  // Step 4: compute pore volume constraint
172  computePoreVolumeConstraint( k,
173  porosity_n,
174  stack );
175 }
176 
177 
178 template< typename SUBREGION_TYPE,
179  typename CONSTITUTIVE_TYPE,
180  typename FE_TYPE >
185  localIndex const q,
186  real64 const & porosity,
187  real64 const & dPorosity_dVolStrain,
188  real64 const & dPorosity_dPressure,
189  real64 const & dPorosity_dTemperature,
190  real64 const & dSolidDensity_dPressure,
191  StackVariables & stack ) const
192 {
193  Base::computeBodyForce( k, q,
194  porosity,
195  dPorosity_dVolStrain,
196  dPorosity_dPressure,
197  dPorosity_dTemperature,
198  dSolidDensity_dPressure,
199  stack, [&]( real64 const & totalMassDensity,
200  real64 const & mixtureDensity )
201  {
202  GEOS_UNUSED_VAR( mixtureDensity );
203 
204  // Step 1: compute the derivative of the mixture density (an average between total mass density and solid density) wrt temperature
205  // TODO include solid density derivative with respect to temperature
206  real64 const dMixtureDens_dTemperature = dPorosity_dTemperature * ( -m_solidDensity( k, q ) + totalMassDensity );
207 
208  // Step 2: finally, get the body force
209 
210  LvArray::tensorOps::scaledCopy< 3 >( stack.dBodyForce_dTemperature, m_gravityVector, dMixtureDens_dTemperature );
211 
212  } );
213 }
214 
215 template< typename SUBREGION_TYPE,
216  typename CONSTITUTIVE_TYPE,
217  typename FE_TYPE >
222  localIndex const q,
223  real64 const & porosity,
224  real64 const & porosity_n,
225  real64 const & dPorosity_dVolStrain,
226  real64 const & dPorosity_dPressure,
227  real64 const & dPorosity_dTemperature,
228  StackVariables & stack ) const
229 {
230  using Deriv = constitutive::multifluid::DerivativeOffset;
231 
232  stack.energyIncrement = 0.0;
234  stack.dEnergyIncrement_dPressure = 0.0;
235  stack.dEnergyIncrement_dTemperature = 0.0;
236  LvArray::tensorOps::fill< maxNumComponents >( stack.dEnergyIncrement_dComponents, 0.0 );
237  LvArray::tensorOps::fill< maxNumComponents >( stack.dCompMassIncrement_dTemperature, 0.0 );
238 
239  Base::computeFluidIncrement( k, q,
240  porosity,
241  porosity_n,
242  dPorosity_dVolStrain,
243  dPorosity_dPressure,
244  dPorosity_dTemperature,
245  stack, [&]( real64 const & ip,
246  real64 const & phaseAmount,
247  real64 const & phaseAmount_n,
248  real64 const & dPhaseAmount_dVolStrain,
249  real64 const & dPhaseAmount_dP,
250  real64 const (&dPhaseAmount_dC)[maxNumComponents] )
251  {
252 
253  // We are in the loop over phases, ip provides the current phase index.
254  // We have to do two things:
255  // 1- Assemble the derivatives of the component mass balance equations with respect to temperature
256  // 2- Assemble the phase-dependent part of the accumulation term of the energy equation
257 
258  real64 dPhaseInternalEnergy_dC[maxNumComponents]{};
259 
260  // construct the slices
261  arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const phaseInternalEnergy_n = m_fluidPhaseInternalEnergy_n[k][q];
262  arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const phaseInternalEnergy = m_fluidPhaseInternalEnergy[k][q];
263  arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > const dPhaseInternalEnergy = m_dFluidPhaseInternalEnergy[k][q];
264  arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const phaseDensity = m_fluidPhaseDensity[k][q];
265  arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > const dPhaseDensity = m_dFluidPhaseDensity[k][q];
266  arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_COMP - 2 > const phaseCompFrac = m_fluidPhaseCompFrac[k][q];
267  arraySlice3d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC -2 > const dPhaseCompFrac = m_dFluidPhaseCompFrac[k][q];
268  arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const phaseVolFrac = m_fluidPhaseVolFrac[k];
269  arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const dPhaseVolFrac = m_dFluidPhaseVolFrac[k];
270  arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const dGlobalCompFrac_dGlobalCompDensity = m_dGlobalCompFraction_dGlobalCompDensity[k];
271 
272  // Step 1: assemble the derivatives of the component mass balance equations wrt temperature
273 
274  real64 const dPhaseAmount_dT = dPorosity_dTemperature * phaseVolFrac( ip ) * phaseDensity( ip )
275  + porosity * ( dPhaseVolFrac( ip, Deriv::dT ) * phaseDensity( ip ) + phaseVolFrac( ip ) * dPhaseDensity( ip, Deriv::dT ) );
276 
277  for( integer ic = 0; ic < m_numComponents; ++ic )
278  {
279  stack.dCompMassIncrement_dTemperature[ic] += dPhaseAmount_dT * phaseCompFrac( ip, ic )
280  + phaseAmount * dPhaseCompFrac( ip, ic, Deriv::dT );
281  }
282 
283  // Step 2: assemble the phase-dependent part of the accumulation term of the energy equation
284 
285  // local accumulation
286  stack.energyIncrement += phaseAmount * phaseInternalEnergy( ip ) - phaseAmount_n * phaseInternalEnergy_n( ip );
287 
288  // derivatives w.r.t. vol strain increment, pressure and temperature
289  stack.dEnergyIncrement_dVolStrainIncrement += dPhaseAmount_dVolStrain * phaseInternalEnergy( ip );
290  stack.dEnergyIncrement_dPressure += dPhaseAmount_dP * phaseInternalEnergy( ip )
291  + phaseAmount * dPhaseInternalEnergy( ip, Deriv::dP );
292  stack.dEnergyIncrement_dTemperature += dPhaseAmount_dT * phaseInternalEnergy( ip )
293  + phaseAmount * dPhaseInternalEnergy( ip, Deriv::dT );
294 
295  // derivatives w.r.t. component densities
296  applyChainRule( m_numComponents, dGlobalCompFrac_dGlobalCompDensity, dPhaseInternalEnergy[ip], dPhaseInternalEnergy_dC, Deriv::dC );
297  for( integer jc = 0; jc < m_numComponents; ++jc )
298  {
299  stack.dEnergyIncrement_dComponents[jc] += dPhaseAmount_dC[jc] * phaseInternalEnergy( ip )
300  + phaseAmount * dPhaseInternalEnergy_dC[jc];
301  }
302  } );
303 
304  // Step 3: assemble the solid part of the accumulation term
305  real64 const oneMinusPoro = 1 - porosity;
306 
307  // local accumulation and derivatives w.r.t. pressure and temperature
308  stack.energyIncrement += oneMinusPoro * m_rockInternalEnergy( k, 0 ) - ( 1 - porosity_n ) * m_rockInternalEnergy_n( k, 0 );
309  stack.dEnergyIncrement_dVolStrainIncrement += -dPorosity_dVolStrain * m_rockInternalEnergy( k, 0 );
310  stack.dEnergyIncrement_dPressure += -dPorosity_dPressure * m_rockInternalEnergy( k, 0 );
311  stack.dEnergyIncrement_dTemperature += -dPorosity_dTemperature * m_rockInternalEnergy( k, 0 ) + oneMinusPoro * m_dRockInternalEnergy_dTemperature( k, 0 );
312 }
313 
314 template< typename SUBREGION_TYPE,
315  typename CONSTITUTIVE_TYPE,
316  typename FE_TYPE >
321  real64 const & porosity_n,
322  StackVariables & stack ) const
323 {
324  using Deriv = constitutive::multifluid::DerivativeOffset;
325 
326  Base::computePoreVolumeConstraint( k,
327  porosity_n,
328  stack );
329 
330  arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const dPhaseVolFrac = m_dFluidPhaseVolFrac[k];
331 
333  for( integer ip = 0; ip < m_numPhases; ++ip )
334  {
335  stack.dPoreVolConstraint_dTemperature -= dPhaseVolFrac( ip, Deriv::dT ) * porosity_n;
336  }
337 }
338 
339 template< typename SUBREGION_TYPE,
340  typename CONSTITUTIVE_TYPE,
341  typename FE_TYPE >
345 assembleMomentumBalanceTerms( real64 const ( &N )[numNodesPerElem],
346  real64 const ( &dNdX )[numNodesPerElem][3],
347  real64 const & detJxW,
348  StackVariables & stack ) const
349 {
350  using namespace PDEUtilities;
351 
352  Base::assembleMomentumBalanceTerms( N, dNdX, detJxW, stack );
353 
354  constexpr FunctionSpace displacementTrialSpace = FE_TYPE::template getFunctionSpace< numDofPerTrialSupportPoint >();
355  constexpr FunctionSpace displacementTestSpace = displacementTrialSpace;
356  constexpr FunctionSpace pressureTrialSpace = FunctionSpace::P0;
357 
358  // compute local linear momentum balance residual derivatives with respect to temperature
359 
360  BilinearFormUtilities::compute< displacementTestSpace,
361  pressureTrialSpace,
362  DifferentialOperator::SymmetricGradient,
363  DifferentialOperator::Identity >
364  (
366  dNdX,
368  1.0,
369  -detJxW );
370 
371  BilinearFormUtilities::compute< displacementTestSpace,
372  pressureTrialSpace,
373  DifferentialOperator::Identity,
374  DifferentialOperator::Identity >
375  (
377  N,
379  1.0,
380  detJxW );
381 }
382 
383 template< typename SUBREGION_TYPE,
384  typename CONSTITUTIVE_TYPE,
385  typename FE_TYPE >
389 assembleElementBasedFlowTerms( real64 const ( &dNdX )[numNodesPerElem][3],
390  real64 const & detJxW,
391  StackVariables & stack ) const
392 {
393  using namespace PDEUtilities;
394 
395  Base::assembleElementBasedFlowTerms( dNdX, detJxW, stack );
396 
397  constexpr FunctionSpace displacementTrialSpace = FE_TYPE::template getFunctionSpace< numDofPerTrialSupportPoint >();
398  constexpr FunctionSpace pressureTrialSpace = FunctionSpace::P0;
399  constexpr FunctionSpace pressureTestSpace = pressureTrialSpace;
400 
401  // Step 1: compute local mass balance residual derivatives with respect to temperature
402 
403  BilinearFormUtilities::compute< pressureTestSpace,
404  pressureTrialSpace,
405  DifferentialOperator::Identity,
406  DifferentialOperator::Identity >
407  (
409  1.0,
411  1.0,
412  detJxW );
413 
414  // Step 2: compute local pore volume constraint residual derivatives with respect to temperature
415 
416  BilinearFormUtilities::compute< pressureTestSpace,
417  pressureTrialSpace,
418  DifferentialOperator::Identity,
419  DifferentialOperator::Identity >
420  (
422  1.0,
424  1.0,
425  detJxW );
426 
427  // Step 3: compute local energy balance residual and its derivatives
428 
429  LinearFormUtilities::compute< pressureTestSpace,
430  DifferentialOperator::Identity >
431  (
432  stack.localResidualEnergy,
433  1.0,
434  stack.energyIncrement,
435  detJxW );
436 
437  BilinearFormUtilities::compute< pressureTestSpace,
438  displacementTrialSpace,
439  DifferentialOperator::Identity,
440  DifferentialOperator::Divergence >
441  (
443  1.0,
445  dNdX,
446  detJxW );
447 
448  BilinearFormUtilities::compute< pressureTestSpace,
449  pressureTrialSpace,
450  DifferentialOperator::Identity,
451  DifferentialOperator::Identity >
452  (
454  1.0,
456  1.0,
457  detJxW );
458 
459  BilinearFormUtilities::compute< pressureTestSpace,
460  pressureTrialSpace,
461  DifferentialOperator::Identity,
462  DifferentialOperator::Identity >
463  (
465  1.0,
467  1.0,
468  detJxW );
469 
470  BilinearFormUtilities::compute< pressureTestSpace,
471  pressureTrialSpace,
472  DifferentialOperator::Identity,
473  DifferentialOperator::Identity >
474  (
476  1.0,
478  1.0,
479  detJxW );
480 
481 }
482 
483 template< typename SUBREGION_TYPE,
484  typename CONSTITUTIVE_TYPE,
485  typename FE_TYPE >
490  localIndex const q,
491  StackVariables & stack ) const
492 {
493  // Step 1: compute displacement finite element basis functions (N), basis function derivatives (dNdX), and
494  // determinant of the Jacobian transformation matrix times the quadrature weight (detJxW)
495  real64 N[numNodesPerElem]{};
496  real64 dNdX[numNodesPerElem][3]{};
497  FE_TYPE::calcN( q, stack.feStack, N );
498  real64 const detJxW = m_finiteElementSpace.template getGradN< FE_TYPE >( k, q, stack.xLocal,
499  stack.feStack, dNdX );
500 
501  // Step 2: compute strain increment
502  LvArray::tensorOps::fill< 6 >( stack.strainIncrement, 0.0 );
503  FE_TYPE::symmetricGradient( dNdX, stack.uhat_local, stack.strainIncrement );
504 
505  // Step 3: compute 1) the total stress, 2) the body force terms, and 3) the fluidMassIncrement
506  // using quantities returned by the PorousSolid constitutive model.
507  // This function also computes the derivatives of these three quantities wrt primary variables
508  smallStrainUpdate( k, q, stack );
509 
510  // Step 4: use the total stress and the body force to increment the local momentum balance residual
511  // This function also fills the local Jacobian rows corresponding to the momentum balance.
512  assembleMomentumBalanceTerms( N, dNdX, detJxW, stack );
513 
514  // Step 5: use the fluid mass increment to increment the local mass balance residual
515  // This function also fills the local Jacobian rows corresponding to the mass balance.
516  assembleElementBasedFlowTerms( dNdX, detJxW, stack );
517 }
518 
519 template< typename SUBREGION_TYPE,
520  typename CONSTITUTIVE_TYPE,
521  typename FE_TYPE >
525 complete( localIndex const k,
526  StackVariables & stack ) const
527 {
528  using namespace compositionalMultiphaseUtilities;
529 
530  real64 const maxForce = Base::complete( k, stack );
531 
532  localIndex const numSupportPoints =
533  m_finiteElementSpace.template numSupportPoints< FE_TYPE >( stack.feStack );
534  integer numDisplacementDofs = numSupportPoints * numDofPerTestSupportPoint;
535 
536  if( m_useTotalMassEquation > 0 )
537  {
538  // Apply equation/variable change transformation(s)
539  real64 work[maxNumComponents + 1]{};
540  shiftRowsAheadByOneAndReplaceFirstRowWithColumnSum( m_numComponents, 1, stack.dLocalResidualMass_dTemperature, work );
541  }
542 
543  // Step 1: assemble the derivatives of linear momentum balance wrt temperature into the global matrix
544 
545  for( int localNode = 0; localNode < numSupportPoints; ++localNode )
546  {
547  for( integer dim = 0; dim < numDofPerTestSupportPoint; ++dim )
548  {
549  localIndex const dof = LvArray::integerConversion< localIndex >( stack.localRowDofIndex[numDofPerTestSupportPoint*localNode + dim] - m_dofRankOffset );
550 
551  // we need this check to filter out ghost nodes in the assembly
552  if( dof < 0 || dof >= m_matrix.numRows() )
553  {
554  continue;
555  }
556 
557  m_matrix.template addToRowBinarySearchUnsorted< parallelDeviceAtomic >( dof,
559  stack.dLocalResidualMomentum_dTemperature[numDofPerTestSupportPoint * localNode + dim],
560  1 );
561  }
562  }
563 
564  localIndex const massDof = LvArray::integerConversion< localIndex >( stack.localPressureDofIndex - m_dofRankOffset );
565 
566  // we need this check to filter out ghost nodes in the assembly
567  if( 0 <= massDof && massDof < m_matrix.numRows() )
568  {
569 
570  // Step 2: assemble the derivatives of mass balance residual wrt temperature into the global matrix
571 
572  for( localIndex i = 0; i < m_numComponents; ++i )
573  {
574  m_matrix.template addToRow< serialAtomic >( massDof + i,
577  1 );
578  }
579 
580  // Step 3: assemble the derivatives of pore-volume constraint residual wrt temperature into the global matrix
581 
582  m_matrix.template addToRow< serialAtomic >( massDof + m_numComponents,
585  1 );
586  }
587 
588  // Step 4: assemble the energy balance and its derivatives into the global matrix
589 
590  localIndex const energyDof = LvArray::integerConversion< localIndex >( stack.localTemperatureDofIndex - m_dofRankOffset );
591 
592  // we need this check to filter out ghost nodes in the assembly
593  if( 0 <= energyDof && energyDof < m_matrix.numRows() )
594  {
595  m_matrix.template addToRowBinarySearchUnsorted< serialAtomic >( energyDof,
596  stack.localRowDofIndex,
598  numDisplacementDofs );
599  m_matrix.template addToRow< serialAtomic >( energyDof,
600  &stack.localPressureDofIndex,
602  1 );
603  m_matrix.template addToRow< serialAtomic >( energyDof,
606  1 );
607  m_matrix.template addToRow< serialAtomic >( energyDof,
608  stack.localComponentDofIndices,
610  m_numComponents );
611 
612  RAJA::atomicAdd< serialAtomic >( &m_rhs[energyDof], stack.localResidualEnergy[0] );
613  }
614 
615  return maxForce;
616 }
617 
618 template< typename SUBREGION_TYPE,
619  typename CONSTITUTIVE_TYPE,
620  typename FE_TYPE >
621 template< typename POLICY,
622  typename KERNEL_TYPE >
624 kernelLaunch( localIndex const numElems,
625  KERNEL_TYPE const & kernelComponent )
626 {
628 
629  // Define a RAJA reduction variable to get the maximum residual contribution.
630  RAJA::ReduceMax< ReducePolicy< POLICY >, real64 > maxResidual( 0 );
631 
632  forAll< POLICY >( numElems,
633  [=] GEOS_HOST_DEVICE ( localIndex const k )
634  {
635  typename KERNEL_TYPE::StackVariables stack;
636 
637  kernelComponent.setup( k, stack );
638  for( integer q=0; q<KERNEL_TYPE::numQuadraturePointsPerElem; ++q )
639  {
640  kernelComponent.quadraturePointKernel( k, q, stack );
641  }
642  maxResidual.max( kernelComponent.complete( k, stack ) );
643  } );
644  return maxResidual.get();
645 }
646 
647 } // namespace thermalporomechanicsKernels
648 
649 } // namespace geos
650 
651 #endif // GEOS_PHYSICSSOLVERS_MULTIPHYSICS_POROMECHANICSKERNELS_THERMALMULTIPHASEPOROMECHANICS_IMPL_HPP_
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:84
#define GEOS_FORCE_INLINE
Marks a function or lambda for inlining.
Definition: GeosxMacros.hpp:51
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
This class provides an interface to ObjectManagerBase in order to manage edge data.
Definition: EdgeManager.hpp:43
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
Definition: FaceManager.hpp:44
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:46
Defines the kernel structure for solving quasi-static poromechanics.
Implements kernels for solving quasi-static thermal multiphase poromechanics.
GEOS_HOST_DEVICE void computeBodyForce(localIndex const k, localIndex const q, real64 const &porosity, real64 const &dPorosity_dVolStrain, real64 const &dPorosity_dPressure, real64 const &dPorosity_dTemperature, real64 const &dSolidDensity_dPressure, StackVariables &stack) const
Helper function to compute the body force term (\rho g) and its derivatives wrt primary variables.
GEOS_HOST_DEVICE real64 complete(localIndex const k, StackVariables &stack) const
Performs the complete phase for the kernel.
GEOS_HOST_DEVICE void setup(localIndex const k, StackVariables &stack) const
Copy global values from primary field to a local stack array.
GEOS_HOST_DEVICE void computeFluidIncrement(localIndex const k, localIndex const q, real64 const &porosity, real64 const &porosity_n, real64 const &dPorosity_dVolStrain, real64 const &dPorosity_dPressure, real64 const &dPorosity_dTemperature, StackVariables &stack) const
Helper function to compute the fluid mass increment and its derivatives wrt primary variables.
ThermalMultiphasePoromechanics(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 inputDispDofNumber, globalIndex const rankOffset, CRSMatrixView< real64, globalIndex const > const inputMatrix, arrayView1d< real64 > const inputRhs, real64 const inputDt, real64 const (&gravityVector)[3], string const inputFlowDofKey, localIndex const numComponents, localIndex const numPhases, integer const useTotalMassEquation, integer const performStressInitialization, string const fluidModelKey)
Constructor.
static real64 kernelLaunch(localIndex const numElems, KERNEL_TYPE const &kernelComponent)
Kernel Launcher.
GEOS_HOST_DEVICE void assembleMomentumBalanceTerms(real64 const (&N)[numNodesPerElem], real64 const (&dNdX)[numNodesPerElem][3], real64 const &detJxW, StackVariables &stack) const
Assemble the local linear momentum balance residual and derivatives using total stress and body force...
GEOS_HOST_DEVICE void smallStrainUpdate(localIndex const k, localIndex const q, StackVariables &stack) const
Helper function to compute 1) the total stress, 2) the body force term, and 3) the fluidMass/EnergyIn...
GEOS_HOST_DEVICE void computePoreVolumeConstraint(localIndex const k, real64 const &porosity_n, StackVariables &stack) const
Helper function to compute the pore-volume constraint and its derivatives wrt primary variables.
GEOS_HOST_DEVICE void assembleElementBasedFlowTerms(real64 const (&dNdX)[numNodesPerElem][3], real64 const &detJxW, StackVariables &stack) const
Assemble the local mass/energy balance residual and derivatives using fluid mass/energy increment.
arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > m_fluidPhaseInternalEnergy_n
Views on phase internal energy.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:188
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:318
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:87
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
Definition: DataTypes.hpp:208
ArraySlice< T, 3, USD > arraySlice3d
Alias for 3D array slice.
Definition: DataTypes.hpp:224
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
Definition: DataTypes.hpp:192
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:81
Kernel variables (dof numbers, jacobian and residual) located on the stack.
globalIndex localPressureDofIndex
C-array storage for the element local row degrees of freedom.
real64 dTotalStress_dTemperature[6]
Derivative of total stress wrt temperature.
CONSTITUTIVE_TYPE::KernelWrapper::DiscretizationOps stiffness
Derivative of total stress wrt displacement.
real64 dTotalStress_dPressure[6]
Derivative of total stress wrt pressure.
real64 deltaTemperature
Delta temperature from reference state.
real64 deltaTemperatureFromLastStep
Delta temperature since last time step.
real64 dEnergyIncrement_dComponents[maxNumComponents]
Derivative of energy increment wrt global comp fraction.
real64 dLocalResidualEnergy_dTemperature[1][1]
Derivative of energy balance residual wrt temperature.
real64 dEnergyIncrement_dVolStrainIncrement
Derivative of energy increment wrt volumetric strain increment.
real64 dLocalResidualMomentum_dTemperature[Base::StackVariables::numDispDofPerElem][1]
Derivative of linear momentum balance residual wrt temperature.
real64 dPoreVolConstraint_dTemperature
Derivative of pore volume constraint wrt temperature.
real64 dLocalResidualEnergy_dComponents[1][maxNumComponents]
Derivative of energy balance residual wrt global comp fraction.
real64 dLocalResidualEnergy_dPressure[1][1]
Derivative of energy balance residual wrt pressure.
real64 dLocalResidualPoreVolConstraint_dTemperature[1][1]
Derivative of pore volume constraint residual wrt pressure.
real64 dLocalResidualMass_dTemperature[maxNumComponents][1]
Derivative of mass balance residual wrt pressure.
real64 dCompMassIncrement_dTemperature[maxNumComponents]
Derivative of mass increment wrt temperature.
real64 dLocalResidualEnergy_dDisplacement[1][Base::StackVariables::numDispDofPerElem]
Derivative of energy balance residual wrt displacement.