mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: simplify ensightCells/ensightFaces with labelRange
- can avoid allocating/reallocating SubList STYLE: don't need NamedEnum for ensightCells, ensightFaces lookup
This commit is contained in:
@ -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) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -27,24 +27,13 @@ License
|
|||||||
#include "error.H"
|
#include "error.H"
|
||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
#include "cellModeller.H"
|
#include "cellModeller.H"
|
||||||
#include "demandDrivenData.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const Foam::label Foam::ensightCells::nTypes = 5;
|
const Foam::label Foam::ensightCells::nTypes = 5;
|
||||||
|
|
||||||
namespace Foam
|
const char* Foam::ensightCells::elemNames[5] =
|
||||||
{
|
{ "tetra4", "pyramid5", "penta6", "hexa8", "nfaced" };
|
||||||
template<>
|
|
||||||
const char* Foam::NamedEnum
|
|
||||||
<
|
|
||||||
Foam::ensightCells::elemType,
|
|
||||||
5
|
|
||||||
>::names[] = { "tetra4", "pyramid5", "penta6", "hexa8", "nfaced" };
|
|
||||||
}
|
|
||||||
|
|
||||||
const Foam::NamedEnum<Foam::ensightCells::elemType, 5>
|
|
||||||
Foam::ensightCells::elemEnum;
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -63,9 +52,8 @@ void Foam::ensightCells::resizeAll()
|
|||||||
n = 0;
|
n = 0;
|
||||||
forAll(sizes_, typei)
|
forAll(sizes_, typei)
|
||||||
{
|
{
|
||||||
deleteDemandDrivenData(lists_[typei]);
|
slices_[typei].setStart(n);
|
||||||
|
slices_[typei].setSize(sizes_[typei]);
|
||||||
lists_[typei] = new SubList<label>(address_, sizes_[typei], n);
|
|
||||||
|
|
||||||
n += sizes_[typei];
|
n += sizes_[typei];
|
||||||
}
|
}
|
||||||
@ -78,16 +66,10 @@ Foam::ensightCells::ensightCells(const label partIndex)
|
|||||||
:
|
:
|
||||||
index_(partIndex),
|
index_(partIndex),
|
||||||
address_(),
|
address_(),
|
||||||
sizes_(Zero),
|
slices_(),
|
||||||
lists_()
|
sizes_(Zero)
|
||||||
{
|
{
|
||||||
// Ensure sub-lists are properly initialized to nullptr
|
resizeAll(); // adjust allocation/sizing
|
||||||
forAll(lists_, typei)
|
|
||||||
{
|
|
||||||
lists_[typei] = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
resizeAll(); // adjust allocation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,22 +77,16 @@ Foam::ensightCells::ensightCells(const ensightCells& obj)
|
|||||||
:
|
:
|
||||||
index_(obj.index_),
|
index_(obj.index_),
|
||||||
address_(obj.address_),
|
address_(obj.address_),
|
||||||
sizes_(),
|
slices_(),
|
||||||
lists_()
|
sizes_()
|
||||||
{
|
{
|
||||||
// Ensure sub-lists are properly initialized to nullptr
|
// Save the total (reduced) sizes
|
||||||
forAll(lists_, typei)
|
|
||||||
{
|
|
||||||
lists_[typei] = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Total (reduced) sizes
|
|
||||||
FixedList<label, 5> totSizes = obj.sizes_;
|
FixedList<label, 5> totSizes = obj.sizes_;
|
||||||
|
|
||||||
// Local sizes
|
// Need local sizes for the resize operation
|
||||||
this->sizes_ = obj.sizes();
|
this->sizes_ = obj.sizes();
|
||||||
|
|
||||||
resizeAll(); // adjust allocation
|
resizeAll(); // adjust allocation/sizing
|
||||||
|
|
||||||
// Restore total (reduced) sizes
|
// Restore total (reduced) sizes
|
||||||
this->sizes_ = totSizes;
|
this->sizes_ = totSizes;
|
||||||
@ -120,13 +96,7 @@ Foam::ensightCells::ensightCells(const ensightCells& obj)
|
|||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::ensightCells::~ensightCells()
|
Foam::ensightCells::~ensightCells()
|
||||||
{
|
{}
|
||||||
forAll(lists_, typei)
|
|
||||||
{
|
|
||||||
deleteDemandDrivenData(lists_[typei]);
|
|
||||||
}
|
|
||||||
address_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
@ -134,27 +104,15 @@ Foam::ensightCells::~ensightCells()
|
|||||||
Foam::FixedList<Foam::label, 5> Foam::ensightCells::sizes() const
|
Foam::FixedList<Foam::label, 5> Foam::ensightCells::sizes() const
|
||||||
{
|
{
|
||||||
FixedList<label, 5> count;
|
FixedList<label, 5> count;
|
||||||
forAll(lists_, typei)
|
forAll(slices_, typei)
|
||||||
{
|
{
|
||||||
count[typei] = lists_[typei]->size();
|
count[typei] = slices_[typei].size();
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::ensightCells::offset(const enum elemType what) const
|
|
||||||
{
|
|
||||||
label n = 0;
|
|
||||||
for (label typei = 0; typei < label(what); ++typei)
|
|
||||||
{
|
|
||||||
n += lists_[typei]->size();
|
|
||||||
}
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::ensightCells::total() const
|
Foam::label Foam::ensightCells::total() const
|
||||||
{
|
{
|
||||||
label n = 0;
|
label n = 0;
|
||||||
@ -175,9 +133,10 @@ void Foam::ensightCells::clear()
|
|||||||
|
|
||||||
void Foam::ensightCells::reduce()
|
void Foam::ensightCells::reduce()
|
||||||
{
|
{
|
||||||
|
// No listCombineGather, listCombineScatter for FixedList
|
||||||
forAll(sizes_, typei)
|
forAll(sizes_, typei)
|
||||||
{
|
{
|
||||||
sizes_[typei] = lists_[typei]->size();
|
sizes_[typei] = slices_[typei].size();
|
||||||
Foam::reduce(sizes_[typei], sumOp<label>());
|
Foam::reduce(sizes_[typei], sumOp<label>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,9 +144,13 @@ void Foam::ensightCells::reduce()
|
|||||||
|
|
||||||
void Foam::ensightCells::sort()
|
void Foam::ensightCells::sort()
|
||||||
{
|
{
|
||||||
forAll(lists_, typei)
|
forAll(slices_, typei)
|
||||||
{
|
{
|
||||||
Foam::sort(*(lists_[typei]));
|
if (slices_[typei].size())
|
||||||
|
{
|
||||||
|
SubList<label> idLst(address_, slices_[typei]);
|
||||||
|
Foam::sort(idLst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +203,7 @@ void Foam::ensightCells::classify
|
|||||||
}
|
}
|
||||||
|
|
||||||
resizeAll(); // adjust allocation
|
resizeAll(); // adjust allocation
|
||||||
sizes_ = Zero; // reset sizes
|
sizes_ = Zero; // reset sizes - use for local indexing here
|
||||||
|
|
||||||
// Assign cell-id per shape type
|
// Assign cell-id per shape type
|
||||||
for (label listi = 0; listi < sz; ++listi)
|
for (label listi = 0; listi < sz; ++listi)
|
||||||
@ -267,7 +230,10 @@ void Foam::ensightCells::classify
|
|||||||
}
|
}
|
||||||
|
|
||||||
// eg, the processor local cellId
|
// eg, the processor local cellId
|
||||||
lists_[what]->operator[](sizes_[what]++) = id;
|
UList<label> slice = address_[slices_[what]];
|
||||||
|
|
||||||
|
slice[sizes_[what]] = id;
|
||||||
|
sizes_[what]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -35,8 +35,6 @@ Description
|
|||||||
|
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
#include "FixedList.H"
|
#include "FixedList.H"
|
||||||
#include "SubList.H"
|
|
||||||
#include "NamedEnum.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -58,18 +56,18 @@ public:
|
|||||||
//- Addressable ensight element types
|
//- Addressable ensight element types
|
||||||
enum elemType
|
enum elemType
|
||||||
{
|
{
|
||||||
TETRA4,
|
TETRA4, //!< "tetra4"
|
||||||
PYRAMID5,
|
PYRAMID5, //!< "pyramid5"
|
||||||
PENTA6,
|
PENTA6, //!< "penta6"
|
||||||
HEXA8,
|
HEXA8, //!< "hexa8"
|
||||||
NFACED
|
NFACED //!< "nfaced"
|
||||||
};
|
};
|
||||||
|
|
||||||
//- Number of element types (5)
|
//- Number of element types (5)
|
||||||
static const label nTypes;
|
static const label nTypes;
|
||||||
|
|
||||||
//- The Ensight names for each element type
|
//- The ensight element type names
|
||||||
static const NamedEnum<elemType, 5> elemEnum;
|
static const char* elemNames[5];
|
||||||
|
|
||||||
|
|
||||||
// Static Member Functions
|
// Static Member Functions
|
||||||
@ -86,17 +84,16 @@ private:
|
|||||||
// The ensight part number is typically this value +1.
|
// The ensight part number is typically this value +1.
|
||||||
label index_;
|
label index_;
|
||||||
|
|
||||||
//- Linear list of ids, sub-sectioned per element type via SubLists
|
//- Linear list of ids, sub-sectioned per element type by sub-lists
|
||||||
labelList address_;
|
labelList address_;
|
||||||
|
|
||||||
|
//- Slices (sub-lists) of the address ids for each element type.
|
||||||
|
FixedList<labelRange, 5> slices_;
|
||||||
|
|
||||||
//- List of global sizes for each element type.
|
//- List of global sizes for each element type.
|
||||||
// Used temporarily for local sizes when building the element lists.
|
// Used temporarily for local sizes when building the element lists.
|
||||||
FixedList<label, 5> sizes_;
|
FixedList<label, 5> sizes_;
|
||||||
|
|
||||||
//- List of ids for each element type.
|
|
||||||
// Managed via pointers, since a SubList cannot be relocated/resized.
|
|
||||||
FixedList<SubList<label>*, 5> lists_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -115,7 +112,7 @@ public:
|
|||||||
ensightCells(label partIndex = 0);
|
ensightCells(label partIndex = 0);
|
||||||
|
|
||||||
//- Copy constructor. Needed for lists etc.
|
//- Copy constructor. Needed for lists etc.
|
||||||
ensightCells(const ensightCells&);
|
ensightCells(const ensightCells& obj);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -135,6 +132,9 @@ public:
|
|||||||
//- The processor local size of all elements.
|
//- The processor local size of all elements.
|
||||||
inline label size() const;
|
inline label size() const;
|
||||||
|
|
||||||
|
//- The processor local size of the specified element type.
|
||||||
|
inline label size(const enum elemType) const;
|
||||||
|
|
||||||
//- The global number of the specified element type.
|
//- The global number of the specified element type.
|
||||||
// This value is only meaningful after a reduce operation.
|
// This value is only meaningful after a reduce operation.
|
||||||
inline label total(const enum elemType) const;
|
inline label total(const enum elemType) const;
|
||||||
@ -151,23 +151,23 @@ public:
|
|||||||
FixedList<label, 5> sizes() const;
|
FixedList<label, 5> sizes() const;
|
||||||
|
|
||||||
//- Processor local starting offset of element type.
|
//- Processor local starting offset of element type.
|
||||||
label offset(const enum elemType what) const;
|
inline label offset(const enum elemType what) const;
|
||||||
|
|
||||||
//- Return the (local) cell ids of the specified element type
|
//- Return the (local) cell ids of the specified element type
|
||||||
inline const labelUList& cellIds(const enum elemType) const;
|
inline const labelUList cellIds(const enum elemType) const;
|
||||||
|
|
||||||
//- Return the cell ids of all elements
|
//- Return the cell ids of all elements
|
||||||
inline const labelUList& cellIds() const;
|
inline const labelUList& cellIds() const;
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
//- Classify cell types and set the element lists.
|
//- Classify cell types and set the element lists.
|
||||||
// The optional indirect addressing can be used when classifying
|
// The optional indirect addressing can be used when classifying
|
||||||
// groups of cells (eg, from a cellZone etc).
|
// groups of cells (eg, from a cellZone etc).
|
||||||
void classify
|
void classify
|
||||||
(
|
(
|
||||||
const polyMesh&,
|
const polyMesh& mesh,
|
||||||
const labelUList& addressing = labelUList::null()
|
const labelUList& addressing = labelUList::null()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ License
|
|||||||
|
|
||||||
inline const char* Foam::ensightCells::key(const enum elemType what)
|
inline const char* Foam::ensightCells::key(const enum elemType what)
|
||||||
{
|
{
|
||||||
return elemEnum[what];
|
return elemNames[what];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -63,20 +63,24 @@ inline Foam::label Foam::ensightCells::total(const enum elemType what) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::labelUList& Foam::ensightCells::cellIds
|
inline Foam::label Foam::ensightCells::size(const enum elemType what) const
|
||||||
|
{
|
||||||
|
return slices_[what].size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::label Foam::ensightCells::offset(const enum elemType what) const
|
||||||
|
{
|
||||||
|
return slices_[what].start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::labelUList Foam::ensightCells::cellIds
|
||||||
(
|
(
|
||||||
const enum elemType what
|
const enum elemType what
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (!lists_[what])
|
return address_[slices_[what]];
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Accessing unallocated sublist for elem-type: "
|
|
||||||
<< elemEnum[what]
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(lists_[what]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -27,24 +27,13 @@ License
|
|||||||
#include "error.H"
|
#include "error.H"
|
||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
#include "demandDrivenData.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const Foam::label Foam::ensightFaces::nTypes = 3;
|
const Foam::label Foam::ensightFaces::nTypes = 3;
|
||||||
|
|
||||||
namespace Foam
|
const char* Foam::ensightFaces::elemNames[3] =
|
||||||
{
|
{ "tria3", "quad4", "nsided" };
|
||||||
template<>
|
|
||||||
const char* Foam::NamedEnum
|
|
||||||
<
|
|
||||||
Foam::ensightFaces::elemType,
|
|
||||||
3
|
|
||||||
>::names[] = { "tria3", "quad4", "nsided" };
|
|
||||||
}
|
|
||||||
|
|
||||||
const Foam::NamedEnum<Foam::ensightFaces::elemType, 3>
|
|
||||||
Foam::ensightFaces::elemEnum;
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -99,9 +88,8 @@ void Foam::ensightFaces::resizeAll()
|
|||||||
n = 0;
|
n = 0;
|
||||||
forAll(sizes_, typei)
|
forAll(sizes_, typei)
|
||||||
{
|
{
|
||||||
deleteDemandDrivenData(lists_[typei]);
|
slices_[typei].setStart(n);
|
||||||
|
slices_[typei].setSize(sizes_[typei]);
|
||||||
lists_[typei] = new SubList<label>(address_, sizes_[typei], n);
|
|
||||||
|
|
||||||
n += sizes_[typei];
|
n += sizes_[typei];
|
||||||
}
|
}
|
||||||
@ -118,16 +106,10 @@ Foam::ensightFaces::ensightFaces(label partIndex)
|
|||||||
index_(partIndex),
|
index_(partIndex),
|
||||||
address_(),
|
address_(),
|
||||||
flipMap_(),
|
flipMap_(),
|
||||||
sizes_(Zero),
|
slices_(),
|
||||||
lists_()
|
sizes_(Zero)
|
||||||
{
|
{
|
||||||
// Ensure sub-lists are properly initialized to nullptr
|
resizeAll(); // adjust allocation/sizing
|
||||||
forAll(lists_, typei)
|
|
||||||
{
|
|
||||||
lists_[typei] = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
resizeAll(); // adjust allocation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,22 +118,16 @@ Foam::ensightFaces::ensightFaces(const ensightFaces& obj)
|
|||||||
index_(obj.index_),
|
index_(obj.index_),
|
||||||
address_(obj.address_),
|
address_(obj.address_),
|
||||||
flipMap_(obj.flipMap_),
|
flipMap_(obj.flipMap_),
|
||||||
sizes_(),
|
slices_(),
|
||||||
lists_()
|
sizes_()
|
||||||
{
|
{
|
||||||
// Ensure sub-lists are properly initialized to nullptr
|
// Save the total (reduced) sizes
|
||||||
forAll(lists_, typei)
|
|
||||||
{
|
|
||||||
lists_[typei] = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Total (reduced) sizes
|
|
||||||
FixedList<label, 3> totSizes = obj.sizes_;
|
FixedList<label, 3> totSizes = obj.sizes_;
|
||||||
|
|
||||||
// Local sizes
|
// Need local sizes for the resize operation
|
||||||
this->sizes_ = obj.sizes();
|
this->sizes_ = obj.sizes();
|
||||||
|
|
||||||
resizeAll(); // adjust allocation
|
resizeAll(); // adjust allocation/sizing
|
||||||
|
|
||||||
// Restore total (reduced) sizes
|
// Restore total (reduced) sizes
|
||||||
this->sizes_ = totSizes;
|
this->sizes_ = totSizes;
|
||||||
@ -161,14 +137,7 @@ Foam::ensightFaces::ensightFaces(const ensightFaces& obj)
|
|||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::ensightFaces::~ensightFaces()
|
Foam::ensightFaces::~ensightFaces()
|
||||||
{
|
{}
|
||||||
forAll(lists_, typei)
|
|
||||||
{
|
|
||||||
deleteDemandDrivenData(lists_[typei]);
|
|
||||||
}
|
|
||||||
address_.clear();
|
|
||||||
flipMap_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
@ -176,27 +145,15 @@ Foam::ensightFaces::~ensightFaces()
|
|||||||
Foam::FixedList<Foam::label, 3> Foam::ensightFaces::sizes() const
|
Foam::FixedList<Foam::label, 3> Foam::ensightFaces::sizes() const
|
||||||
{
|
{
|
||||||
FixedList<label, 3> count;
|
FixedList<label, 3> count;
|
||||||
forAll(lists_, typei)
|
forAll(slices_, typei)
|
||||||
{
|
{
|
||||||
count[typei] = lists_[typei]->size();
|
count[typei] = slices_[typei].size();
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::ensightFaces::offset(const enum elemType what) const
|
|
||||||
{
|
|
||||||
label n = 0;
|
|
||||||
for (label typei = 0; typei < label(what); ++typei)
|
|
||||||
{
|
|
||||||
n += lists_[typei]->size();
|
|
||||||
}
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::ensightFaces::total() const
|
Foam::label Foam::ensightFaces::total() const
|
||||||
{
|
{
|
||||||
label n = 0;
|
label n = 0;
|
||||||
@ -217,9 +174,10 @@ void Foam::ensightFaces::clear()
|
|||||||
|
|
||||||
void Foam::ensightFaces::reduce()
|
void Foam::ensightFaces::reduce()
|
||||||
{
|
{
|
||||||
|
// No listCombineGather, listCombineScatter for FixedList
|
||||||
forAll(sizes_, typei)
|
forAll(sizes_, typei)
|
||||||
{
|
{
|
||||||
sizes_[typei] = lists_[typei]->size();
|
sizes_[typei] = slices_[typei].size();
|
||||||
Foam::reduce(sizes_[typei], sumOp<label>());
|
Foam::reduce(sizes_[typei], sumOp<label>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,20 +187,15 @@ void Foam::ensightFaces::sort()
|
|||||||
{
|
{
|
||||||
if (flipMap_.size() == address_.size())
|
if (flipMap_.size() == address_.size())
|
||||||
{
|
{
|
||||||
// sort flip map too
|
// Must sort flip map as well
|
||||||
|
|
||||||
labelList order;
|
labelList order;
|
||||||
label start = 0;
|
|
||||||
|
|
||||||
forAll(lists_, typei)
|
forAll(slices_, typei)
|
||||||
{
|
{
|
||||||
SubList<label>& idLst = *(lists_[typei]);
|
if (slices_[typei].size())
|
||||||
const label sz = idLst.size();
|
|
||||||
|
|
||||||
if (sz)
|
|
||||||
{
|
{
|
||||||
SubList<bool> flip(flipMap_, sz, start);
|
SubList<label> idLst(address_, slices_[typei]);
|
||||||
start += sz; // for next sub-list
|
SubList<bool> flip(flipMap_, slices_[typei]);
|
||||||
|
|
||||||
Foam::sortedOrder(idLst, order);
|
Foam::sortedOrder(idLst, order);
|
||||||
|
|
||||||
@ -254,11 +207,16 @@ void Foam::ensightFaces::sort()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no flip-maps, simpler to sort
|
// no flip-maps, simpler to sort
|
||||||
forAll(lists_, typei)
|
forAll(slices_, typei)
|
||||||
{
|
{
|
||||||
Foam::sort(*(lists_[typei]));
|
if (slices_[typei].size())
|
||||||
|
{
|
||||||
|
SubList<label> idLst(address_, slices_[typei]);
|
||||||
|
Foam::sort(idLst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
flipMap_.clear(); // for safety
|
|
||||||
|
flipMap_.clear(); // for extra safety
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +236,7 @@ void Foam::ensightFaces::classify(const faceList& faces)
|
|||||||
}
|
}
|
||||||
|
|
||||||
resizeAll(); // adjust allocation
|
resizeAll(); // adjust allocation
|
||||||
sizes_ = Zero; // reset sizes
|
sizes_ = Zero; // reset sizes - use for local indexing here
|
||||||
|
|
||||||
// Assign face-id per shape type
|
// Assign face-id per shape type
|
||||||
for (label listi = 0; listi < sz; ++listi)
|
for (label listi = 0; listi < sz; ++listi)
|
||||||
@ -318,7 +276,7 @@ void Foam::ensightFaces::classify
|
|||||||
}
|
}
|
||||||
|
|
||||||
resizeAll(); // adjust allocation
|
resizeAll(); // adjust allocation
|
||||||
sizes_ = Zero; // reset sizes
|
sizes_ = Zero; // reset sizes - use for local indexing here
|
||||||
|
|
||||||
if (useFlip)
|
if (useFlip)
|
||||||
{
|
{
|
||||||
@ -330,11 +288,11 @@ void Foam::ensightFaces::classify
|
|||||||
for (label listi = 0; listi < sz; ++listi)
|
for (label listi = 0; listi < sz; ++listi)
|
||||||
{
|
{
|
||||||
const label faceId = addressing[listi];
|
const label faceId = addressing[listi];
|
||||||
const bool flip = useFlip && flipMap[listi];
|
const bool doFlip = useFlip && flipMap[listi];
|
||||||
|
|
||||||
if (!exclude[faceId])
|
if (!exclude[faceId])
|
||||||
{
|
{
|
||||||
add(faces[faceId], faceId, flip);
|
add(faces[faceId], faceId, doFlip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -37,7 +37,6 @@ Description
|
|||||||
#include "faceList.H"
|
#include "faceList.H"
|
||||||
#include "FixedList.H"
|
#include "FixedList.H"
|
||||||
#include "PackedBoolList.H"
|
#include "PackedBoolList.H"
|
||||||
#include "NamedEnum.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -57,16 +56,16 @@ public:
|
|||||||
//- Addressable ensight element types
|
//- Addressable ensight element types
|
||||||
enum elemType
|
enum elemType
|
||||||
{
|
{
|
||||||
TRIA3,
|
TRIA3, //!< "tria3"
|
||||||
QUAD4,
|
QUAD4, //!< "quad4"
|
||||||
NSIDED
|
NSIDED //!< "nsided"
|
||||||
};
|
};
|
||||||
|
|
||||||
//- Number of element types (3)
|
//- Number of element types (3)
|
||||||
static const label nTypes;
|
static const label nTypes;
|
||||||
|
|
||||||
//- The Ensight names for each element type
|
//- The ensight element type names
|
||||||
static const NamedEnum<elemType, 3> elemEnum;
|
static const char* elemNames[3];
|
||||||
|
|
||||||
|
|
||||||
// Static Member Functions
|
// Static Member Functions
|
||||||
@ -83,28 +82,27 @@ private:
|
|||||||
// The ensight part number is typically this value +1.
|
// The ensight part number is typically this value +1.
|
||||||
label index_;
|
label index_;
|
||||||
|
|
||||||
//- Linear list of ids, sub-sectioned per element type via SubLists
|
//- Linear list of ids, sub-sectioned per element type by sub-lists
|
||||||
labelList address_;
|
labelList address_;
|
||||||
|
|
||||||
//- Linear list of face-flips
|
//- Linear list of face-flips
|
||||||
boolList flipMap_;
|
boolList flipMap_;
|
||||||
|
|
||||||
|
//- Slices (sub-lists) of the address and flips for each element type.
|
||||||
|
FixedList<labelRange, 3> slices_;
|
||||||
|
|
||||||
//- List of global sizes for each element type.
|
//- List of global sizes for each element type.
|
||||||
// Used temporarily for local sizes when building the element lists.
|
// Used temporarily for local sizes when building the element lists.
|
||||||
FixedList<label, 3> sizes_;
|
FixedList<label, 3> sizes_;
|
||||||
|
|
||||||
//- SubLists of ids for each element type.
|
|
||||||
// Managed via pointers, since a SubList cannot be relocated/resized.
|
|
||||||
FixedList<SubList<label>*, 3> lists_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Simple classifier
|
//- Simple classifier
|
||||||
inline static elemType whatType(const face&);
|
inline static elemType whatType(const face& f);
|
||||||
|
|
||||||
//- Low-level internal addition routine
|
//- Low-level internal addition routine
|
||||||
inline void add(const face&, const label id, const bool flip = false);
|
inline void add(const face& f, const label id, const bool flip = false);
|
||||||
|
|
||||||
//- Use temporarily stored sizes to redimension the element lists
|
//- Use temporarily stored sizes to redimension the element lists
|
||||||
void resizeAll();
|
void resizeAll();
|
||||||
@ -121,7 +119,7 @@ public:
|
|||||||
ensightFaces(label partIndex = 0);
|
ensightFaces(label partIndex = 0);
|
||||||
|
|
||||||
//- Copy constructor. Needed for lists etc.
|
//- Copy constructor. Needed for lists etc.
|
||||||
ensightFaces(const ensightFaces&);
|
ensightFaces(const ensightFaces& obj);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -141,14 +139,17 @@ public:
|
|||||||
//- The processor local size of all elements.
|
//- The processor local size of all elements.
|
||||||
inline label size() const;
|
inline label size() const;
|
||||||
|
|
||||||
//- The global number of the specified element type.
|
//- The processor local size of the specified element type.
|
||||||
// This value is only meaningful after a reduce operation.
|
inline label size(const enum elemType) const;
|
||||||
inline label total(const enum elemType) const;
|
|
||||||
|
|
||||||
//- The global number of all element types.
|
//- The global number of all element types.
|
||||||
// This value is only meaningful after a reduce operation.
|
// This value is only meaningful after a reduce operation.
|
||||||
label total() const;
|
label total() const;
|
||||||
|
|
||||||
|
//- The global number of the specified element type.
|
||||||
|
// This value is only meaningful after a reduce operation.
|
||||||
|
inline label total(const enum elemType) const;
|
||||||
|
|
||||||
//- The global numbers per element type.
|
//- The global numbers per element type.
|
||||||
// This value is only meaningful after a reduce operation.
|
// This value is only meaningful after a reduce operation.
|
||||||
inline const FixedList<label, 3>& totals() const;
|
inline const FixedList<label, 3>& totals() const;
|
||||||
@ -157,10 +158,10 @@ public:
|
|||||||
FixedList<label, 3> sizes() const;
|
FixedList<label, 3> sizes() const;
|
||||||
|
|
||||||
//- Processor local starting offset of element type.
|
//- Processor local starting offset of element type.
|
||||||
label offset(const enum elemType what) const;
|
inline label offset(const enum elemType what) const;
|
||||||
|
|
||||||
//- Return the (local) face ids of the specified element type
|
//- Return the (local) face ids of the specified element type
|
||||||
inline const labelUList& faceIds(const enum elemType) const;
|
inline const labelUList faceIds(const enum elemType) const;
|
||||||
|
|
||||||
//- Return the processor local face ids of all elements
|
//- Return the processor local face ids of all elements
|
||||||
inline const labelUList& faceIds() const;
|
inline const labelUList& faceIds() const;
|
||||||
|
|||||||
@ -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) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -29,7 +29,7 @@ License
|
|||||||
|
|
||||||
inline const char* Foam::ensightFaces::key(const enum elemType what)
|
inline const char* Foam::ensightFaces::key(const enum elemType what)
|
||||||
{
|
{
|
||||||
return elemEnum[what];
|
return elemNames[what];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -63,20 +63,24 @@ inline Foam::label Foam::ensightFaces::total(const enum elemType what) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::labelUList& Foam::ensightFaces::faceIds
|
inline Foam::label Foam::ensightFaces::size(const enum elemType what) const
|
||||||
|
{
|
||||||
|
return slices_[what].size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::label Foam::ensightFaces::offset(const enum elemType what) const
|
||||||
|
{
|
||||||
|
return slices_[what].start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::labelUList Foam::ensightFaces::faceIds
|
||||||
(
|
(
|
||||||
const enum elemType what
|
const enum elemType what
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (!lists_[what])
|
return address_[slices_[what]];
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Accessing unallocated sublist for elem-type: "
|
|
||||||
<< elemEnum[what]
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(lists_[what]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user