UList: Rationalize assignment (shallow-copy vs deep-copy)

//- Disallow default shallow-copy assignment
    //
    //  Assignment of UList<T> may need to be either shallow (copy pointer)
    //  or deep (copy elements) depending on context or the particular type
    //  of list derived from UList and it is confusing and prone to error
    //  for the default assignment to be either.  The solution is to
    //  disallow default assignment and provide separate 'shallowCopy' and
    //  'deepCopy' member functions.
    void operator=(const UList<T>&) = delete;

    //- Copy the pointer held by the given UList.
    inline void shallowCopy(const UList<T>&);

    //- Copy elements of the given UList.
    void deepCopy(const UList<T>&);
This commit is contained in:
Henry Weller
2016-04-03 10:26:05 +01:00
parent 06f7682413
commit ac71f86574
31 changed files with 122 additions and 100 deletions

View File

@ -56,8 +56,8 @@ int main(int argc, char *argv[])
rowSizes[1] = row1.size(); rowSizes[1] = row1.size();
cll1.resize(rowSizes); cll1.resize(rowSizes);
cll1[0].assign(row0); //note: operator= will not work since UList cll1[0].deepCopy(row0);
cll1[1].assign(row1); cll1[1].deepCopy(row1);
Info<< "cll1:" << cll1 << endl; Info<< "cll1:" << cll1 << endl;
forAll(cll1.m(), i) forAll(cll1.m(), i)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -64,10 +64,8 @@ int main(int argc, char *argv[])
// Create field with my local data // Create field with my local data
pointField coords(globalPointSlavesMap.constructSize()); pointField coords(globalPointSlavesMap.constructSize());
SubList<point>(coords, coupledPatch.nPoints()).assign SubList<point>(coords, coupledPatch.nPoints()) =
( coupledPatch.localPoints();
coupledPatch.localPoints()
);
// Exchange data. Apply positional transforms. // Exchange data. Apply positional transforms.
globalPointSlavesMap.distribute globalPointSlavesMap.distribute
@ -185,8 +183,7 @@ int main(int argc, char *argv[])
label nBnd = mesh.nFaces()-mesh.nInternalFaces(); label nBnd = mesh.nFaces()-mesh.nInternalFaces();
pointField fc(globalPointBoundaryFacesMap.constructSize()); pointField fc(globalPointBoundaryFacesMap.constructSize());
SubList<point>(fc, nBnd).assign SubList<point>(fc, nBnd) =
(
primitivePatch primitivePatch
( (
SubList<face> SubList<face>
@ -196,8 +193,7 @@ int main(int argc, char *argv[])
mesh.nInternalFaces() mesh.nInternalFaces()
), ),
mesh.points() mesh.points()
).faceCentres() ).faceCentres();
);
// Exchange data // Exchange data
globalPointBoundaryFacesMap.distribute globalPointBoundaryFacesMap.distribute

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -240,7 +240,7 @@ bool setFaceFieldType
field.boundaryField()[patchi].size(), field.boundaryField()[patchi].size(),
field.boundaryField()[patchi].patch().start() field.boundaryField()[patchi].patch().start()
- mesh.nInternalFaces() - mesh.nInternalFaces()
).assign(field.boundaryField()[patchi]); ) = field.boundaryField()[patchi];
} }
// Override // Override

View File

@ -424,14 +424,14 @@ int main(int argc, char *argv[])
( (
availablePoints, availablePoints,
upp.faceCentres().size() upp.faceCentres().size()
).assign(upp.faceCentres()); ) = upp.faceCentres();
SubList<point> SubList<point>
( (
availablePoints, availablePoints,
upp.localPoints().size(), upp.localPoints().size(),
upp.faceCentres().size() upp.faceCentres().size()
).assign(upp.localPoints()); ) = upp.localPoints();
point cfo = cf; point cfo = cf;
scalar dist = GREAT; scalar dist = GREAT;
@ -592,8 +592,8 @@ int main(int argc, char *argv[])
DynamicList<label> compactPatchId(map.constructSize()); DynamicList<label> compactPatchId(map.constructSize());
// Insert my coarse local values // Insert my coarse local values
SubList<point>(compactCoarseSf, nCoarseFaces).assign(localCoarseSf); SubList<point>(compactCoarseSf, nCoarseFaces) = localCoarseSf;
SubList<point>(compactCoarseCf, nCoarseFaces).assign(localCoarseCf); SubList<point>(compactCoarseCf, nCoarseFaces) = localCoarseCf;
// Insert my fine local values // Insert my fine local values
label compactI = 0; label compactI = 0;

View File

@ -87,6 +87,9 @@ public:
//- Allow cast to a const List<T>& //- Allow cast to a const List<T>&
inline operator const Foam::List<T>&() const; inline operator const Foam::List<T>&() const;
//- Assignment of all entries to the given sub-list
inline void operator=(const SubList<T>&);
//- Assignment of all entries to the given list //- Assignment of all entries to the given list
inline void operator=(const UList<T>&); inline void operator=(const UList<T>&);

View File

@ -87,10 +87,17 @@ inline Foam::SubList<T>::operator const Foam::List<T>&() const
} }
template<class T>
inline void Foam::SubList<T>::operator=(const SubList<T>& sl)
{
UList<T>::deepCopy(sl);
}
template<class T> template<class T>
inline void Foam::SubList<T>::operator=(const UList<T>& l) inline void Foam::SubList<T>::operator=(const UList<T>& l)
{ {
UList<T>::assign(l); UList<T>::deepCopy(l);
} }

View File

@ -34,7 +34,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T> template<class T>
void Foam::UList<T>::assign(const UList<T>& a) void Foam::UList<T>::deepCopy(const UList<T>& a)
{ {
if (a.size_ != this->size_) if (a.size_ != this->size_)
{ {

View File

@ -80,6 +80,19 @@ class UList
T* __restrict__ v_; T* __restrict__ v_;
// Private Member Functions
//- Disallow default shallow-copy assignment
//
// Assignment of UList<T> may need to be either shallow (copy pointer)
// or deep (copy elements) depending on context or the particular type
// of list derived from UList and it is confusing and prone to error
// for the default assignment to be either. The solution is to
// disallow default assignment and provide separate 'shallowCopy' and
// 'deepCopy' member functions.
void operator=(const UList<T>&) = delete;
public: public:
// Related types // Related types
@ -90,11 +103,13 @@ public:
//- Declare friendship with the SubList class //- Declare friendship with the SubList class
friend class SubList<T>; friend class SubList<T>;
// Static Member Functions // Static Member Functions
//- Return a null UList //- Return a null UList
inline static const UList<T>& null(); inline static const UList<T>& null();
// Public classes // Public classes
//- Less function class that can be used for sorting //- Less function class that can be used for sorting
@ -198,15 +213,18 @@ public:
inline void checkIndex(const label i) const; inline void checkIndex(const label i) const;
//- Copy the pointer held by the given UList.
inline void shallowCopy(const UList<T>&);
//- Copy elements of the given UList.
void deepCopy(const UList<T>&);
//- Write the UList as a dictionary entry. //- Write the UList as a dictionary entry.
void writeEntry(Ostream&) const; void writeEntry(Ostream&) const;
//- Write the UList as a dictionary entry with keyword. //- Write the UList as a dictionary entry with keyword.
void writeEntry(const word& keyword, Ostream&) const; void writeEntry(const word& keyword, Ostream&) const;
//- Assign elements to those from UList.
void assign(const UList<T>&);
// Member operators // Member operators
@ -327,7 +345,7 @@ public:
// STL member operators // STL member operators
//- Equality operation on ULists of the same type. //- Equality operation on ULists of the same type.
// Returns true when the ULists are elementwise equal // Returns true when the ULists are element-wise equal
// (using UList::value_type::operator==). Takes linear time. // (using UList::value_type::operator==). Takes linear time.
bool operator==(const UList<T>&) const; bool operator==(const UList<T>&) const;

View File

@ -152,6 +152,14 @@ inline T* Foam::UList<T>::data()
} }
template<class T>
inline void Foam::UList<T>::shallowCopy(const UList<T>& a)
{
size_ = a.size_;
v_ = a.v_;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //

View File

@ -158,7 +158,7 @@ slicedBoundaryField
DimensionedField<Type, GeoMesh>::null() DimensionedField<Type, GeoMesh>::null()
) )
); );
bf[patchi].UList<Type>::operator=(bField[patchi]); bf[patchi].shallowCopy(bField[patchi]);
} }
} }
@ -193,7 +193,7 @@ DimensionedInternalField::DimensionedInternalField
) )
{ {
// Set the internalField to the slice of the complete field // Set the internalField to the slice of the complete field
UList<Type>::operator= UList<Type>::shallowCopy
( (
typename Field<Type>::subField(iField, GeoMesh::size(mesh)) typename Field<Type>::subField(iField, GeoMesh::size(mesh))
); );
@ -227,7 +227,7 @@ SlicedGeometricField
) )
{ {
// Set the internalField to the slice of the complete field // Set the internalField to the slice of the complete field
UList<Type>::operator= UList<Type>::shallowCopy
( (
typename Field<Type>::subField(completeField, GeoMesh::size(mesh)) typename Field<Type>::subField(completeField, GeoMesh::size(mesh))
); );
@ -271,7 +271,7 @@ SlicedGeometricField
) )
{ {
// Set the internalField to the slice of the complete field // Set the internalField to the slice of the complete field
UList<Type>::operator= UList<Type>::shallowCopy
( (
typename Field<Type>::subField(completeIField, GeoMesh::size(mesh)) typename Field<Type>::subField(completeIField, GeoMesh::size(mesh))
); );
@ -305,7 +305,7 @@ SlicedGeometricField
) )
{ {
// Set the internalField to the supplied internal field // Set the internalField to the supplied internal field
UList<Type>::operator=(gf.internalField()); UList<Type>::shallowCopy(gf.internalField());
correctBoundaryConditions(); correctBoundaryConditions();
} }
@ -334,7 +334,7 @@ SlicedGeometricField
) )
{ {
// Set the internalField to the supplied internal field // Set the internalField to the supplied internal field
UList<Type>::operator=(gf.internalField()); UList<Type>::shallowCopy(gf.internalField());
} }
@ -352,7 +352,7 @@ Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
{ {
// Set the internalField storage pointer to NULL before its destruction // Set the internalField storage pointer to NULL before its destruction
// to protect the field it a slice of. // to protect the field it a slice of.
UList<Type>::operator=(UList<Type>(NULL, 0)); UList<Type>::shallowCopy(UList<Type>(NULL, 0));
} }
@ -368,7 +368,7 @@ DimensionedInternalField::~DimensionedInternalField()
{ {
// Set the internalField storage pointer to NULL before its destruction // Set the internalField storage pointer to NULL before its destruction
// to protect the field it a slice of. // to protect the field it a slice of.
UList<Type>::operator=(UList<Type>(NULL, 0)); UList<Type>::shallowCopy(UList<Type>(NULL, 0));
} }

View File

@ -51,7 +51,7 @@ void Foam::LUscalarMatrix::solve
( (
X, X,
x.size() x.size()
).assign(x); ) = x;
for for
( (

View File

@ -497,14 +497,13 @@ void Foam::GAMGSolver::procAgglomerateMatrix
if (coarsestMatrix.hasDiag()) if (coarsestMatrix.hasDiag())
{ {
scalarField& allDiag = allMatrix.diag(); scalarField& allDiag = allMatrix.diag();
SubList<scalar> SubList<scalar>
( (
allDiag, allDiag,
coarsestMatrix.diag().size() coarsestMatrix.diag().size()
).assign ) = coarsestMatrix.diag();
(
coarsestMatrix.diag()
);
forAll(otherMats, i) forAll(otherMats, i)
{ {
SubList<scalar> SubList<scalar>
@ -512,10 +511,7 @@ void Foam::GAMGSolver::procAgglomerateMatrix
allDiag, allDiag,
otherMats[i].diag().size(), otherMats[i].diag().size(),
cellOffsets[i+1] cellOffsets[i+1]
).assign ) = otherMats[i].diag();
(
otherMats[i].diag()
);
} }
} }
if (coarsestMatrix.hasLower()) if (coarsestMatrix.hasLower())

View File

@ -295,7 +295,7 @@ void Foam::GAMGSolver::Vcycle
// used // used
if (nPreSweeps_) if (nPreSweeps_)
{ {
preSmoothedCoarseCorrField.assign(coarseCorrFields[leveli]); preSmoothedCoarseCorrField = coarseCorrFields[leveli];
} }
agglomeration_.prolongField agglomeration_.prolongField

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -44,7 +44,7 @@ void Foam::globalIndex::gather
allFld.setSize(off.last()); allFld.setSize(off.last());
// Assign my local data // Assign my local data
SubList<Type>(allFld, fld.size(), 0).assign(fld); SubList<Type>(allFld, fld.size(), 0) = fld;
if (commsType == Pstream::scheduled || commsType == Pstream::blocking) if (commsType == Pstream::scheduled || commsType == Pstream::blocking)
{ {
@ -207,7 +207,7 @@ void Foam::globalIndex::scatter
{ {
if (Pstream::myProcNo(comm) == procIDs[0]) if (Pstream::myProcNo(comm) == procIDs[0])
{ {
fld.assign(SubList<Type>(allFld, off[1]-off[0])); fld.deepCopy(SubList<Type>(allFld, off[1]-off[0]));
if (commsType == Pstream::scheduled || commsType == Pstream::blocking) if (commsType == Pstream::scheduled || commsType == Pstream::blocking)
{ {

View File

@ -582,7 +582,7 @@ operator=
{ {
clearOut(); clearOut();
FaceList<Face>::operator=(pp); FaceList<Face>::shallowCopy(pp);
} }

View File

@ -88,7 +88,7 @@ void Foam::UPstream::allToAll
const label communicator const label communicator
) )
{ {
recvData.assign(sendData); recvData.deepCopy(sendData);
} }

View File

@ -316,7 +316,7 @@ void Foam::UPstream::allToAll
if (!UPstream::parRun()) if (!UPstream::parRun())
{ {
recvData.assign(sendData); recvData.deepCopy(sendData);
} }
else else
{ {

View File

@ -566,10 +566,8 @@ void Foam::fvMeshDistribute::getNeighbourData
} }
// Which processor they will end up on // Which processor they will end up on
SubList<label>(nbrNewNbrProc, pp.size(), offset).assign SubList<label>(nbrNewNbrProc, pp.size(), offset) =
( UIndirectList<label>(distribution, pp.faceCells())();
UIndirectList<label>(distribution, pp.faceCells())()
);
} }
} }
@ -1074,7 +1072,7 @@ void Foam::fvMeshDistribute::sendMesh
if (myZoneID != -1) if (myZoneID != -1)
{ {
zonePoints[nameI].assign(pointZones[myZoneID]); zonePoints[nameI].deepCopy(pointZones[myZoneID]);
} }
} }
} }
@ -1106,8 +1104,8 @@ void Foam::fvMeshDistribute::sendMesh
if (myZoneID != -1) if (myZoneID != -1)
{ {
zoneFaces[nameI].assign(faceZones[myZoneID]); zoneFaces[nameI].deepCopy(faceZones[myZoneID]);
zoneFaceFlip[nameI].assign(faceZones[myZoneID].flipMap()); zoneFaceFlip[nameI].deepCopy(faceZones[myZoneID].flipMap());
} }
} }
} }
@ -1137,7 +1135,7 @@ void Foam::fvMeshDistribute::sendMesh
if (myZoneID != -1) if (myZoneID != -1)
{ {
zoneCells[nameI].assign(cellZones[myZoneID]); zoneCells[nameI].deepCopy(cellZones[myZoneID]);
} }
} }
} }

View File

@ -38,7 +38,7 @@ Foam::slicedFvPatchField<Type>::slicedFvPatchField
fvPatchField<Type>(p, iF, Field<Type>()) fvPatchField<Type>(p, iF, Field<Type>())
{ {
// Set the fvPatchField to a slice of the given complete field // Set the fvPatchField to a slice of the given complete field
UList<Type>::operator=(p.patchSlice(completeField)); UList<Type>::shallowCopy(p.patchSlice(completeField));
} }
@ -92,7 +92,7 @@ Foam::slicedFvPatchField<Type>::slicedFvPatchField
fvPatchField<Type>(ptf.patch(), iF, Field<Type>()) fvPatchField<Type>(ptf.patch(), iF, Field<Type>())
{ {
// Transfer the slice from the argument // Transfer the slice from the argument
UList<Type>::operator=(ptf); UList<Type>::shallowCopy(ptf);
} }
@ -121,7 +121,7 @@ Foam::slicedFvPatchField<Type>::slicedFvPatchField
) )
{ {
// Transfer the slice from the argument // Transfer the slice from the argument
UList<Type>::operator=(ptf); UList<Type>::shallowCopy(ptf);
} }
@ -144,7 +144,7 @@ Foam::slicedFvPatchField<Type>::~slicedFvPatchField()
{ {
// Set the fvPatchField storage pointer to NULL before its destruction // Set the fvPatchField storage pointer to NULL before its destruction
// to protect the field it a slice of. // to protect the field it a slice of.
UList<Type>::operator=(UList<Type>(NULL, 0)); UList<Type>::shallowCopy(UList<Type>(NULL, 0));
} }

View File

@ -38,7 +38,7 @@ Foam::slicedFvsPatchField<Type>::slicedFvsPatchField
fvsPatchField<Type>(p, iF, Field<Type>()) fvsPatchField<Type>(p, iF, Field<Type>())
{ {
// Set the fvsPatchField to a slice of the given complete field // Set the fvsPatchField to a slice of the given complete field
UList<Type>::operator=(p.patchSlice(completeField)); UList<Type>::shallowCopy(p.patchSlice(completeField));
} }
@ -92,7 +92,7 @@ Foam::slicedFvsPatchField<Type>::slicedFvsPatchField
fvsPatchField<Type>(ptf.patch(), iF, Field<Type>()) fvsPatchField<Type>(ptf.patch(), iF, Field<Type>())
{ {
// Transfer the slice from the argument // Transfer the slice from the argument
UList<Type>::operator=(ptf); UList<Type>::shallowCopy(ptf);
} }
@ -121,7 +121,7 @@ Foam::slicedFvsPatchField<Type>::slicedFvsPatchField
) )
{ {
// Transfer the slice from the argument // Transfer the slice from the argument
UList<Type>::operator=(ptf); UList<Type>::shallowCopy(ptf);
} }
@ -144,7 +144,7 @@ Foam::slicedFvsPatchField<Type>::~slicedFvsPatchField()
{ {
// Set the fvsPatchField storage pointer to NULL before its destruction // Set the fvsPatchField storage pointer to NULL before its destruction
// to protect the field it a slice of. // to protect the field it a slice of.
UList<Type>::operator=(UList<Type>(NULL, 0)); UList<Type>::shallowCopy(UList<Type>(NULL, 0));
} }

View File

@ -184,7 +184,7 @@ Foam::tmp<Foam::Field<Type>> Foam::volPointInterpolation::flatBoundaryField
boundaryVals, boundaryVals,
vf.boundaryField()[patchI].size(), vf.boundaryField()[patchI].size(),
bFaceI bFaceI
).assign(vf.boundaryField()[patchI]); ) = vf.boundaryField()[patchI];
} }
else else
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -115,7 +115,7 @@ void Foam::CellZoneInjection<CloudType>::setPositions
allPositions, allPositions,
globalPositions.localSize(Pstream::myProcNo()), globalPositions.localSize(Pstream::myProcNo()),
globalPositions.offset(Pstream::myProcNo()) globalPositions.offset(Pstream::myProcNo())
).assign(positions); ) = positions;
Pstream::listCombineGather(allPositions, minEqOp<point>()); Pstream::listCombineGather(allPositions, minEqOp<point>());
Pstream::listCombineScatter(allPositions); Pstream::listCombineScatter(allPositions);
@ -126,19 +126,19 @@ void Foam::CellZoneInjection<CloudType>::setPositions
allInjectorCells, allInjectorCells,
globalPositions.localSize(Pstream::myProcNo()), globalPositions.localSize(Pstream::myProcNo()),
globalPositions.offset(Pstream::myProcNo()) globalPositions.offset(Pstream::myProcNo())
).assign(injectorCells); ) = injectorCells;
SubList<label> SubList<label>
( (
allInjectorTetFaces, allInjectorTetFaces,
globalPositions.localSize(Pstream::myProcNo()), globalPositions.localSize(Pstream::myProcNo()),
globalPositions.offset(Pstream::myProcNo()) globalPositions.offset(Pstream::myProcNo())
).assign(injectorTetFaces); ) = injectorTetFaces;
SubList<label> SubList<label>
( (
allInjectorTetPts, allInjectorTetPts,
globalPositions.localSize(Pstream::myProcNo()), globalPositions.localSize(Pstream::myProcNo()),
globalPositions.offset(Pstream::myProcNo()) globalPositions.offset(Pstream::myProcNo())
).assign(injectorTetPts); ) = injectorTetPts;
// Transfer data // Transfer data
positions_.transfer(allPositions); positions_.transfer(allPositions);

View File

@ -138,7 +138,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
allMass, allMass,
globalParcels.localSize(procI), globalParcels.localSize(procI),
globalParcels.offset(procI) globalParcels.offset(procI)
).assign(procMass[procI]); ) = procMass[procI];
// flatten the distance list // flatten the distance list
SubList<scalar> SubList<scalar>
@ -146,7 +146,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
allDist, allDist,
globalParcels.localSize(procI), globalParcels.localSize(procI),
globalParcels.offset(procI) globalParcels.offset(procI)
).assign(procDist[procI]); ) = procDist[procI];
} }
// sort allDist distances into ascending order // sort allDist distances into ascending order

View File

@ -246,7 +246,7 @@ distributeAndMergePatches
// My own data first // My own data first
{ {
const labelList& faceIDs = allTgtFaceIDs[Pstream::myProcNo()]; const labelList& faceIDs = allTgtFaceIDs[Pstream::myProcNo()];
SubList<label>(tgtFaceIDs, faceIDs.size()).assign(faceIDs); SubList<label>(tgtFaceIDs, faceIDs.size()) = faceIDs;
const faceList& fcs = allFaces[Pstream::myProcNo()]; const faceList& fcs = allFaces[Pstream::myProcNo()];
forAll(fcs, i) forAll(fcs, i)
@ -274,7 +274,7 @@ distributeAndMergePatches
if (procI != Pstream::myProcNo()) if (procI != Pstream::myProcNo())
{ {
const labelList& faceIDs = allTgtFaceIDs[procI]; const labelList& faceIDs = allTgtFaceIDs[procI];
SubList<label>(tgtFaceIDs, faceIDs.size(), nFaces).assign(faceIDs); SubList<label>(tgtFaceIDs, faceIDs.size(), nFaces) = faceIDs;
const faceList& fcs = allFaces[procI]; const faceList& fcs = allFaces[procI];
forAll(fcs, i) forAll(fcs, i)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -325,7 +325,7 @@ Foam::labelList Foam::simpleGeomDecomp::decompose
label nTotalPoints = 0; label nTotalPoints = 0;
// Master first // Master first
SubField<point>(allPoints, points.size()).assign(points); SubField<point>(allPoints, points.size()) = points;
nTotalPoints += points.size(); nTotalPoints += points.size();
// Add slaves // Add slaves
@ -338,7 +338,7 @@ Foam::labelList Foam::simpleGeomDecomp::decompose
allPoints, allPoints,
nbrPoints.size(), nbrPoints.size(),
nTotalPoints nTotalPoints
).assign(nbrPoints); ) = nbrPoints;
nTotalPoints += nbrPoints.size(); nTotalPoints += nbrPoints.size();
} }
@ -401,8 +401,8 @@ Foam::labelList Foam::simpleGeomDecomp::decompose
label nTotalPoints = 0; label nTotalPoints = 0;
// Master first // Master first
SubField<point>(allPoints, points.size()).assign(points); SubField<point>(allPoints, points.size()) = points;
SubField<scalar>(allWeights, points.size()).assign(weights); SubField<scalar>(allWeights, points.size()) = weights;
nTotalPoints += points.size(); nTotalPoints += points.size();
// Add slaves // Add slaves
@ -416,13 +416,13 @@ Foam::labelList Foam::simpleGeomDecomp::decompose
allPoints, allPoints,
nbrPoints.size(), nbrPoints.size(),
nTotalPoints nTotalPoints
).assign(nbrPoints); ) = nbrPoints;
SubField<scalar> SubField<scalar>
( (
allWeights, allWeights,
nbrWeights.size(), nbrWeights.size(),
nTotalPoints nTotalPoints
).assign(nbrWeights); ) = nbrWeights;
nTotalPoints += nbrPoints.size(); nTotalPoints += nbrPoints.size();
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -122,7 +122,7 @@ Foam::labelList Foam::SloanRenumber::renumber
nbr, nbr,
pbm[patchI].size(), pbm[patchI].size(),
pbm[patchI].start()-mesh.nInternalFaces() pbm[patchI].start()-mesh.nInternalFaces()
).assign(pbm[patchI].faceCells()); ) = pbm[patchI].faceCells();
} }
} }
syncTools::swapBoundaryFaceList(mesh, nbr); syncTools::swapBoundaryFaceList(mesh, nbr);

View File

@ -644,17 +644,14 @@ void Foam::meshToMesh::distributeAndMergeCells
forAll(allPoints, procI) forAll(allPoints, procI)
{ {
const pointField& pts = allPoints[procI]; const pointField& pts = allPoints[procI];
SubList<point>(tgtPoints, pts.size(), pointOffset[procI]).assign(pts); SubList<point>(tgtPoints, pts.size(), pointOffset[procI]) = pts;
} }
// Insert cellIDs // Insert cellIDs
forAll(allTgtCellIDs, procI) forAll(allTgtCellIDs, procI)
{ {
const labelList& cellIDs = allTgtCellIDs[procI]; const labelList& cellIDs = allTgtCellIDs[procI];
SubList<label>(tgtCellIDs, cellIDs.size(), cellOffset[procI]).assign SubList<label>(tgtCellIDs, cellIDs.size(), cellOffset[procI]) = cellIDs;
(
cellIDs
);
} }
@ -671,7 +668,7 @@ void Foam::meshToMesh::distributeAndMergeCells
allNInternalFaces[procI], allNInternalFaces[procI],
internalFaceOffset[procI] internalFaceOffset[procI]
); );
slice.assign(SubList<face>(fcs, allNInternalFaces[procI])); slice = SubList<face>(fcs, allNInternalFaces[procI]);
forAll(slice, i) forAll(slice, i)
{ {
add(slice[i], pointOffset[procI]); add(slice[i], pointOffset[procI]);
@ -683,7 +680,7 @@ void Foam::meshToMesh::distributeAndMergeCells
allNInternalFaces[procI], allNInternalFaces[procI],
internalFaceOffset[procI] internalFaceOffset[procI]
); );
ownSlice.assign(SubField<label>(faceOs, allNInternalFaces[procI])); ownSlice = SubField<label>(faceOs, allNInternalFaces[procI]);
add(ownSlice, cellOffset[procI]); add(ownSlice, cellOffset[procI]);
SubField<label> nbrSlice SubField<label> nbrSlice
@ -692,7 +689,7 @@ void Foam::meshToMesh::distributeAndMergeCells
allNInternalFaces[procI], allNInternalFaces[procI],
internalFaceOffset[procI] internalFaceOffset[procI]
); );
nbrSlice.assign(SubField<label>(faceNs, allNInternalFaces[procI])); nbrSlice = SubField<label>(faceNs, allNInternalFaces[procI]);
add(nbrSlice, cellOffset[procI]); add(nbrSlice, cellOffset[procI]);
internalFaceOffset[procI] += allNInternalFaces[procI]; internalFaceOffset[procI] += allNInternalFaces[procI];

View File

@ -109,7 +109,7 @@ Foam::sampledPatchInternalField::interpolateField
// Now patchVals holds the interpolated data in patch face order. // Now patchVals holds the interpolated data in patch face order.
// Collect. // Collect.
SubList<Type>(allPatchVals, patchVals.size(), sz).assign(patchVals); SubList<Type>(allPatchVals, patchVals.size(), sz) = patchVals;
sz += patchVals.size(); sz += patchVals.size();
} }

View File

@ -67,7 +67,7 @@ Foam::sampledTriSurfaceMesh::sampleField
bVals, bVals,
vField.boundaryField()[patchI].size(), vField.boundaryField()[patchI].size(),
bFaceI bFaceI
).assign(vField.boundaryField()[patchI]); ) = vField.boundaryField()[patchI];
} }
// Sample in flat boundary field // Sample in flat boundary field

View File

@ -229,7 +229,7 @@ Foam::surfMesh::~surfMesh()
void Foam::surfMesh::updatePointsRef() void Foam::surfMesh::updatePointsRef()
{ {
// assign the reference to the points (this is truly ugly) // Assign the reference to the points (this is truly ugly)
reinterpret_cast<SubField<point>&> reinterpret_cast<SubField<point>&>
( (
const_cast<Field<point>&>(MeshReference::points()) const_cast<Field<point>&>(MeshReference::points())
@ -239,8 +239,8 @@ void Foam::surfMesh::updatePointsRef()
void Foam::surfMesh::updateFacesRef() void Foam::surfMesh::updateFacesRef()
{ {
// assign the reference to the faces // Assign the reference to the faces
static_cast<UList<face>&>(*this) = this->storedFaces(); shallowCopy(this->storedFaces());
} }

View File

@ -467,10 +467,9 @@ void Foam::radiation::viewFactor::calculate()
} }
// Fill the local values to distribute // Fill the local values to distribute
SubList<scalar>(compactCoarseT,nLocalCoarseFaces_).assign(localCoarseTave); SubList<scalar>(compactCoarseT,nLocalCoarseFaces_) = localCoarseTave;
SubList<scalar>(compactCoarseE,nLocalCoarseFaces_).assign(localCoarseEave); SubList<scalar>(compactCoarseE,nLocalCoarseFaces_) = localCoarseEave;
SubList<scalar> SubList<scalar>(compactCoarseHo,nLocalCoarseFaces_) = localCoarseHoave;
(compactCoarseHo,nLocalCoarseFaces_).assign(localCoarseHoave);
// Distribute data // Distribute data
map_->distribute(compactCoarseT); map_->distribute(compactCoarseT);
@ -491,7 +490,7 @@ void Foam::radiation::viewFactor::calculate()
( (
compactGlobalIds, compactGlobalIds,
nLocalCoarseFaces_ nLocalCoarseFaces_
).assign(localGlobalIds); ) = localGlobalIds;
map_->distribute(compactGlobalIds); map_->distribute(compactGlobalIds);