ENH: PatchEdgeWave: new patchEdgeFaceRegions functionality

This commit is contained in:
mattijs
2013-05-28 17:27:08 +01:00
parent 99eb5ad5b4
commit 213d409f2e
7 changed files with 510 additions and 3 deletions

View File

@ -43,6 +43,9 @@ patchWave = $(algorithms)/PatchEdgeFaceWave
$(patchWave)/PatchEdgeFaceWaveName.C $(patchWave)/PatchEdgeFaceWaveName.C
$(patchWave)/patchEdgeFaceInfo.C $(patchWave)/patchEdgeFaceInfo.C
$(patchWave)/patchPatchDist.C $(patchWave)/patchPatchDist.C
$(patchWave)/patchEdgeFaceRegion.C
$(patchWave)/patchEdgeFaceRegions.C
meshWave = $(algorithms)/MeshWave meshWave = $(algorithms)/MeshWave
$(meshWave)/MeshWaveName.C $(meshWave)/MeshWaveName.C
@ -113,7 +116,6 @@ $(faceSources)/boundaryToFace/boundaryToFace.C
$(faceSources)/zoneToFace/zoneToFace.C $(faceSources)/zoneToFace/zoneToFace.C
$(faceSources)/boxToFace/boxToFace.C $(faceSources)/boxToFace/boxToFace.C
$(faceSources)/regionToFace/regionToFace.C $(faceSources)/regionToFace/regionToFace.C
$(faceSources)/regionToFace/patchEdgeFaceRegion.C
pointSources = sets/pointSources pointSources = sets/pointSources
$(pointSources)/labelToPoint/labelToPoint.C $(pointSources)/labelToPoint/labelToPoint.C

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 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 "patchEdgeFaceRegions.H"
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Foam::Ostream& os,
const Foam::patchEdgeFaceRegions& wDist
)
{
return os << wDist.regions_;
}
Foam::Istream& Foam::operator>>
(
Foam::Istream& is,
Foam::patchEdgeFaceRegions& wDist
)
{
return is >> wDist.regions_;
}
// ************************************************************************* //

View File

@ -0,0 +1,173 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 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::patchEdgeFaceRegions
Description
Transport of regions for use in PatchEdgeFaceWave.
Set element to -1 to denote blocked.
SourceFiles
patchEdgeFaceRegionsI.H
patchEdgeFaceRegions.C
\*---------------------------------------------------------------------------*/
#ifndef patchEdgeFaceRegions_H
#define patchEdgeFaceRegions_H
#include "labelList.H"
#include "scalar.H"
#include "tensor.H"
#include "labelPair.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class polyMesh;
/*---------------------------------------------------------------------------*\
Class patchEdgeFaceRegions Declaration
\*---------------------------------------------------------------------------*/
class patchEdgeFaceRegions
{
// Private data
//- region per point
labelList regions_;
public:
// Constructors
//- Construct null
inline patchEdgeFaceRegions();
//- Construct from regions
inline patchEdgeFaceRegions(const labelList&);
//- Construct from regions (on edge)
inline patchEdgeFaceRegions(const labelPair&);
// Member Functions
// Access
inline const labelList& regions() 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;
//- Apply rotation matrix
template<class Patch, class TrackingData>
inline void transform
(
const polyMesh& mesh,
const Patch& patch,
const tensor& rotTensor,
const scalar tol,
TrackingData& td
);
//- Influence of face on edge
template<class Patch, class TrackingData>
inline bool updateEdge
(
const polyMesh& mesh,
const Patch& patch,
const label edgeI,
const label faceI,
const patchEdgeFaceRegions& faceInfo,
const scalar tol,
TrackingData& td
);
//- New information for edge (from e.g. coupled edge)
template<class Patch, class TrackingData>
inline bool updateEdge
(
const polyMesh& mesh,
const Patch& patch,
const patchEdgeFaceRegions& edgeInfo,
const bool sameOrientation,
const scalar tol,
TrackingData& td
);
//- Influence of edge on face.
template<class Patch, class TrackingData>
inline bool updateFace
(
const polyMesh& mesh,
const Patch& patch,
const label faceI,
const label edgeI,
const patchEdgeFaceRegions& edgeInfo,
const scalar tol,
TrackingData& td
);
//- Same (like operator==)
template<class TrackingData>
inline bool equal(const patchEdgeFaceRegions&, TrackingData&) const;
// Member Operators
// Needed for List IO
inline bool operator==(const patchEdgeFaceRegions&) const;
inline bool operator!=(const patchEdgeFaceRegions&) const;
// IOstream Operators
friend Ostream& operator<<(Ostream&, const patchEdgeFaceRegions&);
friend Istream& operator>>(Istream&, patchEdgeFaceRegions&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "patchEdgeFaceRegionsI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,282 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 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"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::patchEdgeFaceRegions::patchEdgeFaceRegions()
{}
inline Foam::patchEdgeFaceRegions::patchEdgeFaceRegions
(
const labelList& regions
)
:
regions_(regions)
{}
inline Foam::patchEdgeFaceRegions::patchEdgeFaceRegions
(
const labelPair& regions
)
:
regions_(2)
{
regions_[0] = regions[0];
regions_[1] = regions[1];
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::labelList& Foam::patchEdgeFaceRegions::regions() const
{
return regions_;
}
template<class TrackingData>
inline bool Foam::patchEdgeFaceRegions::valid(TrackingData& td) const
{
return regions_.size() && (findIndex(regions_, labelMax) == -1);
}
template<class Patch, class TrackingData>
inline void Foam::patchEdgeFaceRegions::transform
(
const polyMesh& mesh,
const Patch& patch,
const tensor& rotTensor,
const scalar tol,
TrackingData& td
)
{}
template<class Patch, class TrackingData>
inline bool Foam::patchEdgeFaceRegions::updateEdge
(
const polyMesh& mesh,
const Patch& patch,
const label edgeI,
const label faceI,
const patchEdgeFaceRegions& faceInfo,
const scalar tol,
TrackingData& td
)
{
const face& f = patch.localFaces()[faceI];
const edge& e = patch.edges()[edgeI];
label index = findIndex(patch.faceEdges()[faceI], edgeI);
bool sameOrientation = (f[index] == e.start());
// Get information in edge-order
edge orientedInfo
(
faceInfo.regions_[index],
faceInfo.regions_[f.fcIndex(index)]
);
if (!sameOrientation)
{
orientedInfo.flip();
}
if (!faceInfo.valid(td))
{
FatalErrorIn("patchEdgeFaceRegions::updateEdge(..)")
<< "problem." << abort(FatalError);
}
if ((findIndex(orientedInfo, -1) != -1) || (findIndex(regions_, -1) != -1))
{
// Blocked edge/face
return false;
}
bool changed = false;
regions_.setSize(orientedInfo.size(), labelMax);
forAll(orientedInfo, i)
{
if (orientedInfo[i] != -1 && orientedInfo[i] < regions_[i])
{
regions_[i] = orientedInfo[i];
changed = true;
}
}
return changed;
}
template<class Patch, class TrackingData>
inline bool Foam::patchEdgeFaceRegions::updateEdge
(
const polyMesh& mesh,
const Patch& patch,
const patchEdgeFaceRegions& edgeInfo,
const bool sameOrientation,
const scalar tol,
TrackingData& td
)
{
// Get information in edge-order
edge orientedInfo(edgeInfo.regions_[0], edgeInfo.regions_[1]);
if (!sameOrientation)
{
orientedInfo.flip();
}
if (!edgeInfo.valid(td))
{
FatalErrorIn("patchEdgeFaceRegions::updateEdge(..)")
<< "problem." << abort(FatalError);
}
if ((findIndex(orientedInfo, -1) != -1) || (findIndex(regions_, -1) != -1))
{
// Blocked edge/face
return false;
}
bool changed = false;
regions_.setSize(orientedInfo.size(), labelMax);
forAll(orientedInfo, i)
{
if (orientedInfo[i] != -1 && orientedInfo[i] < regions_[i])
{
regions_[i] = orientedInfo[i];
changed = true;
}
}
return changed;
}
template<class Patch, class TrackingData>
inline bool Foam::patchEdgeFaceRegions::updateFace
(
const polyMesh& mesh,
const Patch& patch,
const label faceI,
const label edgeI,
const patchEdgeFaceRegions& edgeInfo,
const scalar tol,
TrackingData& td
)
{
const face& f = patch.localFaces()[faceI];
const edge& e = patch.edges()[edgeI];
// Find starting point of edge on face.
label index0 = findIndex(patch.faceEdges()[faceI], edgeI);
label index1 = f.fcIndex(index0);
bool sameOrientation = (f[index0] == e.start());
// Get information in face-order
edge orientedInfo
(
edgeInfo.regions_[0],
edgeInfo.regions_[1]
);
if (!sameOrientation)
{
orientedInfo.flip();
}
if (!edgeInfo.valid(td))
{
FatalErrorIn("patchEdgeFaceRegions::updateFace(..)")
<< "problem." << abort(FatalError);
}
if ((findIndex(orientedInfo, -1) != -1) || (findIndex(regions_, -1) != -1))
{
// Blocked edge/face
return false;
}
bool changed = false;
// Scale if needed
regions_.setSize(f.size(), labelMax);
if (orientedInfo[0] < regions_[index0])
{
regions_[index0] = orientedInfo[0];
changed = true;
}
if (orientedInfo[1] < regions_[index1])
{
regions_[index1] = orientedInfo[1];
changed = true;
}
return changed;
}
template<class TrackingData>
inline bool Foam::patchEdgeFaceRegions::equal
(
const patchEdgeFaceRegions& rhs,
TrackingData& td
) const
{
return operator==(rhs);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline bool Foam::patchEdgeFaceRegions::operator==
(
const Foam::patchEdgeFaceRegions& rhs
) const
{
return regions() == rhs.regions();
}
inline bool Foam::patchEdgeFaceRegions::operator!=
(
const Foam::patchEdgeFaceRegions& rhs
) const
{
return !(*this == rhs);
}
// ************************************************************************* //