Commit b8bb781e authored by laurence's avatar laurence
Browse files

Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

parents 57d92949 f2d8f636
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -222,6 +222,21 @@ Foam::dictionary::~dictionary()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::dictionary& Foam::dictionary::topDict() const
{
const dictionary& p = parent();
if (&p != this && !p.name().empty())
{
return p.topDict();
}
else
{
return p;
}
}
Foam::label Foam::dictionary::startLineNumber() const
{
if (size())
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -250,6 +250,9 @@ public:
return parent_;
}
//- Return the top of the tree
const dictionary& topDict() const;
//- Return line number of first token in dictionary
label startLineNumber() const;
......
......@@ -65,30 +65,12 @@ const Foam::word Foam::functionEntries::codeStream::codeTemplateC
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const Foam::dictionary& Foam::functionEntries::codeStream::topDict
(
const dictionary& dict
)
{
const dictionary& p = dict.parent();
if (&p != &dict && !p.name().empty())
{
return topDict(p);
}
else
{
return dict;
}
}
Foam::dlLibraryTable& Foam::functionEntries::codeStream::libs
(
const dictionary& dict
)
{
const IOdictionary& d = static_cast<const IOdictionary&>(topDict(dict));
const IOdictionary& d = static_cast<const IOdictionary&>(dict.topDict());
return const_cast<Time&>(d.time()).libs();
}
......@@ -114,7 +96,7 @@ Foam::functionEntries::codeStream::getFunction
// see if library is loaded
void* lib = NULL;
if (isA<IOdictionary>(topDict(parentDict)))
if (isA<IOdictionary>(parentDict.topDict()))
{
lib = libs(parentDict).findLibrary(libPath);
}
......@@ -129,7 +111,7 @@ Foam::functionEntries::codeStream::getFunction
// avoid compilation if possible by loading an existing library
if (!lib)
{
if (isA<IOdictionary>(topDict(parentDict)))
if (isA<IOdictionary>(parentDict.topDict()))
{
// Cached access to dl libs. Guarantees clean up upon destruction
// of Time.
......@@ -267,7 +249,7 @@ Foam::functionEntries::codeStream::getFunction
}
}
if (isA<IOdictionary>(topDict(parentDict)))
if (isA<IOdictionary>(parentDict.topDict()))
{
// Cached access to dl libs. Guarantees clean up upon destruction
// of Time.
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -26,11 +26,8 @@ License
#include "mapPolyMesh.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::mapPolyMesh::mapPolyMesh
(
const polyMesh& mesh,
......@@ -115,7 +112,6 @@ Foam::mapPolyMesh::mapPolyMesh
}
// Construct from components and optionally reuse storage
Foam::mapPolyMesh::mapPolyMesh
(
const polyMesh& mesh,
......@@ -177,31 +173,32 @@ Foam::mapPolyMesh::mapPolyMesh
oldPatchStarts_(oldPatchStarts, reUse),
oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse)
{
// Calculate old patch sizes
for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
if (oldPatchStarts_.size() > 0)
{
oldPatchSizes_[patchI] =
oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
}
// Calculate old patch sizes
for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
{
oldPatchSizes_[patchI] =
oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
}
// Set the last one by hand
const label lastPatchID = oldPatchStarts_.size() - 1;
// Set the last one by hand
const label lastPatchID = oldPatchStarts_.size() - 1;
oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
if (polyMesh::debug)
{
if (min(oldPatchSizes_) < 0)
if (polyMesh::debug)
{
FatalErrorIn("mapPolyMesh::mapPolyMesh(...)")
<< "Calculated negative old patch size. Error in mapping data"
<< abort(FatalError);
if (min(oldPatchSizes_) < 0)
{
FatalErrorIn("mapPolyMesh::mapPolyMesh(...)")
<< "Calculated negative old patch size."
<< " Error in mapping data"
<< abort(FatalError);
}
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ 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 "makeCombustionTypes.H"
#include "psiCombustionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace combustionModels
{
makeCombustionTypes
(
infinitelyFastChemistry,
psiCombustionModel
);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -58,10 +58,8 @@ void Foam::layerAdditionRemoval::checkDefinition()
{
if (!faceZoneID_.active())
{
FatalErrorIn
(
"void Foam::layerAdditionRemoval::checkDefinition()"
) << "Master face zone named " << faceZoneID_.name()
FatalErrorIn("void Foam::layerAdditionRemoval::checkDefinition()")
<< "Master face zone named " << faceZoneID_.name()
<< " cannot be found."
<< abort(FatalError);
}
......@@ -79,13 +77,15 @@ void Foam::layerAdditionRemoval::checkDefinition()
<< abort(FatalError);
}
if (topoChanger().mesh().faceZones()[faceZoneID_.index()].empty())
label nFaces = topoChanger().mesh().faceZones()[faceZoneID_.index()].size();
reduce(nFaces, sumOp<label>());
if (nFaces == 0)
{
FatalErrorIn
(
"void Foam::layerAdditionRemoval::checkDefinition()"
) << "Face extrusion zone contains no faces. "
<< " Please check your mesh definition."
FatalErrorIn("void Foam::layerAdditionRemoval::checkDefinition()")
<< "Face extrusion zone contains no faces. "
<< "Please check your mesh definition."
<< abort(FatalError);
}
......@@ -120,16 +120,18 @@ Foam::layerAdditionRemoval::layerAdditionRemoval
(
const word& name,
const label index,
const polyTopoChanger& mme,
const polyTopoChanger& ptc,
const word& zoneName,
const scalar minThickness,
const scalar maxThickness
const scalar maxThickness,
const Switch thicknessFromVolume
)
:
polyMeshModifier(name, index, mme, true),
faceZoneID_(zoneName, mme.mesh().faceZones()),
polyMeshModifier(name, index, ptc, true),
faceZoneID_(zoneName, ptc.mesh().faceZones()),
minLayerThickness_(minThickness),
maxLayerThickness_(maxThickness),
thicknessFromVolume_(thicknessFromVolume),
oldLayerThickness_(-1.0),
pointsPairingPtr_(NULL),
facesPairingPtr_(NULL),
......@@ -145,13 +147,17 @@ Foam::layerAdditionRemoval::layerAdditionRemoval
const word& name,
const dictionary& dict,
const label index,
const polyTopoChanger& mme
const polyTopoChanger& ptc
)
:
polyMeshModifier(name, index, mme, Switch(dict.lookup("active"))),
faceZoneID_(dict.lookup("faceZoneName"), mme.mesh().faceZones()),
polyMeshModifier(name, index, ptc, Switch(dict.lookup("active"))),
faceZoneID_(dict.lookup("faceZoneName"), ptc.mesh().faceZones()),
minLayerThickness_(readScalar(dict.lookup("minLayerThickness"))),
maxLayerThickness_(readScalar(dict.lookup("maxLayerThickness"))),
thicknessFromVolume_
(
dict.lookupOrDefault<Switch>("thicknessFromVolume", true)
),
oldLayerThickness_(readOldThickness(dict)),
pointsPairingPtr_(NULL),
facesPairingPtr_(NULL),
......@@ -188,11 +194,13 @@ bool Foam::layerAdditionRemoval::changeTopology() const
// Layer removal:
// When the min thickness falls below the threshold, trigger removal.
const faceZone& fz = topoChanger().mesh().faceZones()[faceZoneID_.index()];
const polyMesh& mesh = topoChanger().mesh();
const faceZone& fz = mesh.faceZones()[faceZoneID_.index()];
const labelList& mc = fz.masterCells();
const scalarField& V = topoChanger().mesh().cellVolumes();
const vectorField& S = topoChanger().mesh().faceAreas();
const scalarField& V = mesh.cellVolumes();
const vectorField& S = mesh.faceAreas();
if (min(V) < -VSMALL)
{
......@@ -205,63 +213,68 @@ bool Foam::layerAdditionRemoval::changeTopology() const
scalar avgDelta = 0;
scalar minDelta = GREAT;
scalar maxDelta = 0;
label nDelta = 0;
if (thicknessFromVolume_)
{
// Thickness calculated from cell volume/face area
forAll(fz, faceI)
{
scalar curDelta = V[mc[faceI]]/mag(S[fz[faceI]]);
avgDelta += curDelta;
minDelta = min(minDelta, curDelta);
maxDelta = max(maxDelta, curDelta);
}
forAll(fz, faceI)
nDelta = fz.size();
}
else
{
scalar curDelta = V[mc[faceI]]/mag(S[fz[faceI]]);
avgDelta += curDelta;
minDelta = min(minDelta, curDelta);
maxDelta = max(maxDelta, curDelta);
// Thickness calculated from edges on layer
const Map<label>& zoneMeshPointMap = fz().meshPointMap();
// Edges with only one point on zone
forAll(mc, faceI)
{
const cell& cFaces = mesh.cells()[mc[faceI]];
const edgeList cellEdges(cFaces.edges(mesh.faces()));
forAll(cellEdges, i)
{
const edge& e = cellEdges[i];
if (zoneMeshPointMap.found(e[0]))
{
if (!zoneMeshPointMap.found(e[1]))
{
scalar curDelta = e.mag(mesh.points());
avgDelta += curDelta;
nDelta++;
minDelta = min(minDelta, curDelta);
maxDelta = max(maxDelta, curDelta);
}
}
else
{
if (zoneMeshPointMap.found(e[1]))
{
scalar curDelta = e.mag(mesh.points());
avgDelta += curDelta;
nDelta++;
minDelta = min(minDelta, curDelta);
maxDelta = max(maxDelta, curDelta);
}
}
}
}
}
avgDelta /= fz.size();
////MJ Alternative thickness determination
//{
// // Edges on layer.
// const Map<label>& zoneMeshPointMap = fz().meshPointMap();
//
// label nDelta = 0;
//
// // Edges with only one point on zone
// const polyMesh& mesh = topoChanger().mesh();
//
// forAll(mc, faceI)
// {
// const cell& cFaces = mesh.cells()[mc[faceI]];
// const edgeList cellEdges(cFaces.edges(mesh.faces()));
//
// forAll(cellEdges, i)
// {
// const edge& e = cellEdges[i];
//
// if (zoneMeshPointMap.found(e[0]))
// {
// if (!zoneMeshPointMap.found(e[1]))
// {
// scalar curDelta = e.mag(mesh.points());
// avgDelta += curDelta;
// nDelta++;
// minDelta = min(minDelta, curDelta);
// maxDelta = max(maxDelta, curDelta);
// }
// }
// else
// {
// if (zoneMeshPointMap.found(e[1]))
// {
// scalar curDelta = e.mag(mesh.points());
// avgDelta += curDelta;
// nDelta++;
// minDelta = min(minDelta, curDelta);
// maxDelta = max(maxDelta, curDelta);
// }
// }
// }
// }
//
// avgDelta /= nDelta;
//}
reduce(minDelta, minOp<scalar>());
reduce(maxDelta, maxOp<scalar>());
reduce(avgDelta, sumOp<scalar>());
reduce(nDelta, sumOp<label>());
avgDelta /= nDelta;
if (debug)
{
......@@ -286,7 +299,6 @@ bool Foam::layerAdditionRemoval::changeTopology() const
}
// No topological changes allowed before first mesh motion
//
oldLayerThickness_ = avgDelta;
topologicalChange = false;
......@@ -314,7 +326,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const
<< "Triggering layer removal" << endl;
}
triggerRemoval_ = topoChanger().mesh().time().timeIndex();
triggerRemoval_ = mesh.time().timeIndex();
// Old thickness looses meaning.
// Set it up to indicate layer removal
......@@ -346,7 +358,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const
<< "Triggering layer addition" << endl;
}
triggerAddition_ = topoChanger().mesh().time().timeIndex();
triggerAddition_ = mesh.time().timeIndex();
// Old thickness looses meaning.
// Set it up to indicate layer removal
......@@ -377,8 +389,8 @@ void Foam::layerAdditionRemoval::setRefinement(polyTopoChange& ref) const
if (debug)
{
Pout<< "layerAdditionRemoval::setRefinement(polyTopoChange&) "
<< " for object " << name() << " : "
<< "Clearing addressing after layer removal. " << endl;
<< "for object " << name() << " : "
<< "Clearing addressing after layer removal" << endl;
}
triggerRemoval_ = -1;
......@@ -393,8 +405,8 @@ void Foam::layerAdditionRemoval::setRefinement(polyTopoChange& ref) const
if (debug)
{
Pout<< "layerAdditionRemoval::setRefinement(polyTopoChange&) "
<< " for object " << name() << " : "
<< "Clearing addressing after layer addition. " << endl;
<< "for object " << name() << " : "
<< "Clearing addressing after layer addition" << endl;
}
triggerAddition_ = -1;
......@@ -408,8 +420,8 @@ void Foam::layerAdditionRemoval::updateMesh(const mapPolyMesh&)
if (debug)
{
Pout<< "layerAdditionRemoval::updateMesh(const mapPolyMesh&) "
<< " for object " << name() << " : "
<< "Clearing addressing on external request. ";
<< "for object " << name() << " : "
<< "Clearing addressing on external request";
if (pointsPairingPtr_ || facesPairingPtr_)
{
......@@ -471,7 +483,8 @@ void Foam::layerAdditionRemoval::write(Ostream& os) const
<< faceZoneID_ << nl
<< minLayerThickness_ << nl
<< oldLayerThickness_ << nl
<< maxLayerThickness_ << endl;
<< maxLayerThickness_ << nl
<< thicknessFromVolume_ << endl;
}
......@@ -486,6 +499,8 @@ void Foam::layerAdditionRemoval::writeDict(Ostream& os) const
<< token::END_STATEMENT << nl
<< " maxLayerThickness " << maxLayerThickness_
<< token::END_STATEMENT << nl
<< " thicknessFromVolume " << thicknessFromVolume_
<< token::END_STATEMENT << nl
<< " oldLayerThickness " << oldLayerThickness_
<< token::END_STATEMENT << nl
<< " active " << active()
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -65,6 +65,10 @@ class layerAdditionRemoval
//- Max thickness of extrusion layer. Triggers layer addition
mutable scalar maxLayerThickness_;
//- Switch to calculate thickness as volume/area
// If false, thickness calculated from edges
const bool thicknessFromVolume_;
//- Layer thickness from previous step
// Used to decide whether to add or remove layers
mutable scalar oldLayerThickness_;
......@@ -78,7 +82,7 @@ class layerAdditionRemoval
//- Layer removal trigger time index
mutable label triggerRemoval_;
//- Layer addition trigger time index
//- Layer addition trigger time index
mutable label triggerAddition_;
......@@ -120,6 +124,7 @@ class layerAdditionRemoval
//- Clear addressing
void clearAddressing() const;
// Helpers
//- Optionally read old thickness
......@@ -149,10 +154,11 @@ public:
(
const word& name,
const label index,
const polyTopoChanger& mme,
const polyTopoChanger& ptc,
const word& zoneName,
const scalar minThickness,
const scalar maxThickness
const scalar maxThickness,
const Switch thicknessFromVolume = true
);
//- Construct from dictionary
......@@ -161,7 +167,7 @@ public:
const word& name,
const dictionary& dict,
const label index,
const polyTopoChanger& mme
const polyTopoChanger& ptc
);
......
......@@ -818,22 +818,25 @@ void Foam::polyTopoChange::getFaceOrder
patchSizes.setSize(nPatches_);
patchSizes = 0;
patchStarts[0] = newFaceI;
for (label faceI = 0; faceI < nActiveFaces; faceI++)
if (nPatches_ > 0)
{
if (region_[faceI] >= 0)
patchStarts[0] = newFaceI;
for (label faceI = 0; faceI < nActiveFaces; faceI++)
{
patchSizes[region_[faceI]]++;
if (region_[faceI] >= 0)
{
patchSizes[region_[faceI]]++;
}
}
}
label faceI = patchStarts[0];
label faceI = patchStarts[0];
forAll(patchStarts, patchI)
{