Commit 709b92d9 authored by andy's avatar andy Committed by Andrew Heather
Browse files

ENH: mesh motion updates

parent f46e9966
......@@ -19,7 +19,7 @@ Foam::label Foam::findOppositeWedge
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
scalar wppCosAngle = wpp.centreNormal()&wpp.patchNormal();
scalar wppCosAngle = wpp.cosAngle();
forAll(patches, patchI)
{
......@@ -30,13 +30,11 @@ Foam::label Foam::findOppositeWedge
&& isA<wedgePolyPatch>(patches[patchI])
)
{
const wedgePolyPatch& pp = refCast<const wedgePolyPatch>
(
patches[patchI]
);
const wedgePolyPatch& pp =
refCast<const wedgePolyPatch>(patches[patchI]);
// Calculate (cos of) angle to wpp (not pp!) centre normal
scalar ppCosAngle = wpp.centreNormal()&pp.patchNormal();
scalar ppCosAngle = wpp.centreNormal() & pp.n();
if
(
......@@ -73,12 +71,10 @@ bool Foam::checkWedges
{
if (patches[patchI].size() && isA<wedgePolyPatch>(patches[patchI]))
{
const wedgePolyPatch& pp = refCast<const wedgePolyPatch>
(
patches[patchI]
);
const wedgePolyPatch& pp =
refCast<const wedgePolyPatch>(patches[patchI]);
scalar wedgeAngle = acos(pp.centreNormal()&pp.patchNormal());
scalar wedgeAngle = acos(pp.cosAngle());
if (report)
{
......@@ -100,10 +96,8 @@ bool Foam::checkWedges
return true;
}
const wedgePolyPatch& opp = refCast<const wedgePolyPatch>
(
patches[oppositePatchI]
);
const wedgePolyPatch& opp =
refCast<const wedgePolyPatch>(patches[oppositePatchI]);
if (mag(opp.axis() & pp.axis()) < (1-1e-3))
......@@ -140,7 +134,7 @@ bool Foam::checkWedges
forAll(pp.meshPoints(), i)
{
const point& pt = p[pp.meshPoints()[i]];
scalar d = mag((pt-p0) & pp.patchNormal());
scalar d = mag((pt - p0) & pp.n());
if (d > sqrt(SMALL))
{
......@@ -385,10 +379,8 @@ bool Foam::checkCoupledPoints
{
if (patches[patchI].coupled())
{
const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>
(
patches[patchI]
);
const coupledPolyPatch& cpp =
refCast<const coupledPolyPatch>(patches[patchI]);
if (cpp.owner())
{
......
......@@ -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-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -21,9 +21,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Wedge front and back plane patch
\*---------------------------------------------------------------------------*/
#include "wedgePointPatch.H"
......@@ -46,6 +43,19 @@ namespace Foam
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::wedgePointPatch::wedgePointPatch
(
const polyPatch& patch,
const pointBoundaryMesh& bm
)
:
facePointPatch(patch, bm),
wedgePolyPatch_(refCast<const wedgePolyPatch>(patch))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::wedgePointPatch::applyConstraint
......@@ -54,7 +64,7 @@ void Foam::wedgePointPatch::applyConstraint
pointConstraint& pc
) const
{
pc.applyConstraint(pointNormals()[pointi]);
pc.applyConstraint(wedgePolyPatch_.n());
}
......
......@@ -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-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -51,6 +51,11 @@ class wedgePointPatch
:
public facePointPatch
{
// Private data
//- Local reference cast into the symmetryPlane patch
const wedgePolyPatch& wedgePolyPatch_;
public:
......@@ -65,10 +70,7 @@ public:
(
const polyPatch& patch,
const pointBoundaryMesh& bm
)
:
facePointPatch(patch, bm)
{}
);
// Member Functions
......@@ -85,6 +87,12 @@ public:
const label pointi,
pointConstraint&
) const;
//- Return symmetry plane normal
const vector& n() const
{
return wedgePolyPatch_.n();
}
};
......
......@@ -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-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -28,9 +28,6 @@ License
#include "polyMesh.H"
#include "mapPolyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faceMapper::calcAddressing() const
......@@ -168,7 +165,7 @@ void Foam::faceMapper::calcAddressing() const
}
// Grab inserted points (for them the size of addressing is still zero)
// Grab inserted faces (for them the size of addressing is still zero)
insertedFaceLabelsPtr_ = new labelList(mesh_.nFaces());
labelList& insertedFaces = *insertedFaceLabelsPtr_;
......@@ -413,13 +410,4 @@ const Foam::labelList& Foam::faceMapper::oldPatchSizes() const
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// ************************************************************************* //
......@@ -921,7 +921,6 @@ Foam::polyMesh::cellTree() const
}
// Add boundary patches. Constructor helper
void Foam::polyMesh::addPatches
(
const List<polyPatch*>& p,
......@@ -968,7 +967,6 @@ void Foam::polyMesh::addPatches
}
// Add mesh zones. Constructor helper
void Foam::polyMesh::addZones
(
const List<pointZone*>& pz,
......@@ -1084,7 +1082,6 @@ const Foam::labelList& Foam::polyMesh::faceNeighbour() const
}
// Return old mesh motion points
const Foam::pointField& Foam::polyMesh::oldPoints() const
{
if (oldPointsPtr_.empty())
......@@ -1129,11 +1126,14 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
points_ = newPoints;
bool moveError = false;
if (debug)
{
// Check mesh motion
if (checkMeshMotion(points_, true))
{
moveError = true;
Info<< "tmp<scalarField> polyMesh::movePoints"
<< "(const pointField&) : "
<< "Moving the mesh with given points will "
......@@ -1176,6 +1176,12 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
const_cast<Time&>(time()).functionObjects().movePoints(*this);
if (debug && moveError)
{
write();
}
return sweptVols;
}
......@@ -1219,7 +1225,6 @@ Foam::label& Foam::polyMesh::comm()
}
// Remove all files and some subdirs (eg, sets)
void Foam::polyMesh::removeFiles(const fileName& instanceDir) const
{
fileName meshFilesPath = thisDb().time().path()/instanceDir/meshDir();
......
......@@ -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-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -40,56 +40,90 @@ namespace Foam
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::wedgePolyPatch::initTransforms()
void Foam::wedgePolyPatch::calcGeometry(PstreamBuffers&)
{
if (size() > 0)
if (axis_ != vector::rootMax)
{
const pointField& points = this->points();
return;
}
if (returnReduce(size(), sumOp<label>()))
{
const vectorField& nf(faceNormals());
n_ = gAverage(nf);
if (debug)
{
Info<< "Patch " << name() << " calculated average normal "
<< n_ << endl;
}
patchNormal_ = operator[](0).normal(points);
patchNormal_ /= mag(patchNormal_);
// Check the wedge is planar
forAll(nf, faceI)
{
if (magSqr(n_ - nf[faceI]) > SMALL)
{
// only issue warning instead of error so that the case can
// still be read for post-processing
WarningIn
(
"wedgePolyPatch::calcGeometry(PstreamBuffers&)"
)
<< "Wedge patch '" << name() << "' is not planar." << nl
<< "At local face at "
<< primitivePatch::faceCentres()[faceI]
<< " the normal " << nf[faceI]
<< " differs from the average normal " << n_
<< " by " << magSqr(n_ - nf[faceI]) << nl
<< "Either correct the patch or split it into planar parts"
<< endl;
}
}
centreNormal_ =
vector
(
sign(patchNormal_.x())*(max(mag(patchNormal_.x()), 0.5) - 0.5),
sign(patchNormal_.y())*(max(mag(patchNormal_.y()), 0.5) - 0.5),
sign(patchNormal_.z())*(max(mag(patchNormal_.z()), 0.5) - 0.5)
sign(n_.x())*(max(mag(n_.x()), 0.5) - 0.5),
sign(n_.y())*(max(mag(n_.y()), 0.5) - 0.5),
sign(n_.z())*(max(mag(n_.z()), 0.5) - 0.5)
);
centreNormal_ /= mag(centreNormal_);
cosAngle_ = centreNormal_ & n_;
const scalar cnCmptSum =
centreNormal_.x() + centreNormal_.y() + centreNormal_.z();
if (mag(cnCmptSum) < (1 - SMALL))
{
FatalErrorIn("wedgePolyPatch::initTransforms()")
FatalErrorIn("wedgePolyPatch::calcGeometry(PstreamBuffers&)")
<< "wedge " << name()
<< " centre plane does not align with a coordinate plane by "
<< 1 - mag(cnCmptSum)
<< exit(FatalError);
}
axis_ = centreNormal_ ^ patchNormal_;
axis_ = centreNormal_ ^ n_;
scalar magAxis = mag(axis_);
if (magAxis < SMALL)
{
FatalErrorIn("wedgePolyPatch::initTransforms()")
FatalErrorIn("wedgePolyPatch::calcGeometry(PstreamBuffers&)")
<< "wedge " << name()
<< " plane aligns with a coordinate plane." << nl
<< " The wedge plane should make a small angle (~2.5deg)"
" with the coordinate plane" << nl
<< " and the the pair of wedge planes should be symmetric"
<< " about the coordinate plane." << nl
<< " Normal of face " << 0 << " is " << patchNormal_
<< " Normal of wedge plane is " << n_
<< " , implied coordinate plane direction is " << centreNormal_
<< exit(FatalError);
}
axis_ /= magAxis;
faceT_ = rotationTensor(centreNormal_, patchNormal_);
faceT_ = rotationTensor(centreNormal_, n_);
cellT_ = faceT_ & faceT_;
}
}
......@@ -107,10 +141,14 @@ Foam::wedgePolyPatch::wedgePolyPatch
const word& patchType
)
:
polyPatch(name, size, start, index, bm, patchType)
{
initTransforms();
}
polyPatch(name, size, start, index, bm, patchType),
axis_(vector::rootMax),
centreNormal_(vector::rootMax),
n_(vector::rootMax),
cosAngle_(0.0),
faceT_(tensor::zero),
cellT_(tensor::zero)
{}
Foam::wedgePolyPatch::wedgePolyPatch
......@@ -122,10 +160,14 @@ Foam::wedgePolyPatch::wedgePolyPatch
const word& patchType
)
:
polyPatch(name, dict, index, bm, patchType)
{
initTransforms();
}
polyPatch(name, dict, index, bm, patchType),
axis_(vector::rootMax),
centreNormal_(vector::rootMax),
n_(vector::rootMax),
cosAngle_(0.0),
faceT_(tensor::zero),
cellT_(tensor::zero)
{}
Foam::wedgePolyPatch::wedgePolyPatch
......@@ -134,10 +176,14 @@ Foam::wedgePolyPatch::wedgePolyPatch
const polyBoundaryMesh& bm
)
:
polyPatch(pp, bm)
{
initTransforms();
}
polyPatch(pp, bm),
axis_(pp.axis_),
centreNormal_(pp.centreNormal_),
n_(pp.n_),
cosAngle_(pp.cosAngle_),
faceT_(pp.faceT_),
cellT_(pp.cellT_)
{}
Foam::wedgePolyPatch::wedgePolyPatch
......@@ -149,10 +195,14 @@ Foam::wedgePolyPatch::wedgePolyPatch
const label newStart
)
:
polyPatch(pp, bm, index, newSize, newStart)
{
initTransforms();
}
polyPatch(pp, bm, index, newSize, newStart),
axis_(pp.axis_),
centreNormal_(pp.centreNormal_),
n_(pp.n_),
cosAngle_(pp.cosAngle_),
faceT_(pp.faceT_),
cellT_(pp.cellT_)
{}
Foam::wedgePolyPatch::wedgePolyPatch
......@@ -164,10 +214,14 @@ Foam::wedgePolyPatch::wedgePolyPatch
const label newStart
)
:
polyPatch(pp, bm, index, mapAddressing, newStart)
{
initTransforms();
}
polyPatch(pp, bm, index, mapAddressing, newStart),
axis_(pp.axis_),
centreNormal_(pp.centreNormal_),
n_(pp.n_),
cosAngle_(pp.cosAngle_),
faceT_(pp.faceT_),
cellT_(pp.cellT_)
{}
// ************************************************************************* //
......@@ -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-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -59,7 +59,10 @@ class wedgePolyPatch
vector centreNormal_;
//- Normal to the patch
vector patchNormal_;
vector n_;
//- Cosine of the wedge angle
scalar cosAngle_;
//- Face transformation tensor
tensor faceT_;
......@@ -67,8 +70,13 @@ class wedgePolyPatch
//- Neighbour-cell transformation tensor
tensor cellT_;
//- Calculate the above tensors
void initTransforms();
protected:
// Protected Member Functions
//- Calculate the patch geometry
virtual void calcGeometry(PstreamBuffers&);
public:
......@@ -180,9 +188,15 @@ public:
}
//- Return the normal to the patch
const vector& patchNormal() const
const vector& n() const
{
return n_;
}
//- Return the cosine of the wedge angle
scalar cosAngle() const
{
return patchNormal_;
return cosAngle_;
}
//- Return face transformation tensor
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -35,7 +35,6 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
//- Calculate the offset to the next layer
Foam::tmp<Foam::vectorField> Foam::layerAdditionRemoval::extrusionDir() const
{
const polyMesh& mesh = topoChanger().mesh();
......@@ -79,6 +78,7 @@ Foam::tmp<Foam::vectorField> Foam::layerAdditionRemoval::extrusionDir() const
extrusionDir = minLayerThickness_*masterFaceLayer.pointNormals();
}
return textrusionDir;
}
......@@ -120,7 +120,7 @@ void Foam::layerAdditionRemoval::addCellLayer
// Get the extrusion direction for the added points
tmp<vectorField> tpointOffsets = extrusionDir();
const vectorField pointOffsets(extrusionDir());
// Add the new points
labelList addedPoints(mp.size());
......@@ -135,7 +135,7 @@ void Foam::layerAdditionRemoval::addCellLayer
polyAddPoint
(
points[mp[pointI]] // point
+ addDelta_*tpointOffsets()[pointI],
+ addDelta_*pointOffsets[pointI],
mp[pointI], // master point
-1, // zone for point
true // supports a cell
......@@ -143,14 +143,18 @@ void Foam::layerAdditionRemoval::addCellLayer
);
}
// Pout<< "mp: " << mp << " addedPoints: " << addedPoints << endl;
if (debug > 1)
{
Pout<< "mp: " << mp << " addedPoints: " << addedPoints << endl;
}
// Create the cells
const labelList& mc =
mesh.faceZones()[faceZoneID_.index()].masterCells();
const labelList& sc =
mesh.faceZones()[faceZoneID_.index()].slaveCells();
// Pout<< "mc: " << mc << " sc: " << sc << endl;
const labelList& mf = mesh.faceZones()[faceZoneID_.index()];
const boolList& mfFlip = mesh.faceZones()[faceZoneID_.index()].flipMap();
......@@ -231,10 +235,13 @@ void Foam::layerAdditionRemoval::addCellLayer
)
);
// Pout<< "adding face: " << newFace
// << " own: " << mc[faceI]
// << " nei: " << addedCells[faceI]
// << endl;
if (debug > 1)
{
Pout<< "adding face: " << newFace
<< " own: " << mc[faceI]
<< " nei: " << addedCells[faceI]
<< endl;
}
}
// Modify the faces from the master zone for the new neighbour
......@@ -267,10 +274,14 @@ void Foam::layerAdditionRemoval::addCellLayer