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: VectorialPDEOperator.hpp,v 1.5 2007/05/20 23:02:46 delpinux Exp $ 00019 00020 // This class describes a vectorial PDE operator. 00021 // It means a PDE operator that can be applied to a vectorial function. 00022 00023 00024 #ifndef VECTORIAL_PDE_OPERATOR_HPP 00025 #define VECTORIAL_PDE_OPERATOR_HPP 00026 00027 #include <vector> 00028 #include <PDEOperatorSum.hpp> 00029 00038 class VectorialPDEOperator 00039 { 00040 private: 00041 std::vector<ReferenceCounting<PDEOperatorSum> > 00042 __vectorPDEOperator; 00045 public: 00052 size_t size() const 00053 { 00054 return __vectorPDEOperator.size(); 00055 } 00056 00064 ReferenceCounting<PDEOperatorSum> 00065 operator[](const size_t& i) 00066 { 00067 ASSERT(i<__vectorPDEOperator.size()); 00068 return __vectorPDEOperator[i]; 00069 } 00070 00078 ConstReferenceCounting<PDEOperatorSum> 00079 operator[](const size_t& i) const 00080 { 00081 ASSERT(i<__vectorPDEOperator.size()); 00082 return __vectorPDEOperator[i]; 00083 } 00084 00093 friend std::ostream& 00094 operator << (std::ostream& os, const VectorialPDEOperator& vectorialPDEOperator) 00095 { 00096 if (vectorialPDEOperator.__vectorPDEOperator.size() > 0) { 00097 for(size_t i=0; i<vectorialPDEOperator.__vectorPDEOperator.size(); ++i) { 00098 if (i!=0) 00099 os << " + "; 00100 os << '(' << *(vectorialPDEOperator.__vectorPDEOperator[i]) << ")(u_" << i << ')'; 00101 } 00102 } else { 00103 os << 0; 00104 } 00105 return os; 00106 } 00107 00116 ConstReferenceCounting<VectorialPDEOperator> 00117 operator*(const ConstReferenceCounting<ScalarFunctionBase>& c) const 00118 { 00119 VectorialPDEOperator* newVectorialPDEOperator = new VectorialPDEOperator(this->size()); 00120 00121 for (size_t i=0; i<__vectorPDEOperator.size(); ++i) 00122 (*newVectorialPDEOperator).__vectorPDEOperator[i] = (*__vectorPDEOperator[i]) * c; 00123 00124 return newVectorialPDEOperator; 00125 } 00126 00134 const VectorialPDEOperator& 00135 operator+=(const VectorialPDEOperator& vectorialPDEOperator) 00136 { 00137 ASSERT(__vectorPDEOperator.size() == vectorialPDEOperator.__vectorPDEOperator.size()); 00138 00139 for (size_t i=0; i<__vectorPDEOperator.size(); ++i) 00140 for (size_t j=0; j< vectorialPDEOperator.__vectorPDEOperator[i]->numberOfOperators(); ++j) 00141 (*__vectorPDEOperator[i]).add((*(vectorialPDEOperator.__vectorPDEOperator[i]))[j]); 00142 00143 return *this; 00144 } 00145 00153 const VectorialPDEOperator& 00154 operator-=(const VectorialPDEOperator& vectorialPDEOperator) 00155 { 00156 ASSERT(__vectorPDEOperator.size() == vectorialPDEOperator.__vectorPDEOperator.size()); 00157 00158 for (size_t i=0; i<__vectorPDEOperator.size(); ++i) 00159 for (size_t j=0; j<vectorialPDEOperator.__vectorPDEOperator[i]->numberOfOperators(); ++j) 00160 (*__vectorPDEOperator[i]).add((*vectorialPDEOperator.__vectorPDEOperator[i])[j]); 00161 00162 return *this; 00163 } 00164 00170 VectorialPDEOperator(const size_t& dimension) 00171 : __vectorPDEOperator(dimension) 00172 { 00173 for(size_t i=0; i<dimension; ++i) 00174 __vectorPDEOperator[i] = new PDEOperatorSum(); 00175 } 00176 00181 VectorialPDEOperator() 00182 { 00183 ; 00184 } 00185 00190 ~VectorialPDEOperator() 00191 { 00192 ; 00193 } 00194 }; 00195 00196 #endif // VECTORIAL_PDE_OPERATOR_HPP
1.5.6