cellEdgeAddressing: Optimised memory usage
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -45,6 +45,34 @@ Foam::HashList<Type, Key, Hash>::HashList(const label size)
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type, class Key, class Hash>
|
||||
inline Foam::label Foam::HashList<Type, Key, Hash>::capacity() const
|
||||
{
|
||||
return List<Tuple2<Key, Type>>::size();
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class Key, class Hash>
|
||||
void Foam::HashList<Type, Key, Hash>::clear()
|
||||
{
|
||||
List<Tuple2<Key, Type>>::operator=
|
||||
(
|
||||
Tuple2<Key, Type>(nullKey, Type())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class Key, class Hash>
|
||||
void Foam::HashList<Type, Key, Hash>::resizeAndClear(const label newSize)
|
||||
{
|
||||
List<Tuple2<Key, Type>>::resize
|
||||
(
|
||||
newSize,
|
||||
Tuple2<Key, Type>(nullKey, Type())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class Key, class Hash>
|
||||
bool Foam::HashList<Type, Key, Hash>::insert(const Key& k, const Type& t)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -75,6 +75,15 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The size of the underlying list
|
||||
inline label capacity() const;
|
||||
|
||||
//- Clear all elements
|
||||
void clear();
|
||||
|
||||
//- Resize and clear all elements
|
||||
void resizeAndClear(const label newSize);
|
||||
|
||||
//- Insert into the hash list. Return true if the value was newly
|
||||
// inserted, or false if it was already there.
|
||||
bool insert(const Key& k, const Type& t);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,31 +28,28 @@ License
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
template<class Container>
|
||||
Foam::CompactListList<T>::CompactListList(const List<Container>& ll)
|
||||
template<class T2>
|
||||
Foam::CompactListList<T>::CompactListList(const UList<T2>& ll)
|
||||
:
|
||||
UCompactListList<T>(),
|
||||
offsets_(ll.size() + 1),
|
||||
offsets_(),
|
||||
m_()
|
||||
{
|
||||
label sumSize = 0;
|
||||
offsets_[0] = 0;
|
||||
forAll(ll, i)
|
||||
{
|
||||
sumSize += ll[i].size();
|
||||
offsets_[i+1] = sumSize;
|
||||
}
|
||||
UCompactListList<T>::setSizeAndValuesToListList(offsets_, m_, ll);
|
||||
|
||||
m_.setSize(sumSize);
|
||||
UCompactListList<T>::shallowCopy(UCompactListList<T>(offsets_, m_));
|
||||
}
|
||||
|
||||
label k = 0;
|
||||
forAll(ll, i)
|
||||
{
|
||||
forAll(ll[i], j)
|
||||
{
|
||||
m_[k++] = ll[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template<class T2>
|
||||
Foam::CompactListList<T>::CompactListList(const UIndirectList<T2>& ll)
|
||||
:
|
||||
UCompactListList<T>(),
|
||||
offsets_(),
|
||||
m_()
|
||||
{
|
||||
UCompactListList<T>::setSizeAndValuesToListList(offsets_, m_, ll);
|
||||
|
||||
UCompactListList<T>::shallowCopy(UCompactListList<T>(offsets_, m_));
|
||||
}
|
||||
@ -158,6 +155,26 @@ void Foam::CompactListList<T>::setSize(const labelUList& rowSizes)
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<class T2>
|
||||
void Foam::CompactListList<T>::setSize(const UList<T2>& ll)
|
||||
{
|
||||
UCompactListList<T>::setSizeToListList(offsets_, m_, ll);
|
||||
|
||||
UCompactListList<T>::shallowCopy(UCompactListList<T>(offsets_, m_));
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<class T2>
|
||||
void Foam::CompactListList<T>::setSize(const UIndirectList<T2>& ll)
|
||||
{
|
||||
UCompactListList<T>::setSizeToListList(offsets_, m_, ll);
|
||||
|
||||
UCompactListList<T>::shallowCopy(UCompactListList<T>(offsets_, m_));
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::CompactListList<T>::clear()
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -104,9 +104,13 @@ public:
|
||||
// the number of data and a value for all elements.
|
||||
inline CompactListList(const label mRows, const label nData, const T&);
|
||||
|
||||
//- Construct by converting given List<Container>
|
||||
template<class Container>
|
||||
CompactListList(const List<Container>&);
|
||||
//- Construct from UList<T2>
|
||||
template<class T2>
|
||||
CompactListList(const UList<T2>&);
|
||||
|
||||
//- Construct from UIndirectList<T2>
|
||||
template<class T2>
|
||||
CompactListList(const UIndirectList<T2>&);
|
||||
|
||||
//- Construct given list of row-sizes and a value for all elements
|
||||
CompactListList(const labelUList& rowSizes, const T&);
|
||||
@ -135,6 +139,15 @@ public:
|
||||
//- Reset size of CompactListList.
|
||||
void setSize(const labelUList& rowSizes);
|
||||
|
||||
//- Reset size of CompactListList to match the given UList<T2>
|
||||
template<class T2>
|
||||
void setSize(const UList<T2>&);
|
||||
|
||||
//- Reset size of CompactListList to match the given
|
||||
// UIndirectList<T2>
|
||||
template<class T2>
|
||||
void setSize(const UIndirectList<T2>&);
|
||||
|
||||
//- Reset size of CompactListList.
|
||||
// This form only allows contraction of the CompactListList.
|
||||
inline void resize(const label mRows);
|
||||
@ -148,6 +161,16 @@ public:
|
||||
//- Reset size of CompactListList.
|
||||
inline void resize(const labelUList& rowSizes);
|
||||
|
||||
//- Reset size of CompactListList to match the given
|
||||
// UList<T2>
|
||||
template<class T2>
|
||||
void resize(const UList<T2>&);
|
||||
|
||||
//- Reset size of CompactListList to match the given
|
||||
// UIndirectList<T2>
|
||||
template<class T2>
|
||||
void resize(const UIndirectList<T2>&);
|
||||
|
||||
//- Clear the CompactListList, i.e. set sizes to zero.
|
||||
void clear();
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -147,4 +147,20 @@ inline void Foam::CompactListList<T>::resize
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<class T2>
|
||||
void Foam::CompactListList<T>::resize(const UList<T2>& ll)
|
||||
{
|
||||
this->setSize(ll);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<class T2>
|
||||
void Foam::CompactListList<T>::resize(const UIndirectList<T2>& ll)
|
||||
{
|
||||
this->setSize(ll);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,6 +25,53 @@ License
|
||||
|
||||
#include "UCompactListList.H"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
template<class ListType, class ListListType>
|
||||
void Foam::UCompactListList<T>::setSizeToListList
|
||||
(
|
||||
ListType& offsets,
|
||||
ListType& m,
|
||||
const ListListType& ll
|
||||
)
|
||||
{
|
||||
offsets.setSize(ll.size() + 1);
|
||||
|
||||
label sumSize = 0;
|
||||
offsets[0] = 0;
|
||||
forAll(ll, i)
|
||||
{
|
||||
sumSize += ll[i].size();
|
||||
offsets[i+1] = sumSize;
|
||||
}
|
||||
|
||||
m.setSize(sumSize);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<class ListType, class ListListType>
|
||||
void Foam::UCompactListList<T>::setSizeAndValuesToListList
|
||||
(
|
||||
ListType& offsets,
|
||||
ListType& m,
|
||||
const ListListType& ll
|
||||
)
|
||||
{
|
||||
setSizeToListList(offsets, m, ll);
|
||||
|
||||
label k = 0;
|
||||
forAll(ll, i)
|
||||
{
|
||||
forAll(ll[i], j)
|
||||
{
|
||||
m[k++] = ll[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -73,6 +73,24 @@ public:
|
||||
//- Return a null UCompactListList
|
||||
inline static const UCompactListList<T>& null();
|
||||
|
||||
//- Set the sizes to match that of the given list-list
|
||||
template<class ListType, class ListListType>
|
||||
static void setSizeToListList
|
||||
(
|
||||
ListType& offsets,
|
||||
ListType& m,
|
||||
const ListListType& ll
|
||||
);
|
||||
|
||||
//- Set the sizes and values to match that of the given list-list
|
||||
template<class ListType, class ListListType>
|
||||
static void setSizeAndValuesToListList
|
||||
(
|
||||
ListType& offsets,
|
||||
ListType& m,
|
||||
const ListListType& ll
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -48,30 +48,63 @@ struct QuickHashEdge
|
||||
template<>
|
||||
const edge HashList<label, edge, QuickHashEdge>::nullKey(-labelMax, -labelMax);
|
||||
|
||||
// Workspace for addressing calculations
|
||||
struct cellEdgeAddressingWorkspace
|
||||
{
|
||||
HashList<label, edge, QuickHashEdge> edgeToCei;
|
||||
|
||||
DynamicList<bool> cOwnsIsSet;
|
||||
|
||||
cellEdgeAddressingWorkspace()
|
||||
:
|
||||
edgeToCei(0),
|
||||
cOwnsIsSet()
|
||||
{
|
||||
resizeAndClear(6, 12);
|
||||
}
|
||||
|
||||
void resizeAndClear(const label nCellFaces, const label nCellEdges)
|
||||
{
|
||||
if (edgeToCei.capacity() < nCellEdges)
|
||||
{
|
||||
edgeToCei.resizeAndClear(nCellEdges*6);
|
||||
}
|
||||
else
|
||||
{
|
||||
edgeToCei.clear();
|
||||
}
|
||||
|
||||
cOwnsIsSet.resize(nCellFaces);
|
||||
cOwnsIsSet = false;
|
||||
}
|
||||
}
|
||||
workspace_;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellEdgeAddressing::cellEdgeAddressing
|
||||
Foam::cellEdgeAddressingData::cellEdgeAddressingData
|
||||
(
|
||||
const cell& c,
|
||||
const faceList& fs,
|
||||
const bool cOwnsFirst
|
||||
)
|
||||
{
|
||||
// Compute the number of cell edges
|
||||
label nCellEdges = 0;
|
||||
forAll(c, cfi)
|
||||
{
|
||||
const face& f = fs[c[cfi]];
|
||||
// Allocate and initialise the addressing
|
||||
cfiAndFeiToCei_.resize(UIndirectList<face>(fs, c));
|
||||
ceiToCfiAndFei_ =
|
||||
List<Pair<labelPair>>
|
||||
(
|
||||
cfiAndFeiToCei_.m().size()/2,
|
||||
Pair<labelPair>(labelPair(-1, -1), labelPair(-1, -1))
|
||||
);
|
||||
|
||||
nCellEdges += f.size();
|
||||
}
|
||||
nCellEdges /= 2;
|
||||
// Resize and reset the workspace
|
||||
workspace_.resizeAndClear(c.size(), ceiToCfiAndFei_.size());
|
||||
|
||||
// Construct a map to enumerate the cell edges
|
||||
HashList<label, edge, QuickHashEdge> edgeToCei(nCellEdges*6);
|
||||
{
|
||||
label cellEdgei = 0;
|
||||
|
||||
@ -81,30 +114,22 @@ Foam::cellEdgeAddressing::cellEdgeAddressing
|
||||
|
||||
forAll(f, fei)
|
||||
{
|
||||
cellEdgei += edgeToCei.insert(f.faceEdge(fei), cellEdgei);
|
||||
cellEdgei +=
|
||||
workspace_.edgeToCei.insert(f.faceEdge(fei), cellEdgei);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate and initialise the addressing
|
||||
cfiAndFeiToCei_ = labelListList(c.size());
|
||||
ceiToCfiAndFei_ =
|
||||
List<Pair<labelPair>>
|
||||
(
|
||||
nCellEdges,
|
||||
Pair<labelPair>(labelPair(-1, -1), labelPair(-1, -1))
|
||||
);
|
||||
|
||||
// Copy data out of the map into the addressing
|
||||
forAll(c, cfi)
|
||||
{
|
||||
const face& f = fs[c[cfi]];
|
||||
|
||||
cfiAndFeiToCei_[cfi] = labelList(f.size(), -1);
|
||||
cfiAndFeiToCei_[cfi] = -1;
|
||||
|
||||
forAll(f, fei)
|
||||
{
|
||||
const label cei = edgeToCei[f.faceEdge(fei)];
|
||||
const label cei = workspace_.edgeToCei[f.faceEdge(fei)];
|
||||
|
||||
cfiAndFeiToCei_[cfi][fei] = cei;
|
||||
ceiToCfiAndFei_[cei]
|
||||
@ -117,15 +142,14 @@ Foam::cellEdgeAddressing::cellEdgeAddressing
|
||||
// Allocate and initialise the face signs
|
||||
cOwns_ = boolList(c.size(), false);
|
||||
cOwns_[0] = cOwnsFirst;
|
||||
boolList cOwnsIsSet(c.size(), false);
|
||||
cOwnsIsSet[0] = true;
|
||||
workspace_.cOwnsIsSet[0] = true;
|
||||
|
||||
// Compare cell-face-edges to determine face signs
|
||||
forAll(c, cfi)
|
||||
{
|
||||
const face& f = fs[c[cfi]];
|
||||
|
||||
if (!cOwnsIsSet[cfi]) continue;
|
||||
if (!workspace_.cOwnsIsSet[cfi]) continue;
|
||||
|
||||
forAll(f, fei)
|
||||
{
|
||||
@ -138,7 +162,7 @@ Foam::cellEdgeAddressing::cellEdgeAddressing
|
||||
];
|
||||
const label cfj = other[0], fej = other[1];
|
||||
|
||||
if (cOwnsIsSet[cfj]) continue;
|
||||
if (workspace_.cOwnsIsSet[cfj]) continue;
|
||||
|
||||
const label sign =
|
||||
edge::compare
|
||||
@ -148,7 +172,7 @@ Foam::cellEdgeAddressing::cellEdgeAddressing
|
||||
);
|
||||
|
||||
cOwns_[cfj] = sign < 0 ? cOwns_[cfi] : !cOwns_[cfi];
|
||||
cOwnsIsSet[cfj] = true;
|
||||
workspace_.cOwnsIsSet[cfj] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -201,28 +225,4 @@ void Foam::cellEdgeAddressingList::mapMesh(const polyMeshMap& map)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::cellEdgeAddressing& Foam::cellEdgeAddressingList::operator[]
|
||||
(
|
||||
const label celli
|
||||
) const
|
||||
{
|
||||
if (!list_.set(celli))
|
||||
{
|
||||
const cell& c = mesh().cells()[celli];
|
||||
const faceList& fs = mesh().faces();
|
||||
const labelList& fOwners = mesh().faceOwner();
|
||||
|
||||
list_.set
|
||||
(
|
||||
celli,
|
||||
new cellEdgeAddressing(c, fs, fOwners[c[0]] == celli)
|
||||
);
|
||||
}
|
||||
|
||||
return list_[celli];
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -22,6 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::cellEdgeAddressingData
|
||||
Foam::cellEdgeAddressing
|
||||
Foam::cellEdgeAddressingList
|
||||
|
||||
@ -39,6 +40,7 @@ SourceFiles
|
||||
|
||||
#include "DemandDrivenMeshObject.H"
|
||||
#include "polyMesh.H"
|
||||
#include "CompactListList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -48,19 +50,20 @@ namespace Foam
|
||||
class polyDistributionMap;
|
||||
class polyTopoChangeMap;
|
||||
class polyMeshMap;
|
||||
class cellEdgeAddressingList;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cellEdgeAddressing Declaration
|
||||
Class cellEdgeAddressingData Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cellEdgeAddressing
|
||||
class cellEdgeAddressingData
|
||||
{
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Map from cell-face-index and face-edge-index to cell-edge-index
|
||||
labelListList cfiAndFeiToCei_;
|
||||
CompactListList<label> cfiAndFeiToCei_;
|
||||
|
||||
//- Map from cell-edge-index to cell-face-index and face-edge-index.
|
||||
// Note that there are two sets of indices for each cell-edge,
|
||||
@ -81,7 +84,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from a cell and its faces
|
||||
cellEdgeAddressing
|
||||
cellEdgeAddressingData
|
||||
(
|
||||
const cell& c,
|
||||
const faceList& fs,
|
||||
@ -92,7 +95,49 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Map from cell-face-index and face-edge-index to cell-edge-index
|
||||
inline const labelListList& cfiAndFeiToCei() const;
|
||||
inline const CompactListList<label>& cfiAndFeiToCei() const;
|
||||
|
||||
//- Map from cell-edge-index to cell-face-index and face-edge-index
|
||||
inline const List<Pair<labelPair>>& ceiToCfiAndFei() const;
|
||||
|
||||
//- For each cell-face, whether or not the cell owns it
|
||||
inline const boolList& cOwns() const;
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cellEdgeAddressing Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cellEdgeAddressing
|
||||
{
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- The cell edge addressing list
|
||||
const cellEdgeAddressingList& cAddrs_;
|
||||
|
||||
//- The cell index
|
||||
const label celli_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from the cell edge addressing list and a cell index
|
||||
inline cellEdgeAddressing
|
||||
(
|
||||
const cellEdgeAddressingList& cAddrs,
|
||||
const label celli
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Map from cell-face-index and face-edge-index to cell-edge-index
|
||||
inline const CompactListList<label>& cfiAndFeiToCei() const;
|
||||
|
||||
//- Map from cell-edge-index to cell-face-index and face-edge-index
|
||||
inline const List<Pair<labelPair>>& ceiToCfiAndFei() const;
|
||||
@ -118,7 +163,7 @@ class cellEdgeAddressingList
|
||||
// Private Data
|
||||
|
||||
//- Edge addressing for each cell
|
||||
mutable PtrList<cellEdgeAddressing> list_;
|
||||
mutable PtrList<cellEdgeAddressingData> list_;
|
||||
|
||||
|
||||
protected:
|
||||
@ -155,8 +200,11 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Get the addressing data for a given cell
|
||||
const cellEdgeAddressingData& data(const label celli) const;
|
||||
|
||||
//- Get the addressing for a given cell
|
||||
const cellEdgeAddressing& operator[](const label celli) const;
|
||||
inline const cellEdgeAddressing operator[](const label celli) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,26 +25,88 @@ License
|
||||
|
||||
#include "cellEdgeAddressing.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::cellEdgeAddressing::cellEdgeAddressing
|
||||
(
|
||||
const cellEdgeAddressingList& cAddrs,
|
||||
const label celli
|
||||
)
|
||||
:
|
||||
cAddrs_(cAddrs),
|
||||
celli_(celli)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline const Foam::labelListList&
|
||||
Foam::cellEdgeAddressing::cfiAndFeiToCei() const
|
||||
inline const Foam::CompactListList<Foam::label>&
|
||||
Foam::cellEdgeAddressingData::cfiAndFeiToCei() const
|
||||
{
|
||||
return cfiAndFeiToCei_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::List<Foam::Pair<Foam::labelPair>>&
|
||||
Foam::cellEdgeAddressing::ceiToCfiAndFei() const
|
||||
Foam::cellEdgeAddressingData::ceiToCfiAndFei() const
|
||||
{
|
||||
return ceiToCfiAndFei_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::boolList& Foam::cellEdgeAddressing::cOwns() const
|
||||
inline const Foam::boolList& Foam::cellEdgeAddressingData::cOwns() const
|
||||
{
|
||||
return cOwns_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::CompactListList<Foam::label>&
|
||||
Foam::cellEdgeAddressing::cfiAndFeiToCei() const
|
||||
{
|
||||
return cAddrs_.data(celli_).cfiAndFeiToCei();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::List<Foam::Pair<Foam::labelPair>>&
|
||||
Foam::cellEdgeAddressing::ceiToCfiAndFei() const
|
||||
{
|
||||
return cAddrs_.data(celli_).ceiToCfiAndFei();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::boolList& Foam::cellEdgeAddressing::cOwns() const
|
||||
{
|
||||
return cAddrs_.data(celli_).cOwns();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::cellEdgeAddressingData&
|
||||
Foam::cellEdgeAddressingList::data(const label celli) const
|
||||
{
|
||||
if (!list_.set(celli))
|
||||
{
|
||||
const cell& c = mesh().cells()[celli];
|
||||
const faceList& fs = mesh().faces();
|
||||
const labelList& fOwners = mesh().faceOwner();
|
||||
|
||||
list_.set
|
||||
(
|
||||
celli,
|
||||
new cellEdgeAddressingData(c, fs, fOwners[c[0]] == celli)
|
||||
);
|
||||
}
|
||||
|
||||
return list_[celli];
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
inline const Foam::cellEdgeAddressing
|
||||
Foam::cellEdgeAddressingList::operator[](const label celli) const
|
||||
{
|
||||
return cellEdgeAddressing(*this, celli);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -139,7 +139,7 @@ Foam::labelListList Foam::cutPoly::cellCuts
|
||||
}
|
||||
|
||||
// Get local cell-face-edge addressing
|
||||
const labelListList& cfiAndFeiToCei = cAddr.cfiAndFeiToCei();
|
||||
const CompactListList<label>& cfiAndFeiToCei = cAddr.cfiAndFeiToCei();
|
||||
const List<Pair<labelPair>>& ceiToCfiAndFei = cAddr.ceiToCfiAndFei();
|
||||
const boolList& cOwns = cAddr.cOwns();
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -55,17 +55,22 @@ Foam::cutPolyIsoSurface::cutPolyIsoSurface
|
||||
{
|
||||
cpuTime cpuTime;
|
||||
|
||||
// Request the cell-edge addressing engine
|
||||
const cellEdgeAddressingList& cAddrs = cellEdgeAddressingList::New(mesh);
|
||||
|
||||
// Cut the faces
|
||||
List<List<labelPair>> faceCuts(mesh.faces().size());
|
||||
forAll(mesh.faces(), facei)
|
||||
{
|
||||
faceCuts[facei] =
|
||||
cutPoly::faceCuts(mesh.faces()[facei], pAlphas, isoAlpha);
|
||||
cutPoly::faceCuts
|
||||
(
|
||||
mesh.faces()[facei],
|
||||
pAlphas,
|
||||
isoAlpha
|
||||
);
|
||||
}
|
||||
|
||||
// Request the cell-edge addressing engine
|
||||
const cellEdgeAddressingList& cAddrs = cellEdgeAddressingList::New(mesh);
|
||||
|
||||
// Cut the cells
|
||||
List<labelListList> cellCuts(mesh.cells().size());
|
||||
label nCutCells = 0;
|
||||
@ -81,6 +86,7 @@ Foam::cutPolyIsoSurface::cutPolyIsoSurface
|
||||
pAlphas,
|
||||
isoAlpha
|
||||
);
|
||||
|
||||
nCutCells += !cellCuts[celli].empty();
|
||||
};
|
||||
if (!isNull<labelList>(zoneIDs))
|
||||
@ -111,26 +117,20 @@ Foam::cutPolyIsoSurface::cutPolyIsoSurface
|
||||
DynamicList<label> faceCellsDyn(nAllocate);
|
||||
forAll(mesh.cells(), celli)
|
||||
{
|
||||
const cell& c = mesh.cells()[celli];
|
||||
|
||||
const labelListList& cCuts = cellCuts[celli];
|
||||
|
||||
const List<Pair<labelPair>>& ceiToCfiAndFei =
|
||||
cAddrs[celli].ceiToCfiAndFei();
|
||||
|
||||
forAll(cCuts, cuti)
|
||||
forAll(cellCuts[celli], cellCuti)
|
||||
{
|
||||
if (cCuts[cuti].size() < 3) continue;
|
||||
if (cellCuts[celli][cellCuti].size() < 3) continue;
|
||||
|
||||
facesDyn.append(face(cCuts[cuti].size()));
|
||||
facesDyn.append(face(cellCuts[celli][cellCuti].size()));
|
||||
|
||||
forAll(cCuts[cuti], i)
|
||||
forAll(cellCuts[celli][cellCuti], i)
|
||||
{
|
||||
const label cei = cCuts[cuti][i];
|
||||
const label cfi = ceiToCfiAndFei[cei][0][0];
|
||||
const label fei = ceiToCfiAndFei[cei][0][1];
|
||||
const label cei = cellCuts[celli][cellCuti][i];
|
||||
const label cfi = cAddrs[celli].ceiToCfiAndFei()[cei][0][0];
|
||||
const label fei = cAddrs[celli].ceiToCfiAndFei()[cei][0][1];
|
||||
|
||||
const edge e = mesh.faces()[c[cfi]].faceEdge(fei);
|
||||
const edge e =
|
||||
mesh.faces()[mesh.cells()[celli][cfi]].faceEdge(fei);
|
||||
|
||||
EdgeMap<label>::iterator iter = meshEdgePoint.find(e);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user