ENH: twoDPointCorrector: made into meshobject

This commit is contained in:
mattijs
2013-11-28 15:47:19 +00:00
parent 614ff49977
commit 7b18ea5471
2 changed files with 58 additions and 7 deletions

View File

@ -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
@ -185,7 +185,7 @@ void twoDPointCorrector::clearAddressing() const
twoDPointCorrector::twoDPointCorrector(const polyMesh& mesh)
:
mesh_(mesh),
MeshObject<polyMesh, Foam::UpdateableMeshObject, twoDPointCorrector>(mesh),
required_(mesh_.nGeometricD() == 2),
planeNormalPtr_(NULL),
normalEdgeIndicesPtr_(NULL)
@ -286,12 +286,57 @@ void twoDPointCorrector::correctPoints(pointField& p) const
}
void twoDPointCorrector::updateMesh()
void twoDPointCorrector::correctDisplacement
(
const pointField& p,
vectorField& disp
) const
{
if (!required_) return;
// Algorithm:
// Loop through all edges. Calculate the average point position A for
// the front and the back. Correct the position of point P (in two planes)
// such that vectors AP and planeNormal are parallel
// Get reference to edges
const edgeList& meshEdges = mesh_.edges();
const labelList& neIndices = normalEdgeIndices();
const vector& pn = planeNormal();
forAll(neIndices, edgeI)
{
const edge& e = meshEdges[neIndices[edgeI]];
label startPointI = e.start();
point pStart = p[startPointI] + disp[startPointI];
label endPointI = e.end();
point pEnd = p[endPointI] + disp[endPointI];
// calculate average point position
const point A = 0.5*(pStart + pEnd);
// correct point locations
disp[startPointI] = (A + pn*(pn & (pStart - A))) - p[startPointI];
disp[endPointI] = (A + pn*(pn & (pEnd - A))) - p[endPointI];
}
}
void twoDPointCorrector::updateMesh(const mapPolyMesh&)
{
clearAddressing();
}
bool twoDPointCorrector::movePoints()
{
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -42,6 +42,7 @@ SourceFiles
#ifndef twoDPointCorrector_H
#define twoDPointCorrector_H
#include "MeshObject.H"
#include "pointField.H"
#include "labelList.H"
#include "vector.H"
@ -59,12 +60,11 @@ class polyMesh;
\*---------------------------------------------------------------------------*/
class twoDPointCorrector
:
public MeshObject<polyMesh, UpdateableMeshObject, twoDPointCorrector>
{
// Private data
//- Reference to moving mesh
const polyMesh& mesh_;
//- Is 2D correction required, i.e. is the mesh
bool required_;
@ -129,8 +129,14 @@ public:
//- Correct motion points
void correctPoints(pointField& p) const;
//- Correct motion displacements
void correctDisplacement(const pointField& p, vectorField& disp) const;
//- Update topology
void updateMesh();
void updateMesh(const mapPolyMesh&);
//- Correct weighting factors for moving mesh.
bool movePoints();
};