Commit 371903eb authored by mattijs's avatar mattijs
Browse files

Merge branch 'master' of /home/noisy3/OpenFOAM/OpenFOAM-dev

parents de2a74b2 6ce8e7d0
......@@ -43,31 +43,33 @@ using namespace Foam;
int main(int argc, char *argv[])
{
List<vector> list(IStringStream("1 ((0 1 2))")());
Info<< list << endl;
List<vector> list1(IStringStream("1 ((0 1 2))")());
Info<< "list1: " << list1 << endl;
List<vector> list2(IStringStream("((0 1 2) (3 4 5) (6 7 8))")());
Info<< list2 << endl;
Info<< "list2: " << list2 << endl;
list1.append(list2);
Info<< "list1.append(list2): " << list1 << endl;
Info<< findIndex(list2, vector(3, 4, 5)) << endl;
list2.setSize(10, vector(1, 2, 3));
Info<< list2 << endl;
Info<< "list2: " << list2 << endl;
List<vector> list3(list2.xfer());
Info<< "Transferred via the xfer() method" << endl;
Info<< list2 << nl
<< list3 << endl;
Info<< "list2: " << list2 << nl
<< "list3: " << list3 << endl;
// Subset
const labelList map(IStringStream("2 (0 2)")());
List<vector> subList3(list3, map);
Info<< "Elements " << map << " out of " << list3
<< " : " << subList3 << endl;
<< " => " << subList3 << endl;
return 0;
}
// ************************************************************************* //
......@@ -115,15 +115,13 @@ int main(int argc, char *argv[])
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
if (scaleFactor > 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
Info<< " with scaling " << scaleFactor;
surf.scalePoints(scaleFactor);
}
Info<< endl;
surf.write(exportName, sortByRegion);
Info<< "\nEnd\n" << endl;
......
......@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
argList::noParallel();
argList::validArgs.append("inputFile");
argList::validArgs.append("outputFile");
argList::validOptions.insert("clean", "scale");
argList::validOptions.insert("clean", "");
argList::validOptions.insert("scaleIn", "scale");
argList::validOptions.insert("scaleOut", "scale");
argList::validOptions.insert("dict", "coordinateSystemsDict");
......
......@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
argList::noParallel();
argList::validArgs.append("outputFile");
argList::validOptions.insert("name", "name");
argList::validOptions.insert("clean", "scale");
argList::validOptions.insert("clean", "");
argList::validOptions.insert("scaleIn", "scale");
argList::validOptions.insert("scaleOut", "scale");
argList::validOptions.insert("dict", "coordinateSystemsDict");
......
......@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
argList::noParallel();
argList::validArgs.append("inputFile");
argList::validOptions.insert("name", "name");
argList::validOptions.insert("clean", "scale");
argList::validOptions.insert("clean", "");
argList::validOptions.insert("scaleIn", "scale");
argList::validOptions.insert("scaleOut", "scale");
argList::validOptions.insert("dict", "coordinateSystemsDict");
......
......@@ -404,6 +404,61 @@ void Foam::List<T>::clear()
}
template<class T>
void Foam::List<T>::append(const UList<T>& lst)
{
if (this == &lst)
{
FatalErrorIn
(
"List<T>::append(const UList<T>&)"
) << "attempted appending to self" << abort(FatalError);
}
label nextFree = this->size_;
setSize(nextFree + lst.size());
forAll(lst, elemI)
{
this->operator[](nextFree++) = lst[elemI];
}
}
template<class T>
void Foam::List<T>::append(const UIndirectList<T>& lst)
{
label nextFree = this->size_;
setSize(nextFree + lst.size());
forAll(lst, elemI)
{
this->operator[](nextFree++) = lst[elemI];
}
}
template<class T>
void Foam::List<T>::append(const SLList<T>& lst)
{
if (lst.size())
{
label nextFree = this->size_;
setSize(nextFree + lst.size());
for
(
typename SLList<T>::const_iterator iter = lst.begin();
iter != lst.end();
++iter
)
{
this->operator[](nextFree++) = iter();
}
}
}
// Transfer the contents of the argument List into this List
// and anull the argument list
template<class T>
......@@ -559,12 +614,9 @@ void Foam::List<T>::operator=(const IndirectList<T>& lst)
if (this->size_) this->v_ = new T[this->size_];
}
if (this->size_)
forAll(*this, i)
{
forAll(*this, i)
{
this->operator[](i) = lst[i];
}
this->operator[](i) = lst[i];
}
}
......@@ -581,12 +633,9 @@ void Foam::List<T>::operator=(const UIndirectList<T>& lst)
if (this->size_) this->v_ = new T[this->size_];
}
if (this->size_)
forAll(*this, i)
{
forAll(*this, i)
{
this->operator[](i) = lst[i];
}
this->operator[](i) = lst[i];
}
}
......@@ -603,12 +652,9 @@ void Foam::List<T>::operator=(const BiIndirectList<T>& lst)
if (this->size_) this->v_ = new T[this->size_];
}
if (this->size_)
forAll(*this, i)
{
forAll(*this, i)
{
this->operator[](i) = lst[i];
}
this->operator[](i) = lst[i];
}
}
......
......@@ -109,7 +109,7 @@ public:
List(const List<T>&);
//- Construct by transferring the parameter contents
List(const Xfer<List<T> >&);
List(const Xfer< List<T> >&);
//- Construct as copy or re-use as specified.
List(List<T>&, bool reUse);
......@@ -181,6 +181,15 @@ public:
//- Clear the list, i.e. set size to zero.
void clear();
//- Append a List at the end of this list
void append(const UList<T>&);
//- Append a UIndirectList at the end of this list
void append(const UIndirectList<T>&);
//- Append a SLList at the end of this list
void append(const SLList<T>&);
//- Transfer the contents of the argument List into this List
// and annull the argument list.
void transfer(List<T>&);
......@@ -195,7 +204,7 @@ public:
void transfer(SortableList<T>&);
//- Transfer contents to the Xfer container
inline Xfer<List<T> > xfer();
inline Xfer< List<T> > xfer();
//- Return subscript-checked element of UList.
inline T& newElmt(const label);
......
......@@ -26,7 +26,7 @@ Class
Foam::PackedList
Description
A Dynamically allocatable list of packed unsigned ints.
A dynamically allocatable list of packed unsigned integers.
The list resizing is similar to DynamicList, thus the methods clear()
and setSize() behave like their DynamicList counterparts and the methods
......@@ -38,7 +38,7 @@ Note
In a const context, the '[]' operator simply returns the stored value,
with out-of-range elements returned as zero.
In a non-const context, the '[]' operator returns an iteratorBase, which
may not have a valid reference for out-of-range elements.
might not have a valid reference for out-of-range elements.
The iteratorBase class handles the assignment of new values.
Using the iteratorBase as a proxy allows assignment of values
......@@ -50,11 +50,11 @@ Note
@endcode
Using get() or the '[]' operator are similarly fast. Looping and reading
with an iterator is approx. 15% slower, but can be more flexible.
via an iterator is approx. 15% slower, but can be more flexible.
Using the set() operator (and the '[]' operator) are marginally slower
(approx. 5%) than using an iterator, but the set() method has an
advantage that it also returns a bool if the value changed. This can be
(approx. 5%) than using an iterator, but the set() method has the
advantage of also returning a bool if the value changed. This can be
useful for branching on changed values.
@code
......@@ -65,7 +65,7 @@ Note
The lazy evaluation used means that reading an out-of-range element
returns zero, but does not affect the list size. Even in a non-const
context, only the assigment causes the element to be created.
context, only the assigment itself causes the element to be created.
For example,
@code
list.resize(4);
......@@ -171,7 +171,7 @@ public:
inline PackedList(const PackedList<nBits>&);
//- Construct by transferring the parameter contents
inline PackedList(const Xfer<PackedList<nBits> >&);
inline PackedList(const Xfer< PackedList<nBits> >&);
//- Construct from a list of labels
PackedList(const UList<label>&);
......@@ -240,7 +240,6 @@ public:
//- Reserve allocation space for at least this size.
// Never shrinks the allocated size.
// Optionally provide an initialization value for new elements.
inline void reserve(const label);
//- Clear the list, i.e. set addressable size to zero.
......@@ -258,7 +257,7 @@ public:
inline void transfer(PackedList<nBits>&);
//- Transfer contents to the Xfer container
inline Xfer<PackedList<nBits> > xfer();
inline Xfer< PackedList<nBits> > xfer();
// Member operators
......@@ -413,7 +412,7 @@ public:
//- iterator set to the beginning of the PackedList
inline iterator begin();
//- iterator set to beyond the end of the HashTable
//- iterator set to beyond the end of the PackedList
inline iterator end();
......
......@@ -134,7 +134,7 @@ Foam::label Foam::solution::upgradeSolverDict
// write out information to help people adjust to the new syntax
if (verbose)
if (verbose && Pstream::master())
{
Info<< "// using new solver syntax:\n"
<< iter().keyword() << subdict << endl;
......
......@@ -64,8 +64,8 @@ tmp<volScalarField> autoCreateAlphat
}
else
{
Info<< "--> Upgrading " << fieldName << " to employ run-time "
<< "selectable wall functions" << endl;
Info<< "--> Creating " << fieldName
<< " to employ run-time selectable wall functions" << endl;
const fvBoundaryMesh& bm = mesh.boundary();
......@@ -104,7 +104,7 @@ tmp<volScalarField> autoCreateAlphat
)
);
Info<< " Writing updated " << fieldName << endl;
Info<< " Writing new " << fieldName << endl;
alphat().write();
return alphat;
......@@ -134,8 +134,8 @@ tmp<volScalarField> autoCreateMut
}
else
{
Info<< "--> Upgrading " << fieldName << " to employ run-time "
<< "selectable wall functions" << endl;
Info<< "--> Creating " << fieldName
<< " to employ run-time selectable wall functions" << endl;
const fvBoundaryMesh& bm = mesh.boundary();
......@@ -174,7 +174,7 @@ tmp<volScalarField> autoCreateMut
)
);
Info<< " Writing updated " << fieldName << endl;
Info<< " Writing new " << fieldName << endl;
mut().write();
return mut;
......
......@@ -26,6 +26,7 @@ License
#include "backwardsCompatibilityWallFunctions.H"
#include "Time.H"
#include "OSspecific.H"
#include "wallPolyPatch.H"
......@@ -77,27 +78,35 @@ autoCreateWallFunctionField
}
else
{
Info<< "--> Upgrading " << fieldName << " to employ run-time "
<< "selectable wall functions" << endl;
Info<< "--> Upgrading " << fieldName
<< " to employ run-time selectable wall functions" << endl;
// Read existing field
IOobject ioObj
(
fieldName,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
// Read existing epsilon field
tmp<fieldType> fieldOrig
(
new fieldType
(
IOobject
(
fieldName,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
),
ioObj,
mesh
)
);
// rename file
Info<< " Backup original " << fieldName << " to "
<< fieldName << ".old" << endl;
mv(ioObj.objectPath(), ioObj.objectPath() + ".old");
PtrList<fvPatchField<Type> > newPatchFields(mesh.boundary().size());
forAll(newPatchFields, patchI)
......@@ -145,11 +154,6 @@ autoCreateWallFunctionField
)
);
Info<< " Writing backup of original " << fieldName << " to "
<< fieldName << ".old" << endl;
fieldOrig().rename(fieldName + ".old");
fieldOrig().write();
Info<< " Writing updated " << fieldName << endl;
fieldNew().write();
......
......@@ -63,8 +63,8 @@ tmp<volScalarField> autoCreateNut
}
else
{
Info<< "--> Upgrading " << fieldName << " to employ run-time "
<< "selectable wall functions" << endl;
Info<< "--> Creating " << fieldName
<< " to employ run-time selectable wall functions" << endl;
const fvBoundaryMesh& bm = mesh.boundary();
......@@ -103,7 +103,7 @@ tmp<volScalarField> autoCreateNut
)
);
Info<< " Writing updated " << fieldName << endl;
Info<< " Writing new " << fieldName << endl;
nut().write();
return nut;
......
......@@ -26,6 +26,7 @@ License
#include "backwardsCompatibilityWallFunctions.H"
#include "Time.H"
#include "OSspecific.H"
#include "wallPolyPatch.H"
......@@ -77,27 +78,35 @@ autoCreateWallFunctionField
}
else
{
Info<< "--> Upgrading " << fieldName << " to employ run-time "
<< "selectable wall functions" << endl;
Info<< "--> Upgrading " << fieldName
<< " to employ run-time selectable wall functions" << endl;
// Read existing field
IOobject ioObj
(
fieldName,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
// Read existing epsilon field
tmp<fieldType> fieldOrig
(
new fieldType
(
IOobject
(
fieldName,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
),
ioObj,
mesh
)
);
// rename file
Info<< " Backup original " << fieldName << " to "
<< fieldName << ".old" << endl;
mv(ioObj.objectPath(), ioObj.objectPath() + ".old");
PtrList<fvPatchField<Type> > newPatchFields(mesh.boundary().size());
forAll(newPatchFields, patchI)
......@@ -145,11 +154,6 @@ autoCreateWallFunctionField
)
);
Info<< " Writing backup of original " << fieldName << " to "
<< fieldName << ".old" << endl;
fieldOrig().rename(fieldName + ".old");
fieldOrig().write();
Info<< " Writing updated " << fieldName << endl;
fieldNew().write();
......
Supports Markdown
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