DynamicField.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "DynamicField.H"
00028
00029
00030
00031 namespace Foam
00032 {
00033
00034
00035
00036 template<class Type>
00037 const char* const DynamicField<Type>::typeName("DynamicField");
00038
00039
00040
00041
00042 template<class Type>
00043 DynamicField<Type>::DynamicField(Istream& is)
00044 :
00045 Field<Type>(is),
00046 capacity_(Field<Type>::size())
00047 {}
00048
00049
00050 template<class Type>
00051 tmp<DynamicField<Type> > DynamicField<Type>::clone() const
00052 {
00053 return tmp<DynamicField<Type> >(new DynamicField<Type>(*this));
00054 }
00055
00056
00057
00058
00059 template<class Type>
00060 void DynamicField<Type>::setSize(const label nElem)
00061 {
00062
00063 if (nElem > capacity_)
00064 {
00065 capacity_ = max(nElem, label(1 + capacity_*2));
00066
00067 Field<Type>::setSize(capacity_);
00068 }
00069
00070
00071 Field<Type>::size(nElem);
00072 }
00073
00074
00075
00076
00077
00078
00079
00080 template<class Type>
00081 Ostream& operator<<(Ostream& os, const DynamicField<Type>& f)
00082 {
00083 os << static_cast<const Field<Type>&>(f);
00084 return os;
00085 }
00086
00087
00088 template<class Type>
00089 Ostream& operator<<(Ostream& os, const tmp<DynamicField<Type> >& tf)
00090 {
00091 os << tf();
00092 tf.clear();
00093 return os;
00094 }
00095
00096
00097 template<class Type>
00098 Istream& operator>>(Istream& is, DynamicField<Type>& lst)
00099 {
00100 is >> static_cast<Field<Type>&>(lst);
00101 lst.capacity_ = lst.Field<Type>::size();
00102
00103 return is;
00104 }
00105
00106
00107
00108
00109 }
00110
00111
00112
Copyright © 2000-2009 OpenCFD Ltd