Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

This commit is contained in:
mattijs 2017-01-11 10:46:29 +00:00
commit fbc02a9172
11 changed files with 293 additions and 168 deletions

View File

@ -9,7 +9,7 @@ OpenFOAM is free software: you can redistribute it and/or modify it under the te
# OpenFOAM Trademark
OpenCFD Ltd grants use of the OpenFOAM trademark by Third Parties on a licence basis. ESI Group and the OpenFOAM Foundation Ltd are currently permitted to use the trademark. For information on trademark use, please refer to the [trademark policy guidelines](http://www.openfoam.com/legal/trademark-policy.php).
OpenCFD Ltd grants use of the OpenFOAM trademark by Third Parties on a licence basis. ESI Group and the OpenFOAM Foundation Ltd are currently permitted to use the Name and agreed Domain Name. For information on trademark use, please refer to the [trademark policy guidelines](http://www.openfoam.com/legal/trademark-policy.php).
Please [contact OpenCFD](http://www.openfoam.com/contact) if you have any questions on the use of the OpenFOAM trademark.

View File

@ -42,7 +42,7 @@ int main(int argc, char *argv[])
"def",
"ghi"
};
words = { "def", "ghi", "xy", "all", "begin", "all" };
words = { "def", "ghi", "xy", "all", "end", "all" };
wordHashSet setA
{
@ -84,6 +84,26 @@ int main(int argc, char *argv[])
Info<< "hashedWordList: " << words << nl
<< "with lookup: " << words.lookup() << endl;
{
List<word> input = { "def", "ghi", "xy", "all", "end", "all", "def" };
hashedWordList words1(input, true);
Info<< "input word list: " << input << nl
<< "without dup: " << words1 << endl;
Info<< "from wordHashSet: " << hashedWordList(setA) << endl;
Info<< "from HashTable: " << hashedWordList(tableA) << endl;
Info<< "from HashTable: " << hashedWordList(tableB) << endl;
// even this works
Info<< "from hashSet: "
<< hashedWordList
(
wordHashSet(setA)
| wordHashSet(tableA) | wordHashSet(tableB)
) << endl;
}
Info<< "wordHashSet: " << setA << endl;
Info<< "Table-HashSet: " << tableA << endl;
Info<< "Map<label>: " << mapA << endl;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,7 +40,7 @@ int main(int argc, char *argv[])
#include "createTime.H"
Info<< "Create mesh, no clear-out\n" << endl;
fvMesh mesh
polyMesh mesh
(
IOobject
(
@ -51,12 +51,11 @@ int main(int argc, char *argv[])
)
);
Info<< mesh.C() << endl;
Info<< mesh.V() << endl;
surfaceVectorField Cf = mesh.Cf();
Info<< Cf << endl;
Info<< "Cell centres" << nl << mesh.cellCentres() << endl;
Info<< "Cell volumes" << nl << mesh.cellVolumes() << endl;
Info<< "Cell shapes" << nl << mesh.cellShapes() << endl;
Info<< "Cell face centres" << nl << mesh.faceCentres() << endl;
// Test construct from cellShapes
{
@ -83,7 +82,7 @@ int main(int argc, char *argv[])
word defaultBoundaryPatchName = "defaultFaces";
word defaultBoundaryPatchType = emptyPolyPatch::typeName;
fvMesh newMesh
polyMesh newMesh
(
IOobject
(
@ -101,12 +100,10 @@ int main(int argc, char *argv[])
defaultBoundaryPatchType
);
Info<< newMesh.C() << endl;
Info<< newMesh.V() << endl;
surfaceVectorField Cf = newMesh.Cf();
Info<< Cf << endl;
Info<< "New cell centres" << nl << newMesh.cellCentres() << endl;
Info<< "New cell volumes" << nl << newMesh.cellVolumes() << endl;
Info<< "New cell shapes" << nl << newMesh.cellShapes() << endl;
Info<< "New cell face centres" << nl << newMesh.faceCentres() << endl;
}

View File

@ -43,4 +43,8 @@ namespace Foam
using ISLList = ILList<SLListBase, T>;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,94 +25,46 @@ License
#include "hashedWordList.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::hashedWordList::rehash()
{
indices_.clear();
forAll(*this, i)
{
indices_.insert(List<word>::operator[](i), i);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::hashedWordList::hashedWordList()
Foam::hashedWordList::hashedWordList
(
const label count,
const char** lst,
const bool removeDuplicates
)
:
List<word>()
{}
Foam::hashedWordList::hashedWordList(const UList<word>& names)
:
List<word>(names)
List<word>(count)
{
rehash();
}
forAll(*this, i)
{
List<word>::operator[](i) = lst[i];
}
Foam::hashedWordList::hashedWordList(const hashedWordList& names)
:
List<word>(static_cast<const UList<word>&>(names))
{
rehash();
}
Foam::hashedWordList::hashedWordList(const Xfer<List<word>>& names)
:
List<word>(names)
{
rehash();
}
Foam::hashedWordList::hashedWordList(std::initializer_list<word> lst)
:
List<word>(lst)
{
rehash();
rehash(removeDuplicates);
}
Foam::hashedWordList::hashedWordList
(
const label nNames,
const char** names
)
:
List<word>(nNames)
{
forAll(*this, i)
{
List<word>::operator[](i) = names[i];
}
rehash();
}
Foam::hashedWordList::hashedWordList
(
const char** names
const char** lst,
const bool removeDuplicates
)
{
// count names
label nNames = 0;
for (unsigned i = 0; names[i] && *(names[i]); ++i)
// Determine the number of entries
label count = 0;
for (unsigned i = 0; lst[i] && *(lst[i]); ++i)
{
++nNames;
++count;
}
List<word>::setSize(nNames);
List<word>::setSize(count);
forAll(*this, i)
{
List<word>::operator[](i) = names[i];
List<word>::operator[](i) = lst[i];
}
rehash();
rehash(removeDuplicates);
}
@ -124,59 +76,48 @@ Foam::hashedWordList::hashedWordList(Istream& is)
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::hashedWordList::clear()
{
List<word>::clear();
indices_.clear();
}
void Foam::hashedWordList::append(const word& name)
{
const label idx = size();
List<word>::append(name);
indices_.insert(name, idx);
}
void Foam::hashedWordList::transfer(List<word>& lst)
void Foam::hashedWordList::transfer
(
List<word>& lst,
const bool removeDuplicates
)
{
List<word>::transfer(lst);
rehash();
rehash(removeDuplicates);
}
void Foam::hashedWordList::sort()
void Foam::hashedWordList::rehash() const
{
Foam::sort(*this);
rehash();
indices_.clear();
forAll(*this, i)
{
indices_.insert(List<word>::operator[](i), i);
}
}
void Foam::hashedWordList::uniq()
{
if (size() != indices_.size())
indices_.clear();
label nElem = 0;
forAll(*this, i)
{
// sizes don't match, which means there appear to be duplicates
const word& item = List<word>::operator[](i);
indices_.clear();
label nElem = 0;
forAll(*this, i)
if (indices_.insert(item, nElem))
{
const word& item = List<word>::operator[](i);
if (indices_.insert(item, nElem))
if (nElem != i)
{
if (nElem != i)
{
List<word>::operator[](nElem) = item;
}
++nElem;
List<word>::operator[](nElem) = item;
}
++nElem;
}
List<word>::setSize(nElem);
}
List<word>::setSize(nElem);
}
@ -193,7 +134,7 @@ Foam::Istream& Foam::operator>>(Istream& is, hashedWordList& lst)
Foam::Ostream& Foam::operator<<(Ostream& os, const hashedWordList& lst)
{
os << static_cast<const List<word>&>(lst);
os << static_cast<const UList<word>&>(lst);
return os;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,7 +25,7 @@ Class
Foam::hashedWordList
Description
A wordList with hashed indices for faster lookup by name.
A wordList with hashed indices for additional fast lookup by name.
SourceFiles
hashedWordListI.H
@ -62,38 +62,64 @@ class hashedWordList
// Private data
//- Hash of words/indices
HashTable<label,word> indices_;
mutable HashTable<label,word> indices_;
// Private Member Functions
//- Rebuild the hash of indices
void rehash();
//- Rebuild the lookup hash or make unique entries first.
inline void rehash(const bool unique);
public:
// Constructors
//- Construct null
hashedWordList();
inline hashedWordList();
//- Copy constructor.
hashedWordList(const hashedWordList&);
inline hashedWordList(const hashedWordList& lst);
//- Construct from list of words
hashedWordList(const UList<word>&);
//- Construct from list of words,
// optionally eliminating duplicates
inline hashedWordList
(
const UList<word>& lst,
const bool removeDuplicates=false
);
//- Construct by transferring the parameter contents,
// optionally eliminating duplicates
inline hashedWordList
(
const Xfer<List<word>>& lst,
const bool removeDuplicates=false
);
//- Construct from an initializer list
hashedWordList(std::initializer_list<word>);
inline hashedWordList(std::initializer_list<word>);
//- Construct by transferring the parameter contents
hashedWordList(const Xfer<List<word>>&);
//- Construct from the word keys of any HashTable, sorting immediately.
// This also handles a wordHashSet, which is derived from a HashTable.
// The result is similar to a HashTable::sortedToc.
template<class AnyType, class AnyHash>
explicit inline hashedWordList
(
const HashTable<AnyType, word, AnyHash>& h
);
//- Construct from number and list of names
hashedWordList(const label nNames, const char** names);
//- Construct from number and list of words,
// optionally eliminating duplicates
hashedWordList
(
const label count,
const char** lst,
const bool removeDuplicates=false
);
//- Construct from a nullptr-terminated list of names
hashedWordList(const char** names);
//- Construct from a nullptr-terminated list of words,
// optionally eliminating duplicates
hashedWordList(const char** lst, const bool removeDuplicates=false);
//- Construct from Istream
hashedWordList(Istream&);
@ -102,47 +128,53 @@ public:
// Member Functions
//- Clear the list, i.e. set size to zero.
void clear();
inline void clear();
//- Append an element at the end of the list
void append(const word&);
//- Append an element at the end of the list,
// optionally avoid append if it would be a duplicate entry
inline void append(const word& name, const bool avoidDuplicates=false);
//- Does the list contain the specified name
inline bool found(const word&) const;
inline bool found(const word& name) const;
//- Does the list contain the specified name
inline bool contains(const word&) const;
inline bool contains(const word& name) const;
//- Return the hash of words/indices for inspection
inline const HashTable<label,word>& lookup() const;
//- Transfer the contents of the argument List into this list
// and annul the argument list.
void transfer(List<word>&);
// and annul the argument list,
// optionally eliminating duplicates
void transfer(List<word>& lst, const bool removeDuplicates=false);
//- Rebuild the lookup hash indices
void rehash() const;
//- Sort the list and rehash the indices
void sort();
inline void sort();
//- Adjust the list if necessary to eliminate duplicate entries
//- Adjust the list if necessary to eliminate duplicate entries,
// and rehash the indices
void uniq();
// Member Operators
//- Assignment operator from list of words
inline void operator=(const UList<word>&);
inline void operator=(const UList<word>& lst);
//- Assignment operator from initializer list
inline void operator=(std::initializer_list<word>);
inline void operator=(std::initializer_list<word> lst);
//- Assignment operator.
inline void operator=(const hashedWordList&);
inline void operator=(const hashedWordList& lst);
//- Return name corresponding to specified index
inline const word& operator[](const label index) const;
//- Return index corresponding to specified name
inline label operator[](const word&) const;
inline label operator[](const word& name) const;
// Istream operators

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,8 +23,117 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline void Foam::hashedWordList::rehash(const bool unique)
{
if (unique)
{
uniq();
}
else
{
rehash();
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::hashedWordList::hashedWordList()
:
List<word>(),
indices_()
{}
inline Foam::hashedWordList::hashedWordList(const hashedWordList& lst)
:
List<word>(static_cast<const UList<word>&>(lst))
{
rehash();
}
inline Foam::hashedWordList::hashedWordList
(
const UList<word>& lst,
const bool removeDuplicates
)
:
List<word>(lst)
{
rehash(removeDuplicates);
}
inline Foam::hashedWordList::hashedWordList
(
const Xfer<List<word>>& lst,
const bool removeDuplicates
)
:
List<word>(lst)
{
rehash(removeDuplicates);
}
inline Foam::hashedWordList::hashedWordList(std::initializer_list<word> lst)
:
List<word>(lst)
{
rehash();
}
template<class AnyType, class AnyHash>
inline Foam::hashedWordList::hashedWordList
(
const HashTable<AnyType, word, AnyHash>& h
)
:
List<word>(h.size())
{
label nElem = 0;
for
(
typename HashTable<AnyType, word, AnyHash>::const_iterator
iter = h.cbegin();
iter != h.cend();
++iter
)
{
List<word>::operator[](nElem++) = iter.key();
}
this->sort();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline void Foam::hashedWordList::clear()
{
List<word>::clear();
indices_.clear();
}
inline void Foam::hashedWordList::append
(
const word& name,
const bool avoidDuplicates
)
{
// name is either unique or we don't care about duplicates
if (indices_.insert(name, size()) || !avoidDuplicates)
{
List<word>::append(name);
}
}
inline const Foam::HashTable<Foam::label,Foam::word>&
Foam::hashedWordList::lookup() const
{
@ -44,6 +153,13 @@ inline bool Foam::hashedWordList::contains(const word& name) const
}
inline void Foam::hashedWordList::sort()
{
Foam::sort(*this);
rehash();
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void Foam::hashedWordList::operator=(const UList<word>& lst)
@ -75,9 +191,9 @@ inline const Foam::word& Foam::hashedWordList::operator[]
}
// could return -1 instead of bombing out
inline Foam::label Foam::hashedWordList::operator[](const word& name) const
{
// Could return -1 instead of bombing out
return indices_[name];
}

View File

@ -25,7 +25,7 @@ Class
Foam::fixedNormalInletOutletVelocityFvPatchVectorField
Group
grpInletletBoundaryConditions grpOutletBoundaryConditions
grpInletBoundaryConditions grpOutletBoundaryConditions
Description
This velocity inlet/outlet boundary condition combines a fixed normal

View File

@ -25,7 +25,7 @@ Class
Foam::pressureInletOutletVelocityFvPatchVectorField
Group
grpInletletBoundaryConditions grpOutletBoundaryConditions
grpInletBoundaryConditions grpOutletBoundaryConditions
Description
This velocity inlet/outlet boundary condition is applied to pressure
@ -49,7 +49,7 @@ Usage
type pressureInletOutletVelocity;
phi phi;
tangentialVelocity uniform (0 0 0);
value uniform 0;
value uniform (0 0 0);
}
\endverbatim

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -311,6 +311,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::initialisePatch()
// Determine if all eddies spawned from a single processor
singleProc_ = patch.size() == returnReduce(patch.size(), sumOp<label>());
reduce(singleProc_, orOp<bool>());
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -758,6 +758,28 @@ void Foam::meshToMesh::constructFromCuttingPatches
const wordList& cuttingPatches
)
{
const polyBoundaryMesh& srcBm = srcRegion_.boundaryMesh();
const polyBoundaryMesh& tgtBm = tgtRegion_.boundaryMesh();
// set IDs of cutting patches
cuttingPatches_.setSize(cuttingPatches.size());
forAll(cuttingPatches_, i)
{
const word& patchName = cuttingPatches[i];
label cuttingPatchi = srcBm.findPatchID(patchName);
if (cuttingPatchi == -1)
{
FatalErrorInFunction
<< "Unable to find patch '" << patchName
<< "' in mesh '" << srcRegion_.name() << "'. "
<< " Available patches include:" << srcBm.names()
<< exit(FatalError);
}
cuttingPatches_[i] = cuttingPatchi;
}
DynamicList<label> srcIDs(patchMap.size());
DynamicList<label> tgtIDs(patchMap.size());
@ -766,14 +788,14 @@ void Foam::meshToMesh::constructFromCuttingPatches
const word& tgtPatchName = iter.key();
const word& srcPatchName = iter();
const polyPatch& srcPatch = srcRegion_.boundaryMesh()[srcPatchName];
const polyPatch& srcPatch = srcBm[srcPatchName];
// We want to map all the global patches, including constraint
// patches (since they might have mappable properties, e.g.
// jumpCyclic). We'll fix the value afterwards.
if (!isA<processorPolyPatch>(srcPatch))
{
const polyPatch& tgtPatch = tgtRegion_.boundaryMesh()[tgtPatchName];
const polyPatch& tgtPatch = tgtBm[tgtPatchName];
srcIDs.append(srcPatch.index());
tgtIDs.append(tgtPatch.index());
@ -788,14 +810,6 @@ void Foam::meshToMesh::constructFromCuttingPatches
// calculate patch addressing and weights
calculatePatchAMIs(AMIMethodName);
// set IDs of cutting patches on target mesh
cuttingPatches_.setSize(cuttingPatches.size());
forAll(cuttingPatches_, i)
{
const word& patchName = cuttingPatches[i];
cuttingPatches_[i] = tgtRegion_.boundaryMesh().findPatchID(patchName);
}
}