Commit 0cbdb19e authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Merge branch 'JK/mesh' into 'develop'

JK/mesh

Closes #69 and #70

See merge request !96
parents e3a4ae49 f9daeba5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ void export_MeshReaders( py::module & m )
        .def("loadMesh", &MeshReader::template loadMesh< MeshOfQuadrangles >)
        .def("loadMesh", &MeshReader::template loadMesh< MeshOfTetrahedrons >)
        .def("loadMesh", &MeshReader::template loadMesh< MeshOfHexahedrons >)
        .def("readPointData", &MeshReader::readPointData)
        .def("readCellData", &MeshReader::readCellData)
    ;

    py::class_< TNL::Meshes::Readers::VTKReader, MeshReader >( m, "VTKReader" )
@@ -29,8 +31,6 @@ void export_MeshReaders( py::module & m )
    // base class for VTUReader and PVTUReader
    py::class_< XMLVTK, PyXMLVTK, MeshReader >( m, "XMLVTK" )
        .def(py::init<std::string>())
        .def("readPointData", &XMLVTK::readPointData)
        .def("readCellData", &XMLVTK::readCellData)
   ;

    py::class_< TNL::Meshes::Readers::VTUReader, XMLVTK >( m, "VTUReader" )
+0 −9
Original line number Diff line number Diff line
@@ -167,9 +167,6 @@ public:
   operator()( IndexTypes&&... indices )
   {
      static_assert( sizeof...( indices ) == getDimension(), "got wrong number of indices" );
      __ndarray_impl::assertIndicesInBounds( getSizes(), OverlapsType{}, std::forward< IndexTypes >( indices )... );
      TNL_ASSERT_LT( getStorageIndex( std::forward< IndexTypes >( indices )... ), getStorageSize(),
                     "storage index out of bounds - either input error or a bug in the indexer" );
      return array[ getStorageIndex( std::forward< IndexTypes >( indices )... ) ];
   }

@@ -179,9 +176,6 @@ public:
   operator()( IndexTypes&&... indices ) const
   {
      static_assert( sizeof...( indices ) == getDimension(), "got wrong number of indices" );
      __ndarray_impl::assertIndicesInBounds( getSizes(), OverlapsType{}, std::forward< IndexTypes >( indices )... );
      TNL_ASSERT_LT( getStorageIndex( std::forward< IndexTypes >( indices )... ), getStorageSize(),
                     "storage index out of bounds - either input error or a bug in the indexer" );
      return array[ getStorageIndex( std::forward< IndexTypes >( indices )... ) ];
   }

@@ -294,9 +288,6 @@ public:
   getElement( IndexTypes&&... indices ) const
   {
      static_assert( sizeof...( indices ) == getDimension(), "got wrong number of indices" );
      __ndarray_impl::assertIndicesInBounds( getSizes(), OverlapsType{}, std::forward< IndexTypes >( indices )... );
      TNL_ASSERT_LT( getStorageIndex( std::forward< IndexTypes >( indices )... ), getStorageSize(),
                     "storage index out of bounds - either input error or a bug in the indexer" );
      return array.getElement( getStorageIndex( std::forward< IndexTypes >( indices )... ) );
   }

+13 −4
Original line number Diff line number Diff line
@@ -91,10 +91,19 @@ public:
   getStorageIndex( IndexTypes&&... indices ) const
   {
      static_assert( sizeof...( indices ) == SizesHolder::getDimension(), "got wrong number of indices" );
      return Base::template getStorageIndex< Permutation, Overlaps >
      __ndarray_impl::assertIndicesInBounds( getSizes(), OverlapsType{}, std::forward< IndexTypes >( indices )... );
      const IndexType result = Base::template getStorageIndex< Permutation, Overlaps >
                               ( sizes,
                                 static_cast< const StridesHolder& >( *this ),
                                 std::forward< IndexTypes >( indices )... );
      TNL_ASSERT_GE( result, (IndexType) 0,
                     "storage index out of bounds - either input error or a bug in the indexer" );
      // upper bound can be checked only for contiguous arrays/views
      if( StridesHolder::isContiguous() ) {
         TNL_ASSERT_LT( result, getStorageSize(),
                        "storage index out of bounds - either input error or a bug in the indexer" );
      }
      return result;
   }

protected:
+0 −2
Original line number Diff line number Diff line
@@ -223,7 +223,6 @@ public:
   operator()( IndexTypes&&... indices )
   {
      static_assert( sizeof...( indices ) == getDimension(), "got wrong number of indices" );
      __ndarray_impl::assertIndicesInBounds( getSizes(), OverlapsType{}, std::forward< IndexTypes >( indices )... );
      return array[ getStorageIndex( std::forward< IndexTypes >( indices )... ) ];
   }

@@ -233,7 +232,6 @@ public:
   operator()( IndexTypes&&... indices ) const
   {
      static_assert( sizeof...( indices ) == getDimension(), "got wrong number of indices" );
      __ndarray_impl::assertIndicesInBounds( getSizes(), OverlapsType{}, std::forward< IndexTypes >( indices )... );
      return array[ getStorageIndex( std::forward< IndexTypes >( indices )... ) ];
   }

+25 −0
Original line number Diff line number Diff line
@@ -72,5 +72,30 @@ inline int getRankOnNode( MPI_Comm group = AllGroup() )
#endif
}

/**
 * \brief Applies the given reduction operation to the values among all ranks
 * in the given communicator.
 *
 * This is a collective operation which uses \ref Allreduce internally. It
 * provides nicer semantics than the wrapper function: the input value is passed
 * by value (heh) rather then by pointer, and the result is returned rather than
 * written to the output pointer.
 *
 * \param value Value of the current rank to be reduced.
 * \param op The reduction operation to be applied.
 * \param group The communicator comprising ranks that participate in the
 *              collective operation.
 * \return The reduced value (it is ensured that all ranks receive the same
 *         value).
 */
template< typename T >
T reduce( T value, const MPI_Op& op, MPI_Comm group = AllGroup() )
{
   // call the in-place variant of Allreduce
   Allreduce( &value, 1, op, group );
   // return the reduced value
   return value;
}

} // namespace MPI
} // namespace TNL
Loading