Skip to content

Commit

Permalink
add MeshBase
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Untereiner committed Jan 26, 2024
1 parent d1262e7 commit 9ed51e9
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/coreComponents/fileIO/vtk/VTKPolyDataWriterInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class VTKPolyDataWriterInterface
void clearData();


private:
protected:

/**
* @brief Check if plotting is enabled for this field
Expand Down Expand Up @@ -299,7 +299,7 @@ class VTKPolyDataWriterInterface
void writeUnstructuredGrid( string const & path,
vtkUnstructuredGrid * ug ) const;

private:
protected:

/// Output directory name
string m_outputDir;
Expand Down
2 changes: 2 additions & 0 deletions src/coreComponents/mesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set( mesh_headers
FaceManager.hpp
FieldIdentifiers.hpp
InterObjectRelation.hpp
MeshBase.hpp
MeshBody.hpp
MeshForLoopInterface.hpp
MeshLevel.hpp
Expand Down Expand Up @@ -96,6 +97,7 @@ set( mesh_sources
EmbeddedSurfaceSubRegion.cpp
FaceElementSubRegion.cpp
FaceManager.cpp
MeshBase.cpp
MeshBody.cpp
MeshLevel.cpp
MeshManager.cpp
Expand Down
43 changes: 43 additions & 0 deletions src/coreComponents/mesh/MeshBase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* ------------------------------------------------------------------------------------------------------------
* SPDX-License-Identifier: LGPL-2.1-only
*
* Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2018-2020 TotalEnergies
* Copyright (c) 2019- GEOSX Contributors
* All rights reserved
*
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
* ------------------------------------------------------------------------------------------------------------
*/

#include "MeshBase.hpp"

namespace geos
{
using namespace dataRepository;

MeshBase::MeshBase( string const & name, Group * const parent ):
Group( name, parent )
{
setInputFlags( InputFlags::OPTIONAL_NONUNIQUE );
}

// Group * MeshBase::createChild( string const & GEOS_UNUSED_PARAM(childKey), string const & GEOS_UNUSED_PARAM(childName) )
// {
// return nullptr;
// }

// void MeshBase::expandObjectCatalogs()
// {

// }

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

}
78 changes: 78 additions & 0 deletions src/coreComponents/mesh/MeshBase.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* ------------------------------------------------------------------------------------------------------------
* SPDX-License-Identifier: LGPL-2.1-only
*
* Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2018-2020 TotalEnergies
* Copyright (c) 2019- GEOSX Contributors
* All rights reserved
*
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
* ------------------------------------------------------------------------------------------------------------
*/

/**
* @file MeshBase.hpp
*/

#ifndef GEOS_MESH_MESHBASE_HPP
#define GEOS_MESH_MESHBASE_HPP

#include "dataRepository/Group.hpp"
#include "dataRepository/WrapperBase.hpp"
#include "codingUtilities/Utilities.hpp"
#include "common/DataTypes.hpp"


namespace geos
{

/**
* @class MeshBase
* @brief The MeshBase class provides an abstract base class implementation for different mesh types.
* The MeshBase is the Group specialization for different type of mesh handling.
*/
class MeshBase : public dataRepository::Group
{
public:

/**
* @brief Main constructor for MeshBase base class.
* @param[in] name of the MeshBase object
* @param[in] parent the parent Group pointer for the MeshBase object
*/
explicit MeshBase( string const & name,
Group * const parent );

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

/// This function is used to expand any catalogs in the data structure
// virtual void expandObjectCatalogs() override;

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

/**
* @brief Create a new geometric object (box, plane, etc) as a child of this group.
* @param childKey the catalog key of the new geometric object to create
* @param childName the name of the new geometric object in the repository
* @return the group child
*/
// virtual Group * createChild( string const & childKey, string const & childName ) override;

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

};

}

#endif /* GEOS_MESH_MESHBASE_HPP */
8 changes: 4 additions & 4 deletions src/coreComponents/mesh/MeshManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ MeshManager::~MeshManager()
Group * MeshManager::createChild( string const & childKey, string const & childName )
{
GEOS_LOG_RANK_0( "Adding Mesh: " << childKey << ", " << childName );
std::unique_ptr< MeshGeneratorBase > solver = MeshGeneratorBase::CatalogInterface::factory( childKey, childName, this );
return &this->registerGroup< MeshGeneratorBase >( childName, std::move( solver ) );
std::unique_ptr< MeshBase > mesh = MeshBase::CatalogInterface::factory( childKey, childName, this );
return &this->registerGroup< MeshBase >( childName, std::move( mesh ) );
}


void MeshManager::expandObjectCatalogs()
{
// During schema generation, register one of each type derived from MeshGeneratorBase here
for( auto & catalogIter: MeshGeneratorBase::getCatalog())
// During schema generation, register one of each type derived from MeshBase here
for( auto & catalogIter: MeshBase::getCatalog())

Check warning on line 54 in src/coreComponents/mesh/MeshManager.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/mesh/MeshManager.cpp#L54

Added line #L54 was not covered by tests
{
createChild( catalogIter.first, catalogIter.first );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ ExternalMeshGeneratorBase::ExternalMeshGeneratorBase( string const & name,
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::filePathString(), &m_filePath ).
setInputFlag( InputFlags::REQUIRED ).
setRestartFlags( RestartFlags::NO_WRITE ).
setDescription( "Path to the mesh file" );

registerWrapper( viewKeyStruct::translateString(), &m_translate ).
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( { 0.0, 0.0, 0.0 } ).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class ExternalMeshGeneratorBase : public MeshGeneratorBase
///@cond DO_NOT_DOCUMENT
struct viewKeyStruct
{
constexpr static char const * filePathString() { return "file"; }
constexpr static char const * scaleString() { return "scale"; }
constexpr static char const * translateString() { return "translate"; }
constexpr static char const * volumicFieldsToImportString() { return "fieldsToImport"; }
Expand All @@ -56,9 +55,6 @@ class ExternalMeshGeneratorBase : public MeshGeneratorBase

void postProcessInput() override;

/// Path to the mesh file
Path m_filePath;

/// Translation vector that will be applied to the point coordinates (prior to scaling)
R1Tensor m_translate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -998,5 +998,5 @@ InternalMeshGenerator::
}
}

REGISTER_CATALOG_ENTRY( MeshGeneratorBase, InternalMeshGenerator, string const &, Group * const )
REGISTER_CATALOG_ENTRY( MeshBase, InternalMeshGenerator, string const &, Group * const )
} /* namespace geos */
Original file line number Diff line number Diff line change
Expand Up @@ -523,5 +523,5 @@ void InternalWellboreGenerator::coordinateTransformation( arrayView2d< real64, n
}
}

REGISTER_CATALOG_ENTRY( MeshGeneratorBase, InternalWellboreGenerator, string const &, Group * const )
REGISTER_CATALOG_ENTRY( MeshBase, InternalWellboreGenerator, string const &, Group * const )
} /* namespace geos */
3 changes: 2 additions & 1 deletion src/coreComponents/mesh/generators/MeshGeneratorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace geos
using namespace dataRepository;

MeshGeneratorBase::MeshGeneratorBase( string const & name, Group * const parent ):
Group( name, parent )
MeshBase( name, parent )
{
setInputFlags( InputFlags::OPTIONAL_NONUNIQUE );
}
Expand Down Expand Up @@ -94,4 +94,5 @@ void MeshGeneratorBase::attachWellInfo( CellBlockManager & cellBlockManager )

} );
}

}
7 changes: 2 additions & 5 deletions src/coreComponents/mesh/generators/MeshGeneratorBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@
#ifndef GEOS_MESH_GENERATORS_MESHGENERATORBASE_HPP
#define GEOS_MESH_GENERATORS_MESHGENERATORBASE_HPP

#include "mesh/MeshBase.hpp"
#include "mesh/mpiCommunications/SpatialPartition.hpp"
#include "mesh/generators/CellBlockManagerABC.hpp"

#include "dataRepository/Group.hpp"
#include "dataRepository/WrapperBase.hpp"
#include "codingUtilities/Utilities.hpp"
#include "common/DataTypes.hpp"


namespace geos
Expand All @@ -42,7 +39,7 @@ class CellBlockManager;
* @brief The MeshGeneratorBase class provides an abstract base class implementation for different mesh types.
* The MeshGeneratorBase is the Group specialization for different type of mesh handling.
*/
class MeshGeneratorBase : public dataRepository::Group
class MeshGeneratorBase : public MeshBase
{
public:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,6 @@ void ParticleMeshGenerator::importFieldOnArray( Block block,
GEOS_UNUSED_VAR( wrapper );
}

REGISTER_CATALOG_ENTRY( MeshGeneratorBase, ParticleMeshGenerator, string const &, Group * const )
REGISTER_CATALOG_ENTRY( MeshBase, ParticleMeshGenerator, string const &, Group * const )

} /* namespace geos */
7 changes: 6 additions & 1 deletion src/coreComponents/mesh/generators/VTKMeshGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ VTKMeshGenerator::VTKMeshGenerator( string const & name,
Group * const parent )
: ExternalMeshGeneratorBase( name, parent )
{
registerWrapper( viewKeyStruct::filePathString(), &m_filePath ).
setInputFlag( InputFlags::REQUIRED ).
setRestartFlags( RestartFlags::NO_WRITE ).
setDescription( "Path to the mesh file" );

registerWrapper( viewKeyStruct::regionAttributeString(), &m_attributeName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( InputFlags::OPTIONAL ).
Expand Down Expand Up @@ -216,6 +221,6 @@ void VTKMeshGenerator::freeResources()
m_faceBlockMeshes.clear();
}

REGISTER_CATALOG_ENTRY( MeshGeneratorBase, VTKMeshGenerator, string const &, Group * const )
REGISTER_CATALOG_ENTRY( MeshBase, VTKMeshGenerator, string const &, Group * const )

} // namespace geos
4 changes: 4 additions & 0 deletions src/coreComponents/mesh/generators/VTKMeshGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class VTKMeshGenerator : public ExternalMeshGeneratorBase
///@cond DO_NOT_DOCUMENT
struct viewKeyStruct
{
constexpr static char const * filePathString() { return "file"; }
constexpr static char const * regionAttributeString() { return "regionAttribute"; }
constexpr static char const * mainBlockNameString() { return "mainBlockName"; }
constexpr static char const * faceBlockNamesString() { return "faceBlocks"; }
Expand All @@ -120,6 +121,9 @@ class VTKMeshGenerator : public ExternalMeshGeneratorBase
string const & meshFieldName,
dataRepository::WrapperBase & wrapper ) const;

/// Path to the mesh file
Path m_filePath;

/**
* @brief The VTK mesh to be imported into GEOSX.
* @note We keep this smart pointer as a member for use in @p importFields().
Expand Down
4 changes: 2 additions & 2 deletions src/docs/doxygen/GeosxConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define GEOSX_USE_MPI

/// Enables use of OpenMP (CMake option ENABLE_OPENMP)
#define GEOSX_USE_OPENMP
/* #undef GEOSX_USE_OPENMP */

/// Enables use of CUDA (CMake option ENABLE_CUDA)
/* #undef GEOS_USE_CUDA */
Expand Down Expand Up @@ -135,7 +135,7 @@
/* #undef chai_VERSION */

/// Version information for adiak
#define adiak_VERSION ..
/* #undef adiak_VERSION */

/// Version information for caliper
#define caliper_VERSION 2.10.0
Expand Down

0 comments on commit 9ed51e9

Please sign in to comment.