From 5924a7410804c50d1ddceaa50ae900b2a35d1786 Mon Sep 17 00:00:00 2001 From: graham Date: Thu, 13 May 2010 18:50:07 +0100 Subject: [PATCH 01/22] ENH: New WallInteractionSite class to pass wall data to wall model. Access and lookup to/of UName. --- .../basic/InteractionLists/InteractionLists.H | 7 +- .../InteractionLists/InteractionListsI.H | 7 + .../PairCollision/PairCollision.C | 13 +- .../PairCollision/PairCollision.H | 1 + .../WallInteractionSite/WallInteractionSite.C | 121 +++++++++++++++ .../WallInteractionSite/WallInteractionSite.H | 144 ++++++++++++++++++ .../WallInteractionSiteI.H | 60 ++++++++ .../WallInteractionSiteIO.C | 82 ++++++++++ 8 files changed, 430 insertions(+), 5 deletions(-) create mode 100644 src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.C create mode 100644 src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.H create mode 100644 src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteI.H create mode 100644 src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteIO.C diff --git a/src/lagrangian/basic/InteractionLists/InteractionLists.H b/src/lagrangian/basic/InteractionLists/InteractionLists.H index 77da111828..8382c77bd7 100644 --- a/src/lagrangian/basic/InteractionLists/InteractionLists.H +++ b/src/lagrangian/basic/InteractionLists/InteractionLists.H @@ -287,10 +287,13 @@ public: wallFaceIndexAndTransformToDistribute() const; //- Return access to the referred wall faces - const List& referredWallFaces() const; + inline const List& referredWallFaces() const; + + //- Return the name of the velocity field + inline const word& UName() const; //- Return access to the referred wall data - const List& referredWallData() const; + inline const List& referredWallData() const; //- Return access to the referred particle container inline const List >& diff --git a/src/lagrangian/basic/InteractionLists/InteractionListsI.H b/src/lagrangian/basic/InteractionLists/InteractionListsI.H index ad28f696c5..1b61942f5e 100644 --- a/src/lagrangian/basic/InteractionLists/InteractionListsI.H +++ b/src/lagrangian/basic/InteractionLists/InteractionListsI.H @@ -128,6 +128,13 @@ Foam::InteractionLists::referredWallFaces() const } +template +const Foam::word& Foam::InteractionLists::UName() const +{ + return UName_; +} + + template const Foam::List& Foam::InteractionLists::referredWallData() const diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C index 967acf0640..27a165c88c 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C @@ -175,6 +175,10 @@ void Foam::PairCollision::wallInteraction() const labelListList directWallFaces = il_.dwfil(); + const labelList& patchID = mesh.boundaryMesh().patchID(); + + const volVectorField& U = mesh.lookupObject(il_.UName()); + // Storage for the wall interaction sites DynamicList flatSites; DynamicList flatSiteExclusionDistancesSqr; @@ -199,7 +203,7 @@ void Foam::PairCollision::wallInteraction() sharpSiteExclusionDistancesSqr.clear(); typename CloudType::parcelType& p = - *cellOccupancy_[realCellI][cellParticleI]; + *cellOccupancy_[realCellI][cellParticleI]; const point& pos = p.position(); @@ -269,8 +273,10 @@ void Foam::PairCollision::wallInteraction() forAll(cellRefWallFaces, rWFI) { + label refWallFaceI = cellRefWallFaces[rWFI]; + const referredWallFace& rwf = - il_.referredWallFaces()[cellRefWallFaces[rWFI]]; + il_.referredWallFaces()[refWallFaceI]; const pointField& pts = rwf.points(); @@ -502,7 +508,8 @@ Foam::PairCollision::PairCollision ( owner.mesh(), readScalar(this->coeffDict().lookup("maxInteractionDistance")), - Switch(this->coeffDict().lookup("writeReferredParticleCloud")) + Switch(this->coeffDict().lookup("writeReferredParticleCloud")), + this->coeffDict().lookupOrDefault("UName", word("U")) ) {} diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H index 8582db464e..588f08addd 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H @@ -36,6 +36,7 @@ SourceFiles #include "CollisionModel.H" #include "InteractionLists.H" +#include "WallInteractionSite.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.C new file mode 100644 index 0000000000..8dce24bb08 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.C @@ -0,0 +1,121 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "WallInteractionSite.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::WallInteractionSite::WallInteractionSite() +: + patchI_(), + wallData_() +{} + + +template +Foam::WallInteractionSite::WallInteractionSite +( + label patchI, + const Type& wallData +) +: + patchI_(patchI), + wallData_(wallData) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::WallInteractionSite::~WallInteractionSite() +{} + + +// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // + +template +bool Foam::WallInteractionSite::operator== +( + const WallInteractionSite& rhs +) const +{ + return patchI_ == rhs.patch_ && wallData_ == rhs.wallData_; +} + + +template +bool Foam::WallInteractionSite::operator!= +( + const WallInteractionSite& rhs +) const +{ + return !(*this == rhs); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template +Foam::Istream& Foam::operator>> +( + Istream& is, + WallInteractionSite& wIS +) +{ + is >> wIS.patchI_ >> wIS.wallData_; + + // Check state of Istream + is.check + ( + "Foam::Istream& Foam::operator>>" + "(Foam::Istream&, Foam::WallInteractionSite&)" + ); + + return is; +} + + +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const WallInteractionSite& wIS +) +{ + os << wIS.patchI_ << token::SPACE << wIS.wallData_; + + // Check state of Ostream + os.check + ( + "Foam::Ostream& Foam::operator<<" + "(Ostream&, const WallInteractionSite&)" + ); + + return os; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.H b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.H new file mode 100644 index 0000000000..becede3bc2 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.H @@ -0,0 +1,144 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::WallInteractionSite + +Description + Stores the patch ID and templated data to represent a collision + with a wall to be passed to the wall model. + +SourceFiles + WallInteractionSiteI.H + WallInteractionSite.C + WallInteractionSiteIO.C + +\*---------------------------------------------------------------------------*/ + +#ifndef WallInteractionSite_H +#define WallInteractionSite_H + +#include "label.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators + +template +class WallInteractionSite; + +template +Istream& operator>>(Istream&, WallInteractionSite&); + +template +Ostream& operator<<(Ostream&, const WallInteractionSite&); + + +/*---------------------------------------------------------------------------*\ + Class WallInteractionSite Declaration +\*---------------------------------------------------------------------------*/ + +template +class WallInteractionSite +{ + // Private data + + //- Index of originating patch + label patchI_; + + //- Wall data + Type wallData_; + + +public: + + // Constructors + + //- Construct null + WallInteractionSite(); + + //- Construct from components + WallInteractionSite + ( + label patchI, + const Type& wallData + ); + + + //- Destructor + ~WallInteractionSite(); + + + // Member Functions + + //- Return access to the patch index + inline label patchIndex() const; + + //- Return non-const access to the patch index + inline label& patchIndex(); + + //- Return access to wall data + inline const Type& wallData() const; + + //- Return non-const access to wall data + inline Type& wallData(); + + + // Member Operators + + bool operator==(const WallInteractionSite&) const; + bool operator!=(const WallInteractionSite&) const; + + + // IOstream Operators + + friend Istream& operator>> + (Istream&, WallInteractionSite&); + + friend Ostream& operator<< + (Ostream&, const WallInteractionSite&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "WallInteractionSiteI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "WallInteractionSite.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteI.H b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteI.H new file mode 100644 index 0000000000..58023d6325 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteI.H @@ -0,0 +1,60 @@ +#/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::label Foam::WallInteractionSite::patchIndex() const +{ + return patchI_; +} + + +template +Foam::label& Foam::WallInteractionSite::patchIndex() +{ + return patchI_; +} + + +template +const Type& Foam::WallInteractionSite::wallData() const +{ + return wallData_; +} + + +template +Type& Foam::WallInteractionSite::wallData() +{ + return wallData_; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteIO.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteIO.C new file mode 100644 index 0000000000..e90f26ed31 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteIO.C @@ -0,0 +1,82 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "WallInteractionSite.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::WallInteractionSite::WallInteractionSite(Istream& is) +: + base1(is), + base2(is), + member1(is), + member2(is) +{ + // Check state of Istream + is.check("Foam::WallInteractionSite::WallInteractionSite(Foam::Istream&)"); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template +Foam::Istream& Foam::operator>> +( + Istream& is, + WallInteractionSite& +) +{ + // Check state of Istream + is.check + ( + "Foam::Istream& Foam::operator>>" + "(Foam::Istream&, Foam::WallInteractionSite&)" + ); + + return is; +} + + +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const WallInteractionSite& +) +{ + // Check state of Ostream + os.check + ( + "Foam::Ostream& Foam::operator<<" + "(Ostream&, const WallInteractionSite&)" + ); + + return os; +} + + +// ************************************************************************* // From 1789098e5acb540cbe7f768e2644d0e5036bf0aa Mon Sep 17 00:00:00 2001 From: graham Date: Fri, 14 May 2010 15:58:05 +0100 Subject: [PATCH 02/22] ENH: Adding WallSiteData collection and passing it to the wall model. Adding tangential forces (with no memory) to wall model. --- .../PairCollision/PairCollision.C | 92 ++++++++++++++---- .../PairCollision/PairCollision.H | 8 +- .../PairSpringSliderDashpot.C | 8 +- .../WallInteractionSiteIO.C | 82 ---------------- .../WallModel/WallModel/WallModel.H | 6 +- .../WallSpringSliderDashpot.C | 95 +++++++++++++++++-- .../WallSpringSliderDashpot.H | 10 +- .../WallSiteData.C} | 26 ++--- .../WallSiteData.H} | 40 ++++---- .../WallSiteDataI.H} | 8 +- 10 files changed, 214 insertions(+), 161 deletions(-) delete mode 100644 src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteIO.C rename src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/{WallInteractionSite/WallInteractionSite.C => WallSiteData/WallSiteData.C} (78%) rename src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/{WallInteractionSite/WallInteractionSite.H => WallSiteData/WallSiteData.H} (79%) rename src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/{WallInteractionSite/WallInteractionSiteI.H => WallSiteData/WallSiteDataI.H} (87%) diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C index 27a165c88c..ba7959662d 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C @@ -180,12 +180,15 @@ void Foam::PairCollision::wallInteraction() const volVectorField& U = mesh.lookupObject(il_.UName()); // Storage for the wall interaction sites - DynamicList flatSites; + DynamicList flatSitePoints; DynamicList flatSiteExclusionDistancesSqr; - DynamicList otherSites; + DynamicList > flatSiteData; + DynamicList otherSitePoints; DynamicList otherSiteDistances; - DynamicList sharpSites; + DynamicList > otherSiteData; + DynamicList sharpSitePoints; DynamicList sharpSiteExclusionDistancesSqr; + DynamicList > sharpSiteData; forAll(dil, realCellI) { @@ -195,12 +198,15 @@ void Foam::PairCollision::wallInteraction() // Loop over all Parcels in cell forAll(cellOccupancy_[realCellI], cellParticleI) { - flatSites.clear(); + flatSitePoints.clear(); flatSiteExclusionDistancesSqr.clear(); - otherSites.clear(); + flatSiteData.clear(); + otherSitePoints.clear(); otherSiteDistances.clear(); - sharpSites.clear(); + otherSiteData.clear(); + sharpSitePoints.clear(); sharpSiteExclusionDistancesSqr.clear(); + sharpSiteData.clear(); typename CloudType::parcelType& p = *cellOccupancy_[realCellI][cellParticleI]; @@ -233,6 +239,18 @@ void Foam::PairCollision::wallInteraction() scalar normalAlignment = normal & pW/mag(pW); + // Find the patchIndex and wallData for WallSiteData object + label patchI = patchID[realFaceI - mesh.nInternalFaces()]; + + label patchFaceI = + realFaceI - mesh.boundaryMesh()[patchI].start(); + + WallSiteData wSD + ( + patchI, + U.boundaryField()[patchI][patchFaceI] + ); + if (normalAlignment > cosPhiMinFlatWall) { // Guard against a flat interaction being @@ -243,25 +261,29 @@ void Foam::PairCollision::wallInteraction() ( !duplicatePointInList ( - flatSites, + flatSitePoints, nearPt, sqr(r*flatWallDuplicateExclusion) ) ) { - flatSites.append(nearPt); + flatSitePoints.append(nearPt); flatSiteExclusionDistancesSqr.append ( sqr(r) - sqr(nearest.distance()) ); + + flatSiteData.append(wSD); } } else { - otherSites.append(nearPt); + otherSitePoints.append(nearPt); otherSiteDistances.append(nearest.distance()); + + otherSiteData.append(wSD); } } } @@ -294,6 +316,14 @@ void Foam::PairCollision::wallInteraction() scalar normalAlignment = normal & pW/mag(pW); + // Find the patchIndex and wallData for WallSiteData object + + WallSiteData wSD + ( + rwf.patchIndex(), + il_.referredWallData()[refWallFaceI] + ); + if (normalAlignment > cosPhiMinFlatWall) { // Guard against a flat interaction being @@ -304,25 +334,29 @@ void Foam::PairCollision::wallInteraction() ( !duplicatePointInList ( - flatSites, + flatSitePoints, nearPt, sqr(r*flatWallDuplicateExclusion) ) ) { - flatSites.append(nearPt); + flatSitePoints.append(nearPt); flatSiteExclusionDistancesSqr.append ( sqr(r) - sqr(nearest.distance()) ); + + flatSiteData.append(wSD); } } else { - otherSites.append(nearPt); + otherSitePoints.append(nearPt); otherSiteDistances.append(nearest.distance()); + + otherSiteData.append(wSD); } } } @@ -344,13 +378,13 @@ void Foam::PairCollision::wallInteraction() { label orderedIndex = sortedOtherSiteIndices[siteI]; - const point& otherPt = otherSites[orderedIndex]; + const point& otherPt = otherSitePoints[orderedIndex]; if ( !duplicatePointInList ( - flatSites, + flatSitePoints, otherPt, flatSiteExclusionDistancesSqr ) @@ -363,23 +397,32 @@ void Foam::PairCollision::wallInteraction() ( !duplicatePointInList ( - sharpSites, + sharpSitePoints, otherPt, sharpSiteExclusionDistancesSqr ) ) { - sharpSites.append(otherPt); + sharpSitePoints.append(otherPt); sharpSiteExclusionDistancesSqr.append ( sqr(r) - sqr(otherSiteDistances[orderedIndex]) ); + + sharpSiteData.append(otherSiteData[orderedIndex]); } } } - evaluateWall(p, flatSites, sharpSites); + evaluateWall + ( + p, + flatSitePoints, + flatSiteData, + sharpSitePoints, + sharpSiteData + ); } } } @@ -469,11 +512,20 @@ template void Foam::PairCollision::evaluateWall ( typename CloudType::parcelType& p, - const List& flatSites, - const List& sharpSites + const List& flatSitePoints, + const List >& flatSiteData, + const List& sharpSitePoints, + const List >& sharpSiteData ) const { - wallModel_->evaluateWall(p, flatSites, sharpSites); + wallModel_->evaluateWall + ( + p, + flatSitePoints, + flatSiteData, + sharpSitePoints, + sharpSiteData + ); } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H index 588f08addd..8d5baa02f8 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H @@ -36,7 +36,7 @@ SourceFiles #include "CollisionModel.H" #include "InteractionLists.H" -#include "WallInteractionSite.H" +#include "WallSiteData.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -138,8 +138,10 @@ class PairCollision void evaluateWall ( typename CloudType::parcelType& p, - const List& flatSites, - const List& sharpSites + const List& flatSitePoints, + const List >& flatSiteData, + const List& sharpSitePoints, + const List >& sharpSiteData ) const; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.C index bbefa136ca..752120d0be 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.C @@ -215,7 +215,7 @@ void Foam::PairSpringSliderDashpot::evaluatePair { scalar kT = 8.0*sqrt(R*normalOverlapMag)*Gstar_; - scalar& etaT = etaN; + scalar etaT = etaN; // Tangential force vector fT_AB; @@ -233,9 +233,9 @@ void Foam::PairSpringSliderDashpot::evaluatePair else { fT_AB = - -kT*tangentialOverlapMag - *tangentialOverlap_AB/tangentialOverlapMag - - etaT*USlip_AB; + -kT*tangentialOverlapMag + *tangentialOverlap_AB/tangentialOverlapMag + - etaT*USlip_AB; } pA.f() += fT_AB; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteIO.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteIO.C deleted file mode 100644 index e90f26ed31..0000000000 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteIO.C +++ /dev/null @@ -1,82 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "WallInteractionSite.H" -#include "IOstreams.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::WallInteractionSite::WallInteractionSite(Istream& is) -: - base1(is), - base2(is), - member1(is), - member2(is) -{ - // Check state of Istream - is.check("Foam::WallInteractionSite::WallInteractionSite(Foam::Istream&)"); -} - - -// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // - -template -Foam::Istream& Foam::operator>> -( - Istream& is, - WallInteractionSite& -) -{ - // Check state of Istream - is.check - ( - "Foam::Istream& Foam::operator>>" - "(Foam::Istream&, Foam::WallInteractionSite&)" - ); - - return is; -} - - -template -Foam::Ostream& Foam::operator<< -( - Ostream& os, - const WallInteractionSite& -) -{ - // Check state of Ostream - os.check - ( - "Foam::Ostream& Foam::operator<<" - "(Ostream&, const WallInteractionSite&)" - ); - - return os; -} - - -// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallModel/WallModel/WallModel.H b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallModel/WallModel/WallModel.H index 7088c4df05..1c4e29a059 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallModel/WallModel/WallModel.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallModel/WallModel/WallModel.H @@ -133,8 +133,10 @@ public: virtual void evaluateWall ( typename CloudType::parcelType& p, - const List& flatSites, - const List& sharpSites + const List& flatSitePoints, + const List >& flatSiteData, + const List& sharpSitePoints, + const List >& sharpSiteData ) const = 0; }; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallModel/WallSpringSliderDashpot/WallSpringSliderDashpot.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallModel/WallSpringSliderDashpot/WallSpringSliderDashpot.C index ba22ef3842..3b425d5e12 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallModel/WallSpringSliderDashpot/WallSpringSliderDashpot.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallModel/WallSpringSliderDashpot/WallSpringSliderDashpot.C @@ -66,25 +66,76 @@ void Foam::WallSpringSliderDashpot::evaluateWall ( typename CloudType::parcelType& p, const point& site, + const WallSiteData& data, scalar pNu, scalar pE, scalar Estar, - scalar kN + scalar kN, + scalar Gstar ) const { + scalar pR = p.d()/2; + vector r_PW = p.position() - site; - scalar normalOverlapMag = p.d()/2 - mag(r_PW); + vector U_PW = p.U() - data.wallData(); + + scalar normalOverlapMag = pR - mag(r_PW); vector rHat_PW = r_PW/(mag(r_PW) + VSMALL); scalar etaN = alpha_*sqrt(p.mass()*kN)*pow025(normalOverlapMag); vector fN_PW = - rHat_PW - *(kN*pow(normalOverlapMag, b_) - etaN*(p.U() & rHat_PW)); + rHat_PW + *(kN*pow(normalOverlapMag, b_) - etaN*(U_PW & rHat_PW)); p.f() += fN_PW; + + vector USlip_PW = + U_PW - (U_PW & rHat_PW)*rHat_PW + + (p.omega() ^ (pR*-rHat_PW)); + + scalar deltaT = this->owner().mesh().time().deltaTValue(); + + // For remembering previous overlap + // vector deltaTangentialOverlap_PW = USlip_PW * deltaT; + // tangentialOverlap_PW += deltaTangentialOverlap_PW; + + vector tangentialOverlap_PW = USlip_PW * deltaT; + + scalar tangentialOverlapMag = mag(tangentialOverlap_PW); + + if (tangentialOverlapMag > VSMALL) + { + scalar kT = 8.0*sqrt(pR*normalOverlapMag)*Gstar; + + scalar etaT = etaN; + + // Tangential force + vector fT_PW; + + if (kT*tangentialOverlapMag > mu_*mag(fN_PW)) + { + // Tangential force greater than sliding friction, + // particle slips + + fT_PW = -mu_*mag(fN_PW)*USlip_PW/mag(USlip_PW); + + // tangentialOverlap_PW = vector::zero; + } + else + { + fT_PW = + -kT*tangentialOverlapMag + *tangentialOverlap_PW/tangentialOverlapMag + - etaT*USlip_PW; + } + + p.f() += fT_PW; + + p.torque() += (pR*-rHat_PW) ^ fT_PW; + } } @@ -164,8 +215,10 @@ template void Foam::WallSpringSliderDashpot::evaluateWall ( typename CloudType::parcelType& p, - const List& flatSites, - const List& sharpSites + const List& flatSitePoints, + const List >& flatSiteData, + const List& sharpSitePoints, + const List >& sharpSiteData ) const { scalar pNu = this->owner().constProps().poissonsRatio(); @@ -176,16 +229,38 @@ void Foam::WallSpringSliderDashpot::evaluateWall scalar kN = (4.0/3.0)*sqrt(p.d()/2)*Estar; - forAll(flatSites, siteI) + scalar GStar = 1/(2*((2 + pNu - sqr(pNu))/pE + (2 + nu_ - sqr(nu_))/E_)); + + forAll(flatSitePoints, siteI) { - evaluateWall(p, flatSites[siteI], pNu, pE, Estar, kN); + evaluateWall + ( + p, + flatSitePoints[siteI], + flatSiteData[siteI], + pNu, + pE, + Estar, + kN, + GStar + ); } - forAll(sharpSites, siteI) + forAll(sharpSitePoints, siteI) { // Treating sharp sites like flat sites - evaluateWall(p, sharpSites[siteI], pNu, pE, Estar, kN); + evaluateWall + ( + p, + sharpSitePoints[siteI], + sharpSiteData[siteI], + pNu, + pE, + Estar, + kN, + GStar + ); } } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallModel/WallSpringSliderDashpot/WallSpringSliderDashpot.H b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallModel/WallSpringSliderDashpot/WallSpringSliderDashpot.H index fcc83e22e6..452b4ced18 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallModel/WallSpringSliderDashpot/WallSpringSliderDashpot.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallModel/WallSpringSliderDashpot/WallSpringSliderDashpot.H @@ -86,10 +86,12 @@ class WallSpringSliderDashpot ( typename CloudType::parcelType& p, const point& site, + const WallSiteData& data, scalar pNu, scalar pE, scalar Estar, - scalar kN + scalar kN, + scalar Gstar ) const; @@ -124,8 +126,10 @@ public: virtual void evaluateWall ( typename CloudType::parcelType& p, - const List& flatSites, - const List& sharpSites + const List& flatSitePoints, + const List >& flatSiteData, + const List& sharpSitePoints, + const List >& sharpSiteData ) const; }; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallSiteData/WallSiteData.C similarity index 78% rename from src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.C rename to src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallSiteData/WallSiteData.C index 8dce24bb08..a9aa774c64 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallSiteData/WallSiteData.C @@ -23,12 +23,12 @@ License \*---------------------------------------------------------------------------*/ -#include "WallInteractionSite.H" +#include "WallSiteData.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::WallInteractionSite::WallInteractionSite() +Foam::WallSiteData::WallSiteData() : patchI_(), wallData_() @@ -36,7 +36,7 @@ Foam::WallInteractionSite::WallInteractionSite() template -Foam::WallInteractionSite::WallInteractionSite +Foam::WallSiteData::WallSiteData ( label patchI, const Type& wallData @@ -50,26 +50,26 @@ Foam::WallInteractionSite::WallInteractionSite // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template -Foam::WallInteractionSite::~WallInteractionSite() +Foam::WallSiteData::~WallSiteData() {} // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // template -bool Foam::WallInteractionSite::operator== +bool Foam::WallSiteData::operator== ( - const WallInteractionSite& rhs + const WallSiteData& rhs ) const { - return patchI_ == rhs.patch_ && wallData_ == rhs.wallData_; + return patchI_ == rhs.patchI_ && wallData_ == rhs.wallData_; } template -bool Foam::WallInteractionSite::operator!= +bool Foam::WallSiteData::operator!= ( - const WallInteractionSite& rhs + const WallSiteData& rhs ) const { return !(*this == rhs); @@ -82,7 +82,7 @@ template Foam::Istream& Foam::operator>> ( Istream& is, - WallInteractionSite& wIS + WallSiteData& wIS ) { is >> wIS.patchI_ >> wIS.wallData_; @@ -91,7 +91,7 @@ Foam::Istream& Foam::operator>> is.check ( "Foam::Istream& Foam::operator>>" - "(Foam::Istream&, Foam::WallInteractionSite&)" + "(Foam::Istream&, Foam::WallSiteData&)" ); return is; @@ -102,7 +102,7 @@ template Foam::Ostream& Foam::operator<< ( Ostream& os, - const WallInteractionSite& wIS + const WallSiteData& wIS ) { os << wIS.patchI_ << token::SPACE << wIS.wallData_; @@ -111,7 +111,7 @@ Foam::Ostream& Foam::operator<< os.check ( "Foam::Ostream& Foam::operator<<" - "(Ostream&, const WallInteractionSite&)" + "(Ostream&, const WallSiteData&)" ); return os; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.H b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallSiteData/WallSiteData.H similarity index 79% rename from src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.H rename to src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallSiteData/WallSiteData.H index becede3bc2..a179d4925c 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSite.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallSiteData/WallSiteData.H @@ -22,21 +22,21 @@ License along with OpenFOAM. If not, see . Class - Foam::WallInteractionSite + Foam::WallSiteData Description Stores the patch ID and templated data to represent a collision with a wall to be passed to the wall model. SourceFiles - WallInteractionSiteI.H - WallInteractionSite.C - WallInteractionSiteIO.C + WallSiteDataI.H + WallSiteData.C + WallSiteDataIO.C \*---------------------------------------------------------------------------*/ -#ifndef WallInteractionSite_H -#define WallInteractionSite_H +#ifndef WallSiteData_H +#define WallSiteData_H #include "label.H" @@ -48,21 +48,21 @@ namespace Foam // Forward declaration of friend functions and operators template -class WallInteractionSite; +class WallSiteData; template -Istream& operator>>(Istream&, WallInteractionSite&); +Istream& operator>>(Istream&, WallSiteData&); template -Ostream& operator<<(Ostream&, const WallInteractionSite&); +Ostream& operator<<(Ostream&, const WallSiteData&); /*---------------------------------------------------------------------------*\ - Class WallInteractionSite Declaration + Class WallSiteData Declaration \*---------------------------------------------------------------------------*/ template -class WallInteractionSite +class WallSiteData { // Private data @@ -78,10 +78,10 @@ public: // Constructors //- Construct null - WallInteractionSite(); + WallSiteData(); //- Construct from components - WallInteractionSite + WallSiteData ( label patchI, const Type& wallData @@ -89,7 +89,7 @@ public: //- Destructor - ~WallInteractionSite(); + ~WallSiteData(); // Member Functions @@ -109,17 +109,17 @@ public: // Member Operators - bool operator==(const WallInteractionSite&) const; - bool operator!=(const WallInteractionSite&) const; + bool operator==(const WallSiteData&) const; + bool operator!=(const WallSiteData&) const; // IOstream Operators friend Istream& operator>> - (Istream&, WallInteractionSite&); + (Istream&, WallSiteData&); friend Ostream& operator<< - (Ostream&, const WallInteractionSite&); + (Ostream&, const WallSiteData&); }; @@ -129,12 +129,12 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "WallInteractionSiteI.H" +#include "WallSiteDataI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository -# include "WallInteractionSite.C" +# include "WallSiteData.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteI.H b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallSiteData/WallSiteDataI.H similarity index 87% rename from src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteI.H rename to src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallSiteData/WallSiteDataI.H index 58023d6325..b28bf3be23 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallInteractionSite/WallInteractionSiteI.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/WallSiteData/WallSiteDataI.H @@ -28,28 +28,28 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -Foam::label Foam::WallInteractionSite::patchIndex() const +Foam::label Foam::WallSiteData::patchIndex() const { return patchI_; } template -Foam::label& Foam::WallInteractionSite::patchIndex() +Foam::label& Foam::WallSiteData::patchIndex() { return patchI_; } template -const Type& Foam::WallInteractionSite::wallData() const +const Type& Foam::WallSiteData::wallData() const { return wallData_; } template -Type& Foam::WallInteractionSite::wallData() +Type& Foam::WallSiteData::wallData() { return wallData_; } From 1f1fea9868efebc2ff04e86a1b1f04028dcad4ef Mon Sep 17 00:00:00 2001 From: graham Date: Fri, 14 May 2010 18:48:22 +0100 Subject: [PATCH 03/22] STYLE: copy-paste legacy in SourceFiles list. --- .../sixDoFRigidBodyMotionConstraint.H | 2 +- .../sixDoFRigidBodyMotionRestraint.H | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.H index 3c63ece5da..c6cbc3c11f 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.H @@ -36,7 +36,7 @@ Description SourceFiles sixDoFRigidBodyMotionConstraint.C - dynamicFvMeshNew.C + sixDoFRigidBodyMotionConstraintNew.C \*---------------------------------------------------------------------------*/ diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.H index bab292bc4d..545b17db8d 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.H @@ -36,7 +36,7 @@ Description SourceFiles sixDoFRigidBodyMotionRestraint.C - dynamicFvMeshNew.C + sixDoFRigidBodyMotionRestraintNew.C \*---------------------------------------------------------------------------*/ From 5bdcece3af51113232f2602703da625816c143d2 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 17 May 2010 12:56:30 +0200 Subject: [PATCH 04/22] ENH: allow retention of 'FoamFile' when reading dictionaries - used in expandDictionary --- .../expandDictionary/expandDictionary.C | 11 +- src/OpenFOAM/db/dictionary/dictionary.H | 11 +- src/OpenFOAM/db/dictionary/dictionaryIO.C | 155 ++++++++++-------- 3 files changed, 107 insertions(+), 70 deletions(-) diff --git a/applications/utilities/miscellaneous/expandDictionary/expandDictionary.C b/applications/utilities/miscellaneous/expandDictionary/expandDictionary.C index 08e8f29f24..86b1caec44 100644 --- a/applications/utilities/miscellaneous/expandDictionary/expandDictionary.C +++ b/applications/utilities/miscellaneous/expandDictionary/expandDictionary.C @@ -42,6 +42,12 @@ using namespace Foam; int main(int argc, char *argv[]) { + argList::addNote + ( + "Read the specified dictionary file, expand the macros etc. and write\n" + "the resulting dictionary to standard output." + ); + argList::noBanner(); argList::noParallel(); argList::validArgs.append("inputDict"); @@ -49,9 +55,10 @@ int main(int argc, char *argv[]) const string dictName = args[1]; - Info<<"//\n// expansion of dictionary " << dictName << "\n//\n"; + IOobject::writeBanner(Info) + <<"//\n// " << dictName << "\n//\n"; - dictionary(IFstream(dictName)()).write(Info, false); + dictionary(IFstream(dictName)(), true).write(Info, false); IOobject::writeDivider(Info); diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index c483aed557..3c3d504353 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -191,10 +191,14 @@ public: Istream& ); - //- Construct top-level dictionary from Istream, reading entries - // until EOF + //- Construct top-level dictionary from Istream, + // reading entries until EOF dictionary(Istream&); + //- Construct top-level dictionary from Istream, + // reading entries until EOF, optionally keeping the header + dictionary(Istream&, const bool keepHeader); + //- Construct as copy given the parent dictionary dictionary(const dictionary& parentDict, const dictionary&); @@ -441,6 +445,9 @@ public: //- Read dictionary from Istream bool read(Istream&); + //- Read dictionary from Istream, optionally keeping the header + bool read(Istream&, const bool keepHeader); + // Write diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C index 1c452bafaf..54d2877da2 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryIO.C +++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C @@ -28,68 +28,6 @@ License #include "inputModeEntry.H" #include "regExp.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -bool Foam::dictionary::read(Istream& is) -{ - if (!is.good()) - { - FatalIOErrorIn("dictionary::read(Istream&, const word&)", is) - << "Istream not OK for reading dictionary " - << exit(FatalIOError); - - return false; - } - - token currToken(is); - if (currToken != token::BEGIN_BLOCK) - { - is.putBack(currToken); - } - - while (!is.eof() && entry::New(*this, is)) - {} - - // Remove the FoamFile header entry if it exists - remove("FoamFile"); - - if (is.bad()) - { - Info<< "dictionary::read(Istream&, const word&) : " - << "Istream not OK after reading dictionary " << name() - << endl; - - return false; - } - - return true; -} - - -bool Foam::dictionary::substituteKeyword(const word& keyword) -{ - word varName = keyword(1, keyword.size()-1); - - // lookup the variable name in the given dictionary - const entry* ePtr = lookupEntryPtr(varName, true, true); - - // if defined insert its entries into this dictionary - if (ePtr != NULL) - { - const dictionary& addDict = ePtr->dict(); - - forAllConstIter(IDLList, addDict, iter) - { - add(iter()); - } - - return true; - } - - return false; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::dictionary::dictionary @@ -118,12 +56,97 @@ Foam::dictionary::dictionary(Istream& is) } +Foam::dictionary::dictionary(Istream& is, const bool keepHeader) +: + dictionaryName(is.name()), + parent_(dictionary::null) +{ + // Reset input mode as this is a "top-level" dictionary + functionEntries::inputModeEntry::clear(); + + read(is, keepHeader); +} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + Foam::autoPtr Foam::dictionary::New(Istream& is) { return autoPtr(new dictionary(is)); } +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::dictionary::read(Istream& is, const bool keepHeader) +{ + if (!is.good()) + { + FatalIOErrorIn("dictionary::read(Istream&, bool)", is) + << "Istream not OK for reading dictionary " + << exit(FatalIOError); + + return false; + } + + token currToken(is); + if (currToken != token::BEGIN_BLOCK) + { + is.putBack(currToken); + } + + while (!is.eof() && entry::New(*this, is)) + {} + + // normally remove the FoamFile header entry if it exists + if (!keepHeader) + { + remove("FoamFile"); + } + + if (is.bad()) + { + Info<< "dictionary::read(Istream&, bool) : " + << "Istream not OK after reading dictionary " << name() + << endl; + + return false; + } + + return true; +} + + +bool Foam::dictionary::read(Istream& is) +{ + return this->read(is, false); +} + + +bool Foam::dictionary::substituteKeyword(const word& keyword) +{ + word varName = keyword(1, keyword.size()-1); + + // lookup the variable name in the given dictionary + const entry* ePtr = lookupEntryPtr(varName, true, true); + + // if defined insert its entries into this dictionary + if (ePtr != NULL) + { + const dictionary& addDict = ePtr->dict(); + + forAllConstIter(IDLList, addDict, iter) + { + add(iter()); + } + + return true; + } + + return false; +} + + // * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * * // Foam::Istream& Foam::operator>>(Istream& is, dictionary& dict) @@ -145,7 +168,7 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const { if (subDict) { - os << nl << indent << token::BEGIN_BLOCK << incrIndent << nl; + os << nl << indent << token::BEGIN_BLOCK << incrIndent << nl; } forAllConstIter(IDLList, *this, iter) @@ -153,12 +176,12 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const const entry& e = *iter; // Write entry - os << e; + os << e; // Add extra new line between entries for "top-level" dictionaries if (!subDict && parent() == dictionary::null && e != *last()) { - os << nl; + os << nl; } // Check stream before going to next entry. @@ -173,7 +196,7 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const if (subDict) { - os << decrIndent << indent << token::END_BLOCK << endl; + os << decrIndent << indent << token::END_BLOCK << endl; } } From c600ce545d2ef0d927a3658afaca1550da9bd73f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 17 May 2010 13:08:11 +0200 Subject: [PATCH 05/22] STYLE: remove unneed '()' for simple return statements, - fix 'forAll (' -> 'forAll(' format (again) --- applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C | 2 +- .../adjointShapeOptimizationFoam.C | 2 +- .../solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C | 2 +- .../porousExplicitSourceReactingParcelFoam.C | 2 +- .../reactingParcelFilmFoam/reactingParcelFilmFoam.C | 2 +- .../lagrangian/reactingParcelFoam/reactingParcelFoam.C | 2 +- .../solvers/multiphase/interMixingFoam/interMixingFoam.C | 2 +- .../multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H | 2 +- .../mesh/conversion/fluentMeshToFoam/create3DCellShape.C | 2 +- .../utilities/preProcessing/dsmcInitialise/dsmcInitialise.C | 2 +- src/lagrangian/basic/InteractionLists/InteractionLists.C | 4 ++-- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C b/applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C index 28ed67fd15..785e09173e 100644 --- a/applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C +++ b/applications/solvers/discreteMethods/dsmc/dsmcFoam/dsmcFoam.C @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/incompressible/adjointShapeOptimizationFoam/adjointShapeOptimizationFoam.C b/applications/solvers/incompressible/adjointShapeOptimizationFoam/adjointShapeOptimizationFoam.C index a18298f826..cf9e76d52d 100644 --- a/applications/solvers/incompressible/adjointShapeOptimizationFoam/adjointShapeOptimizationFoam.C +++ b/applications/solvers/incompressible/adjointShapeOptimizationFoam/adjointShapeOptimizationFoam.C @@ -218,7 +218,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C b/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C index 8f828747e8..f562717503 100644 --- a/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C +++ b/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C @@ -118,7 +118,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/porousExplicitSourceReactingParcelFoam.C b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/porousExplicitSourceReactingParcelFoam.C index 8f4bf3823e..429b215ad5 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/porousExplicitSourceReactingParcelFoam.C +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/porousExplicitSourceReactingParcelFoam.C @@ -116,7 +116,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C b/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C index f39d8f070a..36a85b6fde 100644 --- a/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C +++ b/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C @@ -120,7 +120,7 @@ int main(int argc, char *argv[]) Info<< "End" << endl; - return(0); + return 0; } diff --git a/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C b/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C index c4ccb27fc0..ddd0a962cd 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C +++ b/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/interMixingFoam/interMixingFoam.C b/applications/solvers/multiphase/interMixingFoam/interMixingFoam.C index 3659886ea4..a4f5b45f94 100644 --- a/applications/solvers/multiphase/interMixingFoam/interMixingFoam.C +++ b/applications/solvers/multiphase/interMixingFoam/interMixingFoam.C @@ -94,7 +94,7 @@ int main(int argc, char *argv[]) Info<< "\n end \n"; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H index 1d94d47e91..d606046865 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H +++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H @@ -124,7 +124,7 @@ public: const interfacePair& b ) { - return (!(a == b)); + return !(a == b); } }; diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/create3DCellShape.C b/applications/utilities/mesh/conversion/fluentMeshToFoam/create3DCellShape.C index ddf722d324..adcce3869d 100644 --- a/applications/utilities/mesh/conversion/fluentMeshToFoam/create3DCellShape.C +++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/create3DCellShape.C @@ -90,7 +90,7 @@ cellShape create3DCellShape // make a list of outward-pointing faces labelListList localFaces(faceLabels.size()); - forAll (faceLabels, faceI) + forAll(faceLabels, faceI) { const label curFaceLabel = faceLabels[faceI]; diff --git a/applications/utilities/preProcessing/dsmcInitialise/dsmcInitialise.C b/applications/utilities/preProcessing/dsmcInitialise/dsmcInitialise.C index d779a6427d..2b5e4dcaf0 100644 --- a/applications/utilities/preProcessing/dsmcInitialise/dsmcInitialise.C +++ b/applications/utilities/preProcessing/dsmcInitialise/dsmcInitialise.C @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/src/lagrangian/basic/InteractionLists/InteractionLists.C b/src/lagrangian/basic/InteractionLists/InteractionLists.C index 83ab477ee4..391a41aa5b 100644 --- a/src/lagrangian/basic/InteractionLists/InteractionLists.C +++ b/src/lagrangian/basic/InteractionLists/InteractionLists.C @@ -932,7 +932,7 @@ void Foam::InteractionLists::prepareParticlesToRefer IDLList& particlesToRefer = referredParticles_[i]; - forAll (realParticles, rM) + forAll(realParticles, rM) { const ParticleType& particle = *realParticles[rM]; @@ -1188,7 +1188,7 @@ void Foam::InteractionLists::receiveReferredData { UIPstream str(domain, pBufs); - forAll (constructMap, i) + forAll(constructMap, i) { referredParticles_[constructMap[i]] = IDLList ( From 6ed642beb9ed95e47af19b009a2320ccde0dbc8e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 17 May 2010 16:06:53 +0200 Subject: [PATCH 06/22] ENH: change return type of Time::stopAt to report if the setting changed --- src/OpenFOAM/db/Time/Time.C | 4 +++- src/OpenFOAM/db/Time/Time.H | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 0afa8d69b3..b9eebc0d7f 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -552,8 +552,9 @@ bool Foam::Time::end() const } -void Foam::Time::stopAt(const stopAtControls sa) const +bool Foam::Time::stopAt(const stopAtControls sa) const { + const bool changed = (stopAt_ != sa); stopAt_ = sa; // adjust endTime @@ -565,6 +566,7 @@ void Foam::Time::stopAt(const stopAtControls sa) const { endTime_ = GREAT; } + return changed; } diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H index 7596fee0c9..55b02813c9 100644 --- a/src/OpenFOAM/db/Time/Time.H +++ b/src/OpenFOAM/db/Time/Time.H @@ -406,7 +406,8 @@ public: //- Adjust the current stopAtControl. Note that this value // only persists until the next time the dictionary is read. - virtual void stopAt(const stopAtControls) const; + // Return true if the stopAtControl changed. + virtual bool stopAt(const stopAtControls) const; //- Reset the time and time-index to those of the given time virtual void setTime(const Time&); From 4d545e001187eead6447ece5e7f4b33016414f07 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 17 May 2010 16:24:32 +0200 Subject: [PATCH 07/22] BUG: race condition when removing ABORT file --- .../abortCalculation/abortCalculation.C | 53 ++++++++++++------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/src/postProcessing/functionObjects/jobControl/abortCalculation/abortCalculation.C b/src/postProcessing/functionObjects/jobControl/abortCalculation/abortCalculation.C index 9cd6a2af07..08bf5ce773 100644 --- a/src/postProcessing/functionObjects/jobControl/abortCalculation/abortCalculation.C +++ b/src/postProcessing/functionObjects/jobControl/abortCalculation/abortCalculation.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,6 +28,7 @@ License #include "error.H" #include "Time.H" #include "OSspecific.H" +#include "PstreamReduceOps.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -52,8 +53,12 @@ const Foam::NamedEnum void Foam::abortCalculation::removeFile() const { - if (isFile(abortFile_)) + bool hasAbort = isFile(abortFile_); + reduce(hasAbort, orOp()); + + if (hasAbort && Pstream::master()) { + // cleanup ABORT file (on master only) rm(abortFile_); } } @@ -92,14 +97,9 @@ Foam::abortCalculation::~abortCalculation() void Foam::abortCalculation::read(const dictionary& dict) { - word actionName; - if (dict.found("action")) { - action_ = actionTypeNames_.read - ( - dict.lookup("action") - ); + action_ = actionTypeNames_.read(dict.lookup("action")); } else { @@ -115,26 +115,41 @@ void Foam::abortCalculation::read(const dictionary& dict) void Foam::abortCalculation::execute() { - if (isFile(abortFile_)) + bool hasAbort = isFile(abortFile_); + reduce(hasAbort, orOp()); + + if (hasAbort) { switch (action_) { case noWriteNow : - obr_.time().stopAt(Time::saNoWriteNow); - Info<< "user requested abort - " - "stop immediately without writing data" << endl; + if (obr_.time().stopAt(Time::saNoWriteNow)) + { + Info<< "USER REQUESTED ABORT (timeIndex=" + << obr_.time().timeIndex() + << "): stop without writing data" + << endl; + } break; case writeNow : - obr_.time().stopAt(Time::saWriteNow); - Info<< "user requested abort - " - "stop immediately with writing data" << endl; + if (obr_.time().stopAt(Time::saWriteNow)) + { + Info<< "USER REQUESTED ABORT (timeIndex=" + << obr_.time().timeIndex() + << "): stop+write data" + << endl; + } break; case nextWrite : - obr_.time().stopAt(Time::saNextWrite); - Info<< "user requested abort - " - "stop after next data write" << endl; + if (obr_.time().stopAt(Time::saNextWrite)) + { + Info<< "USER REQUESTED ABORT (timeIndex=" + << obr_.time().timeIndex() + << "): stop after next data write" + << endl; + } break; } } @@ -149,7 +164,7 @@ void Foam::abortCalculation::end() void Foam::abortCalculation::write() { - execute(); + // Do nothing - only valid on execute } From 0dccf9de85b08593ded9b4cc3dbfc37482bf8b95 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 18 May 2010 09:24:46 +0200 Subject: [PATCH 08/22] ENH: improve robustness of outputFilterOutputControl --- src/OpenFOAM/containers/NamedEnum/NamedEnum.C | 18 +++++----- .../outputFilterOutputControl.C | 33 ++++++++++--------- .../outputFilterOutputControl.H | 9 +++-- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/OpenFOAM/containers/NamedEnum/NamedEnum.C b/src/OpenFOAM/containers/NamedEnum/NamedEnum.C index 76b8c58765..b39664af24 100644 --- a/src/OpenFOAM/containers/NamedEnum/NamedEnum.C +++ b/src/OpenFOAM/containers/NamedEnum/NamedEnum.C @@ -33,25 +33,25 @@ Foam::NamedEnum::NamedEnum() : HashTable(2*nEnum) { - for (int i=0; i::NamedEnum()") - << "Illegal enumeration name at position " << i << endl + << "Illegal enumeration name at position " << enumI << endl << "after entries " << goodNames << ".\n" << "Possibly your NamedEnum::names array" << " is not of size " << nEnum << endl << abort(FatalError); } - insert(names[i], i); + insert(names[enumI], enumI); } } @@ -61,7 +61,7 @@ Foam::NamedEnum::NamedEnum() template Enum Foam::NamedEnum::read(Istream& is) const { - word name(is); + const word name(is); HashTable::const_iterator iter = find(name); @@ -71,7 +71,7 @@ Enum Foam::NamedEnum::read(Istream& is) const ( "NamedEnum::read(Istream&) const", is ) << name << " is not in enumeration: " - << toc() << exit(FatalIOError); + << sortedToc() << exit(FatalIOError); } return Enum(iter()); diff --git a/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C b/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C index 2644b0d000..08694c9817 100644 --- a/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C +++ b/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,18 +68,23 @@ Foam::outputFilterOutputControl::~outputFilterOutputControl() void Foam::outputFilterOutputControl::read(const dictionary& dict) { - outputControl_ = outputControlNames_.read(dict.lookup("outputControl")); + if (dict.found("outputControl")) + { + outputControl_ = outputControlNames_.read(dict.lookup("outputControl")); + } + else + { + outputControl_ = ocTimeStep; + } switch (outputControl_) { case ocTimeStep: - { - dict.lookup("outputInterval") >> outputInterval_; - } + outputInterval_ = dict.lookupOrDefault