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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -185,7 +185,7 @@ void twoDPointCorrector::clearAddressing() const
twoDPointCorrector::twoDPointCorrector(const polyMesh& mesh) twoDPointCorrector::twoDPointCorrector(const polyMesh& mesh)
: :
mesh_(mesh), MeshObject<polyMesh, Foam::UpdateableMeshObject, twoDPointCorrector>(mesh),
required_(mesh_.nGeometricD() == 2), required_(mesh_.nGeometricD() == 2),
planeNormalPtr_(NULL), planeNormalPtr_(NULL),
normalEdgeIndicesPtr_(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(); clearAddressing();
} }
bool twoDPointCorrector::movePoints()
{
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

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