Skip to content

Commit

Permalink
feat: in sync with PR#2957
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Untereiner committed Sep 17, 2024
1 parent 7f91ad0 commit ae37a5e
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 74 deletions.
30 changes: 16 additions & 14 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,27 @@ set(componentSources
# set(dependencyList mesh)
set(dependencyList FesapiCpp)

# if(GEOSX_BUILD_SHARED_LIBS)
set(dependencyList ${dependencyList} geosx_core)
# else()
# set(dependencyList ${dependencyList} ${geosx_core_libs})
# endif()
if(GEOS_BUILD_SHARED_LIBS)
set(dependencyList ${dependencyList} geosx_core)
else()
set(dependencyList ${dependencyList} ${geosx_core_libs})
endif()

geos_decorate_link_dependencies( LIST decoratedDependencies
DEPENDENCIES ${dependencyList} )

message("adding RESQML library:")

blt_add_library(NAME resqml
SOURCES ${componentSources}
HEADERS ${componentHeaders}
DEPENDS_ON ${dependencyList}
OBJECT ${GEOSX_BUILD_OBJ_LIBS}
)
blt_add_library( NAME resqml
SOURCES ${componentSources}
HEADERS ${componentHeaders}
DEPENDS_ON ${decoratedDependencies}
OBJECT ${GEOS_BUILD_OBJ_LIBS}
SHARED ${GEOS_BUILD_SHARED_LIBS}
)

target_compile_definitions(resqml PUBLIC "HAS_UNCAUGHT_EXCEPTIONS")

# target_link_libraries(resqml PUBLIC FesapiCpp)
# target_include_directories(resqml PUBLIC ${FESAPI_DIR}/include)
target_include_directories(resqml PUBLIC ${CMAKE_CURRENT_LIST_DIR})

geosx_add_code_checks(PREFIX resqml)
# geosx_add_code_checks(PREFIX resqml)
6 changes: 6 additions & 0 deletions src/ETPRepository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ void ETPRepository::postInputInitialization()
// while (!storeHandlers->isDone()) {}
}

void ETPRepository::open()
{}

REGISTER_CATALOG_ENTRY( ExternalDataRepositoryBase, ETPRepository, string const &,
Group * const )

} // end namespace geosx
7 changes: 7 additions & 0 deletions src/ETPRepository.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class ETPRepository : public EnergyMLDataObjectRepository
ETPRepository( const string & name,
Group * const parent );

/**
* @brief Return the name of the ETPRepository in object catalog.
* @return string that contains the catalog name of the ETPRepository
*/
static string catalogName() { return "ETPRepository"; }

void open() override;

protected:

Expand Down
30 changes: 15 additions & 15 deletions src/EnergyMLDataObjectRepository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ EnergyMLDataObjectRepository::EnergyMLDataObjectRepository( string const & name,
enableLogLevelInput();
}

Group * EnergyMLDataObjectRepository::createChild( string const & childKey, string const & childName )
{
// RESQML DataObject Repositories generally don't have child XML nodes, must override this method to enable
GEOS_THROW( GEOS_FMT( "EnergyMLDataObjectRepository '{}': invalid child XML node '{}' of type {}", getName(), childName, childKey ),
InputError );
std::unique_ptr< EnergyMLDataObjectRepository > task = EnergyMLDataObjectRepository::CatalogInterface::factory( childKey, childName, this );
return &this->getParent().registerGroup< EnergyMLDataObjectRepository >( childName, std::move( task ) );

}

EnergyMLDataObjectRepository::CatalogInterface::CatalogType & EnergyMLDataObjectRepository::getCatalog()
{
static EnergyMLDataObjectRepository::CatalogInterface::CatalogType catalog;
return catalog;
}
// Group * EnergyMLDataObjectRepository::createChild( string const & childKey, string const & childName )
// {
// // RESQML DataObject Repositories generally don't have child XML nodes, must override this method to enable
// // GEOS_THROW( GEOS_FMT( "EnergyMLDataObjectRepository '{}': invalid child XML node '{}' of type {}", getName(), childName, childKey ),
// // InputError );
// std::unique_ptr< EnergyMLDataObjectRepository > task = EnergyMLDataObjectRepository::CatalogInterface::factory( childKey, childName, this );
// return &this->getParent().registerGroup< EnergyMLDataObjectRepository >( childName, std::move( task ) );

// }

// EnergyMLDataObjectRepository::CatalogInterface::CatalogType & EnergyMLDataObjectRepository::getCatalog()
// {
// static EnergyMLDataObjectRepository::CatalogInterface::CatalogType catalog;
// return catalog;
// }

common::DataObjectRepository * EnergyMLDataObjectRepository::getData()
{
Expand Down
28 changes: 0 additions & 28 deletions src/EnergyMLDataObjectRepository.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,9 @@ class EnergyMLDataObjectRepository : public ExternalDataRepositoryBase
explicit EnergyMLDataObjectRepository( string const & name,
Group * const parent );

/**
* @brief Return the name of the MeshGenerator in object catalog.
* @return string that contains the catalog name of the MeshGenerator
*/
static string catalogName() { return "EnergyMLDataObjectRepository"; }

/// using alias for templated Catalog meshGenerator type
using CatalogInterface = dataRepository::CatalogInterface< EnergyMLDataObjectRepository, string const &, Group * const >;

/**
* @brief Accessor for the singleton Catalog object
* @return a static reference to the Catalog object
*/
static CatalogInterface::CatalogType & getCatalog();

/**
* @brief function to return the catalog name of the derived class
* @return a string that contains the catalog name of the derived class
*/
virtual string getCatalogName() = 0;
// /**
// * @brief Create a new object as a child of this group.
// * @param childKey the catalog key of the new object to create
// * @param childName the name of the new object in the repository
// * @return the group child
// */
virtual Group * createChild( string const & childKey, string const & childName ) override;

common::DataObjectRepository * getData();


COMMON_NS::AbstractObject * getDataObject( string const & id );
COMMON_NS::AbstractObject * getDataObjectByTitle( string const & name );

Expand Down
2 changes: 0 additions & 2 deletions src/EpcDocumentRepository.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class EpcDocumentRepository : public EnergyMLDataObjectRepository
*/
static string catalogName() { return "EpcDocumentRepository"; }

string getCatalogName() override { return catalogName(); }

void open() override;

protected:
Expand Down
25 changes: 22 additions & 3 deletions src/RESQMLMeshGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "common/DataLayouts.hpp"
#include "common/MpiWrapper.hpp"
#include "common/TypeDispatch.hpp"
#include "mesh/ExternalDataRepositoryManager.hpp"
#include "mesh/MeshBody.hpp"
#include "mesh/MeshManager.hpp"
#include "mesh/generators/CellBlockManager.hpp"
Expand Down Expand Up @@ -56,6 +57,9 @@ RESQMLMeshGenerator::RESQMLMeshGenerator( string const & name,
: ExternalMeshGeneratorBase( name, parent ),
m_repository( nullptr )
{
getWrapperBase( ExternalMeshGeneratorBase::viewKeyStruct::filePathString()).
setInputFlag( InputFlags::OPTIONAL );

registerWrapper( viewKeyStruct::repositoryString(), &m_objectName ).
setInputFlag( InputFlags::REQUIRED ).
setDescription( "Name of the EnergyML Repository" );
Expand Down Expand Up @@ -132,14 +136,27 @@ Group * RESQMLMeshGenerator::createChild( string const & childKey, string const

void RESQMLMeshGenerator::postInputInitialization()
{
MeshManager & meshManager = this->getGroupByPath< MeshManager >( "/Problem/Mesh" );
// objectRepository.
m_repository = meshManager.getGroupPointer< EnergyMLDataObjectRepository >( m_objectName );
ExternalDataRepositoryManager & externalDataManager = this->getGroupByPath< ExternalDataRepositoryManager >( "/Problem/ExternalDataRepository" );
// objectRepository.
m_repository = externalDataManager.getGroupPointer< EnergyMLDataObjectRepository >( m_objectName );

GEOS_THROW_IF( m_repository == nullptr,
getName() << ": EnergyML Data Object Repository not found: " << m_objectName,
InputError );

COMMON_NS::AbstractObject * rep{nullptr};

if( !m_uuid.empty())
rep = m_repository->getDataObject( m_uuid );
else if( !m_title.empty())
rep = m_repository->getDataObjectByTitle( m_title );

if( rep == nullptr )
GEOS_ERROR( GEOS_FMT( "There exists no such data object with uuid {} or title {} in the epc file", m_uuid, m_title ) );


m_title = rep->getTitle();
m_uuid = rep->getUuid();
}

void RESQMLMeshGenerator::fillCellBlockManager( CellBlockManager & cellBlockManager, SpatialPartition & partition )
Expand Down Expand Up @@ -400,6 +417,8 @@ RESQMLMeshGenerator::retrieveUnstructuredGrid()

GEOS_LOG_RANK_0( GEOS_FMT( "GetNumberOfCells {}", loadedMesh->GetNumberOfCells()) );
GEOS_LOG_RANK_0( GEOS_FMT( "GetNumberOfPoints {}", loadedMesh->GetNumberOfPoints()) );
GEOS_LOG_RANK_0( GEOS_FMT( "UUID {}", m_uuid) );
GEOS_LOG_RANK_0( GEOS_FMT( "Title {}", m_title) );

return loadedMesh;
}
Expand Down
2 changes: 1 addition & 1 deletion src/RESQMLUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <vtkIntArray.h>


#include "fesapi/resqml2/AbstractLocal3dCrs.h"
#include "fesapi/eml2/AbstractLocal3dCrs.h"
#include "fesapi/resqml2/CategoricalProperty.h"
#include "fesapi/resqml2/ContinuousProperty.h"
#include "fesapi/resqml2/DiscreteProperty.h"
Expand Down
26 changes: 15 additions & 11 deletions src/RESQMLWriterInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@
#include "fesapi/eml2_0/HdfProxyMPI.h"
#include "fesapi/eml2/TimeSeries.h"
#include "fesapi/resqml2_0_1/PropertyKind.h"
#include "fesapi/tools/TimeTools.h"
// #include "fesapi/tools/TimeTools.h"
#include "fesapi/resqml2_0_1/ContinuousProperty.h"
#include "fesapi/resqml2_0_1/DiscreteProperty.h"

// System includes
#include <random>
#include <sstream>

#include "hdf5.h"

namespace geos
{

Expand Down Expand Up @@ -254,7 +256,9 @@ RESQMLWriterInterface::RESQMLWriterInterface( string name )
: VTKPolyDataWriterInterface( name ),
m_outputRepository( new COMMON_NS::DataObjectRepository()),
m_propertyKind( nullptr )
{ }
{
// H5Eset_auto2(H5E_DEFAULT, nullptr, nullptr);
}

void RESQMLWriterInterface::initializeOutput()
{
Expand All @@ -264,8 +268,9 @@ void RESQMLWriterInterface::initializeOutput()

m_propertyKind = m_outputRepository->createPropertyKind(
propertyKind, "propType1", "F2I",
gsoap_resqml2_0_1::resqml20__ResqmlUom::m,
gsoap_resqml2_0_1::resqml20__ResqmlPropertyKind::length );
gsoap_resqml2_0_1::resqml20__ResqmlUom::m,
false,
gsoap_resqml2_0_1::resqml20__ResqmlPropertyKind::length);

string timeSeries = uuid::generate_uuid_v4();
MpiWrapper::broadcast( timeSeries, 0 );
Expand All @@ -281,8 +286,8 @@ void RESQMLWriterInterface::initializeOutput()
EML2_NS::AbstractHdfProxy *m_hdfProxy = m_outputRepository->createHdfProxy(
hdfProxy, "Parallel Hdf Proxy", m_outputDir, m_outputName + ".h5",
COMMON_NS::DataObjectRepository::openingMode::OVERWRITE );
m_hdfProxy->setCompressionLevel( 5 );
dynamic_cast< EML2_0_NS::HdfProxyMPI * >(m_hdfProxy)->setCollectiveIO();
// m_hdfProxy->setCompressionLevel( 5 );
// dynamic_cast< EML2_0_NS::HdfProxyMPI * >(m_hdfProxy)->setCollectiveIO();
m_outputRepository->setDefaultHdfProxy( m_hdfProxy );


Expand Down Expand Up @@ -315,8 +320,7 @@ void RESQMLWriterInterface::generateOutput() const
void RESQMLWriterInterface::generateSubRepresentation(
ElementRegionManager const & elemManager, string const & field )
{

std::vector< globalIndex > data;
std::vector< uint64_t > data;

elemManager.forElementRegions< CellElementRegion >(
[&]( CellElementRegion const & region ) {
Expand Down Expand Up @@ -360,8 +364,9 @@ void RESQMLWriterInterface::generateSubRepresentation(

// Alternate way
subrep_allranks->pushBackSubRepresentationPatch( gsoap_eml2_3::eml23__IndexableElement::cells, totalDataSize );
int const rankOffset =
int const rankOffset =
std::accumulate( dataSizes.begin(), std::next( dataSizes.begin(), MpiWrapper::commRank()), 0 );

subrep_allranks->setElementIndices( reinterpret_cast< uint64_t * >(data.data()), data.size(), rankOffset );

//record the object pointer for each field
Expand Down Expand Up @@ -478,7 +483,7 @@ void RESQMLWriterInterface::write( real64 const time,

data->SetNumberOfTuples( numElements );
data->SetName( field.c_str());


//RESQML Property same for all ranks
string property = uuid::generate_uuid_v4();
Expand Down Expand Up @@ -516,7 +521,6 @@ void RESQMLWriterInterface::write( real64 const time,
globalIndex maxCount =
m_subrepresentations[field]->getElementCountOfPatch( 0 );


if( data->GetNumberOfComponents() == 1 ) // scalar data
{
if( data->GetDataType() == VTK_DOUBLE )
Expand Down
2 changes: 2 additions & 0 deletions src/RESQMLWriterInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class RESQMLWriterInterface : private vtk::VTKPolyDataWriterInterface
*/
void setParentRepresentation( const std::tuple< string, string > & parent )
{
GEOS_LOG_RANK_0( GEOS_FMT( "UUID {}", std::get< 0 >( parent )) );
GEOS_LOG_RANK_0( GEOS_FMT( "Title {}", std::get< 1 >( parent )) );
m_parent = m_outputRepository->createPartial< RESQML2_0_1_NS::UnstructuredGridRepresentation >( std::get< 0 >( parent ), std::get< 1 >( parent ));
}

Expand Down

0 comments on commit ae37a5e

Please sign in to comment.