1#ifndef VIENNASHE_IO_GNUPLOT_WRITER_HPP
2#define VIENNASHE_IO_GNUPLOT_WRITER_HPP
25#include "viennagrid/mesh/mesh.hpp"
26#include "viennagrid/algorithm/centroid.hpp"
50 template <
typename DeviceType,
51 typename CellFilterType,
52 typename QuantitiyAccessorType>
54 CellFilterType
const & cell_filter,
55 QuantitiyAccessorType
const & quan,
56 const std::string filename)
const
58 typedef typename DeviceType::mesh_type MeshType;
60 typedef typename viennagrid::result_of::point<MeshType>::type PointType;
62 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
63 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
65 std::ofstream writer(filename.c_str());
72 writer <<
"## ViennaSHE - gnuplot output " << std::endl;
75 for ( CellIterator cit = cells.begin();
80 if ( !cell_filter(*cit) )
continue;
83 PointType p = viennagrid::centroid(*cit);
84 for (std::size_t i = 0; i < static_cast<std::size_t>(PointType::dim); ++i) writer << p[i] <<
" ";
85 this->write_value(writer, quan(*cit));
89 log::info() <<
"* write_vertex_quantity_for_gnuplot(): Writing data to '"
91 <<
"' (can be viewed with e.g. gnuplot)" << std::endl;
95 template <
typename DeviceType,
96 typename QuantitiyAccessorType>
98 QuantitiyAccessorType
const & quan,
99 const std::string filename)
const
107 template <
typename WriterT,
typename ValueT >
108 void write_value(WriterT &, ValueT
const &)
const
111 error_type * obj; obj = 0;
114 template <
typename WriterT >
115 void write_value(WriterT & writer,
double const & val)
const
117 writer << val <<
" " ;
120 template <
typename WriterT >
121 void write_value(WriterT & writer, std::vector<double>
const & val)
const
123 for (std::size_t i = 0; i < val.size(); ++i)
124 writer << val[i] <<
" ";
131 template <
typename DeviceType,
typename AccessorType >
MeshT const & mesh() const
Returns the underlying mesh.
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
Exception which is thrown if a file cannot be opened.
Defines several filter functors for the device. A filter functor returns true if the supplied argumen...
Contains forward declarations and definition of small classes that must be defined at an early stage.
All the exceptions used within the viennashe::io namespace.
A logging facility providing fine-grained control over logging in ViennaSHE.
void write_cell_quantity_for_gnuplot(AccessorType const &quan, DeviceType const &device, std::string filename)
Writes a quantity (on vertices) per point to a text file suitable for gnuplot.
logger< true > info()
Used to log infos. The logging level is logINFO.
The main ViennaSHE namespace. All functionality resides inside this namespace.
Provides a number of fundamental constants. All constants in SI units.
A helper class to raise compile time errors.
Writes quantities to a file which can be processed by Gnuplot. Works for 1d, 2d and 3d only.
void operator()(DeviceType const &device, QuantitiyAccessorType const &quan, const std::string filename) const
Helper function for writing a quantity at all cells to a plain text file. Output can be processed by ...
void operator()(DeviceType const &device, CellFilterType const &cell_filter, QuantitiyAccessorType const &quan, const std::string filename) const
Helper function for writing a quantity at particular cells to a plain text file. Output can be proces...
A trivial filter, all objects are accepted.