GEOS
ProblemManager.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 
21 #ifndef GEOS_MAININTERFACE_PROBLEMMANAGER_HPP_
22 #define GEOS_MAININTERFACE_PROBLEMMANAGER_HPP_
23 
24 #include "dataRepository/Group.hpp"
25 
26 namespace geos
27 {
28 
29 class PhysicsSolverManager;
30 class DomainPartition;
31 class GeometricObjectManager;
32 class FiniteElementDiscretization;
33 class MeshLevel;
34 namespace constitutive
35 {
36 class ConstitutiveManager;
37 }
38 class EventManager;
39 class TasksManager;
40 class FunctionManager;
41 class FieldSpecificationManager;
42 struct CommandLineOptions;
43 class CellBlockManagerABC;
44 class ParticleBlockManagerABC;
45 
51 {
52 public:
53 
58  explicit ProblemManager( conduit::Node & root );
59 
63  ~ProblemManager() override;
64 
75  virtual void setSchemaDeviations( xmlWrapper::xmlNode schemaRoot,
76  xmlWrapper::xmlNode schemaParent,
77  integer documentationType ) override;
78 
87  virtual Group * createChild( string const & childKey, string const & childName ) override;
88 
93 
100  static bool parseRestart( string & restartFileName, CommandLineOptions const & options );
101 
111 
117 
123  void parseInputString( string const & xmlString );
124 
131 
135  void generateMesh();
136 
140  void importFields();
141 
147 
152  void initializationOrder( string_array & order ) override final;
153 
157  void problemSetup();
158 
164 
169 
174 
180 
186 
191  string const & getProblemName() const
192  { return getGroup< Group >( groupKeys.commandLine ).getReference< string >( viewKeys.problemName ); }
193 
198  string const & getInputFileName() const
199  { return getGroup< Group >( groupKeys.commandLine ).getReference< string >( viewKeys.inputFileName ); }
200 
205  string const & getRestartFileName() const
206  { return getGroup< Group >( groupKeys.commandLine ).getReference< string >( viewKeys.restartFileName ); }
207 
212  string const & getSchemaFileName() const
213  { return getGroup< Group >( groupKeys.commandLine ).getReference< string >( viewKeys.schemaFileName ); }
214 
217  {
219  dataRepository::ViewKey restartFileName = {"restartFileName"};
220  dataRepository::ViewKey beginFromRestart = {"beginFromRestart"};
221  dataRepository::ViewKey xPartitionsOverride = {"xPartitionsOverride"};
223  dataRepository::ViewKey yPartitionsOverride = {"yPartitionsOverride"};
225  dataRepository::ViewKey zPartitionsOverride = {"zPartitionsOverride"};
227  dataRepository::ViewKey overridePartitionNumbers = {"overridePartitionNumbers"};
231  dataRepository::ViewKey outputDirectory = {"outputDirectory"};
232  dataRepository::ViewKey useNonblockingMPI = {"useNonblockingMPI"};
236 
239  {
241  static constexpr char const * numericalMethodsManagerString() { return "NumericalMethods"; }
242  dataRepository::GroupKey commandLine = { "commandLine" };
256 
262  {
263  return *m_physicsSolverManager;
264  }
265 
271  {
272  return *m_physicsSolverManager;
273  }
274 
280  {
281  GEOS_ERROR_IF( m_functionManager == nullptr, "Not initialized." );
282  return *m_functionManager;
283  }
284 
290  {
291  GEOS_ERROR_IF( m_functionManager == nullptr, "Not initialized." );
292  return *m_functionManager;
293  }
294 
300  {
301  GEOS_ERROR_IF( m_fieldSpecificationManager == nullptr, "Not initialized." );
302  return *m_fieldSpecificationManager;
303  }
304 
310  {
311  GEOS_ERROR_IF( m_fieldSpecificationManager == nullptr, "Not initialized." );
312  return *m_fieldSpecificationManager;
313  }
314 
320  {return *m_eventManager;}
321 
327  {return *m_tasksManager;}
328 
329 protected:
333  virtual void postInputInitialization() override final;
334 
335 private:
336 
347  map< std::tuple< string, string, string, string >, localIndex > calculateRegionQuadrature( Group & meshBodies );
348 
349 
350  map< std::pair< string, Group const * const >, arrayView1d< string const > const >
351  getDiscretizations() const;
352 
353  void generateMeshLevel( MeshLevel & meshLevel,
354  CellBlockManagerABC const & cellBlockManager,
355  Group const * const discretization,
356  arrayView1d< string const > const & targetRegions );
357 
358  void generateMeshLevel( MeshLevel & meshLevel,
359  ParticleBlockManagerABC & particleBlockManager,
360  arrayView1d< string const > const & );
361 
370  void setRegionQuadrature( Group & meshBodies,
371  constitutive::ConstitutiveManager const & constitutiveManager,
372  map< std::tuple< string, string, string, string >, localIndex > const & regionQuadrature );
373 
375  PhysicsSolverManager * m_physicsSolverManager;
376 
378  EventManager * m_eventManager;
379 
381  TasksManager * m_tasksManager;
382 
384  FunctionManager * m_functionManager;
385 
387  FieldSpecificationManager * m_fieldSpecificationManager;
388 };
389 
390 } /* namespace geos */
391 
392 #endif /* GEOS_MAININTERFACE_PROBLEMMANAGER_HPP_ */
#define GEOS_ERROR_IF(EXP, msg)
Conditionally raise a hard error and terminate the program.
Definition: Logger.hpp:142
Abstract base class for CellBlockManager.
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
Abstract base class for ParticleBlockManager.
This is the class handling the operation flow of the problem being ran in GEOS.
string const & getProblemName() const
Returns the problem name.
PhysicsSolverManager const & getPhysicsSolverManager() const
Returns the PhysicsSolverManager.
PhysicsSolverManager & getPhysicsSolverManager()
Returns the PhysicsSolverManager.
void initializationOrder(string_array &order) override final
Defines the order in which objects should be initialized.
void parseInputFile()
Parses the input xml file.
EventManager & getEventManager()
Returns the EventManager.
TasksManager & getTasksManager()
Returns the TasksManager.
static bool parseRestart(string &restartFileName, CommandLineOptions const &options)
Parses a restart file.
void problemSetup()
Sets up the problem after the input has been read in.
void applyNumericalMethods()
Allocates constitutive relations according to the discretizations on each subregion.
virtual void postInputInitialization() override final
Post process the command line input.
ProblemManager(conduit::Node &root)
Create a new ProblemManager, it must be created from the root conduit node.
virtual void setSchemaDeviations(xmlWrapper::xmlNode schemaRoot, xmlWrapper::xmlNode schemaParent, integer documentationType) override
Handles deviations between the data structure and schema.
FieldSpecificationManager & getFieldSpecificationManager()
Returns the FieldSpecificationManager.
struct geos::ProblemManager::viewKeysStruct viewKeys
Command line input viewKeys.
~ProblemManager() override
Destructor, deletes all Groups and Wrappers owned by this Group.
string const & getSchemaFileName() const
Returns the schema file name.
void applyInitialConditions()
Applies initial conditions indicated within the input file FieldSpecifications block.
void parseCommandLineInput()
Parses command line input.
struct geos::ProblemManager::groupKeysStruct groupKeys
Child group viewKeys.
FunctionManager const & getFunctionManager() const
Returns the const FunctionManager.
string const & getRestartFileName() const
Returns the restart file name.
void generateMesh()
Generates numerical meshes used throughout the code.
DomainPartition & getDomainPartition()
Returns a pointer to the DomainPartition.
void parseXMLDocument(xmlWrapper::xmlDocument &xmlDocument)
Parses the input xml document. Also add the includes content to the xmlDocument when Include nodes ar...
void importFields()
Import field data from external sources (e.g. mesh generator).
void readRestartOverwrite()
After initialization, overwrites data using a restart file.
void generateDocumentation()
Generates the xml schema documentation This function is called when the code is called with the -s sc...
void parseInputString(string const &xmlString)
Parses the input xml string.
FieldSpecificationManager const & getFieldSpecificationManager() const
Returns the const FunctionManager.
DomainPartition const & getDomainPartition() const
Returns a pointer to the DomainPartition.
virtual Group * createChild(string const &childKey, string const &childName) override
Creates a new sub-Group using the ObjectCatalog functionality.
string const & getInputFileName() const
Returns the input file name.
bool runSimulation()
Run the events in the scheduler.
FunctionManager & getFunctionManager()
Returns the FunctionManager.
A class to manage and execute tasks.
Base template for ordered and unordered maps.
Definition: DataTypes.hpp:329
Group::wrapperMap::KeyIndex ViewKey
Type alias for KeyIndexT type used for wrapper lookups.
Definition: Group.hpp:1662
pugi::xml_node xmlNode
Definition: xmlWrapper.hpp:59
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:180
array1d< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:392
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
dataRepository::GroupKey fieldSpecificationManager
Field specification key.
dataRepository::GroupKey geometricObjectManager
Geometry key.
dataRepository::GroupKey numericalMethodsManager
Numerical methods key.
dataRepository::GroupKey eventManager
Events key.
dataRepository::GroupKey commandLine
Command line key.
dataRepository::GroupKey constitutiveManager
Constitutive key.
dataRepository::GroupKey meshManager
Mesh key.
dataRepository::GroupKey tasksManager
Tasks key.
dataRepository::GroupKey functionManager
Functions key.
dataRepository::GroupKey domain
Domain key.
dataRepository::GroupKey externalDataSourceManager
External Data Source key.
dataRepository::GroupKey physicsSolverManager
Solvers key.
static constexpr char const * numericalMethodsManagerString()
dataRepository::GroupKey outputManager
Outputs key.
Command line input viewKeys.
dataRepository::ViewKey zPartitionsOverride
dataRepository::ViewKey xPartitionsOverride
dataRepository::ViewKey inputFileName
Input file name key.
dataRepository::ViewKey beginFromRestart
Flag to begin from restart key.
dataRepository::ViewKey outputDirectory
Output directory key.
dataRepository::ViewKey schemaFileName
Schema file name key.
dataRepository::ViewKey problemName
Problem name key.
dataRepository::ViewKey restartFileName
Restart file name key.
dataRepository::ViewKey overridePartitionNumbers
dataRepository::ViewKey useNonblockingMPI
Flag to use non-block MPI key.
dataRepository::ViewKey yPartitionsOverride
dataRepository::ViewKey suppressPinned