From caa250f81da20f0355aa6efa2ba923c73f4e4c08 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 17 Mar 2010 11:16:29 +0000 Subject: [PATCH] ENH: layered mesh motion solver Specifies motion as blocks inside which motion is interpolated --- src/fvMotionSolver/Make/files | 1 + .../displacementLayeredMotionFvMotionSolver.C | 30 +++++-- .../displacementLayeredMotionFvMotionSolver.H | 2 +- .../layeredSolver/pointEdgeStructuredWalk.C | 4 +- .../layeredSolver/pointEdgeStructuredWalk.H | 21 +---- .../layeredSolver/pointEdgeStructuredWalkI.H | 80 +++++-------------- 6 files changed, 52 insertions(+), 86 deletions(-) diff --git a/src/fvMotionSolver/Make/files b/src/fvMotionSolver/Make/files index 44046b57ca..87e8e39c25 100644 --- a/src/fvMotionSolver/Make/files +++ b/src/fvMotionSolver/Make/files @@ -2,6 +2,7 @@ fvMotionSolvers/fvMotionSolver/fvMotionSolver.C fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.C +fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.C fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.C index f86bd0439e..6731620e56 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.C @@ -51,7 +51,7 @@ namespace Foam void Foam::displacementLayeredMotionFvMotionSolver::calcZoneMask ( - const label cellZoneI, + const label cellZoneI, PackedBoolList& isZonePoint, PackedBoolList& isZoneEdge ) const @@ -133,16 +133,14 @@ void Foam::displacementLayeredMotionFvMotionSolver::walkStructured vectorField& data ) const { - const pointField& points = mesh().points(); - List seedInfo(seedPoints.size()); forAll(seedPoints, i) { seedInfo[i] = pointEdgeStructuredWalk ( - true, - points[seedPoints[i]], + points0()[seedPoints[i]], // location of data + points0()[seedPoints[i]], // previous location 0.0, seedData[i] ); @@ -150,12 +148,22 @@ void Foam::displacementLayeredMotionFvMotionSolver::walkStructured // Current info on points List allPointInfo(mesh().nPoints()); - // Mark points inside cellZone + // Mark points inside cellZone. + + // Note that we use points0, not mesh.points() + // so as not to accumulate errors. + forAll(isZonePoint, pointI) { if (isZonePoint[pointI]) { - allPointInfo[pointI].inZone() = true; + allPointInfo[pointI] = pointEdgeStructuredWalk + ( + points0()[pointI], // location of data + vector::max, // not valid + 0.0, + vector::zero // passive data + ); } } @@ -166,7 +174,13 @@ void Foam::displacementLayeredMotionFvMotionSolver::walkStructured { if (isZoneEdge[edgeI]) { - allEdgeInfo[edgeI].inZone() = true; + allEdgeInfo[edgeI] = pointEdgeStructuredWalk + ( + mesh().edges()[edgeI].centre(points0()), // location of data + vector::max, // not valid + 0.0, + vector::zero + ); } } diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.H index 96bae2c12f..aba9817680 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/displacementLayeredMotionFvMotionSolver.H @@ -88,7 +88,7 @@ class displacementLayeredMotionFvMotionSolver void calcZoneMask ( - const label cellZoneI, + const label cellZoneI, PackedBoolList& isZonePoint, PackedBoolList& isZoneEdge ) const; diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.C b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.C index ec56628f02..83df8ccfa6 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.C @@ -35,7 +35,7 @@ Foam::Ostream& Foam::operator<< ) { return os - << wDist.inZone_ << wDist.previousPoint_ + << wDist.point0_ << wDist.previousPoint_ << wDist.dist_ << wDist.data_; } @@ -46,7 +46,7 @@ Foam::Istream& Foam::operator>> ) { return is - >> wDist.inZone_ >> wDist.previousPoint_ + >> wDist.point0_ >> wDist.previousPoint_ >> wDist.dist_ >> wDist.data_; } diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H index 83454236e6..2c62f9ea44 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H @@ -61,10 +61,10 @@ class pointEdgeStructuredWalk { // Private data - //- Is this point/edge inside the walk zone - bool inZone_; + //- Starting location + point point0_; - //- Previuos point + //- Previous point point previousPoint_; //- Sum of distance @@ -77,15 +77,6 @@ class pointEdgeStructuredWalk //- Evaluate distance to point. inline bool update - ( - const point&, - const pointEdgeStructuredWalk& w2, - const scalar tol - ); - - //- Combine current with w2. Update distSqr, origin if w2 has smaller - // quantities and returns true. - inline bool update ( const pointEdgeStructuredWalk& w2, const scalar tol @@ -101,7 +92,7 @@ public: //- Construct from components inline pointEdgeStructuredWalk ( - const bool, + const point&, const point&, const scalar, const vector& @@ -114,10 +105,6 @@ public: inline bool inZone() const; - inline bool& inZone(); - - inline const point& previousPoint() const; - inline scalar dist() const; inline const vector& data() const; diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalkI.H b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalkI.H index c6cc23f99f..6381ebfb55 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalkI.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalkI.H @@ -32,16 +32,15 @@ License // Update this with w2. inline bool Foam::pointEdgeStructuredWalk::update ( - const point& pt, const pointEdgeStructuredWalk& w2, const scalar tol ) { if (!valid()) { - // current not yet set. Walked from w2 to here (=pt) - dist_ = w2.dist_ + mag(pt-w2.previousPoint_); - previousPoint_ = pt; + // current not yet set. Walked from w2 to here (=point0) + dist_ = w2.dist_ + mag(point0_-w2.previousPoint_); + previousPoint_ = point0_; data_ = w2.data_; return true; @@ -52,36 +51,13 @@ inline bool Foam::pointEdgeStructuredWalk::update } } - -// Update this with w2 (information on same point) -inline bool Foam::pointEdgeStructuredWalk::update -( - const pointEdgeStructuredWalk& w2, - const scalar tol -) -{ - if (!valid()) - { - // current not yet set so use neighbour - dist_ = w2.dist_; - previousPoint_ = w2.previousPoint_; - data_ = w2.data_; - - return true; - } - else - { - // already nearer to pt - return false; - } -} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Null constructor inline Foam::pointEdgeStructuredWalk::pointEdgeStructuredWalk() : - inZone_(false), + point0_(vector::max), previousPoint_(vector::max), dist_(0), data_(vector::zero) @@ -91,13 +67,13 @@ inline Foam::pointEdgeStructuredWalk::pointEdgeStructuredWalk() // Construct from origin, distance inline Foam::pointEdgeStructuredWalk::pointEdgeStructuredWalk ( - const bool inZone, - const point& previousPoint, + const point& point0, + const point& previousPoint, const scalar dist, const vector& data ) : - inZone_(inZone), + point0_(point0), previousPoint_(previousPoint), dist_(dist), data_(data) @@ -108,20 +84,14 @@ inline Foam::pointEdgeStructuredWalk::pointEdgeStructuredWalk inline bool Foam::pointEdgeStructuredWalk::inZone() const { - return inZone_; + return point0_ != vector::max; } -inline bool& Foam::pointEdgeStructuredWalk::inZone() -{ - return inZone_; -} - - -inline const Foam::point& Foam::pointEdgeStructuredWalk::previousPoint() const -{ - return previousPoint_; -} +//inline const Foam::point& Foam::pointEdgeStructuredWalk::previousPoint() const +//{ +// return previousPoint_; +//} inline Foam::scalar Foam::pointEdgeStructuredWalk::dist() const @@ -210,15 +180,15 @@ inline bool Foam::pointEdgeStructuredWalk::updatePoint const scalar tol ) { - if (inZone_) + if (inZone()) { - return update(mesh.points()[pointI], edgeInfo, tol); + return update(edgeInfo, tol); } else { return false; } -} +} // Update this with new information on same point @@ -230,9 +200,9 @@ inline bool Foam::pointEdgeStructuredWalk::updatePoint const scalar tol ) { - if (inZone_) + if (inZone()) { - return update(mesh.points()[pointI], newPointInfo, tol); + return update(newPointInfo, tol); } else { @@ -249,7 +219,7 @@ inline bool Foam::pointEdgeStructuredWalk::updatePoint ) { return update(newPointInfo, tol); -} +} // Update this with information from connected point @@ -262,21 +232,15 @@ inline bool Foam::pointEdgeStructuredWalk::updateEdge const scalar tol ) { - if (inZone_) + if (inZone()) { - const pointField& points = mesh.points(); - - const edge& e = mesh.edges()[edgeI]; - - const point edgeMid(0.5*(points[e[0]] + points[e[1]])); - - return update(edgeMid, pointInfo, tol); + return update(pointInfo, tol); } else { return false; } -} +} // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // @@ -286,7 +250,7 @@ inline bool Foam::pointEdgeStructuredWalk::operator== const Foam::pointEdgeStructuredWalk& rhs ) const { - return previousPoint() == rhs.previousPoint(); + return previousPoint_ == rhs.previousPoint_; }