merge from master

This commit is contained in:
mattijs
2008-10-21 15:04:18 +01:00
parent 4c5ebb4cb1
commit 3efb4ebe20
44 changed files with 589 additions and 225 deletions

View File

@ -43,20 +43,58 @@ int main(int argc, char *argv[])
ldl[0](3) = 3; ldl[0](3) = 3;
ldl[0](1) = 1; ldl[0](1) = 1;
ldl[1](0) = 1; ldl[0].setSize(5); // increase allocated size
ldl[1](1) = 2; ldl[1].setSize(10); // increase allocated size
ldl[1](2) = 2;
ldl[1] = 3; ldl[1] = 3;
Info<< ldl[1]; Info<< "<ldl>" << ldl << "</ldl>" << nl << "sizes: ";
forAll(ldl, i)
{
Info<< " " << ldl[i].size() << "/" << ldl[i].allocSize();
}
Info<< endl;
List<List<label> > ll(2); List<List<label> > ll(2);
ll[0].transfer(ldl[0].shrink()); ll[0].transfer(ldl[0]);
ll[1].transfer(ldl[1].shrink()); ll[1].transfer(ldl[1].shrink());
Info<< ll << endl; Info<< "<ldl>" << ldl << "</ldl>" << nl << "sizes: ";
forAll(ldl, i)
{
Info<< " " << ldl[i].size() << "/" << ldl[i].allocSize();
}
Info<< endl;
Info<< "<ll>" << ll << "</ll>" << nl << endl;
// test the transfer between DynamicLists
DynamicList<label, 1, 0> dlA;
DynamicList<label, 1, 0> dlB;
for (label i = 0; i < 5; i++)
{
dlA.append(i);
}
dlA.setSize(10);
Info<< "<dlA>" << dlA << "</dlA>" << nl << "sizes: "
<< " " << dlA.size() << "/" << dlA.allocSize() << endl;
dlB.transfer(dlA);
// provokes memory error if previous transfer did not maintain
// the correct allocated space
dlB[6] = 6;
Info<< "Transferred to dlB" << endl;
Info<< "<dlA>" << dlA << "</dlA>" << nl << "sizes: "
<< " " << dlA.size() << "/" << dlA.allocSize() << endl;
Info<< "<dlB>" << dlB << "</dlB>" << nl << "sizes: "
<< " " << dlB.size() << "/" << dlB.allocSize() << endl;
Info << "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -52,34 +52,48 @@ int main(int argc, char *argv[])
Info<< "lstA: " << lstA << endl; Info<< "lstA: " << lstA << endl;
Info<< "lstC: " << lstC << endl; Info<< "lstC: " << lstC << endl;
xfer<List<label> > xA(lstA, true); xfer<List<label> > xA = xferMove(lstA);
xfer<List<label> > xB; xfer<List<label> > xB;
// List<label> lstB( xferTmp(List<label>, lstC) );
// List<label> lstB( xfer<List<label> >(lstC) );
List<label> lstB( xA ); List<label> lstB( xA );
Info<< "xA: " << *xA << endl; Info<< "xA: " << xA() << endl;
Info<< "xB: " << *xB << endl; Info<< "xB: " << xB() << endl;
Info<< "lstA: " << lstA << endl; Info<< "lstA: " << lstA << endl;
Info<< "lstB: " << lstB << endl; Info<< "lstB: " << lstB << endl;
Info<< "lstC: " << lstC << endl; Info<< "lstC: " << lstC << endl;
xA = lstB; xA = lstB;
Info<< "xA: " << *xA << endl; Info<< "xA: " << xA() << endl;
Info<< "xB: " << *xB << endl; Info<< "xB: " << xB() << endl;
Info<< "lstA: " << lstA << endl; Info<< "lstA: " << lstA << endl;
Info<< "lstB: " << lstB << endl; Info<< "lstB: " << lstB << endl;
Info<< "lstC: " << lstC << endl; Info<< "lstC: " << lstC << endl;
xB = xA; xB = xA;
Info<< "xA: " << *xA << endl; List<label> lstD(xferCopy(lstC));
Info<< "xB: " << *xB << endl; List<label> lstE(xferMove(lstC));
// this must be empty
List<label> lstF = xferCopy(lstC);
Info<< "xA: " << xA() << endl;
Info<< "xB: " << xB() << endl;
Info<< "lstA: " << lstA << endl; Info<< "lstA: " << lstA << endl;
Info<< "lstB: " << lstB << endl; Info<< "lstB: " << lstB << endl;
Info<< "lstC: " << lstC << endl; Info<< "lstC: " << lstC << endl;
Info<< "lstD: " << lstD << endl;
Info<< "lstE: " << lstE << endl;
Info<< "lstF: " << lstF << endl;
Info<< "xB size: " << xB->size() << endl;
// clear the underlying List
xB->clear();
Info<< "xB size: " << xB->size() << endl;
return 0; return 0;
} }

View File

@ -121,7 +121,7 @@ unset MPI_ARCH_PATH
switch ("$WM_MPLIB") switch ("$WM_MPLIB")
case OPENMPI: case OPENMPI:
set mpi_version=openmpi-1.2.6 set mpi_version=openmpi-1.2.8
setenv MPI_HOME $WM_THIRD_PARTY_DIR/$mpi_version setenv MPI_HOME $WM_THIRD_PARTY_DIR/$mpi_version
setenv MPI_ARCH_PATH $MPI_HOME/platforms/$WM_OPTIONS setenv MPI_ARCH_PATH $MPI_HOME/platforms/$WM_OPTIONS

View File

@ -151,7 +151,7 @@ unset MPI_ARCH_PATH
case "$WM_MPLIB" in case "$WM_MPLIB" in
OPENMPI) OPENMPI)
mpi_version=openmpi-1.2.6 mpi_version=openmpi-1.2.8
export MPI_HOME=$WM_THIRD_PARTY_DIR/$mpi_version export MPI_HOME=$WM_THIRD_PARTY_DIR/$mpi_version
export MPI_ARCH_PATH=$MPI_HOME/platforms/$WM_OPTIONS export MPI_ARCH_PATH=$MPI_HOME/platforms/$WM_OPTIONS

View File

@ -93,7 +93,7 @@ HashTable<T, Key, Hash>::HashTable(const xfer<HashTable<T, Key, Hash> >& ht)
endIter_(*this, NULL, 0), endIter_(*this, NULL, 0),
endConstIter_(*this, NULL, 0) endConstIter_(*this, NULL, 0)
{ {
transfer(*ht); transfer(ht());
} }

View File

@ -90,7 +90,7 @@ StaticHashTable<T, Key, Hash>::StaticHashTable
endIter_(*this, 0, 0), endIter_(*this, 0, 0),
endConstIter_(*this, 0, 0) endConstIter_(*this, 0, 0)
{ {
transfer(*ht); transfer(ht());
} }

View File

@ -95,7 +95,7 @@ CompactListList<T>::CompactListList(const UList<label>& rowSizes, const T& t)
template<class T> template<class T>
CompactListList<T>::CompactListList(const xfer<CompactListList<T> >& lst) CompactListList<T>::CompactListList(const xfer<CompactListList<T> >& lst)
{ {
transfer(*lst); transfer(lst());
} }
template<class T> template<class T>

View File

@ -115,39 +115,36 @@ public:
// Access // Access
//- Size of the underlying storage. //- Size of the underlying storage.
inline label allocSize() const; inline label allocSize() const;
// Edit // Edit
//- Alter the list size. //- Alter the list size.
// When the new size is greater than the addressed list size, the // When the new size is greater than the addressed list size, the
// allocated list sizes is adjusted and the // allocated list sizes is adjusted and the
// addressed size does not change. // addressed size does not change.
// Otherwise the addressed list size is just reduced and the // Otherwise the addressed list size is just reduced and the
// allocated size does not change. // allocated size does not change.
inline void setSize(const label); inline void setSize(const label);
//- Clear the list, i.e. set the size to zero. //- Clear the list, i.e. set the size to zero.
// Allocated size does not change // Allocated size does not change
inline void clear(); inline void clear();
//- Clear the list and delete storage. //- Clear the list and delete storage.
inline void clearStorage(); inline void clearStorage();
//- Shrink the List<T> to the number of elements used //- Shrink the allocated space to the number of elements used.
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& shrink(); // Returns a reference to the DynamicList.
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& shrink();
//- Transfer the contents of the argument List into this List //- Transfer contents of the argument List into this DynamicList
// and annull the argument list. Is same as List::transfer except inline void transfer(List<T>&);
// checks that you're not changing the underlying list to something
// smaller than allocSize_.
inline void transfer(List<T>&);
//- Transfer the contents of the argument DynamicList into this //- Transfer contents of the argument DynamicList into this DynamicList
// DynamicList and annull the argument list. inline void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
inline void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
// Member Operators // Member Operators
@ -158,8 +155,7 @@ public:
//- Remove and return the top element //- Remove and return the top element
inline T remove(); inline T remove();
//- Return non-const access to an element, //- Return non-const access to an element, resizing list if necessary
// resizing the list if necessary
inline T& operator()(const label); inline T& operator()(const label);
//- Assignment of all addressed entries to the given value //- Assignment of all addressed entries to the given value

View File

@ -26,7 +26,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct null
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList() inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList()
: :
@ -37,7 +36,6 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList()
} }
//- Construct given size
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
( (
@ -51,15 +49,14 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
} }
//- Construct given size
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
( (
const UList<T>& s const UList<T>& lst
) )
: :
List<T>(s), List<T>(lst),
allocSize_(s.size()) allocSize_(lst.size())
{} {}
@ -114,31 +111,24 @@ template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>& inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::shrink() Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::shrink()
{ {
allocSize_ = List<T>::size(); if (allocSize_ > List<T>::size())
List<T>::setSize(allocSize_); {
allocSize_ = List<T>::size();
// force re-allocation/copying in List<T>::setSize() by temporarily
// faking a larger list size that will be truncated
List<T>::size(allocSize_+1);
List<T>::setSize(allocSize_);
}
return *this; return *this;
} }
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void inline void
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer(List<T>& l) Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer(List<T>& lst)
{ {
if (l.size() < List<T>::size()) allocSize_ = lst.size();
{ List<T>::transfer(lst); // take over storage, clear addressing for lst.
FatalErrorIn
(
"void DynamicList<T, SizeInc, SizeMult"
", SizeDiv>::transfer(List<T>&)"
) << "Cannot replace the underlying storage of this DynamicList"
<< " of which " << List<T>::size() << " elements are used" << nl
<< "with a List of size " << l.size() << abort(FatalError);
}
else
{
allocSize_ = l.size();
List<T>::transfer(l); // take over storage
}
} }
@ -146,11 +136,14 @@ template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void inline void
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer
( (
DynamicList<T, SizeInc, SizeMult, SizeDiv>& l DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
) )
{ {
allocSize_ = l.allocSize(); // take over storage as-is (without shrink), clear addressing for lst.
List<T>::transfer(l); // take over storage. Null l. allocSize_ = lst.allocSize_;
lst.allocSize_ = 0;
List<T>::transfer(static_cast<List<T>&>(lst));
} }
@ -240,10 +233,13 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator= inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
( (
const List<T>& l const List<T>& lst
) )
{ {
List<T>::operator=(l); // make the entire storage available for the copy operation:
List<T>::size(allocSize_);
List<T>::operator=(lst);
allocSize_ = List<T>::size(); allocSize_ = List<T>::size();
} }

View File

@ -129,7 +129,7 @@ Foam::List<T>::List(const List<T>& a)
template<class T> template<class T>
Foam::List<T>::List(const xfer<List<T> >& lst) Foam::List<T>::List(const xfer<List<T> >& lst)
{ {
transfer(*lst); transfer(lst());
} }
@ -430,6 +430,9 @@ template<class T>
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
void Foam::List<T>::transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a) void Foam::List<T>::transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a)
{ {
// shrink the allocated space to the number of elements used
a.shrink();
if (this->v_) delete[] this->v_; if (this->v_) delete[] this->v_;
this->size_ = a.size_; this->size_ = a.size_;
this->v_ = a.v_; this->v_ = a.v_;

View File

@ -57,7 +57,7 @@ PackedList<nBits>::PackedList(const PackedList<nBits>& PList)
template<int nBits> template<int nBits>
PackedList<nBits>::PackedList(const xfer<PackedList<nBits> >& lst) PackedList<nBits>::PackedList(const xfer<PackedList<nBits> >& lst)
{ {
transfer(*lst); transfer(lst());
} }

View File

@ -74,7 +74,7 @@ Foam::PtrList<T>::PtrList(const PtrList<T>& a, const CloneArg& cloneArg)
template<class T> template<class T>
Foam::PtrList<T>::PtrList(const xfer<PtrList<T> >& lst) Foam::PtrList<T>::PtrList(const xfer<PtrList<T> >& lst)
{ {
transfer(*lst); transfer(lst());
} }

View File

@ -45,9 +45,9 @@ template <class Type>
Foam::SortableList<Type>::SortableList(const xfer<List<Type> >& values) Foam::SortableList<Type>::SortableList(const xfer<List<Type> >& values)
: :
List<Type>(), List<Type>(),
indices_((*values).size()) indices_(values->size())
{ {
List<Type>::transfer(*values); List<Type>::transfer(values());
sort(); sort();
} }

View File

@ -45,7 +45,7 @@ void Foam::UList<T>::assign(const UList<T>& a)
{ {
if (a.size_ != this->size_) if (a.size_ != this->size_)
{ {
FatalErrorIn("UList<T>::operator=(const UList<T>&)") FatalErrorIn("UList<T>::assign(const UList<T>&)")
<< "ULists have different sizes: " << "ULists have different sizes: "
<< this->size_ << " " << a.size_ << this->size_ << " " << a.size_
<< abort(FatalError); << abort(FatalError);

View File

@ -53,7 +53,7 @@ UPtrList<T>::UPtrList(const label s)
template<class T> template<class T>
UPtrList<T>::UPtrList(const xfer<UPtrList<T> >& lst) UPtrList<T>::UPtrList(const xfer<UPtrList<T> >& lst)
{ {
transfer(*lst); transfer(lst());
} }

View File

@ -87,6 +87,25 @@ Foam::IOField<Type>::IOField(const IOobject& io, const Field<Type>& f)
} }
template<class Type>
Foam::IOField<Type>::IOField(const IOobject& io, const xfer<Field<Type> >& f)
:
regIOobject(io)
{
Field<Type>::transfer(f());
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>

View File

@ -65,11 +65,14 @@ public:
//- Construct from IOobject //- Construct from IOobject
IOField(const IOobject&); IOField(const IOobject&);
//- Construct from IOobject and size (does not set values)
IOField(const IOobject&, const label size);
//- Construct from components //- Construct from components
IOField(const IOobject&, const Field<Type>&); IOField(const IOobject&, const Field<Type>&);
//- Construct from IOobject and size (does not set values) //- Construct by transferring the Field contents
IOField(const IOobject&, const label size); IOField(const IOobject&, const xfer<Field<Type> >&);
// Destructor // Destructor

View File

@ -87,6 +87,25 @@ Foam::IOList<T>::IOList(const IOobject& io, const List<T>& list)
} }
template<class T>
Foam::IOList<T>::IOList(const IOobject& io, const xfer<List<T> >& list)
:
regIOobject(io)
{
List<T>::transfer(list());
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
template<class T> template<class T>

View File

@ -72,6 +72,9 @@ public:
//- Construct from IOobject and a List //- Construct from IOobject and a List
IOList(const IOobject&, const List<T>&); IOList(const IOobject&, const List<T>&);
//- Construct by transferring the List contents
IOList(const IOobject&, const xfer<List<T> >&);
// Destructor // Destructor

View File

@ -86,6 +86,25 @@ Foam::IOMap<T>::IOMap(const IOobject& io, const Map<T>& map)
} }
template<class T>
Foam::IOMap<T>::IOMap(const IOobject& io, const xfer<Map<T> >& map)
:
regIOobject(io)
{
Map<T>::transfer(map());
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
template<class T> template<class T>

View File

@ -66,11 +66,14 @@ public:
//- Construct from IOobject //- Construct from IOobject
IOMap(const IOobject&); IOMap(const IOobject&);
//- Construct from IOobject and size of Map
IOMap(const IOobject&, const label);
//- Construct from IOobject and a Map //- Construct from IOobject and a Map
IOMap(const IOobject&, const Map<T>&); IOMap(const IOobject&, const Map<T>&);
//- Construct from IOobject and size of Map //- Construct by transferring the Map contents
IOMap(const IOobject&, const label); IOMap(const IOobject&, const xfer<Map<T> >&);
// Destructor // Destructor

View File

@ -84,6 +84,25 @@ Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const PtrList<T>& list)
} }
template<class T>
Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const xfer<PtrList<T> >& list)
:
regIOobject(io)
{
PtrList<T>::transfer(list());
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
PtrList<T>::read(readStream(typeName), INew<T>());
close();
}
}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
template<class T> template<class T>

View File

@ -73,6 +73,9 @@ public:
//- Construct from IOobject and a PtrList //- Construct from IOobject and a PtrList
IOPtrList(const IOobject&, const PtrList<T>&); IOPtrList(const IOobject&, const PtrList<T>&);
//- Construct by transferring the PtrList contents
IOPtrList(const IOobject&, const xfer<PtrList<T> >&);
// Destructor // Destructor

View File

@ -138,6 +138,19 @@ DimensionedField<Type, GeoMesh>::DimensionedField
{} {}
template<class Type, class GeoMesh>
DimensionedField<Type, GeoMesh>::DimensionedField
(
const xfer<DimensionedField<Type, GeoMesh> >& df
)
:
regIOobject(df(), true),
Field<Type>(df),
mesh_(df->mesh_),
dimensions_(df->dimensions_)
{}
#ifdef ConstructFromTmp #ifdef ConstructFromTmp
template<class Type, class GeoMesh> template<class Type, class GeoMesh>
DimensionedField<Type, GeoMesh>::DimensionedField DimensionedField<Type, GeoMesh>::DimensionedField
@ -202,6 +215,20 @@ DimensionedField<Type, GeoMesh>::DimensionedField
{} {}
template<class Type, class GeoMesh>
DimensionedField<Type, GeoMesh>::DimensionedField
(
const word& newName,
const xfer<DimensionedField<Type, GeoMesh> >& df
)
:
regIOobject(IOobject(newName, df->time().timeName(), df->db())),
Field<Type>(df),
mesh_(df->mesh_),
dimensions_(df->dimensions_)
{}
#ifdef ConstructFromTmp #ifdef ConstructFromTmp
template<class Type, class GeoMesh> template<class Type, class GeoMesh>
DimensionedField<Type, GeoMesh>::DimensionedField DimensionedField<Type, GeoMesh>::DimensionedField

View File

@ -156,6 +156,12 @@ public:
bool reUse bool reUse
); );
//- Construct by transferring the DimensionedField
DimensionedField
(
const xfer<DimensionedField<Type, GeoMesh> >&
);
//- Construct as copy of tmp<DimensionedField> deleting argument //- Construct as copy of tmp<DimensionedField> deleting argument
# ifdef ConstructFromTmp # ifdef ConstructFromTmp
DimensionedField DimensionedField
@ -186,6 +192,13 @@ public:
bool reUse bool reUse
); );
//- Construct by transferring the DimensionedField with a new name
DimensionedField
(
const word& newName,
const xfer<DimensionedField<Type, GeoMesh> >&
);
//- Construct as copy resetting name //- Construct as copy resetting name
# ifdef ConstructFromTmp # ifdef ConstructFromTmp
DimensionedField DimensionedField

View File

@ -37,6 +37,7 @@ SourceFiles
#define FieldField_H #define FieldField_H
#include "tmp.H" #include "tmp.H"
#include "xfer.H"
#include "PtrList.H" #include "PtrList.H"
#include "scalar.H" #include "scalar.H"
#include "direction.H" #include "direction.H"

View File

@ -155,6 +155,13 @@ Field<Type>::Field(Field<Type>& f, bool reUse)
{} {}
template<class Type>
Field<Type>::Field(const xfer<Field<Type> >& f)
:
List<Type>(f)
{}
template<class Type> template<class Type>
Field<Type>::Field(const typename Field<Type>::subField& sf) Field<Type>::Field(const typename Field<Type>::subField& sf)
: :
@ -568,6 +575,20 @@ void Field<Type>::replace
} }
template<class Type>
void Field<Type>::transfer(Field<Type>& f)
{
List<Type>::transfer(f);
}
template<class Type>
void Field<Type>::transfer(List<Type>& lst)
{
List<Type>::transfer(lst);
}
template<class Type> template<class Type>
tmp<Field<Type> > Field<Type>::T() const tmp<Field<Type> > Field<Type>::T() const
{ {

View File

@ -43,6 +43,7 @@ SourceFiles
#define Field_H #define Field_H
#include "tmp.H" #include "tmp.H"
#include "xfer.H"
#include "direction.H" #include "direction.H"
#include "VectorSpace.H" #include "VectorSpace.H"
#include "scalarList.H" #include "scalarList.H"
@ -164,6 +165,9 @@ public:
//- Construct as copy or re-use as specified. //- Construct as copy or re-use as specified.
Field(Field<Type>&, bool reUse); Field(Field<Type>&, bool reUse);
//- Construct by transferring the Field contents
Field(const xfer<Field<Type> >&);
//- Construct as copy of subField //- Construct as copy of subField
Field(const typename Field<Type>::subField&); Field(const typename Field<Type>::subField&);
@ -293,6 +297,12 @@ public:
//- Replace a component field of the field //- Replace a component field of the field
void replace(const direction, const cmptType&); void replace(const direction, const cmptType&);
//- Transfer the contents of the argument Field into this Field
void transfer(Field<Type>&);
//- Transfer the contents of the argument List into this Field
void transfer(List<Type>&);
//- Return the field transpose (only defined for second rank tensors) //- Return the field transpose (only defined for second rank tensors)
tmp<Field<Type> > T() const; tmp<Field<Type> > T() const;

View File

@ -30,7 +30,7 @@ Description
of objects of type \<T\>. of objects of type \<T\>.
Since it is decided upon construction of the xfer object whether the Since it is decided upon construction of the xfer object whether the
parameter is to be copied or transferred, the contents of resulting parameter is to be copied or transferred, the contents of the resulting
object can be transferred unconditionally. object can be transferred unconditionally.
This greatly simplifies defining the constructors for other classes This greatly simplifies defining the constructors for other classes
@ -39,10 +39,6 @@ Description
The wrapped object of type \<T\> must implement a transfer() method and The wrapped object of type \<T\> must implement a transfer() method and
an operator=() copy method. an operator=() copy method.
Note
The macros xferCopy(T,arg) and xferMove(T,arg) can be used as
workarounds for passing temporaries to copy-constructors.
SourceFiles SourceFiles
xferI.H xferI.H
@ -56,6 +52,9 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes
template<class T> class tmp;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class xfer Declaration Class xfer Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -97,52 +96,65 @@ public:
//- Transfer the contents into the object //- Transfer the contents into the object
inline void operator=(const xfer<T>&); inline void operator=(const xfer<T>&);
//- Return a non-const reference to const object
// @sa xferCopy, xferMove macros alternatives for copy-constructors
inline const xfer<T>& operator()() const;
//- Reference to the underlying datatype //- Reference to the underlying datatype
inline T& operator*() const; inline T& operator()() const;
//- Pointer to the underlying datatype
inline T* operator->() const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
/** /**
* @def xferCopy(T,arg) * @fn template<class T> xferCopy(const T&)
* Construct by copying the contents of the @a arg * Construct by copying the contents of the @a arg
* and return a const reference to an xfer of type \<T\>
* *
* Useful for constructors where the argument is temporary. * @sa xferMove, xferTmp and Foam::xfer
* This is a workaround for a template resolution issue.
*
* @sa xferMove and Foam::xfer
*/ */
#define xferCopy(T,arg) \ template<class T>
(static_cast<const Foam::xfer< T >&>(Foam::xfer< T >(arg)())) Foam::xfer<T> xferCopy(const T& t)
{
return Foam::xfer<T>(t);
}
/** /**
* @def xferMove(T,arg) * @fn template<class T> xferMove(T&)
* Construct by transferring the contents of the @a arg * Construct by transferring the contents of the @a arg
* and return a const reference to an xfer of type \<T\>
*
* Useful for constructors where the argument is temporary.
* This is a workaround for a template resolution issue.
* *
* @par Example Use * @par Example Use
* @code * @code
* List<label> a; * List<label> a;
* ... * ...
* List<label> b(xferMove(List<label>, a)); * List<label> b(xferMove(a));
* @endcode * @endcode
* *
* @sa xferCopy and Foam::xfer * @sa xferCopy, xferTmp and Foam::xfer
*/ */
#define xferMove(T,arg) \ template<class T>
(static_cast<const Foam::xfer< T >&>(Foam::xfer< T >(arg, true)())) Foam::xfer<T> xferMove(T& t)
{
return Foam::xfer<T>(t, true);
}
/**
* @fn template<class T> xferTmp(tmp<T>&)
* Construct by transferring the contents of the @a arg
*
* @sa xferCopy, xferMove and Foam::xfer
*/
template<class T>
Foam::xfer<T> xferTmp(Foam::tmp<T>& tt)
{
return Foam::xfer<T>(tt(), tt.isTmp());
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -98,16 +98,16 @@ inline void Foam::xfer<T>::operator=(const xfer<T>& t)
template<class T> template<class T>
inline const Foam::xfer<T>& Foam::xfer<T>::operator()() const inline T& Foam::xfer<T>::operator()() const
{
return *this;
}
template<class T>
inline T& Foam::xfer<T>::operator*() const
{ {
return *ptr_; return *ptr_;
} }
template<class T>
inline T* Foam::xfer<T>::operator->() const
{
return ptr_;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -65,11 +65,11 @@ const Type& Foam::MeshObject<Mesh, Type>::New
template<class Mesh, class Type> template<class Mesh, class Type>
template<class Data> template<class Data1>
const Type& Foam::MeshObject<Mesh, Type>::New const Type& Foam::MeshObject<Mesh, Type>::New
( (
const Mesh& mesh, const Mesh& mesh,
const Data& d const Data1& d
) )
{ {
if (!mesh.db().objectRegistry::foundObject<Type>(Type::typeName)) if (!mesh.db().objectRegistry::foundObject<Type>(Type::typeName))
@ -103,6 +103,49 @@ const Type& Foam::MeshObject<Mesh, Type>::New
} }
template<class Mesh, class Type>
template<class Data1, class Data2, class Data3>
const Type& Foam::MeshObject<Mesh, Type>::New
(
const Mesh& mesh,
const Data1& d1,
const Data2& d2,
const Data3& d3
)
{
if (!mesh.db().objectRegistry::foundObject<Type>(Type::typeName))
{
return store(new Type(mesh, d1, d2, d3));
}
else
{
return mesh.db().objectRegistry::lookupObject<Type>(Type::typeName);
}
}
template<class Mesh, class Type>
template<class Data1, class Data2, class Data3, class Data4>
const Type& Foam::MeshObject<Mesh, Type>::New
(
const Mesh& mesh,
const Data1& d1,
const Data2& d2,
const Data3& d3,
const Data4& d4
)
{
if (!mesh.db().objectRegistry::foundObject<Type>(Type::typeName))
{
return store(new Type(mesh, d3, d4));
}
else
{
return mesh.db().objectRegistry::lookupObject<Type>(Type::typeName);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
template<class Mesh, class Type> template<class Mesh, class Type>

View File

@ -69,11 +69,39 @@ public:
static const Type& New(const Mesh& mesh); static const Type& New(const Mesh& mesh);
template<class Data> template<class Data1>
static const Type& New(const Mesh& mesh, const Data& d); static const Type& New
(
const Mesh& mesh,
const Data1& d
);
template<class Data1, class Data2> template<class Data1, class Data2>
static const Type& New(const Mesh& mesh, const Data1&, const Data2&); static const Type& New
(
const Mesh& mesh,
const Data1&,
const Data2&
);
template<class Data1, class Data2, class Data3>
static const Type& New
(
const Mesh& mesh,
const Data1&,
const Data2&,
const Data3&
);
template<class Data1, class Data2, class Data3, class Data4>
static const Type& New
(
const Mesh& mesh,
const Data1&,
const Data2&,
const Data3&,
const Data4&
);
// Destructor // Destructor

View File

@ -170,6 +170,9 @@ private:
//- Initialise the polyMesh from the given set of cells //- Initialise the polyMesh from the given set of cells
void initMesh(cellList& c); void initMesh(cellList& c);
//- Initialise the polyMesh from the given set of cells
void initMesh(const xfer<cellList>& c);
//- Calculate the valid directions in the mesh from the boundaries //- Calculate the valid directions in the mesh from the boundaries
void calcDirections() const; void calcDirections() const;
@ -226,6 +229,18 @@ public:
const bool syncPar = true const bool syncPar = true
); );
//- Construct without boundary from components.
// Boundary is added using addPatches() member function
polyMesh
(
const IOobject& io,
const xfer<pointField>& points,
const xfer<faceList>& faces,
const xfer<labelList>& owner,
const xfer<labelList>& neighbour,
const bool syncPar = true
);
//- Construct without boundary with cells rather than owner/neighbour. //- Construct without boundary with cells rather than owner/neighbour.
// Boundary is added using addPatches() member function // Boundary is added using addPatches() member function
polyMesh polyMesh
@ -237,6 +252,17 @@ public:
const bool syncPar = true const bool syncPar = true
); );
//- Construct without boundary with cells rather than owner/neighbour.
// Boundary is added using addPatches() member function
polyMesh
(
const IOobject& io,
const xfer<pointField>& points,
const xfer<faceList>& faces,
const xfer<cellList>& cells,
const bool syncPar = true
);
//- Construct from cell shapes //- Construct from cell shapes
polyMesh polyMesh
( (
@ -444,6 +470,23 @@ public:
const bool validBoundary = true const bool validBoundary = true
); );
//- Reset mesh primitive data. Assumes all patch info correct
// (so does e.g. parallel communication). If not use
// validBoundary=false
// (still assumes patchStarts[0] = nInternalFaces and last
// patch ends at nActiveFaces) and change patches with addPatches.
void resetPrimitives
(
const label nUsedFaces,
const xfer<pointField>& points,
const xfer<faceList>& faces,
const xfer<labelList>& owner,
const xfer<labelList>& neighbour,
const labelList& patchSizes,
const labelList& patchStarts,
const bool validBoundary = true
);
// Storage management // Storage management

View File

@ -155,4 +155,10 @@ void Foam::polyMesh::initMesh(cellList& c)
} }
void Foam::polyMesh::initMesh(const xfer<cellList>& clst)
{
initMesh(clst());
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -29,16 +29,15 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(primitiveMesh, 0);
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // }
defineTypeNameAndDebug(primitiveMesh, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
primitiveMesh::primitiveMesh() Foam::primitiveMesh::primitiveMesh()
: :
nInternalPoints_(0), // note: points are considered ordered on empty mesh nInternalPoints_(0), // note: points are considered ordered on empty mesh
nPoints_(0), nPoints_(0),
@ -77,7 +76,7 @@ primitiveMesh::primitiveMesh()
// Construct from components // Construct from components
// WARNING: ASSUMES CORRECT ORDERING OF DATA. // WARNING: ASSUMES CORRECT ORDERING OF DATA.
primitiveMesh::primitiveMesh Foam::primitiveMesh::primitiveMesh
( (
const label nPoints, const label nPoints,
const label nInternalFaces, const label nInternalFaces,
@ -114,14 +113,12 @@ primitiveMesh::primitiveMesh
faceCentresPtr_(NULL), faceCentresPtr_(NULL),
cellVolumesPtr_(NULL), cellVolumesPtr_(NULL),
faceAreasPtr_(NULL) faceAreasPtr_(NULL)
{ {}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
primitiveMesh::~primitiveMesh() Foam::primitiveMesh::~primitiveMesh()
{ {
clearOut(); clearOut();
} }
@ -129,7 +126,7 @@ primitiveMesh::~primitiveMesh()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool primitiveMesh::calcPointOrder bool Foam::primitiveMesh::calcPointOrder
( (
label& nInternalPoints, label& nInternalPoints,
labelList& oldToNew, labelList& oldToNew,
@ -208,7 +205,7 @@ bool primitiveMesh::calcPointOrder
} }
void primitiveMesh::reset void Foam::primitiveMesh::reset
( (
const label nPoints, const label nPoints,
const label nInternalFaces, const label nInternalFaces,
@ -264,13 +261,13 @@ void primitiveMesh::reset
} }
void primitiveMesh::reset void Foam::primitiveMesh::reset
( (
const label nPoints, const label nPoints,
const label nInternalFaces, const label nInternalFaces,
const label nFaces, const label nFaces,
const label nCells, const label nCells,
cellList& c cellList& clst
) )
{ {
reset reset
@ -281,11 +278,32 @@ void primitiveMesh::reset
nCells nCells
); );
cfPtr_ = new cellList(c, true); cfPtr_ = new cellList(clst, true);
} }
tmp<scalarField> primitiveMesh::movePoints void Foam::primitiveMesh::reset
(
const label nPoints,
const label nInternalFaces,
const label nFaces,
const label nCells,
const xfer<cellList>& clst
)
{
reset
(
nPoints,
nInternalFaces,
nFaces,
nCells
);
cfPtr_ = new cellList(clst);
}
Foam::tmp<Foam::scalarField> Foam::primitiveMesh::movePoints
( (
const pointField& newPoints, const pointField& newPoints,
const pointField& oldPoints const pointField& oldPoints
@ -320,7 +338,7 @@ tmp<scalarField> primitiveMesh::movePoints
} }
const cellShapeList& primitiveMesh::cellShapes() const const Foam::cellShapeList& Foam::primitiveMesh::cellShapes() const
{ {
if (!cellShapesPtr_) if (!cellShapesPtr_)
{ {
@ -331,8 +349,4 @@ const cellShapeList& primitiveMesh::cellShapes() const
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -375,6 +375,17 @@ public:
); );
//- Reset this primitiveMesh given the primitive array sizes and cells
void reset
(
const label nPoints,
const label nInternalFaces,
const label nFaces,
const label nCells,
const xfer<cellList>& cells
);
// Access // Access
// Mesh size parameters // Mesh size parameters

View File

@ -30,9 +30,6 @@ Description
#include "meshReader.H" #include "meshReader.H"
// for transition - in case someone really relied on the old behaviour
#undef LEAVE_UNUSED_POINTS
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::meshReader::calcPointCells() const void Foam::meshReader::calcPointCells() const
@ -46,7 +43,7 @@ void Foam::meshReader::calcPointCells() const
<< abort(FatalError); << abort(FatalError);
} }
label nPoints = points().size(); label nPoints = points_.size();
pointCellsPtr_ = new labelListList(nPoints); pointCellsPtr_ = new labelListList(nPoints);
labelListList& ptCells = *pointCellsPtr_; labelListList& ptCells = *pointCellsPtr_;
@ -132,19 +129,15 @@ void Foam::meshReader::calcPointCells() const
// report unused points // report unused points
if (nPoints > pointI) if (nPoints > pointI)
{ {
#ifdef LEAVE_UNUSED_POINTS
FatalErrorIn("meshReader::calcPointCells() const")
<< "mesh has " << (nPoints - pointI)
<< " points that were declared but not used" << endl;
#else
Info<< "removing " << (nPoints - pointI) << " unused points" << endl; Info<< "removing " << (nPoints - pointI) << " unused points" << endl;
nPoints = pointI; nPoints = pointI;
// adjust points and truncate // adjust points and truncate - bend const-ness
inplaceReorder(oldToNew, points()); pointField& adjustedPoints = const_cast<pointField&>(points_);
points().setSize(nPoints);
inplaceReorder(oldToNew, adjustedPoints);
adjustedPoints.setSize(nPoints);
// adjust pointCells and truncate // adjust pointCells and truncate
inplaceReorder(oldToNew, ptCells); inplaceReorder(oldToNew, ptCells);
@ -162,7 +155,6 @@ void Foam::meshReader::calcPointCells() const
inplaceRenumber(oldToNew, faces[i]); inplaceRenumber(oldToNew, faces[i]);
} }
} }
#endif
} }
} }

View File

@ -142,7 +142,7 @@ Foam::autoPtr<Foam::polyMesh> Foam::meshReader::mesh
"constant", "constant",
registry registry
), ),
points(), points_,
meshFaces_, meshFaces_,
cellPolys_ cellPolys_
) )

View File

@ -291,13 +291,6 @@ protected:
//- Subclasses are required to supply this information //- Subclasses are required to supply this information
virtual bool readGeometry(const scalar scaleFactor = 1.0) = 0; virtual bool readGeometry(const scalar scaleFactor = 1.0) = 0;
//- Return mesh points
pointField& points() const
{
return const_cast<pointField&>(points_);
}
public: public:
// Static Members // Static Members

View File

@ -180,6 +180,18 @@ public:
const bool syncPar = true const bool syncPar = true
); );
//- Construct from components without boundary.
// Boundary is added using addFvPatches() member function
fvMesh
(
const IOobject& io,
const xfer<pointField>& points,
const xfer<faceList>& faces,
const xfer<labelList>& allOwner,
const xfer<labelList>& allNeighbour,
const bool syncPar = true
);
//- Construct from components with cells rather than owner //- Construct from components with cells rather than owner
// and neighbourwithout boundary. // and neighbourwithout boundary.
// Boundary is added using addPatches() member function // Boundary is added using addPatches() member function
@ -192,6 +204,18 @@ public:
const bool syncPar = true const bool syncPar = true
); );
//- Construct from components with cells rather than owner
// and neighbourwithout boundary.
// Boundary is added using addPatches() member function
fvMesh
(
const IOobject& io,
const xfer<pointField>& points,
const xfer<faceList>& faces,
const xfer<cellList>& cells,
const bool syncPar = true
);
// Destructor // Destructor
@ -295,7 +319,7 @@ public:
virtual void updateMesh(const mapPolyMesh& mpm); virtual void updateMesh(const mapPolyMesh& mpm);
//- Move points, returns volumes swept by faces in motion //- Move points, returns volumes swept by faces in motion
virtual tmp<scalarField> movePoints(const vectorField&); virtual tmp<scalarField> movePoints(const pointField&);
//- Map all fields in time using given map. //- Map all fields in time using given map.
virtual void mapFields(const mapPolyMesh& mpm); virtual void mapFields(const mapPolyMesh& mpm);

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
quadraticFit Foam::quadraticFit
Description Description
Quadratic fit interpolation scheme which applies an explicit correction to Quadratic fit interpolation scheme which applies an explicit correction to
@ -56,8 +56,16 @@ class quadraticFit
public linear<Type> public linear<Type>
{ {
// Private Data // Private Data
//- Factor the fit is allowed to deviate from linear.
// This limits the amount of high-order correction and increases
// stability on bad meshes
const scalar linearLimitFactor_;
//- Weights for central stencil
const scalar centralWeight_; const scalar centralWeight_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
@ -79,6 +87,7 @@ public:
quadraticFit(const fvMesh& mesh, Istream& is) quadraticFit(const fvMesh& mesh, Istream& is)
: :
linear<Type>(mesh), linear<Type>(mesh),
linearLimitFactor_(readScalar(is)),
centralWeight_(readScalar(is)) centralWeight_(readScalar(is))
{} {}
@ -92,6 +101,7 @@ public:
) )
: :
linear<Type>(mesh), linear<Type>(mesh),
linearLimitFactor_(readScalar(is)),
centralWeight_(readScalar(is)) centralWeight_(readScalar(is))
{} {}
@ -123,6 +133,7 @@ public:
( (
mesh, mesh,
stencil, stencil,
linearLimitFactor_,
centralWeight_ centralWeight_
); );

View File

@ -41,16 +41,16 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
static int count = 0;
Foam::quadraticFitData::quadraticFitData Foam::quadraticFitData::quadraticFitData
( (
const fvMesh& mesh, const fvMesh& mesh,
const extendedCentredStencil& stencil, const extendedCentredStencil& stencil,
const scalar linearLimitFactor,
const scalar cWeight const scalar cWeight
) )
: :
MeshObject<fvMesh, quadraticFitData>(mesh), MeshObject<fvMesh, quadraticFitData>(mesh),
linearLimitFactor_(linearLimitFactor),
centralWeight_(cWeight), centralWeight_(cWeight),
# ifdef SPHERICAL_GEOMETRY # ifdef SPHERICAL_GEOMETRY
dim_(2), dim_(2),
@ -61,7 +61,7 @@ Foam::quadraticFitData::quadraticFitData
( (
dim_ == 1 ? 3 : dim_ == 1 ? 3 :
dim_ == 2 ? 6 : dim_ == 2 ? 6 :
dim_ == 3 ? 9 : 0 dim_ == 3 ? 7 : 0
), ),
fit_(mesh.nInternalFaces()) fit_(mesh.nInternalFaces())
{ {
@ -116,8 +116,6 @@ Foam::quadraticFitData::quadraticFitData
interpPolySize[faci] = calcFit(stencilPoints[faci], faci); interpPolySize[faci] = calcFit(stencilPoints[faci], faci);
} }
Pout<< "count = " << count << endl;
if (debug) if (debug)
{ {
Info<< "quadraticFitData::quadraticFitData() :" Info<< "quadraticFitData::quadraticFitData() :"
@ -243,14 +241,14 @@ Foam::label Foam::quadraticFitData::calcFit
{ {
B[ip][is++] = wts[ip]*py; B[ip][is++] = wts[ip]*py;
B[ip][is++] = wts[ip]*px*py; B[ip][is++] = wts[ip]*px*py;
B[ip][is++] = wts[ip]*sqr(py); //B[ip][is++] = wts[ip]*sqr(py);
} }
if (dim_ == 3) if (dim_ == 3)
{ {
B[ip][is++] = wts[ip]*pz; B[ip][is++] = wts[ip]*pz;
B[ip][is++] = wts[ip]*px*pz; B[ip][is++] = wts[ip]*px*pz;
//B[ip][is++] = wts[ip]*py*pz; //B[ip][is++] = wts[ip]*py*pz;
B[ip][is++] = wts[ip]*sqr(pz); //B[ip][is++] = wts[ip]*sqr(pz);
} }
} }
@ -274,15 +272,15 @@ Foam::label Foam::quadraticFitData::calcFit
//goodFit = (fit0 > 0 && fit1 > 0); //goodFit = (fit0 > 0 && fit1 > 0);
goodFit = goodFit =
(mag(fit0 - w[faci])/w[faci] < 0.15) (mag(fit0 - w[faci])/w[faci] < linearLimitFactor_)
&& (mag(fit1 - (1 - w[faci]))/(1 - w[faci]) < 0.15); && (mag(fit1 - (1 - w[faci]))/(1 - w[faci]) < linearLimitFactor_);
//scalar w0Err = fit0/w[faci]; //scalar w0Err = fit0/w[faci];
//scalar w1Err = fit1/(1 - w[faci]); //scalar w1Err = fit1/(1 - w[faci]);
//goodFit = //goodFit =
// (w0Err > 0.5 && w0Err < 1.5) // (w0Err > linearLimitFactor_ && w0Err < (1 + linearLimitFactor_))
// && (w1Err > 0.5 && w1Err < 1.5); // && (w1Err > linearLimitFactor_ && w1Err < (1 + linearLimitFactor_));
if (goodFit) if (goodFit)
{ {
@ -324,13 +322,6 @@ Foam::label Foam::quadraticFitData::calcFit
if (goodFit) if (goodFit)
{ {
if ((mag(fit_[faci][0] - w[faci])/w[faci] < 0.15)
&& (mag(fit_[faci][1] - (1 - w[faci]))/(1 - w[faci]) < 0.15))
{
count++;
//Pout<< "fit " << mag(fit_[faci][0] - w[faci])/w[faci] << " " << mag(fit_[faci][1] - (1 - w[faci]))/(1 - w[faci]) << endl;
}
// scalar limiter = // scalar limiter =
// max // max
// ( // (
@ -358,6 +349,7 @@ Foam::label Foam::quadraticFitData::calcFit
Pout<< "Could not fit face " << faci Pout<< "Could not fit face " << faci
<< " " << fit_[faci][0] << " " << w[faci] << " " << fit_[faci][0] << " " << w[faci]
<< " " << fit_[faci][1] << " " << 1 - w[faci]<< endl; << " " << fit_[faci][1] << " " << 1 - w[faci]<< endl;
fit_[faci] = 0; fit_[faci] = 0;
} }

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
quadraticFitData Foam::quadraticFitData
Description Description
Data for the quadratic fit correction interpolation scheme Data for the quadratic fit correction interpolation scheme
@ -56,13 +56,18 @@ class quadraticFitData
{ {
// Private data // Private data
//- weights for central stencil //- Factor the fit is allowed to deviate from linear.
// This limits the amount of high-order correction and increases
// stability on bad meshes
const scalar linearLimitFactor_;
//- Weights for central stencil
const scalar centralWeight_; const scalar centralWeight_;
//- dimensionality of the geometry //- Dimensionality of the geometry
const label dim_; const label dim_;
//- minimum stencil size //- Minimum stencil size
const label minSize_; const label minSize_;
//- For each cell in the mesh store the values which multiply the //- For each cell in the mesh store the values which multiply the
@ -96,19 +101,18 @@ public:
( (
const fvMesh& mesh, const fvMesh& mesh,
const extendedCentredStencil& stencil, const extendedCentredStencil& stencil,
scalar cWeightDim const scalar linearLimitFactor,
const scalar centralWeight
); );
// Destructor //- Destructor
virtual ~quadraticFitData()
virtual ~quadraticFitData() {}
{}
// Member functions // Member functions
//- Return reference to fit coefficients //- Return reference to fit coefficients
const List<scalarList>& fit() const const List<scalarList>& fit() const
{ {

View File

@ -163,18 +163,6 @@ colourPipe()
} }
#
# prefix message with [HOSTNAME]
#
prefixPipe()
{
while read line
do
echo "[$@] $line"
done
}
colourIndex=0 colourIndex=0
while : while :
@ -202,19 +190,15 @@ do
if [ "$host" = "$HOST" ]; then if [ "$host" = "$HOST" ]; then
eval $* 2>&1 | colourPipe "$colour" eval $* 2>&1 | colourPipe "$colour"
elif [ -n "$JOB_ID" ]; then
qrsh -inherit -v PWD $host "$rcmd"
else else
ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | colourPipe "$colour" ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | colourPipe "$colour"
fi fi
retval=$? retval=$?
else else
if [ "$host" = "$HOST" ]; then if [ "$host" = "$HOST" ]; then
eval $* 2>&1 | prefixPipe "$host" eval $* 2>&1
elif [ -n "$JOB_ID" ]; then
qrsh -inherit -v PWD $host "$rcmd" | prefixPipe "$host"
else else
ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | prefixPipe "$host" ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1
fi fi
retval=$? retval=$?
fi fi