GEOS
SolutionCheckKernel.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_SOLUTIONCHECKKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_SOLUTIONCHECKKERNEL_HPP
22 
23 #include "common/DataTypes.hpp"
24 #include "common/GEOS_RAJA_Interface.hpp"
27 
28 namespace geos
29 {
30 
31 namespace singlePhaseBaseKernels
32 {
33 
34 /******************************** SolutionCheckKernel ********************************/
35 
37 {
38 
39  struct KernelStats
40  {
41  real64 minNegPres;
42  };
43 
44  template< typename POLICY >
45  static KernelStats launch( arrayView1d< real64 const > const & localSolution,
46  globalIndex const rankOffset,
47  arrayView1d< globalIndex const > const & dofNumber,
48  arrayView1d< integer const > const & ghostRank,
49  arrayView1d< real64 const > const & pres,
50  flowSolverUtilities::ScalingType const scalingType,
51  real64 const scalingFactor,
52  arrayView1d< real64 const > const & perElementScaling,
53  ElementsReporterCollector const & negPressureIds )
54  {
55  using reducePolicy = ReducePolicy< POLICY >;
56  using atomicPolicy = AtomicPolicy< POLICY >;
57  RAJA::ReduceMin< reducePolicy, real64 > minNegPres( 0.0 );
58 
59  bool const localScaling = scalingType == flowSolverUtilities::ScalingType::Local;
60 
61  forAll< POLICY >( dofNumber.size(), [=] GEOS_HOST_DEVICE ( localIndex const ei )
62  {
63  if( ghostRank[ei] < 0 && dofNumber[ei] >= 0 )
64  {
65  localIndex const lid = dofNumber[ei] - rankOffset;
66  real64 const newPres = pres[ei] + ( localScaling ? perElementScaling[ei] : scalingFactor ) * localSolution[lid];
67 
68  if( newPres <= 0.0 )
69  {
70  minNegPres.min( newPres );
71  negPressureIds.collectElement( atomicPolicy{}, { ei, newPres } );
72  }
73  }
74 
75  } );
76 
77  return KernelStats{ minNegPres.get() };
78  }
79 
80 };
81 
82 } // namespace singlePhaseBaseKernels
83 
84 } // namespace geos
85 
86 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_SOLUTIONCHECKKERNEL_HPP
ScalingType
Solution scaling type.
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
Collects and reports elements ids and data using an atomic counter. This class provides functionality...
GEOS_HOST_DEVICE void collectElement(CollectorAtomicPolicy, ElementReport const &report) const
Collects a single element report and adds its ID to the output buffer if not disabled and there are a...
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