Skip to content
Snippets Groups Projects
Commit 1b76c2ff authored by Robert K's avatar Robert K
Browse files

added more sofisticated space filling curve print.

parent dc8d7ab8
No related branches found
No related tags found
No related merge requests found
#ifndef DUNE_ALU3DGRID_HSFC_HH
#define DUNE_ALU3DGRID_HSFC_HH
#include <string>
#include <sstream>
#include <fstream>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/common/parallel/collectivecommunication.hh>
#include <dune/common/parallel/mpicollectivecommunication.hh>
......@@ -84,7 +88,71 @@ namespace ALUGridSFC {
}
};
#endif // if HAVE_ZOLTAN
}
template< class GridView >
void printSpaceFillingCurve ( const GridView& view, std::string name = "sfc" )
{
typedef typename GridView :: template Codim< 0 > :: Iterator Iterator ;
typedef typename Iterator :: Entity :: Geometry :: GlobalCoordinate GlobalCoordinate ;
std::vector< GlobalCoordinate > vertices;
vertices.reserve( view.indexSet().size( 0 ) );
const Iterator endit = view.template end< 0 > ();
for(Iterator it = view.template begin< 0 > (); it != endit; ++ it )
{
GlobalCoordinate center = (*it).geometry().center();
vertices.push_back( center );
}
std::stringstream gnufilename;
gnufilename << name << ".gnu";
if( view.grid().comm().size() > 1 )
gnufilename << "." << view.grid().comm().rank();
std::ofstream gnuFile ( gnufilename.str() );
if( gnuFile )
{
for( size_t i=0; i<vertices.size(); ++i )
{
gnuFile << vertices[ i ] << std::endl;
}
gnuFile.close();
}
std::stringstream vtkfilename;
vtkfilename << name << ".vtk";
if( view.grid().comm().size() > 1 )
vtkfilename << "." << view.grid().comm().rank();
std::ofstream vtkFile ( vtkfilename.str() );
if( vtkFile )
{
vtkFile << "# vtk DataFile Version 1.0" << std::endl;
vtkFile << "Line representation of vtk" << std::endl;
vtkFile << "ASCII" << std::endl;
vtkFile << "DATASET POLYDATA" << std::endl;
vtkFile << "POINTS "<< vertices.size() << " FLOAT" << std::endl;
for( size_t i=0; i<vertices.size(); ++i )
{
vtkFile << vertices[ i ];
for( int d=GlobalCoordinate::dimension; d<3; ++d )
vtkFile << " 0";
vtkFile << std::endl;
}
// lines, #lines, #entries
vtkFile << "LINES " << vertices.size()-1 << " " << (vertices.size()-1)*3 << std::endl;
for( size_t i=0; i<vertices.size()-1; ++i )
vtkFile << "2 " << i << " " << i+1 << std::endl;
vtkFile.close();
}
}
} // end namespace ALUGridSFC
namespace Dune {
......
......@@ -26,18 +26,6 @@
#include "diagnostics.hh"
#include "paralleldgf.hh"
template <class Grid>
inline void printSpaceFillingCurve( const Grid& grid, std::ostream& out )
{
const auto& gridView = grid.leafGridView();
for( auto it = gridView.template begin<0>(), end = gridView.template end<0>();
it != end; ++it )
{
out << (*it).geometry().center() << std::endl;
}
}
// method
// ------
void method ( int problem, int startLvl, int maxLvl,
......@@ -67,8 +55,7 @@ void method ( int problem, int startLvl, int maxLvl,
if( grid.comm().size() == 1 )
{
std::ofstream file( "curve.gnu" );
printSpaceFillingCurve( grid, file );
ALUGridSFC::printSpaceFillingCurve( grid.leafGridView() );
}
#ifndef BALL
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment