From adcebb9e1fed5b606b71a92efbd1c32c09b49edf Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 14 Jan 2011 18:07:51 +0000 Subject: [PATCH 01/72] BUG: Numeration of rayIDs for multi region cases --- .../radiation/radiationModel/fvDOM/fvDOM/fvDOM.C | 9 ++++++--- .../fvDOM/radiativeIntensityRay/radiativeIntensityRay.C | 8 ++------ .../fvDOM/radiativeIntensityRay/radiativeIntensityRay.H | 3 ++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C index dca6315cb7..3ef7c1b0e8 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C @@ -157,7 +157,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) deltaTheta, nLambda_, absorptionEmission_, - blackBody_ + blackBody_, + i ) ); i++; @@ -190,7 +191,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) deltaTheta, nLambda_, absorptionEmission_, - blackBody_ + blackBody_, + i ) ); i++; @@ -220,7 +222,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) deltaTheta, nLambda_, absorptionEmission_, - blackBody_ + blackBody_, + i ) ); i++; diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C index 89b8e5725c..bc9f0e85d9 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C @@ -30,9 +30,6 @@ License using namespace Foam::constant; -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -Foam::label Foam::radiation::radiativeIntensityRay::rayId(0); const Foam::word Foam::radiation::radiativeIntensityRay::intensityPrefix("ILambda"); @@ -50,7 +47,8 @@ Foam::radiation::radiativeIntensityRay::radiativeIntensityRay const scalar deltaTheta, const label nLambda, const absorptionEmissionModel& absorptionEmission, - const blackBodyEmission& blackBody + const blackBodyEmission& blackBody, + const label rayId ) : dom_(dom), @@ -167,7 +165,6 @@ Foam::radiation::radiativeIntensityRay::radiativeIntensityRay ); } } - rayId++; } @@ -182,7 +179,6 @@ Foam::radiation::radiativeIntensityRay::~radiativeIntensityRay() Foam::scalar Foam::radiation::radiativeIntensityRay::correct() { // reset boundary heat flux to zero - //Qr_ = dimensionedScalar("zero", dimMass/pow3(dimTime), 0.0); Qr_.boundaryField() = 0.0; scalar maxResidual = -GREAT; diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H index a795052305..4c1d3bf31d 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H @@ -130,7 +130,8 @@ public: const scalar deltaTheta, const label lambda, const absorptionEmissionModel& absEmmModel_, - const blackBodyEmission& blackBody + const blackBodyEmission& blackBody, + const label rayId ); From 66ef07aee8b39f46e41ca07b277af049b4749d67 Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 14 Jan 2011 18:09:47 +0000 Subject: [PATCH 02/72] STY: modification date --- .../radiation/radiationModel/fvDOM/fvDOM/fvDOM.C | 2 +- .../fvDOM/radiativeIntensityRay/radiativeIntensityRay.C | 2 +- .../fvDOM/radiativeIntensityRay/radiativeIntensityRay.H | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C index 3ef7c1b0e8..cda5e495a0 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C index bc9f0e85d9..4edf09663f 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H index 4c1d3bf31d..a7a95648d4 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License From a909be7d9b8c2ee5aa96e09b9eccc4bc6bd179e5 Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 4 Feb 2011 17:57:52 +0000 Subject: [PATCH 03/72] ENH: pairPatchAgglomeratnio --- src/fvAgglomerationMethods/Allwmake | 2 + .../pairPatchAgglomeration/Make/files | 3 + .../pairPatchAgglomeration/Make/options | 10 + .../pairPatchAgglomeration.C | 528 ++++++++++++++++++ .../pairPatchAgglomeration.H | 221 ++++++++ .../pairPatchAgglomerationTemplates.C | 79 +++ 6 files changed, 843 insertions(+) create mode 100644 src/fvAgglomerationMethods/pairPatchAgglomeration/Make/files create mode 100644 src/fvAgglomerationMethods/pairPatchAgglomeration/Make/options create mode 100644 src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C create mode 100644 src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.H create mode 100644 src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomerationTemplates.C diff --git a/src/fvAgglomerationMethods/Allwmake b/src/fvAgglomerationMethods/Allwmake index 61d951c8c6..8328d915fc 100755 --- a/src/fvAgglomerationMethods/Allwmake +++ b/src/fvAgglomerationMethods/Allwmake @@ -10,4 +10,6 @@ then wmake $makeOption MGridGenGamgAgglomeration fi +wmake libso pairPatchAgglomeration + # ----------------------------------------------------------------- end-of-file diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/Make/files b/src/fvAgglomerationMethods/pairPatchAgglomeration/Make/files new file mode 100644 index 0000000000..275c4795f3 --- /dev/null +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/Make/files @@ -0,0 +1,3 @@ +pairPatchAgglomeration.C + +LIB = $(FOAM_LIBBIN)/libpairPatchAgglomeration diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/Make/options b/src/fvAgglomerationMethods/pairPatchAgglomeration/Make/options new file mode 100644 index 0000000000..6dddff38af --- /dev/null +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/Make/options @@ -0,0 +1,10 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/OpenFOAM/lnInclude + +LIB_LIBS = \ + -lfiniteVolume \ + -lOpenFOAM \ + -lmeshTools + diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C new file mode 100644 index 0000000000..d4657ef5e8 --- /dev/null +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C @@ -0,0 +1,528 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 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 "pairPatchAgglomeration.H" +//#include "OFstream.H" +#include "meshTools.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::pairPatchAgglomeration::compactLevels(const label nCreatedLevels) +{ + nFaces_.setSize(nCreatedLevels); + restrictAddressing_.setSize(nCreatedLevels); + patchLevels_.setSize(nCreatedLevels); +} + + +bool Foam::pairPatchAgglomeration::continueAgglomerating +( + const label nCoarseFaces +) +{ + // Check the need for further agglomeration on all processors + bool contAgg = nCoarseFaces >= nFacesInCoarsestLevel_; + reduce(contAgg, andOp()); + return contAgg; +} + + +void Foam::pairPatchAgglomeration::setBasedEdgeWeights() +{ + const bPatch& coarsePatch = patchLevels_[0]; + forAll(coarsePatch.edges(), i) + { + if(coarsePatch.isInternalEdge(i)) + { + scalar edgeLength = + coarsePatch.edges()[i].mag(coarsePatch.localPoints()); + + const labelList& eFaces = coarsePatch.edgeFaces()[i]; + + if (eFaces.size() == 2) + { + scalar cosI = + coarsePatch.faceNormals()[eFaces[0]] & + coarsePatch.faceNormals()[eFaces[1]]; + + const edge edgeCommon = edge(eFaces[0], eFaces[1]); + + if(facePairWeight_.found(edgeCommon)) + { + facePairWeight_[edgeCommon] += edgeLength; + } + else + { + facePairWeight_.insert(edgeCommon, edgeLength); + } + + if + ( + cosI < + Foam::cos + ( + featureAngle_*constant::mathematical::pi/180.0 + ) + ) + { + facePairWeight_[edgeCommon] = -1.0; + } + } + else if (eFaces.size() == 3) + { + facePairWeight_.insert(edge(eFaces[1], eFaces[0]), -1.0); + facePairWeight_.insert(edge(eFaces[2], eFaces[0]), -1.0); + facePairWeight_.insert(edge(eFaces[1], eFaces[2]), -1.0); + } + } + } +} + + +void Foam::pairPatchAgglomeration::setEdgeWeights +( + const label fineLevelIndex +) +{ + + const bPatch& coarsePatch = patchLevels_[fineLevelIndex]; + + const labelList& fineToCoarse = restrictAddressing_[fineLevelIndex]; + const label nCoarseI = max(fineToCoarse)+1; + labelListList coarseToFine + ( + invertOneToMany(nCoarseI, fineToCoarse) + ); + + HashSet > fineFeaturedFaces(coarsePatch.nEdges()/10); + + // Map fine faces with featured edge into coarse faces + forAllConstIter(EdgeMap, facePairWeight_, iter) + { + if (iter() == -1.0) + { + const edge e = iter.key(); + const edge edgeFeatured + ( + fineToCoarse[e[0]], + fineToCoarse[e[1]] + ); + fineFeaturedFaces.insert(edgeFeatured); + } + } + + // Clean old weitghs + facePairWeight_.clear(); + facePairWeight_.resize(coarsePatch.nEdges()); + + forAll(coarsePatch.edges(), i) + { + if(coarsePatch.isInternalEdge(i)) + { + scalar edgeLength = + coarsePatch.edges()[i].mag(coarsePatch.localPoints()); + + const labelList& eFaces = coarsePatch.edgeFaces()[i]; + + if (eFaces.size() == 2) + { + const edge edgeCommon = edge(eFaces[0], eFaces[1]); + if(facePairWeight_.found(edgeCommon)) + { + facePairWeight_[edgeCommon] += edgeLength; + } + else + { + facePairWeight_.insert(edgeCommon, edgeLength); + } + // If the fine 'pair' faces was featured edge so it is + // the coarse 'pair' + if (fineFeaturedFaces.found(edgeCommon)) + { + facePairWeight_[edgeCommon] = -1.0; + } + } + else if (eFaces.size() == 3) + { + facePairWeight_.insert(edge(eFaces[1], eFaces[0]), -1.0); + facePairWeight_.insert(edge(eFaces[2], eFaces[0]), -1.0); + facePairWeight_.insert(edge(eFaces[1], eFaces[2]), -1.0); + } + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::pairPatchAgglomeration::pairPatchAgglomeration +( + const polyPatch& patch, + const dictionary& controlDict, + const bool additionalWeights +) +: + mergeLevels_ + ( + controlDict.lookupOrDefault