00001 // This file is part of ff3d - http://www.freefem.org/ff3d 00002 // Copyright (C) 2003 Pascal Havé 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: FEMFunctionBase.hpp,v 1.14 2008/01/03 01:05:17 delpinux Exp $ 00019 00020 #ifndef FEM_FUNCTION_BASE_HPP 00021 #define FEM_FUNCTION_BASE_HPP 00022 00023 #include <ScalarFunctionBase.hpp> 00024 00025 #include <ScalarDegreeOfFreedomPositionsSet.hpp> 00026 #include <DegreeOfFreedomSetManager.hpp> 00027 00028 #include <ScalarDiscretizationTypeFEM.hpp> 00029 00030 #include <Vector.hpp> 00031 00032 class Mesh; 00033 00041 class FEMFunctionBase 00042 : public ScalarFunctionBase 00043 { 00044 protected: 00045 ConstReferenceCounting<Mesh> 00046 __baseMesh; 00049 ConstReferenceCounting<ScalarDegreeOfFreedomPositionsSet> 00050 __dofPositionsSet; 00052 Vector<real_t> __values; 00054 const ScalarDiscretizationTypeFEM 00055 __discretizationType; 00064 std::ostream& __put(std::ostream& os) const 00065 { 00066 os << "{fem-" << ScalarDiscretizationTypeBase::name(__discretizationType) << '}'; 00067 return os; 00068 } 00069 00079 real_t __outsideValue; 00080 00081 public: 00087 void setOutsideValue(const real_t& value) 00088 { 00089 __outsideValue = value; 00090 } 00091 00097 const real_t& outsideValue() const 00098 { 00099 return __outsideValue; 00100 } 00101 00107 bool canBeSimplified() const 00108 { 00109 return true; 00110 } 00111 00119 bool hasSameType(const FEMFunctionBase& f) const 00120 { 00121 return ((__discretizationType.type() == f.__discretizationType.type()) 00122 and (__baseMesh == f.__baseMesh)); 00123 } 00124 00130 ConstReferenceCounting<Mesh> baseMesh() const 00131 { 00132 return __baseMesh; 00133 } 00134 00140 const ScalarDiscretizationTypeBase::Type& discretizationType() const 00141 { 00142 return __discretizationType.type(); 00143 } 00144 00150 const Vector<real_t>& values() const 00151 { 00152 return __values; 00153 } 00154 00162 inline real_t& operator[](const size_t& i) 00163 { 00164 return __values[i]; 00165 } 00166 00174 inline const real_t& operator[](const size_t& i) const 00175 { 00176 return __values[i]; 00177 } 00178 00184 void operator=(const Vector<real_t>& values) 00185 { 00186 ASSERT (values.size() == __values.size()); 00187 __values = values; 00188 } 00189 00195 virtual void operator=(const ScalarFunctionBase& f) = 0; 00196 00204 virtual TinyVector<3,real_t> 00205 gradient(const TinyVector<3,real_t>& x) const = 0; 00206 00213 FEMFunctionBase(const Mesh* mesh, 00214 const ScalarDiscretizationTypeFEM& discretizationType) 00215 : ScalarFunctionBase(ScalarFunctionBase::femfunction), 00216 __baseMesh(mesh), 00217 __dofPositionsSet(DegreeOfFreedomSetManager::instance().getDOFPositionsSet(*mesh,discretizationType)), 00218 __values(__dofPositionsSet->number()), 00219 __discretizationType(discretizationType), 00220 __outsideValue(0) 00221 { 00222 ; 00223 } 00224 00229 virtual ~FEMFunctionBase() 00230 { 00231 DegreeOfFreedomSetManager::instance().unsubscribe(__dofPositionsSet); 00232 } 00233 }; 00234 00235 #endif // FEM_FUNCTION_BASE_HPP
1.5.6