| [de061d] | 1 | /* | 
|---|
|  | 2 | *    vmg - a versatile multigrid solver | 
|---|
|  | 3 | *    Copyright (C) 2012 Institute for Numerical Simulation, University of Bonn | 
|---|
|  | 4 | * | 
|---|
|  | 5 | *  vmg is free software: you can redistribute it and/or modify | 
|---|
|  | 6 | *  it under the terms of the GNU General Public License as published by | 
|---|
|  | 7 | *  the Free Software Foundation, either version 3 of the License, or | 
|---|
|  | 8 | *  (at your option) any later version. | 
|---|
|  | 9 | * | 
|---|
|  | 10 | *  vmg is distributed in the hope that it will be useful, | 
|---|
|  | 11 | *  but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 12 | *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 13 | *  GNU General Public License for more details. | 
|---|
|  | 14 | * | 
|---|
|  | 15 | *  You should have received a copy of the GNU General Public License | 
|---|
|  | 16 | *  along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
|  | 17 | */ | 
|---|
|  | 18 |  | 
|---|
|  | 19 | /** | 
|---|
|  | 20 | * @file   discretization.hpp | 
|---|
|  | 21 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de> | 
|---|
|  | 22 | * @date   Tue Apr  5 20:32:09 2011 | 
|---|
|  | 23 | * | 
|---|
|  | 24 | * @brief  Base class for controlling the discretization of | 
|---|
|  | 25 | *         the continuous system of equations. The discretized | 
|---|
|  | 26 | *         operator must be specified as a stencil. | 
|---|
|  | 27 | * | 
|---|
|  | 28 | */ | 
|---|
|  | 29 |  | 
|---|
|  | 30 | #ifndef DISCRETIZATION_HPP_ | 
|---|
|  | 31 | #define DISCRETIZATION_HPP_ | 
|---|
|  | 32 |  | 
|---|
|  | 33 | #include <algorithm> | 
|---|
|  | 34 | #include <string> | 
|---|
|  | 35 |  | 
|---|
|  | 36 | #include "base/object.hpp" | 
|---|
|  | 37 | #include "base/stencil.hpp" | 
|---|
|  | 38 | #include "grid/grid.hpp" | 
|---|
|  | 39 | #include "grid/multigrid.hpp" | 
|---|
|  | 40 | #include "mg.hpp" | 
|---|
|  | 41 |  | 
|---|
|  | 42 | namespace VMG | 
|---|
|  | 43 | { | 
|---|
|  | 44 |  | 
|---|
|  | 45 | class Discretization : public Object | 
|---|
|  | 46 | { | 
|---|
|  | 47 | public: | 
|---|
|  | 48 | Discretization(bool register_ = true) : | 
|---|
|  | 49 | Object("DISCRETIZATION", register_), | 
|---|
|  | 50 | stencil(1.0), | 
|---|
|  | 51 | order(2) | 
|---|
|  | 52 | {} | 
|---|
|  | 53 |  | 
|---|
|  | 54 | Discretization(const int& order, bool register_ = true) : | 
|---|
|  | 55 | Object("DISCRETIZATION", register_), | 
|---|
|  | 56 | stencil(1.0), | 
|---|
|  | 57 | order(order) | 
|---|
|  | 58 | {} | 
|---|
|  | 59 |  | 
|---|
|  | 60 | Discretization(const Stencil& stencil_, const int& order, bool register_ = true) : | 
|---|
|  | 61 | Object("DISCRETIZATION", register_), | 
|---|
|  | 62 | stencil(stencil_), | 
|---|
|  | 63 | order(order) | 
|---|
|  | 64 | {} | 
|---|
|  | 65 |  | 
|---|
|  | 66 | Discretization(std::string id) : | 
|---|
|  | 67 | Object(id), | 
|---|
|  | 68 | stencil(1.0), | 
|---|
|  | 69 | order(2) | 
|---|
|  | 70 | {} | 
|---|
|  | 71 |  | 
|---|
|  | 72 | Discretization(std::string id, const int& order) : | 
|---|
|  | 73 | Object(id), | 
|---|
|  | 74 | stencil(1.0), | 
|---|
|  | 75 | order(order) | 
|---|
|  | 76 | {} | 
|---|
|  | 77 |  | 
|---|
|  | 78 | Discretization(std::string id, const Stencil& stencil_, const int& order) : | 
|---|
|  | 79 | Object(id), | 
|---|
|  | 80 | stencil(stencil_), | 
|---|
|  | 81 | order(order) | 
|---|
|  | 82 | {} | 
|---|
|  | 83 |  | 
|---|
|  | 84 | const Stencil& GetStencil() const {return stencil;} ///< Returns the stencil of the discretized operator. | 
|---|
|  | 85 |  | 
|---|
|  | 86 | virtual vmg_float OperatorPrefactor(const Grid& grid) const = 0; ///< Returns the prefactor of the operator. | 
|---|
|  | 87 |  | 
|---|
|  | 88 | virtual void ModifyRightHandSide() {} | 
|---|
|  | 89 |  | 
|---|
|  | 90 | /** | 
|---|
|  | 91 | * This function gets called whenever boundary points at inner boundaries are needed. | 
|---|
|  | 92 | * Inner boundaries occur when using adaptive grid refinement. | 
|---|
|  | 93 | * | 
|---|
|  | 94 | * @param sol_fine Solution vector / fine level | 
|---|
|  | 95 | * @param rhs_fine Right handside vector / fine level | 
|---|
|  | 96 | * @param sol_coarse Solution vector / coarse level | 
|---|
|  | 97 | */ | 
|---|
|  | 98 | void SetInnerBoundary(Grid& sol_fine, Grid& rhs_fine, Grid& sol_coarse) const | 
|---|
|  | 99 | { | 
|---|
|  | 100 | if (sol_fine.Global().BoundaryType() == LocallyRefined) | 
|---|
|  | 101 | SetInnerBoundaryCompute(sol_fine, rhs_fine, sol_coarse); | 
|---|
|  | 102 | } | 
|---|
|  | 103 |  | 
|---|
|  | 104 | private: | 
|---|
|  | 105 | virtual void SetInnerBoundaryCompute(Grid& sol_fine, Grid& rhs_fine, Grid& sol_coarse) const {} | 
|---|
|  | 106 |  | 
|---|
|  | 107 | protected: | 
|---|
|  | 108 | VMG::Stencil stencil; | 
|---|
|  | 109 | int order; | 
|---|
|  | 110 | }; | 
|---|
|  | 111 |  | 
|---|
|  | 112 | } | 
|---|
|  | 113 |  | 
|---|
|  | 114 | #endif /* DISCRETIZATION_HPP_ */ | 
|---|