root/include/grid.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. grid_dim
  2. world_dim
  3. size
  4. begin
  5. end
  6. begin
  7. end
  8. cbegin
  9. cend
  10. name
  11. size
  12. begin
  13. end
  14. begin
  15. end
  16. cbegin
  17. cend
  18. name

   1 /*! \file grid.h
   2     \brief Fundamental header providing grid, time provider and finite element functions
   3 
   4     Revision history
   5     --------------------------------------------------
   6 
   7           Revised by Christian Power June 2016
   8           Revised by Christian Power Mai 2016
   9           Revised by Christian Power March 2016
  10           Revised by Christian Power February 2016
  11           Originally written by Christian Power
  12                (power22c@gmail.com) January 2016
  13 
  14     Idea
  15     --------------------------------------------------
  16 
  17     Wrapper classes for the dune implementations.  This is very usefull
  18     since the construction of those classes is quite non trivial.
  19 
  20     \author Christian Power
  21     \date 7. June 2016
  22     \copyright Copyright (c) 2016 Christian Power.  All rights reserved.
  23  */
  24 
  25 #ifndef GRID_H
  26 #define GRID_H 
  27 
  28 #include <memory>
  29 #include <config.h>
  30 #include <dune/grid/geometrygrid.hh>    // geometry grid
  31 #include <dune/fem/gridpart/adaptiveleafgridpart.hh>    // grid part
  32 #include <dune/grid/geometrygrid/coordfunction.hh>
  33 #include <dune/fem/solver/timeprovider.hh>
  34 #include <dune/fem/space/common/functionspace.hh>
  35 #include <dune/fem/space/lagrange.hh>   // discrete function space
  36 #include <dune/fem/function/adaptivefunction.hh>        // discrete function
  37 #include <dune/fem/function/blockvectorfunction.hh>     // 2. discrete function
  38 
  39 #include "esfem_fwd.h"
  40 
  41 namespace Esfem{
  42   namespace Grid{
  43     inline constexpr int grid_dim(){
  44       return Dune::GridSelector::dimgrid;
  45     }
  46     inline constexpr int world_dim(){
  47       return Dune::GridSelector::dimworld;
  48     }
  49 
  50     static_assert( grid_dim() == 2, "Bad grid dimension.");
  51     static_assert( world_dim() == 3, "Bad world dimension.");
  52     
  53     class Deformation
  54       : public Dune::
  55                AnalyticalCoordFunction<double, world_dim(), world_dim(), Deformation>
  56     {
  57     public:
  58       using Base = Dune::AnalyticalCoordFunction
  59         <double, world_dim(), world_dim(), Deformation>;
  60       using Domain = Base::DomainVector;
  61       using Range = Base::RangeVector;
  62 
  63       //! Analytic formula
  64       Deformation();
  65       //! Hash map for grid evolution
  66       explicit Deformation(const std::string& fname);
  67       //! Pointer to implementation requires this.
  68       ~Deformation();
  69 
  70       //! Explicit mapping
  71       void evaluate(const Domain&, Range&) const;
  72       //! Finish cyclic dependency
  73       void set_timeProvider(const Dune::Fem::TimeProviderBase&);
  74       //! Update hash map
  75       Deformation& operator=(const Vec_FEfun&);
  76     private:
  77       struct Data;
  78       //! Pointer to implementation
  79       std::unique_ptr<Data> d_ptr;
  80     };
  81     //! FE grid, FE space, function space
  82     class Grid_and_time{
  83     public:
  84       //! Important for dune 
  85       using Host_grid = Dune::GridSelector::GridType;
  86       //! \copybrief Host_grid
  87       using Grid = Dune::GeometryGrid<Host_grid, Deformation>;
  88       //! ALU-Grid
  89       using Grid_part
  90       = Dune::Fem::AdaptiveLeafGridPart<Grid, Dune::InteriorBorder_Partition>;
  91       //! \f$f\colon \R^3\to \R\f$
  92       using Function_space = Dune::Fem::
  93         FunctionSpace<double, double, Grid::dimensionworld, 1>;
  94       //! Scalar valued finite element space
  95       using FE_space = Dune::Fem::
  96         LagrangeDiscreteFunctionSpace<Function_space, Grid_part, POLORDER>;
  97       //! \f$ f\colon \R^3\to \R^3\f$
  98       using Vec_Function_space = Dune::Fem::
  99         FunctionSpace<double, double, Grid::dimensionworld, Grid::dimensionworld>;
 100       //! Vector valued finite element space
 101       using Vec_FE_space = Dune::Fem::
 102         LagrangeDiscreteFunctionSpace<Vec_Function_space, Grid_part, POLORDER>;
 103 
 104       //! Construct first grid
 105       explicit Grid_and_time(const Io::Parameter&);
 106       //! Read from an dgf
 107       explicit Grid_and_time(const Io::Parameter&, const std::string& dgf_file,
 108                              const double t0);
 109       //! Pointer to implementation requires this.
 110       ~Grid_and_time();
 111 
 112       //! ++time
 113       void next_timeStep(const double);
 114       //! Update hash grid
 115       void new_nodes(const Vec_FEfun&);
 116 
 117       //! Get time provider
 118       Dune::Fem::TimeProviderBase& time_provider();
 119       //! Get time provider
 120       const Dune::Fem::TimeProviderBase& time_provider() const;
 121 
 122       //! Grid for finite element functions
 123       Grid& grid() const;
 124       //! I believe for the norm
 125       Grid_part& grid_part() const;
 126       //! Finite element space
 127       /*! Used for dune operator */
 128       FE_space& fe_space() const;
 129       //! Vector valued finite element space
 130       /*! Used for dune operator */
 131       Vec_FE_space& vec_fe_space() const;
 132     private:
 133       struct Data;
 134       //! Pointer to implementation
 135       std::unique_ptr<Data> d_ptr;
 136     };
 137     class Scal_FEfun{
 138     public:
 139       // using Dune_FEfun = Dune::Fem::AdaptiveDiscreteFunction<Grid_and_time::FE_space>;
 140       using Dune_FEfun 
 141       = Dune::Fem::ISTLBlockVectorDiscreteFunction<Grid_and_time::FE_space>;
 142       
 143       explicit Scal_FEfun(const std::string& name, const Grid_and_time& gt);
 144       explicit Scal_FEfun(const Scal_FEfun&, const Grid_and_time&);
 145       Scal_FEfun& operator=(const Scal_FEfun&);
 146       
 147       operator Dune_FEfun&(){ return fun; }
 148       operator const Dune_FEfun&() const { return fun; }
 149 
 150       auto size() const { return fun.size(); }
 151       auto begin() { return fun.dbegin(); }
 152       auto end() { return fun.dend(); }
 153       auto begin() const { return fun.dbegin(); }
 154       auto end() const { return fun.dend(); }
 155       auto cbegin() const { return fun.dbegin(); }
 156       auto cend() const { return fun.dend(); }
 157       auto name() const { return fun.name(); }
 158 
 159       Scal_FEfun& operator+=(const double d);
 160       Scal_FEfun& operator*=(const double d);
 161     private:
 162       Dune_FEfun fun;
 163     };
 164     class Vec_FEfun{
 165     public:
 166       using Dune_FEfun
 167       = Dune::Fem::AdaptiveDiscreteFunction<Grid_and_time::Vec_FE_space>;
 168       // using Dune_FEfun 
 169       // = Dune::Fem::ISTLBlockVectorDiscreteFunction<Grid_and_time::Vec_FE_space>;
 170       
 171       explicit Vec_FEfun(const std::string& name, const Grid_and_time&);
 172       explicit Vec_FEfun(const Vec_FEfun&, const Grid_and_time&);
 173       Vec_FEfun& operator=(const Vec_FEfun&);
 174 
 175       operator Dune_FEfun&(){ return fun; }
 176       operator const Dune_FEfun&() const { return fun; }
 177 
 178       auto size() const { return fun.size(); }
 179       auto begin() { return fun.dbegin(); }
 180       auto end() { return fun.dend(); }
 181       auto begin() const { return fun.dbegin(); }
 182       auto end() const { return fun.dend(); }
 183       auto cbegin() const { return fun.dbegin(); }
 184       auto cend() const { return fun.dend(); }
 185       auto name() const { return fun.name(); }
 186 
 187       Vec_FEfun& operator+=(const double);
 188       Vec_FEfun& operator*=(const double);
 189     private:
 190       Dune_FEfun fun;
 191     };
 192   }     // namespace Grid
 193 }       // namespace Esfem
 194 
 195 #endif // GRID_H

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