Loading CMakeLists.txt +4 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,10 @@ if( DEFINED ENV{CI_JOB_NAME} OR ${CMAKE_GENERATOR} STREQUAL "Ninja" ) endif() endif() # add the filesystem library to all targets # https://en.cppreference.com/w/cpp/filesystem link_libraries( stdc++fs ) # gtest has to be built before we add the MPI flags if( ${WITH_TESTS} OR ${WITH_MATRIX_TESTS} ) enable_testing() Loading cmake/FindMETIS.cmake 0 → 100644 +23 −0 Original line number Diff line number Diff line # This module will try to find METIS and define the following: # METIS_FOUND - True iff METIS was found # METIS_INCLUDE_DIRS - METIS include directories # METIS_LIBRARIES - METIS library paths find_path(METIS_INCLUDE_DIR metis.h PATHS /usr/include /usr/local/include DOC "METIS include directory") find_library(METIS_LIBRARY metis PATHS /usr/lib /usr/local/lib ${PROJECT_SOURCE_DIR}/metis DOC "Path to METIS library") include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set METIS_FOUND to TRUE # if all listed variables are TRUE find_package_handle_standard_args(METIS DEFAULT_MSG METIS_LIBRARY METIS_INCLUDE_DIR) mark_as_advanced(METIS_INCLUDE_DIR METIS_LIBRARY) set(METIS_LIBRARIES ${METIS_LIBRARY}) set(METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR}) src/Python/pytnl/tnl/Mesh.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -13,18 +13,18 @@ void export_Meshes( py::module & m ) using Reader = TNL::Meshes::Readers::VTKReader; py::class_< Reader >( m, "VTKReader" ) .def(py::init<>()) .def("readMesh", &Reader::template readMesh< MeshOfEdges >) .def("readMesh", &Reader::template readMesh< MeshOfTriangles >) .def("readMesh", &Reader::template readMesh< MeshOfTetrahedrons >) // .def("readMesh", []( Reader& reader, const std::string& name, MeshOfEdges & mesh ) { // return reader.readMesh( name.c_str(), mesh ); .def(py::init<std::string>()) .def("loadMesh", &Reader::template loadMesh< MeshOfEdges >) .def("loadMesh", &Reader::template loadMesh< MeshOfTriangles >) .def("loadMesh", &Reader::template loadMesh< MeshOfTetrahedrons >) // .def("loadMesh", []( Reader& reader, const std::string& name, MeshOfEdges & mesh ) { // return reader.loadMesh( name.c_str(), mesh ); // } ) // .def("readMesh", []( Reader& reader, const std::string& name, MeshOfTriangles & mesh ) { // return reader.readMesh( name.c_str(), mesh ); // .def("loadMesh", []( Reader& reader, const std::string& name, MeshOfTriangles & mesh ) { // return reader.loadMesh( name.c_str(), mesh ); // } ) // .def("readMesh", []( Reader& reader, const std::string& name, MeshOfTetrahedrons & mesh ) { // return reader.readMesh( name.c_str(), mesh ); // .def("loadMesh", []( Reader& reader, const std::string& name, MeshOfTetrahedrons & mesh ) { // return reader.loadMesh( name.c_str(), mesh ); // } ) ; } src/Python/pytnl/tnl/Mesh.h +29 −36 Original line number Diff line number Diff line Loading @@ -13,22 +13,12 @@ namespace py = pybind11; #include <type_traits> template< typename MeshEntity > typename MeshEntity::MeshTraitsType::GlobalIndexType getIndex( const MeshEntity& entity ) { return entity.getIndex(); }; struct _general {}; struct _special : _general {}; template< typename MeshEntity, int Superdimension, typename Scope, typename = typename std::enable_if< Superdimension <= MeshEntity::MeshTraitsType::meshDimension >::type > std::enable_if_t< Superdimension <= MeshEntity::MeshType::getMeshDimension(), bool > = true > // && MeshEntity::template SuperentityTraits< Superdimension >::storageEnabled >::type > void export_getSuperentityIndex( Scope & m, _special ) void export_getSuperentityIndex( Scope & m ) { m.def("getSuperentityIndex", []( const MeshEntity& entity, const typename MeshEntity::LocalIndexType& i ) { return entity.template getSuperentityIndex< Superdimension >( i ); Loading @@ -38,8 +28,9 @@ void export_getSuperentityIndex( Scope & m, _special ) template< typename MeshEntity, int Superdimension, typename Scope > void export_getSuperentityIndex( Scope &, _general ) typename Scope, std::enable_if_t< ! ( Superdimension <= MeshEntity::MeshType::getMeshDimension() ), bool > = true > void export_getSuperentityIndex( Scope & ) { } Loading @@ -47,9 +38,9 @@ void export_getSuperentityIndex( Scope &, _general ) template< typename MeshEntity, int Subdimension, typename Scope, typename = typename std::enable_if< Subdimension <= MeshEntity::MeshTraitsType::meshDimension && (Subdimension < MeshEntity::getEntityDimension()) >::type > void export_getSubentityIndex( Scope & m, const char* name, _special ) std::enable_if_t< Subdimension <= MeshEntity::MeshType::getMeshDimension() && (Subdimension < MeshEntity::getEntityDimension()), bool > = true > void export_getSubentityIndex( Scope & m, const char* name ) { m.def(name, []( const MeshEntity& entity, const typename MeshEntity::LocalIndexType& i ) { return entity.template getSubentityIndex< Subdimension >( i ); Loading @@ -58,17 +49,20 @@ void export_getSubentityIndex( Scope & m, const char* name, _special ) } template< typename MeshEntity, int Superdimension, typename Scope > void export_getSubentityIndex( Scope &, const char*, _general ) int Subdimension, typename Scope, std::enable_if_t< ! ( Subdimension <= MeshEntity::MeshType::getMeshDimension() && (Subdimension < MeshEntity::getEntityDimension()) ), bool > = true > void export_getSubentityIndex( Scope &, const char* ) { } template< typename MeshEntity, typename Scope, typename = typename std::enable_if< MeshEntity::getEntityDimension() == 0 >::type > void export_getPoint( Scope & scope, _special ) std::enable_if_t< MeshEntity::getEntityDimension() == 0, bool > = true > void export_getPoint( Scope & scope ) { scope.def("getPoint", []( const MeshEntity& entity ) { return entity.getPoint(); Loading @@ -77,8 +71,9 @@ void export_getPoint( Scope & scope, _special ) } template< typename MeshEntity, typename Scope > void export_getPoint( Scope &, _general ) typename Scope, std::enable_if_t< MeshEntity::getEntityDimension() != 0, bool > = true > void export_getPoint( Scope & ) { } Loading @@ -88,24 +83,22 @@ void export_MeshEntity( Scope & scope, const char* name ) { auto entity = py::class_< MeshEntity >( scope, name ) .def_static("getEntityDimension", &MeshEntity::getEntityDimension) // FIXME: boost chokes on this // .def("getIndex", &MeshEntity::getIndex, py::return_internal_reference<>()) .def("getIndex", getIndex< MeshEntity >) .def("getIndex", &MeshEntity::getIndex) // TODO ; export_getSuperentityIndex< MeshEntity, MeshEntity::getEntityDimension() + 1 >( entity, _special() ); export_getSubentityIndex< MeshEntity, 0 >( entity, "getSubvertexIndex", _special() ); export_getPoint< MeshEntity >( entity, _special() ); export_getSuperentityIndex< MeshEntity, MeshEntity::getEntityDimension() + 1 >( entity ); export_getSubentityIndex< MeshEntity, 0 >( entity, "getSubvertexIndex" ); export_getPoint< MeshEntity >( entity ); } template< typename Mesh > void export_Mesh( py::module & m, const char* name ) { // there are two templates - const and non-const - take only the const auto (Mesh::* getEntity_cell)(const typename Mesh::GlobalIndexType&) const = &Mesh::template getEntity<typename Mesh::Cell>; auto (Mesh::* getEntity_face)(const typename Mesh::GlobalIndexType&) const = &Mesh::template getEntity<typename Mesh::Face>; auto (Mesh::* getEntity_vertex)(const typename Mesh::GlobalIndexType&) const = &Mesh::template getEntity<typename Mesh::Vertex>; auto (Mesh::* getEntity_cell)(const typename Mesh::GlobalIndexType) const = &Mesh::template getEntity<typename Mesh::Cell>; auto (Mesh::* getEntity_face)(const typename Mesh::GlobalIndexType) const = &Mesh::template getEntity<typename Mesh::Face>; auto (Mesh::* getEntity_vertex)(const typename Mesh::GlobalIndexType) const = &Mesh::template getEntity<typename Mesh::Vertex>; export_EntityTypes(m); Loading @@ -116,9 +109,9 @@ void export_Mesh( py::module & m, const char* name ) .def("getSerializationTypeVirtual", &Mesh::getSerializationTypeVirtual) .def("getEntitiesCount", &mesh_getEntitiesCount< Mesh >) // TODO: if combined, the return type would depend on the runtime parameter (entity) .def("getEntity_cell", getEntity_cell, py::return_value_policy::reference_internal) .def("getEntity_face", getEntity_face, py::return_value_policy::reference_internal) .def("getEntity_vertex", getEntity_vertex, py::return_value_policy::reference_internal) .def("getEntity_cell", getEntity_cell) .def("getEntity_face", getEntity_face) .def("getEntity_vertex", getEntity_vertex) .def("getEntityCenter", []( const Mesh& mesh, const typename Mesh::Cell& cell ){ return getEntityCenter( mesh, cell ); } ) .def("getEntityCenter", []( const Mesh& mesh, const typename Mesh::Face& face ){ return getEntityCenter( mesh, face ); } ) .def("getEntityCenter", []( const Mesh& mesh, const typename Mesh::Vertex& vertex ){ return getEntityCenter( mesh, vertex ); } ) Loading src/Python/pytnl/typedefs.h +3 −6 Original line number Diff line number Diff line Loading @@ -24,19 +24,16 @@ using MeshOfEdges = TNL::Meshes::Mesh< TNL::Meshes::DefaultConfig< EdgeTopology::dimension, RealType, IndexType, LocalIndexType, IndexType > >; LocalIndexType > >; using MeshOfTriangles = TNL::Meshes::Mesh< TNL::Meshes::DefaultConfig< TriangleTopology, TriangleTopology::dimension, RealType, IndexType, LocalIndexType, IndexType > >; LocalIndexType > >; using MeshOfTetrahedrons = TNL::Meshes::Mesh< TNL::Meshes::DefaultConfig< TetrahedronTopology, TetrahedronTopology::dimension, RealType, IndexType, LocalIndexType, IndexType > >; LocalIndexType > >; Loading
CMakeLists.txt +4 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,10 @@ if( DEFINED ENV{CI_JOB_NAME} OR ${CMAKE_GENERATOR} STREQUAL "Ninja" ) endif() endif() # add the filesystem library to all targets # https://en.cppreference.com/w/cpp/filesystem link_libraries( stdc++fs ) # gtest has to be built before we add the MPI flags if( ${WITH_TESTS} OR ${WITH_MATRIX_TESTS} ) enable_testing() Loading
cmake/FindMETIS.cmake 0 → 100644 +23 −0 Original line number Diff line number Diff line # This module will try to find METIS and define the following: # METIS_FOUND - True iff METIS was found # METIS_INCLUDE_DIRS - METIS include directories # METIS_LIBRARIES - METIS library paths find_path(METIS_INCLUDE_DIR metis.h PATHS /usr/include /usr/local/include DOC "METIS include directory") find_library(METIS_LIBRARY metis PATHS /usr/lib /usr/local/lib ${PROJECT_SOURCE_DIR}/metis DOC "Path to METIS library") include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set METIS_FOUND to TRUE # if all listed variables are TRUE find_package_handle_standard_args(METIS DEFAULT_MSG METIS_LIBRARY METIS_INCLUDE_DIR) mark_as_advanced(METIS_INCLUDE_DIR METIS_LIBRARY) set(METIS_LIBRARIES ${METIS_LIBRARY}) set(METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR})
src/Python/pytnl/tnl/Mesh.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -13,18 +13,18 @@ void export_Meshes( py::module & m ) using Reader = TNL::Meshes::Readers::VTKReader; py::class_< Reader >( m, "VTKReader" ) .def(py::init<>()) .def("readMesh", &Reader::template readMesh< MeshOfEdges >) .def("readMesh", &Reader::template readMesh< MeshOfTriangles >) .def("readMesh", &Reader::template readMesh< MeshOfTetrahedrons >) // .def("readMesh", []( Reader& reader, const std::string& name, MeshOfEdges & mesh ) { // return reader.readMesh( name.c_str(), mesh ); .def(py::init<std::string>()) .def("loadMesh", &Reader::template loadMesh< MeshOfEdges >) .def("loadMesh", &Reader::template loadMesh< MeshOfTriangles >) .def("loadMesh", &Reader::template loadMesh< MeshOfTetrahedrons >) // .def("loadMesh", []( Reader& reader, const std::string& name, MeshOfEdges & mesh ) { // return reader.loadMesh( name.c_str(), mesh ); // } ) // .def("readMesh", []( Reader& reader, const std::string& name, MeshOfTriangles & mesh ) { // return reader.readMesh( name.c_str(), mesh ); // .def("loadMesh", []( Reader& reader, const std::string& name, MeshOfTriangles & mesh ) { // return reader.loadMesh( name.c_str(), mesh ); // } ) // .def("readMesh", []( Reader& reader, const std::string& name, MeshOfTetrahedrons & mesh ) { // return reader.readMesh( name.c_str(), mesh ); // .def("loadMesh", []( Reader& reader, const std::string& name, MeshOfTetrahedrons & mesh ) { // return reader.loadMesh( name.c_str(), mesh ); // } ) ; }
src/Python/pytnl/tnl/Mesh.h +29 −36 Original line number Diff line number Diff line Loading @@ -13,22 +13,12 @@ namespace py = pybind11; #include <type_traits> template< typename MeshEntity > typename MeshEntity::MeshTraitsType::GlobalIndexType getIndex( const MeshEntity& entity ) { return entity.getIndex(); }; struct _general {}; struct _special : _general {}; template< typename MeshEntity, int Superdimension, typename Scope, typename = typename std::enable_if< Superdimension <= MeshEntity::MeshTraitsType::meshDimension >::type > std::enable_if_t< Superdimension <= MeshEntity::MeshType::getMeshDimension(), bool > = true > // && MeshEntity::template SuperentityTraits< Superdimension >::storageEnabled >::type > void export_getSuperentityIndex( Scope & m, _special ) void export_getSuperentityIndex( Scope & m ) { m.def("getSuperentityIndex", []( const MeshEntity& entity, const typename MeshEntity::LocalIndexType& i ) { return entity.template getSuperentityIndex< Superdimension >( i ); Loading @@ -38,8 +28,9 @@ void export_getSuperentityIndex( Scope & m, _special ) template< typename MeshEntity, int Superdimension, typename Scope > void export_getSuperentityIndex( Scope &, _general ) typename Scope, std::enable_if_t< ! ( Superdimension <= MeshEntity::MeshType::getMeshDimension() ), bool > = true > void export_getSuperentityIndex( Scope & ) { } Loading @@ -47,9 +38,9 @@ void export_getSuperentityIndex( Scope &, _general ) template< typename MeshEntity, int Subdimension, typename Scope, typename = typename std::enable_if< Subdimension <= MeshEntity::MeshTraitsType::meshDimension && (Subdimension < MeshEntity::getEntityDimension()) >::type > void export_getSubentityIndex( Scope & m, const char* name, _special ) std::enable_if_t< Subdimension <= MeshEntity::MeshType::getMeshDimension() && (Subdimension < MeshEntity::getEntityDimension()), bool > = true > void export_getSubentityIndex( Scope & m, const char* name ) { m.def(name, []( const MeshEntity& entity, const typename MeshEntity::LocalIndexType& i ) { return entity.template getSubentityIndex< Subdimension >( i ); Loading @@ -58,17 +49,20 @@ void export_getSubentityIndex( Scope & m, const char* name, _special ) } template< typename MeshEntity, int Superdimension, typename Scope > void export_getSubentityIndex( Scope &, const char*, _general ) int Subdimension, typename Scope, std::enable_if_t< ! ( Subdimension <= MeshEntity::MeshType::getMeshDimension() && (Subdimension < MeshEntity::getEntityDimension()) ), bool > = true > void export_getSubentityIndex( Scope &, const char* ) { } template< typename MeshEntity, typename Scope, typename = typename std::enable_if< MeshEntity::getEntityDimension() == 0 >::type > void export_getPoint( Scope & scope, _special ) std::enable_if_t< MeshEntity::getEntityDimension() == 0, bool > = true > void export_getPoint( Scope & scope ) { scope.def("getPoint", []( const MeshEntity& entity ) { return entity.getPoint(); Loading @@ -77,8 +71,9 @@ void export_getPoint( Scope & scope, _special ) } template< typename MeshEntity, typename Scope > void export_getPoint( Scope &, _general ) typename Scope, std::enable_if_t< MeshEntity::getEntityDimension() != 0, bool > = true > void export_getPoint( Scope & ) { } Loading @@ -88,24 +83,22 @@ void export_MeshEntity( Scope & scope, const char* name ) { auto entity = py::class_< MeshEntity >( scope, name ) .def_static("getEntityDimension", &MeshEntity::getEntityDimension) // FIXME: boost chokes on this // .def("getIndex", &MeshEntity::getIndex, py::return_internal_reference<>()) .def("getIndex", getIndex< MeshEntity >) .def("getIndex", &MeshEntity::getIndex) // TODO ; export_getSuperentityIndex< MeshEntity, MeshEntity::getEntityDimension() + 1 >( entity, _special() ); export_getSubentityIndex< MeshEntity, 0 >( entity, "getSubvertexIndex", _special() ); export_getPoint< MeshEntity >( entity, _special() ); export_getSuperentityIndex< MeshEntity, MeshEntity::getEntityDimension() + 1 >( entity ); export_getSubentityIndex< MeshEntity, 0 >( entity, "getSubvertexIndex" ); export_getPoint< MeshEntity >( entity ); } template< typename Mesh > void export_Mesh( py::module & m, const char* name ) { // there are two templates - const and non-const - take only the const auto (Mesh::* getEntity_cell)(const typename Mesh::GlobalIndexType&) const = &Mesh::template getEntity<typename Mesh::Cell>; auto (Mesh::* getEntity_face)(const typename Mesh::GlobalIndexType&) const = &Mesh::template getEntity<typename Mesh::Face>; auto (Mesh::* getEntity_vertex)(const typename Mesh::GlobalIndexType&) const = &Mesh::template getEntity<typename Mesh::Vertex>; auto (Mesh::* getEntity_cell)(const typename Mesh::GlobalIndexType) const = &Mesh::template getEntity<typename Mesh::Cell>; auto (Mesh::* getEntity_face)(const typename Mesh::GlobalIndexType) const = &Mesh::template getEntity<typename Mesh::Face>; auto (Mesh::* getEntity_vertex)(const typename Mesh::GlobalIndexType) const = &Mesh::template getEntity<typename Mesh::Vertex>; export_EntityTypes(m); Loading @@ -116,9 +109,9 @@ void export_Mesh( py::module & m, const char* name ) .def("getSerializationTypeVirtual", &Mesh::getSerializationTypeVirtual) .def("getEntitiesCount", &mesh_getEntitiesCount< Mesh >) // TODO: if combined, the return type would depend on the runtime parameter (entity) .def("getEntity_cell", getEntity_cell, py::return_value_policy::reference_internal) .def("getEntity_face", getEntity_face, py::return_value_policy::reference_internal) .def("getEntity_vertex", getEntity_vertex, py::return_value_policy::reference_internal) .def("getEntity_cell", getEntity_cell) .def("getEntity_face", getEntity_face) .def("getEntity_vertex", getEntity_vertex) .def("getEntityCenter", []( const Mesh& mesh, const typename Mesh::Cell& cell ){ return getEntityCenter( mesh, cell ); } ) .def("getEntityCenter", []( const Mesh& mesh, const typename Mesh::Face& face ){ return getEntityCenter( mesh, face ); } ) .def("getEntityCenter", []( const Mesh& mesh, const typename Mesh::Vertex& vertex ){ return getEntityCenter( mesh, vertex ); } ) Loading
src/Python/pytnl/typedefs.h +3 −6 Original line number Diff line number Diff line Loading @@ -24,19 +24,16 @@ using MeshOfEdges = TNL::Meshes::Mesh< TNL::Meshes::DefaultConfig< EdgeTopology::dimension, RealType, IndexType, LocalIndexType, IndexType > >; LocalIndexType > >; using MeshOfTriangles = TNL::Meshes::Mesh< TNL::Meshes::DefaultConfig< TriangleTopology, TriangleTopology::dimension, RealType, IndexType, LocalIndexType, IndexType > >; LocalIndexType > >; using MeshOfTetrahedrons = TNL::Meshes::Mesh< TNL::Meshes::DefaultConfig< TetrahedronTopology, TetrahedronTopology::dimension, RealType, IndexType, LocalIndexType, IndexType > >; LocalIndexType > >;