Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

This commit is contained in:
mattijs
2017-05-24 16:11:33 +01:00
70 changed files with 2702 additions and 315 deletions

View File

@ -120,11 +120,14 @@ int main(int argc, char *argv[])
"cSf_pos", "cSf_pos",
interpolate(c, pos, T.name())*mesh.magSf() interpolate(c, pos, T.name())*mesh.magSf()
); );
cSf_pos.setOriented();
surfaceScalarField cSf_neg surfaceScalarField cSf_neg
( (
"cSf_neg", "cSf_neg",
interpolate(c, neg, T.name())*mesh.magSf() interpolate(c, neg, T.name())*mesh.magSf()
); );
cSf_neg.setOriented();
surfaceScalarField ap surfaceScalarField ap
( (
@ -269,4 +272,5 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -101,11 +101,14 @@ int main(int argc, char *argv[])
"cSf_pos", "cSf_pos",
interpolate(c, pos, T.name())*mesh.magSf() interpolate(c, pos, T.name())*mesh.magSf()
); );
cSf_pos.setOriented();
surfaceScalarField cSf_neg surfaceScalarField cSf_neg
( (
"cSf_neg", "cSf_neg",
interpolate(c, neg, T.name())*mesh.magSf() interpolate(c, neg, T.name())*mesh.magSf()
); );
cSf_neg.setOriented();
surfaceScalarField ap surfaceScalarField ap
( (

View File

@ -38,7 +38,6 @@ Description
#include "basicReactingMultiphaseCloud.H" #include "basicReactingMultiphaseCloud.H"
#include "rhoCombustionModel.H" #include "rhoCombustionModel.H"
#include "radiationModel.H" #include "radiationModel.H"
#include "IOporosityModelList.H"
#include "fvOptions.H" #include "fvOptions.H"
#include "SLGThermo.H" #include "SLGThermo.H"
#include "simpleControl.H" #include "simpleControl.H"

View File

@ -113,6 +113,7 @@ Foam::multiphaseMixtureThermo::multiphaseMixtureThermo
1e-8/pow(average(mesh_.V()), 1.0/3.0) 1e-8/pow(average(mesh_.V()), 1.0/3.0)
) )
{ {
rhoPhi_.setOriented();
calcAlphas(); calcAlphas();
alphas_.write(); alphas_.write();
correct(); correct();
@ -698,6 +699,7 @@ Foam::multiphaseMixtureThermo::surfaceTensionForce() const
); );
surfaceScalarField& stf = tstf.ref(); surfaceScalarField& stf = tstf.ref();
stf.setOriented();
forAllConstIter(PtrDictionary<phaseModel>, phases_, phase1) forAllConstIter(PtrDictionary<phaseModel>, phases_, phase1)
{ {

View File

@ -801,6 +801,7 @@ Foam::tmp<Foam::surfaceScalarField> Foam::multiphaseSystem::surfaceTension
) )
) )
); );
tSurfaceTension.ref().setOriented();
forAllConstIter(PtrDictionary<phaseModel>, phases_, iter) forAllConstIter(PtrDictionary<phaseModel>, phases_, iter)
{ {

View File

@ -113,6 +113,8 @@ Foam::phaseModel::phaseModel
dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0) dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0)
) )
{ {
alphaPhi_.setOriented();
const word phiName = IOobject::groupName("phi", name_); const word phiName = IOobject::groupName("phi", name_);
IOobject phiHeader IOobject phiHeader

View File

@ -128,6 +128,8 @@ Foam::multiphaseMixture::multiphaseMixture
1e-8/pow(average(mesh_.V()), 1.0/3.0) 1e-8/pow(average(mesh_.V()), 1.0/3.0)
) )
{ {
rhoPhi_.setOriented();
calcAlphas(); calcAlphas();
alphas_.write(); alphas_.write();
} }
@ -273,6 +275,7 @@ Foam::multiphaseMixture::surfaceTensionForce() const
); );
surfaceScalarField& stf = tstf.ref(); surfaceScalarField& stf = tstf.ref();
stf.setOriented();
forAllConstIter(PtrDictionary<phase>, phases_, iter1) forAllConstIter(PtrDictionary<phase>, phases_, iter1)
{ {

View File

@ -455,6 +455,7 @@ Foam::BlendedInterfacialModel<ModelType>::Ff() const
dimensionedScalar("zero", ModelType::dimF*dimArea, 0) dimensionedScalar("zero", ModelType::dimF*dimArea, 0)
) )
); );
x.ref().setOriented();
if (model_.valid()) if (model_.valid())
{ {

View File

@ -347,7 +347,7 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::Ff
} }
else else
{ {
return tmp<surfaceScalarField> tmp<surfaceScalarField> tFf
( (
new surfaceScalarField new surfaceScalarField
( (
@ -364,6 +364,10 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::Ff
dimensionedScalar("zero", liftModel::dimF*dimArea, 0) 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]; return phiDs[phasei];

View File

@ -200,6 +200,9 @@ Foam::MovingPhaseModel<BasePhaseModel>::MovingPhaseModel
dimensionedScalar("0", dimDensity/dimTime, 0) dimensionedScalar("0", dimDensity/dimTime, 0)
) )
{ {
alphaPhi_.setOriented();
alphaRhoPhi_.setOriented();
phi_.writeOpt() = IOobject::AUTO_WRITE; phi_.writeOpt() = IOobject::AUTO_WRITE;
correctKinematics(); correctKinematics();
} }

View File

@ -548,6 +548,8 @@ Foam::tmp<Foam::surfaceScalarField> Foam::multiphaseSystem::surfaceTension
) )
); );
tSurfaceTension.ref().setOriented();
forAll(phases(), phasej) forAll(phases(), phasej)
{ {
const phaseModel& phase2 = phases()[phasej]; const phaseModel& phase2 = phases()[phasej];

View File

@ -109,6 +109,9 @@ Foam::phaseModel::phaseModel
dimensionedScalar("0", dimensionSet(1, 0, -1, 0, 0), 0) dimensionedScalar("0", dimensionSet(1, 0, -1, 0, 0), 0)
) )
{ {
alphaPhi_.setOriented();
alphaRhoPhi_.setOriented();
thermo_->validate("phaseModel " + name_, "h", "e"); thermo_->validate("phaseModel " + name_, "h", "e");
const word phiName = IOobject::groupName("phi", name_); const word phiName = IOobject::groupName("phi", name_);

View File

@ -0,0 +1,3 @@
Test-mapDistributePolyMesh.C
EXE = $(FOAM_USER_APPBIN)/Test-mapDistributePolyMesh

View File

@ -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

View File

@ -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;
}
// ************************************************************************* //

View File

@ -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;
}
}
// ************************************************************************* //

View File

@ -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;
}
}
// ************************************************************************* //

View File

@ -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();
}
}
// ************************************************************************* //

View File

@ -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
# -----------------------------------------------------------------------------

View File

@ -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
# -----------------------------------------------------------------------------

View File

@ -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;
// ************************************************************************* //

View File

@ -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
(
);
// ************************************************************************* //

View File

@ -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;
// ************************************************************************* //

View File

@ -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;
// ************************************************************************* //

View File

@ -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;
// ************************************************************************* //

View File

@ -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"
//);
// ************************************************************************* //

View File

@ -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"
//);
// ************************************************************************* //

View File

@ -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"
//);
// ************************************************************************* //

View File

@ -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;
}
// ************************************************************************* //

View File

@ -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;
}
// ************************************************************************* //

View File

@ -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;
}
// ************************************************************************* //

View File

@ -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;
}
// ************************************************************************* //

View File

@ -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();
#};
}
}
// ************************************************************************* //

View File

@ -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;
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -66,7 +66,7 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeInternalField
IOobject::NO_WRITE IOobject::NO_WRITE
); );
return tmp<DimensionedField<Type, volMesh>> tmp<DimensionedField<Type, volMesh>> tfield
( (
new DimensionedField<Type, volMesh> new DimensionedField<Type, volMesh>
( (
@ -76,6 +76,10 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeInternalField
internalField internalField
) )
); );
tfield.ref().oriented() = fld.oriented();
return tfield;
} }
@ -209,7 +213,7 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeField
IOobject::NO_WRITE IOobject::NO_WRITE
); );
return tmp<GeometricField<Type, fvPatchField, volMesh>> tmp<GeometricField<Type, fvPatchField, volMesh>> tfield
( (
new GeometricField<Type, fvPatchField, volMesh> new GeometricField<Type, fvPatchField, volMesh>
( (
@ -220,6 +224,10 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeField
basePatchFields basePatchFields
) )
); );
tfield.ref().oriented()= fld.oriented();
return tfield;
} }
@ -269,7 +277,7 @@ Foam::parFvFieldReconstructor::reconstructFvSurfaceField
} }
// Map all faces // 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) // Trim to internal faces (note: could also have special mapper)
internalField.setSize internalField.setSize
@ -372,7 +380,7 @@ Foam::parFvFieldReconstructor::reconstructFvSurfaceField
IOobject::NO_WRITE IOobject::NO_WRITE
); );
return tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tfield
( (
new GeometricField<Type, fvsPatchField, surfaceMesh> new GeometricField<Type, fvsPatchField, surfaceMesh>
( (
@ -383,6 +391,10 @@ Foam::parFvFieldReconstructor::reconstructFvSurfaceField
basePatchFields basePatchFields
) )
); );
tfield.ref().oriented() = fld.oriented();
return tfield;
} }

View File

@ -275,6 +275,8 @@ dimensionedTypes/dimensionedSphericalTensor/dimensionedSphericalTensor.C
dimensionedTypes/dimensionedSymmTensor/dimensionedSymmTensor.C dimensionedTypes/dimensionedSymmTensor/dimensionedSymmTensor.C
dimensionedTypes/dimensionedTensor/dimensionedTensor.C dimensionedTypes/dimensionedTensor/dimensionedTensor.C
orientedType/orientedType.C
matrices/solution/solution.C matrices/solution/solution.C
scalarMatrices = matrices/scalarMatrices scalarMatrices = matrices/scalarMatrices

View File

@ -80,7 +80,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField
regIOobject(io), regIOobject(io),
Field<Type>(field), Field<Type>(field),
mesh_(mesh), mesh_(mesh),
dimensions_(dims) dimensions_(dims),
oriented_()
{ {
checkFieldSize(); checkFieldSize();
} }
@ -134,7 +135,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField
regIOobject(io), regIOobject(io),
Field<Type>(GeoMesh::size(mesh)), Field<Type>(GeoMesh::size(mesh)),
mesh_(mesh), mesh_(mesh),
dimensions_(dims) dimensions_(dims),
oriented_()
{ {
if (checkIOFlags) if (checkIOFlags)
{ {
@ -155,7 +157,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField
regIOobject(io), regIOobject(io),
Field<Type>(GeoMesh::size(mesh), dt.value()), Field<Type>(GeoMesh::size(mesh), dt.value()),
mesh_(mesh), mesh_(mesh),
dimensions_(dt.dimensions()) dimensions_(dt.dimensions()),
oriented_()
{ {
if (checkIOFlags) if (checkIOFlags)
{ {
@ -173,7 +176,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField
regIOobject(df), regIOobject(df),
Field<Type>(df), Field<Type>(df),
mesh_(df.mesh_), mesh_(df.mesh_),
dimensions_(df.dimensions_) dimensions_(df.dimensions_),
oriented_(df.oriented_)
{} {}
@ -187,7 +191,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField
regIOobject(df, reuse), regIOobject(df, reuse),
Field<Type>(df, reuse), Field<Type>(df, reuse),
mesh_(df.mesh_), mesh_(df.mesh_),
dimensions_(df.dimensions_) dimensions_(df.dimensions_),
oriented_(df.oriented_)
{} {}
@ -200,7 +205,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField
regIOobject(df(), true), regIOobject(df(), true),
Field<Type>(df), Field<Type>(df),
mesh_(df->mesh_), mesh_(df->mesh_),
dimensions_(df->dimensions_) dimensions_(df->dimensions_),
oriented_(df->oriented_)
{} {}
@ -218,7 +224,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField
tdf.isTmp() tdf.isTmp()
), ),
mesh_(tdf().mesh_), mesh_(tdf().mesh_),
dimensions_(tdf().dimensions_) dimensions_(tdf().dimensions_),
oriented_(tdf().oriented_)
{ {
tdf.clear(); tdf.clear();
} }
@ -235,7 +242,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField
regIOobject(io), regIOobject(io),
Field<Type>(df), Field<Type>(df),
mesh_(df.mesh_), mesh_(df.mesh_),
dimensions_(df.dimensions_) dimensions_(df.dimensions_),
oriented_(df.oriented_)
{} {}
@ -250,7 +258,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField
regIOobject(io, df), regIOobject(io, df),
Field<Type>(df, reuse), Field<Type>(df, reuse),
mesh_(df.mesh_), 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()), regIOobject(newName, df, newName == df.name()),
Field<Type>(df), Field<Type>(df),
mesh_(df.mesh_), mesh_(df.mesh_),
dimensions_(df.dimensions_) dimensions_(df.dimensions_),
oriented_(df.oriented_)
{} {}
@ -279,7 +289,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField
regIOobject(newName, df, true), regIOobject(newName, df, true),
Field<Type>(df, reuse), Field<Type>(df, reuse),
mesh_(df.mesh_), mesh_(df.mesh_),
dimensions_(df.dimensions_) dimensions_(df.dimensions_),
oriented_(df.oriented_)
{} {}
@ -293,7 +304,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField
regIOobject(newName, df, true), regIOobject(newName, df, true),
Field<Type>(df), Field<Type>(df),
mesh_(df->mesh_), mesh_(df->mesh_),
dimensions_(df->dimensions_) dimensions_(df->dimensions_),
oriented_(df->oriented_)
{} {}
@ -312,7 +324,8 @@ DimensionedField<Type, GeoMesh>::DimensionedField
tdf.isTmp() tdf.isTmp()
), ),
mesh_(tdf().mesh_), mesh_(tdf().mesh_),
dimensions_(tdf().dimensions_) dimensions_(tdf().dimensions_),
oriented_(tdf().oriented_)
{ {
tdf.clear(); tdf.clear();
} }
@ -487,6 +500,7 @@ void DimensionedField<Type, GeoMesh>::operator=
checkField(*this, df, "="); checkField(*this, df, "=");
dimensions_ = df.dimensions(); dimensions_ = df.dimensions();
oriented_ = df.oriented();
Field<Type>::operator=(df); Field<Type>::operator=(df);
} }
@ -510,6 +524,7 @@ void DimensionedField<Type, GeoMesh>::operator=
checkField(*this, df, "="); checkField(*this, df, "=");
dimensions_ = df.dimensions(); dimensions_ = df.dimensions();
oriented_ = df.oriented();
this->transfer(const_cast<DimensionedField<Type, GeoMesh>&>(df)); this->transfer(const_cast<DimensionedField<Type, GeoMesh>&>(df));
tdf.clear(); tdf.clear();
} }
@ -537,6 +552,7 @@ void DimensionedField<Type, GeoMesh>::operator op \
checkField(*this, df, #op); \ checkField(*this, df, #op); \
\ \
dimensions_ op df.dimensions(); \ dimensions_ op df.dimensions(); \
oriented_ op df.oriented(); \
Field<Type>::operator op(df); \ Field<Type>::operator op(df); \
} \ } \
\ \

View File

@ -41,6 +41,7 @@ SourceFiles
#include "regIOobject.H" #include "regIOobject.H"
#include "Field.H" #include "Field.H"
#include "dimensionedType.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> template<class Type, class GeoMesh>
@ -99,6 +100,9 @@ private:
//- Dimension set for this field //- Dimension set for this field
dimensionSet dimensions_; dimensionSet dimensions_;
//- Oriented flag
orientedType oriented_;
// Private Member Functions // Private Member Functions
@ -283,6 +287,15 @@ public:
//- Return non-const access to dimensions //- Return non-const access to dimensions
inline dimensionSet& 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 //- Return field
inline const Field<Type>& field() const; inline const Field<Type>& field() const;

View File

@ -52,6 +52,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \
\ \
Func(tRes.ref().field(), df1.field()); \ Func(tRes.ref().field(), df1.field()); \
\ \
tRes.ref().oriented() = Dfunc(df1.oriented()); \
\
return tRes; \ return tRes; \
} \ } \
\ \
@ -75,6 +77,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \
\ \
Func(tRes.ref().field(), df1.field()); \ Func(tRes.ref().field(), df1.field()); \
\ \
tRes.ref().oriented() = Dfunc(df1.oriented()); \
\
tdf1.clear(); \ tdf1.clear(); \
\ \
return tRes; \ return tRes; \
@ -108,6 +112,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
\ \
Foam::OpFunc(tRes.ref().field(), df1.field()); \ Foam::OpFunc(tRes.ref().field(), df1.field()); \
\ \
tRes.ref().oriented() = Dfunc(df1.oriented()); \
\
return tRes; \ return tRes; \
} \ } \
\ \
@ -131,6 +137,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
\ \
Foam::OpFunc(tRes.ref().field(), df1.field()); \ Foam::OpFunc(tRes.ref().field(), df1.field()); \
\ \
tRes.ref().oriented() = Dfunc(df1.oriented()); \
\
tdf1.clear(); \ tdf1.clear(); \
\ \
return tRes; \ return tRes; \
@ -165,6 +173,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \
\ \
Func(tRes.ref().field(), df1.field(), df2.field()); \ Func(tRes.ref().field(), df1.field(), df2.field()); \
\ \
tRes.ref().oriented() = Func(df1.oriented(), df2.oriented()); \
\
return tRes; \ return tRes; \
} \ } \
\ \
@ -189,6 +199,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \
\ \
Func(tRes.ref().field(), df1.field(), df2.field()); \ Func(tRes.ref().field(), df1.field(), df2.field()); \
\ \
tRes.ref().oriented() = Func(df1.oriented(), df2.oriented()); \
\
tdf2.clear(); \ tdf2.clear(); \
\ \
return tRes; \ return tRes; \
@ -215,6 +227,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \
\ \
Func(tRes.ref().field(), df1.field(), df2.field()); \ Func(tRes.ref().field(), df1.field(), df2.field()); \
\ \
tRes.ref().oriented() = Func(df1.oriented(), df2.oriented()); \
\
tdf1.clear(); \ tdf1.clear(); \
\ \
return tRes; \ return tRes; \
@ -244,6 +258,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \
\ \
Func(tRes.ref().field(), df1.field(), df2.field()); \ Func(tRes.ref().field(), df1.field(), df2.field()); \
\ \
tRes.ref().oriented() = Func(df1.oriented(), df2.oriented()); \
\
tdf1.clear(); \ tdf1.clear(); \
tdf2.clear(); \ tdf2.clear(); \
\ \
@ -279,6 +295,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \
\ \
Func(tRes.ref().field(), dt1.value(), df2.field()); \ Func(tRes.ref().field(), dt1.value(), df2.field()); \
\ \
tRes.ref().oriented() = df2.oriented(); \
\
return tRes; \ return tRes; \
} \ } \
\ \
@ -314,6 +332,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \
\ \
Func(tRes.ref().field(), dt1.value(), df2.field()); \ Func(tRes.ref().field(), dt1.value(), df2.field()); \
\ \
tRes.ref().oriented() = df2.oriented(); \
\
tdf2.clear(); \ tdf2.clear(); \
\ \
return tRes; \ return tRes; \
@ -356,6 +376,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \
\ \
Func(tRes.ref().field(), df1.field(), dt2.value()); \ Func(tRes.ref().field(), df1.field(), dt2.value()); \
\ \
tRes.ref().oriented() = df1.oriented(); \
\
return tRes; \ return tRes; \
} \ } \
\ \
@ -391,6 +413,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \
\ \
Func(tRes.ref().field(), df1.field(), dt2.value()); \ Func(tRes.ref().field(), df1.field(), dt2.value()); \
\ \
tRes.ref().oriented() = df1.oriented(); \
\
tdf1.clear(); \ tdf1.clear(); \
\ \
return tRes; \ return tRes; \
@ -440,6 +464,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
\ \
Foam::OpFunc(tRes.ref().field(), df1.field(), df2.field()); \ Foam::OpFunc(tRes.ref().field(), df1.field(), df2.field()); \
\ \
tRes.ref().oriented() = df1.oriented() Op df2.oriented(); \
\
return tRes; \ return tRes; \
} \ } \
\ \
@ -464,6 +490,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
\ \
Foam::OpFunc(tRes.ref().field(), df1.field(), df2.field()); \ Foam::OpFunc(tRes.ref().field(), df1.field(), df2.field()); \
\ \
tRes.ref().oriented() = df1.oriented() Op df2.oriented(); \
\
tdf2.clear(); \ tdf2.clear(); \
\ \
return tRes; \ return tRes; \
@ -490,6 +518,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
\ \
Foam::OpFunc(tRes.ref().field(), df1.field(), df2.field()); \ Foam::OpFunc(tRes.ref().field(), df1.field(), df2.field()); \
\ \
tRes.ref().oriented() = df1.oriented() Op df2.oriented(); \
\
tdf1.clear(); \ tdf1.clear(); \
\ \
return tRes; \ return tRes; \
@ -519,6 +549,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
\ \
Foam::OpFunc(tRes.ref().field(), df1.field(), df2.field()); \ Foam::OpFunc(tRes.ref().field(), df1.field(), df2.field()); \
\ \
tRes.ref().oriented() = df1.oriented() Op df2.oriented(); \
\
tdf1.clear(); \ tdf1.clear(); \
tdf2.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 \ TEMPLATE \
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ 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()); \ Foam::OpFunc(tRes.ref().field(), dt1.value(), df2.field()); \
\ \
return tRes; \ return tRes; \
@ -589,6 +623,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
\ \
Foam::OpFunc(tRes.ref().field(), dt1.value(), tdf2().field()); \ Foam::OpFunc(tRes.ref().field(), dt1.value(), tdf2().field()); \
\ \
tRes.ref().oriented() = df2.oriented(); \
\
tdf2.clear(); \ tdf2.clear(); \
\ \
return tRes; \ 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 \ TEMPLATE \
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \ 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()); \ Foam::OpFunc(tRes.ref().field(), df1.field(), dt2.value()); \
\ \
tRes.ref().oriented() = df1.oriented(); \
\
return tRes; \ return tRes; \
} \ } \
\ \
@ -666,6 +704,8 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
\ \
Foam::OpFunc(tRes.ref().field(), tdf1().field(), dt2.value()); \ Foam::OpFunc(tRes.ref().field(), tdf1().field(), dt2.value()); \
\ \
tRes.ref().oriented() = df1.oriented(); \
\
tdf1.clear(); \ tdf1.clear(); \
\ \
return tRes; \ return tRes; \

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -48,14 +48,39 @@ Foam::DimensionedField<Type, GeoMesh>::dimensions() const
return dimensions_; return dimensions_;
} }
template<class Type, class GeoMesh> template<class Type, class GeoMesh>
inline Foam::dimensionSet& inline Foam::dimensionSet& Foam::DimensionedField<Type, GeoMesh>::dimensions()
Foam::DimensionedField<Type, GeoMesh>::dimensions()
{ {
return 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> template<class Type, class GeoMesh>
inline const Foam::Field<Type>& inline const Foam::Field<Type>&
Foam::DimensionedField<Type, GeoMesh>::field() const Foam::DimensionedField<Type, GeoMesh>::field() const
@ -63,6 +88,7 @@ Foam::DimensionedField<Type, GeoMesh>::field() const
return *this; return *this;
} }
template<class Type, class GeoMesh> template<class Type, class GeoMesh>
inline Foam::Field<Type>& inline Foam::Field<Type>&
Foam::DimensionedField<Type, GeoMesh>::field() Foam::DimensionedField<Type, GeoMesh>::field()

View File

@ -37,6 +37,7 @@ void Foam::DimensionedField<Type, GeoMesh>::readField
) )
{ {
dimensions_.reset(dimensionSet(fieldDict.lookup("dimensions"))); dimensions_.reset(dimensionSet(fieldDict.lookup("dimensions")));
oriented_.read(fieldDict);
Field<Type> f(fieldDictEntry, fieldDict, GeoMesh::size(mesh_)); Field<Type> f(fieldDictEntry, fieldDict, GeoMesh::size(mesh_));
this->transfer(f); this->transfer(f);
@ -74,7 +75,8 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
regIOobject(io), regIOobject(io),
Field<Type>(0), Field<Type>(0),
mesh_(mesh), mesh_(mesh),
dimensions_(dimless) dimensions_(dimless),
oriented_()
{ {
readField(dictionary(readStream(typeName)), fieldDictEntry); readField(dictionary(readStream(typeName)), fieldDictEntry);
} }
@ -92,7 +94,8 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
regIOobject(io), regIOobject(io),
Field<Type>(0), Field<Type>(0),
mesh_(mesh), mesh_(mesh),
dimensions_(dimless) dimensions_(dimless),
oriented_()
{ {
readField(fieldDict, fieldDictEntry); readField(fieldDict, fieldDictEntry);
} }
@ -107,17 +110,15 @@ bool Foam::DimensionedField<Type, GeoMesh>::writeData
const word& fieldDictEntry const word& fieldDictEntry
) const ) const
{ {
os.writeKeyword("dimensions") << dimensions() << token::END_STATEMENT os.writeEntry("dimensions", dimensions());
<< nl << nl; oriented_.writeEntry(os);
os<< nl << nl;
Field<Type>::writeEntry(fieldDictEntry, os); Field<Type>::writeEntry(fieldDictEntry, os);
// Check state of Ostream // Check state of Ostream
os.check os.check(FUNCTION_NAME);
(
"bool DimensionedField<Type, GeoMesh>::writeData"
"(Ostream& os, const word& fieldDictEntry) const"
);
return (os.good()); return (os.good());
} }

View File

@ -28,7 +28,6 @@ License
#include "dictionary.H" #include "dictionary.H"
#include "contiguous.H" #include "contiguous.H"
#include "mapDistributeBase.H" #include "mapDistributeBase.H"
#include "flipOp.H"
// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * //

View File

@ -1175,6 +1175,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
// Only assign field contents not ID // Only assign field contents not ID
this->dimensions() = gf.dimensions(); this->dimensions() = gf.dimensions();
this->oriented() = gf.oriented();
if (tgf.isTmp()) if (tgf.isTmp())
{ {
@ -1246,7 +1247,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
{ \ { \
checkField(*this, gf, #op); \ checkField(*this, gf, #op); \
\ \
ref() op gf(); \ ref() op gf(); \
boundaryFieldRef() op gf.boundaryField(); \ boundaryFieldRef() op gf.boundaryField(); \
} \ } \
\ \
@ -1266,7 +1267,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
const dimensioned<TYPE>& dt \ const dimensioned<TYPE>& dt \
) \ ) \
{ \ { \
ref() op dt; \ ref() op dt; \
boundaryFieldRef() op dt.value(); \ boundaryFieldRef() op dt.value(); \
} }

View File

@ -51,6 +51,7 @@ void component
{ {
component(gcf.primitiveFieldRef(), gf.primitiveField(), d); component(gcf.primitiveFieldRef(), gf.primitiveField(), d);
component(gcf.boundaryFieldRef(), gf.boundaryField(), d); component(gcf.boundaryFieldRef(), gf.boundaryField(), d);
gcf.oriented() = gf.oriented();
} }
@ -63,6 +64,7 @@ void T
{ {
T(gf.primitiveFieldRef(), gf1.primitiveField()); T(gf.primitiveFieldRef(), gf1.primitiveField());
T(gf.boundaryFieldRef(), gf1.boundaryField()); T(gf.boundaryFieldRef(), gf1.boundaryField());
gf.oriented() = gf1.oriented();
} }
@ -81,6 +83,7 @@ void pow
{ {
pow(gf.primitiveFieldRef(), gf1.primitiveField(), r); pow(gf.primitiveFieldRef(), gf1.primitiveField(), r);
pow(gf.boundaryFieldRef(), gf1.boundaryField(), r); pow(gf.boundaryFieldRef(), gf1.boundaryField(), r);
gf.oriented() = pow(gf1.oriented(), r);
} }
template template
@ -175,6 +178,7 @@ void sqr
{ {
sqr(gf.primitiveFieldRef(), gf1.primitiveField()); sqr(gf.primitiveFieldRef(), gf1.primitiveField());
sqr(gf.boundaryFieldRef(), gf1.boundaryField()); sqr(gf.boundaryFieldRef(), gf1.boundaryField());
gf.oriented() = sqr(gf1.oriented());
} }
template<class Type, template<class> class PatchField, class GeoMesh> template<class Type, template<class> class PatchField, class GeoMesh>
@ -263,6 +267,7 @@ void magSqr
{ {
magSqr(gsf.primitiveFieldRef(), gf.primitiveField()); magSqr(gsf.primitiveFieldRef(), gf.primitiveField());
magSqr(gsf.boundaryFieldRef(), gf.boundaryField()); magSqr(gsf.boundaryFieldRef(), gf.boundaryField());
gsf.oriented() = magSqr(gf.oriented());
} }
template<class Type, template<class> class PatchField, class GeoMesh> template<class Type, template<class> class PatchField, class GeoMesh>
@ -335,6 +340,7 @@ void mag
{ {
mag(gsf.primitiveFieldRef(), gf.primitiveField()); mag(gsf.primitiveFieldRef(), gf.primitiveField());
mag(gsf.boundaryFieldRef(), gf.boundaryField()); mag(gsf.boundaryFieldRef(), gf.boundaryField());
gsf.oriented() = mag(gf.oriented());
} }
template<class Type, template<class> class PatchField, class GeoMesh> template<class Type, template<class> class PatchField, class GeoMesh>
@ -412,6 +418,7 @@ void cmptAv
{ {
cmptAv(gcf.primitiveFieldRef(), gf.primitiveField()); cmptAv(gcf.primitiveFieldRef(), gf.primitiveField());
cmptAv(gcf.boundaryFieldRef(), gf.boundaryField()); cmptAv(gcf.boundaryFieldRef(), gf.boundaryField());
gcf.oriented() = cmptAv(gf.oriented());
} }
template<class Type, template<class> class PatchField, class GeoMesh> template<class Type, template<class> class PatchField, class GeoMesh>
@ -611,6 +618,8 @@ void opFunc \
gf1.boundaryField(), \ gf1.boundaryField(), \
gf2.boundaryField() \ gf2.boundaryField() \
); \ ); \
\
gf.oriented() = gf1.oriented() op gf2.oriented(); \
} \ } \
\ \
template \ template \
@ -757,6 +766,7 @@ void opFunc \
{ \ { \
Foam::opFunc(gf.primitiveFieldRef(), gf1.primitiveField(), dvs.value()); \ Foam::opFunc(gf.primitiveFieldRef(), gf1.primitiveField(), dvs.value()); \
Foam::opFunc(gf.boundaryFieldRef(), gf1.boundaryField(), dvs.value()); \ Foam::opFunc(gf.boundaryFieldRef(), gf1.boundaryField(), dvs.value()); \
gf.oriented() = gf1.oriented(); \
} \ } \
\ \
template \ template \
@ -870,6 +880,7 @@ void opFunc \
{ \ { \
Foam::opFunc(gf.primitiveFieldRef(), dvs.value(), gf1.primitiveField()); \ Foam::opFunc(gf.primitiveFieldRef(), dvs.value(), gf1.primitiveField()); \
Foam::opFunc(gf.boundaryFieldRef(), dvs.value(), gf1.boundaryField()); \ Foam::opFunc(gf.boundaryFieldRef(), dvs.value(), gf1.boundaryField()); \
gf.oriented() = gf1.oriented(); \
} \ } \
\ \
template \ template \

View File

@ -43,6 +43,7 @@ void Func \
{ \ { \
Foam::Func(res.primitiveFieldRef(), gf1.primitiveField()); \ Foam::Func(res.primitiveFieldRef(), gf1.primitiveField()); \
Foam::Func(res.boundaryFieldRef(), gf1.boundaryField()); \ Foam::Func(res.boundaryFieldRef(), gf1.boundaryField()); \
res.oriented() = gf1.oriented(); \
} \ } \
\ \
TEMPLATE \ TEMPLATE \
@ -112,6 +113,7 @@ void OpFunc \
{ \ { \
Foam::OpFunc(res.primitiveFieldRef(), gf1.primitiveField()); \ Foam::OpFunc(res.primitiveFieldRef(), gf1.primitiveField()); \
Foam::OpFunc(res.boundaryFieldRef(), gf1.boundaryField()); \ Foam::OpFunc(res.boundaryFieldRef(), gf1.boundaryField()); \
res.oriented() = gf1.oriented(); \
} \ } \
\ \
TEMPLATE \ TEMPLATE \
@ -192,6 +194,7 @@ void Func \
gf1.boundaryField(), \ gf1.boundaryField(), \
gf2.boundaryField() \ gf2.boundaryField() \
); \ ); \
res.oriented() = Func(gf1.oriented(), gf2.oriented()); \
} \ } \
\ \
TEMPLATE \ TEMPLATE \
@ -320,6 +323,7 @@ void Func \
{ \ { \
Foam::Func(res.primitiveFieldRef(), dt1.value(), gf2.primitiveField()); \ Foam::Func(res.primitiveFieldRef(), dt1.value(), gf2.primitiveField()); \
Foam::Func(res.boundaryFieldRef(), dt1.value(), gf2.boundaryField()); \ Foam::Func(res.boundaryFieldRef(), dt1.value(), gf2.boundaryField()); \
res.oriented() = gf2.oriented(); \
} \ } \
\ \
TEMPLATE \ TEMPLATE \
@ -411,6 +415,7 @@ void Func \
{ \ { \
Foam::Func(res.primitiveFieldRef(), gf1.primitiveField(), dt2.value()); \ Foam::Func(res.primitiveFieldRef(), gf1.primitiveField(), dt2.value()); \
Foam::Func(res.boundaryFieldRef(), gf1.boundaryField(), dt2.value()); \ Foam::Func(res.boundaryFieldRef(), gf1.boundaryField(), dt2.value()); \
res.oriented() = gf1.oriented(); \
} \ } \
\ \
TEMPLATE \ TEMPLATE \
@ -511,6 +516,7 @@ void OpFunc \
(res.primitiveFieldRef(), gf1.primitiveField(), gf2.primitiveField()); \ (res.primitiveFieldRef(), gf1.primitiveField(), gf2.primitiveField()); \
Foam::OpFunc \ Foam::OpFunc \
(res.boundaryFieldRef(), gf1.boundaryField(), gf2.boundaryField()); \ (res.boundaryFieldRef(), gf1.boundaryField(), gf2.boundaryField()); \
res.oriented() = gf1.oriented() Op gf2.oriented(); \
} \ } \
\ \
TEMPLATE \ TEMPLATE \
@ -639,6 +645,8 @@ void OpFunc \
{ \ { \
Foam::OpFunc(res.primitiveFieldRef(), dt1.value(), gf2.primitiveField()); \ Foam::OpFunc(res.primitiveFieldRef(), dt1.value(), gf2.primitiveField()); \
Foam::OpFunc(res.boundaryFieldRef(), dt1.value(), gf2.boundaryField()); \ Foam::OpFunc(res.boundaryFieldRef(), dt1.value(), gf2.boundaryField()); \
res.oriented() = gf2.oriented(); \
\
} \ } \
\ \
TEMPLATE \ TEMPLATE \
@ -730,6 +738,7 @@ void OpFunc \
{ \ { \
Foam::OpFunc(res.primitiveFieldRef(), gf1.primitiveField(), dt2.value()); \ Foam::OpFunc(res.primitiveFieldRef(), gf1.primitiveField(), dt2.value()); \
Foam::OpFunc(res.boundaryFieldRef(), gf1.boundaryField(), dt2.value()); \ Foam::OpFunc(res.boundaryFieldRef(), gf1.boundaryField(), dt2.value()); \
res.oriented() = gf1.oriented(); \
} \ } \
\ \
TEMPLATE \ TEMPLATE \

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -51,7 +51,7 @@ public:
void operator() void operator()
( (
Field<Type>& field, DimensionedField<Type, GeoMesh>& field,
const MeshMapper& mapper const MeshMapper& mapper
) const; ) const;
}; };
@ -72,10 +72,12 @@ void MapGeometricFields
const MeshMapper& mapper const MeshMapper& mapper
) )
{ {
HashTable<const GeometricField<Type, PatchField, GeoMesh>*> fields typedef GeometricField<Type, PatchField, GeoMesh> FieldType;
HashTable<const FieldType*> fields
( (
mapper.thisDb().objectRegistry::template mapper.thisDb().objectRegistry::template
lookupClass<GeometricField<Type, PatchField, GeoMesh>>() lookupClass<FieldType>()
); );
// It is necessary to enforce that all old-time fields are stored // 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 // old-time-level field is mapped before the field itself, sizes
// will not match. // will not match.
for forAllConstIter(typename HashTable<const FieldType*>, fields, fieldIter)
(
typename HashTable<const GeometricField<Type, PatchField, GeoMesh>*>::
iterator fieldIter = fields.begin();
fieldIter != fields.end();
++fieldIter
)
{ {
GeometricField<Type, PatchField, GeoMesh>& field = FieldType& field = const_cast<FieldType&>(*fieldIter());
const_cast<GeometricField<Type, PatchField, GeoMesh>&>
(*fieldIter());
//Note: check can be removed once pointFields are actually stored on //Note: check can be removed once pointFields are actually stored on
// the pointMesh instead of now on the polyMesh! // the pointMesh instead of now on the polyMesh!
@ -103,17 +97,9 @@ void MapGeometricFields
} }
} }
for forAllConstIter(typename HashTable<const FieldType*>, fields, fieldIter)
(
typename HashTable<const GeometricField<Type, PatchField, GeoMesh>*>::
iterator fieldIter = fields.begin();
fieldIter != fields.end();
++fieldIter
)
{ {
GeometricField<Type, PatchField, GeoMesh>& field = FieldType& field = const_cast<FieldType&>(*fieldIter());
const_cast<GeometricField<Type, PatchField, GeoMesh>&>
(*fieldIter());
if (&field.mesh() == &mapper.mesh()) if (&field.mesh() == &mapper.mesh())
{ {
@ -124,15 +110,11 @@ void MapGeometricFields
} }
// Map the internal field // Map the internal field
MapInternalField<Type, MeshMapper, GeoMesh>() MapInternalField<Type, MeshMapper, GeoMesh>()(field.ref(), mapper);
(
field.primitiveFieldRef(),
mapper
);
// Map the patch fields // Map the patch fields
typename GeometricField<Type, PatchField, GeoMesh> typename FieldType::Boundary& bfield = field.boundaryFieldRef();
::Boundary& bfield = field.boundaryFieldRef();
forAll(bfield, patchi) forAll(bfield, patchi)
{ {
// Cannot check sizes for patch fields because of // Cannot check sizes for patch fields because of

View File

@ -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);
}
// ************************************************************************* //

View File

@ -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
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / 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 License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -205,6 +205,8 @@ void Foam::fvMeshDistribute::mapExposedFaces
forAllIter(typename HashTable<fldType*>, flds, iter) forAllIter(typename HashTable<fldType*>, flds, iter)
{ {
fldType& fld = *iter(); fldType& fld = *iter();
const bool oriented = fld.oriented()();
typename fldType::Boundary& bfld = fld.boundaryFieldRef(); typename fldType::Boundary& bfld = fld.boundaryFieldRef();
const Field<T>& oldInternal = oldFlds[fieldI++]; const Field<T>& oldInternal = oldFlds[fieldI++];
@ -225,7 +227,7 @@ void Foam::fvMeshDistribute::mapExposedFaces
{ {
patchFld[i] = oldInternal[oldFaceI]; patchFld[i] = oldInternal[oldFaceI];
if (map.flipFaceFlux().found(faceI)) if (oriented && map.flipFaceFlux().found(faceI))
{ {
patchFld[i] = flipOp()(patchFld[i]); patchFld[i] = flipOp()(patchFld[i]);
} }

View File

@ -283,16 +283,14 @@ public:
const fvMesh& sMesh, const fvMesh& sMesh,
const labelList& patchMap, const labelList& patchMap,
const labelList& cellMap, const labelList& cellMap,
const labelList& faceMap, const labelList& faceMap
const bool negateIfFlipped = true
); );
template<class Type> template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
interpolate interpolate
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>&, const GeometricField<Type, fvsPatchField, surfaceMesh>&
const bool negateIfFlipped = true
) const; ) const;
//- Map point field //- Map point field

View File

@ -102,6 +102,7 @@ tmp<GeometricField<Type, fvPatchField, volMesh>> fvMeshSubset::interpolate
) )
); );
GeometricField<Type, fvPatchField, volMesh>& resF = tresF.ref(); GeometricField<Type, fvPatchField, volMesh>& resF = tresF.ref();
resF.oriented() = vf.oriented();
// 2. Change the fvPatchFields to the correct type using a mapper // 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 fvMesh& sMesh,
const labelList& patchMap, const labelList& patchMap,
const labelList& cellMap, const labelList& cellMap,
const labelList& faceMap, const labelList& faceMap
const bool negateIfFlipped
) )
{ {
// 1. Create the complete field with dummy patch fields // 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(); GeometricField<Type, fvsPatchField, surfaceMesh>& resF = tresF.ref();
resF.oriented() = vf.oriented();
// 2. Change the fvsPatchFields to the correct type using a mapper // 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]; Type val = vf.internalField()[baseFacei];
if (cellMap[fc[i]] == own[baseFacei] || !negateIfFlipped) if (cellMap[fc[i]] == own[baseFacei] || !vf.oriented()())
{ {
pfld[i] = val; pfld[i] = val;
} }
@ -342,8 +343,7 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate
template<class Type> template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>& sf, const GeometricField<Type, fvsPatchField, surfaceMesh>& sf
const bool negateIfFlipped
) const ) const
{ {
return interpolate return interpolate
@ -352,8 +352,7 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate
subMesh(), subMesh(),
patchMap(), patchMap(),
cellMap(), cellMap(),
faceMap(), faceMap()
negateIfFlipped
); );
} }
@ -423,6 +422,7 @@ fvMeshSubset::interpolate
) )
); );
GeometricField<Type, pointPatchField, pointMesh>& resF = tresF.ref(); GeometricField<Type, pointPatchField, pointMesh>& resF = tresF.ref();
resF.oriented() = vf.oriented();
// 2. Change the pointPatchFields to the correct type using a mapper // 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; return tresF;
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,6 +26,7 @@ License
#include "IOobject.H" #include "IOobject.H"
#include "dictionary.H" #include "dictionary.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "surfaceMesh.H"
#include "fvPatchFieldMapper.H" #include "fvPatchFieldMapper.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -93,20 +94,15 @@ Foam::fvsPatchField<Type>::fvsPatchField
} }
else else
{ {
FatalIOErrorInFunction FatalIOErrorInFunction(dict)
( << "essential 'value' entry not provided"
dict
) << "essential value entry not provided"
<< exit(FatalIOError); << exit(FatalIOError);
} }
} }
template<class Type> template<class Type>
Foam::fvsPatchField<Type>::fvsPatchField Foam::fvsPatchField<Type>::fvsPatchField(const fvsPatchField<Type>& ptf)
(
const fvsPatchField<Type>& ptf
)
: :
Field<Type>(ptf), Field<Type>(ptf),
patch_(ptf.patch_), patch_(ptf.patch_),
@ -149,12 +145,10 @@ void Foam::fvsPatchField<Type>::check(const fvsPatchField<Type>& ptf) const
template<class Type> template<class Type>
void Foam::fvsPatchField<Type>::autoMap void Foam::fvsPatchField<Type>::autoMap(const fvPatchFieldMapper& m)
(
const fvPatchFieldMapper& m
)
{ {
Field<Type>::autoMap(m); const bool oriented = internalField_.oriented()();
Field<Type>::autoMap(m, oriented);
} }

View File

@ -286,8 +286,7 @@ public:
} }
//- Return dimensioned internal field reference //- Return dimensioned internal field reference
const DimensionedField<Type, surfaceMesh>& const DimensionedField<Type, surfaceMesh>& internalField() const
internalField() const
{ {
return internalField_; return internalField_;
} }

View File

@ -75,8 +75,7 @@ CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::DDt0Field
template<class Type> template<class Type>
template<class GeoField> template<class GeoField>
label CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>:: label CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::startTimeIndex() const
startTimeIndex() const
{ {
return startTimeIndex_; return startTimeIndex_;
} }
@ -84,8 +83,7 @@ startTimeIndex() const
template<class Type> template<class Type>
template<class GeoField> template<class GeoField>
GeoField& CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>:: GeoField& CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::operator()()
operator()()
{ {
return *this; return *this;
} }
@ -93,8 +91,10 @@ operator()()
template<class Type> template<class Type>
template<class GeoField> template<class GeoField>
void CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>:: void CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::operator=
operator=(const GeoField& gf) (
const GeoField& gf
)
{ {
GeoField::operator=(gf); GeoField::operator=(gf);
} }
@ -1259,6 +1259,7 @@ CrankNicolsonDdtScheme<Type>::fvcDdtPhiCorr
"ddtCorrDdt0(" + phi.name() + ')', "ddtCorrDdt0(" + phi.name() + ')',
phi.dimensions() phi.dimensions()
); );
dphidt0.setOriented();
dimensionedScalar rDtCoef = rDtCoef_(ddt0); dimensionedScalar rDtCoef = rDtCoef_(ddt0);
@ -1503,6 +1504,8 @@ tmp<surfaceScalarField> CrankNicolsonDdtScheme<Type>::meshPhi
dimVolume dimVolume
); );
meshPhi0.setOriented();
if (evaluate(meshPhi0)) if (evaluate(meshPhi0))
{ {
meshPhi0 = meshPhi0 =

View File

@ -115,6 +115,7 @@ gaussLaplacianScheme<Type, GType>::gammaSnGradCorr
*vf.dimensions()*mesh.deltaCoeffs().dimensions() *vf.dimensions()*mesh.deltaCoeffs().dimensions()
) )
); );
tgammaSnGradCorr.ref().oriented() = SfGammaCorr.oriented();
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++) for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
{ {

View File

@ -124,6 +124,7 @@ snGradScheme<Type>::snGrad
) )
); );
GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tsf.ref(); GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tsf.ref();
ssf.setOriented();
// set reference to difference factors array // set reference to difference factors array
const scalarField& deltaCoeffs = tdeltaCoeffs(); const scalarField& deltaCoeffs = tdeltaCoeffs();

View File

@ -892,6 +892,8 @@ flux() const
GeometricField<Type, fvsPatchField, surfaceMesh>& fieldFlux = GeometricField<Type, fvsPatchField, surfaceMesh>& fieldFlux =
tfieldFlux.ref(); tfieldFlux.ref();
fieldFlux.setOriented();
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{ {
fieldFlux.primitiveFieldRef().replace fieldFlux.primitiveFieldRef().replace

View File

@ -67,6 +67,8 @@ void Foam::fvMesh::makeSf() const
dimArea, dimArea,
faceAreas() faceAreas()
); );
SfPtr_->setOriented();
} }
@ -271,8 +273,7 @@ const Foam::volScalarField::Internal& Foam::fvMesh::V00() const
} }
Foam::tmp<Foam::volScalarField::Internal> Foam::tmp<Foam::volScalarField::Internal> Foam::fvMesh::Vsc() const
Foam::fvMesh::Vsc() const
{ {
if (moving() && time().subCycling()) if (moving() && time().subCycling())
{ {
@ -300,8 +301,7 @@ Foam::fvMesh::Vsc() const
} }
Foam::tmp<Foam::volScalarField::Internal> Foam::tmp<Foam::volScalarField::Internal> Foam::fvMesh::Vsc0() const
Foam::fvMesh::Vsc0() const
{ {
if (moving() && time().subCycling()) if (moving() && time().subCycling())
{ {
@ -400,6 +400,7 @@ Foam::tmp<Foam::surfaceVectorField> Foam::fvMesh::delta() const
) )
); );
surfaceVectorField& delta = tdelta.ref(); surfaceVectorField& delta = tdelta.ref();
delta.setOriented();
const volVectorField& C = this->C(); const volVectorField& C = this->C();
const labelUList& owner = this->owner(); 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]]; delta[facei] = C[neighbour[facei]] - C[owner[facei]];
} }
surfaceVectorField::Boundary& deltabf = surfaceVectorField::Boundary& deltabf = delta.boundaryFieldRef();
delta.boundaryFieldRef();
forAll(deltabf, patchi) forAll(deltabf, patchi)
{ {
@ -438,6 +438,8 @@ const Foam::surfaceScalarField& Foam::fvMesh::phi() const
(*phiPtr_) = dimensionedScalar("0", dimVolume/dimTime, 0.0); (*phiPtr_) = dimensionedScalar("0", dimVolume/dimTime, 0.0);
} }
phiPtr_->setOriented();
return *phiPtr_; return *phiPtr_;
} }

View File

@ -48,7 +48,7 @@ public:
void operator() void operator()
( (
Field<Type>& field, DimensionedField<Type, surfaceMesh>& field,
const MeshMapper& mapper const MeshMapper& mapper
) const; ) const;
}; };
@ -57,7 +57,7 @@ public:
template<class Type, class MeshMapper> template<class Type, class MeshMapper>
void MapInternalField<Type, MeshMapper, surfaceMesh>::operator() void MapInternalField<Type, MeshMapper, surfaceMesh>::operator()
( (
Field<Type>& field, DimensionedField<Type, surfaceMesh>& field,
const MeshMapper& mapper const MeshMapper& mapper
) const ) const
{ {
@ -69,16 +69,22 @@ void MapInternalField<Type, MeshMapper, surfaceMesh>::operator()
<< abort(FatalError); << 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 if (field.oriented()())
const labelList flipFaces = mapper.surfaceMap().flipFaceFlux().toc();
forAll(flipFaces, i)
{ {
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;
}
} }
} }
} }

View File

@ -48,7 +48,7 @@ public:
void operator() void operator()
( (
Field<Type>& field, DimensionedField<Type, volMesh>& field,
const MeshMapper& mapper const MeshMapper& mapper
) const; ) const;
}; };
@ -57,7 +57,7 @@ public:
template<class Type, class MeshMapper> template<class Type, class MeshMapper>
void MapInternalField<Type, MeshMapper, volMesh>::operator() void MapInternalField<Type, MeshMapper, volMesh>::operator()
( (
Field<Type>& field, DimensionedField<Type, volMesh>& field,
const MeshMapper& mapper const MeshMapper& mapper
) const ) const
{ {

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -73,8 +73,7 @@ Foam::surfaceInterpolation::~surfaceInterpolation()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::surfaceScalarField& const Foam::surfaceScalarField& Foam::surfaceInterpolation::weights() const
Foam::surfaceInterpolation::weights() const
{ {
if (!weights_) if (!weights_)
{ {
@ -85,8 +84,7 @@ Foam::surfaceInterpolation::weights() const
} }
const Foam::surfaceScalarField& const Foam::surfaceScalarField& Foam::surfaceInterpolation::deltaCoeffs() const
Foam::surfaceInterpolation::deltaCoeffs() const
{ {
if (!deltaCoeffs_) if (!deltaCoeffs_)
{ {
@ -156,11 +154,12 @@ void Foam::surfaceInterpolation::makeWeights() const
dimless dimless
); );
surfaceScalarField& weights = *weights_; surfaceScalarField& weights = *weights_;
weights.setOriented();
// Set local references to mesh data // Set local references to mesh data
// (note that we should not use fvMesh sliced fields at this point yet // Note that we should not use fvMesh sliced fields at this point yet
// since this causes a loop when generating weighting factors in // since this causes a loop when generating weighting factors in
// coupledFvPatchField evaluation phase) // coupledFvPatchField evaluation phase
const labelUList& owner = mesh_.owner(); const labelUList& owner = mesh_.owner();
const labelUList& neighbour = mesh_.neighbour(); const labelUList& neighbour = mesh_.neighbour();
@ -174,7 +173,7 @@ void Foam::surfaceInterpolation::makeWeights() const
forAll(owner, facei) forAll(owner, facei)
{ {
// Note: mag in the dot-product. // 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 // 90 deg and the dot-product will be positive. For invalid
// meshes (d & s <= 0), this will stabilise the calculation // meshes (d & s <= 0), this will stabilise the calculation
// but the result will be poor. // but the result will be poor.
@ -183,8 +182,7 @@ void Foam::surfaceInterpolation::makeWeights() const
w[facei] = SfdNei/(SfdOwn + SfdNei); w[facei] = SfdNei/(SfdOwn + SfdNei);
} }
surfaceScalarField::Boundary& wBf = surfaceScalarField::Boundary& wBf = weights.boundaryFieldRef();
weights.boundaryFieldRef();
forAll(mesh_.boundary(), patchi) forAll(mesh_.boundary(), patchi)
{ {
@ -228,6 +226,7 @@ void Foam::surfaceInterpolation::makeDeltaCoeffs() const
dimless/dimLength dimless/dimLength
); );
surfaceScalarField& deltaCoeffs = *deltaCoeffs_; surfaceScalarField& deltaCoeffs = *deltaCoeffs_;
deltaCoeffs.setOriented();
// Set local references to mesh data // Set local references to mesh data
@ -278,6 +277,7 @@ void Foam::surfaceInterpolation::makeNonOrthDeltaCoeffs() const
dimless/dimLength dimless/dimLength
); );
surfaceScalarField& nonOrthDeltaCoeffs = *nonOrthDeltaCoeffs_; surfaceScalarField& nonOrthDeltaCoeffs = *nonOrthDeltaCoeffs_;
nonOrthDeltaCoeffs.setOriented();
// Set local references to mesh data // Set local references to mesh data
@ -342,6 +342,7 @@ void Foam::surfaceInterpolation::makeNonOrthCorrectionVectors() const
dimless dimless
); );
surfaceVectorField& corrVecs = *nonOrthCorrectionVectors_; surfaceVectorField& corrVecs = *nonOrthCorrectionVectors_;
corrVecs.setOriented();
// Set local references to mesh data // Set local references to mesh data
const volVectorField& C = mesh_.C(); const volVectorField& C = mesh_.C();

View File

@ -311,6 +311,8 @@ Foam::surfaceInterpolationScheme<Type>::dotInterpolate
tlambdas.clear(); tlambdas.clear();
// tsf.ref().oriented() = Sf.oriented();
return tsf; return tsf;
} }
@ -363,6 +365,8 @@ Foam::surfaceInterpolationScheme<Type>::dotInterpolate
> >
> tsf = dotInterpolate(Sf, vf, weights(vf)); > tsf = dotInterpolate(Sf, vf, weights(vf));
tsf.ref().oriented() = Sf.oriented();
if (corrected()) if (corrected())
{ {
tsf.ref() += Sf & correction(vf); tsf.ref() += Sf & correction(vf);
@ -397,6 +401,7 @@ Foam::surfaceInterpolationScheme<Type>::dotInterpolate
surfaceMesh surfaceMesh
> >
> tSfDotinterpVf = dotInterpolate(Sf, tvf()); > tSfDotinterpVf = dotInterpolate(Sf, tvf());
tvf.clear(); tvf.clear();
return tSfDotinterpVf; return tSfDotinterpVf;
} }

View File

@ -154,7 +154,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
DynamicList<label> faceIds(fZone.size()); DynamicList<label> faceIds(fZone.size());
DynamicList<label> facePatchIds(fZone.size()); DynamicList<label> facePatchIds(fZone.size());
DynamicList<bool> faceFlip(fZone.size()); DynamicList<bool> faceFlip(fZone.size());
forAll(fZone, i) forAll(fZone, i)
{ {
@ -459,7 +459,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea() const
} }
else else
{ {
totalArea = gSum(filterField(mesh_.magSf(), false)); totalArea = gSum(filterField(mesh_.magSf()));
} }
return totalArea; return totalArea;
@ -479,10 +479,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::needsSf() const
case opAverage: case opAverage:
case opMin: case opMin:
case opMax: case opMax:
{
return false; return false;
}
default: default:
{
return true; return true;
}
} }
} }
@ -496,10 +499,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::needsWeight() const
case opWeightedAverage: case opWeightedAverage:
case opWeightedAreaAverage: case opWeightedAreaAverage:
case opWeightedAreaIntegrate: case opWeightedAreaIntegrate:
{
return true; return true;
}
default: default:
{
return false; return false;
}
} }
} }
@ -596,7 +602,6 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
weightFieldName_ = "none"; weightFieldName_ = "none";
orientWeightField_ = false;
if (needsWeight()) if (needsWeight())
{ {
if (dict.readIfPresent("weightField", weightFieldName_)) if (dict.readIfPresent("weightField", weightFieldName_))
@ -610,41 +615,21 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
Info<< " weight field = " << weightFieldName_ << nl; 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; List<word> orientedFields;
orientedFieldsStart_ = labelMax;
if (dict.readIfPresent("orientedFields", orientedFields)) 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); fields_.append(orientedFields);
} }
surfaceWriterPtr_.clear(); surfaceWriterPtr_.clear();
if (writeFields_) if (writeFields_)
{ {
@ -854,8 +839,6 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
[dict.lookupOrDefault<word>("postOperation", "none")] [dict.lookupOrDefault<word>("postOperation", "none")]
), ),
weightFieldName_("none"), weightFieldName_("none"),
orientWeightField_(false),
orientedFieldsStart_(labelMax),
writeArea_(dict.lookupOrDefault("writeArea", false)), writeArea_(dict.lookupOrDefault("writeArea", false)),
nFaces_(0), nFaces_(0),
faceId_(), faceId_(),
@ -883,8 +866,6 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
[dict.lookupOrDefault<word>("postOperation", "none")] [dict.lookupOrDefault<word>("postOperation", "none")]
), ),
weightFieldName_("none"), weightFieldName_("none"),
orientWeightField_(false),
orientedFieldsStart_(labelMax),
writeArea_(dict.lookupOrDefault("writeArea", false)), writeArea_(dict.lookupOrDefault("writeArea", false)),
nFaces_(0), nFaces_(0),
faceId_(), faceId_(),
@ -959,7 +940,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
} }
else else
{ {
Sf = filterField(mesh_.Sf(), true); // Oriented Sf Sf = filterField(mesh_.Sf());
} }
} }
@ -988,12 +969,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
{ {
scalarField weightField scalarField weightField
( (
getFieldValues<scalar> getFieldValues<scalar>(weightFieldName_, true)
(
weightFieldName_,
true,
orientWeightField_
)
); );
// Process the fields // Process the fields
@ -1003,12 +979,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
{ {
vectorField weightField vectorField weightField
( (
getFieldValues<vector> getFieldValues<vector>(weightFieldName_, true)
(
weightFieldName_,
true,
orientWeightField_
)
); );
// Process the fields // Process the fields

View File

@ -91,7 +91,6 @@ Usage
orientedWeightField | name of oriented field to apply weighting | no | orientedWeightField | name of oriented field to apply weighting | no |
scaleFactor | scale factor | no | 1 scaleFactor | scale factor | no | 1
fields | list of fields to operate on | yes | fields | list of fields to operate on | yes |
orientedFields | list of oriented fields to operate on | no |
\endtable \endtable
Where \c regionType is defined by Where \c regionType is defined by
@ -130,8 +129,6 @@ Note
- faces on empty patches get ignored - faces on empty patches get ignored
- if the field is a volField the \c faceZone can only consist of boundary - if the field is a volField the \c faceZone can only consist of boundary
faces 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: - Using \c surface:
- The keyword %subRegion should not be used to select surfaces. - The keyword %subRegion should not be used to select surfaces.
Specify instead the regionType 'surface' and provide the surface name. Specify instead the regionType 'surface' and provide the surface name.
@ -285,12 +282,6 @@ protected:
//- Weight field name - optional //- Weight field name - optional
word weightFieldName_; 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 //- Total area of the surfaceFieldValue
scalar totalArea_; scalar totalArea_;
@ -353,8 +344,7 @@ protected:
tmp<Field<Type>> getFieldValues tmp<Field<Type>> getFieldValues
( (
const word& fieldName, const word& fieldName,
const bool mustGet = false, const bool mustGet = false
const bool applyOrientation = false
) const; ) const;
//- Apply the 'operation' to the values. Operation must preserve Type. //- Apply the 'operation' to the values. Operation must preserve Type.
@ -380,16 +370,14 @@ protected:
template<class Type> template<class Type>
tmp<Field<Type>> filterField tmp<Field<Type>> filterField
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>& field, const GeometricField<Type, fvsPatchField, surfaceMesh>& field
const bool applyOrientation
) const; ) const;
//- Filter a volume field according to faceIds //- Filter a volume field according to faceIds
template<class Type> template<class Type>
tmp<Field<Type>> filterField tmp<Field<Type>> filterField
( (
const GeometricField<Type, fvPatchField, volMesh>& field, const GeometricField<Type, fvPatchField, volMesh>& field
const bool applyOrientation
) const; ) const;
//- Weighting factor //- Weighting factor
@ -424,7 +412,6 @@ protected:
const word& fieldName, const word& fieldName,
const vectorField& Sf, const vectorField& Sf,
const Field<WeightType>& weightField, const Field<WeightType>& weightField,
const bool orient,
const meshedSurf& surfToWrite const meshedSurf& surfToWrite
); );

View File

@ -57,8 +57,7 @@ Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
( (
const word& fieldName, const word& fieldName,
const bool mustGet, const bool mustGet
const bool applyOrientation
) const ) const
{ {
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf; typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
@ -71,7 +70,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
} }
else if (regionType_ != stSampledSurface && foundObject<sf>(fieldName)) else if (regionType_ != stSampledSurface && foundObject<sf>(fieldName))
{ {
return filterField(lookupObject<sf>(fieldName), applyOrientation); return filterField(lookupObject<sf>(fieldName));
} }
else if (foundObject<vf>(fieldName)) else if (foundObject<vf>(fieldName))
{ {
@ -112,7 +111,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
} }
else else
{ {
return filterField(fld, applyOrientation); return filterField(fld);
} }
} }
@ -140,7 +139,9 @@ processSameTypeValues
switch (operation_) switch (operation_)
{ {
case opNone: case opNone:
{
break; break;
}
case opSum: case opSum:
{ {
result = gSum(values); result = gSum(values);
@ -258,8 +259,10 @@ processSameTypeValues
case opAreaNormalAverage: case opAreaNormalAverage:
case opAreaNormalIntegrate: case opAreaNormalIntegrate:
// handled in specializations only {
// Handled in specializations only
break; break;
}
} }
return result; return result;
@ -302,30 +305,17 @@ Foam::label Foam::functionObjects::fieldValues::surfaceFieldValue::writeAll
forAll(fields_, i) forAll(fields_, i)
{ {
const word& fieldName = fields_[i]; const word& fieldName = fields_[i];
const bool orient = (i >= orientedFieldsStart_);
if if
( (
writeValues<scalar> writeValues<scalar>(fieldName, Sf, weightField, surfToWrite)
( || writeValues<vector>(fieldName, Sf, weightField, surfToWrite)
fieldName, Sf, weightField, orient, surfToWrite
)
|| writeValues<vector>
(
fieldName, Sf, weightField, orient, surfToWrite
)
|| writeValues<sphericalTensor> || writeValues<sphericalTensor>
( (
fieldName, Sf, weightField, orient, surfToWrite fieldName, Sf, weightField, surfToWrite
)
|| writeValues<symmTensor>
(
fieldName, Sf, weightField, orient, surfToWrite
)
|| writeValues<tensor>
(
fieldName, Sf, weightField, orient, surfToWrite
) )
|| writeValues<symmTensor>(fieldName, Sf, weightField, surfToWrite)
|| writeValues<tensor>(fieldName, Sf, weightField, surfToWrite)
) )
{ {
++nProcessed; ++nProcessed;
@ -349,7 +339,6 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
const word& fieldName, const word& fieldName,
const vectorField& Sf, const vectorField& Sf,
const Field<WeightType>& weightField, const Field<WeightType>& weightField,
const bool orient,
const meshedSurf& surfToWrite const meshedSurf& surfToWrite
) )
{ {
@ -357,7 +346,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
if (ok) if (ok)
{ {
Field<Type> values(getFieldValues<Type>(fieldName, true, orient)); Field<Type> values(getFieldValues<Type>(fieldName, true));
// Write raw values on surface if specified // Write raw values on surface if specified
if (surfaceWriterPtr_.valid()) if (surfaceWriterPtr_.valid())
@ -389,7 +378,9 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
switch (postOperation_) switch (postOperation_)
{ {
case postOpNone: case postOpNone:
{
break; break;
}
case postOpSqrt: case postOpSqrt:
{ {
// sqrt: component-wise - doesn't change the type // sqrt: component-wise - doesn't change the type
@ -438,8 +429,7 @@ template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::surfaceFieldValue::filterField Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
( (
const GeometricField<Type, fvPatchField, volMesh>& field, const GeometricField<Type, fvPatchField, volMesh>& field
const bool applyOrientation
) const ) const
{ {
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size())); tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
@ -464,16 +454,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
} }
} }
if (applyOrientation) // No need to flip values - all boundary faces point outwards
{
forAll(values, i)
{
if (faceFlip_[i])
{
values[i] *= -1;
}
}
}
return tvalues; return tvalues;
} }
@ -483,8 +464,7 @@ template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::surfaceFieldValue::filterField Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>& field, const GeometricField<Type, fvsPatchField, surfaceMesh>& field
const bool applyOrientation
) const ) const
{ {
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size())); 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) forAll(values, i)
{ {

View File

@ -107,7 +107,7 @@ processorSurfacePatchFieldDecomposer
weights_[i].setSize(1); weights_[i].setSize(1);
addressing_[i][0] = mag(addressingSlice[i]) - 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), faceAddressing_(faceAddressing),
cellAddressing_(cellAddressing), cellAddressing_(cellAddressing),
boundaryAddressing_(boundaryAddressing), boundaryAddressing_(boundaryAddressing),
patchFieldDecomposerPtrs_ patchFieldDecomposerPtrs_(procMesh_.boundary().size()),
( processorVolPatchFieldDecomposerPtrs_(procMesh_.boundary().size()),
procMesh_.boundary().size(), processorSurfacePatchFieldDecomposerPtrs_(procMesh_.boundary().size()),
static_cast<patchFieldDecomposer*>(nullptr) faceSign_(procMesh_.boundary().size())
),
processorVolPatchFieldDecomposerPtrs_
(
procMesh_.boundary().size(),
static_cast<processorVolPatchFieldDecomposer*>(nullptr)
),
processorSurfacePatchFieldDecomposerPtrs_
(
procMesh_.boundary().size(),
static_cast<processorSurfacePatchFieldDecomposer*>(nullptr)
)
{ {
forAll(boundaryAddressing_, patchi) forAll(boundaryAddressing_, patchi)
{ {
const fvPatch& fvp = procMesh_.boundary()[patchi];
if if
( (
boundaryAddressing_[patchi] >= 0 boundaryAddressing_[patchi] >= 0
&& !isA<processorLduInterface>(procMesh.boundary()[patchi]) && !isA<processorLduInterface>(procMesh.boundary()[patchi])
) )
{ {
patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer patchFieldDecomposerPtrs_.set
( (
procMesh_.boundary()[patchi].patchSlice(faceAddressing_), patchi,
completeMesh_.boundaryMesh() new patchFieldDecomposer
[ (
boundaryAddressing_[patchi] fvp.patchSlice(faceAddressing_),
].start() completeMesh_.boundaryMesh()
[
boundaryAddressing_[patchi]
].start()
)
); );
} }
else else
{ {
processorVolPatchFieldDecomposerPtrs_[patchi] = processorVolPatchFieldDecomposerPtrs_.set
(
patchi,
new processorVolPatchFieldDecomposer new processorVolPatchFieldDecomposer
( (
completeMesh_, completeMesh_,
procMesh_.boundary()[patchi].patchSlice(faceAddressing_) fvp.patchSlice(faceAddressing_)
); )
);
processorSurfacePatchFieldDecomposerPtrs_[patchi] = processorSurfacePatchFieldDecomposerPtrs_.set
(
patchi,
new processorSurfacePatchFieldDecomposer new processorSurfacePatchFieldDecomposer
( (
static_cast<const labelUList&> static_cast<const labelUList&>
( (
procMesh_.boundary()[patchi].patchSlice fvp.patchSlice
( (
faceAddressing_ 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 * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fvFieldDecomposer::~fvFieldDecomposer() 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];
}
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -215,15 +215,18 @@ private:
const labelList& boundaryAddressing_; const labelList& boundaryAddressing_;
//- List of patch field decomposers //- List of patch field decomposers
List<patchFieldDecomposer*> patchFieldDecomposerPtrs_; PtrList<patchFieldDecomposer> patchFieldDecomposerPtrs_;
List<processorVolPatchFieldDecomposer*> PtrList<processorVolPatchFieldDecomposer>
processorVolPatchFieldDecomposerPtrs_; processorVolPatchFieldDecomposerPtrs_;
List<processorSurfacePatchFieldDecomposer*> PtrList<processorSurfacePatchFieldDecomposer>
processorSurfacePatchFieldDecomposerPtrs_; processorSurfacePatchFieldDecomposerPtrs_;
PtrList<scalarField> faceSign_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct

View File

@ -40,6 +40,8 @@ Foam::fvFieldDecomposer::decomposeField
const bool allowUnknownPatchFields const bool allowUnknownPatchFields
) const ) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
// 1. Create the complete field with dummy patch fields // 1. Create the complete field with dummy patch fields
PtrList<fvPatchField<Type>> patchFields(boundaryAddressing_.size()); PtrList<fvPatchField<Type>> patchFields(boundaryAddressing_.size());
@ -58,9 +60,9 @@ Foam::fvFieldDecomposer::decomposeField
} }
// Create the field for the processor // Create the field for the processor
tmp<GeometricField<Type, fvPatchField, volMesh>> tresF tmp<VolFieldType> tresF
( (
new GeometricField<Type, fvPatchField, volMesh> new VolFieldType
( (
IOobject IOobject
( (
@ -76,18 +78,18 @@ Foam::fvFieldDecomposer::decomposeField
patchFields 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 // 2. Change the fvPatchFields to the correct type using a mapper
// constructor (with reference to the now correct internal field) // constructor (with reference to the now correct internal field)
typename GeometricField<Type, fvPatchField, volMesh>:: typename VolFieldType::Boundary& bf = resF.boundaryFieldRef();
Boundary& bf = resF.boundaryFieldRef();
forAll(bf, patchi) forAll(bf, patchi)
{ {
if (patchFieldDecomposerPtrs_[patchi]) if (patchFieldDecomposerPtrs_.set(patchi))
{ {
bf.set bf.set
( (
@ -97,7 +99,7 @@ Foam::fvFieldDecomposer::decomposeField
field.boundaryField()[boundaryAddressing_[patchi]], field.boundaryField()[boundaryAddressing_[patchi]],
procMesh_.boundary()[patchi], procMesh_.boundary()[patchi],
resF(), resF(),
*patchFieldDecomposerPtrs_[patchi] patchFieldDecomposerPtrs_[patchi]
) )
); );
} }
@ -113,7 +115,7 @@ Foam::fvFieldDecomposer::decomposeField
Field<Type> Field<Type>
( (
field.primitiveField(), field.primitiveField(),
*processorVolPatchFieldDecomposerPtrs_[patchi] processorVolPatchFieldDecomposerPtrs_[patchi]
) )
) )
); );
@ -130,7 +132,7 @@ Foam::fvFieldDecomposer::decomposeField
Field<Type> Field<Type>
( (
field.primitiveField(), field.primitiveField(),
*processorVolPatchFieldDecomposerPtrs_[patchi] processorVolPatchFieldDecomposerPtrs_[patchi]
) )
) )
); );
@ -166,6 +168,8 @@ Foam::fvFieldDecomposer::decomposeField
const GeometricField<Type, fvsPatchField, surfaceMesh>& field const GeometricField<Type, fvsPatchField, surfaceMesh>& field
) const ) const
{ {
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
labelList mapAddr labelList mapAddr
( (
labelList::subList labelList::subList
@ -200,7 +204,7 @@ Foam::fvFieldDecomposer::decomposeField
forAll(field.boundaryField(), patchi) 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(); 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 IOobject
( (
@ -246,18 +250,17 @@ Foam::fvFieldDecomposer::decomposeField
patchFields 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 // 2. Change the fvsPatchFields to the correct type using a mapper
// constructor (with reference to the now correct internal field) // constructor (with reference to the now correct internal field)
typename GeometricField<Type, fvsPatchField, surfaceMesh>:: typename SurfaceFieldType::Boundary& bf = resF.boundaryFieldRef();
Boundary& bf = resF.boundaryFieldRef();
forAll(boundaryAddressing_, patchi) forAll(boundaryAddressing_, patchi)
{ {
if (patchFieldDecomposerPtrs_[patchi]) if (patchFieldDecomposerPtrs_.set(patchi))
{ {
bf.set bf.set
( (
@ -267,7 +270,7 @@ Foam::fvFieldDecomposer::decomposeField
field.boundaryField()[boundaryAddressing_[patchi]], field.boundaryField()[boundaryAddressing_[patchi]],
procMesh_.boundary()[patchi], procMesh_.boundary()[patchi],
resF(), resF(),
*patchFieldDecomposerPtrs_[patchi] patchFieldDecomposerPtrs_[patchi]
) )
); );
} }
@ -283,10 +286,15 @@ Foam::fvFieldDecomposer::decomposeField
Field<Type> Field<Type>
( (
allFaceField, allFaceField,
*processorSurfacePatchFieldDecomposerPtrs_[patchi] processorSurfacePatchFieldDecomposerPtrs_[patchi]
) )
) )
); );
if (resF.oriented()())
{
bf[patchi] *= faceSign_[patchi];
}
} }
else if (isA<processorFvPatch>(procMesh_.boundary()[patchi])) else if (isA<processorFvPatch>(procMesh_.boundary()[patchi]))
{ {
@ -300,10 +308,15 @@ Foam::fvFieldDecomposer::decomposeField
Field<Type> Field<Type>
( (
allFaceField, allFaceField,
*processorSurfacePatchFieldDecomposerPtrs_[patchi] processorSurfacePatchFieldDecomposerPtrs_[patchi]
) )
) )
); );
if (resF.oriented()())
{
bf[patchi] *= faceSign_[patchi];
}
} }
else else
{ {

View File

@ -56,7 +56,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeInternalField
); );
} }
return tmp<DimensionedField<Type, volMesh>> tmp<DimensionedField<Type, volMesh>> tfield
( (
new DimensionedField<Type, volMesh> new DimensionedField<Type, volMesh>
( (
@ -66,6 +66,10 @@ Foam::fvFieldReconstructor::reconstructFvVolumeInternalField
internalField internalField
) )
); );
tfield.ref().oriented() = procFields[0].oriented();
return tfield;
} }
@ -282,7 +286,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
// Now construct and write the field // Now construct and write the field
// setting the internalField and patchFields // setting the internalField and patchFields
return tmp<GeometricField<Type, fvPatchField, volMesh>> tmp<GeometricField<Type, fvPatchField, volMesh>> tfield
( (
new GeometricField<Type, fvPatchField, volMesh> new GeometricField<Type, fvPatchField, volMesh>
( (
@ -293,6 +297,10 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
patchFields patchFields
) )
); );
tfield.ref().oriented() = procFields[0].oriented();
return tfield;
} }
@ -523,7 +531,7 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField
// Now construct and write the field // Now construct and write the field
// setting the internalField and patchFields // setting the internalField and patchFields
return tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tfield
( (
new GeometricField<Type, fvsPatchField, surfaceMesh> new GeometricField<Type, fvsPatchField, surfaceMesh>
( (
@ -534,6 +542,10 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField
patchFields patchFields
) )
); );
tfield.ref().oriented() = procFields[0].oriented();
return tfield;
} }