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 
129  FluxComputeKernel( globalIndex const rankOffset,
130  STENCILWRAPPER const & stencilWrapper,
131  DofNumberAccessor const & dofNumberAccessor,
132  SinglePhaseFlowAccessors const & singlePhaseFlowAccessors,
133  ReactiveSinglePhaseFlowAccessors const & reactiveSinglePhaseFlowAccessors,
134  SinglePhaseFluidAccessors const & singlePhaseFluidAccessors,
135  ReactiveSinglePhaseFluidAccessors const & reactiveSinglePhaseFluidAccessors,
136  PermeabilityAccessors const & permeabilityAccessors,
137  DiffusionAccessors const & diffusionAccessors,
138  PorosityAccessors const & porosityAccessors,
139  integer const & hasDiffusion,
140  arrayView1d< integer const > const & mobilePrimarySpeciesFlags,
141  real64 const & dt,
142  CRSMatrixView< real64, globalIndex const > const & localMatrix,
143  arrayView1d< real64 > const & localRhs )
144  : Base( rankOffset,
145  stencilWrapper,
146  dofNumberAccessor,
147  singlePhaseFlowAccessors,
148  singlePhaseFluidAccessors,
149  permeabilityAccessors,
150  dt,
151  localMatrix,
152  localRhs ),
153  m_logPrimarySpeciesConc( reactiveSinglePhaseFlowAccessors.get( fields::flow::logPrimarySpeciesConcentration {} ) ),
154  m_dMob_dLogPrimaryConc( reactiveSinglePhaseFlowAccessors.get( fields::flow::dMobility_dLogPrimaryConc {} ) ),
155  m_primarySpeciesMobileAggregateConc( reactiveSinglePhaseFluidAccessors.get( fields::reactivefluid::primarySpeciesMobileAggregateConcentration {} ) ),
156  m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc( reactiveSinglePhaseFluidAccessors.get(
157  fields::reactivefluid::dPrimarySpeciesMobileAggregateConcentration_dLogPrimarySpeciesConcentrations {} ) ),
158  m_diffusivity( diffusionAccessors.get( fields::diffusion::diffusivity {} ) ),
159  m_dDiffusivity_dTemp( diffusionAccessors.get( fields::diffusion::dDiffusivity_dTemperature {} ) ),
160  m_referencePorosity( porosityAccessors.get( fields::porosity::referencePorosity {} ) ),
161  m_hasDiffusion( hasDiffusion ),
162  m_mobilePrimarySpeciesFlags( mobilePrimarySpeciesFlags )
163  {}
164 
170  {
171 public:
172 
179  StackVariables( localIndex const size, localIndex numElems )
180  : Base::StackVariables( size, numElems )
181  {}
182 
190 
195 
196  };
197 
205  template< typename FUNC = NoOpFunc >
207  void computeFlux( localIndex const iconn,
208  StackVariables & stack,
209  FUNC && kernelOp = NoOpFunc{} ) const
210  {
211  using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >;
212  // ***********************************************
213  // First, we call the base computeFlux to compute:
214  // 1) massFlux and its derivatives,
215  // 2) speciesFlux and its derivatives
216  Base::computeFlux( iconn, stack, [&] ( localIndex const (&k)[2],
217  localIndex const (&seri)[2],
218  localIndex const (&sesri)[2],
219  localIndex const (&sei)[2],
220  localIndex const connectionIndex,
221  real64 const alpha,
222  real64 const mobility,
223  real64 const & potGrad,
224  real64 const & fluxVal,
225  real64 const (&dFlux_dP)[2] )
226  {
227  // Step 1: compute the derivatives of the fluid density, potential difference,
228  // and the massFlux wrt log of primary species concentration (to complete)
229  real64 dFlux_dLogConc[numFluxSupportPoints][numSpecies]{};
230 
231  GEOS_UNUSED_VAR( dFlux_dLogConc ); // Todo: to add the massFlux derivatives wrt speciesConc
232 
233  // Step 2: compute the speciesFlux
234  real64 speciesFlux[numSpecies]{};
235  real64 dSpeciesFlux_dP[numFluxSupportPoints][numSpecies]{};
236  real64 dSpeciesFlux_dLogConc[numFluxSupportPoints][numSpecies][numSpecies]{};
237  // real64 dSpeciesFlux_dTrans[numSpecies]{};
238 
239  // choose upstream cell
240  localIndex const k_up = (potGrad >= 0) ? 0 : 1;
241 
242  localIndex const er_up = seri[k_up];
243  localIndex const esr_up = sesri[k_up];
244  localIndex const ei_up = sei[k_up];
245 
246  real64 const fluidDens_up = m_dens[er_up][esr_up][ei_up][0];
247  real64 const dDens_dPres = m_dDens[er_up][esr_up][ei_up][0][DerivOffset::dP];
248 
249  // compute species fluxes and derivatives using upstream cell concentration
250  for( integer is = 0; is < numSpecies; ++is )
251  {
252  real64 const aggregateConc_i = m_primarySpeciesMobileAggregateConc[er_up][esr_up][ei_up][0][is];
253  speciesFlux[is] = aggregateConc_i / fluidDens_up * fluxVal;
254 
255  for( integer ke = 0; ke < numFluxSupportPoints; ++ke )
256  {
257  dSpeciesFlux_dP[ke][is] += aggregateConc_i / fluidDens_up * dFlux_dP[ke];
258  }
259 
260  dSpeciesFlux_dP[k_up][is] += -aggregateConc_i * fluxVal * dDens_dPres / (fluidDens_up * fluidDens_up);
261 
262  for( integer js = 0; js < numSpecies; ++js )
263  {
264  real64 const dAggregateConc_i_dLogConc_j = m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc[er_up][esr_up][ei_up][0][is][js];
265  dSpeciesFlux_dLogConc[k_up][is][js] += dAggregateConc_i_dLogConc_j / fluidDens_up * fluxVal;
266  }
267  }
268 
270  for( integer is = 0; is < numSpecies; ++is )
271  {
272  integer const eqIndex0 = k[0] * numEqn + numEqn - numSpecies + is;
273  integer const eqIndex1 = k[1] * numEqn + numEqn - numSpecies + is;
274 
275  stack.localFlux[eqIndex0] += m_dt * speciesFlux[is] * m_mobilePrimarySpeciesFlags[is];
276  stack.localFlux[eqIndex1] -= m_dt * speciesFlux[is] * m_mobilePrimarySpeciesFlags[is];
277 
278  for( integer ke = 0; ke < numFluxSupportPoints; ++ke )
279  {
280  localIndex const localDofIndexPres = k[ke] * numDof;
281  stack.localFluxJacobian[eqIndex0][localDofIndexPres] += m_dt * dSpeciesFlux_dP[ke][is] * m_mobilePrimarySpeciesFlags[is];
282  stack.localFluxJacobian[eqIndex1][localDofIndexPres] -= m_dt * dSpeciesFlux_dP[ke][is] * m_mobilePrimarySpeciesFlags[is];
283 
284  for( integer js = 0; js < numSpecies; ++js )
285  {
286  localIndex const localDofIndexSpecies = localDofIndexPres + js + numDof - numSpecies;
287  stack.localFluxJacobian[eqIndex0][localDofIndexSpecies] += m_dt * dSpeciesFlux_dLogConc[ke][is][js] * m_mobilePrimarySpeciesFlags[is];
288  stack.localFluxJacobian[eqIndex1][localDofIndexSpecies] -= m_dt * dSpeciesFlux_dLogConc[ke][is][js] * m_mobilePrimarySpeciesFlags[is];
289  }
290  }
291  }
292 
293  // Customize the kernel with this lambda
294  kernelOp( k, seri, sesri, sei, connectionIndex, alpha, mobility, potGrad, fluxVal, dFlux_dP, fluidDens_up );
295  } );
296  }
297 
305  template< typename FUNC = NoOpFunc >
307  void computeDiffusion( localIndex const iconn,
308  StackVariables & stack,
309  FUNC && kernelOp = NoOpFunc{} ) const
310  {
311  if( m_hasDiffusion )
312  {
313  // *****************************************************
314  // Computation of the diffusion term in the species flux
315 
316  // Step 1: compute the diffusion transmissibilities at this face
317  m_stencilWrapper.computeWeights( iconn,
319  m_dDiffusivity_dTemp,
321  stack.dDiffusionTrans_dT );
322 
324  localIndex connectionIndex = 0;
325 
326  for( k[0] = 0; k[0] < stack.numFluxElems; ++k[0] )
327  {
328  for( k[1] = k[0] + 1; k[1] < stack.numFluxElems; ++k[1] )
329  {
330  localIndex const seri[numFluxSupportPoints] = {m_seri( iconn, k[0] ), m_seri( iconn, k[1] )};
331  localIndex const sesri[numFluxSupportPoints] = {m_sesri( iconn, k[0] ), m_sesri( iconn, k[1] )};
332  localIndex const sei[numFluxSupportPoints] = {m_sei( iconn, k[0] ), m_sei( iconn, k[1] )};
333 
334  // clear working arrays
335  real64 diffusionFlux[numSpecies]{};
336  real64 speciesGrad[numSpecies]{};
337  // real64 dDiffusionFlux_dP[numFluxSupportPoints][numSpecies]{}; // Turn on if diffusionFlux is pressure-dependent
338  real64 dDiffusionFlux_dLogConc[numFluxSupportPoints][numSpecies][numSpecies]{};
339 
340  real64 const diffusionTrans[numFluxSupportPoints] = { stack.diffusionTransmissibility[connectionIndex][0],
341  stack.diffusionTransmissibility[connectionIndex][1] };
342 
343  //***** calculation of flux *****
344  // loop over primary species
345  for( integer is = 0; is < numSpecies; ++is )
346  {
347  // real64 dSpeciesGrad_i_dP[numFluxSupportPoints]{}; // Turn on if speciesGrad is pressure-dependent
348  real64 dSpeciesGrad_i_dLogConc[numFluxSupportPoints][numSpecies]{};
349 
350  // Step 2: compute species gradient
351  for( integer ke = 0; ke < numFluxSupportPoints; ++ke )
352  {
353  localIndex const er = seri[ke];
354  localIndex const esr = sesri[ke];
355  localIndex const ei = sei[ke];
356 
357  real64 const aggregateConc_i = m_primarySpeciesMobileAggregateConc[er][esr][ei][0][is];
358 
359  speciesGrad[is] += diffusionTrans[ke] * aggregateConc_i;
360 
361  for( integer js = 0; js < numSpecies; ++js )
362  {
363  real64 const dAggregateConc_i_dLogConc_j = m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc[er][esr][ei][0][is][js];
364 
365  dSpeciesGrad_i_dLogConc[ke][js] += diffusionTrans[ke] * dAggregateConc_i_dLogConc_j;
366  }
367  }
368 
369  // choose upstream cell for species upwinding
370  localIndex const k_up = (speciesGrad[is] >= 0) ? 0 : 1;
371 
372  localIndex const er_up = seri[k_up];
373  localIndex const esr_up = sesri[k_up];
374  localIndex const ei_up = sei[k_up];
375 
376  // computation of the upwinded species flux
377  diffusionFlux[is] += m_referencePorosity[er_up][esr_up][ei_up] * speciesGrad[is];
378 
379  // add contributions of the derivatives of component fractions wrt pressure/component fractions
380  for( integer ke = 0; ke < numFluxSupportPoints; ke++ )
381  {
382  for( integer js = 0; js < numSpecies; ++js )
383  {
384  dDiffusionFlux_dLogConc[ke][is][js] += m_referencePorosity[er_up][esr_up][ei_up] * dSpeciesGrad_i_dLogConc[ke][js];
385  }
386  }
387 
388  // Add the local diffusion flux contribution to the residual and Jacobian
389  integer const eqIndex0 = k[0] * numEqn + numEqn - numSpecies + is;
390  integer const eqIndex1 = k[1] * numEqn + numEqn - numSpecies + is;
391 
392  stack.localFlux[eqIndex0] += m_dt * diffusionFlux[is] * m_mobilePrimarySpeciesFlags[is];
393  stack.localFlux[eqIndex1] -= m_dt * diffusionFlux[is] * m_mobilePrimarySpeciesFlags[is];
394 
395  for( integer ke = 0; ke < numFluxSupportPoints; ++ke )
396  {
397  localIndex const localDofIndexPres = k[ke] * numDof;
398  // stack.localFluxJacobian[eqIndex0][localDofIndexPres] += m_dt * dDiffusionFlux_dP[ke][is] * m_mobilePrimarySpeciesFlags[is];
399  // stack.localFluxJacobian[eqIndex1][localDofIndexPres] -= m_dt * dDiffusionFlux_dP[ke][is] * m_mobilePrimarySpeciesFlags[is];
400 
401  for( integer js = 0; js < numSpecies; ++js )
402  {
403  localIndex const localDofIndexSpecies = localDofIndexPres + js + numDof - numSpecies;
404  stack.localFluxJacobian[eqIndex0][localDofIndexSpecies] += m_dt * dDiffusionFlux_dLogConc[ke][is][js] * m_mobilePrimarySpeciesFlags[is];
405  stack.localFluxJacobian[eqIndex1][localDofIndexSpecies] -= m_dt * dDiffusionFlux_dLogConc[ke][is][js] * m_mobilePrimarySpeciesFlags[is];
406  }
407  }
408 
409  // Customize the kernel with this lambda
410  kernelOp( is, k, seri, sesri, sei, connectionIndex, k_up );
411  } // loop over primary species
412  connectionIndex++;
413  }
414  }
415  }
416  }
417 
423  template< typename FUNC = NoOpFunc >
425  void complete( localIndex const iconn,
426  StackVariables & stack,
427  FUNC && kernelOp = NoOpFunc{} ) const
428  {
429  // Call Base::complete to assemble the total mass balance equation
430  // In the lambda, add contribution to residual and jacobian into the species amount balance equation
431  Base::complete( iconn, stack, [&] ( integer const i,
432  localIndex const localRow )
433  {
434  // The no. of fluxes is equal to the no. of equations in m_localRhs and m_localMatrix
435  for( integer is = 0; is < numSpecies; ++is )
436  {
437  RAJA::atomicAdd( parallelDeviceAtomic{}, &AbstractBase::m_localRhs[localRow + numEqn - numSpecies + is],
438  stack.localFlux[i * numEqn + numEqn - numSpecies + is] );
439  AbstractBase::m_localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic >
440  ( localRow + numEqn - numSpecies + is,
441  stack.dofColIndices.data(),
442  stack.localFluxJacobian[i * numEqn + numEqn - numSpecies + is].dataIfContiguous(),
443  stack.stencilSize * numDof );
444  }
445 
446  // call the lambda to assemble additional terms, such as thermal terms
447  kernelOp( i, localRow );
448  } );
449  }
450 
458  template< typename POLICY, typename KERNEL_TYPE >
459  static void
460  launch( localIndex const numConnections,
461  KERNEL_TYPE const & kernelComponent )
462  {
464 
465  forAll< POLICY >( numConnections, [=] GEOS_HOST_DEVICE ( localIndex const iconn )
466  {
467  typename KERNEL_TYPE::StackVariables stack( kernelComponent.stencilSize( iconn ),
468  kernelComponent.numPointsInFlux( iconn ) );
469 
470  kernelComponent.setup( iconn, stack );
471  kernelComponent.computeFlux( iconn, stack );
472  kernelComponent.computeDiffusion( iconn, stack );
473  kernelComponent.complete( iconn, stack );
474  } );
475  }
476 
477 protected:
478 
481 
484 
487 
490 
493  ElementViewConst< arrayView3d< real64 const > > const m_dDiffusivity_dTemp;
494 
497 
500 
503 };
504 
509 {
510 public:
511 
528  template< typename POLICY, typename STENCILWRAPPER >
529  static void
530  createAndLaunch( integer const numSpecies,
531  integer const hasDiffusion,
532  arrayView1d< integer const > const mobilePrimarySpeciesFlags,
533  globalIndex const rankOffset,
534  string const & dofKey,
535  string const & solverName,
536  ElementRegionManager const & elemManager,
537  STENCILWRAPPER const & stencilWrapper,
538  real64 const & dt,
539  CRSMatrixView< real64, globalIndex const > const & localMatrix,
540  arrayView1d< real64 > const & localRhs )
541  {
542  singlePhaseReactiveBaseKernels::internal::kernelLaunchSelectorCompSwitch( numSpecies, [&]( auto NS )
543  {
544  integer constexpr NUM_SPECIES = NS();
545  integer constexpr NUM_DOF = 1+NS();
546  integer constexpr NUM_EQN = 1+NS();
547 
549  elemManager.constructArrayViewAccessor< globalIndex, 1 >( dofKey );
550  dofNumberAccessor.setName( solverName + "/accessors/" + dofKey );
551 
553  typename KernelType::SinglePhaseFlowAccessors flowAccessors( elemManager, solverName );
554  typename KernelType::ReactiveSinglePhaseFlowAccessors reactiveFlowAccessors( elemManager, solverName );
555  typename KernelType::SinglePhaseFluidAccessors fluidAccessors( elemManager, solverName );
556  typename KernelType::ReactiveSinglePhaseFluidAccessors reactiveFluidAccessors( elemManager, solverName );
557  typename KernelType::PermeabilityAccessors permAccessors( elemManager, solverName );
558  typename KernelType::DiffusionAccessors diffusionAccessors( elemManager, solverName );
559  typename KernelType::PorosityAccessors porosityAccessors( elemManager, solverName );
560 
561  KernelType kernel( rankOffset, stencilWrapper, dofNumberAccessor,
562  flowAccessors, reactiveFlowAccessors, fluidAccessors, reactiveFluidAccessors,
563  permAccessors, diffusionAccessors, porosityAccessors, hasDiffusion, mobilePrimarySpeciesFlags,
564  dt, localMatrix, localRhs );
565  KernelType::template launch< POLICY >( stencilWrapper.size(), kernel );
566  } );
567  }
568 };
569 
570 } // namespace singlePhaseReactiveFVMKernels
571 
572 } // namespace geos
573 
574 #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.
Definition: GeosxMacros.hpp:84
#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, 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)
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...
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 &dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
Constructor for the kernel interface.
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.
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.