root/src/io_paraview.cpp

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. write
  2. prefix

   1 /*! \file io_paraview.cpp
   2 
   3     \brief <Program Name>
   4 
   5      Revision history:
   6 
   7           Revised by Christian Power dd.mm.yyyy
   8           Originally written by Christian Power
   9                (power22c@gmail.com) 31. Januar 2016
  10 
  11      Implementation details for io_paraview.h
  12      Created by Christian Power on 31.01.2016
  13      Copyright (c) 2016 Christian Power. All rights reserved.
  14  */
  15 
  16 #include <sstream>
  17 #include <config.h>
  18 #include <dune/fem/io/file/dataoutput.hh>
  19 #include "io_paraview.h"
  20 #include "io_parameter.h"
  21 #include "grid.h"
  22 
  23 using namespace std;
  24 
  25 using Grid = Esfem::Grid::Grid_and_time::Grid;
  26 using FEfun = Esfem::Grid::Scal_FEfun::Dune_FEfun;
  27 using Dune_tuple = Dune::tuple<FEfun*, FEfun*>;
  28 using DataOutput = Dune::Fem::DataOutput<Grid, Dune_tuple>;
  29 
  30 class DataOutputParameters 
  31   : public Dune::Fem::LocalParameter<Dune::Fem::DataOutputParameters,
  32                                      DataOutputParameters> {
  33 public:
  34   explicit DataOutputParameters(const Esfem::Io::Parameter&, const int = 0);
  35   DataOutputParameters(const DataOutputParameters&);
  36   std::string prefix() const;
  37 private:
  38   std::string filename;
  39   int step;
  40 };
  41 
  42 // ----------------------------------------------------------------------
  43 // Implementation of io_paraview.h
  44 
  45 struct Esfem::Io::Paraview::Data{
  46   const Dune::Fem::TimeProviderBase& tp;
  47   Dune_tuple tuple;
  48   DataOutputParameters dop;
  49   DataOutput plotter;
  50   Data(const Parameter& p, const Grid::Grid_and_time& gt,
  51        Grid::Scal_FEfun& fef1, Grid::Scal_FEfun& fef2,
  52        const int refinement_label)
  53     : tp {gt.time_provider()},
  54       tuple {&static_cast<FEfun&>(fef1), &static_cast<FEfun&>(fef2)},
  55       dop {p, refinement_label}, plotter {gt.grid(), tuple, dop}
  56   {}
  57 };
  58 
  59 Esfem::Io::Paraview::Paraview(const Parameter& p , const Grid::Grid_and_time& gt,
  60                               Grid::Scal_FEfun& fef1, Grid::Scal_FEfun& fef2,
  61                               const int refinement_label)
  62 try : d_ptr {make_unique<Data>(p, gt, fef1, fef2, refinement_label)}
  63 {}
  64 catch(const std::exception&){
  65   std::throw_with_nested(std::logic_error
  66                          {"Error in constructor of Paraview."});
  67  }
  68  catch(...){
  69    throw std::logic_error{"Unkown error in constructor of Paraview."};
  70  }
  71 Esfem::Io::Paraview::~Paraview() = default;
  72 // {
  73 //   delete d_ptr;
  74 //   d_ptr = nullptr;
  75 // #ifdef DEBUG
  76 //   std::cerr << "~Paraview(): delete d_ptr.\n";
  77 // #endif
  78 // }
  79 void Esfem::Io::Paraview::write(){
  80   d_ptr -> plotter.write( d_ptr -> tp);
  81 }
  82 // ----------------------------------------------------------------------
  83 // Internal implementation
  84 
  85 DataOutputParameters::DataOutputParameters(const Esfem::Io::Parameter& p, const int i)
  86   : filename {p.paraview()}, step {i}
  87 {}
  88 DataOutputParameters::DataOutputParameters(const DataOutputParameters& other)
  89   : step {other.step}
  90 {}
  91 inline std::string DataOutputParameters::prefix() const {
  92   std::ostringstream s;
  93   s << filename << step << "-";
  94   return s.str();
  95 }
  96 
  97 /*! Log:
  98  */

/* [<][>][^][v][top][bottom][index][help] */