00001 // This file is part of ff3d - http://www.freefem.org/ff3d 00002 // Copyright (C) 2008 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: DGFunctionBase.hpp,v 1.1 2008/01/31 21:38:15 delpinux Exp $ 00019 00020 #ifndef DG_FUNCTION_BASE_HPP 00021 #define DG_FUNCTION_BASE_HPP 00022 00023 #include <ScalarFunctionBase.hpp> 00024 00025 #include <ScalarDegreeOfFreedomPositionsSet.hpp> 00026 #include <DegreeOfFreedomSetManager.hpp> 00027 00028 #include <ScalarDiscretizationTypeDG.hpp> 00029 00030 #include <Vector.hpp> 00031 00032 class Mesh; 00033 00041 class DGFunctionBase 00042 : public ScalarFunctionBase 00043 { 00044 protected: 00045 ConstReferenceCounting<Mesh> 00046 __baseMesh; 00049 ConstReferenceCounting<ScalarDegreeOfFreedomPositionsSet> 00050 __dofPositionsSet; 00052 Vector<real_t> __values; 00054 const ScalarDiscretizationTypeDG 00055 __discretizationType; 00064 std::ostream& __put(std::ostream& os) const 00065 { 00066 os << "{dg-" << 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 #warning set to false since not implemented yet 00110 return false; 00111 } 00112 00120 bool hasSameType(const DGFunctionBase& f) const 00121 { 00122 return ((__discretizationType.type() == f.__discretizationType.type()) 00123 and (__baseMesh == f.__baseMesh)); 00124 } 00125 00131 ConstReferenceCounting<Mesh> baseMesh() const 00132 { 00133 return __baseMesh; 00134 } 00135 00141 const ScalarDiscretizationTypeBase::Type& discretizationType() const 00142 { 00143 return __discretizationType.type(); 00144 } 00145 00151 const Vector<real_t>& values() const 00152 { 00153 return __values; 00154 } 00155 00163 inline real_t& operator[](const size_t& i) 00164 { 00165 return __values[i]; 00166 } 00167 00175 inline const real_t& operator[](const size_t& i) const 00176 { 00177 return __values[i]; 00178 } 00179 00185 void operator=(const Vector<real_t>& values) 00186 { 00187 ASSERT (values.size() == __values.size()); 00188 __values = values; 00189 } 00190 00196 virtual void operator=(const ScalarFunctionBase& f) = 0; 00197 00205 virtual TinyVector<3,real_t> 00206 gradient(const TinyVector<3,real_t>& x) const = 0; 00207 00214 DGFunctionBase(const Mesh* mesh, 00215 const ScalarDiscretizationTypeDG& discretizationType) 00216 : ScalarFunctionBase(ScalarFunctionBase::dgfunction), 00217 __baseMesh(mesh), 00218 __dofPositionsSet(DegreeOfFreedomSetManager::instance().getDOFPositionsSet(*mesh,discretizationType)), 00219 __values(__dofPositionsSet->number()), 00220 __discretizationType(discretizationType), 00221 __outsideValue(0) 00222 { 00223 ; 00224 } 00225 00230 virtual ~DGFunctionBase() 00231 { 00232 DegreeOfFreedomSetManager::instance().unsubscribe(__dofPositionsSet); 00233 } 00234 }; 00235 00236 #endif // DG_FUNCTION_BASE_HPP
1.5.6