diff --git a/src/meshTools/algorithms/PointEdgeWave/PointData.C b/src/meshTools/algorithms/PointEdgeWave/PointData.C new file mode 100644 index 0000000000..f480f0a990 --- /dev/null +++ b/src/meshTools/algorithms/PointEdgeWave/PointData.C @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "PointData.H" + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<<(Ostream& os, const PointData& pd) +{ + if (os.format() == IOstream::ASCII) + { + return os + << static_cast(pd) + << token::SPACE << pd.data(); + } + else + { + return os + << static_cast(pd) + << pd.data(); + } +} + + +template +Foam::Istream& Foam::operator>>(Istream& is, PointData& pd) +{ + return is >> static_cast(pd) >> pd.data_; +} + + +// ************************************************************************* // diff --git a/src/meshTools/algorithms/PointEdgeWave/PointData.H b/src/meshTools/algorithms/PointEdgeWave/PointData.H new file mode 100644 index 0000000000..02a97092bf --- /dev/null +++ b/src/meshTools/algorithms/PointEdgeWave/PointData.H @@ -0,0 +1,211 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 3 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, see . + +Class + Foam::PointData + +Description + Variant of pointEdgePoint with some transported additional data. Templated + on the transported data type. + +SourceFiles + PointDataI.H + PointData.C + +\*---------------------------------------------------------------------------*/ + +#ifndef PointData_H +#define PointData_H + +#include "pointEdgePoint.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class Istream; +class Ostream; +template +class PointData; + +// Forward declaration of friend functions and operators +template +Ostream& operator<<(Ostream&, const PointData&); +template +Istream& operator>>(Istream&, PointData&); + +/*---------------------------------------------------------------------------*\ + Class PointData Declaration +\*---------------------------------------------------------------------------*/ + +template +class PointData +: + public pointEdgePoint +{ +private: + + // Private data + + //- Additional transported data + DataType data_; + + +public: + + // Constructors + + //- Construct null + inline PointData(); + + //- Construct from origin, distance and data + inline PointData + ( + const point& origin, + const scalar distSqr, + const DataType& data + ); + + //- Construct as copy + inline PointData(const PointData&); + + + // Member Functions + + // Access + + //- Const access the data + inline const DataType& data() const; + + + // Needed by meshWave + + //- Apply rotation matrix to the data + template + inline void transform + ( + const tensor& rotTensor, + TrackingData& td + ); + + //- Influence of edge on point + template + inline bool updatePoint + ( + const polyMesh& mesh, + const label pointI, + const label edgeI, + const PointData& edgeInfo, + const scalar tol, + TrackingData& td + ); + + //- Influence of different value on same point. + // Merge new and old info. + template + inline bool updatePoint + ( + const polyMesh& mesh, + const label pointI, + const PointData& newPointInfo, + const scalar tol, + TrackingData& td + ); + + //- Influence of different value on same point. + // No information about current position whatsoever. + template + inline bool updatePoint + ( + const PointData& newPointInfo, + const scalar tol, + TrackingData& td + ); + + //- Influence of point on edge. + template + inline bool updateEdge + ( + const polyMesh& mesh, + const label edgeI, + const label pointI, + const PointData& pointInfo, + const scalar tol, + TrackingData& td + ); + + // Member Operators + + inline bool operator==(const PointData&) const; + inline bool operator!=(const PointData&) const; + + + // IOstream Operators + + friend Ostream& operator<< + ( + Ostream&, + const PointData& + ); + friend Istream& operator>> + ( + Istream&, + PointData& + ); +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +//- Data associated with PointData types is contiguous + +template<> +inline bool contiguous >() +{ + return true; +} + +template<> +inline bool contiguous >() +{ + return true; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "PointDataI.H" + +#ifdef NoRepository +# include "PointData.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/algorithms/PointEdgeWave/PointDataI.H b/src/meshTools/algorithms/PointEdgeWave/PointDataI.H new file mode 100644 index 0000000000..6ecc1c49fe --- /dev/null +++ b/src/meshTools/algorithms/PointEdgeWave/PointDataI.H @@ -0,0 +1,234 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "polyMesh.H" +#include "transform.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +inline Foam::PointData::PointData() +: + pointEdgePoint() +{} + + +template +inline Foam::PointData::PointData +( + const point& origin, + const scalar distSqr, + const DataType& data +) +: + pointEdgePoint(origin, distSqr), + data_(data) +{} + + +template +inline Foam::PointData::PointData(const PointData& wpt) +: + pointEdgePoint(wpt), + data_(wpt.data()) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline const DataType& Foam::PointData::data() const +{ + return data_; +} + + +template +template +inline void Foam::PointData::transform +( + const tensor& rotTensor, + TrackingData& td +) +{ + pointEdgePoint::transform(rotTensor, td); + data_ = Foam::transform(rotTensor, data_); +} + + +template +template +inline bool Foam::PointData::updatePoint +( + const polyMesh& mesh, + const label pointI, + const label edgeI, + const PointData& edgeInfo, + const scalar tol, + TrackingData& td +) +{ + if + ( + pointEdgePoint::updatePoint + ( + mesh, + pointI, + edgeI, + edgeInfo, + tol, + td + ) + ) + { + data_ = edgeInfo.data_; + + return true; + } + else + { + return false; + } +} + + +template +template +inline bool Foam::PointData::updatePoint +( + const polyMesh& mesh, + const label pointI, + const PointData& newPointInfo, + const scalar tol, + TrackingData& td +) +{ + if + ( + pointEdgePoint::updatePoint + ( + mesh, + pointI, + newPointInfo, + tol, + td + ) + ) + { + data_ = newPointInfo.data_; + + return true; + } + else + { + return false; + } +} + + +template +template +inline bool Foam::PointData::updatePoint +( + const PointData& newPointInfo, + const scalar tol, + TrackingData& td +) +{ + if (pointEdgePoint::updatePoint(newPointInfo, tol, td)) + { + data_ = newPointInfo.data_; + + return true; + } + else + { + return false; + } +} + + +template +template +inline bool Foam::PointData::updateEdge +( + const polyMesh& mesh, + const label edgeI, + const label pointI, + const PointData& pointInfo, + const scalar tol, + TrackingData& td + +) +{ + if + ( + pointEdgePoint::updateEdge + ( + mesh, + edgeI, + pointI, + pointInfo, + tol, + td + ) + ) + { + data_ = pointInfo.data_; + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +inline bool Foam::PointData::operator== +( + const Foam::PointData& rhs +) +const +{ + return pointEdgePoint::operator==(rhs) && (data() == rhs.data()); +} + + +template +inline bool Foam::PointData::operator!= +( + const Foam::PointData& rhs +) +const +{ + return !(*this == rhs); +} + + +// ************************************************************************* //