00001 // This file is part of ff3d - http://www.freefem.org/ff3d 00002 // Copyright (C) 2005 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: DiscretizationType.hpp,v 1.9 2007/11/20 22:00:06 delpinux Exp $ 00019 00020 #ifndef DISCRETIZATION_TYPE_HPP 00021 #define DISCRETIZATION_TYPE_HPP 00022 00023 #include <ScalarDiscretizationTypeBase.hpp> 00024 00025 #include <ReferenceCounting.hpp> 00026 #include <vector> 00027 #include <iostream> 00028 00037 class DiscretizationType 00038 { 00039 public: 00040 enum Family { 00041 fem, 00042 spectral, 00043 unknown 00044 }; 00045 00046 typedef std::vector<ConstReferenceCounting<ScalarDiscretizationTypeBase> > 00047 ScalarDiscretizationTypeList; 00048 00049 private: 00050 ScalarDiscretizationTypeList __types; 00052 friend std::ostream& operator<<(std::ostream& os, 00053 const DiscretizationType& discretization) 00054 { 00055 os << ScalarDiscretizationTypeBase::name(discretization.__types[0]->type()); 00056 for (size_t i=1; i<discretization.__types.size(); ++i) { 00057 os << ',' << ScalarDiscretizationTypeBase::name(discretization.__types[i]->type()); 00058 } 00059 return os; 00060 } 00061 00062 Family __componentFamily(const size_t& i) const 00063 { 00064 ASSERT(i<__types.size()); 00065 00066 switch(__types[i]->type()) { 00067 case ScalarDiscretizationTypeBase::lagrangianFEM0: 00068 case ScalarDiscretizationTypeBase::lagrangianFEM1: 00069 case ScalarDiscretizationTypeBase::lagrangianFEM2: { 00070 return fem; 00071 } 00072 case ScalarDiscretizationTypeBase::spectralLegendre: { 00073 return spectral; 00074 } 00075 case ScalarDiscretizationTypeBase::undefined: 00076 case ScalarDiscretizationTypeBase::functionLike: 00077 default: { 00078 return unknown; 00079 } 00080 } 00081 } 00082 00083 public: 00084 00090 Family getFamily() const 00091 { 00092 Family family = this->__componentFamily(0); 00093 00094 for (size_t i=1; i<__types.size(); ++i) { 00095 if (family != this->__componentFamily(i)) { 00096 return unknown; 00097 } 00098 } 00099 00100 return family; 00101 } 00102 00108 size_t number() const 00109 { 00110 return __types.size(); 00111 } 00112 00120 const ScalarDiscretizationTypeBase& operator[](const size_t& i) const 00121 { 00122 ASSERT(i<__types.size()); 00123 return *(__types[i]); 00124 } 00125 00131 void add(ConstReferenceCounting<ScalarDiscretizationTypeBase> type) 00132 { 00133 __types.push_back(type); 00134 } 00135 00140 DiscretizationType() 00141 { 00142 ; 00143 } 00144 00150 DiscretizationType(const DiscretizationType& d) 00151 : __types(d.__types) 00152 { 00153 ; 00154 } 00155 00160 ~DiscretizationType() 00161 { 00162 ; 00163 } 00164 }; 00165 00166 #endif // DISCRETIZATION_TYPE_HPP
1.5.6