ENH: collapseEdges: Use PointEdgeWave to propagate collapse information

This commit is contained in:
laurence
2012-04-20 17:07:10 +01:00
parent df636c4082
commit c0695e04fa
6 changed files with 1549 additions and 343 deletions

View File

@ -1,3 +1,4 @@
collapseEdges.C
pointEdgeCollapse/pointEdgeCollapse.C
EXE = $(FOAM_APPBIN)/collapseEdges

View File

@ -1,7 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-IpointEdgeCollapse
EXE_LIBS = \
-ldynamicMesh \
-lmeshTools
-lmeshTools \
-lfiniteVolume

View File

@ -0,0 +1,51 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ 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 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "pointEdgeCollapse.H"
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Foam::Ostream& os,
const Foam::pointEdgeCollapse& wDist
)
{
return os
<< wDist.collapsePoint_ << wDist.collapseIndex_;
}
Foam::Istream& Foam::operator>>
(
Foam::Istream& is,
Foam::pointEdgeCollapse& wDist
)
{
return is
>> wDist.collapsePoint_ >> wDist.collapseIndex_;
}
// ************************************************************************* //

View File

@ -0,0 +1,227 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ 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 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 <http://www.gnu.org/licenses/>.
Class
Foam::pointEdgeCollapse
Description
Determines length of string of edges walked to point.
SourceFiles
pointEdgeCollapseI.H
pointEdgeCollapse.C
\*---------------------------------------------------------------------------*/
#ifndef pointEdgeCollapse_H
#define pointEdgeCollapse_H
#include "point.H"
#include "tensor.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class polyPatch;
class polyMesh;
/*---------------------------------------------------------------------------*\
Class pointEdgeCollapse Declaration
\*---------------------------------------------------------------------------*/
class pointEdgeCollapse
{
// Private data
//- Collapse location
point collapsePoint_;
//- Collapse string index
label collapseIndex_;
// Private Member Functions
//- Evaluate distance to point.
template<class TrackingData>
inline bool update
(
const pointEdgeCollapse& w2,
const scalar tol,
TrackingData& td
);
//- Check for same coordinate
inline bool samePoint(const point& pt) const;
public:
// Constructors
//- Construct null
inline pointEdgeCollapse();
//- Construct from components
inline pointEdgeCollapse
(
const point& collapsePoint,
const label collapseIndex
);
// Member Functions
// Access
inline const point& collapsePoint() const;
inline label collapseIndex() const;
// Needed by meshWave
//- Check whether origin has been changed at all or
// still contains original (invalid) value.
template<class TrackingData>
inline bool valid(TrackingData& td) const;
//- Convert origin to relative vector to leaving point
// (= point coordinate)
template<class TrackingData>
inline void leaveDomain
(
const polyPatch& patch,
const label patchPointI,
const point& pos,
TrackingData& td
);
//- Convert relative origin to absolute by adding entering point
template<class TrackingData>
inline void enterDomain
(
const polyPatch& patch,
const label patchPointI,
const point& pos,
TrackingData& td
);
//- Apply rotation matrix to origin
template<class TrackingData>
inline void transform
(
const tensor& rotTensor,
TrackingData& td
);
//- Influence of edge on point
template<class TrackingData>
inline bool updatePoint
(
const polyMesh& mesh,
const label pointI,
const label edgeI,
const pointEdgeCollapse& edgeInfo,
const scalar tol,
TrackingData& td
);
//- Influence of different value on same point.
// Merge new and old info.
template<class TrackingData>
inline bool updatePoint
(
const polyMesh& mesh,
const label pointI,
const pointEdgeCollapse& newPointInfo,
const scalar tol,
TrackingData& td
);
//- Influence of different value on same point.
// No information about current position whatsoever.
template<class TrackingData>
inline bool updatePoint
(
const pointEdgeCollapse& newPointInfo,
const scalar tol,
TrackingData& td
);
//- Influence of point on edge.
template<class TrackingData>
inline bool updateEdge
(
const polyMesh& mesh,
const label edgeI,
const label pointI,
const pointEdgeCollapse& pointInfo,
const scalar tol,
TrackingData& td
);
//- Same (like operator==)
template<class TrackingData>
inline bool equal(const pointEdgeCollapse&, TrackingData&)
const;
// Member Operators
//Note: Used to determine whether to call update.
inline bool operator==(const pointEdgeCollapse&) const;
inline bool operator!=(const pointEdgeCollapse&) const;
// IOstream Operators
friend Ostream& operator<<(Ostream&, const pointEdgeCollapse&);
friend Istream& operator>>(Istream&, pointEdgeCollapse&);
};
//- Data associated with pointEdgeCollapse type are contiguous
template<>
inline bool contiguous<pointEdgeCollapse>()
{
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pointEdgeCollapseI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,313 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ 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 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "polyMesh.H"
#include "transform.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Update this with w2.
template<class TrackingData>
inline bool Foam::pointEdgeCollapse::update
(
const pointEdgeCollapse& w2,
const scalar tol,
TrackingData& td
)
{
if (!w2.valid(td))
{
FatalErrorIn("pointEdgeCollapse::update(..)")
<< "problem." << abort(FatalError);
}
if (w2.collapseIndex_ == -1)
{
// Not marked for collapse; only happens on edges.
return false;
}
if (!valid(td))
{
operator=(w2);
return true;
}
else
{
// Same coordinate. Same string?
if (w2.collapseIndex_ < collapseIndex_)
{
// Take over string index from w2 (and also coordinate but this
// was same)
operator=(w2);
return true;
}
else if (w2.collapseIndex_ == collapseIndex_)
{
bool identicalPoint = samePoint(w2.collapsePoint_);
bool nearer = magSqr(w2.collapsePoint_) < magSqr(collapsePoint_);
if (nearer)
{
operator=(w2);
}
if (identicalPoint)
{
return false;
}
else
{
return nearer;
}
}
else
{
return false;
}
// if (samePoint(w2.collapsePoint_))
// {
// // Same coordinate. Same string?
// if (w2.collapseIndex_ < collapseIndex_)
// {
// // Take over string index from w2 (and also coordinate but this
// // was same)
// operator=(w2);
// return true;
// }
// else
// {
// return false;
// }
// }
// else
// {
// // Find nearest coordinate
// if (magSqr(w2.collapsePoint_) < magSqr(collapsePoint_))
// {
// operator=(w2);
// return true;
// }
// else
// {
// return false;
// }
// }
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Null constructor
inline Foam::pointEdgeCollapse::pointEdgeCollapse()
:
collapsePoint_(GREAT, GREAT, GREAT),
collapseIndex_(-2)
{}
// Construct from origin, distance
inline Foam::pointEdgeCollapse::pointEdgeCollapse
(
const point& collapsePoint,
const label collapseIndex
)
:
collapsePoint_(collapsePoint),
collapseIndex_(collapseIndex)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::point& Foam::pointEdgeCollapse::collapsePoint() const
{
return collapsePoint_;
}
inline Foam::label Foam::pointEdgeCollapse::collapseIndex() const
{
return collapseIndex_;
}
inline bool Foam::pointEdgeCollapse::samePoint(const point& pt) const
{
bool isLegal1 = (cmptMin(collapsePoint_) < 0.5*GREAT);
bool isLegal2 = (cmptMin(pt) < 0.5*GREAT);
if (isLegal1 && isLegal2)
{
return mag(collapsePoint_ - pt) < 1e-9;//SMALL;
}
else
{
return isLegal1 == isLegal2;
}
}
template<class TrackingData>
inline bool Foam::pointEdgeCollapse::valid(TrackingData& td) const
{
return collapseIndex_ != -2;
}
template<class TrackingData>
inline void Foam::pointEdgeCollapse::leaveDomain
(
const polyPatch& patch,
const label patchPointI,
const point& coord,
TrackingData& td
)
{
collapsePoint_ -= coord;
}
template<class TrackingData>
inline void Foam::pointEdgeCollapse::transform
(
const tensor& rotTensor,
TrackingData& td
)
{
collapsePoint_ = Foam::transform(rotTensor, collapsePoint_);
}
// Update absolute geometric quantities. Note that distance (dist_)
// is not affected by leaving/entering domain.
template<class TrackingData>
inline void Foam::pointEdgeCollapse::enterDomain
(
const polyPatch& patch,
const label patchPointI,
const point& coord,
TrackingData& td
)
{
// back to absolute form
collapsePoint_ += coord;
}
// Update this with information from connected edge
template<class TrackingData>
inline bool Foam::pointEdgeCollapse::updatePoint
(
const polyMesh& mesh,
const label pointI,
const label edgeI,
const pointEdgeCollapse& edgeInfo,
const scalar tol,
TrackingData& td
)
{
return update(edgeInfo, tol, td);
}
// Update this with new information on same point
template<class TrackingData>
inline bool Foam::pointEdgeCollapse::updatePoint
(
const polyMesh& mesh,
const label pointI,
const pointEdgeCollapse& newPointInfo,
const scalar tol,
TrackingData& td
)
{
return update(newPointInfo, tol, td);
}
// Update this with new information on same point. No extra information.
template<class TrackingData>
inline bool Foam::pointEdgeCollapse::updatePoint
(
const pointEdgeCollapse& newPointInfo,
const scalar tol,
TrackingData& td
)
{
return update(newPointInfo, tol, td);
}
// Update this with information from connected point
template<class TrackingData>
inline bool Foam::pointEdgeCollapse::updateEdge
(
const polyMesh& mesh,
const label edgeI,
const label pointI,
const pointEdgeCollapse& pointInfo,
const scalar tol,
TrackingData& td
)
{
return update(pointInfo, tol, td);
}
template <class TrackingData>
inline bool Foam::pointEdgeCollapse::equal
(
const pointEdgeCollapse& rhs,
TrackingData& td
) const
{
return operator==(rhs);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline bool Foam::pointEdgeCollapse::operator==
(
const Foam::pointEdgeCollapse& rhs
) const
{
return
collapseIndex_ == rhs.collapseIndex_
&& samePoint(rhs.collapsePoint_);
}
inline bool Foam::pointEdgeCollapse::operator!=
(
const Foam::pointEdgeCollapse& rhs
) const
{
return !(*this == rhs);
}
// ************************************************************************* //