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: DegreeOfFreedomSet.hpp,v 1.12 2007/08/02 23:13:44 delpinux Exp $ 00019 00020 #ifndef DEGREE_OF_FREEDOM_SET_HPP 00021 #define DEGREE_OF_FREEDOM_SET_HPP 00022 00023 #include <Vector.hpp> 00024 00025 #include <ReferenceCounting.hpp> 00026 #include <ErrorHandler.hpp> 00027 00028 #include <DegreeOfFreedomPositionsSet.hpp> 00029 00030 #include <cstddef> 00040 class DegreeOfFreedomSet 00041 { 00042 public: 00043 typedef Vector<int> Correspondance; 00044 private: 00045 ConstReferenceCounting<Correspondance> __correspondance; 00046 ConstReferenceCounting<DegreeOfFreedomPositionsSet> __dofPositionsSet; 00047 00048 const size_t __numberOfVariables; 00049 00050 Vector<size_t> __offset; 00051 00052 public: 00053 const ScalarDegreeOfFreedomPositionsSet& positionsSet(const size_t& i) const 00054 { 00055 return (*__dofPositionsSet)[i]; 00056 } 00057 00058 // const size_t& numberOfUsedDOFPositions() const 00059 // { 00060 // return __numberOfUsedDOFPositions; 00061 // } 00062 00063 const size_t& numberOfDOFPositions(const size_t& i) const 00064 { 00065 return (*__dofPositionsSet)[i].number(); 00066 } 00067 00068 const size_t& numberOfVariables() const 00069 { 00070 return __numberOfVariables; 00071 } 00072 00073 size_t size() const 00074 { 00075 return __offset[__numberOfVariables]; 00076 } 00077 00078 size_t operator()(const size_t& variableNumber, 00079 const size_t& scalarDOFNumber) const 00080 { 00081 const size_t dofNumber = __offset[variableNumber]+scalarDOFNumber; 00082 00083 ASSERT((*__correspondance)[dofNumber] != -1); 00084 00085 return ((*__correspondance)[dofNumber]); 00086 } 00087 00088 bool isDOFVertex(const size_t& variableNumber, 00089 const size_t& scalarDOFNumber) const 00090 { 00091 const size_t dofNumber = __offset[variableNumber]+scalarDOFNumber; 00092 return ((*__correspondance)[dofNumber] != -1); 00093 } 00094 00095 DegreeOfFreedomSet(ConstReferenceCounting<DegreeOfFreedomPositionsSet> dofPositions, 00096 ConstReferenceCounting<Correspondance> correspondance) 00097 : __correspondance(correspondance), 00098 __dofPositionsSet(dofPositions), 00099 __numberOfVariables(dofPositions->number()), 00100 __offset(__numberOfVariables+1) 00101 { 00102 __offset[0] = 0; 00103 const DegreeOfFreedomPositionsSet& dofPositionsSet = *dofPositions; 00104 for(size_t i=0; i<dofPositionsSet.number(); ++i) { 00105 __offset[i+1] = __offset[i]+(*dofPositions)[i].number(); 00106 } 00107 } 00108 00109 ~DegreeOfFreedomSet() 00110 { 00111 ; 00112 } 00113 }; 00114 00115 #endif // DEGREE_OF_FREEDOM_SET_HPP 00116
1.5.6