diff --git a/src/mesh/blockMesh/block/block.H b/src/mesh/blockMesh/block/block.H index 943d38bdfc648562a0492887f7a5e790bb8ef87f..7d3f908b5e75c70b16ab9ecd6902c9b65c3f8e39 100644 --- a/src/mesh/blockMesh/block/block.H +++ b/src/mesh/blockMesh/block/block.H @@ -146,7 +146,9 @@ public: const labelListListList& boundaryPatches() const; - //- Clear geometry + // Edit + + //- Clear geometry (internal points, cells, boundaryPatches) void clearGeom(); diff --git a/src/mesh/blockMesh/blockMesh/blockMesh.H b/src/mesh/blockMesh/blockMesh/blockMesh.H index 4acc0797c4dd968fa73cc26f0cfafc964c1f65a3..3b817c5179ac9cb59e6b878a12c3d74bd6cf30a1 100644 --- a/src/mesh/blockMesh/blockMesh/blockMesh.H +++ b/src/mesh/blockMesh/blockMesh/blockMesh.H @@ -165,6 +165,11 @@ public: label numZonedBlocks() const; + // Edit + + //- Clear geometry (internal points, cells, boundaryPatches) + void clearGeom(); + // Write //- Writes edges of blockMesh in OBJ format. diff --git a/src/mesh/blockMesh/blockMesh/blockMeshCreate.C b/src/mesh/blockMesh/blockMesh/blockMeshCreate.C index 546b9fbc8b21496c4304b9bf6499a532321e2732..f9ebd02c66d8ef7cf2e2e230f22f1686b7de956f 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshCreate.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshCreate.C @@ -32,7 +32,7 @@ License void Foam::blockMesh::createPoints() const { - const blockMesh& blocks = *this; + const blockList& blocks = *this; Info<< "Creating points with scale " << scaleFactor_ << endl; @@ -62,7 +62,7 @@ void Foam::blockMesh::createPoints() const void Foam::blockMesh::createCells() const { - const blockMesh& blocks = *this; + const blockList& blocks = *this; const cellModel& hex = *(cellModeller::lookup("hex")); Info<< "Creating cells" << endl; @@ -107,7 +107,7 @@ Foam::faceList Foam::blockMesh::createPatchFaces const polyPatch& patchTopologyFaces ) const { - const blockMesh& blocks = *this; + const blockList& blocks = *this; labelList blockLabels = patchTopologyFaces.polyPatch::faceCells(); @@ -237,4 +237,15 @@ void Foam::blockMesh::createPatches() const } + +void Foam::blockMesh::clearGeom() +{ + blockList& blocks = *this; + + forAll(blocks, blockI) + { + blocks[blockI].clearGeom(); + } +} + // ************************************************************************* // diff --git a/src/mesh/blockMesh/blockMesh/blockMeshMerge.C b/src/mesh/blockMesh/blockMesh/blockMeshMerge.C index 20442c15c778952f8b909987f42ddfea6d8dc166..6da65be26ee7478b410bdf4e31805d39bc25fd1d 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshMerge.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshMerge.C @@ -30,7 +30,7 @@ License void Foam::blockMesh::calcMergeInfo() { - const blockMesh& blocks = *this; + const blockList& blocks = *this; Info<< "Creating block offsets" << endl; diff --git a/src/mesh/blockMesh/blockMesh/blockMeshTopology.C b/src/mesh/blockMesh/blockMesh/blockMeshTopology.C index 10c4a85684bb561fc0a2541be2093bef2ad45a03..bb20b20468e30e068d7cb9b9f2364781b31bfa55 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshTopology.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshTopology.C @@ -36,7 +36,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict) { bool topologyOK = true; - blockMesh& blocks = *this; + blockList& blocks = *this; word defaultPatchName = "defaultFaces"; word defaultPatchType = emptyPolyPatch::typeName; diff --git a/src/mesh/blockMesh/curvedEdges/BSpline.C b/src/mesh/blockMesh/curvedEdges/BSpline.C index 32634fc6f38427b51666ec44f7e30b83eaf17910..56e829eda523e433fa15861b86f67b647b70a828 100644 --- a/src/mesh/blockMesh/curvedEdges/BSpline.C +++ b/src/mesh/blockMesh/curvedEdges/BSpline.C @@ -119,7 +119,7 @@ Foam::BSpline::BSpline // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::vector Foam::BSpline::realPosition(scalar mu) +Foam::vector Foam::BSpline::realPosition(const scalar mu) const { return spline::position(mu); } diff --git a/src/mesh/blockMesh/curvedEdges/BSpline.H b/src/mesh/blockMesh/curvedEdges/BSpline.H index f127d89d29403b4801dae2a59c973b83729d0e66..2020d194b12d6a441f3c84184eb4af6813a064e9 100644 --- a/src/mesh/blockMesh/curvedEdges/BSpline.H +++ b/src/mesh/blockMesh/curvedEdges/BSpline.H @@ -83,7 +83,7 @@ public: //- Return the real position of a point on the curve given by // the parameter 0 <= lambda <= 1 - vector realPosition(scalar lambda); + vector realPosition(const scalar lambda) const; //- Return the position of a point on the curve given by // the parameter 0 <= lambda <= 1 diff --git a/src/mesh/blockMesh/curvedEdges/curvedEdge.C b/src/mesh/blockMesh/curvedEdges/curvedEdge.C index 1241330c7441245fa570f125a8285e84f7f7cac4..4b80a221ddd16c78fead7a889344db6d4454b189 100644 --- a/src/mesh/blockMesh/curvedEdges/curvedEdge.C +++ b/src/mesh/blockMesh/curvedEdges/curvedEdge.C @@ -108,7 +108,7 @@ Foam::autoPtr<Foam::curvedEdge> Foam::curvedEdge::New // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::pointField Foam::knotlist +Foam::pointField Foam::curvedEdge::knotlist ( const pointField& points, const label start, @@ -116,19 +116,19 @@ Foam::pointField Foam::knotlist const pointField& otherknots ) { - label listsize(otherknots.size() + 2); - pointField tmp(listsize); + pointField newPoints(otherknots.size() + 2); - tmp[0] = points[start]; + // start/end knots + newPoints[0] = points[start]; + newPoints[otherknots.size() + 1] = points[end]; - for (register label i=1; i<listsize-1; i++) + // intermediate knots + forAll(otherknots, knotI) { - tmp[i] = otherknots[i-1]; + newPoints[knotI+1] = otherknots[knotI]; } - tmp[listsize-1] = points[end]; - - return tmp; + return newPoints; } diff --git a/src/mesh/blockMesh/curvedEdges/curvedEdge.H b/src/mesh/blockMesh/curvedEdges/curvedEdge.H index 41b0a709c1c1a83220d262d2292e71936e3189ca..c891550cb3ede1ca8d49ff852d8c5099e6430d8d 100644 --- a/src/mesh/blockMesh/curvedEdges/curvedEdge.H +++ b/src/mesh/blockMesh/curvedEdges/curvedEdge.H @@ -66,7 +66,6 @@ public: //- Runtime type information TypeName("curvedEdge"); - // Declare run-time constructor selection tables declareRunTimeSelectionTable @@ -113,36 +112,22 @@ public: // Member Functions //- Return label of start point - label start() const - { - return start_; - } + inline label start() const; //- Return label of end point - label end() const - { - return end_; - } + inline label end() const; //- Compare the given start and end points with this curve // - 0: different // - +1: identical // - -1: same edge, but different orientation - int compare(const label start, const label end) const - { - if (start_ == start && end_ == end) - { - return 1; - } - else if (start_ == end && end_ == start) - { - return -1; - } - else - { - return 0; - } - } + inline int compare(const curvedEdge&) const; + + //- Compare the given start and end points with this curve + // - 0: different + // - +1: identical + // - -1: same edge, but different orientation + inline int compare(const label start, const label end) const; //- Return the position of a point on the curve given by // the parameter 0 <= lambda <= 1 @@ -151,6 +136,17 @@ public: //- Return the length of the curve virtual scalar length() const = 0; + //- Return a complete knotList by adding the start/end points + // to the given list + static pointField knotlist + ( + const pointField&, + const label start, + const label end, + const pointField& otherknots + ); + + // Member operators void operator=(const curvedEdge&); @@ -161,20 +157,13 @@ public: }; -//- Return the complete knotList by adding the start and end points to the -// given list -pointField knotlist -( - const pointField& points, - const label start, - const label end, - const pointField& otherknots -); +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam +#include "curvedEdgeI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/mesh/blockMesh/curvedEdges/curvedEdgeI.H b/src/mesh/blockMesh/curvedEdges/curvedEdgeI.H new file mode 100644 index 0000000000000000000000000000000000000000..8a800bf613c7267e04415a66659c24488f47a788 --- /dev/null +++ b/src/mesh/blockMesh/curvedEdges/curvedEdgeI.H @@ -0,0 +1,78 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline Foam::label Foam::curvedEdge::start() const +{ + return start_; +} + + +inline Foam::label Foam::curvedEdge::end() const +{ + return end_; +} + + +inline int Foam::curvedEdge::compare(const curvedEdge& ce) const +{ + if (start_ == ce.start_ && end_ == ce.end_) + { + return 1; + } + else if (start_ == ce.end_ && end_ == ce.start_) + { + return -1; + } + else + { + return 0; + } +} + + +inline int Foam::curvedEdge::compare(const label start, const label end) const +{ + if (start_ == start && end_ == end) + { + return 1; + } + else if (start_ == end && end_ == start) + { + return -1; + } + else + { + return 0; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/lineDivide.C b/src/mesh/blockMesh/curvedEdges/lineDivide.C index 065ade5516862bb36d87fce1f07da9ff97bccabb..9a3fd1664db5d92d36b5ed78492dd1181b7987e9 100644 --- a/src/mesh/blockMesh/curvedEdges/lineDivide.C +++ b/src/mesh/blockMesh/curvedEdges/lineDivide.C @@ -48,8 +48,8 @@ Foam::lineDivide::lineDivide if (xratio == 1.0) { - scalar y(1.0/np); - for (label i=0; i<=noPoints_; i++) + const scalar y(1.0/np); + for (label i=0; i <= noPoints_; i++) { lambda = scalar(i)/np; points_[i] = bc.position(lambda); @@ -62,7 +62,7 @@ Foam::lineDivide::lineDivide divisions_[0] = 0.0; scalar xrpower = 1.0; - for (label i=1; i<=noPoints_; i++) + for (label i=1; i <= noPoints_; i++) { lambda = (1.0 - pow(xratio, i))/(1.0 - pow(xratio, np)); points_[i] = bc.position(lambda); diff --git a/src/mesh/blockMesh/curvedEdges/lineEdge.H b/src/mesh/blockMesh/curvedEdges/lineEdge.H index c71500d3aed485342b950b0e0aeb6c4cfa3a0426..307fb071c81fd3adcd28427482451ff23be277d3 100644 --- a/src/mesh/blockMesh/curvedEdges/lineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/lineEdge.H @@ -54,8 +54,11 @@ class lineEdge { // Private data - vector startPoint_; - vector direction_; + //- Avoid repetitive calculation of the start point + const vector startPoint_; + + //- Avoid repetitive calculation of the direction (end - start) + const vector direction_; public: @@ -66,10 +69,10 @@ public: // Constructors //- Construct from components - lineEdge(const pointField& points, const label start, const label end); + lineEdge(const pointField&, const label start, const label end); //- Construct from Istream setting pointsList - lineEdge(const pointField& points, Istream&); + lineEdge(const pointField&, Istream&); // Destructor diff --git a/src/mesh/blockMesh/curvedEdges/polyLine.H b/src/mesh/blockMesh/curvedEdges/polyLine.H index ad7a47d4b0e2e3af9d0d23a03bda08964bde547f..35cb7cdfa9390d07b24d617e03eb50e27a878c02 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLine.H +++ b/src/mesh/blockMesh/curvedEdges/polyLine.H @@ -48,7 +48,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class polyLine Declaration + Class polyLine Declaration \*---------------------------------------------------------------------------*/ @@ -73,7 +73,7 @@ public: // Constructors //- Construct from components - polyLine(const pointField& ps); + polyLine(const pointField&); // Member Functions diff --git a/src/mesh/blockMesh/curvedEdges/polyLineEdge.C b/src/mesh/blockMesh/curvedEdges/polyLineEdge.C index 14431cc2844d76f6e7c1af6d96db0fe2b7007af7..89029d1af97726cf6895650b32e8baaa8e1bf971 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLineEdge.C +++ b/src/mesh/blockMesh/curvedEdges/polyLineEdge.C @@ -48,7 +48,7 @@ Foam::polyLineEdge::polyLineEdge ) : curvedEdge(ps, start, end), - polyLine(knotlist(ps,start,end,otherpoints)) + polyLine(knotlist(ps, start, end, otherpoints)) {} diff --git a/src/mesh/blockMesh/curvedEdges/polyLineEdge.H b/src/mesh/blockMesh/curvedEdges/polyLineEdge.H index 82e2a1305cf29e441bed0e7e94806b225daa0030..f0b8095e1d9cd6869fc446974eef924882b7f26d 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/polyLineEdge.H @@ -46,7 +46,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class polyLineEdge Declaration + Class polyLineEdge Declaration \*---------------------------------------------------------------------------*/ class polyLineEdge @@ -66,14 +66,14 @@ public: //- Construct from components polyLineEdge ( - const pointField& ps, + const pointField&, const label start, const label end, - const pointField& otherpoints + const pointField& otherPoints ); //- Construct from Istream - polyLineEdge(const pointField& ps, Istream&); + polyLineEdge(const pointField&, Istream&); // Destructor diff --git a/src/mesh/blockMesh/curvedEdges/polySplineEdge.H b/src/mesh/blockMesh/curvedEdges/polySplineEdge.H index 3ddec108e5c8b6b0f6c25ce2a5401ad17c00972a..dfb58388546966ac1743307b95370bfadf3503a8 100644 --- a/src/mesh/blockMesh/curvedEdges/polySplineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/polySplineEdge.H @@ -45,7 +45,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class polySplineEdge Declaration + Class polySplineEdge Declaration \*---------------------------------------------------------------------------*/ class polySplineEdge @@ -62,14 +62,15 @@ class polySplineEdge pointField intervening ( - const pointField& otherknots, - const label nbetweenKnots, - const vector&, const vector& + const pointField& otherKnots, + const label nBetweenKnots, + const vector&, + const vector& ); - label nsize(const label otherknotsSize, const label nbetweenKnots) + label nsize(const label otherKnotsSize, const label nBetweenKnots) { - return otherknotsSize*(1 + nbetweenKnots) + nbetweenKnots + 2; + return otherKnotsSize*(1 + nBetweenKnots) + nBetweenKnots + 2; } @@ -84,15 +85,15 @@ public: //- Construct from components polySplineEdge ( - const pointField& points, + const pointField&, const label start, const label end, - const pointField& otherknots, + const pointField& otherKnots, const label nInterKnots = 20 ); //- Construct from Istream setting pointsList - polySplineEdge(const pointField& points, Istream& is); + polySplineEdge(const pointField&, Istream&); // Destructor diff --git a/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.H b/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.H index 77e48005c54919d3b8698356f9c772945a05a378..59a4160025c1a597795ea98fefea84ae14cd31bf 100644 --- a/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.H @@ -45,7 +45,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class simpleSplineEdge Declaration + Class simpleSplineEdge Declaration \*---------------------------------------------------------------------------*/ class simpleSplineEdge @@ -65,19 +65,19 @@ public: //- Construct from components simpleSplineEdge ( - const pointField& points, + const pointField&, const label start, const label end, - const pointField& otherknots + const pointField& otherKnots ); //- Construct from components simpleSplineEdge ( - const pointField& points, + const pointField&, const label start, const label end, - const pointField& otherknots, + const pointField& otherKnots, const vector& fstend, const vector& sndend ); diff --git a/src/mesh/blockMesh/curvedEdges/spline.H b/src/mesh/blockMesh/curvedEdges/spline.H index fd7ffcb85ad754347b8ceb8f643b53f6a1359c53..ab62352ca8a2980078d0e3d8dec402a6b3d5d96d 100644 --- a/src/mesh/blockMesh/curvedEdges/spline.H +++ b/src/mesh/blockMesh/curvedEdges/spline.H @@ -46,7 +46,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class spline Declaration + Class spline Declaration \*---------------------------------------------------------------------------*/ class spline