diff --git a/io/file/amiramesh/amsgridwriter.cc b/io/file/amiramesh/amsgridwriter.cc index 2a70f48b683a494c302125c8387e4df8e0390726..cd33871ae62adcbf7ba7bd5e594f581aa3c8588d 100644 --- a/io/file/amiramesh/amsgridwriter.cc +++ b/io/file/amiramesh/amsgridwriter.cc @@ -6,15 +6,14 @@ #include <dune/grid/sgrid.hh> -#if 0 namespace Dune { template <> - template <class DiscFuncType> - class AmiraMeshWriter<SGrid<3,3>, DiscFuncType> { + class AmiraMeshWriter<SGrid<3,3> > { public: + template <class DiscFuncType> static void write(const SGrid<3,3>& grid, const DiscFuncType& sol, const std::string& filename); @@ -26,15 +25,14 @@ namespace Dune { } -//template<> -void Dune::AmiraMeshWriter<Dune::SimpleGrid<3,3>, double>::write(const Dune::SimpleGrid<3,3>& grid, - const Array<double>& sol, - const std::string& filename) +template<class DiscFuncType> +void Dune::AmiraMeshWriter<Dune::SGrid<3,3> >::write(const Dune::SGrid<3,3>& grid, + const DiscFuncType& sol, + const std::string& filename) { - printf("This is the AmiraMesh writer for SimpleGrid<3,3>!\n"); + printf("This is the AmiraMesh writer for SGrid<3,3>!\n"); int maxlevel = grid.maxlevel(); - const levelinfo<3>* li = grid.get_levelinfo(maxlevel); // determine current time time_t time_val = time(NULL); @@ -47,14 +45,18 @@ void Dune::AmiraMeshWriter<Dune::SimpleGrid<3,3>, double>::write(const Dune::Sim fprintf(fp, "# AmiraMesh 3D ASCII 2.0\n"); fprintf(fp, "# CreationDate: %s\n\n\n", asctime_val); - fprintf(fp, "define Lattice %d %d %d\n\n", li->ne[0], li->ne[1], li->ne[2]); + fprintf(fp, "define Lattice %d %d %d\n\n", grid.dims(maxlevel)[0]+1, + grid.dims(maxlevel)[1]+1, grid.dims(maxlevel)[2]+1); fprintf(fp, "Parameters {\n"); - // SimpleGrids always have the unit bounding box - fprintf(fp, " BoundingBox 0 1 0 1 0 1,\n"); + fprintf(fp, " BoundingBox %g %g %g %g %g %g,\n", + grid.lowerLeft()[0], grid.upperRight()[0], + grid.lowerLeft()[1], grid.upperRight()[1], + grid.lowerLeft()[2], grid.upperRight()[2]); fprintf(fp, " CoordType \"uniform\",\n"); fprintf(fp, " Content \"%dx%dx%d double, uniform coordinates\"\n", - li->ne[0], li->ne[1], li->ne[2]); + grid.dims(maxlevel)[0]+1, + grid.dims(maxlevel)[1]+1, grid.dims(maxlevel)[2]+1); fprintf(fp, "}\n\n"); fprintf(fp, "Lattice { double Data } @1\n\n"); @@ -63,24 +65,26 @@ void Dune::AmiraMeshWriter<Dune::SimpleGrid<3,3>, double>::write(const Dune::Sim fprintf(fp, "@1\n"); // - Array<double>::Iterator iter = sol.begin(); - for (; iter!=sol.end(); ++iter) { - fprintf(fp, "%f\n", *iter); + typedef typename DiscFuncType::ConstDofIteratorType DofIterator; + DofIterator it = sol.dbegin(); + DofIterator endIt = sol.dend(); + + for (; it!=endIt; ++it) { + fprintf(fp, "%f\n", *it); } fclose(fp); } -#endif namespace Dune { template<> - template <class DiscFuncType> - class AmiraMeshWriter<SGrid<2,2>, DiscFuncType> { + class AmiraMeshWriter<SGrid<2,2> > { public: + template <class DiscFuncType> static void write(const SGrid<2,2>& grid, const DiscFuncType& sol, const std::string& filename); @@ -93,8 +97,9 @@ namespace Dune { } -template<> template <class DiscFuncType> -void Dune::AmiraMeshWriter<Dune::SGrid<2,2>, DiscFuncType>:: +//template<> +template <class DiscFuncType> +void Dune::AmiraMeshWriter<Dune::SGrid<2,2> >:: write(const Dune::SGrid<2,2>& grid, const DiscFuncType& sol, const std::string& filename) @@ -102,7 +107,6 @@ write(const Dune::SGrid<2,2>& grid, std::cout << "This is the AmiraMesh writer for SGrid<2,2>!" << std::endl; int maxlevel = grid.maxlevel(); - //const Dune::levelinfo<2>* li = grid.get_levelinfo(maxlevel); // determine current time time_t time_val = time(NULL); @@ -115,16 +119,18 @@ write(const Dune::SGrid<2,2>& grid, fprintf(fp, "# AmiraMesh 3D ASCII 2.0\n"); fprintf(fp, "# CreationDate: %s\n\n\n", asctime_val); - fprintf(fp, "define Lattice %d %d %d\n\n", grid.dims(maxlevel)[0]+1, grid.dims(maxlevel)[1]+1, 1); + fprintf(fp, "define Lattice %d %d\n\n", grid.dims(maxlevel)[0]+1, grid.dims(maxlevel)[1]+1); fprintf(fp, "Parameters {\n"); + fprintf(fp, "TypeId \"HxRegScalarOrthoSlice2\",\n"); + fprintf(fp, "ContentType \"HxField2d\",\n"); + fprintf(fp, " Content \"%dx%d double, uniform coordinates\",\n", + grid.dims(maxlevel)[0]+1, grid.dims(maxlevel)[1]+1); fprintf(fp, " BoundingBox %g %g %g %g 0 1,\n", grid.lowerLeft()[0], grid.upperRight()[0], grid.lowerLeft()[1], grid.upperRight()[1]); - fprintf(fp, " CoordType \"uniform\",\n"); - fprintf(fp, " Content \"%dx%dx%d double, uniform coordinates\"\n", - grid.dims(maxlevel)[0]+1, grid.dims(maxlevel)[1]+1, 1); + fprintf(fp, " CoordType \"uniform\"\n"); fprintf(fp, "}\n\n"); fprintf(fp, "Lattice { double Data } @1\n\n"); @@ -133,9 +139,9 @@ write(const Dune::SGrid<2,2>& grid, fprintf(fp, "@1\n"); // - typedef typename DiscFuncType::DofIteratorType DofIterator; - DofIterator it = sol.dbegin(maxlevel); - DofIterator endIt = sol.dend(maxlevel); + typedef typename DiscFuncType::ConstDofIteratorType DofIterator; + DofIterator it = sol.dbegin(); + DofIterator endIt = sol.dend(); for (; it!=endIt; ++it) { fprintf(fp, "%f\n", *it);