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_temperature_n( elementSubRegion.template getField< fields::flow::temperature_n >() ),
82  m_temperature( elementSubRegion.template getField< fields::flow::temperature >() )
83 {
84  // extract fluid constitutive data views
85  {
86  string const fluidModelName = elementSubRegion.template getReference< string >( fluidModelKey );
87  constitutive::MultiFluidBase const & fluid =
88  elementSubRegion.template getConstitutiveModel< constitutive::MultiFluidBase >( fluidModelName );
89 
90  m_fluidPhaseInternalEnergy_n = fluid.phaseInternalEnergy_n();
91  m_fluidPhaseInternalEnergy = fluid.phaseInternalEnergy();
92  m_dFluidPhaseInternalEnergy = fluid.dPhaseInternalEnergy();
93  }
94 }
95 
96 
97 template< typename SUBREGION_TYPE,
98  typename CONSTITUTIVE_TYPE,
99  typename FE_TYPE >
103 setup( localIndex const k,
104  StackVariables & stack ) const
105 {
106  // initialize displacement, pressure, temperature and fluid components degree of freedom
107  Base::setup( k, stack );
108 
109  stack.localTemperatureDofIndex = stack.localPressureDofIndex + m_numComponents + 1;
110  stack.temperature = m_temperature[k];
111  stack.deltaTemperatureFromLastStep = m_temperature[k] - m_temperature_n[k];
112 }
113 
114 template< typename SUBREGION_TYPE,
115  typename CONSTITUTIVE_TYPE,
116  typename FE_TYPE >
121  localIndex const q,
122  StackVariables & stack ) const
123 {
124  real64 porosity = 0.0;
125  real64 porosity_n = 0.0;
126  real64 dPorosity_dVolStrain = 0.0;
127  real64 dPorosity_dPressure = 0.0;
128  real64 dPorosity_dTemperature = 0.0;
129  real64 dSolidDensity_dPressure = 0.0;
130 
131  // Step 1: call the constitutive model to update the total stress, the porosity and their derivatives
132  m_constitutiveUpdate.smallStrainUpdatePoromechanics( k, q,
133  m_dt,
134  m_pressure[k],
135  m_pressure_n[k],
136  stack.temperature,
138  stack.strainIncrement,
139  stack.totalStress,
142  stack.stiffness,
143  m_performStressInitialization,
144  porosity,
145  porosity_n,
146  dPorosity_dVolStrain,
147  dPorosity_dPressure,
148  dPorosity_dTemperature,
149  dSolidDensity_dPressure );
150 
151  // Step 2: compute the body force
152  computeBodyForce( k, q,
153  porosity,
154  dPorosity_dVolStrain,
155  dPorosity_dPressure,
156  dPorosity_dTemperature,
157  dSolidDensity_dPressure,
158  stack );
159 
160  // Step 3: compute fluid mass increment
161  computeFluidIncrement( k, q,
162  porosity,
163  porosity_n,
164  dPorosity_dVolStrain,
165  dPorosity_dPressure,
166  dPorosity_dTemperature,
167  stack );
168 
169  // Step 4: compute pore volume constraint
170  computePoreVolumeConstraint( k,
171  porosity_n,
172  stack );
173 }
174 
175 
176 template< typename SUBREGION_TYPE,
177  typename CONSTITUTIVE_TYPE,
178  typename FE_TYPE >
183  localIndex const q,
184  real64 const & porosity,
185  real64 const & dPorosity_dVolStrain,
186  real64 const & dPorosity_dPressure,
187  real64 const & dPorosity_dTemperature,
188  real64 const & dSolidDensity_dPressure,
189  StackVariables & stack ) const
190 {
191  Base::computeBodyForce( k, q,
192  porosity,
193  dPorosity_dVolStrain,
194  dPorosity_dPressure,
195  dPorosity_dTemperature,
196  dSolidDensity_dPressure,
197  stack, [&]( real64 const & totalMassDensity,
198  real64 const & mixtureDensity )
199  {
200  GEOS_UNUSED_VAR( mixtureDensity );
201 
202  // Step 1: compute the derivative of the mixture density (an average between total mass density and solid density) wrt temperature
203  // TODO include solid density derivative with respect to temperature
204  real64 const dMixtureDens_dTemperature = dPorosity_dTemperature * ( -m_solidDensity( k, q ) + totalMassDensity );
205 
206  // Step 2: finally, get the body force
207 
208  LvArray::tensorOps::scaledCopy< 3 >( stack.dBodyForce_dTemperature, m_gravityVector, dMixtureDens_dTemperature );
209 
210  } );
211 }
212 
213 template< typename SUBREGION_TYPE,
214  typename CONSTITUTIVE_TYPE,
215  typename FE_TYPE >
220  localIndex const q,
221  real64 const & porosity,
222  real64 const & porosity_n,
223  real64 const & dPorosity_dVolStrain,
224  real64 const & dPorosity_dPressure,
225  real64 const & dPorosity_dTemperature,
226  StackVariables & stack ) const
227 {
228  using Deriv = constitutive::multifluid::DerivativeOffset;
229 
230  stack.energyIncrement = 0.0;
232  stack.dEnergyIncrement_dPressure = 0.0;
233  stack.dEnergyIncrement_dTemperature = 0.0;
234  LvArray::tensorOps::fill< maxNumComponents >( stack.dEnergyIncrement_dComponents, 0.0 );
235  LvArray::tensorOps::fill< maxNumComponents >( stack.dCompMassIncrement_dTemperature, 0.0 );
236 
237  Base::computeFluidIncrement( k, q,
238  porosity,
239  porosity_n,
240  dPorosity_dVolStrain,
241  dPorosity_dPressure,
242  dPorosity_dTemperature,
243  stack, [&]( real64 const & ip,
244  real64 const & phaseAmount,
245  real64 const & phaseAmount_n,
246  real64 const & dPhaseAmount_dVolStrain,
247  real64 const & dPhaseAmount_dP,
248  real64 const (&dPhaseAmount_dC)[maxNumComponents] )
249  {
250 
251  // We are in the loop over phases, ip provides the current phase index.
252  // We have to do two things:
253  // 1- Assemble the derivatives of the component mass balance equations with respect to temperature
254  // 2- Assemble the phase-dependent part of the accumulation term of the energy equation
255 
256  real64 dPhaseInternalEnergy_dC[maxNumComponents]{};
257 
258  // construct the slices
259  arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const phaseInternalEnergy_n = m_fluidPhaseInternalEnergy_n[k][q];
260  arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const phaseInternalEnergy = m_fluidPhaseInternalEnergy[k][q];
261  arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > const dPhaseInternalEnergy = m_dFluidPhaseInternalEnergy[k][q];
262  arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const phaseDensity = m_fluidPhaseDensity[k][q];
263  arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > const dPhaseDensity = m_dFluidPhaseDensity[k][q];
264  arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_COMP - 2 > const phaseCompFrac = m_fluidPhaseCompFrac[k][q];
265  arraySlice3d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC -2 > const dPhaseCompFrac = m_dFluidPhaseCompFrac[k][q];
266  arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const phaseVolFrac = m_fluidPhaseVolFrac[k];
267  arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const dPhaseVolFrac = m_dFluidPhaseVolFrac[k];
268  arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const dGlobalCompFrac_dGlobalCompDensity = m_dGlobalCompFraction_dGlobalCompDensity[k];
269 
270  // Step 1: assemble the derivatives of the component mass balance equations wrt temperature
271 
272  real64 const dPhaseAmount_dT = dPorosity_dTemperature * phaseVolFrac( ip ) * phaseDensity( ip )
273  + porosity * ( dPhaseVolFrac( ip, Deriv::dT ) * phaseDensity( ip ) + phaseVolFrac( ip ) * dPhaseDensity( ip, Deriv::dT ) );
274 
275  for( integer ic = 0; ic < m_numComponents; ++ic )
276  {
277  stack.dCompMassIncrement_dTemperature[ic] += dPhaseAmount_dT * phaseCompFrac( ip, ic )
278  + phaseAmount * dPhaseCompFrac( ip, ic, Deriv::dT );
279  }
280 
281  // Step 2: assemble the phase-dependent part of the accumulation term of the energy equation
282 
283  // local accumulation
284  stack.energyIncrement += phaseAmount * phaseInternalEnergy( ip ) - phaseAmount_n * phaseInternalEnergy_n( ip );
285 
286  // derivatives w.r.t. vol strain increment, pressure and temperature
287  stack.dEnergyIncrement_dVolStrainIncrement += dPhaseAmount_dVolStrain * phaseInternalEnergy( ip );
288  stack.dEnergyIncrement_dPressure += dPhaseAmount_dP * phaseInternalEnergy( ip )
289  + phaseAmount * dPhaseInternalEnergy( ip, Deriv::dP );
290  stack.dEnergyIncrement_dTemperature += dPhaseAmount_dT * phaseInternalEnergy( ip )
291  + phaseAmount * dPhaseInternalEnergy( ip, Deriv::dT );
292 
293  // derivatives w.r.t. component densities
294  applyChainRule( m_numComponents, dGlobalCompFrac_dGlobalCompDensity, dPhaseInternalEnergy[ip], dPhaseInternalEnergy_dC, Deriv::dC );
295  for( integer jc = 0; jc < m_numComponents; ++jc )
296  {
297  stack.dEnergyIncrement_dComponents[jc] += dPhaseAmount_dC[jc] * phaseInternalEnergy( ip )
298  + phaseAmount * dPhaseInternalEnergy_dC[jc];
299  }
300  } );
301 
302  // Step 3: assemble the solid part of the accumulation term
303  real64 const oneMinusPoro = 1 - porosity;
304 
305  // local accumulation and derivatives w.r.t. pressure and temperature
306  stack.energyIncrement += oneMinusPoro * m_rockInternalEnergy( k, 0 ) - ( 1 - porosity_n ) * m_rockInternalEnergy_n( k, 0 );
307  stack.dEnergyIncrement_dVolStrainIncrement += -dPorosity_dVolStrain * m_rockInternalEnergy( k, 0 );
308  stack.dEnergyIncrement_dPressure += -dPorosity_dPressure * m_rockInternalEnergy( k, 0 );
309  stack.dEnergyIncrement_dTemperature += -dPorosity_dTemperature * m_rockInternalEnergy( k, 0 ) + oneMinusPoro * m_dRockInternalEnergy_dTemperature( k, 0 );
310 }
311 
312 template< typename SUBREGION_TYPE,
313  typename CONSTITUTIVE_TYPE,
314  typename FE_TYPE >
319  real64 const & porosity_n,
320  StackVariables & stack ) const
321 {
322  using Deriv = constitutive::multifluid::DerivativeOffset;
323 
324  Base::computePoreVolumeConstraint( k,
325  porosity_n,
326  stack );
327 
328  arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const dPhaseVolFrac = m_dFluidPhaseVolFrac[k];
329 
331  for( integer ip = 0; ip < m_numPhases; ++ip )
332  {
333  stack.dPoreVolConstraint_dTemperature -= dPhaseVolFrac( ip, Deriv::dT ) * porosity_n;
334  }
335 }
336 
337 template< typename SUBREGION_TYPE,
338  typename CONSTITUTIVE_TYPE,
339  typename FE_TYPE >
343 assembleMomentumBalanceTerms( real64 const ( &N )[numNodesPerElem],
344  real64 const ( &dNdX )[numNodesPerElem][3],
345  real64 const & detJxW,
346  StackVariables & stack ) const
347 {
348  using namespace PDEUtilities;
349 
350  Base::assembleMomentumBalanceTerms( N, dNdX, detJxW, stack );
351 
352  constexpr FunctionSpace displacementTrialSpace = FE_TYPE::template getFunctionSpace< numDofPerTrialSupportPoint >();
353  constexpr FunctionSpace displacementTestSpace = displacementTrialSpace;
354  constexpr FunctionSpace pressureTrialSpace = FunctionSpace::P0;
355 
356  // compute local linear momentum balance residual derivatives with respect to temperature
357 
358  BilinearFormUtilities::compute< displacementTestSpace,
359  pressureTrialSpace,
360  DifferentialOperator::SymmetricGradient,
361  DifferentialOperator::Identity >
362  (
364  dNdX,
366  1.0,
367  -detJxW );
368 
369  BilinearFormUtilities::compute< displacementTestSpace,
370  pressureTrialSpace,
371  DifferentialOperator::Identity,
372  DifferentialOperator::Identity >
373  (
375  N,
377  1.0,
378  detJxW );
379 }
380 
381 template< typename SUBREGION_TYPE,
382  typename CONSTITUTIVE_TYPE,
383  typename FE_TYPE >
387 assembleElementBasedFlowTerms( real64 const ( &dNdX )[numNodesPerElem][3],
388  real64 const & detJxW,
389  StackVariables & stack ) const
390 {
391  using namespace PDEUtilities;
392 
393  Base::assembleElementBasedFlowTerms( dNdX, detJxW, stack );
394 
395  constexpr FunctionSpace displacementTrialSpace = FE_TYPE::template getFunctionSpace< numDofPerTrialSupportPoint >();
396  constexpr FunctionSpace pressureTrialSpace = FunctionSpace::P0;
397  constexpr FunctionSpace pressureTestSpace = pressureTrialSpace;
398 
399  // Step 1: compute local mass balance residual derivatives with respect to temperature
400 
401  BilinearFormUtilities::compute< pressureTestSpace,
402  pressureTrialSpace,
403  DifferentialOperator::Identity,
404  DifferentialOperator::Identity >
405  (
407  1.0,
409  1.0,
410  detJxW );
411 
412  // Step 2: compute local pore volume constraint residual derivatives with respect to temperature
413 
414  BilinearFormUtilities::compute< pressureTestSpace,
415  pressureTrialSpace,
416  DifferentialOperator::Identity,
417  DifferentialOperator::Identity >
418  (
420  1.0,
422  1.0,
423  detJxW );
424 
425  // Step 3: compute local energy balance residual and its derivatives
426 
427  LinearFormUtilities::compute< pressureTestSpace,
428  DifferentialOperator::Identity >
429  (
430  stack.localResidualEnergy,
431  1.0,
432  stack.energyIncrement,
433  detJxW );
434 
435  BilinearFormUtilities::compute< pressureTestSpace,
436  displacementTrialSpace,
437  DifferentialOperator::Identity,
438  DifferentialOperator::Divergence >
439  (
441  1.0,
443  dNdX,
444  detJxW );
445 
446  BilinearFormUtilities::compute< pressureTestSpace,
447  pressureTrialSpace,
448  DifferentialOperator::Identity,
449  DifferentialOperator::Identity >
450  (
452  1.0,
454  1.0,
455  detJxW );
456 
457  BilinearFormUtilities::compute< pressureTestSpace,
458  pressureTrialSpace,
459  DifferentialOperator::Identity,
460  DifferentialOperator::Identity >
461  (
463  1.0,
465  1.0,
466  detJxW );
467 
468  BilinearFormUtilities::compute< pressureTestSpace,
469  pressureTrialSpace,
470  DifferentialOperator::Identity,
471  DifferentialOperator::Identity >
472  (
474  1.0,
476  1.0,
477  detJxW );
478 
479 }
480 
481 template< typename SUBREGION_TYPE,
482  typename CONSTITUTIVE_TYPE,
483  typename FE_TYPE >
488  localIndex const q,
489  StackVariables & stack ) const
490 {
491  // Step 1: compute displacement finite element basis functions (N), basis function derivatives (dNdX), and
492  // determinant of the Jacobian transformation matrix times the quadrature weight (detJxW)
493  real64 N[numNodesPerElem]{};
494  real64 dNdX[numNodesPerElem][3]{};
495  FE_TYPE::calcN( q, stack.feStack, N );
496  real64 const detJxW = m_finiteElementSpace.template getGradN< FE_TYPE >( k, q, stack.xLocal,
497  stack.feStack, dNdX );
498 
499  // Step 2: compute strain increment
500  LvArray::tensorOps::fill< 6 >( stack.strainIncrement, 0.0 );
501  FE_TYPE::symmetricGradient( dNdX, stack.uhat_local, stack.strainIncrement );
502 
503  // Step 3: compute 1) the total stress, 2) the body force terms, and 3) the fluidMassIncrement
504  // using quantities returned by the PorousSolid constitutive model.
505  // This function also computes the derivatives of these three quantities wrt primary variables
506  smallStrainUpdate( k, q, stack );
507 
508  // Step 4: use the total stress and the body force to increment the local momentum balance residual
509  // This function also fills the local Jacobian rows corresponding to the momentum balance.
510  assembleMomentumBalanceTerms( N, dNdX, detJxW, stack );
511 
512  // Step 5: use the fluid mass increment to increment the local mass balance residual
513  // This function also fills the local Jacobian rows corresponding to the mass balance.
514  assembleElementBasedFlowTerms( dNdX, detJxW, stack );
515 }
516 
517 template< typename SUBREGION_TYPE,
518  typename CONSTITUTIVE_TYPE,
519  typename FE_TYPE >
523 complete( localIndex const k,
524  StackVariables & stack ) const
525 {
526  using namespace compositionalMultiphaseUtilities;
527 
528  real64 const maxForce = Base::complete( k, stack );
529 
530  localIndex const numSupportPoints =
531  m_finiteElementSpace.template numSupportPoints< FE_TYPE >( stack.feStack );
532  integer numDisplacementDofs = numSupportPoints * numDofPerTestSupportPoint;
533 
534  if( m_useTotalMassEquation > 0 )
535  {
536  // Apply equation/variable change transformation(s)
537  real64 work[maxNumComponents + 1]{};
538  shiftRowsAheadByOneAndReplaceFirstRowWithColumnSum( m_numComponents, 1, stack.dLocalResidualMass_dTemperature, work );
539  }
540 
541  // Step 1: assemble the derivatives of linear momentum balance wrt temperature into the global matrix
542 
543  for( int localNode = 0; localNode < numSupportPoints; ++localNode )
544  {
545  for( integer dim = 0; dim < numDofPerTestSupportPoint; ++dim )
546  {
547  localIndex const dof = LvArray::integerConversion< localIndex >( stack.localRowDofIndex[numDofPerTestSupportPoint*localNode + dim] - m_dofRankOffset );
548 
549  // we need this check to filter out ghost nodes in the assembly
550  if( dof < 0 || dof >= m_matrix.numRows() )
551  {
552  continue;
553  }
554 
555  m_matrix.template addToRowBinarySearchUnsorted< parallelDeviceAtomic >( dof,
557  stack.dLocalResidualMomentum_dTemperature[numDofPerTestSupportPoint * localNode + dim],
558  1 );
559  }
560  }
561 
562  localIndex const massDof = LvArray::integerConversion< localIndex >( stack.localPressureDofIndex - m_dofRankOffset );
563 
564  // we need this check to filter out ghost nodes in the assembly
565  if( 0 <= massDof && massDof < m_matrix.numRows() )
566  {
567 
568  // Step 2: assemble the derivatives of mass balance residual wrt temperature into the global matrix
569 
570  for( localIndex i = 0; i < m_numComponents; ++i )
571  {
572  m_matrix.template addToRow< serialAtomic >( massDof + i,
575  1 );
576  }
577 
578  // Step 3: assemble the derivatives of pore-volume constraint residual wrt temperature into the global matrix
579 
580  m_matrix.template addToRow< serialAtomic >( massDof + m_numComponents,
583  1 );
584  }
585 
586  // Step 4: assemble the energy balance and its derivatives into the global matrix
587 
588  localIndex const energyDof = LvArray::integerConversion< localIndex >( stack.localTemperatureDofIndex - m_dofRankOffset );
589 
590  // we need this check to filter out ghost nodes in the assembly
591  if( 0 <= energyDof && energyDof < m_matrix.numRows() )
592  {
593  m_matrix.template addToRowBinarySearchUnsorted< serialAtomic >( energyDof,
594  stack.localRowDofIndex,
596  numDisplacementDofs );
597  m_matrix.template addToRow< serialAtomic >( energyDof,
598  &stack.localPressureDofIndex,
600  1 );
601  m_matrix.template addToRow< serialAtomic >( energyDof,
604  1 );
605  m_matrix.template addToRow< serialAtomic >( energyDof,
606  stack.localComponentDofIndices,
608  m_numComponents );
609 
610  RAJA::atomicAdd< serialAtomic >( &m_rhs[energyDof], stack.localResidualEnergy[0] );
611  }
612 
613  return maxForce;
614 }
615 
616 template< typename SUBREGION_TYPE,
617  typename CONSTITUTIVE_TYPE,
618  typename FE_TYPE >
619 template< typename POLICY,
620  typename KERNEL_TYPE >
622 kernelLaunch( localIndex const numElems,
623  KERNEL_TYPE const & kernelComponent )
624 {
626 
627  // Define a RAJA reduction variable to get the maximum residual contribution.
628  RAJA::ReduceMax< ReducePolicy< POLICY >, real64 > maxResidual( 0 );
629 
630  forAll< POLICY >( numElems,
631  [=] GEOS_HOST_DEVICE ( localIndex const k )
632  {
633  typename KERNEL_TYPE::StackVariables stack;
634 
635  kernelComponent.setup( k, stack );
636  for( integer q=0; q<KERNEL_TYPE::numQuadraturePointsPerElem; ++q )
637  {
638  kernelComponent.quadraturePointKernel( k, q, stack );
639  }
640  maxResidual.max( kernelComponent.complete( k, stack ) );
641  } );
642  return maxResidual.get();
643 }
644 
645 } // namespace thermalporomechanicsKernels
646 
647 } // namespace geos
648 
649 #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:180
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:310
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:88
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
Definition: DataTypes.hpp:200
ArraySlice< T, 3, USD > arraySlice3d
Alias for 3D array slice.
Definition: DataTypes.hpp:216
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
Definition: DataTypes.hpp:184
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
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 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.