Skip to content
Snippets Groups Projects
Commit 28b97ce8 authored by Oliver Sander's avatar Oliver Sander
Browse files

writing SGrid<2,2> and SGrid<3,3>

[[Imported from SVN: r2083]]
parent 1c482538
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
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