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: FirstOrderOperator.hpp,v 1.6 2007/02/14 21:53:19 delpinux Exp $ 00019 00020 00021 #ifndef FIRST_ORDER_OPERATOR_HPP 00022 #define FIRST_ORDER_OPERATOR_HPP 00023 00024 #include <PDEOperator.hpp> 00025 00041 class FirstOrderOperator 00042 : public PDEOperator 00043 { 00044 public: 00045 typedef TinyVector<3,ConstReferenceCounting<ScalarFunctionBase> > Vector; 00046 00047 private: 00048 ConstReferenceCounting<FirstOrderOperator::Vector> 00049 __nu; 00051 public: 00057 std::string 00058 typeName() const 00059 { 00060 return std::string("FirstOrderOperator"); 00061 } 00062 00070 bool isSet(const int&i) const 00071 { 00072 return ((*__nu)[i] != 0); 00073 } 00074 00082 ConstReferenceCounting<ScalarFunctionBase> 00083 nu(const size_t& i) const 00084 { 00085 return (*__nu)[i]; 00086 } 00087 00093 ConstReferenceCounting<FirstOrderOperator::Vector> 00094 nu() const 00095 { 00096 return __nu; 00097 } 00098 00106 ConstReferenceCounting<PDEOperator> 00107 operator*(const ConstReferenceCounting<ScalarFunctionBase>& c) const 00108 { 00109 ReferenceCounting<FirstOrderOperator::Vector> nu2 00110 = new FirstOrderOperator::Vector; 00111 00112 for (size_t i=0; i<3; ++i) { 00113 if (this->isSet(i)) { 00114 ScalarFunctionBuilder functionBuilder; 00115 functionBuilder.setFunction((*__nu)[i]); 00116 functionBuilder.setBinaryOperation(BinaryOperation::product,c); 00117 (*nu2)[i] = functionBuilder.getBuiltFunction(); 00118 } 00119 } 00120 00121 return new FirstOrderOperator(nu2); 00122 } 00123 00129 ConstReferenceCounting<PDEOperator> 00130 operator-() const 00131 { 00132 ReferenceCounting<FirstOrderOperator::Vector> nu2 00133 = new FirstOrderOperator::Vector; 00134 00135 for (size_t i=0; i<3; ++i) { 00136 if (this->isSet(i)) { 00137 ScalarFunctionBuilder functionBuilder; 00138 functionBuilder.setFunction((*__nu)[i]); 00139 functionBuilder.setUnaryMinus(); 00140 (*nu2)[i] = functionBuilder.getBuiltFunction(); 00141 } 00142 } 00143 return new FirstOrderOperator(nu2); 00144 } 00145 00151 FirstOrderOperator(ReferenceCounting<FirstOrderOperator::Vector> nu) 00152 : PDEOperator(PDEOperator::firstorderop, 00153 3), 00154 __nu(nu) 00155 { 00156 ; 00157 } 00158 00164 FirstOrderOperator(const FirstOrderOperator& o) 00165 : PDEOperator(o), 00166 __nu(o.__nu) 00167 { 00168 ; 00169 } 00170 00175 ~FirstOrderOperator() 00176 { 00177 ; 00178 } 00179 }; 00180 00181 #endif // FIRST_ORDER_OPERATOR_HPP
1.5.6