Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Andrew Heather
2017-10-13 14:03:13 +01:00
13 changed files with 152 additions and 116 deletions

View File

@ -15,12 +15,16 @@
) )
: -dpdt : -dpdt
) )
- fvm::laplacian(alphaEff, he)
== ==
radiation->Sh(thermo, he) radiation->Sh(thermo, he)
+ fvOptions(rho, he) + fvOptions(rho, he)
); );
if (turbulence.valid())
{
EEqn -= fvm::laplacian(turbulence->alphaEff(), he);
}
EEqn.relax(); EEqn.relax();
fvOptions.constrain(EEqn); fvOptions.constrain(EEqn);

View File

@ -35,7 +35,31 @@ volVectorField U
#include "compressibleCreatePhi.H" #include "compressibleCreatePhi.H"
#include "setAlphaEff.H" autoPtr<compressible::turbulenceModel> turbulence;
IOobject turbulencePropertiesHeader
(
"turbulenceProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
);
if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(false))
{
Info<< "Creating turbulence model\n" << endl;
turbulence =
compressible::turbulenceModel::New
(
rho,
U,
phi,
thermo
);
}
#include "createDpdt.H" #include "createDpdt.H"

View File

@ -1,47 +0,0 @@
Info<< "Creating turbulence model\n" << endl;
tmp<volScalarField> talphaEff;
IOobject turbulencePropertiesHeader
(
"turbulenceProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
);
if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(true))
{
autoPtr<compressible::turbulenceModel> turbulence
(
compressible::turbulenceModel::New
(
rho,
U,
phi,
thermo
)
);
talphaEff = turbulence->alphaEff();
}
else
{
talphaEff = tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"alphaEff",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("0", dimMass/dimLength/dimTime, 0.0)
)
);
}

View File

@ -54,8 +54,6 @@ int main(int argc, char *argv[])
#include "createFields.H" #include "createFields.H"
#include "createFvOptions.H" #include "createFvOptions.H"
const volScalarField& alphaEff = talphaEff();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nEvolving thermodynamics\n" << endl; Info<< "\nEvolving thermodynamics\n" << endl;

View File

@ -373,7 +373,8 @@ kOmegaSSTLM<BasicTurbulenceModel>::kOmegaSSTLM
alphaRhoPhi, alphaRhoPhi,
phi, phi,
transport, transport,
propertiesName propertiesName,
typeName
), ),
ca1_ ca1_
@ -477,7 +478,12 @@ kOmegaSSTLM<BasicTurbulenceModel>::kOmegaSSTLM
this->mesh_, this->mesh_,
dimensionedScalar("0", dimless, 0) dimensionedScalar("0", dimless, 0)
) )
{} {
if (type == typeName)
{
this->printCoeffs(type);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -245,7 +245,7 @@ Foam::vtk::patchWriter::patchWriter
nFaces_(0) nFaces_(0)
{ {
outputOptions opts(outOpts); outputOptions opts(outOpts);
opts.append(false); // No append opts.append(false); // No append supported
os_.open((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str()); os_.open((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
format_ = opts.newFormatter(os_); format_ = opts.newFormatter(os_);

View File

@ -193,7 +193,7 @@ Foam::vtk::surfaceMeshWriter::surfaceMeshWriter
os_() os_()
{ {
outputOptions opts(outOpts); outputOptions opts(outOpts);
opts.legacy(true); // No append supported opts.append(false); // No append supported
os_.open((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str()); os_.open((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
format_ = opts.newFormatter(os_); format_ = opts.newFormatter(os_);

View File

@ -172,6 +172,8 @@ bool Foam::functionObjects::DESModelRegions::write()
<< " writing field " << DESModelRegions.name() << nl << " writing field " << DESModelRegions.name() << nl
<< endl; << endl;
DESModelRegions.write();
return true; return true;
} }

View File

@ -41,7 +41,7 @@ void Foam::vtk::writeCellSetFaces
) )
{ {
outputOptions opts(outOpts); outputOptions opts(outOpts);
opts.legacy(true); // Legacy only, no append opts.legacy(true); // Legacy only, no xml, no append
const bool legacy_(opts.legacy()); const bool legacy_(opts.legacy());

View File

@ -41,7 +41,7 @@ void Foam::vtk::writeFaceSet
) )
{ {
outputOptions opts(outOpts); outputOptions opts(outOpts);
opts.legacy(true); // Legacy only, no append opts.legacy(true); // Legacy only, no xml, no append
const bool legacy_(opts.legacy()); const bool legacy_(opts.legacy());

View File

@ -40,7 +40,7 @@ void Foam::vtk::writePointSet
) )
{ {
outputOptions opts(outOpts); outputOptions opts(outOpts);
opts.legacy(true); // Legacy only, no append opts.legacy(true); // Legacy only, no xml, no append
const bool legacy_(opts.legacy()); const bool legacy_(opts.legacy());

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-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 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.
@ -99,7 +99,7 @@ void Foam::multiLevelDecomp::subsetGlobalCellCells
forAll(cCells, i) forAll(cCells, i)
{ {
// Get locally-compact cell index of neighbouring cell // Get locally-compact cell index of neighbouring cell
label nbrCelli = oldToNew[cCells[i]]; const label nbrCelli = oldToNew[cCells[i]];
if (nbrCelli == -1) if (nbrCelli == -1)
{ {
cutConnections[allDist[cCells[i]]]++; cutConnections[allDist[cCells[i]]]++;
@ -109,10 +109,10 @@ void Foam::multiLevelDecomp::subsetGlobalCellCells
// Reconvert local cell index into global one // Reconvert local cell index into global one
// Get original neighbour // Get original neighbour
label celli = set[subCelli]; const label celli = set[subCelli];
label oldNbrCelli = cellCells[celli][i]; const label oldNbrCelli = cellCells[celli][i];
// Get processor from original neighbour // Get processor from original neighbour
label proci = globalCells.whichProcID(oldNbrCelli); const label proci = globalCells.whichProcID(oldNbrCelli);
// Convert into global compact numbering // Convert into global compact numbering
cCells[newI++] = globalSubCells.toGlobal(proci, nbrCelli); cCells[newI++] = globalSubCells.toGlobal(proci, nbrCelli);
} }
@ -127,15 +127,16 @@ void Foam::multiLevelDecomp::decompose
const labelListList& pointPoints, const labelListList& pointPoints,
const pointField& points, const pointField& points,
const scalarField& pointWeights, const scalarField& pointWeights,
const labelList& pointMap, // map back to original points const labelUList& pointMap, // map back to original points
const label levelI, const label currLevel,
const label leafOffset,
labelField& finalDecomp labelList& finalDecomp
) )
{ {
labelList dist labelList dist
( (
methods_[levelI].decompose methods_[currLevel].decompose
( (
pointPoints, pointPoints,
points, points,
@ -143,30 +144,62 @@ void Foam::multiLevelDecomp::decompose
) )
); );
forAll(pointMap, i) // The next recursion level
const label nextLevel = currLevel+1;
// Number of domains at this current level
const label nCurrDomains = methods_[currLevel].nDomains();
// Calculate the domain remapping.
// The decompose() method delivers a distribution of [0..nDomains-1]
// which we map to the final location according to the decomposition
// leaf we are on.
labelList domainLookup(nCurrDomains);
{ {
label orig = pointMap[i]; label sizes = 1; // Cumulative number of domains
finalDecomp[orig] += dist[i]; for (label i = 0; i <= currLevel; ++i)
{
sizes *= methods_[i].nDomains();
} }
if (levelI != methods_.size()-1) // Distribution of domains at this level
sizes = this->nDomains() / sizes;
forAll(domainLookup, i)
{
domainLookup[i] = i * sizes + leafOffset;
}
}
if (debug)
{
Info<< "Distribute at level " << currLevel
<< " to domains" << nl
<< flatOutput(domainLookup) << endl;
}
// Extract processor+local index from point-point addressing
forAll(pointMap, i)
{
const label orig = pointMap[i];
finalDecomp[orig] = domainLookup[dist[i]];
}
if (nextLevel < methods_.size())
{ {
// Recurse // Recurse
// Determine points per domain // Determine points per domain
label n = methods_[levelI].nDomains(); labelListList domainToPoints(invertOneToMany(nCurrDomains, dist));
labelListList domainToPoints(invertOneToMany(n, dist));
// 'Make space' for new levels of decomposition
finalDecomp *= methods_[levelI+1].nDomains();
// Extract processor+local index from point-point addressing // Extract processor+local index from point-point addressing
if (debug && Pstream::master()) if (debug && Pstream::master())
{ {
Pout<< "Decomposition at level " << levelI << " :" << endl; Pout<< "Decomposition at level " << currLevel << " :" << endl;
} }
for (label domainI = 0; domainI < n; domainI++) for (label domainI = 0; domainI < nCurrDomains; domainI++)
{ {
// Extract elements for current domain // Extract elements for current domain
const labelList domainPoints(findIndices(dist, domainI)); const labelList domainPoints(findIndices(dist, domainI));
@ -180,7 +213,7 @@ void Foam::multiLevelDecomp::decompose
labelList nOutsideConnections; labelList nOutsideConnections;
subsetGlobalCellCells subsetGlobalCellCells
( (
n, nCurrDomains,
domainI, domainI,
dist, dist,
@ -196,12 +229,12 @@ void Foam::multiLevelDecomp::decompose
Pstream::listCombineScatter(nOutsideConnections); Pstream::listCombineScatter(nOutsideConnections);
label nPatches = 0; label nPatches = 0;
label nFaces = 0; label nFaces = 0;
forAll(nOutsideConnections, i) for (const label nConnect : nOutsideConnections)
{ {
if (nOutsideConnections[i] > 0) if (nConnect > 0)
{ {
nPatches++; ++nPatches;
nFaces += nOutsideConnections[i]; nFaces += nConnect;
} }
} }
@ -224,7 +257,8 @@ void Foam::multiLevelDecomp::decompose
subPoints, subPoints,
subWeights, subWeights,
subPointMap, subPointMap,
levelI+1, nextLevel,
domainLookup[domainI], // The offset for this level and leaf
finalDecomp finalDecomp
); );
@ -238,24 +272,30 @@ void Foam::multiLevelDecomp::decompose
if (debug) if (debug)
{ {
// Do straight decompose of two levels // Do straight decompose of two levels
label nNext = methods_[levelI+1].nDomains(); const label nNext = methods_[nextLevel].nDomains();
label nTotal = n*nNext; const label nTotal = nCurrDomains * nNext;
// Retrieve original level0 dictionary and modify number of domains // Get original level0 dictionary and modify numberOfSubdomains
dictionary::const_iterator iter = dictionary level0Dict;
decompositionDict_.optionalSubDict(typeName + "Coeffs").begin(); forAllConstIter(dictionary, methodsDict_, iter)
dictionary myDict = iter().dict(); {
myDict.set("numberOfSubdomains", nTotal); if (iter().isDict())
{
level0Dict = iter().dict();
break;
}
}
level0Dict.set("numberOfSubdomains", nTotal);
if (debug && Pstream::master()) if (debug && Pstream::master())
{ {
Pout<< "Reference decomposition with " << myDict << " :" Pout<< "Reference decomposition with " << level0Dict << " :"
<< endl; << endl;
} }
autoPtr<decompositionMethod> method0 = decompositionMethod::New autoPtr<decompositionMethod> method0 = decompositionMethod::New
( (
myDict level0Dict
); );
labelList dist labelList dist
( (
@ -267,12 +307,12 @@ void Foam::multiLevelDecomp::decompose
) )
); );
for (label blockI = 0; blockI < n; blockI++) for (label blockI = 0; blockI < nCurrDomains; blockI++)
{ {
// Count the number inbetween blocks of nNext size // Count the number inbetween blocks of nNext size
label nPoints = 0; label nPoints = 0;
labelList nOutsideConnections(n, 0); labelList nOutsideConnections(nCurrDomains, 0);
forAll(pointPoints, pointi) forAll(pointPoints, pointi)
{ {
if ((dist[pointi] / nNext) == blockI) if ((dist[pointi] / nNext) == blockI)
@ -283,7 +323,7 @@ void Foam::multiLevelDecomp::decompose
forAll(pPoints, i) forAll(pPoints, i)
{ {
label distBlockI = dist[pPoints[i]] / nNext; const label distBlockI = dist[pPoints[i]] / nNext;
if (distBlockI != blockI) if (distBlockI != blockI)
{ {
nOutsideConnections[distBlockI]++; nOutsideConnections[distBlockI]++;
@ -301,12 +341,12 @@ void Foam::multiLevelDecomp::decompose
Pstream::listCombineScatter(nOutsideConnections); Pstream::listCombineScatter(nOutsideConnections);
label nPatches = 0; label nPatches = 0;
label nFaces = 0; label nFaces = 0;
forAll(nOutsideConnections, i) for (const label nConnect : nOutsideConnections)
{ {
if (nOutsideConnections[i] > 0) if (nConnect > 0)
{ {
nPatches++; ++nPatches;
nFaces += nOutsideConnections[i]; nFaces += nConnect;
} }
} }
@ -330,31 +370,37 @@ void Foam::multiLevelDecomp::decompose
Foam::multiLevelDecomp::multiLevelDecomp(const dictionary& decompositionDict) Foam::multiLevelDecomp::multiLevelDecomp(const dictionary& decompositionDict)
: :
decompositionMethod(decompositionDict), decompositionMethod(decompositionDict),
methodsDict_(decompositionDict_.optionalSubDict(typeName + "Coeffs")) methodsDict_(decompositionDict_.subDict(typeName + "Coeffs"))
{ {
methods_.setSize(methodsDict_.size()); methods_.setSize(methodsDict_.size());
label i = 0; label nLevels = 0;
forAllConstIter(dictionary, methodsDict_, iter) forAllConstIter(dictionary, methodsDict_, iter)
{ {
methods_.set(i++, decompositionMethod::New(iter().dict())); // Ignore primitive entries which may be there for additional control
if (iter().isDict())
{
methods_.set(nLevels++, decompositionMethod::New(iter().dict()));
}
} }
label n = 1; methods_.setSize(nLevels);
label nTot = 1;
Info<< "decompositionMethod " << type() << " :" << endl; Info<< "decompositionMethod " << type() << " :" << endl;
forAll(methods_, i) forAll(methods_, i)
{ {
Info<< " level " << i << " decomposing with " << methods_[i].type() Info<< " level " << i << " decomposing with " << methods_[i].type()
<< " into " << methods_[i].nDomains() << " subdomains." << endl; << " into " << methods_[i].nDomains() << " subdomains." << endl;
n *= methods_[i].nDomains(); nTot *= methods_[i].nDomains();
} }
if (n != nDomains()) if (nTot != nDomains())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Top level decomposition specifies " << nDomains() << "Top level decomposition specifies " << nDomains()
<< " domains which is not equal to the product of" << " domains which is not equal to the product of"
<< " all sub domains " << n << " all sub domains " << nTot
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -385,7 +431,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose
CompactListList<label> cellCells; CompactListList<label> cellCells;
calcCellCells(mesh, identity(cc.size()), cc.size(), true, cellCells); calcCellCells(mesh, identity(cc.size()), cc.size(), true, cellCells);
labelField finalDecomp(cc.size(), 0); labelList finalDecomp(cc.size(), 0);
labelList cellMap(identity(cc.size())); labelList cellMap(identity(cc.size()));
decompose decompose
@ -395,6 +441,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose
cWeights, cWeights,
cellMap, // map back to original cells cellMap, // map back to original cells
0, 0,
0,
finalDecomp finalDecomp
); );
@ -410,7 +457,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose
const scalarField& pointWeights const scalarField& pointWeights
) )
{ {
labelField finalDecomp(points.size(), 0); labelList finalDecomp(points.size(), 0);
labelList pointMap(identity(points.size())); labelList pointMap(identity(points.size()));
decompose decompose
@ -420,6 +467,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose
pointWeights, pointWeights,
pointMap, // map back to original points pointMap, // map back to original points
0, 0,
0,
finalDecomp finalDecomp
); );

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.
@ -71,21 +71,22 @@ class multiLevelDecomp
labelList& cutConnections labelList& cutConnections
) const; ) const;
//- Decompose level methodI without addressing //- Decompose at 'currLevel' without addressing
void decompose void decompose
( (
const labelListList& pointPoints, const labelListList& pointPoints,
const pointField& points, const pointField& points,
const scalarField& pointWeights, const scalarField& pointWeights,
const labelList& pointMap, // map back to original points const labelUList& pointMap, // map back to original points
const label levelI, const label currLevel,
const label leafOffset,
labelField& finalDecomp labelList& finalDecomp
); );
//- Disallow default bitwise copy construct and assignment //- Disallow default bitwise copy construct and assignment
void operator=(const multiLevelDecomp&); void operator=(const multiLevelDecomp&) = delete;
multiLevelDecomp(const multiLevelDecomp&); multiLevelDecomp(const multiLevelDecomp&) = delete;
public: public: