GEOS
SolutionCheckHelpers.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_SOLUTIONCHECKHELPERS_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SOLUTIONCHECKHELPERS_HPP
22 
24 #include "common/Units.hpp"
25 
26 namespace geos
27 {
28 
33 {
34 public:
35 
37  using ElementCount = ElementsReporterCollector::ElementCount;
38 
44 
49  { return m_ranksSignaledElementsCount; }
50 
55  { return m_ranksCollectedElementsCount; }
56 
66  void outputTooLowValues( string_view linesPrefix,
67  string_view valueNaming,
68  real64 minValue,
69  units::Unit valueUnit ) const;
70 
71 private:
72 
74  ElementsReporterBuffer const & m_buffer;
75 
77  ElementCount m_ranksSignaledElementsCount;
78 
80  ElementCount m_ranksCollectedElementsCount;
81 
82 };
83 
89 {
90 public:
91 
93  using ElementCount = ElementsReporterCollector::ElementCount;
94 
100  ElementsReporterBuffer( bool enabled, ElementCount maxCollectionSize );
101 
106 
111 
116 
121 
126  { return m_elementsCounter.empty() ? 0 : m_elementsCounter[0]; }
127 
132  { return LvArray::math::min( getSignaledElementsCount(), m_elementsBuffer.size() ); }
133 
138  { return m_elementsBuffer[id]; }
139 
143  auto begin() const
144  { return m_elementsBuffer.begin(); }
145 
149  auto end() const
150  { return m_elementsBuffer.begin() + getCollectedElementsCount(); }
151 
155  bool enabled() const
156  { return !m_elementsCounter.empty(); }
157 
161  bool empty() const
162  { return getCollectedElementsCount() == 0; }
163 
167  bool isComplete() const
169 
174 
175  ElementsReporterOutput createOutput() const;
176 
177 private:
178 
179  // array of one element to get benefit of managed host-device memory.
180  array1d< ElementCount > m_elementsCounter;
181 
182  // Preallocated array of ids of detected elements
183  array1d< ElementReport > m_elementsBuffer;
184 
185 };
186 
187 } // namespace geos
188 
189 
190 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_SOLUTIONCHECKHELPERS_HPP
Enumerates the Units that are in use in GEOS and regroups useful conversion and formatting functions.
Unit
Enumerator of available unit types for given physical scales. Units are in SI by default.
Definition: Units.hpp:59
A buffer to count and store element ids during kernel execution. This facilitates the reporting mecha...
ElementsReporterCollector::ElementCount ElementCount
Type alias for elements count (e.g., localIndex, globalIndex).
ElementCount getCollectedElementsCount() const
ElementCount getSignaledElementsCount() const
ElementsReporterCollector createCollector(arrayView1d< globalIndex const > const &localToGlobalId) const
ElementsReporterBuffer(bool enabled, ElementCount maxCollectionSize)
Construct a preallocated buffer to collect a limited quantity of ids in kernels.
ElementsReporterBuffer & operator=(ElementsReporterBuffer &&other)=default
Transfers ownership of an ElementsReporterBuffer to another instance (move semantics).
ElementsReporterBuffer(ElementsReporterBuffer &&other)=default
Transfers ownership of an ElementsReporterBuffer to another instance (move semantics).
ElementReport const & operator[](ElementCount id) const
ElementsReporterBuffer & operator=(ElementsReporterBuffer const &)=delete
Copying prevented as it doesn't seem relevant / useful.
ElementsReporterBuffer(ElementsReporterBuffer const &)=delete
Copying prevented as it doesn't seem relevant / useful.
Collects and reports elements ids and data using an atomic counter. This class provides functionality...
A class to report elements collected by the solver.
ElementsReporterCollector::ElementCount ElementCount
Type alias for elements count (e.g., localIndex, globalIndex).
ElementCount getRanksCollectedIdsCount() const
ElementsReporterOutput(ElementsReporterBuffer const &buffer)
Construct a preallocated buffer for collecting element ids in kernels.
void outputTooLowValues(string_view linesPrefix, string_view valueNaming, real64 minValue, units::Unit valueUnit) const
Report elements with values below a specified threshold in the log: Outputs lines indicating which va...
ElementCount getRanksSignaledIdsCount() const
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:175
std::string_view string_view
String type.
Definition: DataTypes.hpp:93