root/src/secOrd_op_solutionDriven.cpp

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

DEFINITIONS

This source file includes following definitions.
  1. solve
  2. brusselator_rhs

   1 /*! \file secOrd_op_solutionDriven.cpp
   2     \author Christian Power
   3     \date 17. March 2016
   4 
   5     \brief Implementing `Esfem::SecOrd_op::Solution_driven`
   6 
   7      Revision history
   8      --------------------------------------------------
   9 
  10           Revised by Christian Power March 2016
  11           Originally written by Christian Power
  12                (power22c@gmail.com) March 2016
  13 
  14      Idea
  15      --------------------------------------------------
  16 
  17      Implementation of `secOrd_op_solutionDriven.h`
  18 
  19          Created by Christian Power on 17.03.2016
  20          Copyright (c) 2016 Christian Power.  All rights reserved.
  21 
  22 */
  23 
  24 #include <config.h>
  25 #include <dune/fem/solver/cginverseoperator.hh>
  26 #include "secOrd_op_solutionDriven.h"
  27 #include "secOrd_op_solutionDriven_impl.h"
  28 #include "io_parameter.h"
  29 #include "grid.h"
  30 
  31 
  32 using Esfem::SecOrd_op::Solution_driven;
  33 using Esfem::Impl::MCF_op;
  34 //! Scalar valued finite element functions
  35 using FEfun = Esfem::Grid::Scal_FEfun::Dune_FEfun;
  36 //! Vector valued finite element functions
  37 using Vec_FEfun = Esfem::Grid::Vec_FEfun::Dune_FEfun;
  38 //! CG solver
  39 using Vec_cg_solver = Dune::Fem::CGInverseOperator<Vec_FEfun>;
  40 // Matrix for GMRes
  41 // using Linear_operator = Dune::Fem::ISTLLinearOperator<Vec_FEfun, Vec_FEfun>;
  42 // GMRes solver 
  43 // using GMRes = Dune::Fem::ISTLGMResOp<Vec_FEfun, Linear_operator>;
  44 // ----------------------------------------------------------------------
  45 // Implementation of Solution_driven::Data
  46 
  47 struct Solution_driven::Data{
  48   MCF_op mcf_op;
  49   Vec_cg_solver cg_solver;
  50   // Linear_operator matrix;
  51   // GMRes gmres_solver;
  52   Data(const Io::Parameter&, const Grid::Grid_and_time&,
  53        const Grid::Scal_FEfun& u_wrapper);
  54 };
  55 
  56 Solution_driven::Data::Data(const Io::Parameter& p, const Grid::Grid_and_time& g,
  57                             const Grid::Scal_FEfun& u_wrapper)
  58   :mcf_op {p, g, u_wrapper},
  59    cg_solver {mcf_op, p.eps(), p.eps()}
  60    // matrix {"matrix for operator", g.vec_fe_space(), g.vec_fe_space()},
  61    // gmres_solver {matrix, p.eps(), p.eps()}
  62 {}
  63 
  64 // ----------------------------------------------------------------------
  65 // Implementation of Solution_driven
  66 
  67 Solution_driven::Solution_driven(const Io::Parameter& p,
  68                                  const Grid::Grid_and_time& g,
  69                                  const Grid::Scal_FEfun& u)
  70   :d_ptr {std::make_unique<Data>(p, g, u)}
  71 {}
  72 
  73 Solution_driven::~Solution_driven() = default;
  74 
  75 void Solution_driven::
  76 solve(const Grid::Vec_FEfun& rhs, Grid::Vec_FEfun& lhs) const{
  77   const Vec_FEfun& vfef1 = rhs;
  78   Vec_FEfun& vfef2 = lhs;
  79   d_ptr -> cg_solver(vfef1, vfef2);
  80   // d_ptr -> mcf_op.jacobian(vfef1, d_ptr -> matrix);
  81   // d_ptr -> gmres_solver(vfef1, vfef2);
  82 }
  83 
  84 void Solution_driven::brusselator_rhs(const Grid::Vec_FEfun& rhs,
  85                                       Grid::Vec_FEfun& lhs) const{
  86   d_ptr -> mcf_op.brusselator_rhs(rhs, lhs);
  87 }
  88 
  89 void Solution_driven::operator()(const Grid::Vec_FEfun& rhs,
  90                                  Grid::Vec_FEfun& lhs) const{
  91   d_ptr -> mcf_op(rhs, lhs);
  92 }

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