Commit 38d75809 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Rewritten mesh initializer to optimize memory usage

parent 184a4ca1
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -89,8 +89,9 @@ class Mesh

      bool operator==( const Mesh& mesh ) const;

      bool init( const typename MeshTraitsType::PointArrayType& points,
                 const typename MeshTraitsType::CellSeedArrayType& cellSeeds );
      // The points and cellSeeds arrays will be reset when not needed to save memory.
      bool init( typename MeshTraitsType::PointArrayType& points,
                 typename MeshTraitsType::CellSeedArrayType& cellSeeds );

   protected:
      // Methods for the mesh initializer
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ class MeshBuilder
      return this->cellSeeds[ index ];
   }

   bool build( MeshType& mesh ) const
   bool build( MeshType& mesh )
   {
      if( ! this->validate() )
         return false;
+2 −2
Original line number Diff line number Diff line
@@ -154,8 +154,8 @@ operator==( const Mesh& mesh ) const
template< typename MeshConfig >
bool
Mesh< MeshConfig >::
init( const typename MeshTraitsType::PointArrayType& points,
      const typename MeshTraitsType::CellSeedArrayType& cellSeeds )
init( typename MeshTraitsType::PointArrayType& points,
      typename MeshTraitsType::CellSeedArrayType& cellSeeds )
{
   MeshInitializer< MeshConfig> meshInitializer;
   if( ! meshInitializer.createMesh( points, cellSeeds, *this ) )
+252 −278

File changed.

Preview size limit exceeded, changes collapsed.

+39 −0
Original line number Diff line number Diff line
@@ -62,6 +62,45 @@ class MeshEntitySeed
      IdArrayType cornerIds;
};

template< typename MeshConfig >
class MeshEntitySeed< MeshConfig, MeshVertexTopology >
{
   using MeshConfigTraits = MeshTraits< MeshConfig >;

   public:
      using GlobalIndexType = typename MeshTraits< MeshConfig >::GlobalIndexType;
      using LocalIndexType  = typename MeshTraits< MeshConfig >::LocalIndexType;
      using IdArrayType     = Containers::StaticArray< 1, GlobalIndexType >;

      static String getType() { return String( "MeshEntitySeed<>" ); }

      static constexpr LocalIndexType getCornersCount()
      {
         return 1;
      }

      void setCornerId( const LocalIndexType& cornerIndex, const GlobalIndexType& pointIndex )
      {
         Assert( cornerIndex == 0, std::cerr << "cornerIndex = " << cornerIndex );
         Assert( 0 <= pointIndex, std::cerr << "pointIndex = " << pointIndex );

         this->cornerIds[ cornerIndex ] = pointIndex;
      }

      IdArrayType& getCornerIds()
      {
         return cornerIds;
      }

      const IdArrayType& getCornerIds() const
      {
         return cornerIds;
      }

   private:
      IdArrayType cornerIds;
};

template< typename MeshConfig, typename EntityTopology >
std::ostream& operator<<( std::ostream& str, const MeshEntitySeed< MeshConfig, EntityTopology >& e )
{
Loading