namespace Algorithms
{
+ /**
+ * An output operator writing a separate file in each step and
+ * writing the vectors as finite element functions with respect to a
+ * given DoFHandler.
+ */
template <class VECTOR, int dim, int spacedim=dim>
class DoFOutputOperator : public OutputOperator<VECTOR>
{
public:
+ /*
+ * Constructor. The <tt>filename</tt> is the common base name of all
+ * files and the argument <tt>digits</tt> should be the number of digits
+ * of the highest number in the sequence. File names by default
+ * have the form "outputNN" with NNN the number set by the last
+ * step command. Numbers with less digits are filled with zeros
+ * from the left.
+ */
+ DoFOutputOperator (const std::string filename_base = std::string("output"),
+ const unsigned int digits = 3);
+
void initialize (DoFHandler<dim, spacedim> &dof_handler);
virtual OutputOperator<VECTOR> &
- operator<<(const NamedData<VECTOR *> &vectors);
+ operator << (const AnyData &vectors);
private:
SmartPointer<DoFHandler<dim, spacedim>,
DoFOutputOperator<VECTOR, dim, spacedim> > dof;
+
+ const std::string filename_base;
+ const unsigned int digits;
};
template <class VECTOR, int dim, int spacedim>
namespace Algorithms
{
+ template <class VECTOR, int dim, int spacedim>
+ DoFOutputOperator<VECTOR, dim, spacedim>::DoFOutputOperator (
+ const std::string filename_base,
+ const unsigned int digits)
+ :
+ filename_base(filename_base),
+ digits(digits)
+ {}
+
+
template <class VECTOR, int dim, int spacedim>
OutputOperator<VECTOR> &
DoFOutputOperator<VECTOR, dim, spacedim>::operator<<(
- const NamedData<VECTOR *> &vectors)
+ const AnyData &data)
{
Assert ((dof!=0), ExcNotInitialized());
DataOut<dim> out;
+ out.set_default_format(DataOutBase::gnuplot);
out.attach_dof_handler (*dof);
- out.add_data_vector (*vectors(vectors.find("solution")), "solution");
- out.add_data_vector (*vectors(vectors.find("update")), "update");
- out.add_data_vector (*vectors(vectors.find("residual")), "residual");
+ for (unsigned int i=0;i<data.size();++i)
+ {
+ const VECTOR* p = data.try_read_ptr<VECTOR>(i);
+ if (p!=0)
+ {
+ out.add_data_vector (*p, data.name(i));
+ }
+ }
std::ostringstream streamOut;
- streamOut << "Newton_" << std::setw(3) << std::setfill('0') << this->step;
+ streamOut << filename_base
+ << std::setw(digits) << std::setfill('0') << this->step
+ << out.default_suffix();
std::ofstream out_filename (streamOut.str().c_str());
out.build_patches (2);
out.write_gnuplot (out_filename);