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: ScalarFunctionLinearBasis.hpp,v 1.3 2006/10/28 12:26:54 delpinux Exp $ 00019 00020 #ifndef SCALAR_FUNCTION_LINEAR_BASIS_HPP 00021 #define SCALAR_FUNCTION_LINEAR_BASIS_HPP 00022 00023 #include <ScalarFunctionBase.hpp> 00024 00033 class ScalarFunctionLinearBasis 00034 : public ScalarFunctionBase 00035 { 00036 public: 00037 enum BasisType { 00038 x, 00039 y, 00040 z 00041 }; 00042 00043 private: 00044 const BasisType __basisType; 00053 std::ostream& __put(std::ostream& os) const 00054 { 00055 switch (__basisType) { 00056 case ScalarFunctionLinearBasis::x: { 00057 os << 'x'; 00058 break; 00059 } 00060 case ScalarFunctionLinearBasis::y: { 00061 os << 'y'; 00062 break; 00063 } 00064 case ScalarFunctionLinearBasis::z: { 00065 os << 'z'; 00066 break; 00067 } 00068 } 00069 return os; 00070 } 00071 00072 public: 00080 real_t operator()(const TinyVector<3, real_t>& X) const 00081 { 00082 switch (__basisType) { 00083 case ScalarFunctionLinearBasis::x: { 00084 return X[0]; 00085 } 00086 case ScalarFunctionLinearBasis::y: { 00087 return X[1]; 00088 } 00089 case ScalarFunctionLinearBasis::z: { 00090 return X[2]; 00091 } 00092 } 00093 // never reached 00094 return 0; 00095 } 00096 00102 bool canBeSimplified() const 00103 { 00104 return false; 00105 } 00106 00112 ScalarFunctionLinearBasis(const BasisType& basisType) 00113 : ScalarFunctionBase(ScalarFunctionBase::linearBasis), 00114 __basisType(basisType) 00115 { 00116 ; 00117 } 00118 00124 ScalarFunctionLinearBasis(const ScalarFunctionLinearBasis& f) 00125 : ScalarFunctionBase(f), 00126 __basisType(f.__basisType) 00127 { 00128 ; 00129 } 00130 00135 ~ScalarFunctionLinearBasis() 00136 { 00137 ; 00138 } 00139 }; 00140 00141 #endif // SCALAR_FUNCTION_LINEAR_BASIS_HPP
1.5.6