Compare commits
20 Commits
feature-em
...
feature-st
| Author | SHA1 | Date | |
|---|---|---|---|
| 775d0b277b | |||
| f7dfb02d12 | |||
| a252677618 | |||
| 99f5d9a7db | |||
| 133149a1dd | |||
| 6396256522 | |||
| 5d98eec6af | |||
| 2d76514b5b | |||
| 2e3f0811a0 | |||
| ff2abdf1f0 | |||
| f49403969e | |||
| 2e8e259217 | |||
| 0250a1b0bb | |||
| aa1b6d9cbd | |||
| df6de6ed33 | |||
| f800ccc3d9 | |||
| 459aaad0f9 | |||
| a341d09afc | |||
| 6d7e67408e | |||
| d8f5714d1b |
@ -1,2 +1,2 @@
|
|||||||
api=2306
|
api=2307
|
||||||
patch=0
|
patch=0
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -37,6 +37,7 @@ Description
|
|||||||
#include "scalarField.H"
|
#include "scalarField.H"
|
||||||
#include "SubField.H"
|
#include "SubField.H"
|
||||||
#include "labelRange.H"
|
#include "labelRange.H"
|
||||||
|
#include "ListOps.H"
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
@ -57,26 +58,26 @@ int main(int argc, char *argv[])
|
|||||||
argList::noFunctionObjects();
|
argList::noFunctionObjects();
|
||||||
|
|
||||||
{
|
{
|
||||||
List<scalar> ident(25);
|
List<label> ident(25);
|
||||||
std::iota(ident.begin(), ident.end(), 0);
|
std::iota(ident.begin(), ident.end(), 0);
|
||||||
|
|
||||||
print(ident);
|
print(ident);
|
||||||
|
|
||||||
SubList<scalar>(ident, 10) = -10;
|
SubList<label>(ident, 10) = -10;
|
||||||
print(ident);
|
print(ident);
|
||||||
|
|
||||||
SubField<scalar>(ident, 10) = 10;
|
SubField<label>(ident, 10) = 10;
|
||||||
print(ident);
|
print(ident);
|
||||||
|
|
||||||
SubField<scalar>(ident, 10) += 10;
|
SubField<label>(ident, 10) += 10;
|
||||||
print(ident);
|
print(ident);
|
||||||
|
|
||||||
SubField<scalar>{ident, 10, 10} *= 5;
|
SubField<label>{ident, 10, 10} *= 5;
|
||||||
print(ident);
|
print(ident);
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Need {} instead of ()
|
// NOTE: Need {} instead of ()
|
||||||
// SubList<scalar>(ident) = 100;
|
// SubList<label>(ident) = 100;
|
||||||
|
|
||||||
// GCC
|
// GCC
|
||||||
// error: conflicting declaration 'Foam::SubList<double> ident'
|
// error: conflicting declaration 'Foam::SubList<double> ident'
|
||||||
@ -85,7 +86,30 @@ int main(int argc, char *argv[])
|
|||||||
// warning: parentheses were disambiguated as redundant parentheses
|
// warning: parentheses were disambiguated as redundant parentheses
|
||||||
// around declaration of variable named 'ident' [-Wvexing-parse]
|
// around declaration of variable named 'ident' [-Wvexing-parse]
|
||||||
|
|
||||||
SubList<scalar>{ident} = 100;
|
SubList<label>{ident} = 100;
|
||||||
|
print(ident);
|
||||||
|
|
||||||
|
SubList<label> sub(ident);
|
||||||
|
sub = 1;
|
||||||
|
print(sub);
|
||||||
|
|
||||||
|
sub.reset(ident, labelRange(4, 5)) = 5;
|
||||||
|
print(sub);
|
||||||
|
print(ident);
|
||||||
|
|
||||||
|
sub.reset(ident, labelRange(14, 5)) = 15;
|
||||||
|
print(sub);
|
||||||
|
print(ident);
|
||||||
|
|
||||||
|
// Cryptic, probably not a great idea to write this
|
||||||
|
sub.reset(ident, {20, 3}) = -1;
|
||||||
|
print(sub);
|
||||||
|
print(ident);
|
||||||
|
|
||||||
|
// This is also possible since we hold a concrete pointer/size
|
||||||
|
// and not an intermediate
|
||||||
|
ListOps::identity(sub.reset(ident, 8, 8));
|
||||||
|
print(sub);
|
||||||
print(ident);
|
print(ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2022 OpenCFD Ltd.
|
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -75,6 +75,16 @@ void testBroadcast(List<T>& values)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void testBroadcast(std::vector<T>& values)
|
||||||
|
{
|
||||||
|
Info<< nl << "is_contiguous:" << is_contiguous<T>::value << endl;
|
||||||
|
Pout<< "pre-broadcast: " << flatOutput(values) << endl;
|
||||||
|
Pstream::broadcast(values);
|
||||||
|
Pout<< "post-broadcast: " << flatOutput(values) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void testBroadcast(bitSet& values)
|
void testBroadcast(bitSet& values)
|
||||||
{
|
{
|
||||||
Pout<< "pre-broadcast: "
|
Pout<< "pre-broadcast: "
|
||||||
@ -135,6 +145,20 @@ int main(int argc, char *argv[])
|
|||||||
testBroadcast(values);
|
testBroadcast(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::vector<word> values;
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
values.resize(UPstream::nProcs());
|
||||||
|
|
||||||
|
for (decltype(values.size()) i=0; i < values.size(); ++i)
|
||||||
|
{
|
||||||
|
values[i] = "vector_" + Foam::name(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
testBroadcast(values);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
vector values(vector::uniform(-1));
|
vector values(vector::uniform(-1));
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
|
|||||||
@ -51,13 +51,30 @@ int main(int argc, char *argv[])
|
|||||||
hmm.source()[1] = vector(1.0, 4.0, 3.0);
|
hmm.source()[1] = vector(1.0, 4.0, 3.0);
|
||||||
hmm.source()[2] = vector(0.0, 5.0, 2.0);
|
hmm.source()[2] = vector(0.0, 5.0, 2.0);
|
||||||
|
|
||||||
Info<< hmm << endl;
|
Info<< hmm << nl;
|
||||||
Info<< hmm.solve() << endl;
|
Info<< hmm.solve() << nl;
|
||||||
Info<< hmm << endl;
|
Info<< hmm << nl;
|
||||||
Info<< hmm.LUsolve() << endl;
|
Info<< hmm.LUsolve() << nl;
|
||||||
Info<< hmm << endl;
|
Info<< hmm << nl;
|
||||||
|
|
||||||
Info<< "End\n" << endl;
|
{
|
||||||
|
scalarSquareMatrix mat0;
|
||||||
|
Info<< "empty: " << mat0 << endl;
|
||||||
|
|
||||||
|
mat0.resize_nocopy(1);
|
||||||
|
mat0 = Identity<scalar>();
|
||||||
|
Info<< "ident (1x1): " << mat0 << endl;
|
||||||
|
|
||||||
|
mat0.resize_nocopy(3);
|
||||||
|
mat0 = Identity<scalar>();
|
||||||
|
Info<< "ident (3x3): " << mat0 << endl;
|
||||||
|
|
||||||
|
mat0.resize_nocopy(5);
|
||||||
|
mat0 = Identity<scalar>();
|
||||||
|
Info<< "ident (5x5): " << mat0 << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -429,7 +429,7 @@ unset cmd
|
|||||||
|
|
||||||
case "$WM_MPLIB" in
|
case "$WM_MPLIB" in
|
||||||
*OPENMPI*)
|
*OPENMPI*)
|
||||||
cmd="mpirun -app $PWD/mpirun.schema </dev/null"
|
cmd="mpirun --oversubscribe -app $PWD/mpirun.schema </dev/null"
|
||||||
;;
|
;;
|
||||||
MPICH)
|
MPICH)
|
||||||
cmd="mpiexec"
|
cmd="mpiexec"
|
||||||
|
|||||||
@ -304,16 +304,21 @@ runApplication()
|
|||||||
#
|
#
|
||||||
runParallel()
|
runParallel()
|
||||||
{
|
{
|
||||||
local appName appRun optValue logFile logMode nProcs
|
local appName appRun optValue logFile logMode
|
||||||
|
local mpiopts nProcs
|
||||||
|
|
||||||
# Any additional parsed arguments (eg, decomposeParDict)
|
# Any additional parsed arguments (eg, decomposeParDict)
|
||||||
local appArgs="-parallel"
|
local appArgs="-parallel"
|
||||||
|
|
||||||
local mpirun="mpirun"
|
local mpirun="mpirun"
|
||||||
if [ "$FOAM_MPI" = msmpi ]
|
case "$FOAM_MPI" in
|
||||||
then
|
(msmpi*)
|
||||||
mpirun="mpiexec"
|
mpirun="mpiexec"
|
||||||
fi
|
;;
|
||||||
|
(*openmpi*)
|
||||||
|
mpiopts="--oversubscribe"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Parse options until executable is encountered
|
# Parse options until executable is encountered
|
||||||
while [ "$#" -gt 0 ] && [ -z "$appRun" ]
|
while [ "$#" -gt 0 ] && [ -z "$appRun" ]
|
||||||
@ -378,11 +383,11 @@ runParallel()
|
|||||||
if [ "$logMode" = append ]
|
if [ "$logMode" = append ]
|
||||||
then
|
then
|
||||||
(
|
(
|
||||||
$mpirun -n $nProcs $appRun $appArgs "$@" </dev/null >> $logFile 2>&1
|
"$mpirun" $mpiopts -n "${nProcs:?}" $appRun $appArgs "$@" </dev/null >> $logFile 2>&1
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
(
|
(
|
||||||
$mpirun -n $nProcs $appRun $appArgs "$@" </dev/null > $logFile 2>&1
|
"$mpirun" $mpiopts -n "${nProcs:?}" $appRun $appArgs "$@" </dev/null > $logFile 2>&1
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -225,6 +225,8 @@ castellatedMeshControls
|
|||||||
//cellZone sphere;
|
//cellZone sphere;
|
||||||
//cellZoneInside inside; // outside/insidePoint
|
//cellZoneInside inside; // outside/insidePoint
|
||||||
//insidePoint (1 1 1); // if (cellZoneInside == insidePoint)
|
//insidePoint (1 1 1); // if (cellZoneInside == insidePoint)
|
||||||
|
// or alternative multiple insidePoints:
|
||||||
|
//insidePoints ((1 1 1)); // if (cellZoneInside == insidePoint)
|
||||||
|
|
||||||
//- Optional specification of what to do with faceZone faces:
|
//- Optional specification of what to do with faceZone faces:
|
||||||
// internal : keep them as internal faces (default)
|
// internal : keep them as internal faces (default)
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -102,48 +102,51 @@ bool Foam::PackedList<Width>::uniform() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// The value of the first element for testing
|
// The value of the first element for testing
|
||||||
const unsigned int val = get(0);
|
const unsigned int val = get(0);
|
||||||
|
|
||||||
const label nblocks = num_blocks(size());
|
|
||||||
|
|
||||||
bool identical = true;
|
bool identical = true;
|
||||||
|
|
||||||
if (!val)
|
if (!val)
|
||||||
{
|
{
|
||||||
// Zero value: can just check block content directly
|
// No bits set: just check there are no non-zero blocks
|
||||||
|
// - like bitSet::none()
|
||||||
|
identical = (-1 == first_block());
|
||||||
|
}
|
||||||
|
else if (val == PackedList<Width>::max_value)
|
||||||
|
{
|
||||||
|
// All bits set: just check there are no zero blocks
|
||||||
|
// - like bitSet::all()
|
||||||
|
identical = (-1 == first_not_block());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const label nblocks = num_blocks(size());
|
||||||
|
|
||||||
for (label blocki = 0; identical && blocki < nblocks; ++blocki)
|
if (nblocks > 1)
|
||||||
{
|
{
|
||||||
identical = !blocks_[blocki];
|
// Fill value for complete blocks
|
||||||
|
const unsigned int blockval = repeated_value(val);
|
||||||
|
|
||||||
|
// Check each complete block (nblocks-1)
|
||||||
|
for (label blocki = 0; identical && blocki < (nblocks-1); ++blocki)
|
||||||
|
{
|
||||||
|
identical = (blocks_[blocki] == blockval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return identical;
|
// Partial block: check manually
|
||||||
}
|
for
|
||||||
else if (nblocks > 1)
|
(
|
||||||
{
|
label elemi = elem_per_block*(nblocks-1);
|
||||||
// Fill value for complete blocks
|
identical && elemi < size();
|
||||||
const unsigned int blockval = repeated_value(val);
|
++elemi
|
||||||
|
)
|
||||||
// Check each complete block (nblocks-1)
|
|
||||||
for (label blocki = 0; identical && blocki < (nblocks-1); ++blocki)
|
|
||||||
{
|
{
|
||||||
identical = (blocks_[blocki] == blockval);
|
identical = (val == get(elemi));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Partial block: check manually
|
|
||||||
for
|
|
||||||
(
|
|
||||||
label elemi = elem_per_block*(nblocks-1);
|
|
||||||
identical && elemi < size();
|
|
||||||
++elemi
|
|
||||||
)
|
|
||||||
{
|
|
||||||
identical = (val == get(elemi));
|
|
||||||
}
|
|
||||||
|
|
||||||
return identical;
|
return identical;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,16 +197,20 @@ Foam::PackedList<Width>::unpack() const
|
|||||||
"Width of IntType is too small to hold result"
|
"Width of IntType is too small to hold result"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
List<IntType> output(size());
|
||||||
|
|
||||||
if (empty())
|
if (empty())
|
||||||
{
|
{
|
||||||
return List<IntType>(0);
|
return output;
|
||||||
}
|
}
|
||||||
else if (uniform())
|
else if (uniform())
|
||||||
{
|
{
|
||||||
return List<IntType>(size(), static_cast<IntType>(get(0)));
|
output = static_cast<IntType>(get(0));
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IntType> output(size());
|
// NON-UNIFORM and len > 0
|
||||||
|
|
||||||
label outi = 0;
|
label outi = 0;
|
||||||
|
|
||||||
// Process n-1 complete blocks
|
// Process n-1 complete blocks
|
||||||
@ -215,7 +222,7 @@ Foam::PackedList<Width>::unpack() const
|
|||||||
|
|
||||||
for (unsigned nget = elem_per_block; nget; --nget, ++outi)
|
for (unsigned nget = elem_per_block; nget; --nget, ++outi)
|
||||||
{
|
{
|
||||||
output[outi] = IntType(blockval & max_value);
|
output[outi] = IntType(blockval & PackedList<Width>::max_value);
|
||||||
blockval >>= Width;
|
blockval >>= Width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -221,6 +221,14 @@ protected:
|
|||||||
//- Copy assignment
|
//- Copy assignment
|
||||||
inline void copyAssign(const PackedList<Width>& rhs);
|
inline void copyAssign(const PackedList<Width>& rhs);
|
||||||
|
|
||||||
|
//- Find the first block with a '1' bit
|
||||||
|
// \return block number or -1 for an list or if all bits are OFF.
|
||||||
|
inline label first_block() const;
|
||||||
|
|
||||||
|
//- Find the first block with a '0' bit
|
||||||
|
// \return block number or -1 for an list or if all bits are ON.
|
||||||
|
inline label first_not_block() const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -292,7 +300,7 @@ public:
|
|||||||
//- Number of elements that can be stored without reallocating
|
//- Number of elements that can be stored without reallocating
|
||||||
inline label capacity() const noexcept;
|
inline label capacity() const noexcept;
|
||||||
|
|
||||||
//- True if all entries have identical values, and list is non-empty
|
//- True if all entries have identical values (and list is non-empty)
|
||||||
bool uniform() const;
|
bool uniform() const;
|
||||||
|
|
||||||
//- Test for equality of sizes and the bits set
|
//- Test for equality of sizes and the bits set
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -147,6 +147,73 @@ inline void Foam::PackedList<Width>::copyAssign(const PackedList<Width>& rhs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned Width>
|
||||||
|
inline Foam::label Foam::PackedList<Width>::first_block() const
|
||||||
|
{
|
||||||
|
if (size())
|
||||||
|
{
|
||||||
|
const label nblocks = num_blocks(size());
|
||||||
|
|
||||||
|
for (label blocki=0; blocki < nblocks; ++blocki)
|
||||||
|
{
|
||||||
|
if (blocks_[blocki])
|
||||||
|
{
|
||||||
|
return blocki;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned Width>
|
||||||
|
inline Foam::label Foam::PackedList<Width>::first_not_block() const
|
||||||
|
{
|
||||||
|
if (!size())
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check on complement (changes 0 <-> 1).
|
||||||
|
// If any 1's now appear, there was a 0 bit before
|
||||||
|
|
||||||
|
const label nblocks = num_blocks(size());
|
||||||
|
|
||||||
|
// Extra bits in the final block?
|
||||||
|
const unsigned int off = size() % elem_per_block;
|
||||||
|
|
||||||
|
if (!off)
|
||||||
|
{
|
||||||
|
for (label blocki=0; blocki < nblocks; ++blocki)
|
||||||
|
{
|
||||||
|
if (~(blocks_[blocki]))
|
||||||
|
{
|
||||||
|
return blocki;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (label blocki=0; blocki < nblocks-1; ++blocki)
|
||||||
|
{
|
||||||
|
if (~(blocks_[blocki]))
|
||||||
|
{
|
||||||
|
return blocki;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The final block needs masking
|
||||||
|
if (~(blocks_[nblocks-1]) & mask_lower(off))
|
||||||
|
{
|
||||||
|
return nblocks-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Specializations * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Specializations * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
|
|||||||
@ -18,8 +18,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef PackedBoolList_H
|
#ifndef FoamCompat_PackedBoolList_H
|
||||||
#define PackedBoolList_H
|
#define FoamCompat_PackedBoolList_H
|
||||||
|
|
||||||
#include "bitSet.H"
|
#include "bitSet.H"
|
||||||
|
|
||||||
|
|||||||
@ -65,13 +65,6 @@ class bitSet
|
|||||||
:
|
:
|
||||||
public PackedList<1>
|
public PackedList<1>
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Find the first block with a '0' bit
|
|
||||||
// \return block number or -1 if the set is empty or all bits are on.
|
|
||||||
inline label first_not_block() const;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Logic/Set Operations
|
// Logic/Set Operations
|
||||||
@ -138,7 +131,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Default construct an empty, zero-sized bitSet
|
//- Default construct an empty, zero-sized bitSet
|
||||||
inline bitSet() noexcept;
|
inline constexpr bitSet() noexcept;
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
explicit bitSet(Istream& is);
|
explicit bitSet(Istream& is);
|
||||||
@ -246,9 +239,6 @@ public:
|
|||||||
// \note Method name compatibility with boost::dynamic_bitset
|
// \note Method name compatibility with boost::dynamic_bitset
|
||||||
inline bool none() const;
|
inline bool none() const;
|
||||||
|
|
||||||
//- True if all entries have identical values, and the set is non-empty
|
|
||||||
inline bool uniform() const;
|
|
||||||
|
|
||||||
//- Count number of bits set.
|
//- Count number of bits set.
|
||||||
// \param on can be set to false to count the number of unset bits
|
// \param on can be set to false to count the number of unset bits
|
||||||
// instead.
|
// instead.
|
||||||
|
|||||||
@ -25,56 +25,9 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
inline Foam::label Foam::bitSet::first_not_block() const
|
|
||||||
{
|
|
||||||
if (empty())
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use complement to change 0 <-> 1 and check if any 1's now appear
|
|
||||||
|
|
||||||
const label nblocks = num_blocks(size());
|
|
||||||
|
|
||||||
// Extra bits in the final block?
|
|
||||||
const unsigned int off = size() % elem_per_block;
|
|
||||||
|
|
||||||
if (!off)
|
|
||||||
{
|
|
||||||
for (label blocki=0; blocki < nblocks; ++blocki)
|
|
||||||
{
|
|
||||||
if (~(blocks_[blocki]))
|
|
||||||
{
|
|
||||||
return blocki;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (label blocki=0; blocki < nblocks-1; ++blocki)
|
|
||||||
{
|
|
||||||
if (~(blocks_[blocki]))
|
|
||||||
{
|
|
||||||
return blocki;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The final block needs masking
|
|
||||||
if (~(blocks_[nblocks-1]) & mask_lower(off))
|
|
||||||
{
|
|
||||||
return nblocks-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::bitSet::bitSet() noexcept
|
inline constexpr Foam::bitSet::bitSet() noexcept
|
||||||
:
|
:
|
||||||
PackedList<1>()
|
PackedList<1>()
|
||||||
{}
|
{}
|
||||||
@ -313,14 +266,14 @@ inline Foam::bitSet::const_iterator Foam::bitSet::cend() const noexcept
|
|||||||
|
|
||||||
inline Foam::label Foam::bitSet::find_first() const
|
inline Foam::label Foam::bitSet::find_first() const
|
||||||
{
|
{
|
||||||
// Process block-wise, detecting any '1' bits
|
const label blocki = first_block();
|
||||||
|
|
||||||
const label nblocks = num_blocks(size());
|
if (blocki >= 0)
|
||||||
|
|
||||||
for (label blocki = 0; blocki < nblocks; ++blocki)
|
|
||||||
{
|
{
|
||||||
label pos = (blocki * elem_per_block);
|
label pos = (blocki * elem_per_block);
|
||||||
|
|
||||||
|
// Detect first '1' bit within the block
|
||||||
|
|
||||||
for
|
for
|
||||||
(
|
(
|
||||||
unsigned int blockval = blocks_[blocki];
|
unsigned int blockval = blocks_[blocki];
|
||||||
@ -348,7 +301,7 @@ inline Foam::label Foam::bitSet::find_first_not() const
|
|||||||
{
|
{
|
||||||
label pos = (blocki * elem_per_block);
|
label pos = (blocki * elem_per_block);
|
||||||
|
|
||||||
// Detect first '0' bit by checking the complement.
|
// Detect first '0' bit within the block (check the complement)
|
||||||
|
|
||||||
// No special masking for the final block, that was already checked
|
// No special masking for the final block, that was already checked
|
||||||
// in the first_not_block() call.
|
// in the first_not_block() call.
|
||||||
@ -461,39 +414,19 @@ inline const Foam::bitSet& Foam::bitSet::null()
|
|||||||
inline bool Foam::bitSet::all() const
|
inline bool Foam::bitSet::all() const
|
||||||
{
|
{
|
||||||
if (empty()) return true; // SIC. boost convention
|
if (empty()) return true; // SIC. boost convention
|
||||||
|
return (-1 == first_not_block());
|
||||||
return -1 == first_not_block();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::bitSet::any() const
|
inline bool Foam::bitSet::any() const
|
||||||
{
|
{
|
||||||
if (size())
|
return (-1 != first_block());
|
||||||
{
|
|
||||||
const label nblocks = num_blocks(size());
|
|
||||||
|
|
||||||
for (label blocki=0; blocki < nblocks; ++blocki)
|
|
||||||
{
|
|
||||||
if (blocks_[blocki])
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::bitSet::none() const
|
inline bool Foam::bitSet::none() const
|
||||||
{
|
{
|
||||||
return !any();
|
return (-1 == first_block());
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::bitSet::uniform() const
|
|
||||||
{
|
|
||||||
return (size() == 1 || (size() > 1 && (test(0) ? all() : none())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -108,6 +108,8 @@ const Foam::SubList<T> Foam::CircularBuffer<T>::array_two() const
|
|||||||
template<class T>
|
template<class T>
|
||||||
Foam::label Foam::CircularBuffer<T>::find(const T& val, label pos) const
|
Foam::label Foam::CircularBuffer<T>::find(const T& val, label pos) const
|
||||||
{
|
{
|
||||||
|
if (pos < 0) return -1; // no-op
|
||||||
|
|
||||||
label i = -1;
|
label i = -1;
|
||||||
|
|
||||||
const auto list1 = this->array_one();
|
const auto list1 = this->array_one();
|
||||||
|
|||||||
@ -282,18 +282,21 @@ public:
|
|||||||
|
|
||||||
// Search
|
// Search
|
||||||
|
|
||||||
|
//- True if the value is contained in the list.
|
||||||
|
inline bool contains(const T& val) const;
|
||||||
|
|
||||||
|
//- Is the value contained in the list?
|
||||||
|
// \param val The value to search for
|
||||||
|
// \param pos The first position to examine (no-op if -ve)
|
||||||
|
// \return true if found.
|
||||||
|
inline bool contains(const T& val, label pos) const;
|
||||||
|
|
||||||
//- Find index of the first occurrence of the value.
|
//- Find index of the first occurrence of the value.
|
||||||
// Any occurrences before the start pos are ignored.
|
// Any occurrences before the start pos are ignored.
|
||||||
// Linear search.
|
// Linear search.
|
||||||
// \return position in list or -1 if not found.
|
// \return position in list or -1 if not found.
|
||||||
label find(const T& val, label pos = 0) const;
|
label find(const T& val, label pos = 0) const;
|
||||||
|
|
||||||
//- Is the value contained in the list?
|
|
||||||
// Linear search from start pos until the end of the list.
|
|
||||||
// Any occurrences before the start pos are ignored.
|
|
||||||
// \return true if found.
|
|
||||||
inline bool contains(const T& val, label pos = 0) const;
|
|
||||||
|
|
||||||
|
|
||||||
// Stack-like Operations
|
// Stack-like Operations
|
||||||
|
|
||||||
|
|||||||
@ -255,6 +255,13 @@ inline void Foam::CircularBuffer<T>::reserve_nocopy(const label len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool Foam::CircularBuffer<T>::contains(const T& val) const
|
||||||
|
{
|
||||||
|
return (this->array_one().contains(val) || this->array_two().contains(val));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool Foam::CircularBuffer<T>::contains(const T& val, label pos) const
|
inline bool Foam::CircularBuffer<T>::contains(const T& val, label pos) const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -499,8 +499,12 @@ bool Foam::HashTable<T, Key, Hash>::erase(const iterator& iter)
|
|||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
bool Foam::HashTable<T, Key, Hash>::erase(const Key& key)
|
bool Foam::HashTable<T, Key, Hash>::erase(const Key& key)
|
||||||
{
|
{
|
||||||
iterator iter(find(key));
|
if (size_)
|
||||||
return iterator_erase(iter);
|
{
|
||||||
|
iterator iter(find(key));
|
||||||
|
if (iter.good()) return iterator_erase(iter);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -31,13 +31,21 @@ template<class T, class Addr>
|
|||||||
Foam::label Foam::IndirectListBase<T, Addr>::find
|
Foam::label Foam::IndirectListBase<T, Addr>::find
|
||||||
(
|
(
|
||||||
const T& val,
|
const T& val,
|
||||||
label pos
|
label pos,
|
||||||
|
label len
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const label len = addr_.size();
|
if (pos >= 0 && pos < addr_.size())
|
||||||
|
|
||||||
if (pos >= 0 && len)
|
|
||||||
{
|
{
|
||||||
|
// Change sub-length to (one-past) end position
|
||||||
|
// len == -1 (like std::string::npos) - search until end
|
||||||
|
|
||||||
|
if (len > 0) len += pos;
|
||||||
|
if (len < 0 || len > addr_.size())
|
||||||
|
{
|
||||||
|
len = addr_.size();
|
||||||
|
}
|
||||||
|
|
||||||
const T* const vals = values_.begin();
|
const T* const vals = values_.begin();
|
||||||
|
|
||||||
while (pos < len)
|
while (pos < len)
|
||||||
@ -62,7 +70,7 @@ Foam::label Foam::IndirectListBase<T, Addr>::rfind
|
|||||||
label pos
|
label pos
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// pos == -1 has same meaning as std::string::npos - search from end
|
// pos == -1 (like std::string::npos) - search from end
|
||||||
|
|
||||||
if (pos < 0 || pos >= addr_.size())
|
if (pos < 0 || pos >= addr_.size())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -179,11 +179,19 @@ public:
|
|||||||
|
|
||||||
// Search
|
// Search
|
||||||
|
|
||||||
|
//- Is the value contained in the list?
|
||||||
|
// \param val The value to search for
|
||||||
|
// \param pos The first position to examine (default: 0, no-op if -ve)
|
||||||
|
// \param len The length of the search region (-ve until the end)
|
||||||
|
// \return true if found.
|
||||||
|
inline bool contains(const T& val, label pos = 0, label len = -1) const;
|
||||||
|
|
||||||
//- Find index of the first occurrence of the value.
|
//- Find index of the first occurrence of the value.
|
||||||
// Any occurrences before the start pos are ignored.
|
// \param val The value to search for
|
||||||
// Linear search.
|
// \param pos The first position to examine (default: 0, no-op if -ve)
|
||||||
// \return -1 if not found.
|
// \param len The length of the search region (-ve until the end)
|
||||||
label find(const T& val, label pos = 0) const;
|
// \return position in list or -1 if not found.
|
||||||
|
label find(const T& val, label pos = 0, label len = -1) const;
|
||||||
|
|
||||||
//- Find index of the last occurrence of the value.
|
//- Find index of the last occurrence of the value.
|
||||||
// Any occurrences after the end pos are ignored.
|
// Any occurrences after the end pos are ignored.
|
||||||
@ -191,12 +199,6 @@ public:
|
|||||||
// \return -1 if not found.
|
// \return -1 if not found.
|
||||||
label rfind(const T& val, label pos = -1) const;
|
label rfind(const T& val, label pos = -1) const;
|
||||||
|
|
||||||
//- Is the value contained in the list?
|
|
||||||
// Linear search from start pos until the end of the list.
|
|
||||||
// Any occurrences before the start pos are ignored.
|
|
||||||
// \return true if found.
|
|
||||||
inline bool contains(const T& val, label pos = 0) const;
|
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
|
|||||||
@ -102,10 +102,11 @@ template<class T, class Addr>
|
|||||||
inline bool Foam::IndirectListBase<T, Addr>::contains
|
inline bool Foam::IndirectListBase<T, Addr>::contains
|
||||||
(
|
(
|
||||||
const T& val,
|
const T& val,
|
||||||
label pos
|
label pos,
|
||||||
|
label len
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return (this->find(val, pos) >= 0);
|
return (this->find(val, pos, len) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -222,6 +222,27 @@ Foam::Istream& Foam::DynamicList<T, SizeMin>::readList(Istream& is)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (std::is_same<char, T>::value)
|
||||||
|
{
|
||||||
|
// Special treatment for char data (always binary and contiguous)
|
||||||
|
// (see List<char>::readList)
|
||||||
|
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
const auto oldFmt = is.format(IOstreamOption::BINARY);
|
||||||
|
|
||||||
|
// read(...) includes surrounding start/end delimiters
|
||||||
|
is.read(list.data_bytes(), list.size_bytes());
|
||||||
|
|
||||||
|
is.format(oldFmt);
|
||||||
|
|
||||||
|
is.fatalCheck
|
||||||
|
(
|
||||||
|
"DynamicList<char>::readList(Istream&) : "
|
||||||
|
"reading binary block"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Begin of contents marker
|
// Begin of contents marker
|
||||||
|
|||||||
@ -45,6 +45,14 @@ std::streamsize Foam::FixedList<T, N>::byteSize()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class T, unsigned N>
|
||||||
|
Foam::label Foam::FixedList<T, N>::find(const T& val) const
|
||||||
|
{
|
||||||
|
const auto iter = std::find(this->cbegin(), this->cend(), val);
|
||||||
|
return (iter != this->cend() ? label(iter - this->cbegin()) : label(-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned N>
|
template<class T, unsigned N>
|
||||||
Foam::label Foam::FixedList<T, N>::find
|
Foam::label Foam::FixedList<T, N>::find
|
||||||
(
|
(
|
||||||
@ -55,8 +63,8 @@ Foam::label Foam::FixedList<T, N>::find
|
|||||||
{
|
{
|
||||||
if (pos >= 0 && pos < label(N))
|
if (pos >= 0 && pos < label(N))
|
||||||
{
|
{
|
||||||
// Change length to end iterator position
|
// Change sub-length to (one-past) end position
|
||||||
// len == -1 has same meaning as std::string::npos - search until end
|
// len == -1 (like std::string::npos) - search until end
|
||||||
|
|
||||||
if (len > 0) len += pos;
|
if (len > 0) len += pos;
|
||||||
if (len < 0 || len > label(N))
|
if (len < 0 || len > label(N))
|
||||||
@ -64,13 +72,16 @@ Foam::label Foam::FixedList<T, N>::find
|
|||||||
len = label(N);
|
len = label(N);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto iter = (this->cbegin() + pos);
|
const auto iter = std::find
|
||||||
const auto lastIter = (this->cbegin() + len);
|
(
|
||||||
|
(this->cbegin() + pos),
|
||||||
|
(this->cbegin() + len),
|
||||||
|
val
|
||||||
|
);
|
||||||
|
|
||||||
iter = std::find(iter, lastIter, val);
|
if (iter != (this->cbegin() + len))
|
||||||
if (iter != lastIter)
|
|
||||||
{
|
{
|
||||||
return label(iter - this->begin());
|
return label(iter - this->cbegin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +92,8 @@ Foam::label Foam::FixedList<T, N>::find
|
|||||||
template<class T, unsigned N>
|
template<class T, unsigned N>
|
||||||
Foam::label Foam::FixedList<T, N>::rfind(const T& val, label pos) const
|
Foam::label Foam::FixedList<T, N>::rfind(const T& val, label pos) const
|
||||||
{
|
{
|
||||||
// pos == -1 has same meaning as std::string::npos - search from end
|
// pos == -1 (like std::string::npos) - search from end
|
||||||
|
|
||||||
if (pos < 0 || pos >= label(N))
|
if (pos < 0 || pos >= label(N))
|
||||||
{
|
{
|
||||||
pos = label(N)-1;
|
pos = label(N)-1;
|
||||||
|
|||||||
@ -275,12 +275,27 @@ public:
|
|||||||
|
|
||||||
// Search
|
// Search
|
||||||
|
|
||||||
|
//- True if the value is contained in the list.
|
||||||
|
inline bool contains(const T& val) const;
|
||||||
|
|
||||||
|
//- Is the value contained in the list?
|
||||||
|
// \param val The value to search for
|
||||||
|
// \param pos The first position to examine (no-op if -ve)
|
||||||
|
// \param len The length of the search region (-ve until the end)
|
||||||
|
// \return true if found.
|
||||||
|
inline bool contains(const T& val, label pos, label len = -1) const;
|
||||||
|
|
||||||
//- Find index of the first occurrence of the value.
|
//- Find index of the first occurrence of the value.
|
||||||
// \param val The value to search for
|
// \param val The value to search for
|
||||||
// \param pos The first position to examine (default: 0, -ve no-op)
|
// \return position in list or -1 if not found.
|
||||||
|
label find(const T& val) const;
|
||||||
|
|
||||||
|
//- Find index of the first occurrence of the value.
|
||||||
|
// \param val The value to search for
|
||||||
|
// \param pos The first position to examine (no-op if -ve)
|
||||||
// \param len The length of the search region (-ve until the end)
|
// \param len The length of the search region (-ve until the end)
|
||||||
// \return position in list or -1 if not found.
|
// \return position in list or -1 if not found.
|
||||||
label find(const T& val, label pos = 0, label len = -1) const;
|
label find(const T& val, label pos, label len = -1) const;
|
||||||
|
|
||||||
//- Find index of the last occurrence of the value.
|
//- Find index of the last occurrence of the value.
|
||||||
// Any occurrences after the end pos are ignored.
|
// Any occurrences after the end pos are ignored.
|
||||||
@ -288,13 +303,6 @@ public:
|
|||||||
// \return position in list or -1 if not found.
|
// \return position in list or -1 if not found.
|
||||||
label rfind(const T& val, label pos = -1) const;
|
label rfind(const T& val, label pos = -1) const;
|
||||||
|
|
||||||
//- Is the value contained in the list?
|
|
||||||
// \param val The value to search for
|
|
||||||
// \param pos The first position to examine (default: 0, -ve no-op)
|
|
||||||
// \param len The length of the search region (-ve until the end)
|
|
||||||
// \return true if found.
|
|
||||||
inline bool contains(const T& val, label pos = 0, label len = -1) const;
|
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
|
|||||||
@ -306,6 +306,14 @@ inline bool Foam::FixedList<T, N>::uniform() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned N>
|
||||||
|
inline bool Foam::FixedList<T, N>::contains(const T& val) const
|
||||||
|
{
|
||||||
|
const auto iter = std::find(this->cbegin(), this->cend(), val);
|
||||||
|
return (iter != this->cend());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned N>
|
template<class T, unsigned N>
|
||||||
inline bool Foam::FixedList<T, N>::contains
|
inline bool Foam::FixedList<T, N>::contains
|
||||||
(
|
(
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -89,7 +89,10 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from UList, the entire size
|
//- Construct from UList, the entire size
|
||||||
inline explicit SubList(const UList<T>& list);
|
inline explicit SubList(const UList<T>& list) noexcept;
|
||||||
|
|
||||||
|
//- Construct from std::vector, the entire size
|
||||||
|
inline explicit SubList(const std::vector<T>& list) noexcept;
|
||||||
|
|
||||||
//- Construct from FixedList, the entire size
|
//- Construct from FixedList, the entire size
|
||||||
template<unsigned N>
|
template<unsigned N>
|
||||||
@ -128,6 +131,47 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Reset to zero-sized and nullptr
|
||||||
|
inline UList<T>& reset(std::nullptr_t) noexcept;
|
||||||
|
|
||||||
|
//- Reset to use entire UList
|
||||||
|
inline UList<T>& reset(const UList<T>& list) noexcept;
|
||||||
|
|
||||||
|
//- Reset to use UList with sub-list size, start at 0
|
||||||
|
inline UList<T>& reset
|
||||||
|
(
|
||||||
|
const UList<T>& list,
|
||||||
|
const label subSize
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Reset to use UList with sub-list size and start index
|
||||||
|
inline UList<T>& reset
|
||||||
|
(
|
||||||
|
const UList<T>& list,
|
||||||
|
const label subSize,
|
||||||
|
const label startIndex
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Reset to use UList with a (start,size) range.
|
||||||
|
// The range is subsetted with the list size itself to ensure that the
|
||||||
|
// result always addresses a valid section of the list.
|
||||||
|
inline UList<T>& reset
|
||||||
|
(
|
||||||
|
const UList<T>& list,
|
||||||
|
const labelRange& range
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Reset to use UList with a (start,size) range, but bypassing
|
||||||
|
//- run-time range checking.
|
||||||
|
inline UList<T>& reset
|
||||||
|
(
|
||||||
|
const labelRange& range,
|
||||||
|
const UList<T>& list
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
//- Allow cast to a const List\<T\>&
|
//- Allow cast to a const List\<T\>&
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -28,18 +28,37 @@ License
|
|||||||
|
|
||||||
#include "FixedList.H"
|
#include "FixedList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline const Foam::SubList<T>& Foam::SubList<T>::null()
|
||||||
|
{
|
||||||
|
return NullObjectRef<SubList<T>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Foam::SubList<T>::SubList
|
inline Foam::SubList<T>::SubList
|
||||||
(
|
(
|
||||||
const UList<T>& list
|
const UList<T>& list
|
||||||
)
|
) noexcept
|
||||||
:
|
:
|
||||||
UList<T>(const_cast<T*>(list.cdata()), list.size())
|
UList<T>(const_cast<T*>(list.cdata()), list.size())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::SubList<T>::SubList
|
||||||
|
(
|
||||||
|
const std::vector<T>& list
|
||||||
|
) noexcept
|
||||||
|
:
|
||||||
|
UList<T>(const_cast<T*>(list.data()), label(list.size()))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
template<unsigned N>
|
template<unsigned N>
|
||||||
inline Foam::SubList<T>::SubList
|
inline Foam::SubList<T>::SubList
|
||||||
@ -113,9 +132,102 @@ inline Foam::SubList<T>::SubList
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline const Foam::SubList<T>& Foam::SubList<T>::null()
|
inline Foam::UList<T>& Foam::SubList<T>::reset(std::nullptr_t) noexcept
|
||||||
{
|
{
|
||||||
return NullObjectRef<SubList<T>>();
|
UList<T>::shallowCopy(nullptr, 0);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::UList<T>& Foam::SubList<T>::reset
|
||||||
|
(
|
||||||
|
const UList<T>& list
|
||||||
|
) noexcept
|
||||||
|
{
|
||||||
|
UList<T>::shallowCopy(list);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::UList<T>& Foam::SubList<T>::reset
|
||||||
|
(
|
||||||
|
const UList<T>& list,
|
||||||
|
const label subSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#ifdef FULLDEBUG
|
||||||
|
list.checkSize(subSize);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UList<T>::shallowCopy(const_cast<T*>(list.cdata()), subSize);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::UList<T>& Foam::SubList<T>::reset
|
||||||
|
(
|
||||||
|
const UList<T>& list,
|
||||||
|
const label subSize,
|
||||||
|
const label startIndex
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#ifdef FULLDEBUG
|
||||||
|
list.checkRange(startIndex, subSize);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UList<T>::shallowCopy
|
||||||
|
(
|
||||||
|
const_cast<T*>(list.cdata() + startIndex),
|
||||||
|
subSize
|
||||||
|
);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::UList<T>& Foam::SubList<T>::reset
|
||||||
|
(
|
||||||
|
const UList<T>& list,
|
||||||
|
const labelRange& range
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#ifdef FULLDEBUG
|
||||||
|
// subset0() always produces valid ranges but want to check
|
||||||
|
// that the input itself was valid
|
||||||
|
list.checkRange(range.start(), range.size());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
labelRange clamped(range.subset0(list.size()));
|
||||||
|
|
||||||
|
UList<T>::shallowCopy
|
||||||
|
(
|
||||||
|
const_cast<T*>(list.cdata() + clamped.start()),
|
||||||
|
clamped.size()
|
||||||
|
);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::UList<T>& Foam::SubList<T>::reset
|
||||||
|
(
|
||||||
|
const labelRange& range,
|
||||||
|
const UList<T>& list
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#ifdef FULLDEBUG
|
||||||
|
list.checkRange(range.start(), range.size());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UList<T>::shallowCopy
|
||||||
|
(
|
||||||
|
const_cast<T*>(list.cdata() + range.start()),
|
||||||
|
range.size()
|
||||||
|
);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -176,13 +176,21 @@ std::streamsize Foam::UList<T>::byteSize() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
Foam::label Foam::UList<T>::find(const T& val) const
|
||||||
|
{
|
||||||
|
const auto iter = std::find(this->cbegin(), this->cend(), val);
|
||||||
|
return (iter != this->cend() ? label(iter - this->cbegin()) : label(-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Foam::label Foam::UList<T>::find(const T& val, label pos, label len) const
|
Foam::label Foam::UList<T>::find(const T& val, label pos, label len) const
|
||||||
{
|
{
|
||||||
if (pos >= 0 && pos < this->size())
|
if (pos >= 0 && pos < this->size())
|
||||||
{
|
{
|
||||||
// Change length to end iterator position
|
// Change sub-length to (one-past) end position
|
||||||
// len == -1 has same meaning as std::string::npos - search until end
|
// len == -1 (like std::string::npos) - search until end
|
||||||
|
|
||||||
if (len > 0) len += pos;
|
if (len > 0) len += pos;
|
||||||
if (len < 0 || len > this->size())
|
if (len < 0 || len > this->size())
|
||||||
@ -190,13 +198,16 @@ Foam::label Foam::UList<T>::find(const T& val, label pos, label len) const
|
|||||||
len = this->size();
|
len = this->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto iter = (this->cbegin() + pos);
|
const auto iter = std::find
|
||||||
const auto lastIter = (this->cbegin() + len);
|
(
|
||||||
|
(this->cbegin() + pos),
|
||||||
|
(this->cbegin() + len),
|
||||||
|
val
|
||||||
|
);
|
||||||
|
|
||||||
iter = std::find(iter, lastIter, val);
|
if (iter != (this->cbegin() + len))
|
||||||
if (iter != lastIter)
|
|
||||||
{
|
{
|
||||||
return label(iter - this->begin());
|
return label(iter - this->cbegin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +218,8 @@ Foam::label Foam::UList<T>::find(const T& val, label pos, label len) const
|
|||||||
template<class T>
|
template<class T>
|
||||||
Foam::label Foam::UList<T>::rfind(const T& val, label pos) const
|
Foam::label Foam::UList<T>::rfind(const T& val, label pos) const
|
||||||
{
|
{
|
||||||
// pos == -1 has same meaning as std::string::npos - search from end
|
// pos == -1 (like std::string::npos) - search from end
|
||||||
|
|
||||||
if (pos < 0 || pos >= this->size())
|
if (pos < 0 || pos >= this->size())
|
||||||
{
|
{
|
||||||
pos = this->size()-1;
|
pos = this->size()-1;
|
||||||
|
|||||||
@ -318,12 +318,27 @@ public:
|
|||||||
|
|
||||||
// Search
|
// Search
|
||||||
|
|
||||||
|
//- True if the value is contained in the list.
|
||||||
|
inline bool contains(const T& val) const;
|
||||||
|
|
||||||
|
//- Is the value contained in the list?
|
||||||
|
// \param val The value to search for
|
||||||
|
// \param pos The first position to examine (no-op if -ve)
|
||||||
|
// \param len The length of the search region (-ve until the end)
|
||||||
|
// \return true if found.
|
||||||
|
inline bool contains(const T& val, label pos, label len = -1) const;
|
||||||
|
|
||||||
//- Find index of the first occurrence of the value.
|
//- Find index of the first occurrence of the value.
|
||||||
// \param val The value to search for
|
// \param val The value to search for
|
||||||
// \param pos Initial position to examine (default: 0, -ve no-op)
|
// \return position in list or -1 if not found.
|
||||||
|
label find(const T& val) const;
|
||||||
|
|
||||||
|
//- Find index of the first occurrence of the value.
|
||||||
|
// \param val The value to search for
|
||||||
|
// \param pos The first position to examine (no-op if -ve)
|
||||||
// \param len The length of the search region (-ve until the end)
|
// \param len The length of the search region (-ve until the end)
|
||||||
// \return position in list or -1 if not found.
|
// \return position in list or -1 if not found.
|
||||||
label find(const T& val, label pos = 0, label len = -1) const;
|
label find(const T& val, label pos, label len = -1) const;
|
||||||
|
|
||||||
//- Find index of the last occurrence of the value.
|
//- Find index of the last occurrence of the value.
|
||||||
// Any occurrences after the end pos are ignored.
|
// Any occurrences after the end pos are ignored.
|
||||||
@ -331,13 +346,6 @@ public:
|
|||||||
// \return position in list or -1 if not found.
|
// \return position in list or -1 if not found.
|
||||||
label rfind(const T& val, label pos = -1) const;
|
label rfind(const T& val, label pos = -1) const;
|
||||||
|
|
||||||
//- Is the value contained in the list?
|
|
||||||
// \param val The value to search for
|
|
||||||
// \param pos The first position to examine (default: 0, -ve no-op)
|
|
||||||
// \param len The length of the search region (-ve until the end)
|
|
||||||
// \return true if found.
|
|
||||||
inline bool contains(const T& val, label pos = 0, label len = -1) const;
|
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
@ -356,6 +364,9 @@ public:
|
|||||||
|
|
||||||
// Copy
|
// Copy
|
||||||
|
|
||||||
|
//- Copy the pointer and size
|
||||||
|
inline void shallowCopy(T* __restrict__ ptr, const label len) noexcept;
|
||||||
|
|
||||||
//- Copy the pointer and size held by the given UList
|
//- Copy the pointer and size held by the given UList
|
||||||
inline void shallowCopy(const UList<T>& list) noexcept;
|
inline void shallowCopy(const UList<T>& list) noexcept;
|
||||||
|
|
||||||
@ -665,7 +676,11 @@ Ostream& operator<<(Ostream& os, const UList<T>& list)
|
|||||||
return list.writeList(os, Detail::ListPolicy::short_length<T>::value);
|
return list.writeList(os, Detail::ListPolicy::short_length<T>::value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write std::vector to Ostream. ASCII only, no line-breaks
|
//- Read std::vector contents from Istream
|
||||||
|
template<class T>
|
||||||
|
Istream& operator>>(Istream& is, std::vector<T>& list);
|
||||||
|
|
||||||
|
//- Write std::vector to Ostream (via UList)
|
||||||
template<class T>
|
template<class T>
|
||||||
Ostream& operator<<(Ostream& os, const std::vector<T>& list);
|
Ostream& operator<<(Ostream& os, const std::vector<T>& list);
|
||||||
|
|
||||||
|
|||||||
@ -303,6 +303,14 @@ inline std::streamsize Foam::UList<T>::size_bytes() const noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline bool Foam::UList<T>::contains(const T& val) const
|
||||||
|
{
|
||||||
|
const auto iter = std::find(this->begin(), this->end(), val);
|
||||||
|
return (iter != this->end());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool Foam::UList<T>::contains(const T& val, label pos, label len) const
|
inline bool Foam::UList<T>::contains(const T& val, label pos, label len) const
|
||||||
{
|
{
|
||||||
@ -310,6 +318,18 @@ inline bool Foam::UList<T>::contains(const T& val, label pos, label len) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline void Foam::UList<T>::shallowCopy
|
||||||
|
(
|
||||||
|
T* __restrict__ ptr,
|
||||||
|
const label len
|
||||||
|
) noexcept
|
||||||
|
{
|
||||||
|
size_ = len;
|
||||||
|
v_ = ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void Foam::UList<T>::shallowCopy(const UList<T>& list) noexcept
|
inline void Foam::UList<T>::shallowCopy(const UList<T>& list) noexcept
|
||||||
{
|
{
|
||||||
|
|||||||
@ -187,10 +187,7 @@ Foam::Istream& Foam::UList<T>::readList(Istream& is)
|
|||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (label i = 0; i < len; ++i)
|
std::move(elems.begin(), elems.end(), list.begin());
|
||||||
{
|
|
||||||
list[i] = std::move(elems[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (tok.isLabel())
|
else if (tok.isLabel())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -26,35 +26,183 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "UList.H"
|
#include "UList.H"
|
||||||
|
#include "Istream.H"
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
|
#include "contiguous.H"
|
||||||
#include "token.H"
|
#include "token.H"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const std::vector<T>& list)
|
Foam::Istream& Foam::operator>>(Istream& is, std::vector<T>& list)
|
||||||
{
|
{
|
||||||
auto iter = list.cbegin();
|
is.fatalCheck(FUNCTION_NAME);
|
||||||
const auto last = list.cend();
|
|
||||||
|
|
||||||
// Write ascii list contents, no line breaks
|
token tok(is);
|
||||||
|
|
||||||
os << label(list.size()) << token::BEGIN_LIST;
|
is.fatalCheck("Istream >> std::vector<T> : reading first token");
|
||||||
|
|
||||||
if (iter != last)
|
if (tok.isCompound())
|
||||||
{
|
{
|
||||||
os << *iter;
|
// No compound handling ...
|
||||||
|
|
||||||
while (++iter != last)
|
list.clear(); // Clear old contents
|
||||||
|
FatalIOErrorInFunction(is)
|
||||||
|
<< "Support for compoundToken - not implemented" << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
else if (tok.isLabel())
|
||||||
|
{
|
||||||
|
// Label: could be int(..), int{...} or just a plain '0'
|
||||||
|
|
||||||
|
const label len = tok.labelToken();
|
||||||
|
|
||||||
|
// Resize to length required
|
||||||
|
list.resize(len);
|
||||||
|
|
||||||
|
if (is.format() == IOstreamOption::BINARY && is_contiguous<T>::value)
|
||||||
{
|
{
|
||||||
os << token::SPACE << *iter;
|
// Binary and contiguous
|
||||||
|
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
Detail::readContiguous<T>
|
||||||
|
(
|
||||||
|
is,
|
||||||
|
reinterpret_cast<char*>(list.data()), // data_bytes()
|
||||||
|
std::streamsize(list.size())*sizeof(T) // size_bytes()
|
||||||
|
);
|
||||||
|
|
||||||
|
is.fatalCheck
|
||||||
|
(
|
||||||
|
"Istream >> std::vector<T> : "
|
||||||
|
"reading binary block"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (std::is_same<char, T>::value)
|
||||||
|
{
|
||||||
|
// Special treatment for char data (binary I/O only)
|
||||||
|
const auto oldFmt = is.format(IOstreamOption::BINARY);
|
||||||
|
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
// read(...) includes surrounding start/end delimiters
|
||||||
|
is.read
|
||||||
|
(
|
||||||
|
reinterpret_cast<char*>(list.data()), // data_bytes()
|
||||||
|
std::streamsize(list.size())*sizeof(T) // size_bytes()
|
||||||
|
);
|
||||||
|
|
||||||
|
is.fatalCheck
|
||||||
|
(
|
||||||
|
"Istream >> std::vector<char> : "
|
||||||
|
"reading binary block"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
is.format(oldFmt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Begin of contents marker
|
||||||
|
const char delimiter = is.readBeginList("List");
|
||||||
|
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
if (delimiter == token::BEGIN_LIST)
|
||||||
|
{
|
||||||
|
auto iter = list.begin();
|
||||||
|
const auto last = list.end();
|
||||||
|
|
||||||
|
// Contents
|
||||||
|
for (/*nil*/; (iter != last); (void)++iter)
|
||||||
|
{
|
||||||
|
is >> *iter;
|
||||||
|
|
||||||
|
is.fatalCheck
|
||||||
|
(
|
||||||
|
"Istream >> std::vector<char> : "
|
||||||
|
"reading entry"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Uniform content (delimiter == token::BEGIN_BLOCK)
|
||||||
|
|
||||||
|
T elem;
|
||||||
|
is >> elem;
|
||||||
|
|
||||||
|
is.fatalCheck
|
||||||
|
(
|
||||||
|
"Istream >> std::vector<char> : "
|
||||||
|
"reading the single entry"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Fill with the value
|
||||||
|
list.assign(list.size(), elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// End of contents marker
|
||||||
|
is.readEndList("List");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (tok.isPunctuation(token::BEGIN_LIST))
|
||||||
|
{
|
||||||
|
// "(...)" : read as bracketed list
|
||||||
|
|
||||||
os << token::END_LIST;
|
// Slightly sub-optimal since it has intermediate resizing,
|
||||||
|
// however don't expect this as input very often.
|
||||||
|
|
||||||
os.check(FUNCTION_NAME);
|
list.clear(); // Clear addressing, leave storage intact (probably)
|
||||||
|
|
||||||
|
is >> tok;
|
||||||
|
is.fatalCheck(FUNCTION_NAME);
|
||||||
|
|
||||||
|
while (!tok.isPunctuation(token::END_LIST))
|
||||||
|
{
|
||||||
|
is.putBack(tok);
|
||||||
|
|
||||||
|
// C++17
|
||||||
|
// is >> list.emplace_back();
|
||||||
|
|
||||||
|
// C++11
|
||||||
|
list.emplace_back();
|
||||||
|
is >> list.back();
|
||||||
|
|
||||||
|
is.fatalCheck
|
||||||
|
(
|
||||||
|
"Istream >> std::vector<char> : "
|
||||||
|
"reading entry"
|
||||||
|
);
|
||||||
|
|
||||||
|
is >> tok;
|
||||||
|
is.fatalCheck(FUNCTION_NAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list.clear(); // Clear old contents
|
||||||
|
|
||||||
|
FatalIOErrorInFunction(is)
|
||||||
|
<< "incorrect first token, expected <int> or '(', found "
|
||||||
|
<< tok.info() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
Foam::Ostream& Foam::operator<<(Ostream& os, const std::vector<T>& list)
|
||||||
|
{
|
||||||
|
// Use UList for output
|
||||||
|
UList<T> proxy(const_cast<T*>(list.data()), label(list.size()));
|
||||||
|
os << proxy;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -88,6 +88,41 @@ template<> struct no_linebreak<word> : std::true_type {};
|
|||||||
template<> struct no_linebreak<wordRe> : std::true_type {};
|
template<> struct no_linebreak<wordRe> : std::true_type {};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//- Classification of list/container uniformity.
|
||||||
|
//- The values can be used with bit-wise \c or reduction
|
||||||
|
enum uniformity : unsigned char
|
||||||
|
{
|
||||||
|
EMPTY = 0, //!< An empty container
|
||||||
|
UNIFORM = 0x1, //!< Container (non-empty) with identical values
|
||||||
|
NONUNIFORM = 0x2, //!< Container (non-empty) with different values
|
||||||
|
MIXED = 0x3 //!< Mixed uniform/non-uniform (eg, after reduction)
|
||||||
|
};
|
||||||
|
|
||||||
|
//- Algorithm to determine list/container uniformity
|
||||||
|
template<class InputIt>
|
||||||
|
enum uniformity check_uniformity(InputIt first, InputIt last)
|
||||||
|
{
|
||||||
|
if (first == last) return uniformity::EMPTY;
|
||||||
|
|
||||||
|
// Like std::all_of() with checking against element 0,
|
||||||
|
// but without using a lambda with auto type (pre C++14) etc.
|
||||||
|
|
||||||
|
const auto& elem0 = *first;
|
||||||
|
|
||||||
|
for ((void)++first; (first != last); (void)++first)
|
||||||
|
{
|
||||||
|
if (elem0 != *first)
|
||||||
|
{
|
||||||
|
return uniformity::NONUNIFORM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return uniformity::UNIFORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace ListPolicy
|
} // End namespace ListPolicy
|
||||||
|
|||||||
@ -399,7 +399,7 @@ Foam::functionObjectList::functionObjectList
|
|||||||
errorHandling_(),
|
errorHandling_(),
|
||||||
digests_(),
|
digests_(),
|
||||||
indices_(),
|
indices_(),
|
||||||
warnings_(),
|
warnings_(0),
|
||||||
time_(runTime),
|
time_(runTime),
|
||||||
parentDict_(parentDict),
|
parentDict_(parentDict),
|
||||||
propsDictPtr_(nullptr),
|
propsDictPtr_(nullptr),
|
||||||
@ -664,7 +664,7 @@ bool Foam::functionObjectList::execute()
|
|||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
(errorHandling != error::handlerTypes::IGNORE)
|
(errorHandling == error::handlerTypes::WARN)
|
||||||
&& (nWarnings = ++warnings_(objName)) <= maxWarnings
|
&& (nWarnings = ++warnings_(objName)) <= maxWarnings
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -706,10 +706,11 @@ bool Foam::functionObjectList::execute()
|
|||||||
{
|
{
|
||||||
// Treat IOerror and error identically
|
// Treat IOerror and error identically
|
||||||
unsigned nWarnings;
|
unsigned nWarnings;
|
||||||
|
hadError = true;
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
(errorHandling != error::handlerTypes::IGNORE)
|
(errorHandling == error::handlerTypes::WARN)
|
||||||
&& (nWarnings = ++warnings_(objName)) <= maxWarnings
|
&& (nWarnings = ++warnings_(objName)) <= maxWarnings
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -731,6 +732,17 @@ bool Foam::functionObjectList::execute()
|
|||||||
// Restore previous state
|
// Restore previous state
|
||||||
FatalError.throwing(oldThrowingError);
|
FatalError.throwing(oldThrowingError);
|
||||||
FatalIOError.throwing(oldThrowingIOerr);
|
FatalIOError.throwing(oldThrowingIOerr);
|
||||||
|
|
||||||
|
// Reset the warning counter (if any)
|
||||||
|
// if no errors were encountered
|
||||||
|
if
|
||||||
|
(
|
||||||
|
(errorHandling == error::handlerTypes::WARN)
|
||||||
|
&& !hadError && !warnings_.empty()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
warnings_.erase(objName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -857,32 +869,35 @@ bool Foam::functionObjectList::end()
|
|||||||
catch (const Foam::error& err)
|
catch (const Foam::error& err)
|
||||||
{
|
{
|
||||||
// Treat IOerror and error identically
|
// Treat IOerror and error identically
|
||||||
unsigned nWarnings;
|
// If it somehow failed, emit a warning (unless IGNORE).
|
||||||
|
// Unlike execute(), do not suppress further warning messages
|
||||||
|
// (we want to know about rare issues)
|
||||||
|
// but do reset the warnings counter for the next cycle.
|
||||||
|
|
||||||
if
|
if (errorHandling != error::handlerTypes::IGNORE)
|
||||||
(
|
|
||||||
(errorHandling != error::handlerTypes::IGNORE)
|
|
||||||
&& (nWarnings = ++warnings_(objName)) <= maxWarnings
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// Trickery to get original message
|
// Trickery to get original message
|
||||||
err.write(Warning, false);
|
err.write(Warning, false);
|
||||||
Info<< nl
|
Info<< nl
|
||||||
<< "--> end() function object '"
|
<< "--> end() function object '"
|
||||||
<< objName << "'";
|
<< objName << "'"
|
||||||
|
<< nl << endl;
|
||||||
if (nWarnings == maxWarnings)
|
|
||||||
{
|
|
||||||
Info<< nl << "... silencing further warnings";
|
|
||||||
}
|
|
||||||
|
|
||||||
Info<< nl << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore previous state
|
// Restore previous state
|
||||||
FatalError.throwing(oldThrowingError);
|
FatalError.throwing(oldThrowingError);
|
||||||
FatalIOError.throwing(oldThrowingIOerr);
|
FatalIOError.throwing(oldThrowingIOerr);
|
||||||
|
|
||||||
|
// Reset the corresponding warning counter (if any)
|
||||||
|
if
|
||||||
|
(
|
||||||
|
(errorHandling == error::handlerTypes::WARN)
|
||||||
|
&& !warnings_.empty()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
warnings_.erase(objName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,154 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | www.openfoam.com
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
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::SubDimensionedField
|
|
||||||
|
|
||||||
Description
|
|
||||||
SubDimensionedField is a DimensionedField obtained as a section of another
|
|
||||||
DimensionedField.
|
|
||||||
|
|
||||||
Thus it is itself unallocated so that no storage is allocated or
|
|
||||||
deallocated during its use. To achieve this behaviour,
|
|
||||||
SubDimensionedField is derived from SubField rather than Field.
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
SubDimensionedFieldI.H
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef SubDimensionedField_H
|
|
||||||
#define SubDimensionedField_H
|
|
||||||
|
|
||||||
#include "Field.H"
|
|
||||||
#include "SubField.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class SubDimensionedField Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
class SubDimensionedField
|
|
||||||
:
|
|
||||||
public regIOobject,
|
|
||||||
public SubField<Type>
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Public typedefs
|
|
||||||
|
|
||||||
typedef typename GeoMesh::Mesh Mesh;
|
|
||||||
typedef typename Field<Type>::cmptType cmptType;
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Construct from a SubField
|
|
||||||
inline SubDimensionedField(const SubField<Type>& sfield);
|
|
||||||
|
|
||||||
//- Construct from a UList and size
|
|
||||||
inline SubDimensionedField
|
|
||||||
(
|
|
||||||
const UList<Type>& list,
|
|
||||||
const label subSize
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Construct from a UList start and end indices
|
|
||||||
inline SubDimensionedField
|
|
||||||
(
|
|
||||||
const UList<Type>& list,
|
|
||||||
const label subSize,
|
|
||||||
const label startIndex
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Construct from UList and a (start,size) range.
|
|
||||||
// The range is subsetted with the list size itself to ensure that the
|
|
||||||
// result always addresses a valid section of the list.
|
|
||||||
inline SubDimensionedField
|
|
||||||
(
|
|
||||||
const UList<Type>& list,
|
|
||||||
const labelRange& range
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Construct from UList and a (start,size) range, but bypassing
|
|
||||||
//- run-time range checking.
|
|
||||||
inline SubDimensionedField
|
|
||||||
(
|
|
||||||
const labelRange& range,
|
|
||||||
const UList<Type>& list
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Construct as copy
|
|
||||||
inline SubDimensionedField
|
|
||||||
(
|
|
||||||
const SubDimensionedField<cmptType, GeoMesh>& sfield
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
|
||||||
|
|
||||||
//- Return a null SubDimensionedField
|
|
||||||
static inline const SubDimensionedField<Type, GeoMesh>& null();
|
|
||||||
|
|
||||||
//- Return a component field of the field
|
|
||||||
inline tmp<DimensionedField<cmptType, GeoMesh>> component
|
|
||||||
(
|
|
||||||
const direction d
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Return the field transpose (only defined for second rank tensors)
|
|
||||||
tmp<DimensionedField<Type, GeoMesh>> T() const;
|
|
||||||
|
|
||||||
|
|
||||||
// Member operators
|
|
||||||
|
|
||||||
//- Assignment
|
|
||||||
inline void operator=(const SubDimensionedField<Type, GeoMesh>& rhs);
|
|
||||||
|
|
||||||
//- Allow cast to a const DimensionedField<Type, GeoMesh>&
|
|
||||||
inline operator const DimensionedField<Type, GeoMesh>&() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#include "SubDimensionedFieldI.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,156 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | www.openfoam.com
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
inline Foam::SubDimensionedField<Type, GeoMesh>::SubDimensionedField
|
|
||||||
(
|
|
||||||
const SubField<Type>& sfield
|
|
||||||
)
|
|
||||||
:
|
|
||||||
SubField<Type>(sfield)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
inline Foam::SubDimensionedField<Type, GeoMesh>::SubDimensionedField
|
|
||||||
(
|
|
||||||
const UList<Type>& list,
|
|
||||||
const label subSize
|
|
||||||
)
|
|
||||||
:
|
|
||||||
SubField<Type>(list, subSize)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
inline Foam::SubDimensionedField<Type, GeoMesh>::SubDimensionedField
|
|
||||||
(
|
|
||||||
const UList<Type>& list,
|
|
||||||
const label subSize,
|
|
||||||
const label startIndex
|
|
||||||
)
|
|
||||||
:
|
|
||||||
SubField<Type>(list, subSize, startIndex)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
inline Foam::SubDimensionedField<Type, GeoMesh>::SubDimensionedField
|
|
||||||
(
|
|
||||||
const UList<Type>& list,
|
|
||||||
const labelRange& range
|
|
||||||
)
|
|
||||||
:
|
|
||||||
SubField<Type>(list, range)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
inline Foam::SubDimensionedField<Type, GeoMesh>::SubDimensionedField
|
|
||||||
(
|
|
||||||
const labelRange& range,
|
|
||||||
const UList<Type>& list
|
|
||||||
)
|
|
||||||
:
|
|
||||||
SubField<Type>(range, list)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
inline Foam::SubDimensionedField<Type, GeoMesh>::SubDimensionedField
|
|
||||||
(
|
|
||||||
const SubDimensionedField<Type, GeoMesh>& sfield
|
|
||||||
)
|
|
||||||
:
|
|
||||||
refCount(),
|
|
||||||
SubField<Type>(sfield)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
inline const Foam::SubDimensionedField<Type, GeoMesh>&
|
|
||||||
Foam::SubDimensionedField<Type, GeoMesh>::null()
|
|
||||||
{
|
|
||||||
return NullObjectRef<SubDimensionedField<Type, GeoMesh>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
inline
|
|
||||||
Foam::tmp
|
|
||||||
<
|
|
||||||
Foam::Field<typename Foam::SubDimensionedField<Type, GeoMesh>::cmptType>
|
|
||||||
>
|
|
||||||
Foam::SubDimensionedField<Type, GeoMesh>::component
|
|
||||||
(
|
|
||||||
const direction d
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return
|
|
||||||
(
|
|
||||||
reinterpret_cast<const DimensionedField<Type, GeoMesh>&>(*this)
|
|
||||||
).component(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
inline Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
|
|
||||||
Foam::SubDimensionedField<Type, GeoMesh>::T() const
|
|
||||||
{
|
|
||||||
return
|
|
||||||
(
|
|
||||||
reinterpret_cast<const DimensionedField<Type, GeoMesh>&>(*this)
|
|
||||||
).T();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
inline void Foam::SubDimensionedField<Type, GeoMesh>::operator=
|
|
||||||
(
|
|
||||||
const SubDimensionedField<Type, GeoMesh>& rhs
|
|
||||||
)
|
|
||||||
{
|
|
||||||
dimensions() = rhs.dimensions();
|
|
||||||
SubField<Type>::operator=(rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
inline Foam::SubDimensionedField<Type, GeoMesh>::operator
|
|
||||||
const Foam::DimensionedField<Type, GeoMesh>&() const
|
|
||||||
{
|
|
||||||
return *(reinterpret_cast<const DimensionedField<Type, GeoMesh>*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -172,7 +172,7 @@ public:
|
|||||||
|
|
||||||
#include "SubFieldI.H"
|
#include "SubFieldI.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Implementations * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::SubField<Type>
|
Foam::SubField<Type>
|
||||||
|
|||||||
@ -146,9 +146,9 @@ Foam::Ostream& Foam::Matrix<Form, Type>::writeMatrix
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const Matrix<Form, Type>& mat = *this;
|
const Matrix<Form, Type>& mat = *this;
|
||||||
|
const label len = mat.size(); // Total size (rows * cols)
|
||||||
|
|
||||||
// The total size
|
auto iter = mat.cbegin(); // element-wise iterator
|
||||||
const label len = mat.size();
|
|
||||||
|
|
||||||
// Rows, columns size
|
// Rows, columns size
|
||||||
os << mat.nRows() << token::SPACE << mat.nCols();
|
os << mat.nRows() << token::SPACE << mat.nCols();
|
||||||
@ -163,73 +163,101 @@ Foam::Ostream& Foam::Matrix<Form, Type>::writeMatrix
|
|||||||
os.write(mat.cdata_bytes(), mat.size_bytes());
|
os.write(mat.cdata_bytes(), mat.size_bytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (len > 1 && is_contiguous<Type>::value && mat.uniform())
|
||||||
|
{
|
||||||
|
// Two or more entries, and all entries have identical values.
|
||||||
|
os << token::BEGIN_BLOCK << *iter << token::END_BLOCK;
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
(len <= 1 || !shortLen)
|
||||||
|
|| (len <= shortLen && is_contiguous<Type>::value)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Single-line output (entire matrix)
|
||||||
|
|
||||||
|
// Begin matrix
|
||||||
|
os << token::BEGIN_LIST;
|
||||||
|
|
||||||
|
// Loop over rows
|
||||||
|
for (label i = 0; i < mat.nRows(); ++i)
|
||||||
|
{
|
||||||
|
// Begin row
|
||||||
|
os << token::BEGIN_LIST;
|
||||||
|
|
||||||
|
// Write row
|
||||||
|
for (label j = 0; j < mat.nCols(); ++j)
|
||||||
|
{
|
||||||
|
if (j) os << token::SPACE;
|
||||||
|
os << *iter;
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
// End row
|
||||||
|
os << token::END_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
// End matrix
|
||||||
|
os << token::END_LIST;
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
(mat.nCols() <= 1 || !shortLen)
|
||||||
|
|| (mat.nCols() <= shortLen && is_contiguous<Type>::value)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Multi-line matrix, single-line rows
|
||||||
|
|
||||||
|
// Begin matrix
|
||||||
|
os << nl << token::BEGIN_LIST;
|
||||||
|
|
||||||
|
// Loop over rows
|
||||||
|
for (label i = 0; i < mat.nRows(); ++i)
|
||||||
|
{
|
||||||
|
// Begin row
|
||||||
|
os << nl << token::BEGIN_LIST;
|
||||||
|
|
||||||
|
// Write row
|
||||||
|
for (label j = 0; j < mat.nCols(); ++j)
|
||||||
|
{
|
||||||
|
if (j) os << token::SPACE;
|
||||||
|
os << *iter;
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
// End row
|
||||||
|
os << token::END_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
// End matrix
|
||||||
|
os << nl << token::END_LIST << nl;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (len)
|
// Multi-line output
|
||||||
|
|
||||||
|
// Begin matrix
|
||||||
|
os << nl << token::BEGIN_LIST;
|
||||||
|
|
||||||
|
// Loop over rows
|
||||||
|
for (label i=0; i < mat.nRows(); ++i)
|
||||||
{
|
{
|
||||||
const Type* v = mat.cdata();
|
// Begin row
|
||||||
|
os << nl << token::BEGIN_LIST;
|
||||||
|
|
||||||
// Can the contents be considered 'uniform' (ie, identical)
|
// Write row
|
||||||
if (len > 1 && is_contiguous<Type>::value && mat.uniform())
|
for (label j = 0; j < mat.nCols(); ++j)
|
||||||
{
|
{
|
||||||
// Two or more entries, and all entries have identical values.
|
os << nl << *iter;
|
||||||
os << token::BEGIN_BLOCK << v[0] << token::END_BLOCK;
|
++iter;
|
||||||
}
|
}
|
||||||
else if (len < shortLen && is_contiguous<Type>::value)
|
|
||||||
{
|
|
||||||
// Write start contents delimiter
|
|
||||||
os << token::BEGIN_LIST;
|
|
||||||
|
|
||||||
label idx = 0;
|
// End row
|
||||||
|
os << nl << token::END_LIST;
|
||||||
// Loop over rows
|
|
||||||
for (label i = 0; i < mat.nRows(); ++i)
|
|
||||||
{
|
|
||||||
os << token::BEGIN_LIST;
|
|
||||||
|
|
||||||
// Write row
|
|
||||||
for (label j = 0; j < mat.nCols(); ++j)
|
|
||||||
{
|
|
||||||
if (j) os << token::SPACE;
|
|
||||||
os << v[idx++];
|
|
||||||
}
|
|
||||||
|
|
||||||
os << token::END_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write end of contents delimiter
|
|
||||||
os << token::END_LIST;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Write start contents delimiter
|
|
||||||
os << nl << token::BEGIN_LIST;
|
|
||||||
|
|
||||||
label idx = 0;
|
|
||||||
|
|
||||||
// Loop over rows
|
|
||||||
for (label i=0; i < mat.nRows(); ++i)
|
|
||||||
{
|
|
||||||
os << nl << token::BEGIN_LIST;
|
|
||||||
|
|
||||||
// Write row
|
|
||||||
for (label j = 0; j < mat.nCols(); ++j)
|
|
||||||
{
|
|
||||||
os << nl << v[idx++];
|
|
||||||
}
|
|
||||||
|
|
||||||
os << nl << token::END_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write end of contents delimiter
|
|
||||||
os << nl << token::END_LIST << nl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Empty matrix
|
|
||||||
os << token::BEGIN_LIST << token::END_LIST << nl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// End matrix
|
||||||
|
os << nl << token::END_LIST << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
os.check(FUNCTION_NAME);
|
os.check(FUNCTION_NAME);
|
||||||
|
|||||||
@ -150,6 +150,9 @@ public:
|
|||||||
//- Resize the matrix preserving the elements
|
//- Resize the matrix preserving the elements
|
||||||
inline void resize(const label m);
|
inline void resize(const label m);
|
||||||
|
|
||||||
|
//- Resize the matrix \em without preserving existing content
|
||||||
|
inline void resize_nocopy(const label n);
|
||||||
|
|
||||||
//- Resize the matrix preserving the elements (compatibility)
|
//- Resize the matrix preserving the elements (compatibility)
|
||||||
inline void resize(const label m, const label n);
|
inline void resize(const label m, const label n);
|
||||||
|
|
||||||
|
|||||||
@ -218,6 +218,13 @@ inline void Foam::SquareMatrix<Type>::resize(const label m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline void Foam::SquareMatrix<Type>::resize_nocopy(const label m)
|
||||||
|
{
|
||||||
|
Matrix<SquareMatrix<Type>, Type>::resize_nocopy(m, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
inline void Foam::SquareMatrix<Type>::resize(const label m, const label n)
|
inline void Foam::SquareMatrix<Type>::resize(const label m, const label n)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -157,7 +157,7 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
|
|||||||
cyclicAMIPatch_(ptf.cyclicAMIPatch_),
|
cyclicAMIPatch_(ptf.cyclicAMIPatch_),
|
||||||
sendRequests_(0),
|
sendRequests_(0),
|
||||||
recvRequests_(0),
|
recvRequests_(0),
|
||||||
patchNeighbourFieldPtr_(ptf.patchNeighbourFieldPtr_.clone())
|
patchNeighbourFieldPtr_(ptf.patchNeighbourFieldPtr_)
|
||||||
{
|
{
|
||||||
if (debug && !ptf.all_ready())
|
if (debug && !ptf.all_ready())
|
||||||
{
|
{
|
||||||
@ -180,7 +180,7 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
|
|||||||
cyclicAMIPatch_(ptf.cyclicAMIPatch_),
|
cyclicAMIPatch_(ptf.cyclicAMIPatch_),
|
||||||
sendRequests_(0),
|
sendRequests_(0),
|
||||||
recvRequests_(0),
|
recvRequests_(0),
|
||||||
patchNeighbourFieldPtr_(ptf.patchNeighbourFieldPtr_.clone())
|
patchNeighbourFieldPtr_(nullptr)
|
||||||
{
|
{
|
||||||
if (debug && !ptf.all_ready())
|
if (debug && !ptf.all_ready())
|
||||||
{
|
{
|
||||||
@ -655,7 +655,7 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
|
|||||||
const labelUList& nbrFaceCells =
|
const labelUList& nbrFaceCells =
|
||||||
lduAddr.patchAddr(cyclicAMIPatch_.neighbPatchID());
|
lduAddr.patchAddr(cyclicAMIPatch_.neighbPatchID());
|
||||||
|
|
||||||
Field<Type> pnf(psiInternal, nbrFaceCells);
|
pnf = Field<Type>(psiInternal, nbrFaceCells);
|
||||||
|
|
||||||
// Transform according to the transformation tensors
|
// Transform according to the transformation tensors
|
||||||
transformCoupleField(pnf);
|
transformCoupleField(pnf);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2013-2016 OpenFOAM Foundation
|
Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -61,10 +61,11 @@ bool Foam::functionObjects::Lambda2::calc()
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// (JH:p. 76-78)
|
||||||
return store
|
return store
|
||||||
(
|
(
|
||||||
resultName_,
|
resultName_,
|
||||||
-eigenValues(SSplusWW)().component(vector::Y)
|
eigenValues(SSplusWW)().component(vector::Y)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2013-2016 OpenFOAM Foundation
|
Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -37,30 +37,39 @@ Description
|
|||||||
Operands:
|
Operands:
|
||||||
\table
|
\table
|
||||||
Operand | Type | Location
|
Operand | Type | Location
|
||||||
input | volVectorField | $FOAM_CASE/\<time\>/\<inpField\>
|
input | volVectorField | \<case\>/\<time\>/\<inpField\>
|
||||||
output file | - | -
|
output file | - | -
|
||||||
output field | volScalarField | $FOAM_CASE/\<time\>/\<outField\>
|
output field | volScalarField | \<case\>/\<time\>/\<outField\>
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
|
References:
|
||||||
|
\verbatim
|
||||||
|
Governing equation (tag:JH):
|
||||||
|
Jeong, J., & Hussain, F. (1995).
|
||||||
|
On the identification of a vortex.
|
||||||
|
Journal of Fluid Mechanics, 285, 69-94.
|
||||||
|
DOI:10.1017/S0022112095000462
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
Minimal example by using \c system/controlDict.functions:
|
Minimal example by using \c system/controlDict.functions:
|
||||||
\verbatim
|
\verbatim
|
||||||
Lambda21
|
Lambda21
|
||||||
{
|
{
|
||||||
// Mandatory entries (unmodifiable)
|
// Mandatory entries
|
||||||
type Lambda2;
|
type Lambda2;
|
||||||
libs (fieldFunctionObjects);
|
libs (fieldFunctionObjects);
|
||||||
|
|
||||||
// Optional (inherited) entries
|
// Inherited entries
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
where the entries mean:
|
where the entries mean:
|
||||||
\table
|
\table
|
||||||
Property | Description | Type | Req'd | Dflt
|
Property | Description | Type | Reqd | Deflt
|
||||||
type | Type name: Lambda2 | word | yes | -
|
type | Type name: Lambda2 | word | yes | -
|
||||||
libs | Library name: fieldFunctionObjects | word | yes | -
|
libs | Library name: fieldFunctionObjects | word | yes | -
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
The inherited entries are elaborated in:
|
The inherited entries are elaborated in:
|
||||||
@ -72,12 +81,6 @@ Usage
|
|||||||
postProcess -func Lambda2
|
postProcess -func Lambda2
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
See also
|
|
||||||
- Foam::functionObject
|
|
||||||
- Foam::functionObjects::fvMeshFunctionObject
|
|
||||||
- Foam::functionObjects::fieldExpression
|
|
||||||
- ExtendedCodeGuide::functionObjects::field::Lambda2
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
Lambda2.C
|
Lambda2.C
|
||||||
|
|
||||||
|
|||||||
@ -3344,24 +3344,33 @@ void Foam::meshRefinement::zonify
|
|||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
|
|
||||||
// Collect per surface the -insidePoint -cellZone
|
// Collect per surface the -insidePoint -cellZone
|
||||||
pointField insidePoints(locationSurfaces.size());
|
// Usually only a single inside point per surface so no clever
|
||||||
labelList insidePointCellZoneIDs(locationSurfaces.size(), -1);
|
// counting - just use DynamicField
|
||||||
|
DynamicField<point> insidePoints(locationSurfaces.size());
|
||||||
|
DynamicList<label> insidePointCellZoneIDs(locationSurfaces.size());
|
||||||
forAll(locationSurfaces, i)
|
forAll(locationSurfaces, i)
|
||||||
{
|
{
|
||||||
label surfI = locationSurfaces[i];
|
const label surfI = locationSurfaces[i];
|
||||||
insidePoints[i] = surfZones[surfI].zoneInsidePoint();
|
const auto& surfInsidePoints = surfZones[surfI].zoneInsidePoints();
|
||||||
|
|
||||||
const word& name = surfZones[surfI].cellZoneName();
|
const word& name = surfZones[surfI].cellZoneName();
|
||||||
|
label zoneID = -1;
|
||||||
if (name != "none")
|
if (name != "none")
|
||||||
{
|
{
|
||||||
label zoneID = mesh_.cellZones().findZoneID(name);
|
zoneID = mesh_.cellZones().findZoneID(name);
|
||||||
if (zoneID == -1)
|
if (zoneID == -1)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "problem"
|
<< "Specified non-existing cellZone " << name
|
||||||
|
<< " for surface " << surfaces_.names()[surfI]
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
insidePointCellZoneIDs[i] = zoneID;
|
}
|
||||||
|
|
||||||
|
for (const auto& pt : surfInsidePoints)
|
||||||
|
{
|
||||||
|
insidePoints.append(pt);
|
||||||
|
insidePointCellZoneIDs.append(zoneID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2013-2015 OpenFOAM Foundation
|
Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -83,7 +83,7 @@ Foam::surfaceZonesInfo::surfaceZonesInfo
|
|||||||
faceZoneNames_(),
|
faceZoneNames_(),
|
||||||
cellZoneName_(),
|
cellZoneName_(),
|
||||||
zoneInside_(NONE),
|
zoneInside_(NONE),
|
||||||
zoneInsidePoint_(point::min),
|
zoneInsidePoints_(),
|
||||||
faceType_(INTERNAL)
|
faceType_(INTERNAL)
|
||||||
{
|
{
|
||||||
const label nRegions = surface.regions().size();
|
const label nRegions = surface.regions().size();
|
||||||
@ -156,9 +156,31 @@ Foam::surfaceZonesInfo::surfaceZonesInfo
|
|||||||
zoneInside_ = areaSelectionAlgoNames[method];
|
zoneInside_ = areaSelectionAlgoNames[method];
|
||||||
if (zoneInside_ == INSIDEPOINT)
|
if (zoneInside_ == INSIDEPOINT)
|
||||||
{
|
{
|
||||||
surfacesDict.readEntry("insidePoint", zoneInsidePoint_);
|
const bool foundPoints = surfacesDict.readIfPresent
|
||||||
}
|
(
|
||||||
|
"insidePoints",
|
||||||
|
zoneInsidePoints_,
|
||||||
|
keyType::LITERAL
|
||||||
|
);
|
||||||
|
|
||||||
|
if (foundPoints)
|
||||||
|
{
|
||||||
|
if (surfacesDict.found("insidePoint", keyType::LITERAL))
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(surfacesDict)
|
||||||
|
<< "Cannot supply both 'insidePoint'"
|
||||||
|
<< " and 'insidePoints'" << exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
zoneInsidePoints_ = pointField
|
||||||
|
(
|
||||||
|
1,
|
||||||
|
surfacesDict.get<point>("insidePoint", keyType::LITERAL)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -216,14 +238,14 @@ Foam::surfaceZonesInfo::surfaceZonesInfo
|
|||||||
const wordList& faceZoneNames,
|
const wordList& faceZoneNames,
|
||||||
const word& cellZoneName,
|
const word& cellZoneName,
|
||||||
const areaSelectionAlgo& zoneInside,
|
const areaSelectionAlgo& zoneInside,
|
||||||
const point& zoneInsidePoint,
|
const pointField& zoneInsidePoints,
|
||||||
const faceZoneType& faceType
|
const faceZoneType& faceType
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
faceZoneNames_(faceZoneNames),
|
faceZoneNames_(faceZoneNames),
|
||||||
cellZoneName_(cellZoneName),
|
cellZoneName_(cellZoneName),
|
||||||
zoneInside_(zoneInside),
|
zoneInside_(zoneInside),
|
||||||
zoneInsidePoint_(zoneInsidePoint),
|
zoneInsidePoints_(zoneInsidePoints),
|
||||||
faceType_(faceType)
|
faceType_(faceType)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -233,7 +255,7 @@ Foam::surfaceZonesInfo::surfaceZonesInfo(const surfaceZonesInfo& surfZone)
|
|||||||
faceZoneNames_(surfZone.faceZoneNames()),
|
faceZoneNames_(surfZone.faceZoneNames()),
|
||||||
cellZoneName_(surfZone.cellZoneName()),
|
cellZoneName_(surfZone.cellZoneName()),
|
||||||
zoneInside_(surfZone.zoneInside()),
|
zoneInside_(surfZone.zoneInside()),
|
||||||
zoneInsidePoint_(surfZone.zoneInsidePoint()),
|
zoneInsidePoints_(surfZone.zoneInsidePoints()),
|
||||||
faceType_(surfZone.faceType())
|
faceType_(surfZone.faceType())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2014 OpenFOAM Foundation
|
Copyright (C) 2014 OpenFOAM Foundation
|
||||||
Copyright (C) 2015 OpenCFD Ltd.
|
Copyright (C) 2015,2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -38,7 +38,7 @@ SourceFiles
|
|||||||
#define surfaceZonesInfo_H
|
#define surfaceZonesInfo_H
|
||||||
|
|
||||||
#include "Enum.H"
|
#include "Enum.H"
|
||||||
#include "point.H"
|
#include "pointField.H"
|
||||||
#include "word.H"
|
#include "word.H"
|
||||||
#include "PtrList.H"
|
#include "PtrList.H"
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
@ -110,7 +110,7 @@ private:
|
|||||||
areaSelectionAlgo zoneInside_;
|
areaSelectionAlgo zoneInside_;
|
||||||
|
|
||||||
//- If zoneInside=location gives the corresponding inside point
|
//- If zoneInside=location gives the corresponding inside point
|
||||||
point zoneInsidePoint_;
|
pointField zoneInsidePoints_;
|
||||||
|
|
||||||
//- Per 'interface' surface :
|
//- Per 'interface' surface :
|
||||||
// What to do with outside
|
// What to do with outside
|
||||||
@ -142,7 +142,7 @@ public:
|
|||||||
const wordList& faceZoneNames,
|
const wordList& faceZoneNames,
|
||||||
const word& cellZoneNames,
|
const word& cellZoneNames,
|
||||||
const areaSelectionAlgo& zoneInside,
|
const areaSelectionAlgo& zoneInside,
|
||||||
const point& zoneInsidePoints,
|
const pointField& zoneInsidePoints,
|
||||||
const faceZoneType& faceType
|
const faceZoneType& faceType
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -179,10 +179,16 @@ public:
|
|||||||
return zoneInside_;
|
return zoneInside_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Get specified inside locations for surfaces with a cellZone
|
//- Get specified inside location for surfaces with a cellZone
|
||||||
const point& zoneInsidePoint() const
|
const point zoneInsidePoint() const
|
||||||
{
|
{
|
||||||
return zoneInsidePoint_;
|
return zoneInsidePoints_[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Get specified inside locations for surfaces with a cellZone
|
||||||
|
const pointField& zoneInsidePoints() const
|
||||||
|
{
|
||||||
|
return zoneInsidePoints_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- How to handle face of surfaces with a faceZone
|
//- How to handle face of surfaces with a faceZone
|
||||||
|
|||||||
@ -1389,6 +1389,7 @@ Foam::label Foam::snappyRefineDriver::refinementInterfaceRefine
|
|||||||
(
|
(
|
||||||
face2i != facei
|
face2i != facei
|
||||||
&& surfaceIndex[face2i] != -1
|
&& surfaceIndex[face2i] != -1
|
||||||
|
&& cutter.faceLevel(face2i) > cLevel
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Get outwards pointing normal
|
// Get outwards pointing normal
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -756,7 +756,7 @@ Foam::Ostream& Foam::operator<<
|
|||||||
const labelUList& interpolationCells = e.interpolationCells();
|
const labelUList& interpolationCells = e.interpolationCells();
|
||||||
const labelListList& cellStencil = e.cellStencil();
|
const labelListList& cellStencil = e.cellStencil();
|
||||||
|
|
||||||
labelList nCells(cellCellStencil::count(4, cellTypes));
|
labelList nCells(cellCellStencil::count(5, cellTypes));
|
||||||
|
|
||||||
label nInvalidInterpolated = 0;
|
label nInvalidInterpolated = 0;
|
||||||
label nLocal = 0;
|
label nLocal = 0;
|
||||||
@ -808,7 +808,7 @@ Foam::Ostream& Foam::operator<<
|
|||||||
reduce(nRemote, sumOp<label>());
|
reduce(nRemote, sumOp<label>());
|
||||||
reduce(nInvalidInterpolated, sumOp<label>());
|
reduce(nInvalidInterpolated, sumOp<label>());
|
||||||
|
|
||||||
Info<< "Overset analysis : nCells : "
|
os << "Overset analysis : nCells : "
|
||||||
<< returnReduce(cellTypes.size(), sumOp<label>()) << nl
|
<< returnReduce(cellTypes.size(), sumOp<label>()) << nl
|
||||||
<< incrIndent
|
<< incrIndent
|
||||||
<< indent << "calculated : " << nCells[cellCellStencil::CALCULATED]
|
<< indent << "calculated : " << nCells[cellCellStencil::CALCULATED]
|
||||||
@ -818,9 +818,16 @@ Foam::Ostream& Foam::operator<<
|
|||||||
<< " mixed local/remote:" << nMixed
|
<< " mixed local/remote:" << nMixed
|
||||||
<< " remote:" << nRemote
|
<< " remote:" << nRemote
|
||||||
<< " special:" << nInvalidInterpolated << ")" << nl
|
<< " special:" << nInvalidInterpolated << ")" << nl
|
||||||
<< indent << "hole : " << nCells[cellCellStencil::HOLE] << nl
|
<< indent << "hole : " << nCells[cellCellStencil::HOLE] << nl;
|
||||||
<< indent << "special : " << nCells[cellCellStencil::SPECIAL] << nl
|
|
||||||
<< decrIndent << endl;
|
if (nCells[cellCellStencil::SPECIAL] || nCells[cellCellStencil::POROUS])
|
||||||
|
{
|
||||||
|
os << indent << "special : " << nCells[cellCellStencil::SPECIAL]
|
||||||
|
<< nl
|
||||||
|
<< indent << "porous : " << nCells[cellCellStencil::POROUS]
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
os << decrIndent << endl;
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2014-2022 OpenCFD Ltd.
|
Copyright (C) 2014-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -1100,16 +1100,7 @@ bool Foam::cellCellStencils::cellVolumeWeight::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
Info << this->info();
|
||||||
labelList nCells(count(3, cellTypes_));
|
|
||||||
Info<< "Overset analysis : nCells : "
|
|
||||||
<< returnReduce(cellTypes_.size(), sumOp<label>()) << nl
|
|
||||||
<< incrIndent
|
|
||||||
<< indent << "calculated : " << nCells[CALCULATED] << nl
|
|
||||||
<< indent << "interpolated : " << nCells[INTERPOLATED] << nl
|
|
||||||
<< indent << "hole : " << nCells[HOLE] << nl
|
|
||||||
<< decrIndent << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -1136,60 +1136,8 @@ bool Foam::cellCellStencils::trackingInverseDistance::update()
|
|||||||
|
|
||||||
|
|
||||||
// Print some stats
|
// Print some stats
|
||||||
{
|
Info<< this->info();
|
||||||
labelList nCells(count(3, cellTypes_));
|
|
||||||
|
|
||||||
label nLocal = 0;
|
|
||||||
label nMixed = 0;
|
|
||||||
label nRemote = 0;
|
|
||||||
forAll(interpolationCells_, i)
|
|
||||||
{
|
|
||||||
label celli = interpolationCells_[i];
|
|
||||||
const labelList& slots = cellStencil_[celli];
|
|
||||||
|
|
||||||
bool hasLocal = false;
|
|
||||||
bool hasRemote = false;
|
|
||||||
|
|
||||||
forAll(slots, sloti)
|
|
||||||
{
|
|
||||||
if (slots[sloti] >= mesh_.nCells())
|
|
||||||
{
|
|
||||||
hasRemote = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hasLocal = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasRemote)
|
|
||||||
{
|
|
||||||
if (!hasLocal)
|
|
||||||
{
|
|
||||||
nRemote++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nMixed++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (hasLocal)
|
|
||||||
{
|
|
||||||
nLocal++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Info<< "Overset analysis : nCells : "
|
|
||||||
<< returnReduce(cellTypes_.size(), sumOp<label>()) << nl
|
|
||||||
<< incrIndent
|
|
||||||
<< indent << "calculated : " << nCells[CALCULATED] << nl
|
|
||||||
<< indent << "interpolated : " << nCells[INTERPOLATED]
|
|
||||||
<< " (from local:" << returnReduce(nLocal, sumOp<label>())
|
|
||||||
<< " mixed local/remote:" << returnReduce(nMixed, sumOp<label>())
|
|
||||||
<< " remote:" << returnReduce(nRemote, sumOp<label>()) << ")" << nl
|
|
||||||
<< indent << "hole : " << nCells[HOLE] << nl
|
|
||||||
<< decrIndent << endl;
|
|
||||||
}
|
|
||||||
DebugInfo<< FUNCTION_NAME << " : Finished analysis" << endl;
|
DebugInfo<< FUNCTION_NAME << " : Finished analysis" << endl;
|
||||||
|
|
||||||
// Tbd: detect if anything changed. Most likely it did!
|
// Tbd: detect if anything changed. Most likely it did!
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#-------------------------------*- makefile -*---------------------------------
|
#-------------------------------*- makefile -*---------------------------------
|
||||||
WM_VERSION = OPENFOAM=2306
|
WM_VERSION = OPENFOAM=2307
|
||||||
|
|
||||||
AR = ar
|
AR = ar
|
||||||
ARFLAGS = cr
|
ARFLAGS = cr
|
||||||
|
|||||||
Reference in New Issue
Block a user