From af7c53443ea02f237b4c5fd68b0233242b085144 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 20 Dec 2010 17:16:30 +0000 Subject: [PATCH] ENH: FaceCellWave,PointEdgeWave : contiguous underlying data type --- .../directions/directionInfo/directionInfo.C | 38 ++- .../directions/directionInfo/directionInfo.H | 8 + .../wallNormalInfo/wallNormalInfo.C | 34 +- .../wallNormalInfo/wallNormalInfo.H | 8 + .../polyTopoChange/refinementData.C | 34 +- .../polyTopoChange/refinementData.H | 8 + .../polyTopoChange/refinementDistanceData.H | 8 + .../finiteVolume/fvc/fvcSmooth/smoothData.H | 8 + .../finiteVolume/fvc/fvcSmooth/sweepData.H | 8 + .../wallDist/wallPointYPlus/wallPointYPlus.H | 8 + .../layeredSolver/pointEdgeStructuredWalk.H | 8 + .../autoHexMeshDriver/pointData/pointData.H | 11 +- src/meshTools/PointEdgeWave/pointEdgePoint.H | 8 + src/meshTools/cellClassification/cellInfo.H | 8 + src/meshTools/cellDist/wallPoint/wallPoint.H | 8 + .../cellDist/wallPoint/wallPointData.H | 40 +++ .../structuredDecomp/topoDistanceData.H | 8 + .../LES/LESdeltas/smoothDelta/smoothDelta.H | 319 +++++++++--------- 18 files changed, 407 insertions(+), 165 deletions(-) diff --git a/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.C b/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.C index 9c904bbc6b..c35bb701bb 100644 --- a/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.C +++ b/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.C @@ -25,11 +25,8 @@ License \*---------------------------------------------------------------------------*/ #include "directionInfo.H" -//#include "hexMatcher.H" -//#include "meshTools.H" #include "polyMesh.H" - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // Find edge among edgeLabels that uses v0 and v1 @@ -209,13 +206,44 @@ Foam::Ostream& Foam::operator<< const Foam::directionInfo& wDist ) { - return os << wDist.index_ << wDist.n_; + if (os.format() == IOstream::ASCII) + { + os << wDist.index_ << wDist.n_; + } + else + { + os.write + ( + reinterpret_cast(&wDist.index_), + sizeof(directionInfo) + ); + } + + // Check state of Ostream + os.check("Ostream& operator<<(Ostream&, const directionInfo&)"); + return os; + } Foam::Istream& Foam::operator>>(Foam::Istream& is, Foam::directionInfo& wDist) { - return is >> wDist.index_ >> wDist.n_; + if (is.format() == IOstream::ASCII) + { + is >> wDist.index_ >> wDist.n_; + } + else + { + is.read + ( + reinterpret_cast(&wDist.index_), + sizeof(directionInfo) + ); + } + + // Check state of Istream + is.check("Istream& operator>>(Istream&, directionInfo&)"); + return is; } // ************************************************************************* // diff --git a/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.H b/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.H index a42c44d41f..bd9608ba01 100644 --- a/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.H +++ b/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.H @@ -251,6 +251,14 @@ public: }; +//- Data associated with directionInfo type are contiguous +template<> +inline bool contiguous() +{ + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/dynamicMesh/meshCut/wallLayerCells/wallNormalInfo/wallNormalInfo.C b/src/dynamicMesh/meshCut/wallLayerCells/wallNormalInfo/wallNormalInfo.C index ce0add8f25..98bf885362 100644 --- a/src/dynamicMesh/meshCut/wallLayerCells/wallNormalInfo/wallNormalInfo.C +++ b/src/dynamicMesh/meshCut/wallLayerCells/wallNormalInfo/wallNormalInfo.C @@ -33,12 +33,42 @@ Foam::Ostream& Foam::operator<< const Foam::wallNormalInfo& wDist ) { - return os << wDist.normal(); + if (os.format() == IOstream::ASCII) + { + os << wDist.normal(); + } + else + { + os.write + ( + reinterpret_cast(&wDist.normal_), + sizeof(vector) + ); + } + + // Check state of Ostream + os.check("Ostream& operator<<(Ostream&, const wallNormalInfo&)"); + return os; } Foam::Istream& Foam::operator>>(Foam::Istream& is, Foam::wallNormalInfo& wDist) { - return is >> wDist.normal_; + if (is.format() == IOstream::ASCII) + { + is >> wDist.normal_; + } + else + { + is.read + ( + reinterpret_cast(&wDist.normal_), + sizeof(vector) + ); + } + + // Check state of Istream + is.check("Istream& operator>>(Istream&, wallNormalInfo&)"); + return is; } // ************************************************************************* // diff --git a/src/dynamicMesh/meshCut/wallLayerCells/wallNormalInfo/wallNormalInfo.H b/src/dynamicMesh/meshCut/wallLayerCells/wallNormalInfo/wallNormalInfo.H index f4553ec47c..2f0025fc63 100644 --- a/src/dynamicMesh/meshCut/wallLayerCells/wallNormalInfo/wallNormalInfo.H +++ b/src/dynamicMesh/meshCut/wallLayerCells/wallNormalInfo/wallNormalInfo.H @@ -191,6 +191,14 @@ public: }; +//- Data associated with wallNormalInfo type are contiguous +template<> +inline bool contiguous() +{ + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementData.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementData.C index c76042beb9..391c0a079b 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementData.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementData.C @@ -33,13 +33,43 @@ Foam::Ostream& Foam::operator<< const Foam::refinementData& wDist ) { - return os << wDist.refinementCount_ << token::SPACE << wDist.count_; + if (os.format() == IOstream::ASCII) + { + os << wDist.refinementCount_ << token::SPACE << wDist.count_; + } + else + { + os.write + ( + reinterpret_cast(&wDist.refinementCount_), + sizeof(refinementData) + ); + } + + // Check state of Ostream + os.check("Ostream& operator<<(Ostream&, const refinementData&)"); + return os; } Foam::Istream& Foam::operator>>(Foam::Istream& is, Foam::refinementData& wDist) { - return is >> wDist.refinementCount_ >> wDist.count_; + if (is.format() == IOstream::ASCII) + { + is >> wDist.refinementCount_ >> wDist.count_; + } + else + { + is.read + ( + reinterpret_cast(&wDist.refinementCount_), + sizeof(refinementData) + ); + } + + // Check state of Istream + is.check("Istream& operator>>(Istream&, refinementData&)"); + return is; } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementData.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementData.H index 171de17109..33349d78e0 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementData.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementData.H @@ -208,6 +208,14 @@ public: }; +//- Data associated with refinementData type are contiguous +template<> +inline bool contiguous() +{ + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementDistanceData.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementDistanceData.H index d838ef7178..d0f9f2d6eb 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementDistanceData.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementDistanceData.H @@ -242,6 +242,14 @@ public: }; +//- Data associated with refinementDistanceData type are contiguous +template<> +inline bool contiguous() +{ + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteVolume/finiteVolume/fvc/fvcSmooth/smoothData.H b/src/finiteVolume/finiteVolume/fvc/fvcSmooth/smoothData.H index f51124e920..2a2de73727 100644 --- a/src/finiteVolume/finiteVolume/fvc/fvcSmooth/smoothData.H +++ b/src/finiteVolume/finiteVolume/fvc/fvcSmooth/smoothData.H @@ -219,6 +219,14 @@ public: }; +//- Data associated with smoothData type are contiguous +template<> +inline bool contiguous() +{ + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/finiteVolume/fvc/fvcSmooth/sweepData.H b/src/finiteVolume/finiteVolume/fvc/fvcSmooth/sweepData.H index ff64713e0b..f7524a2641 100644 --- a/src/finiteVolume/finiteVolume/fvc/fvcSmooth/sweepData.H +++ b/src/finiteVolume/finiteVolume/fvc/fvcSmooth/sweepData.H @@ -210,6 +210,14 @@ public: }; +//- Data associated with sweepData type are contiguous +template<> +inline bool contiguous() +{ + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fvMesh/wallDist/wallPointYPlus/wallPointYPlus.H b/src/finiteVolume/fvMesh/wallDist/wallPointYPlus/wallPointYPlus.H index 2ca7e7197c..9d0279fea1 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallPointYPlus/wallPointYPlus.H +++ b/src/finiteVolume/fvMesh/wallDist/wallPointYPlus/wallPointYPlus.H @@ -144,6 +144,14 @@ public: }; +//- Data associated with pointEdgePoint type as contiguous as underlying type +template<> +inline bool contiguous() +{ + return contiguous >(); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H index e6852dffa2..31d25d6a9f 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H @@ -218,6 +218,14 @@ public: }; +//- Data associated with pointEdgeStructuredWalk type are contiguous +template<> +inline bool contiguous() +{ + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.H index 7719079821..f4f29af8be 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.H @@ -40,9 +40,6 @@ SourceFiles #define pointData_H #include "pointEdgePoint.H" -//#include "point.H" -//#include "label.H" -//#include "tensor.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -158,6 +155,14 @@ public: }; +//- Data associated with pointData as contiguous as pointEdgePoint +template<> +inline bool contiguous() +{ + return contiguous(); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/meshTools/PointEdgeWave/pointEdgePoint.H b/src/meshTools/PointEdgeWave/pointEdgePoint.H index 81f4019bd4..fdf346fc0b 100644 --- a/src/meshTools/PointEdgeWave/pointEdgePoint.H +++ b/src/meshTools/PointEdgeWave/pointEdgePoint.H @@ -226,6 +226,14 @@ public: }; +//- Data associated with pointEdgePoint type are contiguous +template<> +inline bool contiguous() +{ + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/meshTools/cellClassification/cellInfo.H b/src/meshTools/cellClassification/cellInfo.H index a51e255f4c..b282b07cbd 100644 --- a/src/meshTools/cellClassification/cellInfo.H +++ b/src/meshTools/cellClassification/cellInfo.H @@ -201,6 +201,14 @@ public: }; +//- Data associated with cellInfo type are contiguous +template<> +inline bool contiguous() +{ + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/meshTools/cellDist/wallPoint/wallPoint.H b/src/meshTools/cellDist/wallPoint/wallPoint.H index 8215795896..a7d5082e4e 100644 --- a/src/meshTools/cellDist/wallPoint/wallPoint.H +++ b/src/meshTools/cellDist/wallPoint/wallPoint.H @@ -223,6 +223,14 @@ public: }; +//- Data associated with wallPoint type are contiguous +template<> +inline bool contiguous() +{ + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/meshTools/cellDist/wallPoint/wallPointData.H b/src/meshTools/cellDist/wallPoint/wallPointData.H index a826f0003a..6b0d1bdcb2 100644 --- a/src/meshTools/cellDist/wallPoint/wallPointData.H +++ b/src/meshTools/cellDist/wallPoint/wallPointData.H @@ -160,6 +160,46 @@ public: }; +//- Data associated with wallPointData type are contiguous. List the usual +// ones. + +template <> +inline bool contiguous >() +{ + return contiguous(); +} +template <> +inline bool contiguous >() +{ + return contiguous(); +} +template <> +inline bool contiguous >() +{ + return contiguous(); +} +template <> +inline bool contiguous >() +{ + return contiguous(); +} +template <> +inline bool contiguous >() +{ + return contiguous(); +} +template <> +inline bool contiguous >() +{ + return contiguous(); +} +template <> +inline bool contiguous >() +{ + return contiguous(); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceData.H b/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceData.H index a19ed5bdf3..9f4f1ee2cf 100644 --- a/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceData.H +++ b/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceData.H @@ -195,6 +195,14 @@ public: }; +//- Data associated with topoDistanceData type are contiguous +template<> +inline bool contiguous() +{ + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/turbulenceModels/LES/LESdeltas/smoothDelta/smoothDelta.H b/src/turbulenceModels/LES/LESdeltas/smoothDelta/smoothDelta.H index 7a302b9379..a9f0e388d3 100644 --- a/src/turbulenceModels/LES/LESdeltas/smoothDelta/smoothDelta.H +++ b/src/turbulenceModels/LES/LESdeltas/smoothDelta/smoothDelta.H @@ -52,6 +52,164 @@ class smoothDelta : public LESdelta { +public: + + //- Public member class used by mesh-wave to propagate the delta-ratio + class deltaData + { + scalar delta_; + + // Private Member Functions + + //- Update. Gets information from neighbouring face/cell and + // uses this to update itself (if nessecary) and return true. + template + inline bool update + ( + const deltaData& w2, + const scalar scale, + const scalar tol, + TrackingData& td + ); + + + public: + + // Constructors + + //- Construct null + inline deltaData(); + + //- Construct from origin, yStar, distance + inline deltaData(const scalar delta); + + + // Member Functions + + // Access + + scalar delta() const + { + return delta_; + } + + + // Needed by FaceCellWave + + //- Check whether origin has been changed at all or + // still contains original (invalid) value. + template + inline bool valid(TrackingData& td) const; + + //- Check for identical geometrical data. + // Used for cyclics checking. + template + inline bool sameGeometry + ( + const polyMesh&, + const deltaData&, + const scalar, + TrackingData& td + ) const; + + //- Convert any absolute coordinates into relative to + // (patch)face centre + template + inline void leaveDomain + ( + const polyMesh&, + const polyPatch&, + const label patchFaceI, + const point& faceCentre, + TrackingData& td + ); + + //- Reverse of leaveDomain + template + inline void enterDomain + ( + const polyMesh&, + const polyPatch&, + const label patchFaceI, + const point& faceCentre, + TrackingData& td + ); + + //- Apply rotation matrix to any coordinates + template + inline void transform + ( + const polyMesh&, + const tensor&, + TrackingData& td + ); + + //- Influence of neighbouring face. + template + inline bool updateCell + ( + const polyMesh&, + const label thisCellI, + const label neighbourFaceI, + const deltaData& neighbourInfo, + const scalar tol, + TrackingData& td + ); + + //- Influence of neighbouring cell. + template + inline bool updateFace + ( + const polyMesh&, + const label thisFaceI, + const label neighbourCellI, + const deltaData& neighbourInfo, + const scalar tol, + TrackingData& td + ); + + //- Influence of different value on same face. + template + inline bool updateFace + ( + const polyMesh&, + const label thisFaceI, + const deltaData& neighbourInfo, + const scalar tol, + TrackingData& td + ); + + //- Same (like operator==) + template + inline bool equal(const deltaData&, TrackingData& td) const; + + // Member Operators + + // Needed for List IO + inline bool operator==(const deltaData&) const; + + inline bool operator!=(const deltaData&) const; + + // IOstream Operators + + friend Ostream& operator<< + ( + Ostream& os, + const deltaData& wDist + ) + { + return os << wDist.delta_; + } + + friend Istream& operator>>(Istream& is, deltaData& wDist) + { + return is >> wDist.delta_; + } + }; + + +private: + // Private data autoPtr geometricDelta_; @@ -67,159 +225,6 @@ class smoothDelta // Calculate the delta values void calcDelta(); - //- Private member class used by mesh-wave to propagate the delta-ratio - class deltaData - { - scalar delta_; - - // Private Member Functions - - //- Update. Gets information from neighbouring face/cell and - // uses this to update itself (if nessecary) and return true. - template - inline bool update - ( - const deltaData& w2, - const scalar scale, - const scalar tol, - TrackingData& td - ); - - - public: - - // Constructors - - //- Construct null - inline deltaData(); - - //- Construct from origin, yStar, distance - inline deltaData(const scalar delta); - - - // Member Functions - - // Access - - scalar delta() const - { - return delta_; - } - - - // Needed by FaceCellWave - - //- Check whether origin has been changed at all or - // still contains original (invalid) value. - template - inline bool valid(TrackingData& td) const; - - //- Check for identical geometrical data. - // Used for cyclics checking. - template - inline bool sameGeometry - ( - const polyMesh&, - const deltaData&, - const scalar, - TrackingData& td - ) const; - - //- Convert any absolute coordinates into relative to - // (patch)face centre - template - inline void leaveDomain - ( - const polyMesh&, - const polyPatch&, - const label patchFaceI, - const point& faceCentre, - TrackingData& td - ); - - //- Reverse of leaveDomain - template - inline void enterDomain - ( - const polyMesh&, - const polyPatch&, - const label patchFaceI, - const point& faceCentre, - TrackingData& td - ); - - //- Apply rotation matrix to any coordinates - template - inline void transform - ( - const polyMesh&, - const tensor&, - TrackingData& td - ); - - //- Influence of neighbouring face. - template - inline bool updateCell - ( - const polyMesh&, - const label thisCellI, - const label neighbourFaceI, - const deltaData& neighbourInfo, - const scalar tol, - TrackingData& td - ); - - //- Influence of neighbouring cell. - template - inline bool updateFace - ( - const polyMesh&, - const label thisFaceI, - const label neighbourCellI, - const deltaData& neighbourInfo, - const scalar tol, - TrackingData& td - ); - - //- Influence of different value on same face. - template - inline bool updateFace - ( - const polyMesh&, - const label thisFaceI, - const deltaData& neighbourInfo, - const scalar tol, - TrackingData& td - ); - - //- Same (like operator==) - template - inline bool equal(const deltaData&, TrackingData& td) const; - - // Member Operators - - // Needed for List IO - inline bool operator==(const deltaData&) const; - - inline bool operator!=(const deltaData&) const; - - // IOstream Operators - - friend Ostream& operator<< - ( - Ostream& os, - const deltaData& wDist - ) - { - return os << wDist.delta_; - } - - friend Istream& operator>>(Istream& is, deltaData& wDist) - { - return is >> wDist.delta_; - } - }; - void setChangedFaces ( @@ -262,6 +267,14 @@ public: }; +//- Data associated with deltaData type are contiguous +template<> +inline bool contiguous() +{ + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam