$treeview $search $mathjax
|
Palabos
Version 1.1
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /* This file is part of the Palabos library. 00002 * 00003 * Copyright (C) 2011 FlowKit Sarl 00004 * Avenue de Chailly 23 00005 * 1012 Lausanne, Switzerland 00006 * E-mail contact: contact@flowkit.com 00007 * 00008 * The most recent release of Palabos can be downloaded at 00009 * <http://www.palabos.org/> 00010 * 00011 * The library Palabos is free software: you can redistribute it and/or 00012 * modify it under the terms of the GNU Affero General Public License as 00013 * published by the Free Software Foundation, either version 3 of the 00014 * License, or (at your option) any later version. 00015 * 00016 * The library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Affero General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Affero General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00029 #ifndef GENERALIZED_BOUNDARY_DYNAMICS_SOLVERS_H 00030 #define GENERALIZED_BOUNDARY_DYNAMICS_SOLVERS_H 00031 00032 #include "core/globalDefs.h" 00033 #include "core/cell.h" 00034 #include <Eigen3/Core> 00035 00036 namespace plb { 00037 00038 // ================ GeneralizedBoundarySolver base class =================== // 00039 template<typename T, template<typename U> class Descriptor> 00040 class GeneralizedBoundarySolver 00041 { 00042 public: 00043 GeneralizedBoundarySolver(const std::vector<plint> &mInd_, const std::vector<plint> &kInd_); 00044 virtual ~GeneralizedBoundarySolver() {}; 00045 00046 virtual void apply(Cell<T,Descriptor> &cell, 00047 const Dynamics<T,Descriptor> &dyn, 00048 bool replaceAll = true ) = 0; 00049 protected: 00050 // missing idexes (mInd) and known indexes (kInnd) 00051 std::vector<plint> mInd, kInd; 00052 }; 00053 00054 // ============== GeneralizedLinearBoundarySolver base class =============== // 00055 template<typename T, template<typename U> class Descriptor> 00056 class GeneralizedLinearBoundarySolver : public GeneralizedBoundarySolver<T,Descriptor> 00057 { 00058 public: 00059 GeneralizedLinearBoundarySolver(const std::vector<plint> &mInd_, 00060 const std::vector<plint> &kInd_); 00061 00062 virtual void apply(Cell<T,Descriptor> &cell, 00063 const Dynamics<T,Descriptor> &dyn, 00064 bool replaceAll = true ); 00065 00066 virtual void createLinearSystem(Cell<T,Descriptor> &cell, Eigen::MatrixXd &A, Eigen::VectorXd &b) = 0; 00067 virtual void regularizePopulations(Cell<T,Descriptor> &cell, const Eigen::VectorXd &x, 00068 const Dynamics<T,Descriptor> &dyn, bool replaceAll ) = 0; 00069 00070 void solveLinearSytem(Cell<T,Descriptor> &cell, Eigen::MatrixXd &A, Eigen::VectorXd &b, Eigen::VectorXd &x); 00071 }; 00072 00073 // ============ GeneralizedNonLinearBoundarySolver base class ============== // 00074 template<typename T, template<typename U> class Descriptor> 00075 class GeneralizedNonLinearBoundarySolver : public GeneralizedBoundarySolver<T,Descriptor> 00076 { 00077 public: 00078 GeneralizedNonLinearBoundarySolver(const std::vector<plint> &mInd_, const std::vector<plint> &kInd_, 00079 T epsilon_); 00080 00081 virtual void apply(Cell<T,Descriptor> &cell, 00082 const Dynamics<T,Descriptor> &dyn, 00083 bool replaceAll = true ); 00084 00085 bool converge(const Eigen::VectorXd &x, const Eigen::VectorXd &dx); 00086 00087 virtual void fromXtoMacro(const Eigen::VectorXd &x) = 0; 00088 virtual void fromMacroToX(Eigen::VectorXd &x) = 0; 00089 00090 virtual void iniSystem(Eigen::MatrixXd &Jac, Eigen::VectorXd &f, 00091 Eigen::VectorXd &x, Eigen::VectorXd &dx) = 0; 00092 virtual void createNonLinearSystem(const Cell<T,Descriptor> &cell, Eigen::MatrixXd &Jac, Eigen::VectorXd &f) = 0; 00093 virtual void iterateNonLinearSystem(const Eigen::MatrixXd &Jac, const Eigen::VectorXd &f, 00094 Eigen::VectorXd &x, Eigen::VectorXd &dx); 00095 virtual void regularizePopulations(Cell<T,Descriptor> &cell, const Eigen::VectorXd &x, 00096 const Dynamics<T,Descriptor> &dyn, bool replaceAll ) = 0; 00097 private : 00098 T epsilon; 00099 protected : 00100 std::vector<T> macro; 00101 }; 00102 00103 // ========================================================================= // 00104 // ============ Different kind of Linear BCs for incompressible fluids ===== // 00105 // ========================================================================= // 00106 00107 // ========================= Dirichlet Velocity BC ========================= // 00108 // ======================= without mass conservation ======================= // 00109 template<typename T, template<typename U> class Descriptor> 00110 class DirichletVelocityBoundarySolver : public GeneralizedLinearBoundarySolver<T,Descriptor> 00111 { 00112 public: 00113 DirichletVelocityBoundarySolver(const std::vector<plint> &mInd_, const std::vector<plint> &kInd_, 00114 const Array<T,Descriptor<T>::d> &u_); 00115 00116 virtual void createLinearSystem(Cell<T,Descriptor> &cell, Eigen::MatrixXd &A, Eigen::VectorXd &b); 00117 virtual void regularizePopulations(Cell<T,Descriptor> &cell, const Eigen::VectorXd &x, 00118 const Dynamics<T,Descriptor> &dyn, bool replaceAll ); 00119 private : 00120 Array<T,Descriptor<T>::d> u; 00121 T uSqr; 00122 plint sysX, sysY; 00123 }; 00124 00125 // ========================= Dirichlet Velocity BC ========================= // 00126 // ======================= with mass conservation ======================= // 00127 template<typename T, template<typename U> class Descriptor> 00128 class DirichletMassConservingVelocityBoundarySolver : public GeneralizedLinearBoundarySolver<T,Descriptor> 00129 { 00130 public: 00131 DirichletMassConservingVelocityBoundarySolver(const std::vector<plint> &mInd_, 00132 const std::vector<plint> &kInd_, 00133 const std::vector<plint> &inGoingIndices_, 00134 const Array<T,Descriptor<T>::d> &u_ ); 00135 00136 virtual void createLinearSystem(Cell<T,Descriptor> &cell, Eigen::MatrixXd &A, Eigen::VectorXd &b); 00137 virtual void regularizePopulations(Cell<T,Descriptor> &cell, const Eigen::VectorXd &x, 00138 const Dynamics<T,Descriptor> &dyn, bool replaceAll ); 00139 private : 00140 std::vector<plint> inGoingInd; 00141 Array<T,Descriptor<T>::d> u; 00142 T uSqr; 00143 plint sysX, sysY; 00144 }; 00145 00146 // ========================================================================= // 00147 // ======== Different kind of Non-Linear BCs for incompressible fluids ===== // 00148 // ========================================================================= // 00149 00150 // ========================= Dirichlet Density BC ========================== // 00151 // ======================= without mass conservation ======================= // 00152 template<typename T, template<typename U> class Descriptor, int dir> 00153 class DirichletDensityBoundarySolver : public GeneralizedNonLinearBoundarySolver<T,Descriptor> 00154 { 00155 public: 00156 DirichletDensityBoundarySolver(const std::vector<plint> &mInd_, const std::vector<plint> &kInd_, 00157 T &rho_, Array<T,Descriptor<T>::d> &u_, 00158 Array<T,SymmetricTensor<T,Descriptor>::n> &PiNeq_, 00159 T epsilon_); 00160 00161 virtual void fromXtoMacro(const Eigen::VectorXd &x); 00162 virtual void fromMacroToX(Eigen::VectorXd &x); 00163 virtual void iniSystem(Eigen::MatrixXd &Jac, Eigen::VectorXd &f, 00164 Eigen::VectorXd &x, Eigen::VectorXd &dx); 00165 virtual void createNonLinearSystem(const Cell<T,Descriptor> &cell, Eigen::MatrixXd &Jac, Eigen::VectorXd &f); 00166 virtual void regularizePopulations(Cell<T,Descriptor> &cell, const Eigen::VectorXd &x, 00167 const Dynamics<T,Descriptor> &dyn, bool replaceAll ); 00168 private : 00169 plint sysX, sysY; 00170 }; 00171 00172 00173 00174 } // namespace plb 00175 00176 #endif // GENERALIZED_BOUNDARY_DYNAMICS_H
1.6.3
1.6.3