Commit 2b58eb62 authored by Mark Olesen's avatar Mark Olesen
Browse files

Allow SubField construct from UList w/o extra size specification

- this allows SubField<point> for unallocated storage in PrimitivePatch
parent 4b60453c
......@@ -53,9 +53,9 @@ inline Foam::SubList<T>::SubList
{
# ifdef FULLDEBUG
// Artificially allowing the start of a zero-sized subList to be
// Artificially allow the start of a zero-sized subList to be
// one past the end of the original list.
if (subSize > 0)
if (subSize)
{
list.checkStart(startIndex);
list.checkSize(startIndex + subSize);
......@@ -84,7 +84,7 @@ inline const Foam::SubList<T>& Foam::SubList<T>::null()
template<class T>
inline Foam::SubList<T>::operator const Foam::List<T>&() const
{
return *reinterpret_cast<const List<T>*>(this);
return *reinterpret_cast< const List<T>* >(this);
}
......
......@@ -177,9 +177,9 @@ Field<Type>::Field(const typename Field<Type>::subField& sf)
template<class Type>
Field<Type>::Field(const UList<Type>& tl)
Field<Type>::Field(const UList<Type>& list)
:
List<Type>(tl)
List<Type>(list)
{}
......@@ -232,8 +232,7 @@ Field<Type>::Field
FatalIOErrorIn
(
"Field<Type>::Field"
"(const word& keyword, "
"const dictionary& dict, const label s)",
"(const word& keyword, const dictionary&, const label)",
dict
) << "size " << this->size()
<< " is not equal to the given value of " << s
......@@ -245,8 +244,7 @@ Field<Type>::Field
FatalIOErrorIn
(
"Field<Type>::Field"
"(const word& keyword, "
"const dictionary& dict, const label s)",
"(const word& keyword, const dictionary&, const label)",
dict
) << "expected keyword 'uniform' or 'nonuniform', found "
<< firstToken.wordToken()
......@@ -260,8 +258,7 @@ Field<Type>::Field
IOWarningIn
(
"Field<Type>::Field"
"(const word& keyword, const dictionary& dict, "
"const label s)",
"(const word& keyword, const dictionary&, const label)",
dict
) << "expected keyword 'uniform' or 'nonuniform', "
"assuming deprecated Field format from "
......@@ -277,10 +274,9 @@ Field<Type>::Field
FatalIOErrorIn
(
"Field<Type>::Field"
"(const word& keyword, "
"const dictionary& dict, const label s)",
"(const word& keyword, const dictionary&, const label)",
dict
) << "extected keyword 'uniform' or 'nonuniform', found "
) << "expected keyword 'uniform' or 'nonuniform', found "
<< firstToken.info()
<< exit(FatalIOError);
}
......@@ -371,7 +367,7 @@ void Field<Type>::map
forAll(f, i)
{
const labelList& localAddrs = mapAddressing[i];
const labelList& localAddrs = mapAddressing[i];
const scalarList& localWeights = mapWeights[i];
f[i] = pTraits<Type>::zero;
......@@ -622,37 +618,37 @@ void Field<Type>::writeEntry(const word& keyword, Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type>
void Field<Type>::operator=(const Field<Type>& f)
void Field<Type>::operator=(const Field<Type>& rhs)
{
if (this == &f)
if (this == &rhs)
{
FatalErrorIn("Field<Type>::operator=(const Field<Type>&)")
<< "attempted assignment to self"
<< abort(FatalError);
}
List<Type>::operator=(f);
List<Type>::operator=(rhs);
}
template<class Type>
void Field<Type>::operator=(const SubField<Type>& sf)
void Field<Type>::operator=(const SubField<Type>& rhs)
{
List<Type>::operator=(sf);
List<Type>::operator=(rhs);
}
template<class Type>
void Field<Type>::operator=(const UList<Type>& ul)
void Field<Type>::operator=(const UList<Type>& rhs)
{
List<Type>::operator=(ul);
List<Type>::operator=(rhs);
}
template<class Type>
void Field<Type>::operator=(const tmp<Field>& tf)
void Field<Type>::operator=(const tmp<Field>& rhs)
{
if (this == &(tf()))
if (this == &(rhs()))
{
FatalErrorIn("Field<Type>::operator=(const tmp<Field>&)")
<< "attempted assignment to self"
......@@ -660,7 +656,7 @@ void Field<Type>::operator=(const tmp<Field>& tf)
}
// This is dodgy stuff, don't try it at home.
Field* fieldPtr = tf.ptr();
Field* fieldPtr = rhs.ptr();
List<Type>::transfer(*fieldPtr);
delete fieldPtr;
}
......
......@@ -120,7 +120,7 @@ public:
//- Construct given size and initial value
Field(const label, const Type&);
//- Construct as copy of a UList<Type>
//- Construct as copy of a UList\<Type\>
explicit Field(const UList<Type>&);
//- Construct by transferring the List contents
......
......@@ -68,20 +68,20 @@ public:
// Constructors
//- Construct from UnallocatedField and SubField size
inline SubField
(
const SubList<Type>& slist
);
//- Construct from a SubList
inline SubField(const SubList<Type>&);
//- Construct from a UList\<Type\>, using the entire size
explicit inline SubField(const UList<Type>&);
//- Construct from UnallocatedField and SubField size
//- Construct from a UList\<Type\> with a given size
inline SubField
(
const UList<Type>& list,
const label subSize
);
//- Construct from UnallocatedField, start and end indices
//- Construct from a UList\<Type\> with a given size and start index
inline SubField
(
const UList<Type>& list,
......@@ -90,10 +90,7 @@ public:
);
//- Construct as copy
inline SubField
(
const SubField<Type>& sfield
);
inline SubField(const SubField<Type>&);
// Member functions
......@@ -110,10 +107,10 @@ public:
// Member operators
//- Assignment from UList operator. Takes linear time.
//- Assignment via UList operator. Takes linear time.
inline void operator=(const SubField<Type>&);
//- Allow cast to a const Field<Type>&
//- Allow cast to a const Field\<Type\>&
inline operator const Field<Type>&() const;
};
......
......@@ -29,12 +29,23 @@ License
template<class Type>
inline Foam::SubField<Type>::SubField
(
const SubList<Type>& slist
const SubList<Type>& list
)
:
SubList<Type>(slist)
SubList<Type>(list)
{}
template<class Type>
inline Foam::SubField<Type>::SubField
(
const UList<Type>& list
)
:
SubList<Type>(list, list.size())
{}
template<class Type>
inline Foam::SubField<Type>::SubField
(
......@@ -108,7 +119,7 @@ inline void Foam::SubField<Type>::operator=(const SubField<Type>& rhs)
template<class Type>
inline Foam::SubField<Type>::operator const Foam::Field<Type>&() const
{
return *(reinterpret_cast<const Field<Type>*>(this));
return *reinterpret_cast< const Field<Type>* >(this);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment