From 319292bc2cba9ce3598fb8dc0fa4c46edaa5942b Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 1 Aug 2011 15:36:04 +0100 Subject: [PATCH 1/7] ENH: potentialFoam: add initialiseUBCs option --- applications/solvers/basic/potentialFoam/createFields.H | 6 ++++++ applications/solvers/basic/potentialFoam/potentialFoam.C | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/applications/solvers/basic/potentialFoam/createFields.H b/applications/solvers/basic/potentialFoam/createFields.H index 7e22883256..ef3b220257 100644 --- a/applications/solvers/basic/potentialFoam/createFields.H +++ b/applications/solvers/basic/potentialFoam/createFields.H @@ -44,6 +44,12 @@ fvc::interpolate(U) & mesh.Sf() ); + if (args.optionFound("initialiseUBCs")) + { + U.correctBoundaryConditions(); + phi = fvc::interpolate(U) & mesh.Sf(); + } + label pRefCell = 0; scalar pRefValue = 0.0; diff --git a/applications/solvers/basic/potentialFoam/potentialFoam.C b/applications/solvers/basic/potentialFoam/potentialFoam.C index 8e4a12ee0d..d2a1452f72 100644 --- a/applications/solvers/basic/potentialFoam/potentialFoam.C +++ b/applications/solvers/basic/potentialFoam/potentialFoam.C @@ -38,6 +38,11 @@ Description int main(int argc, char *argv[]) { argList::addBoolOption("writep", "write the final pressure field"); + argList::addBoolOption + ( + "initialiseUBCs", + "initialise U boundary conditions" + ); #include "setRootCase.H" #include "createTime.H" From ba46d43be70d33472f798b879167063ff194e6e6 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 2 Aug 2011 12:50:14 +0100 Subject: [PATCH 2/7] BUG: dlLibraryTable: guarantee dlclose order opposite of dlopen order --- .../dlLibraryTable/dlLibraryTable.C | 62 ++++++++++++------- .../dlLibraryTable/dlLibraryTable.H | 10 +-- .../dlLibraryTable/dlLibraryTableTemplates.C | 4 +- 3 files changed, 48 insertions(+), 28 deletions(-) diff --git a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C index 93d934a1b5..f04b9c1af6 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C +++ b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C @@ -35,8 +35,6 @@ defineTypeNameAndDebug(Foam::dlLibraryTable, 0); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::dlLibraryTable::dlLibraryTable() -: - HashTable >() {} @@ -45,8 +43,6 @@ Foam::dlLibraryTable::dlLibraryTable const dictionary& dict, const word& libsEntry ) -: - HashTable >() { open(dict, libsEntry); } @@ -56,17 +52,18 @@ Foam::dlLibraryTable::dlLibraryTable Foam::dlLibraryTable::~dlLibraryTable() { - forAllConstIter(dlLibraryTable, *this, iter) + forAllReverse(libPtrs_, i) { - // bug in dlclose - does not call static destructors of - // loaded library when actually unloading the library. - // See https://bugzilla.novell.com/show_bug.cgi?id=680125 and 657627. - if (debug) + if (libPtrs_[i]) { - Info<< "dlLibraryTable::~dlLibraryTable() : closing " << iter() - << " with handle " << long(iter.key()) << endl; + if (debug) + { + Info<< "dlLibraryTable::~dlLibraryTable() : closing " + << libNames_[i] + << " with handle " << long(libPtrs_[i]) << endl; + } + dlClose(libPtrs_[i]); } - dlClose(iter.key()); } } @@ -95,7 +92,7 @@ bool Foam::dlLibraryTable::open { WarningIn ( - "dlLibraryTable::open(const fileName&)" + "dlLibraryTable::open(const fileName&, const bool)" ) << "could not load " << functionLibName << endl; } @@ -104,7 +101,9 @@ bool Foam::dlLibraryTable::open } else { - return insert(functionLibPtr, functionLibName); + libPtrs_.append(functionLibPtr); + libNames_.append(functionLibName); + return true; } } else @@ -120,18 +119,30 @@ bool Foam::dlLibraryTable::close const bool verbose ) { - void* libPtr = findLibrary(functionLibName); - if (libPtr) + label index = -1; + forAllReverse(libNames_, i) + { + if (libNames_[i] == functionLibName) + { + index = i; + break; + } + } + + if (index != -1) { if (debug) { Info<< "dlLibraryTable::close : closing " << functionLibName - << " with handle " << long(libPtr) << endl; + << " with handle " << long(libPtrs_[index]) << endl; } - erase(libPtr); + bool ok = dlClose(libPtrs_[index]); - if (!dlClose(libPtr)) + libPtrs_[index] = NULL; + libNames_[index] = fileName::null; + + if (!ok) { if (verbose) { @@ -153,13 +164,20 @@ bool Foam::dlLibraryTable::close void* Foam::dlLibraryTable::findLibrary(const fileName& functionLibName) { - forAllConstIter(dlLibraryTable, *this, iter) + label index = -1; + forAllReverse(libNames_, i) { - if (iter() == functionLibName) + if (libNames_[i] == functionLibName) { - return iter.key(); + index = i; + break; } } + + if (index != -1) + { + return libPtrs_[index]; + } return NULL; } diff --git a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.H b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.H index f2925fe511..9d92fea153 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.H +++ b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.H @@ -36,8 +36,7 @@ SourceFiles #define dlLibraryTable_H #include "label.H" -#include "Hash.H" -#include "HashTable.H" +#include "DynamicList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,11 +48,14 @@ namespace Foam \*---------------------------------------------------------------------------*/ class dlLibraryTable -: - public HashTable > { // Private Member Functions + DynamicList libPtrs_; + + DynamicList libNames_; + + //- Disallow default bitwise copy construct dlLibraryTable(const dlLibraryTable&); diff --git a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTableTemplates.C b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTableTemplates.C index 13a9ae919f..46966e37d6 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTableTemplates.C +++ b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTableTemplates.C @@ -62,8 +62,8 @@ bool Foam::dlLibraryTable::open WarningIn ( "dlLibraryTable::open" - "(const dictionary& dict, const word& libsEntry, " - "const TablePtr tablePtr)" + "(const dictionary&, const word&, " + "const TablePtr&)" ) << "library " << libName << " did not introduce any new entries" << endl << endl; From cb5796df09bb0ad3de08db52701b6f369a2911a9 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 2 Aug 2011 21:48:32 +0100 Subject: [PATCH 3/7] ENH: ideasUnvToFoam: handle reversed boundary faces. --- .../ideasUnvToFoam/ideasUnvToFoam.C | 63 +++++++++++++------ 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C index 92af69626c..5285de5819 100644 --- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C @@ -844,16 +844,16 @@ int main(int argc, char *argv[]) List patchFaceVerts; - labelList nrFaceCells(boundaryFaces.size(),0); - HashTable faceToCell[2]; + labelList own(boundaryFaces.size(), -1); + labelList nei(boundaryFaces.size(), -1); + HashTable faceToCell[2]; { HashTable > faceToFaceID(boundaryFaces.size()); forAll(boundaryFaces, faceI) { - SortableList