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:
@ -56,8 +56,8 @@ int main(int argc, char *argv[])
|
||||
rowSizes[1] = row1.size();
|
||||
cll1.resize(rowSizes);
|
||||
|
||||
cll1[0].assign(row0); //note: operator= will not work since UList
|
||||
cll1[1].assign(row1);
|
||||
cll1[0].deepCopy(row0);
|
||||
cll1[1].deepCopy(row1);
|
||||
Info<< "cll1:" << cll1 << endl;
|
||||
|
||||
forAll(cll1.m(), i)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -64,10 +64,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Create field with my local data
|
||||
pointField coords(globalPointSlavesMap.constructSize());
|
||||
SubList<point>(coords, coupledPatch.nPoints()).assign
|
||||
(
|
||||
coupledPatch.localPoints()
|
||||
);
|
||||
SubList<point>(coords, coupledPatch.nPoints()) =
|
||||
coupledPatch.localPoints();
|
||||
|
||||
// Exchange data. Apply positional transforms.
|
||||
globalPointSlavesMap.distribute
|
||||
@ -185,8 +183,7 @@ int main(int argc, char *argv[])
|
||||
label nBnd = mesh.nFaces()-mesh.nInternalFaces();
|
||||
|
||||
pointField fc(globalPointBoundaryFacesMap.constructSize());
|
||||
SubList<point>(fc, nBnd).assign
|
||||
(
|
||||
SubList<point>(fc, nBnd) =
|
||||
primitivePatch
|
||||
(
|
||||
SubList<face>
|
||||
@ -196,8 +193,7 @@ int main(int argc, char *argv[])
|
||||
mesh.nInternalFaces()
|
||||
),
|
||||
mesh.points()
|
||||
).faceCentres()
|
||||
);
|
||||
).faceCentres();
|
||||
|
||||
// Exchange data
|
||||
globalPointBoundaryFacesMap.distribute
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -240,7 +240,7 @@ bool setFaceFieldType
|
||||
field.boundaryField()[patchi].size(),
|
||||
field.boundaryField()[patchi].patch().start()
|
||||
- mesh.nInternalFaces()
|
||||
).assign(field.boundaryField()[patchi]);
|
||||
) = field.boundaryField()[patchi];
|
||||
}
|
||||
|
||||
// Override
|
||||
|
||||
@ -424,14 +424,14 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
availablePoints,
|
||||
upp.faceCentres().size()
|
||||
).assign(upp.faceCentres());
|
||||
) = upp.faceCentres();
|
||||
|
||||
SubList<point>
|
||||
(
|
||||
availablePoints,
|
||||
upp.localPoints().size(),
|
||||
upp.faceCentres().size()
|
||||
).assign(upp.localPoints());
|
||||
) = upp.localPoints();
|
||||
|
||||
point cfo = cf;
|
||||
scalar dist = GREAT;
|
||||
@ -592,8 +592,8 @@ int main(int argc, char *argv[])
|
||||
DynamicList<label> compactPatchId(map.constructSize());
|
||||
|
||||
// Insert my coarse local values
|
||||
SubList<point>(compactCoarseSf, nCoarseFaces).assign(localCoarseSf);
|
||||
SubList<point>(compactCoarseCf, nCoarseFaces).assign(localCoarseCf);
|
||||
SubList<point>(compactCoarseSf, nCoarseFaces) = localCoarseSf;
|
||||
SubList<point>(compactCoarseCf, nCoarseFaces) = localCoarseCf;
|
||||
|
||||
// Insert my fine local values
|
||||
label compactI = 0;
|
||||
|
||||
@ -87,6 +87,9 @@ public:
|
||||
//- Allow cast to a const List<T>&
|
||||
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
|
||||
inline void operator=(const UList<T>&);
|
||||
|
||||
|
||||
@ -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>
|
||||
inline void Foam::SubList<T>::operator=(const UList<T>& l)
|
||||
{
|
||||
UList<T>::assign(l);
|
||||
UList<T>::deepCopy(l);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ License
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
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_)
|
||||
{
|
||||
|
||||
@ -80,6 +80,19 @@ class UList
|
||||
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:
|
||||
|
||||
// Related types
|
||||
@ -90,11 +103,13 @@ public:
|
||||
//- Declare friendship with the SubList class
|
||||
friend class SubList<T>;
|
||||
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Return a null UList
|
||||
inline static const UList<T>& null();
|
||||
|
||||
|
||||
// Public classes
|
||||
|
||||
//- Less function class that can be used for sorting
|
||||
@ -198,15 +213,18 @@ public:
|
||||
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.
|
||||
void writeEntry(Ostream&) const;
|
||||
|
||||
//- Write the UList as a dictionary entry with keyword.
|
||||
void writeEntry(const word& keyword, Ostream&) const;
|
||||
|
||||
//- Assign elements to those from UList.
|
||||
void assign(const UList<T>&);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
@ -327,7 +345,7 @@ public:
|
||||
// STL member operators
|
||||
|
||||
//- 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.
|
||||
bool operator==(const UList<T>&) const;
|
||||
|
||||
|
||||
@ -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 * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
|
||||
@ -158,7 +158,7 @@ slicedBoundaryField
|
||||
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
|
||||
UList<Type>::operator=
|
||||
UList<Type>::shallowCopy
|
||||
(
|
||||
typename Field<Type>::subField(iField, GeoMesh::size(mesh))
|
||||
);
|
||||
@ -227,7 +227,7 @@ SlicedGeometricField
|
||||
)
|
||||
{
|
||||
// Set the internalField to the slice of the complete field
|
||||
UList<Type>::operator=
|
||||
UList<Type>::shallowCopy
|
||||
(
|
||||
typename Field<Type>::subField(completeField, GeoMesh::size(mesh))
|
||||
);
|
||||
@ -271,7 +271,7 @@ SlicedGeometricField
|
||||
)
|
||||
{
|
||||
// Set the internalField to the slice of the complete field
|
||||
UList<Type>::operator=
|
||||
UList<Type>::shallowCopy
|
||||
(
|
||||
typename Field<Type>::subField(completeIField, GeoMesh::size(mesh))
|
||||
);
|
||||
@ -305,7 +305,7 @@ SlicedGeometricField
|
||||
)
|
||||
{
|
||||
// Set the internalField to the supplied internal field
|
||||
UList<Type>::operator=(gf.internalField());
|
||||
UList<Type>::shallowCopy(gf.internalField());
|
||||
|
||||
correctBoundaryConditions();
|
||||
}
|
||||
@ -334,7 +334,7 @@ SlicedGeometricField
|
||||
)
|
||||
{
|
||||
// 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
|
||||
// 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
|
||||
// to protect the field it a slice of.
|
||||
UList<Type>::operator=(UList<Type>(NULL, 0));
|
||||
UList<Type>::shallowCopy(UList<Type>(NULL, 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ void Foam::LUscalarMatrix::solve
|
||||
(
|
||||
X,
|
||||
x.size()
|
||||
).assign(x);
|
||||
) = x;
|
||||
|
||||
for
|
||||
(
|
||||
|
||||
@ -497,14 +497,13 @@ void Foam::GAMGSolver::procAgglomerateMatrix
|
||||
if (coarsestMatrix.hasDiag())
|
||||
{
|
||||
scalarField& allDiag = allMatrix.diag();
|
||||
|
||||
SubList<scalar>
|
||||
(
|
||||
allDiag,
|
||||
coarsestMatrix.diag().size()
|
||||
).assign
|
||||
(
|
||||
coarsestMatrix.diag()
|
||||
);
|
||||
) = coarsestMatrix.diag();
|
||||
|
||||
forAll(otherMats, i)
|
||||
{
|
||||
SubList<scalar>
|
||||
@ -512,10 +511,7 @@ void Foam::GAMGSolver::procAgglomerateMatrix
|
||||
allDiag,
|
||||
otherMats[i].diag().size(),
|
||||
cellOffsets[i+1]
|
||||
).assign
|
||||
(
|
||||
otherMats[i].diag()
|
||||
);
|
||||
) = otherMats[i].diag();
|
||||
}
|
||||
}
|
||||
if (coarsestMatrix.hasLower())
|
||||
|
||||
@ -295,7 +295,7 @@ void Foam::GAMGSolver::Vcycle
|
||||
// used
|
||||
if (nPreSweeps_)
|
||||
{
|
||||
preSmoothedCoarseCorrField.assign(coarseCorrFields[leveli]);
|
||||
preSmoothedCoarseCorrField = coarseCorrFields[leveli];
|
||||
}
|
||||
|
||||
agglomeration_.prolongField
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -44,7 +44,7 @@ void Foam::globalIndex::gather
|
||||
allFld.setSize(off.last());
|
||||
|
||||
// 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)
|
||||
{
|
||||
@ -207,7 +207,7 @@ void Foam::globalIndex::scatter
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
@ -582,7 +582,7 @@ operator=
|
||||
{
|
||||
clearOut();
|
||||
|
||||
FaceList<Face>::operator=(pp);
|
||||
FaceList<Face>::shallowCopy(pp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ void Foam::UPstream::allToAll
|
||||
const label communicator
|
||||
)
|
||||
{
|
||||
recvData.assign(sendData);
|
||||
recvData.deepCopy(sendData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -316,7 +316,7 @@ void Foam::UPstream::allToAll
|
||||
|
||||
if (!UPstream::parRun())
|
||||
{
|
||||
recvData.assign(sendData);
|
||||
recvData.deepCopy(sendData);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -566,10 +566,8 @@ void Foam::fvMeshDistribute::getNeighbourData
|
||||
}
|
||||
|
||||
// Which processor they will end up on
|
||||
SubList<label>(nbrNewNbrProc, pp.size(), offset).assign
|
||||
(
|
||||
UIndirectList<label>(distribution, pp.faceCells())()
|
||||
);
|
||||
SubList<label>(nbrNewNbrProc, pp.size(), offset) =
|
||||
UIndirectList<label>(distribution, pp.faceCells())();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1074,7 +1072,7 @@ void Foam::fvMeshDistribute::sendMesh
|
||||
|
||||
if (myZoneID != -1)
|
||||
{
|
||||
zonePoints[nameI].assign(pointZones[myZoneID]);
|
||||
zonePoints[nameI].deepCopy(pointZones[myZoneID]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1106,8 +1104,8 @@ void Foam::fvMeshDistribute::sendMesh
|
||||
|
||||
if (myZoneID != -1)
|
||||
{
|
||||
zoneFaces[nameI].assign(faceZones[myZoneID]);
|
||||
zoneFaceFlip[nameI].assign(faceZones[myZoneID].flipMap());
|
||||
zoneFaces[nameI].deepCopy(faceZones[myZoneID]);
|
||||
zoneFaceFlip[nameI].deepCopy(faceZones[myZoneID].flipMap());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1137,7 +1135,7 @@ void Foam::fvMeshDistribute::sendMesh
|
||||
|
||||
if (myZoneID != -1)
|
||||
{
|
||||
zoneCells[nameI].assign(cellZones[myZoneID]);
|
||||
zoneCells[nameI].deepCopy(cellZones[myZoneID]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ Foam::slicedFvPatchField<Type>::slicedFvPatchField
|
||||
fvPatchField<Type>(p, iF, Field<Type>())
|
||||
{
|
||||
// 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>())
|
||||
{
|
||||
// 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
|
||||
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
|
||||
// to protect the field it a slice of.
|
||||
UList<Type>::operator=(UList<Type>(NULL, 0));
|
||||
UList<Type>::shallowCopy(UList<Type>(NULL, 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ Foam::slicedFvsPatchField<Type>::slicedFvsPatchField
|
||||
fvsPatchField<Type>(p, iF, Field<Type>())
|
||||
{
|
||||
// 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>())
|
||||
{
|
||||
// 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
|
||||
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
|
||||
// to protect the field it a slice of.
|
||||
UList<Type>::operator=(UList<Type>(NULL, 0));
|
||||
UList<Type>::shallowCopy(UList<Type>(NULL, 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -184,7 +184,7 @@ Foam::tmp<Foam::Field<Type>> Foam::volPointInterpolation::flatBoundaryField
|
||||
boundaryVals,
|
||||
vf.boundaryField()[patchI].size(),
|
||||
bFaceI
|
||||
).assign(vf.boundaryField()[patchI]);
|
||||
) = vf.boundaryField()[patchI];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -115,7 +115,7 @@ void Foam::CellZoneInjection<CloudType>::setPositions
|
||||
allPositions,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.offset(Pstream::myProcNo())
|
||||
).assign(positions);
|
||||
) = positions;
|
||||
|
||||
Pstream::listCombineGather(allPositions, minEqOp<point>());
|
||||
Pstream::listCombineScatter(allPositions);
|
||||
@ -126,19 +126,19 @@ void Foam::CellZoneInjection<CloudType>::setPositions
|
||||
allInjectorCells,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.offset(Pstream::myProcNo())
|
||||
).assign(injectorCells);
|
||||
) = injectorCells;
|
||||
SubList<label>
|
||||
(
|
||||
allInjectorTetFaces,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.offset(Pstream::myProcNo())
|
||||
).assign(injectorTetFaces);
|
||||
) = injectorTetFaces;
|
||||
SubList<label>
|
||||
(
|
||||
allInjectorTetPts,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.offset(Pstream::myProcNo())
|
||||
).assign(injectorTetPts);
|
||||
) = injectorTetPts;
|
||||
|
||||
// Transfer data
|
||||
positions_.transfer(allPositions);
|
||||
|
||||
@ -138,7 +138,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
|
||||
allMass,
|
||||
globalParcels.localSize(procI),
|
||||
globalParcels.offset(procI)
|
||||
).assign(procMass[procI]);
|
||||
) = procMass[procI];
|
||||
|
||||
// flatten the distance list
|
||||
SubList<scalar>
|
||||
@ -146,7 +146,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
|
||||
allDist,
|
||||
globalParcels.localSize(procI),
|
||||
globalParcels.offset(procI)
|
||||
).assign(procDist[procI]);
|
||||
) = procDist[procI];
|
||||
}
|
||||
|
||||
// sort allDist distances into ascending order
|
||||
|
||||
@ -246,7 +246,7 @@ distributeAndMergePatches
|
||||
// My own data first
|
||||
{
|
||||
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()];
|
||||
forAll(fcs, i)
|
||||
@ -274,7 +274,7 @@ distributeAndMergePatches
|
||||
if (procI != Pstream::myProcNo())
|
||||
{
|
||||
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];
|
||||
forAll(fcs, i)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -325,7 +325,7 @@ Foam::labelList Foam::simpleGeomDecomp::decompose
|
||||
|
||||
label nTotalPoints = 0;
|
||||
// Master first
|
||||
SubField<point>(allPoints, points.size()).assign(points);
|
||||
SubField<point>(allPoints, points.size()) = points;
|
||||
nTotalPoints += points.size();
|
||||
|
||||
// Add slaves
|
||||
@ -338,7 +338,7 @@ Foam::labelList Foam::simpleGeomDecomp::decompose
|
||||
allPoints,
|
||||
nbrPoints.size(),
|
||||
nTotalPoints
|
||||
).assign(nbrPoints);
|
||||
) = nbrPoints;
|
||||
nTotalPoints += nbrPoints.size();
|
||||
}
|
||||
|
||||
@ -401,8 +401,8 @@ Foam::labelList Foam::simpleGeomDecomp::decompose
|
||||
|
||||
label nTotalPoints = 0;
|
||||
// Master first
|
||||
SubField<point>(allPoints, points.size()).assign(points);
|
||||
SubField<scalar>(allWeights, points.size()).assign(weights);
|
||||
SubField<point>(allPoints, points.size()) = points;
|
||||
SubField<scalar>(allWeights, points.size()) = weights;
|
||||
nTotalPoints += points.size();
|
||||
|
||||
// Add slaves
|
||||
@ -416,13 +416,13 @@ Foam::labelList Foam::simpleGeomDecomp::decompose
|
||||
allPoints,
|
||||
nbrPoints.size(),
|
||||
nTotalPoints
|
||||
).assign(nbrPoints);
|
||||
) = nbrPoints;
|
||||
SubField<scalar>
|
||||
(
|
||||
allWeights,
|
||||
nbrWeights.size(),
|
||||
nTotalPoints
|
||||
).assign(nbrWeights);
|
||||
) = nbrWeights;
|
||||
nTotalPoints += nbrPoints.size();
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -122,7 +122,7 @@ Foam::labelList Foam::SloanRenumber::renumber
|
||||
nbr,
|
||||
pbm[patchI].size(),
|
||||
pbm[patchI].start()-mesh.nInternalFaces()
|
||||
).assign(pbm[patchI].faceCells());
|
||||
) = pbm[patchI].faceCells();
|
||||
}
|
||||
}
|
||||
syncTools::swapBoundaryFaceList(mesh, nbr);
|
||||
|
||||
@ -644,17 +644,14 @@ void Foam::meshToMesh::distributeAndMergeCells
|
||||
forAll(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
|
||||
forAll(allTgtCellIDs, procI)
|
||||
{
|
||||
const labelList& cellIDs = allTgtCellIDs[procI];
|
||||
SubList<label>(tgtCellIDs, cellIDs.size(), cellOffset[procI]).assign
|
||||
(
|
||||
cellIDs
|
||||
);
|
||||
SubList<label>(tgtCellIDs, cellIDs.size(), cellOffset[procI]) = cellIDs;
|
||||
}
|
||||
|
||||
|
||||
@ -671,7 +668,7 @@ void Foam::meshToMesh::distributeAndMergeCells
|
||||
allNInternalFaces[procI],
|
||||
internalFaceOffset[procI]
|
||||
);
|
||||
slice.assign(SubList<face>(fcs, allNInternalFaces[procI]));
|
||||
slice = SubList<face>(fcs, allNInternalFaces[procI]);
|
||||
forAll(slice, i)
|
||||
{
|
||||
add(slice[i], pointOffset[procI]);
|
||||
@ -683,7 +680,7 @@ void Foam::meshToMesh::distributeAndMergeCells
|
||||
allNInternalFaces[procI],
|
||||
internalFaceOffset[procI]
|
||||
);
|
||||
ownSlice.assign(SubField<label>(faceOs, allNInternalFaces[procI]));
|
||||
ownSlice = SubField<label>(faceOs, allNInternalFaces[procI]);
|
||||
add(ownSlice, cellOffset[procI]);
|
||||
|
||||
SubField<label> nbrSlice
|
||||
@ -692,7 +689,7 @@ void Foam::meshToMesh::distributeAndMergeCells
|
||||
allNInternalFaces[procI],
|
||||
internalFaceOffset[procI]
|
||||
);
|
||||
nbrSlice.assign(SubField<label>(faceNs, allNInternalFaces[procI]));
|
||||
nbrSlice = SubField<label>(faceNs, allNInternalFaces[procI]);
|
||||
add(nbrSlice, cellOffset[procI]);
|
||||
|
||||
internalFaceOffset[procI] += allNInternalFaces[procI];
|
||||
|
||||
@ -109,7 +109,7 @@ Foam::sampledPatchInternalField::interpolateField
|
||||
|
||||
// Now patchVals holds the interpolated data in patch face order.
|
||||
// Collect.
|
||||
SubList<Type>(allPatchVals, patchVals.size(), sz).assign(patchVals);
|
||||
SubList<Type>(allPatchVals, patchVals.size(), sz) = patchVals;
|
||||
sz += patchVals.size();
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ Foam::sampledTriSurfaceMesh::sampleField
|
||||
bVals,
|
||||
vField.boundaryField()[patchI].size(),
|
||||
bFaceI
|
||||
).assign(vField.boundaryField()[patchI]);
|
||||
) = vField.boundaryField()[patchI];
|
||||
}
|
||||
|
||||
// Sample in flat boundary field
|
||||
|
||||
@ -229,7 +229,7 @@ Foam::surfMesh::~surfMesh()
|
||||
|
||||
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>&>
|
||||
(
|
||||
const_cast<Field<point>&>(MeshReference::points())
|
||||
@ -239,8 +239,8 @@ void Foam::surfMesh::updatePointsRef()
|
||||
|
||||
void Foam::surfMesh::updateFacesRef()
|
||||
{
|
||||
// assign the reference to the faces
|
||||
static_cast<UList<face>&>(*this) = this->storedFaces();
|
||||
// Assign the reference to the faces
|
||||
shallowCopy(this->storedFaces());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -467,10 +467,9 @@ void Foam::radiation::viewFactor::calculate()
|
||||
}
|
||||
|
||||
// Fill the local values to distribute
|
||||
SubList<scalar>(compactCoarseT,nLocalCoarseFaces_).assign(localCoarseTave);
|
||||
SubList<scalar>(compactCoarseE,nLocalCoarseFaces_).assign(localCoarseEave);
|
||||
SubList<scalar>
|
||||
(compactCoarseHo,nLocalCoarseFaces_).assign(localCoarseHoave);
|
||||
SubList<scalar>(compactCoarseT,nLocalCoarseFaces_) = localCoarseTave;
|
||||
SubList<scalar>(compactCoarseE,nLocalCoarseFaces_) = localCoarseEave;
|
||||
SubList<scalar>(compactCoarseHo,nLocalCoarseFaces_) = localCoarseHoave;
|
||||
|
||||
// Distribute data
|
||||
map_->distribute(compactCoarseT);
|
||||
@ -491,7 +490,7 @@ void Foam::radiation::viewFactor::calculate()
|
||||
(
|
||||
compactGlobalIds,
|
||||
nLocalCoarseFaces_
|
||||
).assign(localGlobalIds);
|
||||
) = localGlobalIds;
|
||||
|
||||
map_->distribute(compactGlobalIds);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user