Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/coreComponents/constitutive/ConstitutiveManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "dataRepository/Group.hpp"
#include "dataRepository/ReferenceWrapper.hpp"
#include "dataRepository/ProblemRepository.hpp"
#include "ConstitutiveBase.hpp"

namespace geos
Expand Down Expand Up @@ -83,8 +84,6 @@ class ConstitutiveManager : public dataRepository::Group
};
};



template< typename T >
ViewAccessor< T >
ConstitutiveManager::getConstitutiveData( string const & name,
Expand All @@ -104,7 +103,26 @@ ConstitutiveManager::getConstitutiveData( string const & name,
return rval;
}

} /* namespace constitutive */

// ConstitutiveManager Group is available through the ProblemRepository as a mutable problem-unique manager.
template<> inline
constitutive::ConstitutiveManager & dataRepository::ProblemRepository::getManager()
{
return getRootGroup().
getGroup( m_gks.domain ).
getGroup< constitutive::ConstitutiveManager >( m_gks.constitutiveManager );
}

// ConstitutiveManager Group is available through the ProblemRepository as a const problem-unique manager.
template<> inline
constitutive::ConstitutiveManager const & dataRepository::ProblemRepository::getManager() const
{
return getRootGroup().
getGroup( m_gks.domain ).
getGroup< constitutive::ConstitutiveManager >( m_gks.constitutiveManager );
}

} /* namespace geos */

#endif /* GEOS_CONSTITUTIVE_CONSTITUTIVEMANAGER_HPP_ */
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "LogLevelsInfo.hpp"

#include "constitutive/ConstitutiveManager.hpp"
#include "dataRepository/ProblemRepository.hpp"

#include "common/format/table/TableFormatter.hpp"
#include "common/format/StringUtilities.hpp"
Expand Down Expand Up @@ -246,12 +247,12 @@ void ConstitutiveDriver::allocateTable( integer const numColumns,

ConstitutiveManager & ConstitutiveDriver::getConstitutiveManager()
{
return this->getGroupByPath< ConstitutiveManager >( "/Problem/domain/Constitutive" );
return ProblemRepository::getManager< ConstitutiveManager >( *this );
}

ConstitutiveManager const & ConstitutiveDriver::getConstitutiveManager() const
{
return this->getGroupByPath< ConstitutiveManager >( "/Problem/domain/Constitutive" );
return ProblemRepository::getManager< ConstitutiveManager >( *this );
}

} /* namespace geos */
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void ReactiveFluidDriver::postInputInitialization()
{
// get number of phases and components

ConstitutiveManager & constitutiveManager = this->getGroupByPath< ConstitutiveManager >( "/Problem/domain/Constitutive" );
ConstitutiveManager & constitutiveManager = ProblemRepository::getManager< ConstitutiveManager >( *this );
ReactiveMultiFluid & fluid = constitutiveManager.getGroup< ReactiveMultiFluid >( m_fluidName );

m_numPhases = fluid.numFluidPhases();
Expand Down Expand Up @@ -132,7 +132,7 @@ bool ReactiveFluidDriver::execute( real64 const GEOS_UNUSED_PARAM( time_n ),
// get the fluid out of the constitutive manager.
// for the moment it is of type MultiFluidBase.

ConstitutiveManager & constitutiveManager = this->getGroupByPath< ConstitutiveManager >( "/Problem/domain/Constitutive" );
ConstitutiveManager & constitutiveManager = ProblemRepository::getManager< ConstitutiveManager >( *this );
ReactiveMultiFluid & baseFluid = constitutiveManager.getGroup< ReactiveMultiFluid >( m_fluidName );

// depending on logLevel, print some useful info
Expand Down
4 changes: 3 additions & 1 deletion src/coreComponents/dataRepository/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ set( dataRepository_headers
HistoryDataSpec.hpp
InputFlags.hpp
KeyIndexT.hpp
KeyNames.hpp
LogLevelsInfo.hpp
LogLevelsRegistry.hpp
MappedVector.hpp
ObjectCatalog.hpp
ProblemRepositoryABC.hpp
ProblemRepository.hpp
ReferenceWrapper.hpp
RestartFlags.hpp
Utilities.hpp
Expand All @@ -57,6 +58,7 @@ set( dataRepository_sources
ConduitRestart.cpp
ExecutableGroup.cpp
Group.cpp
ProblemRepository.cpp
Utilities.cpp
WrapperBase.cpp
xmlWrapper.cpp
Expand Down
8 changes: 2 additions & 6 deletions src/coreComponents/dataRepository/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "common/format/table/TableLayout.hpp"
#include "codingUtilities/Utilities.hpp"
#include "GroupContext.hpp"
#include "ProblemRepositoryABC.hpp"
#if defined(GEOS_USE_PYGEOSX)
#include "python/PyGroupType.hpp"
#endif
Expand Down Expand Up @@ -133,12 +134,7 @@ void Group::reserve( indexType const newSize )
}

string Group::getPath() const
{
// In the Conduit node hierarchy everything begins with 'Problem', we should change it so that
// the ProblemManager actually uses the root Conduit Node but that will require a full rebaseline.
string const noProblem = getConduitNode().path().substr( stringutilities::cstrlen( dataRepository::keys::ProblemManager ) );
return noProblem.empty() ? "/" : noProblem;
}
{ return ProblemRepositoryABC::getNoProblemPath( getConduitNode().path() ); }

string Group::processInputName( xmlWrapper::xmlNode const & targetNode,
xmlWrapper::xmlNodePos const & targetNodePos,
Expand Down
43 changes: 0 additions & 43 deletions src/coreComponents/dataRepository/KeyNames.hpp

This file was deleted.

68 changes: 68 additions & 0 deletions src/coreComponents/dataRepository/ProblemRepository.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* ------------------------------------------------------------------------------------------------------------
* 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 MeshLevel.cpp
*/

#include "ProblemRepository.hpp"

namespace geos
{
namespace dataRepository
{

/**
* @name Inline functions implementation
*/
///@{

string ProblemRepositoryABC::getNoProblemPath( string const & originalPath )
{
// In the Conduit node hierarchy everything begins with 'Problem', we should change it so that
// the ProblemManager actually uses the root Conduit Node but that will require a full rebaseline.
size_t const lengthToRemove = stringutilities::cstrlen( ProblemGroupKeys::problemString() );
string const noProblem = originalPath.substr( lengthToRemove );
return noProblem.empty() ? "/" : noProblem;
}

ProblemRepository & ProblemRepository::get( Group & group )
{
// the ProblemRepository is expected to always be the root Group instance.
Group * current = &group;
while( current->hasParent() )
{
current = &current->getParent();
}

ProblemRepository * const root = dynamic_cast< ProblemRepository * >( current );
return *root;
}

ProblemRepository const & ProblemRepository::get( Group const & group )
{
// the ProblemRepository is expected to always be the root Group instance.
Group const * current = &group;
while( current->hasParent() )
{
current = &current->getParent();
}

ProblemRepository const * const root = dynamic_cast< ProblemRepository const * >( current );
return *root;
}

} /* namespace dataRepository */
} /* namespace geos */
Loading
Loading