root/src/grid_GridAndTime.cpp

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

DEFINITIONS

This source file includes following definitions.
  1. Data
  2. Grid_and_time
  3. next_timeStep
  4. new_nodes
  5. time_provider
  6. time_provider
  7. grid
  8. grid_part
  9. fe_space
  10. vec_fe_space
  11. loadBalance_and_deref

   1 /*! \file grid_GridAndTime.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) Januar 2016
  10 
  11      Implementation details for grid_GridAndTime.h
  12      Created by Christian Power on 27.01.2016
  13      Copyright (c) 2016 Christian Power. All rights reserved.
  14  */
  15 
  16 #include <iostream>
  17 #include <stdexcept>
  18 #include <config.h>
  19 #include <dune/fem/solver/timeprovider.hh>
  20 #include <dune/common/exceptions.hh>
  21 #include "grid.h"
  22 #include "grid_GridAndTime_impl.h"
  23 #include "io_parameter.h"
  24 #include "esfem_error.h"
  25 
  26 using namespace std;
  27 
  28 using Esfem::Grid_error;
  29 using Deformation = Esfem::Grid::Deformation;
  30 using Host_grid = Esfem::Grid::Grid_and_time::Host_grid;
  31 using HGrid_ptr = Dune::GridPtr<Host_grid>;
  32 using Grid = Esfem::Grid::Grid_and_time::Grid;
  33 using Grid_part = Esfem::Grid::Grid_and_time::Grid_part;
  34 using Time_provider = Dune::Fem::GridTimeProvider<Grid>;
  35 using FE_space = Esfem::Grid::Grid_and_time::FE_space;
  36 using Vec_FE_space = Esfem::Grid::Grid_and_time::Vec_FE_space;
  37 
  38 Host_grid& loadBalance_and_deref(HGrid_ptr&);
  39 
  40 // ----------------------------------------------------------------------
  41 // Implemenation Esfem::Grid::Grid_and_time::Data
  42 
  43 struct Esfem::Grid::Grid_and_time::Data{
  44   // Impl::Evolving_grid eg;
  45   Deformation d;
  46   HGrid_ptr hg_ptr;
  47   Grid g;
  48   Grid_part gp;
  49   Time_provider tp;
  50   FE_space fes;
  51   Vec_FE_space vfes;
  52   Data(const Io::Parameter&);
  53   Data(const Io::Parameter&, const std::string& dgf_file,
  54        const double t0);
  55 };
  56 
  57 Esfem::Grid::Grid_and_time::Data::Data(const Io::Parameter& p)
  58   :// d {new Impl::Evolving_grid {eg}},
  59    d {p.grid()}, hg_ptr {p.grid()},
  60    g {loadBalance_and_deref(hg_ptr), d},
  61    gp {g}, tp {p.start_time(), g},
  62    fes {gp}, vfes {gp} {
  63   d.set_timeProvider(tp);
  64   tp.init(p.global_timeStep());
  65 }
  66 
  67 Esfem::Grid::Grid_and_time::Data::
  68 Data(const Io::Parameter& p, const std::string& dgf_file,
  69      const double t0)
  70   :d {}, hg_ptr {dgf_file}, g {loadBalance_and_deref(hg_ptr), d},
  71    gp {g}, tp {t0, g}, fes {gp}, vfes {gp} {
  72   d.set_timeProvider(tp);
  73   tp.init(p.global_timeStep());
  74 }
  75 
  76 // ----------------------------------------------------------------------
  77 // Implemenation Esfem::Grid::Grid_and_time
  78 
  79 
  80 Esfem::Grid::Grid_and_time::Grid_and_time(const Io::Parameter& p)
  81 try :d_ptr {std::make_unique<Data>(p)}
  82 {}
  83 catch(const Dune::Exception& e){
  84   ostringstream oss;
  85   oss << "Constructor\n"
  86       << "Dune error: " << e << std::endl;
  87   throw Grid_error {oss.str()};
  88  }
  89  catch(...){
  90    throw_with_nested(Grid_error {"Constructor"});
  91  }
  92 
  93 Esfem::Grid::Grid_and_time::
  94 Grid_and_time(const Io::Parameter& p, const std::string& dgf_file, const double t0)
  95 try : d_ptr {std::make_unique<Data>(p, dgf_file, t0)}
  96 {}
  97 catch(const std::exception&){
  98   throw_with_nested(Grid_error {"Constructor"});
  99  }
 100  catch(const Dune::Exception& e){
 101    ostringstream oss;
 102    oss << "Constructor\n"
 103        << "Dune error: " << e << std::endl;
 104    throw Grid_error {oss.str()};
 105  }
 106  catch(...){
 107    throw Grid_error {"Constructor, unknown error"};
 108  }
 109 
 110 Esfem::Grid::Grid_and_time::~Grid_and_time() = default;
 111 
 112 void Esfem::Grid::Grid_and_time::next_timeStep(const double dT){
 113   d_ptr -> tp.next(dT);
 114 }
 115 void Esfem::Grid::Grid_and_time::new_nodes(const Vec_FEfun& rhs){
 116   d_ptr->d = rhs;
 117 }
 118 Dune::Fem::TimeProviderBase& Esfem::Grid::Grid_and_time::time_provider(){
 119   return d_ptr -> tp;
 120 }
 121 const Dune::Fem::TimeProviderBase& Esfem::Grid::Grid_and_time::time_provider() const{
 122   return d_ptr -> tp;
 123 }
 124 Grid& Esfem::Grid::Grid_and_time::grid() const{
 125   return d_ptr -> g;
 126 }
 127 Grid_part& Esfem::Grid::Grid_and_time::grid_part() const{
 128   return d_ptr -> gp;
 129 }
 130 FE_space& Esfem::Grid::Grid_and_time::fe_space() const{
 131   return d_ptr -> fes;
 132 }
 133 Vec_FE_space& Esfem::Grid::Grid_and_time::vec_fe_space() const{
 134   return d_ptr -> vfes;
 135 }
 136 
 137 // ----------------------------------------------------------------------
 138 // Internal implementation
 139 
 140 Host_grid& loadBalance_and_deref(HGrid_ptr& hg_ptr){
 141   hg_ptr -> loadBalance();
 142   return *hg_ptr;
 143 }
 144 
 145 /*! Log:
 146  */

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