From 603d744f4f7ab3985ae0cf7ca24baad04a0cdb4c Mon Sep 17 00:00:00 2001 From: andy <a.heather@opencfd.co.uk> Date: Wed, 4 Mar 2009 14:47:37 +0000 Subject: [PATCH] removed polyMeshInfo - functionality now in meshTools/polyMesh --- src/lagrangian/basic/Cloud/Cloud.C | 6 +- src/lagrangian/basic/Cloud/Cloud.H | 13 +- src/lagrangian/basic/Cloud/CloudIO.C | 6 +- src/lagrangian/basic/Make/files | 2 - .../basic/polyMeshInfo/polyMeshInfo.C | 325 ------------------ .../basic/polyMeshInfo/polyMeshInfo.H | 176 ---------- src/lagrangian/intermediate/Make/options | 6 +- .../KinematicParcel/KinematicParcel.C | 34 -- .../GradientDispersionRAS.C | 2 +- .../InjectionModel/InjectionModel.C | 42 +-- 10 files changed, 19 insertions(+), 593 deletions(-) delete mode 100644 src/lagrangian/basic/polyMeshInfo/polyMeshInfo.C delete mode 100644 src/lagrangian/basic/polyMeshInfo/polyMeshInfo.H diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index e18e0e3b533..8d39c1f70a9 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -48,8 +48,7 @@ Foam::Cloud<ParticleType>::Cloud cellFaces_(pMesh.cells()), allFaceCentres_(pMesh.faceCentres()), owner_(pMesh.faceOwner()), - neighbour_(pMesh.faceNeighbour()), - meshInfo_(polyMesh_) + neighbour_(pMesh.faceNeighbour()) {} @@ -69,8 +68,7 @@ Foam::Cloud<ParticleType>::Cloud cellFaces_(pMesh.cells()), allFaceCentres_(pMesh.faceCentres()), owner_(pMesh.faceOwner()), - neighbour_(pMesh.faceNeighbour()), - meshInfo_(polyMesh_) + neighbour_(pMesh.faceNeighbour()) {} diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H index 684ceb979e3..d82dc933f19 100644 --- a/src/lagrangian/basic/Cloud/Cloud.H +++ b/src/lagrangian/basic/Cloud/Cloud.H @@ -39,8 +39,7 @@ SourceFiles #include "cloud.H" #include "IDLList.H" #include "IOField.H" - -#include "polyMeshInfo.H" +#include "polyMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -68,7 +67,6 @@ class Cloud public cloud, public IDLList<ParticleType> { - // Private data const polyMesh& polyMesh_; @@ -79,9 +77,6 @@ class Cloud const unallocLabelList& owner_; const unallocLabelList& neighbour_; - //- Mesh information object - const polyMeshInfo meshInfo_; - // Private member functions @@ -173,12 +168,6 @@ public: return polyMesh_.boundaryMesh()[patchi].whichFace(facei); } - //- Return reference to the mesh information object - const polyMeshInfo& meshInfo() const - { - return meshInfo_; - } - label size() const { return IDLList<ParticleType>::size(); diff --git a/src/lagrangian/basic/Cloud/CloudIO.C b/src/lagrangian/basic/Cloud/CloudIO.C index 9b58c12ea52..42c1a9317a2 100644 --- a/src/lagrangian/basic/Cloud/CloudIO.C +++ b/src/lagrangian/basic/Cloud/CloudIO.C @@ -72,8 +72,7 @@ Foam::Cloud<ParticleType>::Cloud cellFaces_(pMesh.cells()), allFaceCentres_(pMesh.faceCentres()), owner_(pMesh.faceOwner()), - neighbour_(pMesh.faceNeighbour()), - meshInfo_(polyMesh_) + neighbour_(pMesh.faceNeighbour()) { initCloud(checkClass); } @@ -94,8 +93,7 @@ Foam::Cloud<ParticleType>::Cloud cellFaces_(pMesh.cells()), allFaceCentres_(pMesh.faceCentres()), owner_(pMesh.faceOwner()), - neighbour_(pMesh.faceNeighbour()), - meshInfo_(polyMesh_) + neighbour_(pMesh.faceNeighbour()) { initCloud(checkClass); } diff --git a/src/lagrangian/basic/Make/files b/src/lagrangian/basic/Make/files index 629d47f4747..969b966f1a1 100644 --- a/src/lagrangian/basic/Make/files +++ b/src/lagrangian/basic/Make/files @@ -6,6 +6,4 @@ indexedParticle = indexedParticle $(passiveParticle)/passiveParticleCloud.C $(indexedParticle)/indexedParticleCloud.C -polyMeshInfo/polyMeshInfo.C - LIB = $(FOAM_LIBBIN)/liblagrangian diff --git a/src/lagrangian/basic/polyMeshInfo/polyMeshInfo.C b/src/lagrangian/basic/polyMeshInfo/polyMeshInfo.C deleted file mode 100644 index 16b347ccbe3..00000000000 --- a/src/lagrangian/basic/polyMeshInfo/polyMeshInfo.C +++ /dev/null @@ -1,325 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "polyMeshInfo.H" -#include "wedgePolyPatch.H" -#include "symmetryPolyPatch.H" -#include "emptyPolyPatch.H" -#include "mathematicalConstants.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(polyMeshInfo, 0); -} - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::polyMeshInfo::setCentrePoint() -{ - boundBox bounds = mesh_.bounds(); - - centrePoint_ = 0.5*(bounds.max() + bounds.min()); -} - - -void Foam::polyMeshInfo::setEmptyComponent(const vector& dir) -{ - for (direction cmpt=0; cmpt<vector::nComponents; cmpt++) - { - if (dir[cmpt] > 1.0e-6) - { - emptyComponent_ = cmpt; - } - } -} - - -void Foam::polyMeshInfo::queryWedge() -{ - label patchId[4]; - - bool symmPlaneExists = false; - - forAll(mesh_.boundaryMesh(), patchi) - { - const polyPatch& patch = mesh_.boundaryMesh()[patchi]; - if (isA<wedgePolyPatch>(patch)) - { - if (patch.size()) - { - nWedge_++; - if (nWedge_ > 4) - { - break; - } - patchId[nWedge_-1] = patchi; - } - } - else if (isA<symmetryPolyPatch>(patch)) - { - symmPlaneExists = true; - } - } - - if (nWedge_ != 0 && nWedge_ != 2 && nWedge_ != 4) - { - FatalErrorIn("void polyMeshInfo::queryWedge() const") - << "Number of wedge patches " << nWedge_ << " is incorrect, " - "should be 0, 2 or 4" - << exit(FatalError); - } - else - { - if (symmPlaneExists) - { - wedgeAngle_ = mathematicalConstant::pi; - } - else - { - if (nWedge_) - { - if (nWedge_ > 2) - { - WarningIn("void polyMeshInfo::queryWedge() const") - << "Only configured for cases with 2 wedges. " - << "Lagrangian calculations may result in errors" - << endl; - } - // Get the vector normal to wedge patch1 - const wedgePolyPatch& patch1 = refCast<const wedgePolyPatch> - (mesh_.boundaryMesh()[patchId[0]]); - vector n1 = patch1.patchNormal(); - - // Get the vector normal to wedge patch2 - const wedgePolyPatch& patch2 = refCast<const wedgePolyPatch> - (mesh_.boundaryMesh()[patchId[1]]); - vector n2 = patch2.patchNormal(); - - // Calculate the angle swept between the patches - const scalar arcCos = (n1 & n2)/mag(n1); - wedgeAngle_ = mathematicalConstant::pi - acos(arcCos); - - // Get the centre normal - centreNormal_ = patch1.centreNormal(); - - // Get the wedge axis - wedgeAxis_ = patch1.axis(); - } - } - } -} - - -void Foam::polyMeshInfo::queryDirections() -{ - vector dirVec = vector::zero; - - forAll(mesh_.boundaryMesh(), patchi) - { - if (isA<emptyPolyPatch>(mesh_.boundaryMesh()[patchi])) - { - if (mesh_.boundaryMesh()[patchi].size()) - { - nEmpty_++; - dirVec += - sum(cmptMag(mesh_.boundaryMesh()[patchi].faceAreas())); - } - } - } - - - for (direction cmpt=0; cmpt<vector::nComponents; cmpt++) - { - directions_[cmpt] = 1; - } - - if (nEmpty_) - { - reduce(dirVec, sumOp<vector>()); - - dirVec /= mag(dirVec); - - for (direction cmpt=0; cmpt<vector::nComponents; cmpt++) - { - if (dirVec[cmpt] > 1.0e-6) - { - directions_[cmpt] = -1; - emptyComponent_ = cmpt; - } - else - { - directions_[cmpt] = 1; - } - } - - // Set the patch normal - centreNormal_ = dirVec; - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::polyMeshInfo::polyMeshInfo -( - const polyMesh& mesh -) -: - mesh_(mesh), - nGeometricD_(0), - nSolutionD_(0), - centreNormal_(vector::zero), - emptyComponent_(0), - centrePoint_(vector::zero), - nEmpty_(0), - nWedge_(0), - wedgeAxis_(vector::zero), - wedgeAngle_(0) -{ - setCentrePoint(); - - queryWedge(); - - queryDirections(); - - nSolutionD_ = cmptSum(directions_ + Vector<label>::one)/2; - - nGeometricD_ = nSolutionD_ - nWedge_/2; - - if (nGeometricD_ == 2) - { - setEmptyComponent(centreNormal_); - } -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::polyMeshInfo::~polyMeshInfo() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::label Foam::polyMeshInfo::nGeometricD() const -{ - return nGeometricD_; -} - - -Foam::label Foam::polyMeshInfo::nSolutionD() const -{ - return nSolutionD_; -} - - -bool Foam::polyMeshInfo::caseIs2dWedge() const -{ - return (nWedge_ > 0); -} - - -bool Foam::polyMeshInfo::caseIs2dSlab() const -{ - return (nEmpty_ > 0); -} - - -bool Foam::polyMeshInfo::caseIs2d() const -{ - return (nGeometricD_ == 2); -} - - -bool Foam::polyMeshInfo::caseIs3d() const -{ - return (nGeometricD_ == 3); -} - - -Foam::vector Foam::polyMeshInfo::wedgeAxis() const -{ - if (nWedge_) - { - return wedgeAxis_; - } - else - { - WarningIn("Foam::polyMeshInfo::wedgeAxis()") - << "wedgeAxis() requested, but case is not of wedge type. " - << "Returning zero vector" << endl; - return vector::zero; - } -} - - -Foam::scalar Foam::polyMeshInfo::wedgeAngle() const -{ - if (nWedge_) - { - return wedgeAngle_; - } - else - { - WarningIn("Foam::polyMeshInfo::wedgeAngle()") - << "wedgeAngle() requested, but case is not of wedge type. " - << "Returning zero" << endl; - return 0.0; - } -} - - -Foam::vector Foam::polyMeshInfo::centreNormal() const -{ - if (nGeometricD_ == 2) - { - return centreNormal_; - } - else - { - WarningIn("Foam::polyMeshInfo::centreNormal()") - << "centreNormal() requested, but case is not 2-D. " - << "Returning zero vector" << endl; - return vector::zero; - } -} - - -Foam::label Foam::polyMeshInfo::emptyComponent() const -{ - return emptyComponent_; -} - - -Foam::vector Foam::polyMeshInfo::centrePoint() const -{ - return centrePoint_; -} - - -// ************************************************************************* // diff --git a/src/lagrangian/basic/polyMeshInfo/polyMeshInfo.H b/src/lagrangian/basic/polyMeshInfo/polyMeshInfo.H deleted file mode 100644 index c047afac184..00000000000 --- a/src/lagrangian/basic/polyMeshInfo/polyMeshInfo.H +++ /dev/null @@ -1,176 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - Foam::polyMeshInfo - -Description - - -SourceFiles - polyMeshInfo.C - -\*---------------------------------------------------------------------------*/ - -#ifndef polyMeshInfo_H -#define polyMeshInfo_H - -#include "polyMesh.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class polyMeshInfo Declaration -\*---------------------------------------------------------------------------*/ - -class polyMeshInfo -{ - - // Private data - - //- Reference to the mesh - const polyMesh& mesh_; - - //- Vector of valid directions in mesh - // defined according to the presence of empty patches - mutable Vector<label> directions_; - - //- Number of number of valid geoemtric dimensions in the mesh - label nGeometricD_; - - //- Number of number of valid solution dimensions in the mesh - // For wedge cases this includes the circumferential direction - // in case of swirl - label nSolutionD_; - - //- Plane normal to the wedge patches, or between empty patches - // for slab 2-D cases - vector centreNormal_; - - //- Empty/unused component for 2-D cases - label emptyComponent_; - - //- Geometric centre point - vector centrePoint_; - - //- Number of empty patches - label nEmpty_; - - //- Number of wedge patches - label nWedge_; - - //- Axis of wedge - vector wedgeAxis_; - - //- Angle of wedge - scalar wedgeAngle_; - - - // Private member functions - - //- Set the value of the mesh centre point - void setCentrePoint(); - - //- Determine wedge information - void queryWedge(); - - //- Determine mesh directions - void queryDirections(); - - -public: - - //- Runtime type information - TypeName("polyMeshInfo"); - - // Constructors - - //- Construct from components - polyMeshInfo - ( - const polyMesh& mesh - ); - - - // Destructors - - virtual ~polyMeshInfo(); - - - // Member functions - - //- Access - - //- Return the number of valid geoemtric dimensions in the mesh - label nGeometricD() const; - - //- Return the number of valid solution dimensions in the mesh - label nSolutionD() const; - - //- Flag to indicate whether case is a 2-D wedge - bool caseIs2dWedge() const; - - //- Flag to indicate whether case is a 2-D slab - bool caseIs2dSlab() const; - - //- Flag to indicate whether case is 2-D - bool caseIs2d() const; - - //- Flag to indicate whether case is 3-D - bool caseIs3d() const; - - //- Return axis of wedge - vector wedgeAxis() const; - - //- Return angle of wedge - scalar wedgeAngle() const; - - //- Return the centre normal - vector centreNormal() const; - - //- Return empty component - label emptyComponent() const; - - //- Return centre point - vector centrePoint() const; - - //- Set the empty component direction based on normal vector dir - void setEmptyComponent(const vector& dir); - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // - diff --git a/src/lagrangian/intermediate/Make/options b/src/lagrangian/intermediate/Make/options index 4304ffde9f9..e9d4852aa05 100644 --- a/src/lagrangian/intermediate/Make/options +++ b/src/lagrangian/intermediate/Make/options @@ -1,5 +1,6 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/pdfs/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ @@ -17,6 +18,8 @@ EXE_INC = \ -I$(LIB_SRC)/turbulenceModels/compressible/LES/lnInclude LIB_LIBS = \ + -lfiniteVolume \ + -lmeshTools \ -llagrangian \ -lpdf \ -lliquids \ @@ -27,5 +30,4 @@ LIB_LIBS = \ -lbasicThermophysicalModels \ -lcombustionThermophysicalModels \ -lcompressibleRASModels \ - -lcompressibleLESModels \ - -lfiniteVolume + -lcompressibleLESModels diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C index ee4c699f05a..bec040ca837 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C @@ -139,17 +139,9 @@ Foam::vector Foam::KinematicParcel<ParcelType>::calcVelocity vector& dUTrans ) { - // Correct carrier phase velocity for 2-D slab cases - const polyMeshInfo& meshInfo = td.cloud().meshInfo(); - if (meshInfo.caseIs2dSlab()) - { - Uc_.component(meshInfo.emptyComponent()) = 0.0; - } - // Return linearised term from drag model Cud = td.cloud().drag().Cu(U_ - Uc_, d_, rhoc_, rho_, muc_); - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Set new particle velocity //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -164,32 +156,6 @@ Foam::vector Foam::KinematicParcel<ParcelType>::calcVelocity // - do not include gravity impulse dUTrans = -mass()*(Unew - U_ - dt*td.g()); - // Make corrections for 2-D cases - if (meshInfo.caseIs2d()) - { - if (meshInfo.caseIs2dSlab()) - { - // Remove the slab normal parcel velocity component - Unew.component(meshInfo.emptyComponent()) = 0.0; - dUTrans.component(meshInfo.emptyComponent()) = 0.0; - - // Snap parcels to central plane - this->position().component(meshInfo.emptyComponent()) = - meshInfo.centrePoint().component(meshInfo.emptyComponent()); - } - else if (meshInfo.caseIs2dWedge()) - { - // Snap parcels to central plane - this->position().component(meshInfo.emptyComponent()) = 0.0; - } - else - { - FatalErrorIn("Foam::vector Foam::KinematicParcel::calcVelocity") - << "Could not determine 2-D case geometry" << nl - << abort(FatalError); - } - } - return Unew; } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/GradientDispersionRAS/GradientDispersionRAS.C b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/GradientDispersionRAS/GradientDispersionRAS.C index e15ee595e06..daac8b5af3f 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/GradientDispersionRAS/GradientDispersionRAS.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/DispersionModel/GradientDispersionRAS/GradientDispersionRAS.C @@ -111,7 +111,7 @@ Foam::vector Foam::GradientDispersionRAS<CloudType>::update // away from the axis of symmetry // This creates a 'hole' in the spray and to // prevent this we let x1 be both negative/positive - if (this->owner().meshInfo().caseIs2d()) + if (this->owner().mesh().nSolutionD() == 2) { fac *= x1; } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C index a8fdec60c0e..1a027a40472 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C @@ -26,6 +26,7 @@ License #include "InjectionModel.H" #include "mathematicalConstants.H" +#include "meshTools.H" // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // @@ -231,44 +232,19 @@ Foam::scalar Foam::InjectionModel<CloudType>::setNumberOfParticles template<class CloudType> void Foam::InjectionModel<CloudType>::geometryCorrection(vector& pos) const { - if (owner_.meshInfo().caseIs2d()) - { - if (owner_.meshInfo().caseIs2dWedge()) - { - pos.component(owner_.meshInfo().emptyComponent()) = 0.0; - } - else if (owner_.meshInfo().caseIs2dSlab()) - { - pos.component(owner_.meshInfo().emptyComponent()) = - owner_.meshInfo().centrePoint().component - ( - owner_.meshInfo().emptyComponent() - ); - } - else - { - FatalErrorIn - ( - "void Foam::InjectionModel<CloudType>::geometryCorrection" - "(vector& pos)" - ) << "Could not determine 2-D case geometry" << nl - << abort(FatalError); - } - } + meshTools::constrainToMeshCentre(owner_.mesh(), pos); } template<class CloudType> void Foam::InjectionModel<CloudType>::velocityCorrection(vector& U) const { - if (owner_.meshInfo().caseIs2dSlab()) - { - U.component(owner_.meshInfo().emptyComponent()) = - owner_.meshInfo().centrePoint().component - ( - owner_.meshInfo().emptyComponent() - ); - } + meshTools::constrainDirection + ( + owner_.mesh(), + owner_.mesh().solutionD(), + U + ); } template<class CloudType> @@ -278,7 +254,7 @@ void Foam::InjectionModel<CloudType>::postInjectCheck() { Pout<< "\n--> Cloud: " << owner_.name() << nl << " Added " << parcelsAdded_ - << " new parcels" << nl << endl; + << " new parcels" << nl << endl; } // Increment total number of parcels added -- GitLab