From ae37a5e658b8d1bf07863db3fd2791d8d0830b14 Mon Sep 17 00:00:00 2001 From: Lionel Untereiner Date: Tue, 17 Sep 2024 15:50:47 +0200 Subject: [PATCH] feat: in sync with PR#2957 --- src/CMakeLists.txt | 30 +++++++++++++++------------- src/ETPRepository.cpp | 6 ++++++ src/ETPRepository.hpp | 7 +++++++ src/EnergyMLDataObjectRepository.cpp | 30 ++++++++++++++-------------- src/EnergyMLDataObjectRepository.hpp | 28 -------------------------- src/EpcDocumentRepository.hpp | 2 -- src/RESQMLMeshGenerator.cpp | 25 ++++++++++++++++++++--- src/RESQMLUtilities.cpp | 2 +- src/RESQMLWriterInterface.cpp | 26 ++++++++++++++---------- src/RESQMLWriterInterface.hpp | 2 ++ 10 files changed, 84 insertions(+), 74 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index efb0b79..4c448fd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/ETPRepository.cpp b/src/ETPRepository.cpp index 16ec304..6a332d5 100644 --- a/src/ETPRepository.cpp +++ b/src/ETPRepository.cpp @@ -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 diff --git a/src/ETPRepository.hpp b/src/ETPRepository.hpp index 730e9b1..b1b0461 100644 --- a/src/ETPRepository.hpp +++ b/src/ETPRepository.hpp @@ -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: diff --git a/src/EnergyMLDataObjectRepository.cpp b/src/EnergyMLDataObjectRepository.cpp index cdd3f27..86e54ef 100644 --- a/src/EnergyMLDataObjectRepository.cpp +++ b/src/EnergyMLDataObjectRepository.cpp @@ -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() { diff --git a/src/EnergyMLDataObjectRepository.hpp b/src/EnergyMLDataObjectRepository.hpp index b6bcbc6..adbd257 100644 --- a/src/EnergyMLDataObjectRepository.hpp +++ b/src/EnergyMLDataObjectRepository.hpp @@ -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 ); diff --git a/src/EpcDocumentRepository.hpp b/src/EpcDocumentRepository.hpp index 684ca43..7c3a6d6 100644 --- a/src/EpcDocumentRepository.hpp +++ b/src/EpcDocumentRepository.hpp @@ -27,8 +27,6 @@ class EpcDocumentRepository : public EnergyMLDataObjectRepository */ static string catalogName() { return "EpcDocumentRepository"; } - string getCatalogName() override { return catalogName(); } - void open() override; protected: diff --git a/src/RESQMLMeshGenerator.cpp b/src/RESQMLMeshGenerator.cpp index 4265178..16a002f 100644 --- a/src/RESQMLMeshGenerator.cpp +++ b/src/RESQMLMeshGenerator.cpp @@ -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" @@ -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" ); @@ -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 ) @@ -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; } diff --git a/src/RESQMLUtilities.cpp b/src/RESQMLUtilities.cpp index bba6e0b..fbd9d69 100644 --- a/src/RESQMLUtilities.cpp +++ b/src/RESQMLUtilities.cpp @@ -29,7 +29,7 @@ #include -#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" diff --git a/src/RESQMLWriterInterface.cpp b/src/RESQMLWriterInterface.cpp index 9fc08be..5d29c9f 100644 --- a/src/RESQMLWriterInterface.cpp +++ b/src/RESQMLWriterInterface.cpp @@ -33,7 +33,7 @@ #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" @@ -41,6 +41,8 @@ #include #include +#include "hdf5.h" + namespace geos { @@ -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() { @@ -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 ); @@ -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 ); @@ -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 ) { @@ -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 @@ -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(); @@ -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 ) diff --git a/src/RESQMLWriterInterface.hpp b/src/RESQMLWriterInterface.hpp index 0ecf190..7f60216 100644 --- a/src/RESQMLWriterInterface.hpp +++ b/src/RESQMLWriterInterface.hpp @@ -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 )); }