-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathFieldStatisticsBase.hpp
More file actions
132 lines (106 loc) · 3.87 KB
/
Copy pathFieldStatisticsBase.hpp
File metadata and controls
132 lines (106 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* ------------------------------------------------------------------------------------------------------------
* SPDX-License-Identifier: LGPL-2.1-only
*
* Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2024 TotalEnergies
* Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2023-2024 Chevron
* Copyright (c) 2019- GEOS/GEOSX Contributors
* All rights reserved
*
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
* ------------------------------------------------------------------------------------------------------------
*/
/**
* @file FieldStatisticsBase.hpp
*/
#ifndef SRC_CORECOMPONENTS_PHYSICSSOLVERS_FIELDSTATISTICSBASE_HPP_
#define SRC_CORECOMPONENTS_PHYSICSSOLVERS_FIELDSTATISTICSBASE_HPP_
#include "events/tasks/TaskBase.hpp"
#include "physicsSolvers/PhysicsSolverManager.hpp"
#include "mesh/MeshLevel.hpp"
#include "fileIO/Outputs/OutputBase.hpp"
namespace geos
{
/**
* @class FieldStatisticsBase
*
* Base task class allowing for the computation of aggregate statistics
*/
template< typename SOLVER >
class FieldStatisticsBase : public TaskBase
{
public:
/**
* @brief Constructor for the statistics class
* @param[in] name the name of the task coming from the xml
* @param[in] parent the parent group of the task
*/
FieldStatisticsBase( const string & name,
Group * const parent )
: TaskBase( name, parent ),
m_solver( nullptr ),
m_outputDir( joinPath( OutputBase::getOutputDirectory(), name ) )
{
registerWrapper( getSolverWrapperKey(), &m_solverName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( dataRepository::InputFlags::REQUIRED ).
setDescription( "Name of the " + SOLVER::coupledSolverAttributePrefix() + " solver" );
this->registerWrapper( viewKeyStruct::writeCSVFlagString(), &m_writeCSV ).
setApplyDefaultValue( 0 ).
setInputFlag( dataRepository::InputFlags::OPTIONAL ).
setDescription( "When set to 1, write the statistics into a CSV file" );
}
/**
* @defgroup Tasks Interface Functions
*
* This function implements the interface defined by the abstract TaskBase class
*/
/**@{*/
virtual bool execute( real64 const time_n,
real64 const dt,
integer const cycleNumber,
integer const eventCounter,
real64 const eventProgress,
DomainPartition & domain ) override = 0;
/**@}*/
protected:
struct viewKeyStruct
{
static constexpr char const * writeCSVFlagString() { return "writeCSV"; }
};
/// Pointer to the physics solver
SOLVER * m_solver;
// Output directory
string const m_outputDir;
// Flag to enable writing CSV output
integer m_writeCSV;
void postInputInitialization() override
{
Group & problemManager = this->getGroupByPath( "/Problem" );
Group & physicsSolverManager = problemManager.getGroup( "Solvers" );
m_solver = physicsSolverManager.getGroupPointer< SOLVER >( m_solverName );
GEOS_THROW_IF( m_solver == nullptr,
GEOS_FMT( "Could not find solver '{}' of type {}",
m_solverName, LvArray::system::demangleType< SOLVER >() ),
InputError, getDataContext() );
// create dir for output
if( m_writeCSV > 0 )
{
if( MpiWrapper::commRank() == 0 )
{
makeDirsForPath( m_outputDir );
}
// wait till the dir is created by rank 0
MPI_Barrier( MPI_COMM_WORLD );
}
}
string getSolverWrapperKey() const
{ return SOLVER::coupledSolverAttributePrefix() + "SolverName"; }
private:
/// Name of the solver
string m_solverName;
};
} /* namespace geos */
#endif /* SRC_CORECOMPONENTS_PHYSICSSOLVERS_FIELDSTATISTICSBASE_HPP_ */