problem.hpp
来自「FreeFem++可以生成高质量的有限元网格。可以用于流体力学」· HPP 代码 · 共 185 行
HPP
185 行
// -*- Mode : c++ -*-//// SUMMARY : // USAGE : // ORG : // AUTHOR : Frederic Hecht// E-MAIL : hecht@ann.jussieu.fr///* This file is part of Freefem++ Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */#ifndef PROBLEM_HPP_#define PROBLEM_HPP_extern Block *currentblock;template<class K> class Matrice_Creuse;template<class K> class MatriceCreuse;namespace Fem2D { template<class K> class SolveGCPrecon; template<class K> class SolveGMRESPrecon; template<class K> class SolveGMRESDiag; }template<class K> class SolveGCDiag; class Plot;class v_fes;typedef FEbase<double,v_fes> * pferbase ;typedef FEbaseArray<double,v_fes> * pferbasearray ;typedef pair<pferbase,int> pfer ;typedef pair<pferbasearray,int> pferarray ;typedef FEbase<Complex,v_fes> * pfecbase ;typedef FEbaseArray<Complex,v_fes> * pfecbasearray ;typedef pair<pfecbase,int> pfec ;typedef pair<pfecbasearray,int> pfecarray ;//typedef pair<pmesh *,int> pmesharray ;typedef LinearComb<MGauche,C_F0> Finconnue;typedef LinearComb<MDroit,C_F0> Ftest;typedef LinearComb<pair<MGauche,MDroit>,C_F0> Foperator;inline int intOp(const MGauche &i) {return i.second;}inline int intOp(const MDroit &i) {return i.second;}inline int intOp(pair<MGauche,MDroit> & p) {return Max(intOp(p.first),intOp(p.second));}inline void SetOp(KN_<bool> & d,const MGauche &i) { d[i.second% last_operatortype]=true;}inline void SetOp(KN_<bool> & d,const MDroit &i) { d[(int) i.second % last_operatortype]=true;}inline void SetOp(KN_<bool> & d,const pair<MGauche,MDroit> & p) {SetOp(d,p.first);SetOp(d,p.second);}inline unsigned int GetDiffOp(const MGauche &i, int& lastop) {int op=(i.second% last_operatortype); lastop=max(lastop,op) ; return 1<<op;}inline unsigned int GetDiffOp(const MDroit &i, int& lastop) {int op=(i.second% last_operatortype); lastop=max(lastop,op) ; return 1<<op;}inline unsigned int GetDiffOp(const pair<MGauche,MDroit> &p, int& lastop) { return GetDiffOp(p.first,lastop)|GetDiffOp(p.second,lastop);}typedef const Finconnue finconnue;typedef const Ftest ftest;typedef const Foperator foperator;Expression IsFebaseArray(Expression f);void SetArgsFormLinear(const ListOfId *lid,int ordre);inline ostream & operator<<(ostream & f,const TypeSolveMat & tm){ switch(tm.t) { case TypeSolveMat::NONESQUARE: f << "No Square (Sparse Morse)"; break; case TypeSolveMat::LU: f << "LU (Skyline)"; break; case TypeSolveMat::CROUT: f << "CROUT (Skyline)"; break; case TypeSolveMat::CHOLESKY: f << "CHOLESKY (Skyline)"; break; case TypeSolveMat::GC: f << "CG (Sparse Morse)"; break; case TypeSolveMat::GMRES: f << "GMRES (Sparse Morse)"; break; case TypeSolveMat::SparseSolver: f << "SparseSolver (Sparse Morse)"; break; default: f << "Unknown bug???"; } return f;}class C_args: public E_F0mps {public: typedef const C_args * Result; list<C_F0> largs; typedef list<C_F0> ::const_iterator const_iterator ; // il faut expendre C_args() :largs(){} C_args(C_F0 c) : largs() { largs.push_back(c);} C_args( const basicAC_F0 & args) :largs(){ int n=args.size(); for (int i=0;i< n;i++) { if (args[i].left() == atype<const C_args *>()) { const C_args * a = dynamic_cast<const C_args *>(args[i].LeftValue()); for (list<C_F0>::const_iterator i=a->largs.begin();i!=a->largs.end();i++) largs.push_back(*i); } else largs.push_back(args[i]); };} static ArrayOfaType typeargs() { return ArrayOfaType(true);} AnyType operator()(Stack ) const { return SetAny<const C_args *>(this);} operator aType () const { return atype<const C_args *>();} static E_F0 * f(const basicAC_F0 & args) { return new C_args(args);} bool IsLinearOperator() const; bool IsBilinearOperator() const;};class C_args_minus: public C_args {public: C_args_minus( const basicAC_F0 & args) { int n=args.size(); ffassert(n==2); if (args[0].left() == atype<const C_args *>()) { const C_args * a = dynamic_cast<const C_args *>(args[0].LeftValue()); ffassert(a); for (list<C_F0>::const_iterator i=a->largs.begin();i!=a->largs.end();i++) largs.push_back(*i); } else largs.push_back(args[0]); largs.push_back(C_F0(TheOperators,"-",args[1])); } static ArrayOfaType typeargs() { return ArrayOfaType(atype<const C_args *>(),true);} static E_F0 * f(const basicAC_F0 & args) { return new C_args_minus(args);} };bool isVF(const list<C_F0> & largs); template<typename F>class Minus_Form: public E_F0mps {public: typedef const F * Result; static ArrayOfaType typeargs() { return ArrayOfaType(atype<const F *>());} static E_F0 * f(const basicAC_F0 & args) { int n=args.size(); ffassert(n==1); aType tF=atype<Result>(); ffassert(args[0].left() == tF); Result f = dynamic_cast<Result>(args[0].LeftValue()); ffassert(f); // F mf = -*f; F * rf=new F(-*f); return rf; } operator aType () const { return atype<Result>();} };//template<class RR=double>class BC_set : public E_F0mps { public: bool complextype; typedef const BC_set* Result; vector<Expression> on; vector<pair<int,Expression> > bc; // n
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?