Commit 507ad1e6 authored by Mark Olesen's avatar Mark Olesen
Browse files

Merge commit 'OpenCFD/master' into olesenm

parents bb804cc3 c49b302a
......@@ -316,6 +316,11 @@ meshQualityControls
//must be >0 for Fluent compatibility
minTriangleTwist -1;
//- if >0 : preserve single cells with all points on the surface if the
// resulting volume after snapping is larger than minVolFraction times old
// volume. If <0 : delete always.
minVolFraction 0.1;
// Advanced
......
......@@ -23,16 +23,13 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
scalar minDistSqr = magSqr(1e-6 * globalBb.span());
// Non-empty directions
const Vector<label> validDirs = (mesh.directions() + Vector<label>::one)/2;
const Vector<label> validDirs = (mesh.geometricD() + Vector<label>::one)/2;
Info<< " Mesh (non-empty, non-wedge) directions " << validDirs << endl;
Info<< " Mesh (non-empty) directions " << validDirs << endl;
const Vector<label> solDirs = (mesh.solutionD() + Vector<label>::one)/2;
Info<< " Mesh (non-empty) directions " << solDirs << endl;
scalar nGeomDims = mesh.nGeometricD();
Info<< " Mesh (non-empty, non-wedge) dimensions "
<< nGeomDims << endl;
if (nGeomDims < 3)
if (mesh.nGeometricD() < 3)
{
pointSet nonAlignedPoints(mesh, "nonAlignedEdges", mesh.nPoints()/100);
......
......@@ -59,7 +59,6 @@ processorVolPatchFieldDecomposer
addressing_(addressingSlice.size()),
weights_(addressingSlice.size())
{
const scalarField& weights = mesh.weights().internalField();
const labelList& own = mesh.faceOwner();
const labelList& neighb = mesh.faceNeighbour();
......@@ -72,15 +71,22 @@ processorVolPatchFieldDecomposer
{
// This is a regular face. it has been an internal face
// of the original mesh and now it has become a face
// on the parallel boundary
addressing_[i].setSize(2);
weights_[i].setSize(2);
// on the parallel boundary.
// Give face the value of the neighbour.
addressing_[i][0] = own[ai];
addressing_[i][1] = neighb[ai];
addressing_[i].setSize(1);
weights_[i].setSize(1);
weights_[i][0] = 1.0;
weights_[i][0] = weights[ai];
weights_[i][1] = 1.0 - weights[ai];
if (addressingSlice[i] >= 0)
{
// I have the owner so use the neighbour value
addressing_[i][0] = neighb[ai];
}
else
{
addressing_[i][0] = own[ai];
}
}
else
{
......@@ -89,7 +95,7 @@ processorVolPatchFieldDecomposer
// do the interpolation properly (I would need to look
// up the different (face) list of data), so I will
// just grab the value from the owner cell
//
addressing_[i].setSize(1);
weights_[i].setSize(1);
......
......@@ -30,16 +30,16 @@
<!-- Global settings -->
<!-- Extrapolate Walls check-box -->
<!-- Extrapolate Patches check-box -->
<IntVectorProperty
name="ExtrapolateWalls"
command="SetExtrapolateWalls"
name="ExtrapolatePatches"
command="SetExtrapolatePatches"
number_of_elements="1"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Extrapolate internalField to wall and empty patches
Extrapolate internalField to non-constraint patches
</Documentation>
</IntVectorProperty>
......
......@@ -64,7 +64,7 @@ vtkPV3FoamReader::vtkPV3FoamReader()
CacheMesh = 1;
ExtrapolateWalls = 0;
ExtrapolatePatches = 0;
IncludeSets = 0;
IncludeZones = 0;
ShowPatchNames = 0;
......
......@@ -65,9 +65,9 @@ public:
vtkGetMacro(CacheMesh, int);
// Description:
// FOAM extrapolate internal values onto the walls
vtkSetMacro(ExtrapolateWalls, int);
vtkGetMacro(ExtrapolateWalls, int);
// FOAM extrapolate internal values onto the patches
vtkSetMacro(ExtrapolatePatches, int);
vtkGetMacro(ExtrapolatePatches, int);
// FOAM read sets control
vtkSetMacro(IncludeSets, int);
......@@ -183,7 +183,7 @@ private:
int TimeStepRange[2];
int CacheMesh;
int ExtrapolateWalls;
int ExtrapolatePatches;
int IncludeSets;
int IncludeZones;
int ShowPatchNames;
......
......@@ -659,29 +659,55 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer)
}
}
// Count number of zones we're actually going to display. This is truncated
// to a max per patch
const label MAXPATCHZONES = 20;
label displayZoneI = 0;
forAll(pbMesh, patchI)
{
displayZoneI += min(MAXPATCHZONES, nZones[patchI]);
}
zoneCentre.shrink();
if (debug)
{
Info<< "patch zone centres = " << zoneCentre << nl
<< "displayed zone centres = " << displayZoneI << nl
<< "zones per patch = " << nZones << endl;
}
// Set the size of the patch labels to max number of zones
patchTextActorsPtrs_.setSize(zoneCentre.size());
patchTextActorsPtrs_.setSize(displayZoneI);
if (debug)
{
Info<< "constructing patch labels" << endl;
}
// Actor index
displayZoneI = 0;
// Index in zone centres
label globalZoneI = 0;
forAll(pbMesh, patchI)
{
const polyPatch& pp = pbMesh[patchI];
// Only selected patches will have a non-zero number of zones
for (label i=0; i<nZones[patchI]; i++)
label nDisplayZones = min(MAXPATCHZONES, nZones[patchI]);
label increment = 1;
if (nZones[patchI] >= MAXPATCHZONES)
{
increment = nZones[patchI]/MAXPATCHZONES;
}
for (label i = 0; i < nDisplayZones; i++)
{
if (debug)
{
......@@ -719,14 +745,15 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer)
// Maintain a list of text labels added so that they can be
// removed later
patchTextActorsPtrs_[globalZoneI] = txt;
patchTextActorsPtrs_[displayZoneI] = txt;
globalZoneI++;
globalZoneI += increment;
displayZoneI++;
}
}
// Resize the patch names list to the actual number of patch names added
patchTextActorsPtrs_.setSize(globalZoneI);
patchTextActorsPtrs_.setSize(displayZoneI);
if (debug)
{
......
......@@ -132,8 +132,8 @@ void Foam::vtkPV3Foam::convertVolFields
isType<emptyFvPatchField<Type> >(ptf)
||
(
typeid(patches[patchId]) == typeid(wallPolyPatch)
&& reader_->GetExtrapolateWalls()
reader_->GetExtrapolatePatches()
&& !polyPatch::constraintType(patches[patchId].type())
)
)
{
......
......@@ -58,8 +58,9 @@ Foam::word Foam::Time::findInstance
{
if (debug)
{
Info<< "Time::findInstance(const fileName&, const word&) : "
<< "found \"" << name
Info<< "Time::findInstance"
"(const fileName&, const word&, const IOobject::readOption)"
<< " : found \"" << name
<< "\" in " << timeName()/dir
<< endl;
}
......@@ -98,8 +99,8 @@ Foam::word Foam::Time::findInstance
if (debug)
{
Info<< "Time::findInstance"
"(const fileName&,const word&) : "
<< "found \"" << name
"(const fileName&, const word&, const IOobject::readOption)"
<< " : found \"" << name
<< "\" in " << ts[instanceI].name()/dir
<< endl;
}
......@@ -129,8 +130,8 @@ Foam::word Foam::Time::findInstance
if (debug)
{
Info<< "Time::findInstance"
"(const fileName&,const word&) : "
<< "found \"" << name
"(const fileName&, const word&, const IOobject::readOption)"
<< " : found \"" << name
<< "\" in " << constant()/dir
<< endl;
}
......@@ -141,10 +142,10 @@ Foam::word Foam::Time::findInstance
if (rOpt == IOobject::MUST_READ)
{
FatalErrorIn
(
"Time::findInstance(const fileName&,const word&)"
)
<< "Cannot find file \"" << name << "\" in directory "
(
"Time::findInstance"
"(const fileName&, const word&, const IOobject::readOption)"
) << "Cannot find file \"" << name << "\" in directory "
<< constant()/dir
<< exit(FatalError);
}
......
......@@ -54,40 +54,79 @@ void Foam::polyMesh::calcDirections() const
{
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
{
directions_[cmpt] = 1;
solutionD_[cmpt] = 1;
}
// Knock out empty and wedge directions. Note:they will be present on all
// domains.
label nEmptyPatches = 0;
label nWedgePatches = 0;
vector dirVec = vector::zero;
vector emptyDirVec = vector::zero;
vector wedgeDirVec = vector::zero;
forAll(boundaryMesh(), patchi)
{
if (isA<emptyPolyPatch>(boundaryMesh()[patchi]))
if (boundaryMesh()[patchi].size())
{
if (boundaryMesh()[patchi].size())
if (isA<emptyPolyPatch>(boundaryMesh()[patchi]))
{
nEmptyPatches++;
dirVec += sum(cmptMag(boundaryMesh()[patchi].faceAreas()));
emptyDirVec += sum(cmptMag(boundaryMesh()[patchi].faceAreas()));
}
else if (isA<wedgePolyPatch>(boundaryMesh()[patchi]))
{
const wedgePolyPatch& wpp = refCast<const wedgePolyPatch>
(
boundaryMesh()[patchi]
);
nWedgePatches++;
wedgeDirVec += cmptMag(wpp.centreNormal());
}
}
}
if (nEmptyPatches)
{
reduce(dirVec, sumOp<vector>());
reduce(emptyDirVec, sumOp<vector>());
dirVec /= mag(dirVec);
emptyDirVec /= mag(emptyDirVec);
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
{
if (dirVec[cmpt] > 1e-6)
if (emptyDirVec[cmpt] > 1e-6)
{
directions_[cmpt] = -1;
solutionD_[cmpt] = -1;
}
else
{
directions_[cmpt] = 1;
solutionD_[cmpt] = 1;
}
}
}
// Knock out wedge directions
geometricD_ = solutionD_;
if (nWedgePatches)
{
reduce(wedgeDirVec, sumOp<vector>());
wedgeDirVec /= mag(wedgeDirVec);
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
{
if (wedgeDirVec[cmpt] > 1e-6)
{
geometricD_[cmpt] = -1;
}
else
{
geometricD_[cmpt] = 1;
}
}
}
......@@ -163,7 +202,8 @@ Foam::polyMesh::polyMesh(const IOobject& io)
*this
),
bounds_(points_),
directions_(Vector<label>::zero),
geometricD_(Vector<label>::zero),
solutionD_(Vector<label>::zero),
pointZones_
(
IOobject
......@@ -350,7 +390,8 @@ Foam::polyMesh::polyMesh
0
),
bounds_(points_, syncPar),
directions_(Vector<label>::zero),
geometricD_(Vector<label>::zero),
solutionD_(Vector<label>::zero),
pointZones_
(
IOobject
......@@ -505,7 +546,8 @@ Foam::polyMesh::polyMesh
0
),
bounds_(points_, syncPar),
directions_(Vector<label>::zero),
geometricD_(Vector<label>::zero),
solutionD_(Vector<label>::zero),
pointZones_
(
IOobject
......@@ -766,44 +808,37 @@ const Foam::fileName& Foam::polyMesh::facesInstance() const
}
const Foam::Vector<Foam::label>& Foam::polyMesh::directions() const
const Foam::Vector<Foam::label>& Foam::polyMesh::geometricD() const
{
if (directions_.x() == 0)
if (geometricD_.x() == 0)
{
calcDirections();
}
return directions_;
return geometricD_;
}
Foam::label Foam::polyMesh::nGeometricD() const
{
label nWedges = 0;
return cmptSum(geometricD() + Vector<label>::one)/2;
}
forAll(boundary_, patchi)
{
if (isA<wedgePolyPatch>(boundary_[patchi]))
{
nWedges++;
}
}
if (nWedges != 0 && nWedges != 2 && nWedges != 4)
const Foam::Vector<Foam::label>& Foam::polyMesh::solutionD() const
{
if (solutionD_.x() == 0)
{
FatalErrorIn("label polyMesh::nGeometricD() const")
<< "Number of wedge patches " << nWedges << " is incorrect, "
"should be 0, 2 or 4"
<< exit(FatalError);
calcDirections();
}
return nSolutionD() - nWedges/2;
return solutionD_;
}
Foam::label Foam::polyMesh::nSolutionD() const
{
return cmptSum(directions() + Vector<label>::one)/2;
return cmptSum(solutionD() + Vector<label>::one)/2;
}
......@@ -823,6 +858,10 @@ void Foam::polyMesh::addPatches
<< abort(FatalError);
}
// Reset valid directions
geometricD_ = Vector<label>::zero;
solutionD_ = Vector<label>::zero;
boundary_.setSize(p.size());
// Copy the patch pointers
......@@ -1037,6 +1076,10 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
faceZones_.movePoints(points_);
cellZones_.movePoints(points_);
// Reset valid directions (could change with rotation)
geometricD_ = Vector<label>::zero;
solutionD_ = Vector<label>::zero;
// Hack until proper callbacks. Below are all the polyMeh MeshObjects with a
// movePoints function.
......
......@@ -120,9 +120,13 @@ private:
// Created from points on construction, updated when the mesh moves
boundBox bounds_;
//- vector of non-constrained directions in mesh
// defined according to the presence of empty and wedge patches
mutable Vector<label> geometricD_;
//- vector of valid directions in mesh
// defined according to the presence of empty patches
mutable Vector<label> directions_;
mutable Vector<label> solutionD_;
// Zoning information
......@@ -309,17 +313,22 @@ public:
return bounds_;
}
//- Return the vector of valid directions in mesh.
// Defined according to the presence of empty patches.
// 1 indicates valid direction and -1 an invalid direction.
const Vector<label>& directions() const;
//- Return the vector of geometric directions in mesh.
// Defined according to the presence of empty and wedge patches.
// 1 indicates unconstrained direction and -1 a constrained
// direction.
const Vector<label>& geometricD() const;
//- Return the number of valid geometric dimensions in the mesh
label nGeometricD() const;
//- Return the number of valid solution dimensions in the mesh.
// For wedge cases this includes the circumferential direction
// in case of swirl.
//- Return the vector of solved-for directions in mesh.
// Differs from geometricD in that it includes for wedge cases
// the circumferential direction in case of swirl.
// 1 indicates valid direction and -1 an invalid direction.
const Vector<label>& solutionD() const;
//- Return the number of valid solved-for dimensions in the mesh
label nSolutionD() const;
//- Return point zone mesh
......
......@@ -68,6 +68,10 @@ void Foam::polyMesh::clearGeom()
boundary_[patchI].clearGeom();
}
// Reset valid directions (could change with rotation)
geometricD_ = Vector<label>::zero;
solutionD_ = Vector<label>::zero;
pointMesh::Delete(*this);
}
......@@ -87,6 +91,10 @@ void Foam::polyMesh::clearAddressing()
// recalculation
deleteDemandDrivenData(globalMeshDataPtr_);
// Reset valid directions
geometricD_ = Vector<label>::zero;
solutionD_ = Vector<label>::zero;
pointMesh::Delete(*this);
}
......
......@@ -217,7 +217,8 @@ Foam::polyMesh::polyMesh
boundaryFaces.size() + 1 // add room for a default patch
),
bounds_(points_, syncPar),
directions_(Vector<label>::zero),
geometricD_(Vector<label>::zero),
solutionD_(Vector<label>::zero),
pointZones_
(
IOobject
......
......@@ -68,6 +68,11 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm)
newMotionPoints.map(oldMotionPoints, mpm.pointMap());
}
// Reset valid directions (could change by faces put into empty patches)
geometricD_ = Vector<label>::zero;
solutionD_ = Vector<label>::zero;
// Hack until proper callbacks. Below are all the polyMesh-MeshObjects.
// pointMesh
......
......@@ -29,6 +29,7 @@ License
#include "mathematicalConstants.H"
#include "refinementSurfaces.H"
#include "searchableSurfaces.H"
#include "regExp.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -300,10 +301,44 @@ Foam::layerParameters::layerParameters
// readScalar(layerDict.lookup("minThickness"));
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Check whether layer specification matches any patches
const List<keyType> wildCards = layersDict.keys(true);
forAll(wildCards, i)
{
regExp re(wildCards[i]);
bool hasMatch = false;
forAll(boundaryMesh, patchI)
{
if (re.match(boundaryMesh[patchI].name()))
{