00001 // This file is part of ff3d - http://www.freefem.org/ff3d 00002 // Copyright (C) 2001, 2002, 2003 Stéphane Del Pino 00003 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2, or (at your option) 00007 // any later version. 00008 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software Foundation, 00016 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 // $Id: PDESystem.hpp,v 1.6 2007/11/02 20:03:18 delpinux Exp $ 00019 00020 #ifndef PDE_SYSTEM_HPP 00021 #define PDE_SYSTEM_HPP 00022 00023 #include <vector> 00024 00025 #include <PDEProblem.hpp> 00026 #include <ReferenceCounting.hpp> 00027 00028 #include <Problem.hpp> 00029 00040 class PDESystem 00041 : public Problem 00042 { 00043 private: 00044 std::vector<ConstReferenceCounting<PDEProblem> > 00045 __pdeProblems; 00047 public: 00053 void add(ReferenceCounting<PDEProblem> pdeProblem) 00054 { 00055 __pdeProblems.push_back(pdeProblem); 00056 } 00057 00065 const PDEProblem& 00066 operator[](const size_t& i) const 00067 { 00068 ASSERT(i<__pdeProblems.size()); 00069 return *(__pdeProblems[i]); 00070 } 00071 00079 const ScalarFunctionBase& 00080 secondMember(const size_t& i) const 00081 { 00082 return *__pdeProblems[i]->pde().secondMember(); 00083 } 00084 00092 const BoundaryConditionSet& 00093 boundaryConditionSet(const size_t& i) const 00094 { 00095 return __pdeProblems[i]->boundaryConditionSet(); 00096 } 00097 00105 ReferenceCounting<Problem> 00106 operator*(const ConstReferenceCounting<ScalarFunctionBase>& c) const 00107 { 00108 PDESystem* newPDESystem = new PDESystem(*this); 00109 00110 for (size_t i=0; i<this->numberOfEquations(); ++i) { 00111 (*newPDESystem).__pdeProblems[i] = (*__pdeProblems[i]) * c; 00112 } 00113 return newPDESystem; 00114 } 00115 00121 size_t numberOfUnknown() const 00122 { 00123 return __pdeProblems.size(); 00124 } 00125 00131 size_t numberOfEquations() const 00132 { 00133 return __pdeProblems.size(); 00134 } 00135 00144 friend std::ostream& 00145 operator << (std::ostream& os, const PDESystem& pdeSystem) 00146 { 00147 for(size_t i=0; i<pdeSystem.numberOfEquations(); ++i) { 00148 os << *(pdeSystem.__pdeProblems[i]) << '\n'; 00149 } 00150 return os; 00151 } 00152 00157 PDESystem () 00158 : Problem(Problem::pde, 0) 00159 { 00160 ; 00161 } 00162 00168 PDESystem (const size_t& dimension) 00169 : Problem(Problem::pde, 0) 00170 { 00171 __pdeProblems.reserve(dimension); 00172 } 00173 00179 PDESystem(const PDESystem& p) 00180 : Problem(p), 00181 __pdeProblems(p.__pdeProblems) 00182 { 00183 } 00184 00189 ~PDESystem () 00190 { 00191 ; 00192 } 00193 }; 00194 00195 #endif // PDE_SYSTEM_HPP
1.5.6