diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C index 96413e02017e72642648bb5c732de4ec9065f5fe..b24f21fe8dfc6d88bac7f046f52353fbcef55fc7 100644 --- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C +++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C @@ -120,11 +120,14 @@ int main(int argc, char *argv[]) "cSf_pos", interpolate(c, pos, T.name())*mesh.magSf() ); + cSf_pos.setOriented(); + surfaceScalarField cSf_neg ( "cSf_neg", interpolate(c, neg, T.name())*mesh.magSf() ); + cSf_neg.setOriented(); surfaceScalarField ap ( @@ -269,4 +272,5 @@ int main(int argc, char *argv[]) return 0; } + // ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C index 65ab9d2db3e9ee7ea9eb3246ec3415bcfae01532..6550d62b28cb858759307c5bcde1c442fcdc6108 100644 --- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C +++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C @@ -101,11 +101,14 @@ int main(int argc, char *argv[]) "cSf_pos", interpolate(c, pos, T.name())*mesh.magSf() ); + cSf_pos.setOriented(); + surfaceScalarField cSf_neg ( "cSf_neg", interpolate(c, neg, T.name())*mesh.magSf() ); + cSf_neg.setOriented(); surfaceScalarField ap ( diff --git a/applications/solvers/lagrangian/reactingParcelFoam/simpleReactingParcelFoam/simpleReactingParcelFoam.C b/applications/solvers/lagrangian/reactingParcelFoam/simpleReactingParcelFoam/simpleReactingParcelFoam.C index b3504da91a555bc5c0402bdf0c1a6bbf5c591ca7..bbec4a41ab9062ac64daa3258e8f8bad7b3169b0 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/simpleReactingParcelFoam/simpleReactingParcelFoam.C +++ b/applications/solvers/lagrangian/reactingParcelFoam/simpleReactingParcelFoam/simpleReactingParcelFoam.C @@ -38,7 +38,6 @@ Description #include "basicReactingMultiphaseCloud.H" #include "rhoCombustionModel.H" #include "radiationModel.H" -#include "IOporosityModelList.H" #include "fvOptions.H" #include "SLGThermo.H" #include "simpleControl.H" diff --git a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C index 55175d8d8049ecfdb9d9078b3526898a724bac21..627dd41b6f2ec5316cdcae0c0c1031a9759680c6 100644 --- a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C +++ b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C @@ -113,6 +113,7 @@ Foam::multiphaseMixtureThermo::multiphaseMixtureThermo 1e-8/pow(average(mesh_.V()), 1.0/3.0) ) { + rhoPhi_.setOriented(); calcAlphas(); alphas_.write(); correct(); @@ -698,6 +699,7 @@ Foam::multiphaseMixtureThermo::surfaceTensionForce() const ); surfaceScalarField& stf = tstf.ref(); + stf.setOriented(); forAllConstIter(PtrDictionary<phaseModel>, phases_, phase1) { diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C index 798e9c2eb6c6d997f8c7fcd211a6708b6ad9fc52..de3084f69f010f2262fe66fa76156a3b4b0b1f19 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C +++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C @@ -801,6 +801,7 @@ Foam::tmp<Foam::surfaceScalarField> Foam::multiphaseSystem::surfaceTension ) ) ); + tSurfaceTension.ref().setOriented(); forAllConstIter(PtrDictionary<phaseModel>, phases_, iter) { diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/phaseModel/phaseModel.C b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/phaseModel/phaseModel.C index a1990a88c9ca733c6be593cd5deb9f773f71ba47..224d0345d6ddc8481542d436e11399fa4187a0f3 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/phaseModel/phaseModel.C +++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/phaseModel/phaseModel.C @@ -113,6 +113,8 @@ Foam::phaseModel::phaseModel dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0) ) { + alphaPhi_.setOriented(); + const word phiName = IOobject::groupName("phi", name_); IOobject phiHeader diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C index 21b5edefe45313803f02ade0c7b9a61f156d0e3f..b6144051a45c09a63b963531718910eeda82a49e 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C +++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C @@ -128,6 +128,8 @@ Foam::multiphaseMixture::multiphaseMixture 1e-8/pow(average(mesh_.V()), 1.0/3.0) ) { + rhoPhi_.setOriented(); + calcAlphas(); alphas_.write(); } @@ -273,6 +275,7 @@ Foam::multiphaseMixture::surfaceTensionForce() const ); surfaceScalarField& stf = tstf.ref(); + stf.setOriented(); forAllConstIter(PtrDictionary<phase>, phases_, iter1) { diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C index 64345bf7597e09c64a97bed915b70398d89a1c61..2213f1a7253e0ca60ca47724196492e1e8a551ad 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C @@ -455,6 +455,7 @@ Foam::BlendedInterfacialModel<ModelType>::Ff() const dimensionedScalar("zero", ModelType::dimF*dimArea, 0) ) ); + x.ref().setOriented(); if (model_.valid()) { diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C index b9859eb41d07956825a509ce71274b1b8249dade..02969b89cb86825dda8f261d7118df25cbe53164 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C @@ -347,7 +347,7 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::Ff } else { - return tmp<surfaceScalarField> + tmp<surfaceScalarField> tFf ( new surfaceScalarField ( @@ -364,6 +364,10 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::Ff dimensionedScalar("zero", liftModel::dimF*dimArea, 0) ) ); + + tFf.ref().setOriented(); + + return tFf; } } @@ -621,6 +625,8 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::setPhiD ) ) ); + + phiDs[phasei].setOriented(); } return phiDs[phasei]; diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/MovingPhaseModel/MovingPhaseModel.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/MovingPhaseModel/MovingPhaseModel.C index 0605c1171e8a09bcacf947f03036335ab38851ba..2afa388aca951c7c9a496765af7d099f4eab41d7 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/MovingPhaseModel/MovingPhaseModel.C +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseModel/MovingPhaseModel/MovingPhaseModel.C @@ -200,6 +200,9 @@ Foam::MovingPhaseModel<BasePhaseModel>::MovingPhaseModel dimensionedScalar("0", dimDensity/dimTime, 0) ) { + alphaPhi_.setOriented(); + alphaRhoPhi_.setOriented(); + phi_.writeOpt() = IOobject::AUTO_WRITE; correctKinematics(); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C b/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C index 805d99844e3586f95d33624bc333938cc32b472b..627af1db87f08a5912e12c0dd01a4650f53fcd99 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C @@ -548,6 +548,8 @@ Foam::tmp<Foam::surfaceScalarField> Foam::multiphaseSystem::surfaceTension ) ); + tSurfaceTension.ref().setOriented(); + forAll(phases(), phasej) { const phaseModel& phase2 = phases()[phasej]; diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/phaseModel/phaseModel.C b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/phaseModel/phaseModel.C index 87a249277a33b2fd754c3af103bbf4a8200ffa24..9352b7239733692ed8e5bc2dce356996f764aeea 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/phaseModel/phaseModel.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/phaseModel/phaseModel.C @@ -109,6 +109,9 @@ Foam::phaseModel::phaseModel dimensionedScalar("0", dimensionSet(1, 0, -1, 0, 0), 0) ) { + alphaPhi_.setOriented(); + alphaRhoPhi_.setOriented(); + thermo_->validate("phaseModel " + name_, "h", "e"); const word phiName = IOobject::groupName("phi", name_); diff --git a/applications/test/mapDistributePolyMesh/Make/files b/applications/test/mapDistributePolyMesh/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..eb304044bffb5434b9a322c49b803f4ab42ae0a3 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/Make/files @@ -0,0 +1,3 @@ +Test-mapDistributePolyMesh.C +EXE = $(FOAM_USER_APPBIN)/Test-mapDistributePolyMesh + diff --git a/applications/test/mapDistributePolyMesh/Make/options b/applications/test/mapDistributePolyMesh/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..dc318df99832515cca0862ee9d04aea77fda2baf --- /dev/null +++ b/applications/test/mapDistributePolyMesh/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -ldynamicMesh \ + -lmeshTools diff --git a/applications/test/mapDistributePolyMesh/Test-mapDistributePolyMesh.C b/applications/test/mapDistributePolyMesh/Test-mapDistributePolyMesh.C new file mode 100644 index 0000000000000000000000000000000000000000..a925be3efe8f80c1e0c62959a619d24ceb00ba47 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/Test-mapDistributePolyMesh.C @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Application + mapDistributePolyMesh + +Description + Test for procAddressing + +\*---------------------------------------------------------------------------*/ + +#include "IOmapDistributePolyMesh.H" +#include "argList.H" +#include "Time.H" +#include "surfaceFields.H" +#include "flipOp.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + + Info<< "Reading distribute map\n" << endl; + + const word instance("0.005"); + const scalar instanceValue(0.005); + + + IOobject io + ( + "procAddressing", + instance, + fvMesh::meshSubDir, + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + IOmapDistributePolyMesh map(io); + + { + // Load the instance mesh + runTime.setTime(instanceValue, 0); + polyMesh distributedMesh + ( + IOobject + ( + polyMesh::defaultRegion, + instance, + runTime, + IOobject::MUST_READ + ) + ); + + // Faces, no flip + { + const mapDistribute& faceMap = map.faceMap(); + pointField fc(mesh.faceCentres()); + faceMap.distribute(fc, noOp()); + Pout<< "Construct size:" << faceMap.constructSize() << endl; + forAll(distributedMesh.faceCentres(), facei) + { + Pout<< "face:" << facei + << "\tmappedFc:" << fc[facei] + << "\tactual:" << distributedMesh.faceCentres()[facei] + << endl; + } + } + // Faces, flipped field + { + const mapDistribute& faceMap = map.faceMap(); + scalarField flux(mesh.faceAreas() & vector(1, 1, 1)); + faceMap.distribute(flux, flipOp()); + Pout<< "Construct size:" << faceMap.constructSize() << endl; + const scalarField newFlux + ( + distributedMesh.faceAreas() + & vector(1, 1, 1) + ); + forAll(newFlux, facei) + { + Pout<< "face:" << facei + << "\tmappedFlux:" << flux[facei] + << "\tactual:" << newFlux[facei] + << endl; + } + } + + + { + const mapDistribute& cellMap = map.cellMap(); + pointField cc(mesh.cellCentres()); + cellMap.distribute(cc, noOp()); + Pout<< "Construct size:" << cellMap.constructSize() << endl; + forAll(distributedMesh.cellCentres(), celli) + { + Pout<< "cell:" << celli + << "\tmappedCc:" << cc[celli] + << "\tactual:" << distributedMesh.cellCentres()[celli] + << endl; + } + } + { + const mapDistribute& pointMap = map.pointMap(); + pointField pc(mesh.points()); + pointMap.distribute(pc, noOp()); + Pout<< "Construct size:" << pointMap.constructSize() << endl; + forAll(distributedMesh.points(), pointi) + { + Pout<< "point:" << pointi + << "\tmappedPoint:" << pc[pointi] + << "\tactual:" << distributedMesh.points()[pointi] + << endl; + } + } + } + + Info<< "End\n" << endl; + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/0/U b/applications/test/mapDistributePolyMesh/cavity/0/U new file mode 100644 index 0000000000000000000000000000000000000000..f3ab7eefb66b855923d3c1889ad524e7725d3503 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/0/U @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (1 1 0); + +boundaryField +{ + movingWall + { + type fixedValue; + value uniform (1 0 0); + } + + fixedWalls + { + type fixedValue; + value uniform (0 0 0); + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/0/p b/applications/test/mapDistributePolyMesh/cavity/0/p new file mode 100644 index 0000000000000000000000000000000000000000..0976329cedb48dfa5dff2d203e19418e7e757993 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/0/p @@ -0,0 +1,39 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + movingWall + { + type zeroGradient; + } + + fixedWalls + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/0/phi b/applications/test/mapDistributePolyMesh/cavity/0/phi new file mode 100644 index 0000000000000000000000000000000000000000..0a745bbd5b740a431c8300d9f1b5dcae87fc8d55 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/0/phi @@ -0,0 +1,228 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus.feature-oriented-fields | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class surfaceScalarField; + location "0"; + object fluxU; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 3 -1 0 0 0 0]; +oriented 1; + + +internalField nonuniform List<scalar> +180 +( +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +0.0001 +) +; + +boundaryField +{ + movingWall + { + type calculated; + value uniform 0; + } + fixedWalls + { + type calculated; + value uniform 0; + } + frontAndBack + { + type empty; + value nonuniform 0(); + } +} + + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/Allclean b/applications/test/mapDistributePolyMesh/cavity/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..1ddaee91ff1648c391e96c435bdbf076d0f58b87 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/Allclean @@ -0,0 +1,13 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +cleanCase + +# Restore default dictionaries +cp system/decomposeParDict-2 system/decomposeParDict +cp system/controlDict-startTime system/controlDict + +# ----------------------------------------------------------------------------- diff --git a/applications/test/mapDistributePolyMesh/cavity/Allrun b/applications/test/mapDistributePolyMesh/cavity/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..9afaa5243d9a1630e3a7597ba8f52b83f7bb08d6 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/Allrun @@ -0,0 +1,17 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +runApplication blockMesh + +runApplication decomposePar -decomposeParDict system/decomposeParDict-2 + +runParallel -s scotch -np 5 redistributePar \ + -decomposeParDict system/decomposeParDict-5 + +runParallel -np 5 Test-mapDistributePolyMesh \ + -decomposeParDict system/decomposeParDict-5 + +# ----------------------------------------------------------------------------- diff --git a/applications/test/mapDistributePolyMesh/cavity/cavity.foam b/applications/test/mapDistributePolyMesh/cavity/cavity.foam new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/applications/test/mapDistributePolyMesh/cavity/constant/transportProperties b/applications/test/mapDistributePolyMesh/cavity/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..de00c3587cd9e0a677d63a6a6db42f7a47fa59a9 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/constant/transportProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +nu nu [ 0 2 -1 0 0 0 0 ] 0.01; + + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/blockMeshDict b/applications/test/mapDistributePolyMesh/cavity/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..3118c894d875f5cf3287d1714402b6bd2cd2f48f --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/blockMeshDict @@ -0,0 +1,75 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 0.1; + +vertices +( + (0 0 0) + (1 0 0) + (1 1 0) + (0 1 0) + (0 0 0.1) + (1 0 0.1) + (1 1 0.1) + (0 1 0.1) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (10 10 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + movingWall + { + type wall; + faces + ( + (3 7 6 2) + ); + } + fixedWalls + { + type wall; + faces + ( + (0 4 7 3) + (2 6 5 1) + (1 5 4 0) + ); + } + frontAndBack + { + type empty; + faces + ( + (0 3 2 1) + (4 5 6 7) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/controlDict b/applications/test/mapDistributePolyMesh/cavity/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..78ef7651b9c85152e9d156436115b65ecbde1815 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/controlDict @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application icoFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.5; + +deltaT 0.005; + +writeControl timeStep; + +writeInterval 20; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/controlDict-latestTime b/applications/test/mapDistributePolyMesh/cavity/system/controlDict-latestTime new file mode 100644 index 0000000000000000000000000000000000000000..8b3e003782dfbb2074f524e3971ae7a1a4ddec06 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/controlDict-latestTime @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application icoFoam; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 1.0; + +deltaT 0.005; + +writeControl timeStep; + +writeInterval 20; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/controlDict-startTime b/applications/test/mapDistributePolyMesh/cavity/system/controlDict-startTime new file mode 100644 index 0000000000000000000000000000000000000000..78ef7651b9c85152e9d156436115b65ecbde1815 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/controlDict-startTime @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application icoFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.5; + +deltaT 0.005; + +writeControl timeStep; + +writeInterval 20; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict b/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..8c054db9bbb955510d8a4f8d176e8bb51a1e9eaf --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict @@ -0,0 +1,143 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +//- Keep owner and neighbour on same processor for faces in zones: +// preserveFaceZones (heater solid1 solid3); + +//- Keep owner and neighbour on same processor for faces in patches: +// (makes sense only for cyclic patches) +//preservePatches (cyclic_half0 cyclic_half1); + +//- Keep all of faceSet on a single processor. This puts all cells +// connected with a point, edge or face on the same processor. +// (just having face connected cells might not guarantee a balanced +// decomposition) +// The processor can be -1 (the decompositionMethod chooses the processor +// for a good load balance) or explicitly provided (upsets balance). +//singleProcessorFaceSets ((f0 -1)); + + +//- Keep owner and neighbour of baffles on same processor (i.e. keep it +// detectable as a baffle). Baffles are two boundary face sharing the +// same points. +//preserveBaffles true; + +//- Use the volScalarField named here as a weight for each cell in the +// decomposition. For example, use a particle population field to decompose +// for a balanced number of particles in a lagrangian simulation. +// weightField dsmcRhoNMean; + +method scotch; +//method hierarchical; +// method simple; +// method metis; +// method manual; +// method multiLevel; +// method structured; // does 2D decomposition of structured mesh + +multiLevelCoeffs +{ + // Decomposition methods to apply in turn. This is like hierarchical but + // fully general - every method can be used at every level. + + level0 + { + numberOfSubdomains 64; + //method simple; + //simpleCoeffs + //{ + // n (2 1 1); + // delta 0.001; + //} + method scotch; + } + level1 + { + numberOfSubdomains 4; + method scotch; + } +} + +// Desired output + +simpleCoeffs +{ + n (2 1 1); + delta 0.001; +} + +hierarchicalCoeffs +{ + n (1 2 1); + delta 0.001; + order xyz; +} + +metisCoeffs +{ + /* + processorWeights + ( + 1 + 1 + 1 + 1 + ); + */ +} + +scotchCoeffs +{ + //processorWeights + //( + // 1 + // 1 + // 1 + // 1 + //); + //writeGraph true; + //strategy "b"; +} + +manualCoeffs +{ + dataFile "decompositionData"; +} + +structuredCoeffs +{ + // Patches to do 2D decomposition on. Structured mesh only; cells have + // to be in 'columns' on top of patches. + patches (movingWall); + + // Method to use on the 2D subset + method scotch; +} + +//// Is the case distributed? Note: command-line argument -roots takes +//// precedence +//distributed yes; +//// Per slave (so nProcs-1 entries) the directory above the case. +//roots +//( +// "/tmp" +// "/tmp" +//); + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict-2 b/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict-2 new file mode 100644 index 0000000000000000000000000000000000000000..8c054db9bbb955510d8a4f8d176e8bb51a1e9eaf --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict-2 @@ -0,0 +1,143 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +//- Keep owner and neighbour on same processor for faces in zones: +// preserveFaceZones (heater solid1 solid3); + +//- Keep owner and neighbour on same processor for faces in patches: +// (makes sense only for cyclic patches) +//preservePatches (cyclic_half0 cyclic_half1); + +//- Keep all of faceSet on a single processor. This puts all cells +// connected with a point, edge or face on the same processor. +// (just having face connected cells might not guarantee a balanced +// decomposition) +// The processor can be -1 (the decompositionMethod chooses the processor +// for a good load balance) or explicitly provided (upsets balance). +//singleProcessorFaceSets ((f0 -1)); + + +//- Keep owner and neighbour of baffles on same processor (i.e. keep it +// detectable as a baffle). Baffles are two boundary face sharing the +// same points. +//preserveBaffles true; + +//- Use the volScalarField named here as a weight for each cell in the +// decomposition. For example, use a particle population field to decompose +// for a balanced number of particles in a lagrangian simulation. +// weightField dsmcRhoNMean; + +method scotch; +//method hierarchical; +// method simple; +// method metis; +// method manual; +// method multiLevel; +// method structured; // does 2D decomposition of structured mesh + +multiLevelCoeffs +{ + // Decomposition methods to apply in turn. This is like hierarchical but + // fully general - every method can be used at every level. + + level0 + { + numberOfSubdomains 64; + //method simple; + //simpleCoeffs + //{ + // n (2 1 1); + // delta 0.001; + //} + method scotch; + } + level1 + { + numberOfSubdomains 4; + method scotch; + } +} + +// Desired output + +simpleCoeffs +{ + n (2 1 1); + delta 0.001; +} + +hierarchicalCoeffs +{ + n (1 2 1); + delta 0.001; + order xyz; +} + +metisCoeffs +{ + /* + processorWeights + ( + 1 + 1 + 1 + 1 + ); + */ +} + +scotchCoeffs +{ + //processorWeights + //( + // 1 + // 1 + // 1 + // 1 + //); + //writeGraph true; + //strategy "b"; +} + +manualCoeffs +{ + dataFile "decompositionData"; +} + +structuredCoeffs +{ + // Patches to do 2D decomposition on. Structured mesh only; cells have + // to be in 'columns' on top of patches. + patches (movingWall); + + // Method to use on the 2D subset + method scotch; +} + +//// Is the case distributed? Note: command-line argument -roots takes +//// precedence +//distributed yes; +//// Per slave (so nProcs-1 entries) the directory above the case. +//roots +//( +// "/tmp" +// "/tmp" +//); + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict-5 b/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict-5 new file mode 100644 index 0000000000000000000000000000000000000000..0692228c7c8437894a89a99d023d5a0031babb27 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict-5 @@ -0,0 +1,143 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 5; + +//- Keep owner and neighbour on same processor for faces in zones: +// preserveFaceZones (heater solid1 solid3); + +//- Keep owner and neighbour on same processor for faces in patches: +// (makes sense only for cyclic patches) +//preservePatches (cyclic_half0 cyclic_half1); + +//- Keep all of faceSet on a single processor. This puts all cells +// connected with a point, edge or face on the same processor. +// (just having face connected cells might not guarantee a balanced +// decomposition) +// The processor can be -1 (the decompositionMethod chooses the processor +// for a good load balance) or explicitly provided (upsets balance). +//singleProcessorFaceSets ((f0 -1)); + + +//- Keep owner and neighbour of baffles on same processor (i.e. keep it +// detectable as a baffle). Baffles are two boundary face sharing the +// same points. +//preserveBaffles true; + +//- Use the volScalarField named here as a weight for each cell in the +// decomposition. For example, use a particle population field to decompose +// for a balanced number of particles in a lagrangian simulation. +// weightField dsmcRhoNMean; + +method scotch; +//method hierarchical; +// method simple; +// method metis; +// method manual; +// method multiLevel; +// method structured; // does 2D decomposition of structured mesh + +multiLevelCoeffs +{ + // Decomposition methods to apply in turn. This is like hierarchical but + // fully general - every method can be used at every level. + + level0 + { + numberOfSubdomains 64; + //method simple; + //simpleCoeffs + //{ + // n (2 1 1); + // delta 0.001; + //} + method scotch; + } + level1 + { + numberOfSubdomains 4; + method scotch; + } +} + +// Desired output + +simpleCoeffs +{ + n (2 1 1); + delta 0.001; +} + +hierarchicalCoeffs +{ + n (1 2 1); + delta 0.001; + order xyz; +} + +metisCoeffs +{ + /* + processorWeights + ( + 1 + 1 + 1 + 1 + ); + */ +} + +scotchCoeffs +{ + //processorWeights + //( + // 1 + // 1 + // 1 + // 1 + //); + //writeGraph true; + //strategy "b"; +} + +manualCoeffs +{ + dataFile "decompositionData"; +} + +structuredCoeffs +{ + // Patches to do 2D decomposition on. Structured mesh only; cells have + // to be in 'columns' on top of patches. + patches (movingWall); + + // Method to use on the 2D subset + method scotch; +} + +//// Is the case distributed? Note: command-line argument -roots takes +//// precedence +//distributed yes; +//// Per slave (so nProcs-1 entries) the directory above the case. +//roots +//( +// "/tmp" +// "/tmp" +//); + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict-hierarchical b/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict-hierarchical new file mode 100644 index 0000000000000000000000000000000000000000..4914ae5e029b602c9d6ff3b27bfce7bc6c557398 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict-hierarchical @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +method hierarchical; + +hierarchicalCoeffs +{ + n (1 2 1); + delta 0.001; + order xyz; +} + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict-scotch b/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict-scotch new file mode 100644 index 0000000000000000000000000000000000000000..9df92a84e456a9513c9fc1a9cf9db324fe67ccbd --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/decomposeParDict-scotch @@ -0,0 +1,28 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +//method scotch; +method hierarchical; +hierarchicalCoeffs +{ + n (2 1 1); + delta 0.001; + order xyz; +} +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/fvSchemes b/applications/test/mapDistributePolyMesh/cavity/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..b43ea748acac4a463d3b4345302831e83227cce6 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/fvSchemes @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; + grad(p) Gauss linear; +} + +divSchemes +{ + default none; + div(phi,U) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/fvSolution b/applications/test/mapDistributePolyMesh/cavity/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..3be65f5ab562344fb13785933c69541e9b74ccba --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/fvSolution @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "(p|pFinal)" + { + solver PCG; + preconditioner DIC; + tolerance 1e-06; + relTol 0; + } + + U + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-05; + relTol 0; + } +} + +PISO +{ + nCorrectors 2; + nNonOrthogonalCorrectors 0; + pRefCell 0; + pRefValue 0; +} + + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/processorField b/applications/test/mapDistributePolyMesh/cavity/system/processorField new file mode 100644 index 0000000000000000000000000000000000000000..19c72f5418f12d49627896aa1ff317a2d288416a --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/processorField @@ -0,0 +1,64 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object postProcessingDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +functions +{ + processorField + { + // Type of functionObject + type processorField; + + // Where to load it from (if not already in solver) + libs ("libfieldFunctionObjects.so"); + + // Function object enabled flag + enabled true; + + // When to output the average fields + writeControl writeTime; + } + cellID + { + // Load the library containing the 'coded' functionObject + functionObjectLibs ("libutilityFunctionObjects.so"); + type coded; + // Name of on-the-fly generated functionObject + redirectType cellID; + codeExecute + #{ + volScalarField cellID + ( + IOobject + ( + "cellID", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ + ), + mesh(), + dimensionedScalar("cellID", dimless, 0) + ); + forAll(cellID, celli) + { + cellID[celli] = celli; + } + cellID.correctBoundaryConditions(); + cellID.write(); + #}; + } +} + +// ************************************************************************* // diff --git a/applications/test/mapDistributePolyMesh/cavity/system/renumberMeshDict-random b/applications/test/mapDistributePolyMesh/cavity/system/renumberMeshDict-random new file mode 100644 index 0000000000000000000000000000000000000000..67631d08ee7fb015c2b803817018d376ac1c7e23 --- /dev/null +++ b/applications/test/mapDistributePolyMesh/cavity/system/renumberMeshDict-random @@ -0,0 +1,112 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh renumbering dictionary"; + object renumberMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Write maps from renumbered back to original mesh +writeMaps true; + +// Optional entry: sort cells on coupled boundaries to last for use with +// e.g. nonBlockingGaussSeidel. +sortCoupledFaceCells false; + +// Optional entry: renumber on a block-by-block basis. It uses a +// blockCoeffs dictionary to construct a decompositionMethod to do +// a block subdivision) and then applies the renumberMethod to each +// block in turn. This can be used in large cases to keep the blocks +// fitting in cache with all the the cache misses bunched at the end. +// This number is the approximate size of the blocks - this gets converted +// to a number of blocks that is the input to the decomposition method. +//blockSize 1000; + +// Optional entry: sort points into internal and boundary points +//orderPoints false; + +// Optional: suppress renumbering cellSets,faceSets,pointSets +//renumberSets false; + + +//method CuthillMcKee; +//method Sloan; +//method manual; +method random; +//method structured; +//method spring; +//method zoltan; // only if compiled with zoltan support + +//CuthillMcKeeCoeffs +//{ +// // Reverse CuthillMcKee (RCM) or plain +// reverse true; +//} + +manualCoeffs +{ + // In system directory: new-to-original (i.e. order) labelIOList + dataFile "cellMap"; +} + + +// For extruded (i.e. structured in one direction) meshes +structuredCoeffs +{ + // Patches that mesh was extruded from. These determine the starting + // layer of cells + patches (movingWall); + // Method to renumber the starting layer of cells + method random; + + // Renumber in columns (depthFirst) or in layers + depthFirst true; + + // Reverse ordering + reverse false; +} + + +springCoeffs +{ + // Maximum jump of cell indices. Is fraction of number of cells + maxCo 0.01; + + // Limit the amount of movement; the fraction maxCo gets decreased + // with every iteration + freezeFraction 0.999; + + // Maximum number of iterations + maxIter 1000; +} + + +blockCoeffs +{ + method scotch; + //method hierarchical; + //hierarchicalCoeffs + //{ + // n (1 2 1); + // delta 0.001; + // order xyz; + //} +} + + +zoltanCoeffs +{ + ORDER_METHOD LOCAL_HSFC; +} + + +// ************************************************************************* // diff --git a/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructorReconstructFields.C b/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructorReconstructFields.C index 3df020099ff8f3d0ed08d3271c9c47e9682c9391..c561dc71839cba0209c9f3ccc1c584eb22884d82 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructorReconstructFields.C +++ b/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructorReconstructFields.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,7 +66,7 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeInternalField IOobject::NO_WRITE ); - return tmp<DimensionedField<Type, volMesh>> + tmp<DimensionedField<Type, volMesh>> tfield ( new DimensionedField<Type, volMesh> ( @@ -76,6 +76,10 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeInternalField internalField ) ); + + tfield.ref().oriented() = fld.oriented(); + + return tfield; } @@ -209,7 +213,7 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeField IOobject::NO_WRITE ); - return tmp<GeometricField<Type, fvPatchField, volMesh>> + tmp<GeometricField<Type, fvPatchField, volMesh>> tfield ( new GeometricField<Type, fvPatchField, volMesh> ( @@ -220,6 +224,10 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeField basePatchFields ) ); + + tfield.ref().oriented()= fld.oriented(); + + return tfield; } @@ -269,7 +277,7 @@ Foam::parFvFieldReconstructor::reconstructFvSurfaceField } // Map all faces - Field<Type> internalField(flatFld, mapper); + Field<Type> internalField(flatFld, mapper, fld.oriented()()); // Trim to internal faces (note: could also have special mapper) internalField.setSize @@ -372,7 +380,7 @@ Foam::parFvFieldReconstructor::reconstructFvSurfaceField IOobject::NO_WRITE ); - return tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> + tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tfield ( new GeometricField<Type, fvsPatchField, surfaceMesh> ( @@ -383,6 +391,10 @@ Foam::parFvFieldReconstructor::reconstructFvSurfaceField basePatchFields ) ); + + tfield.ref().oriented() = fld.oriented(); + + return tfield; } diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 41d694211aae5135d8340335133f0080fc7976e2..f95dc85741bbcb8bb740606b61ea57a538c00f11 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -275,6 +275,8 @@ dimensionedTypes/dimensionedSphericalTensor/dimensionedSphericalTensor.C dimensionedTypes/dimensionedSymmTensor/dimensionedSymmTensor.C dimensionedTypes/dimensionedTensor/dimensionedTensor.C +orientedType/orientedType.C + matrices/solution/solution.C scalarMatrices = matrices/scalarMatrices diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C index 5823ee3f57c1ea360c962e4119788cf50acd18d4..e4717cd7fecf18ee9a9d749e39859c49bd0388b4 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C @@ -80,7 +80,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(io), Field<Type>(field), mesh_(mesh), - dimensions_(dims) + dimensions_(dims), + oriented_() { checkFieldSize(); } @@ -134,7 +135,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(io), Field<Type>(GeoMesh::size(mesh)), mesh_(mesh), - dimensions_(dims) + dimensions_(dims), + oriented_() { if (checkIOFlags) { @@ -155,7 +157,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(io), Field<Type>(GeoMesh::size(mesh), dt.value()), mesh_(mesh), - dimensions_(dt.dimensions()) + dimensions_(dt.dimensions()), + oriented_() { if (checkIOFlags) { @@ -173,7 +176,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(df), Field<Type>(df), mesh_(df.mesh_), - dimensions_(df.dimensions_) + dimensions_(df.dimensions_), + oriented_(df.oriented_) {} @@ -187,7 +191,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(df, reuse), Field<Type>(df, reuse), mesh_(df.mesh_), - dimensions_(df.dimensions_) + dimensions_(df.dimensions_), + oriented_(df.oriented_) {} @@ -200,7 +205,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(df(), true), Field<Type>(df), mesh_(df->mesh_), - dimensions_(df->dimensions_) + dimensions_(df->dimensions_), + oriented_(df->oriented_) {} @@ -218,7 +224,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField tdf.isTmp() ), mesh_(tdf().mesh_), - dimensions_(tdf().dimensions_) + dimensions_(tdf().dimensions_), + oriented_(tdf().oriented_) { tdf.clear(); } @@ -235,7 +242,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(io), Field<Type>(df), mesh_(df.mesh_), - dimensions_(df.dimensions_) + dimensions_(df.dimensions_), + oriented_(df.oriented_) {} @@ -250,7 +258,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(io, df), Field<Type>(df, reuse), mesh_(df.mesh_), - dimensions_(df.dimensions_) + dimensions_(df.dimensions_), + oriented_(df.oriented_) {} @@ -264,7 +273,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(newName, df, newName == df.name()), Field<Type>(df), mesh_(df.mesh_), - dimensions_(df.dimensions_) + dimensions_(df.dimensions_), + oriented_(df.oriented_) {} @@ -279,7 +289,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(newName, df, true), Field<Type>(df, reuse), mesh_(df.mesh_), - dimensions_(df.dimensions_) + dimensions_(df.dimensions_), + oriented_(df.oriented_) {} @@ -293,7 +304,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(newName, df, true), Field<Type>(df), mesh_(df->mesh_), - dimensions_(df->dimensions_) + dimensions_(df->dimensions_), + oriented_(df->oriented_) {} @@ -312,7 +324,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField tdf.isTmp() ), mesh_(tdf().mesh_), - dimensions_(tdf().dimensions_) + dimensions_(tdf().dimensions_), + oriented_(tdf().oriented_) { tdf.clear(); } @@ -487,6 +500,7 @@ void DimensionedField<Type, GeoMesh>::operator= checkField(*this, df, "="); dimensions_ = df.dimensions(); + oriented_ = df.oriented(); Field<Type>::operator=(df); } @@ -510,6 +524,7 @@ void DimensionedField<Type, GeoMesh>::operator= checkField(*this, df, "="); dimensions_ = df.dimensions(); + oriented_ = df.oriented(); this->transfer(const_cast<DimensionedField<Type, GeoMesh>&>(df)); tdf.clear(); } @@ -537,6 +552,7 @@ void DimensionedField<Type, GeoMesh>::operator op \ checkField(*this, df, #op); \ \ dimensions_ op df.dimensions(); \ + oriented_ op df.oriented(); \ Field<Type>::operator op(df); \ } \ \ diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H index b37c63724fcc35b71d80e2f131b78ede67087687..e37bcccc214413a624a3c6d3c39637f307da5775 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H @@ -41,6 +41,7 @@ SourceFiles #include "regIOobject.H" #include "Field.H" #include "dimensionedType.H" +#include "orientedType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -65,7 +66,7 @@ template<class Type, class GeoMesh> Ostream& operator<< /*---------------------------------------------------------------------------*\ - Class DimensionedField Declaration + Class DimensionedField Declaration \*---------------------------------------------------------------------------*/ template<class Type, class GeoMesh> @@ -99,6 +100,9 @@ private: //- Dimension set for this field dimensionSet dimensions_; + //- Oriented flag + orientedType oriented_; + // Private Member Functions @@ -283,6 +287,15 @@ public: //- Return non-const access to dimensions inline dimensionSet& dimensions(); + //- Return oriented type + inline const orientedType& oriented() const; + + //- Return non-const access to the oriented type + inline orientedType& oriented(); + + //- Set the oriented flag + inline void setOriented(const bool oriented = true); + //- Return field inline const Field<Type>& field() const; diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctionsM.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctionsM.C index 6da09d945c4afbdddffaf9d023134f39a0e2f9a6..8e69d617454b145dbf6a30fb6f1f19305b3ddcba 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctionsM.C +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctionsM.C @@ -52,6 +52,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \ \ Func(tRes.ref().field(), df1.field()); \ \ + tRes.ref().oriented() = Dfunc(df1.oriented()); \ + \ return tRes; \ } \ \ @@ -75,6 +77,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \ \ Func(tRes.ref().field(), df1.field()); \ \ + tRes.ref().oriented() = Dfunc(df1.oriented()); \ + \ tdf1.clear(); \ \ return tRes; \ @@ -108,6 +112,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ \ Foam::OpFunc(tRes.ref().field(), df1.field()); \ \ + tRes.ref().oriented() = Dfunc(df1.oriented()); \ + \ return tRes; \ } \ \ @@ -131,6 +137,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ \ Foam::OpFunc(tRes.ref().field(), df1.field()); \ \ + tRes.ref().oriented() = Dfunc(df1.oriented()); \ + \ tdf1.clear(); \ \ return tRes; \ @@ -165,6 +173,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \ \ Func(tRes.ref().field(), df1.field(), df2.field()); \ \ + tRes.ref().oriented() = Func(df1.oriented(), df2.oriented()); \ + \ return tRes; \ } \ \ @@ -189,6 +199,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \ \ Func(tRes.ref().field(), df1.field(), df2.field()); \ \ + tRes.ref().oriented() = Func(df1.oriented(), df2.oriented()); \ + \ tdf2.clear(); \ \ return tRes; \ @@ -215,6 +227,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \ \ Func(tRes.ref().field(), df1.field(), df2.field()); \ \ + tRes.ref().oriented() = Func(df1.oriented(), df2.oriented()); \ + \ tdf1.clear(); \ \ return tRes; \ @@ -244,6 +258,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \ \ Func(tRes.ref().field(), df1.field(), df2.field()); \ \ + tRes.ref().oriented() = Func(df1.oriented(), df2.oriented()); \ + \ tdf1.clear(); \ tdf2.clear(); \ \ @@ -279,6 +295,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \ \ Func(tRes.ref().field(), dt1.value(), df2.field()); \ \ + tRes.ref().oriented() = df2.oriented(); \ + \ return tRes; \ } \ \ @@ -314,6 +332,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \ \ Func(tRes.ref().field(), dt1.value(), df2.field()); \ \ + tRes.ref().oriented() = df2.oriented(); \ + \ tdf2.clear(); \ \ return tRes; \ @@ -356,6 +376,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \ \ Func(tRes.ref().field(), df1.field(), dt2.value()); \ \ + tRes.ref().oriented() = df1.oriented(); \ + \ return tRes; \ } \ \ @@ -391,6 +413,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \ \ Func(tRes.ref().field(), df1.field(), dt2.value()); \ \ + tRes.ref().oriented() = df1.oriented(); \ + \ tdf1.clear(); \ \ return tRes; \ @@ -440,6 +464,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ \ Foam::OpFunc(tRes.ref().field(), df1.field(), df2.field()); \ \ + tRes.ref().oriented() = df1.oriented() Op df2.oriented(); \ + \ return tRes; \ } \ \ @@ -464,6 +490,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ \ Foam::OpFunc(tRes.ref().field(), df1.field(), df2.field()); \ \ + tRes.ref().oriented() = df1.oriented() Op df2.oriented(); \ + \ tdf2.clear(); \ \ return tRes; \ @@ -490,6 +518,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ \ Foam::OpFunc(tRes.ref().field(), df1.field(), df2.field()); \ \ + tRes.ref().oriented() = df1.oriented() Op df2.oriented(); \ + \ tdf1.clear(); \ \ return tRes; \ @@ -519,6 +549,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ \ Foam::OpFunc(tRes.ref().field(), df1.field(), df2.field()); \ \ + tRes.ref().oriented() = df1.oriented() Op df2.oriented(); \ + \ tdf1.clear(); \ tdf2.clear(); \ \ @@ -528,7 +560,7 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \ +#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \ \ TEMPLATE \ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ @@ -552,6 +584,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ ) \ ); \ \ + tRes.ref().oriented() = df2.oriented(); \ + \ Foam::OpFunc(tRes.ref().field(), dt1.value(), df2.field()); \ \ return tRes; \ @@ -589,6 +623,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ \ Foam::OpFunc(tRes.ref().field(), dt1.value(), tdf2().field()); \ \ + tRes.ref().oriented() = df2.oriented(); \ + \ tdf2.clear(); \ \ return tRes; \ @@ -605,7 +641,7 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ } -#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc) \ +#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc) \ \ TEMPLATE \ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ @@ -631,6 +667,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ \ Foam::OpFunc(tRes.ref().field(), df1.field(), dt2.value()); \ \ + tRes.ref().oriented() = df1.oriented(); \ + \ return tRes; \ } \ \ @@ -666,6 +704,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ \ Foam::OpFunc(tRes.ref().field(), tdf1().field(), dt2.value()); \ \ + tRes.ref().oriented() = df1.oriented(); \ + \ tdf1.clear(); \ \ return tRes; \ diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldI.H b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldI.H index 64cfd315895bc29de04ac1b18ceb88dc4e2b8fd3..b4a5b5d8b5afdca66c34240db825b06be1b9a2bd 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldI.H +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldI.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,14 +48,39 @@ Foam::DimensionedField<Type, GeoMesh>::dimensions() const return dimensions_; } + template<class Type, class GeoMesh> -inline Foam::dimensionSet& -Foam::DimensionedField<Type, GeoMesh>::dimensions() +inline Foam::dimensionSet& Foam::DimensionedField<Type, GeoMesh>::dimensions() { return dimensions_; } +template<class Type, class GeoMesh> +inline const Foam::orientedType& +Foam::DimensionedField<Type, GeoMesh>::oriented() const +{ + return oriented_; +} + + +template<class Type, class GeoMesh> +inline Foam::orientedType& Foam::DimensionedField<Type, GeoMesh>::oriented() +{ + return oriented_; +} + + +template<class Type, class GeoMesh> +inline void Foam::DimensionedField<Type, GeoMesh>::setOriented +( + const bool oriented +) +{ + oriented_.setOriented(oriented); +} + + template<class Type, class GeoMesh> inline const Foam::Field<Type>& Foam::DimensionedField<Type, GeoMesh>::field() const @@ -63,6 +88,7 @@ Foam::DimensionedField<Type, GeoMesh>::field() const return *this; } + template<class Type, class GeoMesh> inline Foam::Field<Type>& Foam::DimensionedField<Type, GeoMesh>::field() diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldIO.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldIO.C index 74da71025c3122c36fe03cdb041c232f742a9b6f..7bbd460d36bedad46bee772cb05224a0a26d0a99 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldIO.C +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldIO.C @@ -37,6 +37,7 @@ void Foam::DimensionedField<Type, GeoMesh>::readField ) { dimensions_.reset(dimensionSet(fieldDict.lookup("dimensions"))); + oriented_.read(fieldDict); Field<Type> f(fieldDictEntry, fieldDict, GeoMesh::size(mesh_)); this->transfer(f); @@ -74,7 +75,8 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(io), Field<Type>(0), mesh_(mesh), - dimensions_(dimless) + dimensions_(dimless), + oriented_() { readField(dictionary(readStream(typeName)), fieldDictEntry); } @@ -92,7 +94,8 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField regIOobject(io), Field<Type>(0), mesh_(mesh), - dimensions_(dimless) + dimensions_(dimless), + oriented_() { readField(fieldDict, fieldDictEntry); } @@ -107,17 +110,15 @@ bool Foam::DimensionedField<Type, GeoMesh>::writeData const word& fieldDictEntry ) const { - os.writeKeyword("dimensions") << dimensions() << token::END_STATEMENT - << nl << nl; + os.writeEntry("dimensions", dimensions()); + oriented_.writeEntry(os); + + os<< nl << nl; Field<Type>::writeEntry(fieldDictEntry, os); // Check state of Ostream - os.check - ( - "bool DimensionedField<Type, GeoMesh>::writeData" - "(Ostream& os, const word& fieldDictEntry) const" - ); + os.check(FUNCTION_NAME); return (os.good()); } diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C index f60ed5047b5ad7b94800058aa22e4470de4224bd..f6ca2a766c6e02a958545682b2fa1bccd38e7b6f 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.C +++ b/src/OpenFOAM/fields/Fields/Field/Field.C @@ -28,7 +28,6 @@ License #include "dictionary.H" #include "contiguous.H" #include "mapDistributeBase.H" -#include "flipOp.H" // * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index b75ce6c3eb9c1c7e05df31ccac672b905168f404..74ba7e39e25e5b2d036d5dc853867aec89d93cd1 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -1175,6 +1175,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator= // Only assign field contents not ID this->dimensions() = gf.dimensions(); + this->oriented() = gf.oriented(); if (tgf.isTmp()) { @@ -1246,7 +1247,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ { \ checkField(*this, gf, #op); \ \ - ref() op gf(); \ + ref() op gf(); \ boundaryFieldRef() op gf.boundaryField(); \ } \ \ @@ -1266,7 +1267,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ const dimensioned<TYPE>& dt \ ) \ { \ - ref() op dt; \ + ref() op dt; \ boundaryFieldRef() op dt.value(); \ } diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C index 49a7ce2d62202ceaa566ae33c7fd9a2496e5141d..4113b1d752b68430395af1e3d0231123cd9eb69a 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C @@ -51,6 +51,7 @@ void component { component(gcf.primitiveFieldRef(), gf.primitiveField(), d); component(gcf.boundaryFieldRef(), gf.boundaryField(), d); + gcf.oriented() = gf.oriented(); } @@ -63,6 +64,7 @@ void T { T(gf.primitiveFieldRef(), gf1.primitiveField()); T(gf.boundaryFieldRef(), gf1.boundaryField()); + gf.oriented() = gf1.oriented(); } @@ -81,6 +83,7 @@ void pow { pow(gf.primitiveFieldRef(), gf1.primitiveField(), r); pow(gf.boundaryFieldRef(), gf1.boundaryField(), r); + gf.oriented() = pow(gf1.oriented(), r); } template @@ -175,6 +178,7 @@ void sqr { sqr(gf.primitiveFieldRef(), gf1.primitiveField()); sqr(gf.boundaryFieldRef(), gf1.boundaryField()); + gf.oriented() = sqr(gf1.oriented()); } template<class Type, template<class> class PatchField, class GeoMesh> @@ -263,6 +267,7 @@ void magSqr { magSqr(gsf.primitiveFieldRef(), gf.primitiveField()); magSqr(gsf.boundaryFieldRef(), gf.boundaryField()); + gsf.oriented() = magSqr(gf.oriented()); } template<class Type, template<class> class PatchField, class GeoMesh> @@ -335,6 +340,7 @@ void mag { mag(gsf.primitiveFieldRef(), gf.primitiveField()); mag(gsf.boundaryFieldRef(), gf.boundaryField()); + gsf.oriented() = mag(gf.oriented()); } template<class Type, template<class> class PatchField, class GeoMesh> @@ -412,6 +418,7 @@ void cmptAv { cmptAv(gcf.primitiveFieldRef(), gf.primitiveField()); cmptAv(gcf.boundaryFieldRef(), gf.boundaryField()); + gcf.oriented() = cmptAv(gf.oriented()); } template<class Type, template<class> class PatchField, class GeoMesh> @@ -611,6 +618,8 @@ void opFunc \ gf1.boundaryField(), \ gf2.boundaryField() \ ); \ + \ + gf.oriented() = gf1.oriented() op gf2.oriented(); \ } \ \ template \ @@ -757,6 +766,7 @@ void opFunc \ { \ Foam::opFunc(gf.primitiveFieldRef(), gf1.primitiveField(), dvs.value()); \ Foam::opFunc(gf.boundaryFieldRef(), gf1.boundaryField(), dvs.value()); \ + gf.oriented() = gf1.oriented(); \ } \ \ template \ @@ -870,6 +880,7 @@ void opFunc \ { \ Foam::opFunc(gf.primitiveFieldRef(), dvs.value(), gf1.primitiveField()); \ Foam::opFunc(gf.boundaryFieldRef(), dvs.value(), gf1.boundaryField()); \ + gf.oriented() = gf1.oriented(); \ } \ \ template \ diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctionsM.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctionsM.C index 377339dae972d2c59c39574d9f129392b9ac405e..9ff2ed8639cca3cd015240e441ce8c9249b7a23e 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctionsM.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctionsM.C @@ -43,6 +43,7 @@ void Func \ { \ Foam::Func(res.primitiveFieldRef(), gf1.primitiveField()); \ Foam::Func(res.boundaryFieldRef(), gf1.boundaryField()); \ + res.oriented() = gf1.oriented(); \ } \ \ TEMPLATE \ @@ -112,6 +113,7 @@ void OpFunc \ { \ Foam::OpFunc(res.primitiveFieldRef(), gf1.primitiveField()); \ Foam::OpFunc(res.boundaryFieldRef(), gf1.boundaryField()); \ + res.oriented() = gf1.oriented(); \ } \ \ TEMPLATE \ @@ -192,6 +194,7 @@ void Func \ gf1.boundaryField(), \ gf2.boundaryField() \ ); \ + res.oriented() = Func(gf1.oriented(), gf2.oriented()); \ } \ \ TEMPLATE \ @@ -320,6 +323,7 @@ void Func \ { \ Foam::Func(res.primitiveFieldRef(), dt1.value(), gf2.primitiveField()); \ Foam::Func(res.boundaryFieldRef(), dt1.value(), gf2.boundaryField()); \ + res.oriented() = gf2.oriented(); \ } \ \ TEMPLATE \ @@ -411,6 +415,7 @@ void Func \ { \ Foam::Func(res.primitiveFieldRef(), gf1.primitiveField(), dt2.value()); \ Foam::Func(res.boundaryFieldRef(), gf1.boundaryField(), dt2.value()); \ + res.oriented() = gf1.oriented(); \ } \ \ TEMPLATE \ @@ -511,6 +516,7 @@ void OpFunc \ (res.primitiveFieldRef(), gf1.primitiveField(), gf2.primitiveField()); \ Foam::OpFunc \ (res.boundaryFieldRef(), gf1.boundaryField(), gf2.boundaryField()); \ + res.oriented() = gf1.oriented() Op gf2.oriented(); \ } \ \ TEMPLATE \ @@ -639,6 +645,8 @@ void OpFunc \ { \ Foam::OpFunc(res.primitiveFieldRef(), dt1.value(), gf2.primitiveField()); \ Foam::OpFunc(res.boundaryFieldRef(), dt1.value(), gf2.boundaryField()); \ + res.oriented() = gf2.oriented(); \ + \ } \ \ TEMPLATE \ @@ -730,6 +738,7 @@ void OpFunc \ { \ Foam::OpFunc(res.primitiveFieldRef(), gf1.primitiveField(), dt2.value()); \ Foam::OpFunc(res.boundaryFieldRef(), gf1.boundaryField(), dt2.value()); \ + res.oriented() = gf1.oriented(); \ } \ \ TEMPLATE \ diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/MapGeometricFields.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/MapGeometricFields.H index 93a47eda9fe07e933a2c699b299ebf86e72d7f9d..864318a4b0015dbff681a43458300afbb848d7df 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/MapGeometricFields.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/MapGeometricFields.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,7 +51,7 @@ public: void operator() ( - Field<Type>& field, + DimensionedField<Type, GeoMesh>& field, const MeshMapper& mapper ) const; }; @@ -72,10 +72,12 @@ void MapGeometricFields const MeshMapper& mapper ) { - HashTable<const GeometricField<Type, PatchField, GeoMesh>*> fields + typedef GeometricField<Type, PatchField, GeoMesh> FieldType; + + HashTable<const FieldType*> fields ( mapper.thisDb().objectRegistry::template - lookupClass<GeometricField<Type, PatchField, GeoMesh>>() + lookupClass<FieldType>() ); // It is necessary to enforce that all old-time fields are stored @@ -83,17 +85,9 @@ void MapGeometricFields // old-time-level field is mapped before the field itself, sizes // will not match. - for - ( - typename HashTable<const GeometricField<Type, PatchField, GeoMesh>*>:: - iterator fieldIter = fields.begin(); - fieldIter != fields.end(); - ++fieldIter - ) + forAllConstIter(typename HashTable<const FieldType*>, fields, fieldIter) { - GeometricField<Type, PatchField, GeoMesh>& field = - const_cast<GeometricField<Type, PatchField, GeoMesh>&> - (*fieldIter()); + FieldType& field = const_cast<FieldType&>(*fieldIter()); //Note: check can be removed once pointFields are actually stored on // the pointMesh instead of now on the polyMesh! @@ -103,17 +97,9 @@ void MapGeometricFields } } - for - ( - typename HashTable<const GeometricField<Type, PatchField, GeoMesh>*>:: - iterator fieldIter = fields.begin(); - fieldIter != fields.end(); - ++fieldIter - ) + forAllConstIter(typename HashTable<const FieldType*>, fields, fieldIter) { - GeometricField<Type, PatchField, GeoMesh>& field = - const_cast<GeometricField<Type, PatchField, GeoMesh>&> - (*fieldIter()); + FieldType& field = const_cast<FieldType&>(*fieldIter()); if (&field.mesh() == &mapper.mesh()) { @@ -124,15 +110,11 @@ void MapGeometricFields } // Map the internal field - MapInternalField<Type, MeshMapper, GeoMesh>() - ( - field.primitiveFieldRef(), - mapper - ); + MapInternalField<Type, MeshMapper, GeoMesh>()(field.ref(), mapper); // Map the patch fields - typename GeometricField<Type, PatchField, GeoMesh> - ::Boundary& bfield = field.boundaryFieldRef(); + typename FieldType::Boundary& bfield = field.boundaryFieldRef(); + forAll(bfield, patchi) { // Cannot check sizes for patch fields because of diff --git a/src/OpenFOAM/orientedType/orientedType.C b/src/OpenFOAM/orientedType/orientedType.C new file mode 100644 index 0000000000000000000000000000000000000000..4a04453ac09a3da6e0190477bcaef7562c7db649 --- /dev/null +++ b/src/OpenFOAM/orientedType/orientedType.C @@ -0,0 +1,562 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "orientedType.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + template<> + const char* NamedEnum + < + orientedType::orientedOption, + 3 + >::names[] = + { + "oriented", + "unoriented", + "unknown" + }; +} + +const Foam::NamedEnum<Foam::orientedType::orientedOption, 3> + Foam::orientedType::orientedOptionNames; + + +bool Foam::orientedType::checkType +( + const orientedType& ot1, + const orientedType& ot2 +) +{ + if + ( + (ot1.oriented() == UNKNOWN) + || (ot2.oriented() == UNKNOWN) + || (ot1.oriented() == ot2.oriented()) + ) + { + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::orientedType::orientedType() +: + oriented_(UNKNOWN) +{} + + +Foam::orientedType::orientedType(const orientedType& ot) +: + oriented_(ot.oriented_) +{} + + +Foam::orientedType::orientedType(const bool oriented) +: + oriented_(oriented ? ORIENTED : UNORIENTED) +{} + + +Foam::orientedType::orientedType(Istream& is) +: + oriented_(orientedOptionNames.read(is)) +{ + is.check(FUNCTION_NAME); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::orientedType::orientedOption& Foam::orientedType::oriented() +{ + return oriented_; +} + + +Foam::orientedType::orientedOption Foam::orientedType::oriented() const +{ + return oriented_; +} + + +void Foam::orientedType::setOriented(const bool oriented) +{ + oriented_ = oriented ? ORIENTED : UNORIENTED; +} + + +void Foam::orientedType::read(const dictionary& dict) +{ + if (dict.found("oriented")) + { + oriented_ = orientedOptionNames.read(dict.lookup("oriented")); + } + else + { + oriented_ = UNKNOWN; + } +} + + +void Foam::orientedType::writeEntry(Ostream& os) const +{ + if (oriented_ == ORIENTED) + { + os.writeEntry("oriented", orientedOptionNames[oriented_]); + } +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void Foam::orientedType::operator=(const orientedType& ot) +{ + // Oriented state is inherited on assignment + oriented_ = ot.oriented(); +} + + +void Foam::orientedType::operator+=(const orientedType& ot) +{ + // Set the oriented status if it was unknown + if (oriented_ == UNKNOWN) + { + oriented_ = ot.oriented(); + } + + if (!checkType(*this, ot)) + { + FatalErrorInFunction + << "Operator += is undefined for " + << orientedOptionNames[oriented_] << " and " + << orientedOptionNames[ot.oriented()] << " types" + << abort(FatalError); + } +} + + +void Foam::orientedType::operator-=(const orientedType& ot) +{ + // Set the oriented status if it was unknown + if (oriented_ == UNKNOWN) + { + oriented_ = ot.oriented(); + } + + if (!checkType(*this, ot)) + { + FatalErrorInFunction + << "Operator -= is undefined for " + << orientedOptionNames[oriented_] << " and " + << orientedOptionNames[ot.oriented()] << " types" + << abort(FatalError); + } +} + + +void Foam::orientedType::operator*=(const orientedType& ot) +{ + const orientedType& ot1 = *this; + if (ot1() ^ ot()) + { + oriented_ = ORIENTED; + } + else + { + oriented_ = UNORIENTED; + } +} + + +void Foam::orientedType::operator/=(const orientedType& ot) +{ + const orientedType& ot1 = *this; + if (ot1() ^ ot()) + { + oriented_ = ORIENTED; + } + else + { + oriented_ = UNORIENTED; + } +} + + +void Foam::orientedType::operator*=(const scalar s) +{ + // No change to oriented_ flag +} + + +void Foam::orientedType::operator/=(const scalar s) +{ + // No change to oriented_ flag +} + + +bool Foam::orientedType::operator()() const +{ + return oriented_ == ORIENTED; +} + + +// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // + +Foam::orientedType Foam::max(const orientedType& ot1, const orientedType& ot2) +{ + if (!orientedType::checkType(ot1, ot2)) + { + FatalErrorInFunction + << "Operator max is undefined for " + << orientedType::orientedOptionNames[ot1.oriented()] << " and " + << orientedType::orientedOptionNames[ot2.oriented()] << " types" + << abort(FatalError); + } + + return ot1; +} + + +Foam::orientedType Foam::min(const orientedType& ot1, const orientedType& ot2) +{ + if (!orientedType::checkType(ot1, ot2)) + { + FatalErrorInFunction + << "Operator min is undefined for " + << orientedType::orientedOptionNames[ot1.oriented()] << " and " + << orientedType::orientedOptionNames[ot2.oriented()] << "types" + << abort(FatalError); + } + + return ot1; +} + + +Foam::orientedType Foam::cmptMultiply +( + const orientedType& ot1, + const orientedType& ot2 +) +{ + return ot1 ^ ot2; +} + + +Foam::orientedType Foam::cmptDivide +( + const orientedType& ot1, + const orientedType& ot2 +) +{ + return ot1 ^ ot2; +} + + +Foam::orientedType Foam::cmptAv(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::pow(const orientedType& ot, const scalar r) +{ + // Undefined??? + // - only defined for integers where: + // - odd powers = oriented_ = yes (if ot is oriented) + // - even powers = oriented_ = no + return ot; +} + + +Foam::orientedType Foam::sqr(const orientedType& ot) +{ + return orientedType(false); +} + + +Foam::orientedType Foam::pow3(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::pow4(const orientedType& ot) +{ + return orientedType(false); +} + + +Foam::orientedType Foam::pow5(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::pow6(const orientedType& ot) +{ + return orientedType(false); +} + + +Foam::orientedType Foam::pow025(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::sqrt(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::cbrt(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::magSqr(const orientedType& ot) +{ + return orientedType(false); +} + + +Foam::orientedType Foam::mag(const orientedType& ot) +{ + return orientedType(false); +} + + +Foam::orientedType Foam::sign(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::pos(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::neg(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::posPart(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::negPart(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::inv(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::trans(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::atan2 +( + const orientedType& ot1, + const orientedType& ot2 +) +{ + if (!orientedType::checkType(ot1, ot2)) + { + FatalErrorInFunction + << "Operator atan2 is undefined for " + << orientedType::orientedOptionNames[ot1.oriented()] << " and " + << orientedType::orientedOptionNames[ot2.oriented()] << "types" + << abort(FatalError); + } + + return ot1; +} + + +Foam::orientedType Foam::transform(const orientedType& ot) +{ + return ot; +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Istream& Foam::operator>>(Istream& is, orientedType& ot) +{ + ot.oriented_ = orientedType::orientedOptionNames.read(is); + + is.check(FUNCTION_NAME); + + return is; +} + + +Foam::Ostream& Foam::operator<<(Ostream& os, const orientedType& ot) +{ + os << orientedType::orientedOptionNames[ot.oriented()]; + + os.check(FUNCTION_NAME); + + return os; +} + + +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // + +Foam::orientedType Foam::operator+ +( + const orientedType& ot1, + const orientedType& ot2 +) +{ + if (!orientedType::checkType(ot1, ot2)) + { + FatalErrorInFunction + << "Operator + is undefined for " + << orientedType::orientedOptionNames[ot1.oriented()] << " and " + << orientedType::orientedOptionNames[ot2.oriented()] << " types" + << abort(FatalError); + } + + // Note use of () operators to convert to boolean op + return orientedType(ot1() || ot2()); +} + + +Foam::orientedType Foam::operator-(const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::operator- +( + const orientedType& ot1, + const orientedType& ot2 +) +{ + if (!orientedType::checkType(ot1, ot2)) + { + FatalErrorInFunction + << "Operator - is undefined for " + << orientedType::orientedOptionNames[ot1.oriented()] << " and " + << orientedType::orientedOptionNames[ot2.oriented()] << " types" + << abort(FatalError); + } + + // Note use of () operators to convert to boolean op + return orientedType(ot1() || ot2()); +} + + +Foam::orientedType Foam::operator*(const scalar s, const orientedType& ot) +{ + return ot; +} + + +Foam::orientedType Foam::operator/(const orientedType& ot, const scalar s) +{ + return ot; +} + + +Foam::orientedType Foam::operator/ +( + const orientedType& ot1, + const orientedType& ot2 +) +{ + return ot1 ^ ot2; +} + + +Foam::orientedType Foam::operator* +( + const orientedType& ot1, + const orientedType& ot2 +) +{ + return ot1 ^ ot2; +} + + +Foam::orientedType Foam::operator^ +( + const orientedType& ot1, + const orientedType& ot2 +) +{ + // Note use of () operators to convert to boolean op + return orientedType(ot1() ^ ot2()); +} + + +Foam::orientedType Foam::operator& +( + const orientedType& ot1, + const orientedType& ot2 +) +{ + return ot1 ^ ot2; +} + + +Foam::orientedType Foam::operator&& +( + const orientedType& ot1, + const orientedType& ot2 +) +{ + return orientedType(false); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/orientedType/orientedType.H b/src/OpenFOAM/orientedType/orientedType.H new file mode 100644 index 0000000000000000000000000000000000000000..d050f71dcb5aaeb960f7e2a7b4658d55b04f1b0f --- /dev/null +++ b/src/OpenFOAM/orientedType/orientedType.H @@ -0,0 +1,202 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::orientedType + +Description + Class to determine the 'oriented' status of surface fields + +SourceFiles + orientedType.C + +\*---------------------------------------------------------------------------*/ + +#ifndef orientedType_H +#define orientedType_H + +#include "Istream.H" +#include "Ostream.H" +#include "dictionary.H" +#include "NamedEnum.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators + +class orientedType; + +Istream& operator>>(Istream&, orientedType&); + +Ostream& operator<<(Ostream&, const orientedType&); + +/*---------------------------------------------------------------------------*\ + Class orientedType Declaration +\*---------------------------------------------------------------------------*/ + +class orientedType +{ +public: + + // Public data types + + //- Enumeration defining the valid oriented flags + enum orientedOption + { + ORIENTED, + UNORIENTED, + UNKNOWN + }; + + static const NamedEnum<orientedOption, 3> orientedOptionNames; + + +private: + + // Private data + + //- Oriented flag + orientedOption oriented_; + + +public: + + // Constructors + + //- Null constructor - flag initialised to false + orientedType(); + + //- Copy constructor + orientedType(const orientedType& ot); + + //- Construct from bool + orientedType(const bool oriented); + + //- Construct from Istream + orientedType(Istream& is); + + + // Member functions + + //- Return true if can operate on this pair of oriented types + static bool checkType + ( + const orientedType& ot1, + const orientedType& ot2 + ); + + //- Return non-const reference to the oriented flag + orientedOption& oriented(); + + //- Return const reference to the oriented flag + orientedOption oriented() const; + + //- Set the oriented flag + void setOriented(const bool oriented = true); + + //- Read the oriented state from dictionary + void read(const dictionary& dict); + + //- Write the oriented flag entry + void writeEntry(Ostream& os) const; + + + // Member operators + + void operator=(const orientedType& ot); + + void operator+=(const orientedType& ot); + void operator-=(const orientedType& ot); + void operator*=(const orientedType& ot); + void operator/=(const orientedType& ot); + void operator*=(const scalar s); + void operator/=(const scalar s); + bool operator()() const; + + + // IOstream operators + + friend Istream& operator>>(Istream& is, orientedType& ot); + + friend Ostream& operator<<(Ostream& os, const orientedType& ot); +}; + + +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // + +orientedType max(const orientedType& ot1, const orientedType& ot2); +orientedType min(const orientedType& ot1, const orientedType& ot2); +orientedType cmptMultiply(const orientedType& ot1, const orientedType& ot2); +orientedType cmptDivide(const orientedType& ot1, const orientedType& ot); +orientedType cmptAv(const orientedType& ot); + + +orientedType pow(const orientedType& ot, const scalar r); +orientedType sqr(const orientedType& ot); +orientedType pow3(const orientedType& ot); +orientedType pow4(const orientedType& ot); +orientedType pow5(const orientedType& ot); +orientedType pow6(const orientedType& ot); +orientedType pow025(const orientedType& ot); + + +orientedType sqrt(const orientedType& ot); +orientedType cbrt(const orientedType& ot); +orientedType magSqr(const orientedType& ot); +orientedType mag(const orientedType& ot); +orientedType sign(const orientedType& ot); +orientedType pos(const orientedType& ot); +orientedType neg(const orientedType& ot); +orientedType posPart(const orientedType& ot); +orientedType negPart(const orientedType& ot); +orientedType inv(const orientedType& ot); + + +orientedType trans(const orientedType& ot); +orientedType atan2(const orientedType& ot1, const orientedType& ot2); +orientedType transform(const orientedType& ot); + +orientedType operator-(const orientedType& ot); +orientedType operator*(const scalar s, const orientedType& ot); +orientedType operator/(const orientedType& ot, const scalar s); + +orientedType operator+(const orientedType& ot1, const orientedType& ot2); +orientedType operator-(const orientedType& ot1, const orientedType& ot2); +orientedType operator/(const orientedType& ot1, const orientedType& ot2); +orientedType operator*(const orientedType& ot1, const orientedType& ot2); +orientedType operator^(const orientedType& ot1, const orientedType& ot2); +orientedType operator&(const orientedType& ot1, const orientedType& ot2); +orientedType operator&&(const orientedType& ot1, const orientedType& ot2); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C index 86a9617750af5326ad4955c145ffa8137d45068d..e03840aaa531ea6e7a07fe26c019c806989145a7 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -205,6 +205,8 @@ void Foam::fvMeshDistribute::mapExposedFaces forAllIter(typename HashTable<fldType*>, flds, iter) { fldType& fld = *iter(); + const bool oriented = fld.oriented()(); + typename fldType::Boundary& bfld = fld.boundaryFieldRef(); const Field<T>& oldInternal = oldFlds[fieldI++]; @@ -225,7 +227,7 @@ void Foam::fvMeshDistribute::mapExposedFaces { patchFld[i] = oldInternal[oldFaceI]; - if (map.flipFaceFlux().found(faceI)) + if (oriented && map.flipFaceFlux().found(faceI)) { patchFld[i] = flipOp()(patchFld[i]); } diff --git a/src/dynamicMesh/fvMeshSubset/fvMeshSubset.H b/src/dynamicMesh/fvMeshSubset/fvMeshSubset.H index 7d9c453b5e3a58f75bec2f02a069158855d32318..3f057d2d574a6ae46fedf8cff309ebeebe4eef65 100644 --- a/src/dynamicMesh/fvMeshSubset/fvMeshSubset.H +++ b/src/dynamicMesh/fvMeshSubset/fvMeshSubset.H @@ -283,16 +283,14 @@ public: const fvMesh& sMesh, const labelList& patchMap, const labelList& cellMap, - const labelList& faceMap, - const bool negateIfFlipped = true + const labelList& faceMap ); template<class Type> tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> interpolate ( - const GeometricField<Type, fvsPatchField, surfaceMesh>&, - const bool negateIfFlipped = true + const GeometricField<Type, fvsPatchField, surfaceMesh>& ) const; //- Map point field diff --git a/src/dynamicMesh/fvMeshSubset/fvMeshSubsetInterpolate.C b/src/dynamicMesh/fvMeshSubset/fvMeshSubsetInterpolate.C index 7a0192ee06c9c5862ae8d94b4e75f3ff1278b5ef..228b7df26da3e7ad51f3366f50e8d39f07bcdf18 100644 --- a/src/dynamicMesh/fvMeshSubset/fvMeshSubsetInterpolate.C +++ b/src/dynamicMesh/fvMeshSubset/fvMeshSubsetInterpolate.C @@ -102,6 +102,7 @@ tmp<GeometricField<Type, fvPatchField, volMesh>> fvMeshSubset::interpolate ) ); GeometricField<Type, fvPatchField, volMesh>& resF = tresF.ref(); + resF.oriented() = vf.oriented(); // 2. Change the fvPatchFields to the correct type using a mapper @@ -180,8 +181,7 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate const fvMesh& sMesh, const labelList& patchMap, const labelList& cellMap, - const labelList& faceMap, - const bool negateIfFlipped + const labelList& faceMap ) { // 1. Create the complete field with dummy patch fields @@ -247,6 +247,7 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate ) ); GeometricField<Type, fvsPatchField, surfaceMesh>& resF = tresF.ref(); + resF.oriented() = vf.oriented(); // 2. Change the fvsPatchFields to the correct type using a mapper @@ -310,7 +311,7 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate { Type val = vf.internalField()[baseFacei]; - if (cellMap[fc[i]] == own[baseFacei] || !negateIfFlipped) + if (cellMap[fc[i]] == own[baseFacei] || !vf.oriented()()) { pfld[i] = val; } @@ -342,8 +343,7 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate template<class Type> tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate ( - const GeometricField<Type, fvsPatchField, surfaceMesh>& sf, - const bool negateIfFlipped + const GeometricField<Type, fvsPatchField, surfaceMesh>& sf ) const { return interpolate @@ -352,8 +352,7 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate subMesh(), patchMap(), cellMap(), - faceMap(), - negateIfFlipped + faceMap() ); } @@ -423,6 +422,7 @@ fvMeshSubset::interpolate ) ); GeometricField<Type, pointPatchField, pointMesh>& resF = tresF.ref(); + resF.oriented() = vf.oriented(); // 2. Change the pointPatchFields to the correct type using a mapper @@ -532,6 +532,8 @@ tmp<DimensionedField<Type, volMesh>> fvMeshSubset::interpolate ) ); + tresF.ref().oriented() = df.oriented(); + return tresF; } diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C index cb0276cc7c49c4c9e8f395804ac7fa99a5155e6e..f1ebd2e69082121b0178b3ef85f697d62c99e177 100644 --- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,6 +26,7 @@ License #include "IOobject.H" #include "dictionary.H" #include "fvMesh.H" +#include "surfaceMesh.H" #include "fvPatchFieldMapper.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -93,20 +94,15 @@ Foam::fvsPatchField<Type>::fvsPatchField } else { - FatalIOErrorInFunction - ( - dict - ) << "essential value entry not provided" + FatalIOErrorInFunction(dict) + << "essential 'value' entry not provided" << exit(FatalIOError); } } template<class Type> -Foam::fvsPatchField<Type>::fvsPatchField -( - const fvsPatchField<Type>& ptf -) +Foam::fvsPatchField<Type>::fvsPatchField(const fvsPatchField<Type>& ptf) : Field<Type>(ptf), patch_(ptf.patch_), @@ -149,12 +145,10 @@ void Foam::fvsPatchField<Type>::check(const fvsPatchField<Type>& ptf) const template<class Type> -void Foam::fvsPatchField<Type>::autoMap -( - const fvPatchFieldMapper& m -) +void Foam::fvsPatchField<Type>::autoMap(const fvPatchFieldMapper& m) { - Field<Type>::autoMap(m); + const bool oriented = internalField_.oriented()(); + Field<Type>::autoMap(m, oriented); } diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H index 6c2f12a436fd076b98e9f031d9e88bdeb90b61ac..1b9f0aa2acaf3ca7a966c2dc0a6174256d26e295 100644 --- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H @@ -286,8 +286,7 @@ public: } //- Return dimensioned internal field reference - const DimensionedField<Type, surfaceMesh>& - internalField() const + const DimensionedField<Type, surfaceMesh>& internalField() const { return internalField_; } diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C index e3f9e6961aa64796bf8443d9b6fde8e4d0878c8d..71be26d88d1a16a688e6794f6457de155c3b6c5a 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C @@ -75,8 +75,7 @@ CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::DDt0Field template<class Type> template<class GeoField> -label CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>:: -startTimeIndex() const +label CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::startTimeIndex() const { return startTimeIndex_; } @@ -84,8 +83,7 @@ startTimeIndex() const template<class Type> template<class GeoField> -GeoField& CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>:: -operator()() +GeoField& CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::operator()() { return *this; } @@ -93,8 +91,10 @@ operator()() template<class Type> template<class GeoField> -void CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>:: -operator=(const GeoField& gf) +void CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::operator= +( + const GeoField& gf +) { GeoField::operator=(gf); } @@ -1259,6 +1259,7 @@ CrankNicolsonDdtScheme<Type>::fvcDdtPhiCorr "ddtCorrDdt0(" + phi.name() + ')', phi.dimensions() ); + dphidt0.setOriented(); dimensionedScalar rDtCoef = rDtCoef_(ddt0); @@ -1503,6 +1504,8 @@ tmp<surfaceScalarField> CrankNicolsonDdtScheme<Type>::meshPhi dimVolume ); + meshPhi0.setOriented(); + if (evaluate(meshPhi0)) { meshPhi0 = diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianScheme.C b/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianScheme.C index 795fbff9759d98eed2020424d125062249f98ef4..5f372b1e841354886befc3aae8f968a04efa748d 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianScheme.C +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianScheme.C @@ -115,6 +115,7 @@ gaussLaplacianScheme<Type, GType>::gammaSnGradCorr *vf.dimensions()*mesh.deltaCoeffs().dimensions() ) ); + tgammaSnGradCorr.ref().oriented() = SfGammaCorr.oriented(); for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++) { diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradScheme.C b/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradScheme.C index ae7d0de4585474b8f04bd671b301a69e7c8964e8..5644e7a6b1a4998986354d967af12385b69e7307 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradScheme.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/snGradScheme/snGradScheme.C @@ -124,6 +124,7 @@ snGradScheme<Type>::snGrad ) ); GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tsf.ref(); + ssf.setOriented(); // set reference to difference factors array const scalarField& deltaCoeffs = tdeltaCoeffs(); diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index 4c2ffb5a1f18bc3f11a3f0be6a21833d98738ec2..262444193cd12ea40dbc5dd13ca0a7fd56e62524 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -892,6 +892,8 @@ flux() const GeometricField<Type, fvsPatchField, surfaceMesh>& fieldFlux = tfieldFlux.ref(); + fieldFlux.setOriented(); + for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) { fieldFlux.primitiveFieldRef().replace diff --git a/src/finiteVolume/fvMesh/fvMeshGeometry.C b/src/finiteVolume/fvMesh/fvMeshGeometry.C index a05569849f22117a41c7b234fa8f6a5981c60fa0..c530ee0a9a0c8032062d4bf68e7f3584993c39b8 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -67,6 +67,8 @@ void Foam::fvMesh::makeSf() const dimArea, faceAreas() ); + + SfPtr_->setOriented(); } @@ -271,8 +273,7 @@ const Foam::volScalarField::Internal& Foam::fvMesh::V00() const } -Foam::tmp<Foam::volScalarField::Internal> -Foam::fvMesh::Vsc() const +Foam::tmp<Foam::volScalarField::Internal> Foam::fvMesh::Vsc() const { if (moving() && time().subCycling()) { @@ -300,8 +301,7 @@ Foam::fvMesh::Vsc() const } -Foam::tmp<Foam::volScalarField::Internal> -Foam::fvMesh::Vsc0() const +Foam::tmp<Foam::volScalarField::Internal> Foam::fvMesh::Vsc0() const { if (moving() && time().subCycling()) { @@ -400,6 +400,7 @@ Foam::tmp<Foam::surfaceVectorField> Foam::fvMesh::delta() const ) ); surfaceVectorField& delta = tdelta.ref(); + delta.setOriented(); const volVectorField& C = this->C(); const labelUList& owner = this->owner(); @@ -410,8 +411,7 @@ Foam::tmp<Foam::surfaceVectorField> Foam::fvMesh::delta() const delta[facei] = C[neighbour[facei]] - C[owner[facei]]; } - surfaceVectorField::Boundary& deltabf = - delta.boundaryFieldRef(); + surfaceVectorField::Boundary& deltabf = delta.boundaryFieldRef(); forAll(deltabf, patchi) { @@ -438,6 +438,8 @@ const Foam::surfaceScalarField& Foam::fvMesh::phi() const (*phiPtr_) = dimensionedScalar("0", dimVolume/dimTime, 0.0); } + phiPtr_->setOriented(); + return *phiPtr_; } diff --git a/src/finiteVolume/interpolation/mapping/fvFieldMappers/MapFvSurfaceField.H b/src/finiteVolume/interpolation/mapping/fvFieldMappers/MapFvSurfaceField.H index 40dfd16f7918cda1e55d4621080764141330fb39..d1f21db48ae9c7a7fcead0390be5c84498a42329 100644 --- a/src/finiteVolume/interpolation/mapping/fvFieldMappers/MapFvSurfaceField.H +++ b/src/finiteVolume/interpolation/mapping/fvFieldMappers/MapFvSurfaceField.H @@ -48,7 +48,7 @@ public: void operator() ( - Field<Type>& field, + DimensionedField<Type, surfaceMesh>& field, const MeshMapper& mapper ) const; }; @@ -57,7 +57,7 @@ public: template<class Type, class MeshMapper> void MapInternalField<Type, MeshMapper, surfaceMesh>::operator() ( - Field<Type>& field, + DimensionedField<Type, surfaceMesh>& field, const MeshMapper& mapper ) const { @@ -69,16 +69,22 @@ void MapInternalField<Type, MeshMapper, surfaceMesh>::operator() << abort(FatalError); } - field.autoMap(mapper.surfaceMap()); + // Passing in oriented flag so that oriented fields (e.g. phi) are negated + // if flipped. Un-oriented fields, e.g U interpolated to faces (Uf) are not + // touched + field.autoMap(mapper.surfaceMap(), field.oriented()()); - // Flip the flux - const labelList flipFaces = mapper.surfaceMap().flipFaceFlux().toc(); - - forAll(flipFaces, i) + if (field.oriented()()) { - if (flipFaces[i] < field.size()) + // Flip the flux + const labelList flipFaces = mapper.surfaceMap().flipFaceFlux().toc(); + + forAll(flipFaces, i) { - field[flipFaces[i]] *= -1.0; + if (flipFaces[i] < field.size()) + { + field[flipFaces[i]] *= -1.0; + } } } } diff --git a/src/finiteVolume/interpolation/mapping/fvFieldMappers/MapFvVolField.H b/src/finiteVolume/interpolation/mapping/fvFieldMappers/MapFvVolField.H index db8c9ce72b83df1d94023836bf9ca62f4709b434..f23517342fc83625915224a4f17dfa74643e6213 100644 --- a/src/finiteVolume/interpolation/mapping/fvFieldMappers/MapFvVolField.H +++ b/src/finiteVolume/interpolation/mapping/fvFieldMappers/MapFvVolField.H @@ -48,7 +48,7 @@ public: void operator() ( - Field<Type>& field, + DimensionedField<Type, volMesh>& field, const MeshMapper& mapper ) const; }; @@ -57,7 +57,7 @@ public: template<class Type, class MeshMapper> void MapInternalField<Type, MeshMapper, volMesh>::operator() ( - Field<Type>& field, + DimensionedField<Type, volMesh>& field, const MeshMapper& mapper ) const { diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C index 6e8f8bc7d459c0eedc7c03377d58484839478849..f13c646316b1ec18efafad56511002b4e62560fa 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -73,8 +73,7 @@ Foam::surfaceInterpolation::~surfaceInterpolation() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -const Foam::surfaceScalarField& -Foam::surfaceInterpolation::weights() const +const Foam::surfaceScalarField& Foam::surfaceInterpolation::weights() const { if (!weights_) { @@ -85,8 +84,7 @@ Foam::surfaceInterpolation::weights() const } -const Foam::surfaceScalarField& -Foam::surfaceInterpolation::deltaCoeffs() const +const Foam::surfaceScalarField& Foam::surfaceInterpolation::deltaCoeffs() const { if (!deltaCoeffs_) { @@ -156,11 +154,12 @@ void Foam::surfaceInterpolation::makeWeights() const dimless ); surfaceScalarField& weights = *weights_; + weights.setOriented(); // Set local references to mesh data - // (note that we should not use fvMesh sliced fields at this point yet - // since this causes a loop when generating weighting factors in - // coupledFvPatchField evaluation phase) + // Note that we should not use fvMesh sliced fields at this point yet + // since this causes a loop when generating weighting factors in + // coupledFvPatchField evaluation phase const labelUList& owner = mesh_.owner(); const labelUList& neighbour = mesh_.neighbour(); @@ -174,7 +173,7 @@ void Foam::surfaceInterpolation::makeWeights() const forAll(owner, facei) { // Note: mag in the dot-product. - // For all valid meshes, the non-orthogonality will be less that + // For all valid meshes, the non-orthogonality will be less than // 90 deg and the dot-product will be positive. For invalid // meshes (d & s <= 0), this will stabilise the calculation // but the result will be poor. @@ -183,8 +182,7 @@ void Foam::surfaceInterpolation::makeWeights() const w[facei] = SfdNei/(SfdOwn + SfdNei); } - surfaceScalarField::Boundary& wBf = - weights.boundaryFieldRef(); + surfaceScalarField::Boundary& wBf = weights.boundaryFieldRef(); forAll(mesh_.boundary(), patchi) { @@ -228,6 +226,7 @@ void Foam::surfaceInterpolation::makeDeltaCoeffs() const dimless/dimLength ); surfaceScalarField& deltaCoeffs = *deltaCoeffs_; + deltaCoeffs.setOriented(); // Set local references to mesh data @@ -278,6 +277,7 @@ void Foam::surfaceInterpolation::makeNonOrthDeltaCoeffs() const dimless/dimLength ); surfaceScalarField& nonOrthDeltaCoeffs = *nonOrthDeltaCoeffs_; + nonOrthDeltaCoeffs.setOriented(); // Set local references to mesh data @@ -342,6 +342,7 @@ void Foam::surfaceInterpolation::makeNonOrthCorrectionVectors() const dimless ); surfaceVectorField& corrVecs = *nonOrthCorrectionVectors_; + corrVecs.setOriented(); // Set local references to mesh data const volVectorField& C = mesh_.C(); diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationScheme.C b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationScheme.C index 089d21bee2fae6ad72b7dcf9fd97127d06413a6a..0fbf63650b1034e24cca8fe46fcfb9791a6965fa 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationScheme.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationScheme.C @@ -311,6 +311,8 @@ Foam::surfaceInterpolationScheme<Type>::dotInterpolate tlambdas.clear(); +// tsf.ref().oriented() = Sf.oriented(); + return tsf; } @@ -363,6 +365,8 @@ Foam::surfaceInterpolationScheme<Type>::dotInterpolate > > tsf = dotInterpolate(Sf, vf, weights(vf)); + tsf.ref().oriented() = Sf.oriented(); + if (corrected()) { tsf.ref() += Sf & correction(vf); @@ -397,6 +401,7 @@ Foam::surfaceInterpolationScheme<Type>::dotInterpolate surfaceMesh > > tSfDotinterpVf = dotInterpolate(Sf, tvf()); + tvf.clear(); return tSfDotinterpVf; } diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index 5d5bb380d70f261e84cd3d8839772bf3e3cdf56a..f28944d9959727aac7eda4a0009381280e6fbdb1 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -154,7 +154,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces() DynamicList<label> faceIds(fZone.size()); DynamicList<label> facePatchIds(fZone.size()); - DynamicList<bool> faceFlip(fZone.size()); + DynamicList<bool> faceFlip(fZone.size()); forAll(fZone, i) { @@ -459,7 +459,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea() const } else { - totalArea = gSum(filterField(mesh_.magSf(), false)); + totalArea = gSum(filterField(mesh_.magSf())); } return totalArea; @@ -479,10 +479,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::needsSf() const case opAverage: case opMin: case opMax: + { return false; - + } default: + { return true; + } } } @@ -496,10 +499,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::needsWeight() const case opWeightedAverage: case opWeightedAreaAverage: case opWeightedAreaIntegrate: + { return true; - + } default: + { return false; + } } } @@ -596,7 +602,6 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise weightFieldName_ = "none"; - orientWeightField_ = false; if (needsWeight()) { if (dict.readIfPresent("weightField", weightFieldName_)) @@ -610,41 +615,21 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise Info<< " weight field = " << weightFieldName_ << nl; } - - if (dict.found("orientedWeightField")) - { - if (regionType_ == stSurface || regionType_ == stSampledSurface) - { - FatalIOErrorInFunction(dict) - << "Cannot use orientedWeightField " - << "for surface/sampledSurface" - << exit(FatalIOError); - } - - if (weightFieldName_ == "none") - { - dict.lookup("orientedWeightField") >> weightFieldName_; - orientWeightField_ = true; - - Info<< " weight field = " << weightFieldName_ << nl; - } - else - { - FatalIOErrorInFunction(dict) - << "Cannot specify both weightField and orientedWeightField" - << exit(FatalIOError); - } - } } + // Backwards compatibility for v1612+ and older List<word> orientedFields; - orientedFieldsStart_ = labelMax; if (dict.readIfPresent("orientedFields", orientedFields)) { - orientedFieldsStart_ = fields_.size(); + WarningInFunction + << "The 'orientedFields' option is deprecated. These fields can " + << "and have been added to the standard 'fields' list." + << endl; + fields_.append(orientedFields); } + surfaceWriterPtr_.clear(); if (writeFields_) { @@ -854,8 +839,6 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue [dict.lookupOrDefault<word>("postOperation", "none")] ), weightFieldName_("none"), - orientWeightField_(false), - orientedFieldsStart_(labelMax), writeArea_(dict.lookupOrDefault("writeArea", false)), nFaces_(0), faceId_(), @@ -883,8 +866,6 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue [dict.lookupOrDefault<word>("postOperation", "none")] ), weightFieldName_("none"), - orientWeightField_(false), - orientedFieldsStart_(labelMax), writeArea_(dict.lookupOrDefault("writeArea", false)), nFaces_(0), faceId_(), @@ -959,7 +940,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write() } else { - Sf = filterField(mesh_.Sf(), true); // Oriented Sf + Sf = filterField(mesh_.Sf()); } } @@ -988,12 +969,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write() { scalarField weightField ( - getFieldValues<scalar> - ( - weightFieldName_, - true, - orientWeightField_ - ) + getFieldValues<scalar>(weightFieldName_, true) ); // Process the fields @@ -1003,12 +979,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write() { vectorField weightField ( - getFieldValues<vector> - ( - weightFieldName_, - true, - orientWeightField_ - ) + getFieldValues<vector>(weightFieldName_, true) ); // Process the fields diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.H b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.H index ee460e983aa0c2568c42b301373f89fe89a6f504..a58b27b8a0b55170f214eae7999d2685b1458494 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.H +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.H @@ -91,7 +91,6 @@ Usage orientedWeightField | name of oriented field to apply weighting | no | scaleFactor | scale factor | no | 1 fields | list of fields to operate on | yes | - orientedFields | list of oriented fields to operate on | no | \endtable Where \c regionType is defined by @@ -130,8 +129,6 @@ Note - faces on empty patches get ignored - if the field is a volField the \c faceZone can only consist of boundary faces - - the `oriented' entries relate to mesh-oriented fields, such as the - flux, phi. These fields will be oriented according to the face normals. - Using \c surface: - The keyword %subRegion should not be used to select surfaces. Specify instead the regionType 'surface' and provide the surface name. @@ -285,12 +282,6 @@ protected: //- Weight field name - optional word weightFieldName_; - //- Flag to indicate if flipMap should be applied to the weight field - bool orientWeightField_; - - //- Start index of fields that require application of flipMap - label orientedFieldsStart_; - //- Total area of the surfaceFieldValue scalar totalArea_; @@ -353,8 +344,7 @@ protected: tmp<Field<Type>> getFieldValues ( const word& fieldName, - const bool mustGet = false, - const bool applyOrientation = false + const bool mustGet = false ) const; //- Apply the 'operation' to the values. Operation must preserve Type. @@ -380,16 +370,14 @@ protected: template<class Type> tmp<Field<Type>> filterField ( - const GeometricField<Type, fvsPatchField, surfaceMesh>& field, - const bool applyOrientation + const GeometricField<Type, fvsPatchField, surfaceMesh>& field ) const; //- Filter a volume field according to faceIds template<class Type> tmp<Field<Type>> filterField ( - const GeometricField<Type, fvPatchField, volMesh>& field, - const bool applyOrientation + const GeometricField<Type, fvPatchField, volMesh>& field ) const; //- Weighting factor @@ -424,7 +412,6 @@ protected: const word& fieldName, const vectorField& Sf, const Field<WeightType>& weightField, - const bool orient, const meshedSurf& surfToWrite ); diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C index 6f434ed82c96f1ad526d61c4020f4e2429cf39be..806a06845460250ed251e09c7a2bc40b4cd81218 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C @@ -57,8 +57,7 @@ Foam::tmp<Foam::Field<Type>> Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues ( const word& fieldName, - const bool mustGet, - const bool applyOrientation + const bool mustGet ) const { typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf; @@ -71,7 +70,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues } else if (regionType_ != stSampledSurface && foundObject<sf>(fieldName)) { - return filterField(lookupObject<sf>(fieldName), applyOrientation); + return filterField(lookupObject<sf>(fieldName)); } else if (foundObject<vf>(fieldName)) { @@ -112,7 +111,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues } else { - return filterField(fld, applyOrientation); + return filterField(fld); } } @@ -140,7 +139,9 @@ processSameTypeValues switch (operation_) { case opNone: + { break; + } case opSum: { result = gSum(values); @@ -258,8 +259,10 @@ processSameTypeValues case opAreaNormalAverage: case opAreaNormalIntegrate: - // handled in specializations only + { + // Handled in specializations only break; + } } return result; @@ -302,30 +305,17 @@ Foam::label Foam::functionObjects::fieldValues::surfaceFieldValue::writeAll forAll(fields_, i) { const word& fieldName = fields_[i]; - const bool orient = (i >= orientedFieldsStart_); if ( - writeValues<scalar> - ( - fieldName, Sf, weightField, orient, surfToWrite - ) - || writeValues<vector> - ( - fieldName, Sf, weightField, orient, surfToWrite - ) + writeValues<scalar>(fieldName, Sf, weightField, surfToWrite) + || writeValues<vector>(fieldName, Sf, weightField, surfToWrite) || writeValues<sphericalTensor> ( - fieldName, Sf, weightField, orient, surfToWrite - ) - || writeValues<symmTensor> - ( - fieldName, Sf, weightField, orient, surfToWrite - ) - || writeValues<tensor> - ( - fieldName, Sf, weightField, orient, surfToWrite + fieldName, Sf, weightField, surfToWrite ) + || writeValues<symmTensor>(fieldName, Sf, weightField, surfToWrite) + || writeValues<tensor>(fieldName, Sf, weightField, surfToWrite) ) { ++nProcessed; @@ -349,7 +339,6 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues const word& fieldName, const vectorField& Sf, const Field<WeightType>& weightField, - const bool orient, const meshedSurf& surfToWrite ) { @@ -357,7 +346,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues if (ok) { - Field<Type> values(getFieldValues<Type>(fieldName, true, orient)); + Field<Type> values(getFieldValues<Type>(fieldName, true)); // Write raw values on surface if specified if (surfaceWriterPtr_.valid()) @@ -389,7 +378,9 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues switch (postOperation_) { case postOpNone: + { break; + } case postOpSqrt: { // sqrt: component-wise - doesn't change the type @@ -438,8 +429,7 @@ template<class Type> Foam::tmp<Foam::Field<Type>> Foam::functionObjects::fieldValues::surfaceFieldValue::filterField ( - const GeometricField<Type, fvPatchField, volMesh>& field, - const bool applyOrientation + const GeometricField<Type, fvPatchField, volMesh>& field ) const { tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size())); @@ -464,16 +454,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField } } - if (applyOrientation) - { - forAll(values, i) - { - if (faceFlip_[i]) - { - values[i] *= -1; - } - } - } + // No need to flip values - all boundary faces point outwards return tvalues; } @@ -483,8 +464,7 @@ template<class Type> Foam::tmp<Foam::Field<Type>> Foam::functionObjects::fieldValues::surfaceFieldValue::filterField ( - const GeometricField<Type, fvsPatchField, surfaceMesh>& field, - const bool applyOrientation + const GeometricField<Type, fvsPatchField, surfaceMesh>& field ) const { tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size())); @@ -504,7 +484,13 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField } } - if (applyOrientation) + if (debug) + { + Pout<< "field " << field.name() << " oriented: " + << field.oriented()() << endl; + } + + if (field.oriented()()) { forAll(values, i) { diff --git a/src/parallel/decompose/decompose/fvFieldDecomposer.C b/src/parallel/decompose/decompose/fvFieldDecomposer.C index 310d0ce1fec4c7cd7c4e85de059546cc3a9d1dd7..8ff6ee3e06e41b6cc36b85b3e8665ee4657ff310 100644 --- a/src/parallel/decompose/decompose/fvFieldDecomposer.C +++ b/src/parallel/decompose/decompose/fvFieldDecomposer.C @@ -107,7 +107,7 @@ processorSurfacePatchFieldDecomposer weights_[i].setSize(1); addressing_[i][0] = mag(addressingSlice[i]) - 1; - weights_[i][0] = sign(addressingSlice[i]); + weights_[i][0] = 1; } } @@ -126,59 +126,75 @@ Foam::fvFieldDecomposer::fvFieldDecomposer faceAddressing_(faceAddressing), cellAddressing_(cellAddressing), boundaryAddressing_(boundaryAddressing), - patchFieldDecomposerPtrs_ - ( - procMesh_.boundary().size(), - static_cast<patchFieldDecomposer*>(nullptr) - ), - processorVolPatchFieldDecomposerPtrs_ - ( - procMesh_.boundary().size(), - static_cast<processorVolPatchFieldDecomposer*>(nullptr) - ), - processorSurfacePatchFieldDecomposerPtrs_ - ( - procMesh_.boundary().size(), - static_cast<processorSurfacePatchFieldDecomposer*>(nullptr) - ) + patchFieldDecomposerPtrs_(procMesh_.boundary().size()), + processorVolPatchFieldDecomposerPtrs_(procMesh_.boundary().size()), + processorSurfacePatchFieldDecomposerPtrs_(procMesh_.boundary().size()), + faceSign_(procMesh_.boundary().size()) { forAll(boundaryAddressing_, patchi) { + const fvPatch& fvp = procMesh_.boundary()[patchi]; + if ( boundaryAddressing_[patchi] >= 0 && !isA<processorLduInterface>(procMesh.boundary()[patchi]) ) { - patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer + patchFieldDecomposerPtrs_.set ( - procMesh_.boundary()[patchi].patchSlice(faceAddressing_), - completeMesh_.boundaryMesh() - [ - boundaryAddressing_[patchi] - ].start() + patchi, + new patchFieldDecomposer + ( + fvp.patchSlice(faceAddressing_), + completeMesh_.boundaryMesh() + [ + boundaryAddressing_[patchi] + ].start() + ) ); } else { - processorVolPatchFieldDecomposerPtrs_[patchi] = + processorVolPatchFieldDecomposerPtrs_.set + ( + patchi, new processorVolPatchFieldDecomposer ( completeMesh_, - procMesh_.boundary()[patchi].patchSlice(faceAddressing_) - ); + fvp.patchSlice(faceAddressing_) + ) + ); - processorSurfacePatchFieldDecomposerPtrs_[patchi] = + processorSurfacePatchFieldDecomposerPtrs_.set + ( + patchi, new processorSurfacePatchFieldDecomposer ( static_cast<const labelUList&> ( - procMesh_.boundary()[patchi].patchSlice + fvp.patchSlice ( faceAddressing_ ) ) - ); + ) + ); + + faceSign_.set + ( + patchi, + new scalarField(fvp.patchSlice(faceAddressing_).size()) + ); + + { + const SubList<label> fa = fvp.patchSlice(faceAddressing_); + scalarField& s = faceSign_[patchi]; + forAll(s, i) + { + s[i] = sign(fa[i]); + } + } } } } @@ -187,30 +203,7 @@ Foam::fvFieldDecomposer::fvFieldDecomposer // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::fvFieldDecomposer::~fvFieldDecomposer() -{ - forAll(patchFieldDecomposerPtrs_, patchi) - { - if (patchFieldDecomposerPtrs_[patchi]) - { - delete patchFieldDecomposerPtrs_[patchi]; - } - } +{} - forAll(processorVolPatchFieldDecomposerPtrs_, patchi) - { - if (processorVolPatchFieldDecomposerPtrs_[patchi]) - { - delete processorVolPatchFieldDecomposerPtrs_[patchi]; - } - } - - forAll(processorSurfacePatchFieldDecomposerPtrs_, patchi) - { - if (processorSurfacePatchFieldDecomposerPtrs_[patchi]) - { - delete processorSurfacePatchFieldDecomposerPtrs_[patchi]; - } - } -} // ************************************************************************* // diff --git a/src/parallel/decompose/decompose/fvFieldDecomposer.H b/src/parallel/decompose/decompose/fvFieldDecomposer.H index c6953b37a4aa056e5d415b70ce6e6771da4edc63..b4193edc97adced5649596aba0bad02edc5cbe1d 100644 --- a/src/parallel/decompose/decompose/fvFieldDecomposer.H +++ b/src/parallel/decompose/decompose/fvFieldDecomposer.H @@ -215,15 +215,18 @@ private: const labelList& boundaryAddressing_; //- List of patch field decomposers - List<patchFieldDecomposer*> patchFieldDecomposerPtrs_; + PtrList<patchFieldDecomposer> patchFieldDecomposerPtrs_; - List<processorVolPatchFieldDecomposer*> + PtrList<processorVolPatchFieldDecomposer> processorVolPatchFieldDecomposerPtrs_; - List<processorSurfacePatchFieldDecomposer*> + PtrList<processorSurfacePatchFieldDecomposer> processorSurfacePatchFieldDecomposerPtrs_; + PtrList<scalarField> faceSign_; + + // Private Member Functions //- Disallow default bitwise copy construct diff --git a/src/parallel/decompose/decompose/fvFieldDecomposerDecomposeFields.C b/src/parallel/decompose/decompose/fvFieldDecomposerDecomposeFields.C index a5e87d2097ca5f247eb11f7a1d4d5189a1b307b7..cffd1a6e1e239ca899475eee1b67a6f9c9addbc1 100644 --- a/src/parallel/decompose/decompose/fvFieldDecomposerDecomposeFields.C +++ b/src/parallel/decompose/decompose/fvFieldDecomposerDecomposeFields.C @@ -40,6 +40,8 @@ Foam::fvFieldDecomposer::decomposeField const bool allowUnknownPatchFields ) const { + typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; + // 1. Create the complete field with dummy patch fields PtrList<fvPatchField<Type>> patchFields(boundaryAddressing_.size()); @@ -58,9 +60,9 @@ Foam::fvFieldDecomposer::decomposeField } // Create the field for the processor - tmp<GeometricField<Type, fvPatchField, volMesh>> tresF + tmp<VolFieldType> tresF ( - new GeometricField<Type, fvPatchField, volMesh> + new VolFieldType ( IOobject ( @@ -76,18 +78,18 @@ Foam::fvFieldDecomposer::decomposeField patchFields ) ); - GeometricField<Type, fvPatchField, volMesh>& resF = tresF.ref(); + VolFieldType& resF = tresF.ref(); + resF.oriented() = field().oriented(); // 2. Change the fvPatchFields to the correct type using a mapper // constructor (with reference to the now correct internal field) - typename GeometricField<Type, fvPatchField, volMesh>:: - Boundary& bf = resF.boundaryFieldRef(); + typename VolFieldType::Boundary& bf = resF.boundaryFieldRef(); forAll(bf, patchi) { - if (patchFieldDecomposerPtrs_[patchi]) + if (patchFieldDecomposerPtrs_.set(patchi)) { bf.set ( @@ -97,7 +99,7 @@ Foam::fvFieldDecomposer::decomposeField field.boundaryField()[boundaryAddressing_[patchi]], procMesh_.boundary()[patchi], resF(), - *patchFieldDecomposerPtrs_[patchi] + patchFieldDecomposerPtrs_[patchi] ) ); } @@ -113,7 +115,7 @@ Foam::fvFieldDecomposer::decomposeField Field<Type> ( field.primitiveField(), - *processorVolPatchFieldDecomposerPtrs_[patchi] + processorVolPatchFieldDecomposerPtrs_[patchi] ) ) ); @@ -130,7 +132,7 @@ Foam::fvFieldDecomposer::decomposeField Field<Type> ( field.primitiveField(), - *processorVolPatchFieldDecomposerPtrs_[patchi] + processorVolPatchFieldDecomposerPtrs_[patchi] ) ) ); @@ -166,6 +168,8 @@ Foam::fvFieldDecomposer::decomposeField const GeometricField<Type, fvsPatchField, surfaceMesh>& field ) const { + typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType; + labelList mapAddr ( labelList::subList @@ -200,7 +204,7 @@ Foam::fvFieldDecomposer::decomposeField forAll(field.boundaryField(), patchi) { - const Field<Type> & p = field.boundaryField()[patchi]; + const Field<Type>& p = field.boundaryField()[patchi]; const label patchStart = field.mesh().boundaryMesh()[patchi].start(); @@ -228,9 +232,9 @@ Foam::fvFieldDecomposer::decomposeField ); } - tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tresF + tmp<SurfaceFieldType> tresF ( - new GeometricField<Type, fvsPatchField, surfaceMesh> + new SurfaceFieldType ( IOobject ( @@ -246,18 +250,17 @@ Foam::fvFieldDecomposer::decomposeField patchFields ) ); - GeometricField<Type, fvsPatchField, surfaceMesh>& resF = tresF.ref(); - + SurfaceFieldType& resF = tresF.ref(); + resF.oriented() = field().oriented(); // 2. Change the fvsPatchFields to the correct type using a mapper // constructor (with reference to the now correct internal field) - typename GeometricField<Type, fvsPatchField, surfaceMesh>:: - Boundary& bf = resF.boundaryFieldRef(); + typename SurfaceFieldType::Boundary& bf = resF.boundaryFieldRef(); forAll(boundaryAddressing_, patchi) { - if (patchFieldDecomposerPtrs_[patchi]) + if (patchFieldDecomposerPtrs_.set(patchi)) { bf.set ( @@ -267,7 +270,7 @@ Foam::fvFieldDecomposer::decomposeField field.boundaryField()[boundaryAddressing_[patchi]], procMesh_.boundary()[patchi], resF(), - *patchFieldDecomposerPtrs_[patchi] + patchFieldDecomposerPtrs_[patchi] ) ); } @@ -283,10 +286,15 @@ Foam::fvFieldDecomposer::decomposeField Field<Type> ( allFaceField, - *processorSurfacePatchFieldDecomposerPtrs_[patchi] + processorSurfacePatchFieldDecomposerPtrs_[patchi] ) ) ); + + if (resF.oriented()()) + { + bf[patchi] *= faceSign_[patchi]; + } } else if (isA<processorFvPatch>(procMesh_.boundary()[patchi])) { @@ -300,10 +308,15 @@ Foam::fvFieldDecomposer::decomposeField Field<Type> ( allFaceField, - *processorSurfacePatchFieldDecomposerPtrs_[patchi] + processorSurfacePatchFieldDecomposerPtrs_[patchi] ) ) ); + + if (resF.oriented()()) + { + bf[patchi] *= faceSign_[patchi]; + } } else { diff --git a/src/parallel/reconstruct/reconstruct/fvFieldReconstructorReconstructFields.C b/src/parallel/reconstruct/reconstruct/fvFieldReconstructorReconstructFields.C index 88a8d1b5320feab5e9d3e43e87f3c886428e786b..e7bd26b2cc95d2c4351c269360a2f62fde4b2f32 100644 --- a/src/parallel/reconstruct/reconstruct/fvFieldReconstructorReconstructFields.C +++ b/src/parallel/reconstruct/reconstruct/fvFieldReconstructorReconstructFields.C @@ -56,7 +56,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeInternalField ); } - return tmp<DimensionedField<Type, volMesh>> + tmp<DimensionedField<Type, volMesh>> tfield ( new DimensionedField<Type, volMesh> ( @@ -66,6 +66,10 @@ Foam::fvFieldReconstructor::reconstructFvVolumeInternalField internalField ) ); + + tfield.ref().oriented() = procFields[0].oriented(); + + return tfield; } @@ -282,7 +286,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField // Now construct and write the field // setting the internalField and patchFields - return tmp<GeometricField<Type, fvPatchField, volMesh>> + tmp<GeometricField<Type, fvPatchField, volMesh>> tfield ( new GeometricField<Type, fvPatchField, volMesh> ( @@ -293,6 +297,10 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField patchFields ) ); + + tfield.ref().oriented() = procFields[0].oriented(); + + return tfield; } @@ -523,7 +531,7 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField // Now construct and write the field // setting the internalField and patchFields - return tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> + tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tfield ( new GeometricField<Type, fvsPatchField, surfaceMesh> ( @@ -534,6 +542,10 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField patchFields ) ); + + tfield.ref().oriented() = procFields[0].oriented(); + + return tfield; }