diff --git a/applications/solvers/basic/potentialFoam/createFields.H b/applications/solvers/basic/potentialFoam/createFields.H index 7e228832568dd0d41d3e54b289c9381e84370daa..ef3b220257fbc7864f1fd2b9eb6481d09fa6af5c 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 8e4a12ee0d01af803b9a615c0852547c76bc0e9e..d2a1452f7287ab02e1b373a45cec134e3c0fb905 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" diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C index 92af69626cb4eb3e378ca85dd5cbfac05292c712..5285de5819647df4efc51a440a6af2a61d12e26b 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<faceList> patchFaceVerts; - labelList nrFaceCells(boundaryFaces.size(),0); - HashTable<label,label> faceToCell[2]; + labelList own(boundaryFaces.size(), -1); + labelList nei(boundaryFaces.size(), -1); + HashTable<label, label> faceToCell[2]; { HashTable<label, face, Hash<face> > faceToFaceID(boundaryFaces.size()); forAll(boundaryFaces, faceI) { - SortableList<label> foo(boundaryFaces[faceI]); - face theFace(foo); - faceToFaceID.insert(theFace,faceI); + SortableList<label> sortedVerts(boundaryFaces[faceI]); + faceToFaceID.insert(face(sortedVerts), faceI); } forAll(cellVerts, cellI) @@ -861,31 +861,57 @@ int main(int argc, char *argv[]) faceList faces = cellVerts[cellI].faces(); forAll(faces, i) { - SortableList<label> foo(faces[i]); - face theFace(foo); - if (faceToFaceID.found(theFace)) + SortableList<label> sortedVerts(faces[i]); + HashTable<label, face, Hash<face> >::const_iterator fnd = + faceToFaceID.find(face(sortedVerts)); + + if (fnd != faceToFaceID.end()) { - label faceI = faceToFaceID[theFace]; - if (nrFaceCells[faceI] < 2) + label faceI = fnd(); + int stat = face::compare(faces[i], boundaryFaces[faceI]); + + if (stat == 1) + { + // Same orientation. Cell is owner. + own[faceI] = cellI; + } + else if (stat == -1) { - faceToCell[nrFaceCells[faceI]].insert(faceI,cellI); + // Opposite orientation. Cell is neighbour. + nei[faceI] = cellI; } - nrFaceCells[faceI]++; } } } + label nReverse = 0; + forAll(own, faceI) + { + if (own[faceI] == -1 && nei[faceI] != -1) + { + // Boundary face with incorrect orientation + boundaryFaces[faceI] = boundaryFaces[faceI].reverseFace(); + Swap(own[faceI], nei[faceI]); + nReverse++; + } + } + if (nReverse > 0) + { + Info << "Found " << nReverse << " reversed boundary faces out of " + << boundaryFaces.size() << endl; + } + + label cnt = 0; - forAll(nrFaceCells, faceI) + forAll(own, faceI) { - assert(nrFaceCells[faceI] == 1 || nrFaceCells[faceI] == 2); - if (nrFaceCells[faceI]>1) + if (own[faceI] != -1 && nei[faceI] != -1) { cnt++; } } - if (cnt>0) + if (cnt > 0) { Info << "Of " << boundaryFaces.size() << " so-called" << " boundary faces " << cnt << " belong to two cells " @@ -994,7 +1020,8 @@ int main(int argc, char *argv[]) if (boundaryFaceToIndex.found(faceIndices[i])) { label bFaceI = boundaryFaceToIndex[faceIndices[i]]; - if (nrFaceCells[bFaceI] == 1) + + if (own[bFaceI] != -1 && nei[bFaceI] == -1) { patchFaces[cnt] = boundaryFaces[bFaceI]; cnt++; diff --git a/etc/controlDict b/etc/controlDict index 4f2a8814885645da47e5efe6b798c7114013ab3b..48edc0e71334cd8b3064262c2a106964ac7c39d6 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -912,7 +912,7 @@ DimensionedConstants } electromagnetic { - e e [ 0 0 -1 0 0 1 0 ] 1.60218e-19; + e e [ 0 0 1 0 0 1 0 ] 1.60218e-19; } atomic { @@ -942,7 +942,7 @@ DimensionedConstants } electromagnetic { - e e [ 0 0 -1 0 0 1 0 ] 1.60218e-19; + e e [ 0 0 1 0 0 1 0 ] 1.60218e-19; } atomic { diff --git a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C index 93d934a1b548c79df4965eb497ebc3906337b9c8..f04b9c1af6156208f4221cbcdf0a129ff3dc5a78 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<fileName, void*, Hash<void*> >() {} @@ -45,8 +43,6 @@ Foam::dlLibraryTable::dlLibraryTable const dictionary& dict, const word& libsEntry ) -: - HashTable<fileName, void*, Hash<void*> >() { 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]); + + libPtrs_[index] = NULL; + libNames_[index] = fileName::null; - if (!dlClose(libPtr)) + 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 f2925fe511e866e1a3821dff3b5dd7896dcdb46d..9d92fea15374371827d0a4d8611ab3398f8a7388 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<fileName, void*, Hash<void*> > { // Private Member Functions + DynamicList<void*> libPtrs_; + + DynamicList<fileName> libNames_; + + //- Disallow default bitwise copy construct dlLibraryTable(const dlLibraryTable&); diff --git a/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.C b/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.C index db1e4e6264d2bd6235b56c448af60352b0d05128..7013184a1f289a48b42866d1cab470c0a961aa60 100644 --- a/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.C +++ b/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.C @@ -44,7 +44,7 @@ const Foam::dimensionedScalar Foam::constant::electromagnetic::mu0 dimensionedScalar ( "mu0", - dimensionSet(1, 2, -1, 0, 0, -2, 0), + dimensionSet(1, 1, -2, 0, 0, -2, 0), 4.0*constant::mathematical::pi*1e-07 ) ) diff --git a/src/postProcessing/functionObjects/field/fieldAverage/controlDict b/src/postProcessing/functionObjects/field/fieldAverage/controlDict index b2a9d6b1bc8601f48c8dc18f50e298e9db0eb642..59e47148c8bfea2e7fc2c9af1f117964c11a701d 100644 --- a/src/postProcessing/functionObjects/field/fieldAverage/controlDict +++ b/src/postProcessing/functionObjects/field/fieldAverage/controlDict @@ -52,7 +52,7 @@ functions type fieldAverage; // Where to load it from (if not already in solver) - functionObjectLibs ("libfieldAverage.so"); + functionObjectLibs ("libfieldFunctionObjects.so"); // Function object enabled flag enabled true; diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H index ed90da9b1b7a0c36669a3a02013c158ac92c21a6..d9388764e0c05955432de8c7b5396dbf0a768a2f 100644 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H +++ b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H @@ -34,7 +34,7 @@ Description type fieldAverage; // Where to load it from (if not already in solver) - functionObjectLibs ("libfieldAverage.so"); + functionObjectLibs ("libfieldFunctionObjects.so"); // Whether to perform a clean restart, or start from previous // averaging info if available diff --git a/tutorials/incompressible/simpleFoam/motorBike/0.org/omega b/tutorials/incompressible/simpleFoam/motorBike/0.org/omega index 1d0b5ae1957da0f4d3df93896fb5c894738e0540..02cb50633b8cbd1118c4007785db885ba01f3fed 100644 --- a/tutorials/incompressible/simpleFoam/motorBike/0.org/omega +++ b/tutorials/incompressible/simpleFoam/motorBike/0.org/omega @@ -10,7 +10,7 @@ FoamFile version 2.0; format ascii; class volScalarField; - object epsilon; + object omega; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //