[Dune] suggestion for example adaptivefinitevolume.cc
Matteo Semplice
matteo.semplice at uninsubria.it
Sat Nov 26 18:48:58 CET 2011
On 26/11/2011 17:57, Dedner, Andreas wrote:
>
> Thanks, such suggestion in improving the howto code is greatly
> appreciated.
> Added them to the trunk.
> Do you also have a suggestion for what to add to the dunecontrol
> documentation
> to avoid the difficulties you had?
>
> Best
> Andreas
>
Here is another one about the same exmaple code. VTK output has
extension ".vtp" for one dimensional grids, so it's better to extract
the actual file name from vtkwriter.write:
--- /home/matteo/dune2.1/dune-grid-howto-2.1.0/vtkout.hh
2011-04-29 17:31:53.000000000 +0200
+++ vtkout.hh 2011-11-26 18:36:49.000000000 +0100
@@ -9,16 +9,18 @@
{
Dune::VTKWriter<typename G::LeafGridView> vtkwriter(grid.leafView());
char fname[128];
+ std::string fullname;
char sername[128];
+
sprintf(fname,"%s-%05d",name,k);
sprintf(sername,"%s.series",name);
vtkwriter.addCellData(c,"celldata");
- vtkwriter.write(fname,Dune::VTKOptions::ascii);
+ fullname = vtkwriter.write(fname,Dune::VTKOptions::ascii);
if ( rank == 0)
{
std::ofstream serstream(sername, (k==0 ? std::ios_base::out :
std::ios_base::app));
- serstream << k << " " << fname << ".vtu " << time << std::endl;
+ serstream << k << " " << fullname << " " << time << std::endl;
serstream.close();
}
}
Actually one could reuse the fname variable, but I always get confused
by char*, std:strings and string streams, so I didn't try...
Also, I'm not sure where the writePVD script is to be found (it's
nowhere on my system!), but, in case it's really missing, the following
does the job:
#!/usr/bin/awk -f
BEGIN{
print "<?xml version=\"1.0\"?>" ;
print "<VTKFile type=\"Collection\" version=\"0.1\"
byte_order=\"LittleEndian\">";
print "<Collection>";
}
{
print "<DataSet timestep=\"" $3 "\" file=\"" $2 "\"/>";
}
END{
print "</Collection>";
print "</VTKFile>";
}
--
Matteo Semplice Dip. di Fisica e Matematica
Phone: 031-2386132 Università dell'Insubria
Fax: 031-2386209 Via Valleggio, 11
22100 Como
More information about the Dune
mailing list