GEOS
FluxComputeKernel.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_FLUIDFLOW_SINGLEPHASE_REACTIVE_FLUXCOMPUTEKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_REACTIVE_FLUXCOMPUTEKERNEL_HPP
22 
23 #include "constitutive/diffusion/DiffusionFields.hpp"
24 #include "constitutive/diffusion/DiffusionBase.hpp"
25 #include "constitutive/solid/porosity/PorosityBase.hpp"
26 #include "constitutive/solid/porosity/PorosityFields.hpp"
27 #include "constitutive/fluid/reactivefluid/ReactiveSinglePhaseFluid.hpp"
28 #include "constitutive/fluid/reactivefluid/ReactiveFluidFields.hpp"
30 #include "physicsSolvers/fluidFlow/kernels/singlePhase/reactive/KernelLaunchSelectors.hpp"
31 
32 
33 namespace geos
34 {
35 
36 namespace singlePhaseReactiveFVMKernels
37 {
38 
48 template< integer NUM_SPECIES, integer NUM_EQN, integer NUM_DOF, typename STENCILWRAPPER, typename BASE_FLUID_TYPE >
49 class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_EQN, NUM_DOF, STENCILWRAPPER >
50 {
51 public:
52 
54  static constexpr integer numSpecies = NUM_SPECIES;
55 
57  static constexpr integer numFluxSupportPoints = 2;
58 
65  template< typename VIEWTYPE >
67 
69  using DofNumberAccessor = AbstractBase::DofNumberAccessor;
73 
74  using AbstractBase::m_dt;
77  using AbstractBase::m_gravCoef;
78  using AbstractBase::m_mob;
80  using AbstractBase::m_dDens;
81 
83  using Base::numDof;
84  using Base::numEqn;
85  using Base::maxNumElems;
86  using Base::maxNumConns;
89  using Base::m_seri;
90  using Base::m_sesri;
91  using Base::m_sei;
92 
94  StencilAccessors< fields::flow::logPrimarySpeciesConcentration,
95  fields::flow::dMobility_dLogPrimaryConc >;
96 
99  fields::reactivefluid::primarySpeciesMobileAggregateConcentration,
100  fields::reactivefluid::dPrimarySpeciesMobileAggregateConcentration_dLogPrimarySpeciesConcentrations >;
101 
102  using DiffusionAccessors =
103  StencilMaterialAccessors< constitutive::DiffusionBase,
104  fields::diffusion::diffusivity,
105  fields::diffusion::dDiffusivity_dTemperature >;
106 
107  using PorosityAccessors =
108  StencilMaterialAccessors< constitutive::PorosityBase,
109  fields::porosity::referencePorosity >;
110 
130  FluxComputeKernel( globalIndex const rankOffset,
131  STENCILWRAPPER const & stencilWrapper,
132  DofNumberAccessor const & dofNumberAccessor,
133  SinglePhaseFlowAccessors const & singlePhaseFlowAccessors,
134  ReactiveSinglePhaseFlowAccessors const & reactiveSinglePhaseFlowAccessors,
135  SinglePhaseFluidAccessors const & singlePhaseFluidAccessors,
136  ReactiveSinglePhaseFluidAccessors const & reactiveSinglePhaseFluidAccessors,
137  PermeabilityAccessors const & permeabilityAccessors,
138  DiffusionAccessors const & diffusionAccessors,
139  PorosityAccessors const & porosityAccessors,
140  integer const & hasDiffusion,
141  arrayView1d< integer const > const & mobilePrimarySpeciesFlags,
142  real64 const & solventMassFraction,
143  real64 const & dt,
144  CRSMatrixView< real64, globalIndex const > const & localMatrix,
145  arrayView1d< real64 > const & localRhs )
146  : Base( rankOffset,
147  stencilWrapper,
148  dofNumberAccessor,
149  singlePhaseFlowAccessors,
150  singlePhaseFluidAccessors,
151  permeabilityAccessors,
152  dt,
153  localMatrix,
154  localRhs ),
155  m_logPrimarySpeciesConc( reactiveSinglePhaseFlowAccessors.get( fields::flow::logPrimarySpeciesConcentration {} ) ),
156  m_dMob_dLogPrimaryConc( reactiveSinglePhaseFlowAccessors.get( fields::flow::dMobility_dLogPrimaryConc {} ) ),
157  m_primarySpeciesMobileAggregateConc( reactiveSinglePhaseFluidAccessors.get( fields::reactivefluid::primarySpeciesMobileAggregateConcentration {} ) ),
158  m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc( reactiveSinglePhaseFluidAccessors.get(
159  fields::reactivefluid::dPrimarySpeciesMobileAggregateConcentration_dLogPrimarySpeciesConcentrations {} ) ),
160  m_diffusivity( diffusionAccessors.get( fields::diffusion::diffusivity {} ) ),
161  m_dDiffusivity_dTemp( diffusionAccessors.get( fields::diffusion::dDiffusivity_dTemperature {} ) ),
162  m_referencePorosity( porosityAccessors.get( fields::porosity::referencePorosity {} ) ),
163  m_hasDiffusion( hasDiffusion ),
164  m_mobilePrimarySpeciesFlags( mobilePrimarySpeciesFlags ),
165  m_solventMassFraction( solventMassFraction )
166  {}
167 
173  {
174 public:
175 
182  StackVariables( localIndex const size, localIndex numElems )
183  : Base::StackVariables( size, numElems )
184  {}
185 
193 
198 
199  };
200 
208  template< typename FUNC = NoOpFunc >
210  void computeFlux( localIndex const iconn,
211  StackVariables & stack,
212  FUNC && kernelOp = NoOpFunc{} ) const
213  {
214  // ***********************************************
215  // First, we call the base computeFlux to compute:
216  // 1) massFlux and its derivatives,
217  // 2) speciesFlux and its derivatives
218  Base::computeFlux( iconn, stack, [&] ( localIndex const (&k)[2],
219  localIndex const (&seri)[2],
220  localIndex const (&sesri)[2],
221  localIndex const (&sei)[2],
222  localIndex const connectionIndex,
223  real64 const alpha,
224  real64 const mobility,
225  real64 const & potGrad,
226  real64 const & fluxVal,
227  real64 const (&dFlux_dP)[2] )
228  {
229  // Step 1: compute the derivatives of the fluid density, potential difference,
230  // and the massFlux wrt log of primary species concentration (to complete)
231  real64 dFlux_dLogConc[numFluxSupportPoints][numSpecies]{};
232 
233  GEOS_UNUSED_VAR( dFlux_dLogConc ); // Todo: to add the massFlux derivatives wrt speciesConc
234 
235  // Step 2: compute the speciesFlux
236  real64 speciesFlux[numSpecies]{};
237  real64 dSpeciesFlux_dP[numFluxSupportPoints][numSpecies]{};
238  real64 dSpeciesFlux_dLogConc[numFluxSupportPoints][numSpecies][numSpecies]{};
239  // real64 dSpeciesFlux_dTrans[numSpecies]{};
240 
241  // choose upstream cell
242  localIndex const k_up = (potGrad >= 0) ? 0 : 1;
243 
244  localIndex const er_up = seri[k_up];
245  localIndex const esr_up = sesri[k_up];
246  localIndex const ei_up = sei[k_up];
247 
248  // compute species fluxes and derivatives using upstream cell concentration: the mass flux carries
249  // molality * solvent mass fraction moles per kg of solution, so the density does not enter
250  for( integer is = 0; is < numSpecies; ++is )
251  {
252  real64 const aggregateConcPerMass_i = m_primarySpeciesMobileAggregateConc[er_up][esr_up][ei_up][0][is] * m_solventMassFraction;
253  speciesFlux[is] = aggregateConcPerMass_i * fluxVal;
254 
255  for( integer ke = 0; ke < numFluxSupportPoints; ++ke )
256  {
257  dSpeciesFlux_dP[ke][is] += aggregateConcPerMass_i * dFlux_dP[ke];
258  }
259 
260  for( integer js = 0; js < numSpecies; ++js )
261  {
262  real64 const dAggregateConcPerMass_i_dLogConc_j = m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc[er_up][esr_up][ei_up][0][is][js] * m_solventMassFraction;
263  dSpeciesFlux_dLogConc[k_up][is][js] += dAggregateConcPerMass_i_dLogConc_j * fluxVal;
264  }
265  }
266 
268  for( integer is = 0; is < numSpecies; ++is )
269  {
270  integer const eqIndex0 = k[0] * numEqn + numEqn - numSpecies + is;
271  integer const eqIndex1 = k[1] * numEqn + numEqn - numSpecies + is;
272 
273  stack.localFlux[eqIndex0] += m_dt * speciesFlux[is] * m_mobilePrimarySpeciesFlags[is];
274  stack.localFlux[eqIndex1] -= m_dt * speciesFlux[is] * m_mobilePrimarySpeciesFlags[is];
275 
276  for( integer ke = 0; ke < numFluxSupportPoints; ++ke )
277  {
278  localIndex const localDofIndexPres = k[ke] * numDof;
279  stack.localFluxJacobian[eqIndex0][localDofIndexPres] += m_dt * dSpeciesFlux_dP[ke][is] * m_mobilePrimarySpeciesFlags[is];
280  stack.localFluxJacobian[eqIndex1][localDofIndexPres] -= m_dt * dSpeciesFlux_dP[ke][is] * m_mobilePrimarySpeciesFlags[is];
281 
282  for( integer js = 0; js < numSpecies; ++js )
283  {
284  localIndex const localDofIndexSpecies = localDofIndexPres + js + numDof - numSpecies;
285  stack.localFluxJacobian[eqIndex0][localDofIndexSpecies] += m_dt * dSpeciesFlux_dLogConc[ke][is][js] * m_mobilePrimarySpeciesFlags[is];
286  stack.localFluxJacobian[eqIndex1][localDofIndexSpecies] -= m_dt * dSpeciesFlux_dLogConc[ke][is][js] * m_mobilePrimarySpeciesFlags[is];
287  }
288  }
289  }
290 
291  // Customize the kernel with this lambda
292  kernelOp( k, seri, sesri, sei, connectionIndex, alpha, mobility, potGrad, fluxVal, dFlux_dP );
293  } );
294  }
295 
303  template< typename FUNC = NoOpFunc >
305  void computeDiffusion( localIndex const iconn,
306  StackVariables & stack,
307  FUNC && kernelOp = NoOpFunc{} ) const
308  {
309  using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >;
310  if( m_hasDiffusion )
311  {
312  // *****************************************************
313  // Computation of the diffusion term in the species flux
314 
315  // Step 1: compute the diffusion transmissibilities at this face
316  m_stencilWrapper.computeWeights( iconn,
318  m_dDiffusivity_dTemp,
320  stack.dDiffusionTrans_dT );
321 
323  localIndex connectionIndex = 0;
324 
325  for( k[0] = 0; k[0] < stack.numFluxElems; ++k[0] )
326  {
327  for( k[1] = k[0] + 1; k[1] < stack.numFluxElems; ++k[1] )
328  {
329  localIndex const seri[numFluxSupportPoints] = {m_seri( iconn, k[0] ), m_seri( iconn, k[1] )};
330  localIndex const sesri[numFluxSupportPoints] = {m_sesri( iconn, k[0] ), m_sesri( iconn, k[1] )};
331  localIndex const sei[numFluxSupportPoints] = {m_sei( iconn, k[0] ), m_sei( iconn, k[1] )};
332 
333  // clear working arrays
334  real64 diffusionFlux[numSpecies]{};
335  real64 speciesGrad[numSpecies]{};
336  real64 dDiffusionFlux_dP[numFluxSupportPoints][numSpecies]{};
337  real64 dDiffusionFlux_dLogConc[numFluxSupportPoints][numSpecies][numSpecies]{};
338 
339  real64 const diffusionTrans[numFluxSupportPoints] = { stack.diffusionTransmissibility[connectionIndex][0],
340  stack.diffusionTransmissibility[connectionIndex][1] };
341 
342  //***** calculation of flux *****
343  // loop over primary species
344  for( integer is = 0; is < numSpecies; ++is )
345  {
346  real64 dSpeciesGrad_i_dP[numFluxSupportPoints]{};
347  real64 dSpeciesGrad_i_dLogConc[numFluxSupportPoints][numSpecies]{};
348 
349  // Step 2: compute the gradient of the molarity, molality * solvent mass fraction * density
350  for( integer ke = 0; ke < numFluxSupportPoints; ++ke )
351  {
352  localIndex const er = seri[ke];
353  localIndex const esr = sesri[ke];
354  localIndex const ei = sei[ke];
355 
356  real64 const aggregateConcPerMass_i = m_primarySpeciesMobileAggregateConc[er][esr][ei][0][is] * m_solventMassFraction;
357  real64 const dens = m_dens[er][esr][ei][0];
358 
359  speciesGrad[is] += diffusionTrans[ke] * aggregateConcPerMass_i * dens;
360  dSpeciesGrad_i_dP[ke] += diffusionTrans[ke] * aggregateConcPerMass_i * m_dDens[er][esr][ei][0][DerivOffset::dP];
361 
362  for( integer js = 0; js < numSpecies; ++js )
363  {
364  real64 const dAggregateConcPerMass_i_dLogConc_j = m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc[er][esr][ei][0][is][js] * m_solventMassFraction;
365 
366  dSpeciesGrad_i_dLogConc[ke][js] += diffusionTrans[ke] * dAggregateConcPerMass_i_dLogConc_j * dens;
367  }
368  }
369 
370  // choose upstream cell for species upwinding
371  localIndex const k_up = (speciesGrad[is] >= 0) ? 0 : 1;
372 
373  localIndex const er_up = seri[k_up];
374  localIndex const esr_up = sesri[k_up];
375  localIndex const ei_up = sei[k_up];
376 
377  // computation of the upwinded species flux
378  diffusionFlux[is] += m_referencePorosity[er_up][esr_up][ei_up] * speciesGrad[is];
379 
380  // add contributions of the derivatives of component fractions wrt pressure/component fractions
381  for( integer ke = 0; ke < numFluxSupportPoints; ke++ )
382  {
383  dDiffusionFlux_dP[ke][is] += m_referencePorosity[er_up][esr_up][ei_up] * dSpeciesGrad_i_dP[ke];
384  for( integer js = 0; js < numSpecies; ++js )
385  {
386  dDiffusionFlux_dLogConc[ke][is][js] += m_referencePorosity[er_up][esr_up][ei_up] * dSpeciesGrad_i_dLogConc[ke][js];
387  }
388  }
389 
390  // Add the local diffusion flux contribution to the residual and Jacobian
391  integer const eqIndex0 = k[0] * numEqn + numEqn - numSpecies + is;
392  integer const eqIndex1 = k[1] * numEqn + numEqn - numSpecies + is;
393 
394  stack.localFlux[eqIndex0] += m_dt * diffusionFlux[is] * m_mobilePrimarySpeciesFlags[is];
395  stack.localFlux[eqIndex1] -= m_dt * diffusionFlux[is] * m_mobilePrimarySpeciesFlags[is];
396 
397  for( integer ke = 0; ke < numFluxSupportPoints; ++ke )
398  {
399  localIndex const localDofIndexPres = k[ke] * numDof;
400  stack.localFluxJacobian[eqIndex0][localDofIndexPres] += m_dt * dDiffusionFlux_dP[ke][is] * m_mobilePrimarySpeciesFlags[is];
401  stack.localFluxJacobian[eqIndex1][localDofIndexPres] -= m_dt * dDiffusionFlux_dP[ke][is] * m_mobilePrimarySpeciesFlags[is];
402 
403  for( integer js = 0; js < numSpecies; ++js )
404  {
405  localIndex const localDofIndexSpecies = localDofIndexPres + js + numDof - numSpecies;
406  stack.localFluxJacobian[eqIndex0][localDofIndexSpecies] += m_dt * dDiffusionFlux_dLogConc[ke][is][js] * m_mobilePrimarySpeciesFlags[is];
407  stack.localFluxJacobian[eqIndex1][localDofIndexSpecies] -= m_dt * dDiffusionFlux_dLogConc[ke][is][js] * m_mobilePrimarySpeciesFlags[is];
408  }
409  }
410 
411  // Customize the kernel with this lambda
412  kernelOp( is, k, seri, sesri, sei, connectionIndex, k_up );
413  } // loop over primary species
414  connectionIndex++;
415  }
416  }
417  }
418  }
419 
425  template< typename FUNC = NoOpFunc >
427  void complete( localIndex const iconn,
428  StackVariables & stack,
429  FUNC && kernelOp = NoOpFunc{} ) const
430  {
431  // Call Base::complete to assemble the total mass balance equation
432  // In the lambda, add contribution to residual and jacobian into the species amount balance equation
433  Base::complete( iconn, stack, [&] ( integer const i,
434  localIndex const localRow )
435  {
436  // The no. of fluxes is equal to the no. of equations in m_localRhs and m_localMatrix
437  for( integer is = 0; is < numSpecies; ++is )
438  {
439  RAJA::atomicAdd( parallelDeviceAtomic{}, &AbstractBase::m_localRhs[localRow + numEqn - numSpecies + is],
440  stack.localFlux[i * numEqn + numEqn - numSpecies + is] );
441  AbstractBase::m_localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic >
442  ( localRow + numEqn - numSpecies + is,
443  stack.dofColIndices.data(),
444  stack.localFluxJacobian[i * numEqn + numEqn - numSpecies + is].dataIfContiguous(),
445  stack.stencilSize * numDof );
446  }
447 
448  // call the lambda to assemble additional terms, such as thermal terms
449  kernelOp( i, localRow );
450  } );
451  }
452 
460  template< typename POLICY, typename KERNEL_TYPE >
461  static void
462  launch( localIndex const numConnections,
463  KERNEL_TYPE const & kernelComponent )
464  {
466 
467  forAll< POLICY >( numConnections, [=] GEOS_HOST_DEVICE ( localIndex const iconn )
468  {
469  typename KERNEL_TYPE::StackVariables stack( kernelComponent.stencilSize( iconn ),
470  kernelComponent.numPointsInFlux( iconn ) );
471 
472  kernelComponent.setup( iconn, stack );
473  kernelComponent.computeFlux( iconn, stack );
474  kernelComponent.computeDiffusion( iconn, stack );
475  kernelComponent.complete( iconn, stack );
476  } );
477  }
478 
479 protected:
480 
483 
486 
489 
492 
495  ElementViewConst< arrayView3d< real64 const > > const m_dDiffusivity_dTemp;
496 
499 
502 
505 
508 };
509 
514 {
515 public:
516 
534  template< typename POLICY, typename STENCILWRAPPER >
535  static void
536  createAndLaunch( integer const numSpecies,
537  integer const hasDiffusion,
538  arrayView1d< integer const > const mobilePrimarySpeciesFlags,
539  real64 const solventMassFraction,
540  globalIndex const rankOffset,
541  string const & dofKey,
542  string const & solverName,
543  ElementRegionManager const & elemManager,
544  STENCILWRAPPER const & stencilWrapper,
545  real64 const & dt,
546  CRSMatrixView< real64, globalIndex const > const & localMatrix,
547  arrayView1d< real64 > const & localRhs )
548  {
549  singlePhaseReactiveBaseKernels::internal::kernelLaunchSelectorCompSwitch( numSpecies, [&]( auto NS )
550  {
551  integer constexpr NUM_SPECIES = NS();
552  integer constexpr NUM_DOF = 1+NS();
553  integer constexpr NUM_EQN = 1+NS();
554 
556  elemManager.constructArrayViewAccessor< globalIndex, 1 >( dofKey );
557  dofNumberAccessor.setName( solverName + "/accessors/" + dofKey );
558 
560  typename KernelType::SinglePhaseFlowAccessors flowAccessors( elemManager, solverName );
561  typename KernelType::ReactiveSinglePhaseFlowAccessors reactiveFlowAccessors( elemManager, solverName );
562  typename KernelType::SinglePhaseFluidAccessors fluidAccessors( elemManager, solverName );
563  typename KernelType::ReactiveSinglePhaseFluidAccessors reactiveFluidAccessors( elemManager, solverName );
564  typename KernelType::PermeabilityAccessors permAccessors( elemManager, solverName );
565  typename KernelType::DiffusionAccessors diffusionAccessors( elemManager, solverName );
566  typename KernelType::PorosityAccessors porosityAccessors( elemManager, solverName );
567 
568  KernelType kernel( rankOffset, stencilWrapper, dofNumberAccessor,
569  flowAccessors, reactiveFlowAccessors, fluidAccessors, reactiveFluidAccessors,
570  permAccessors, diffusionAccessors, porosityAccessors, hasDiffusion, mobilePrimarySpeciesFlags,
571  solventMassFraction, dt, localMatrix, localRhs );
572  KernelType::template launch< POLICY >( stencilWrapper.size(), kernel );
573  } );
574  }
575 };
576 
577 } // namespace singlePhaseReactiveFVMKernels
578 
579 } // namespace geos
580 
581 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_REACTIVE_FLUXCOMPUTEKERNEL_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.
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
The ElementRegionManager class provides an interface to ObjectManagerBase in order to manage ElementR...
ElementViewAccessor< ArrayView< T const, NDIM, getUSD< PERM > > > constructArrayViewAccessor(string const &name, string const &neighborName=string()) const
This is a function to construct a ElementViewAccessor to access array data registered on the mesh.
array1d< array1d< VIEWTYPE > > ElementViewAccessor
The ElementViewAccessor at the ElementRegionManager level is an array of array of VIEWTYPE.
typename ElementViewAccessor< VIEWTYPE >::NestedViewTypeConst ElementViewConst
The ElementViewAccessor at the ElementRegionManager level is the type resulting from ElementViewAcces...
A struct to automatically construct and store element view accessors.
A struct to automatically construct and store element view accessors.
Base class for FluxComputeKernel that holds all data not dependent on template parameters (like stenc...
ElementViewConst< arrayView1d< real64 const > > const m_mob
Views on fluid mobility.
ElementViewConst< arrayView1d< globalIndex const > > const m_dofNumber
Views on dof numbers.
arrayView1d< real64 > const m_localRhs
View on the local RHS.
ElementViewConst< arrayView2d< real64 const, constitutive::singlefluid::USD_FLUID > > const m_dens
Views on fluid density.
globalIndex const m_rankOffset
Offset for my MPI rank.
CRSMatrixView< real64, globalIndex const > const m_localMatrix
View on the local CRS matrix.
Define the interface for the assembly kernel in charge of flux terms.
static constexpr integer numEqn
Compute time value for the number of equations.
static constexpr localIndex maxNumConns
Maximum number of connections at the face.
GEOS_HOST_DEVICE void complete(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Performs the complete phase for the kernel.
static constexpr localIndex maxStencilSize
Maximum number of points in the stencil.
STENCILWRAPPER::IndexContainerViewConstType const m_seri
Connection to element maps.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
STENCILWRAPPER const m_stencilWrapper
Reference to the stencil wrapper.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Compute the local flux contributions to the residual and Jacobian.
static constexpr localIndex maxNumElems
Maximum number of elements at the face.
static void createAndLaunch(integer const numSpecies, integer const hasDiffusion, arrayView1d< integer const > const mobilePrimarySpeciesFlags, real64 const solventMassFraction, globalIndex const rankOffset, string const &dofKey, string const &solverName, ElementRegionManager const &elemManager, STENCILWRAPPER const &stencilWrapper, real64 const &dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
Create a new kernel and launch.
Define the interface for the assembly kernel in charge of flux terms.
static constexpr integer numEqn
Compute time value for the number of equations.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Compute the local flux contributions to the residual and Jacobian.
static constexpr integer numSpecies
Compile time value for the number of primary species.
static constexpr localIndex maxNumConns
Maximum number of connections at the face.
ElementViewConst< arrayView2d< real64 const, compflow::USD_FLUID_DC > > const m_dMob_dLogPrimaryConc
Views on derivatives of fluid mobilities.
ElementViewConst< arrayView3d< real64 const, constitutive::reactivefluid::USD_SPECIES > > const m_primarySpeciesMobileAggregateConc
Views on primary species aggregate concentration.
GEOS_HOST_DEVICE void complete(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Performs the complete phase for the kernel.
integer const m_hasDiffusion
Flag of adding the diffusion term.
static constexpr integer numFluxSupportPoints
Number of flux support points (hard-coded for TFPA)
FluxComputeKernel(globalIndex const rankOffset, STENCILWRAPPER const &stencilWrapper, DofNumberAccessor const &dofNumberAccessor, SinglePhaseFlowAccessors const &singlePhaseFlowAccessors, ReactiveSinglePhaseFlowAccessors const &reactiveSinglePhaseFlowAccessors, SinglePhaseFluidAccessors const &singlePhaseFluidAccessors, ReactiveSinglePhaseFluidAccessors const &reactiveSinglePhaseFluidAccessors, PermeabilityAccessors const &permeabilityAccessors, DiffusionAccessors const &diffusionAccessors, PorosityAccessors const &porosityAccessors, integer const &hasDiffusion, arrayView1d< integer const > const &mobilePrimarySpeciesFlags, real64 const &solventMassFraction, real64 const &dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
Constructor for the kernel interface.
ElementRegionManager::ElementViewConst< VIEWTYPE > ElementViewConst
The type for element-based data. Consists entirely of ArrayView's.
STENCILWRAPPER::IndexContainerViewConstType const m_seri
Connection to element maps.
ElementViewConst< arrayView1d< real64 const > > const m_referencePorosity
View on the reference porosity.
arrayView1d< integer const > const m_mobilePrimarySpeciesFlags
Array of flags to indicate mobile primary species.
ElementViewConst< arrayView4d< real64 const, constitutive::reactivefluid::USD_SPECIES_DC > > const m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc
Views on the derivative of primary species mobile aggregate concentration wrt log of primary concentr...
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
ElementViewConst< arrayView2d< real64 const, compflow::USD_COMP > > const m_logPrimarySpeciesConc
Views on log of primary species concentration.
GEOS_HOST_DEVICE void computeDiffusion(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Compute the local diffusion contributions to the residual and Jacobian.
ElementViewConst< arrayView3d< real64 const > > const m_diffusivity
Views on diffusivity.
ElementViewConst< arrayView2d< real64 const, constitutive::singlefluid::USD_FLUID > > const m_dens
Views on fluid density.
real64 const m_solventMassFraction
Mass fraction of solvent in the solution [-]; molality times this fraction is the amount per kg of so...
STENCILWRAPPER const m_stencilWrapper
Reference to the stencil wrapper.
static void launch(localIndex const numConnections, KERNEL_TYPE const &kernelComponent)
Performs the kernel launch.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:87
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
LvArray::CRSMatrixView< T, COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:309
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Kernel variables (dof numbers, jacobian and residual) located on the stack.
real64 dTrans_dPres[maxNumConns][2]
Derivatives of transmissibility with respect to pressure.
stackArray1d< globalIndex, maxNumElems *numDof > dofColIndices
Indices of the matrix rows/columns corresponding to the dofs in this face.
stackArray1d< real64, maxNumElems *numEqn > localFlux
Storage for the face local residual vector (all equations except volume balance)
localIndex const stencilSize
Stencil size for a given connection.
stackArray2d< real64, maxNumElems *numEqn *maxStencilSize *numDof > localFluxJacobian
Storage for the face local Jacobian matrix.
localIndex const numFluxElems
Number of elements for a given connection.
Kernel variables (dof numbers, jacobian and residual) located on the stack.
GEOS_HOST_DEVICE StackVariables(localIndex const size, localIndex numElems)
Constructor for the stack variables.
real64 diffusionTransmissibility[maxNumConns][numFluxSupportPoints]
Diffusion transmissibility.
real64 dDiffusionTrans_dT[maxNumConns][numFluxSupportPoints]
Derivatives of diffusion transmissibility with respect to temperature.