BUG: SPDP: PrecisionAdaptor copies input list. Fixes #1590.

This commit is contained in:
mattijs
2020-02-12 17:27:41 +00:00
parent 09db19c3f0
commit 4fea7b3bb4
4 changed files with 15 additions and 16 deletions

View File

@ -169,12 +169,15 @@ class PrecisionAdaptor
// Private Member Functions // Private Member Functions
//- Copy in field //- Copy in field
void copyInput(const Container<InputType>& input) void copyInput(const Container<InputType>& input, const bool copy)
{ {
Container<Type>* p = new Container<Type>(input.size()); Container<Type>* p = new Container<Type>(input.size());
this->reset(p); this->reset(p);
if (copy)
{
std::copy(input.cbegin(), input.cend(), p->begin()); std::copy(input.cbegin(), input.cend(), p->begin());
} }
}
public: public:
@ -185,8 +188,8 @@ public:
// Constructors // Constructors
//- Construct from Container<InputType>, copying on input as required //- Construct from Container<InputType>, copying on input if required
PrecisionAdaptor(Container<InputType>& input) PrecisionAdaptor(Container<InputType>& input, const bool copy = true)
: :
tmpNrc<Container<Type>>(), tmpNrc<Container<Type>>(),
ref_(input) ref_(input)
@ -197,7 +200,7 @@ public:
} }
else else
{ {
this->copyInput(input); this->copyInput(input, copy);
} }
} }

View File

@ -82,18 +82,14 @@ void Foam::primitiveMesh::makeCellCentresAndVols
{ {
typedef Vector<solveScalar> solveVector; typedef Vector<solveScalar> solveVector;
// Clear the fields for accumulation. Note1: we're doing this before PrecisionAdaptor<solveVector, vector> tcellCtrs(cellCtrs_s, false);
// any precision conversion since this might complain about illegal numbers.
// Note2: zero is a special value which is perfectly converted into zero
// in the new precision
cellCtrs_s = Zero;
cellVols_s = 0.0;
PrecisionAdaptor<solveVector, vector> tcellCtrs(cellCtrs_s);
Field<solveVector>& cellCtrs = tcellCtrs.ref(); Field<solveVector>& cellCtrs = tcellCtrs.ref();
PrecisionAdaptor<solveScalar, scalar> tcellVols(cellVols_s); PrecisionAdaptor<solveScalar, scalar> tcellVols(cellVols_s, false);
Field<solveScalar>& cellVols = tcellVols.ref(); Field<solveScalar>& cellVols = tcellVols.ref();
cellCtrs = Zero;
cellVols = 0.0;
const labelList& own = faceOwner(); const labelList& own = faceOwner();
const labelList& nei = faceNeighbour(); const labelList& nei = faceNeighbour();

View File

@ -229,7 +229,7 @@ Foam::label Foam::kahipDecomp::decomposeSerial
// Output: cell -> processor addressing // Output: cell -> processor addressing
decomp.resize(numCells); decomp.resize(numCells);
PrecisionAdaptor<int, label, List> decomp_param(decomp); PrecisionAdaptor<int, label, List> decomp_param(decomp, false);
#if 0 // WIP: #ifdef KAFFPA_CPP_INTERFACE #if 0 // WIP: #ifdef KAFFPA_CPP_INTERFACE

View File

@ -196,7 +196,7 @@ Foam::label Foam::metisDecomp::decomposeSerial
// Output: cell -> processor addressing // Output: cell -> processor addressing
decomp.resize(numCells); decomp.resize(numCells);
PrecisionAdaptor<idx_t, label, List> decomp_param(decomp); PrecisionAdaptor<idx_t, label, List> decomp_param(decomp, false);
// Output: number of cut edges // Output: number of cut edges
idx_t edgeCut = 0; idx_t edgeCut = 0;