ENH: use emplace_set, emplace_back to simplify code

- eg, for cloud fields, tmp emplace when reading fields etc.
This commit is contained in:
Mark Olesen
2023-07-21 12:32:04 +02:00
parent 63258d0b33
commit 8117cde596
25 changed files with 373 additions and 620 deletions

View File

@ -54,56 +54,44 @@ Description
); );
// An empty zone for cut points // An empty zone for cut points
pzs.append pzs.emplace_back
(
new pointZone
( (
mergeName + "CutPointZone", mergeName + "CutPointZone",
pzs.size(), pzs.size(), // index
pzs pzs
)
); );
cleanupPointZones.insert(pzs.last().name()); cleanupPointZones.insert(pzs.back().name());
// Coupling side 0 (master) // Coupling side 0 (master)
fzs.append fzs.emplace_back
(
new faceZone
( (
mergeName + "Side0Zone", mergeName + "Side0Zone",
identity(patch0.range()), identity(patch0.range()),
false, // none are flipped false, // none are flipped
fzs.size(), fzs.size(), // index
fzs fzs
)
); );
cleanupFaceZones.insert(fzs.last().name()); cleanupFaceZones.insert(fzs.back().name());
// Coupling side 1 (slave) // Coupling side 1 (slave)
fzs.append fzs.emplace_back
(
new faceZone
( (
mergeName + "Side1Zone", mergeName + "Side1Zone",
identity(patch1.range()), identity(patch1.range()),
false, // none are flipped false, // none are flipped
fzs.size(), fzs.size(), // index
fzs fzs
)
); );
cleanupFaceZones.insert(fzs.last().name()); cleanupFaceZones.insert(fzs.back().name());
// An empty zone for cut faces // An empty zone for cut faces
fzs.append fzs.emplace_back
(
new faceZone
( (
mergeName + "CutFaceZone", mergeName + "CutFaceZone",
fzs.size(), fzs.size(), // index
fzs fzs
)
); );
cleanupFaceZones.insert(fzs.last().name()); cleanupFaceZones.insert(fzs.back().name());
} }
} }

View File

@ -139,7 +139,7 @@ void rewriteBoundary
if (patchDict.found("neighbourPatch")) if (patchDict.found("neighbourPatch"))
{ {
patches.set(patchi, oldPatches.set(patchi, nullptr)); patches.set(patchi, oldPatches.release(patchi));
oldToNew[patchi] = newPatchi++; oldToNew[patchi] = newPatchi++;
// Check if patches come from automatic conversion // Check if patches come from automatic conversion
@ -187,7 +187,7 @@ void rewriteBoundary
const dictionary patchDict(patches[patchi].dict()); const dictionary patchDict(patches[patchi].dict());
// Change entry on this side // Change entry on this side
patches.set(patchi, oldPatches.set(patchi, nullptr)); patches.set(patchi, oldPatches.release(patchi));
oldToNew[patchi] = newPatchi++; oldToNew[patchi] = newPatchi++;
dictionary& thisPatchDict = patches[patchi].dict(); dictionary& thisPatchDict = patches[patchi].dict();
thisPatchDict.add("neighbourPatch", nbrName); thisPatchDict.add("neighbourPatch", nbrName);
@ -230,7 +230,7 @@ void rewriteBoundary
} }
else else
{ {
patches.set(patchi, oldPatches.set(patchi, nullptr)); patches.set(patchi, oldPatches.release(patchi));
oldToNew[patchi] = newPatchi++; oldToNew[patchi] = newPatchi++;
} }
} }

View File

@ -199,25 +199,34 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcPointAddressing() const
if (doWeights) if (doWeights)
{ {
// Set interpolation pointWeights // Set interpolation pointWeights
pointWeights.set(pointi, new scalarField(hitFace.size())); const pointField hitFacePoints
(
hitFace.points(fromPatchPoints)
);
pointField hitFacePoints = hitFace.points(fromPatchPoints); auto& pointiWeights =
pointWeights.emplace_set(pointi, hitFacePoints.size());
scalar sumWeight = 0;
forAll(hitFacePoints, masterPointi) forAll(hitFacePoints, masterPointi)
{ {
pointWeights[pointi][masterPointi] = const point& p = hitFacePoints[masterPointi];
1.0/
const scalar w =
( (
hitPoint.dist(hitFacePoints[masterPointi]) 1.0 / (hitPoint.dist(p) + VSMALL)
+ VSMALL
); );
pointiWeights[masterPointi] = w;
sumWeight += w;
} }
pointWeights[pointi] /= sum(pointWeights[pointi]); pointiWeights /= sumWeight;
} }
else else
{ {
pointWeights.set(pointi, new scalarField()); pointWeights.emplace_set(pointi);
} }
} }
} }
@ -296,7 +305,9 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing() const
const labelList& neighbours = const labelList& neighbours =
fromPatchFaceFaces[faceAddressing[facei]]; fromPatchFaceFaces[faceAddressing[facei]];
scalar m = curHit.hitPoint().dist(hitFaceCentre); const point& hitPoint = curHit.hitPoint();
scalar m = hitPoint.dist(hitFaceCentre);
if if
( (
@ -304,8 +315,8 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing() const
|| neighbours.empty() || neighbours.empty()
) )
{ {
faceWeights.set(facei, new scalarField(1)); auto& faceiWeights = faceWeights.emplace_set(facei, 1);
faceWeights[facei][0] = 1.0; faceiWeights[0] = 1.0;
} }
else else
{ {
@ -313,29 +324,33 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing() const
// The first coefficient corresponds to the centre face. // The first coefficient corresponds to the centre face.
// The rest is ordered in the same way as the faceFaces list. // The rest is ordered in the same way as the faceFaces list.
faceWeights.set(facei, new scalarField(neighbours.size() + 1));
faceWeights[facei][0] = 1.0/m; auto& faceiWeights =
faceWeights.emplace_set(facei, neighbours.size() + 1);
forAll(neighbours, nI) faceiWeights[0] = 1.0/m;
scalar sumWeight = faceiWeights[0];
forAll(neighbours, nbri)
{ {
faceWeights[facei][nI + 1] = const point& p = fromPatchFaceCentres[neighbours[nbri]];
1.0/
const scalar w =
( (
curHit.hitPoint().dist 1.0 / (hitPoint.dist(p) + VSMALL)
(
fromPatchFaceCentres[neighbours[nI]]
)
+ VSMALL
); );
}
faceWeights[nbri+1] = w;
sumWeight += w;
} }
faceWeights[facei] /= sum(faceWeights[facei]); faceiWeights /= sumWeight;
}
} }
else else
{ {
faceWeights.set(facei, new scalarField()); faceWeights.emplace_set(facei);
} }
} }
} }

View File

@ -160,8 +160,7 @@ void Foam::fieldsDistributor::readFieldsImpl
#endif #endif
fields.free(); fields.resize_null(masterNames.size());
fields.resize(masterNames.size());
if (fields.empty()) if (fields.empty())
{ {

View File

@ -109,7 +109,7 @@ void Foam::fvMeshAdder::MapVolField
// Sort deleted ones last so is now in newPatch ordering // Sort deleted ones last so is now in newPatch ordering
bfld.reorder(oldToNew); bfld.reorder(oldToNew);
// Extend to covers all patches // Extend to covers all patches
bfld.setSize(mesh.boundaryMesh().size()); bfld.resize(mesh.boundaryMesh().size());
// Delete unused patches // Delete unused patches
for for
( (
@ -118,7 +118,7 @@ void Foam::fvMeshAdder::MapVolField
newPatchi++ newPatchi++
) )
{ {
bfld.set(newPatchi, nullptr); bfld.release(newPatchi);
} }
@ -419,7 +419,7 @@ void Foam::fvMeshAdder::MapSurfaceField
// Sort deleted ones last so is now in newPatch ordering // Sort deleted ones last so is now in newPatch ordering
bfld.reorder(oldToNew); bfld.reorder(oldToNew);
// Extend to covers all patches // Extend to covers all patches
bfld.setSize(mesh.boundaryMesh().size()); bfld.resize(mesh.boundaryMesh().size());
// Delete unused patches // Delete unused patches
for for
( (
@ -428,7 +428,7 @@ void Foam::fvMeshAdder::MapSurfaceField
newPatchi++ newPatchi++
) )
{ {
bfld.set(newPatchi, nullptr); bfld.release(newPatchi);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2018 OpenFOAM Foundation Copyright (C) 2011-2018 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.
@ -222,7 +222,7 @@ Foam::wordList Foam::fvMeshDistribute::mergeWordList(const wordList& procNames)
} }
void Foam::fvMeshDistribute::printMeshInfo(const fvMesh& mesh) void Foam::fvMeshDistribute::printMeshInfo(const polyMesh& mesh)
{ {
Pout<< "Primitives:" << nl Pout<< "Primitives:" << nl
<< " points :" << mesh.nPoints() << nl << " points :" << mesh.nPoints() << nl
@ -231,52 +231,35 @@ void Foam::fvMeshDistribute::printMeshInfo(const fvMesh& mesh)
<< " faces :" << mesh.nFaces() << nl << " faces :" << mesh.nFaces() << nl
<< " cells :" << mesh.nCells() << nl; << " cells :" << mesh.nCells() << nl;
const fvBoundaryMesh& patches = mesh.boundary();
Pout<< "Patches:" << endl; Pout<< "Patches:" << endl;
forAll(patches, patchi) for (const polyPatch& pp : mesh.boundaryMesh())
{ {
const polyPatch& pp = patches[patchi].patch(); Pout<< " " << pp.index() << " name:" << pp.name()
Pout<< " " << patchi << " name:" << pp.name()
<< " size:" << pp.size() << " size:" << pp.size()
<< " start:" << pp.start() << " start:" << pp.start()
<< " type:" << pp.type() << " type:" << pp.type()
<< endl; << endl;
} }
if (mesh.pointZones().size()) if (mesh.pointZones().empty()) Pout<< "PointZones:" << endl;
for (const auto& zn : mesh.pointZones())
{ {
Pout<< "PointZones:" << endl; Pout<< " " << zn.index() << " name:" << zn.name()
forAll(mesh.pointZones(), zoneI) << " size:" << zn.size() << endl;
{
const pointZone& pz = mesh.pointZones()[zoneI];
Pout<< " " << zoneI << " name:" << pz.name()
<< " size:" << pz.size()
<< endl;
} }
}
if (mesh.faceZones().size()) if (!mesh.faceZones().empty()) Pout<< "FaceZones:" << endl;
for (const auto& zn : mesh.faceZones())
{ {
Pout<< "FaceZones:" << endl; Pout<< " " << zn.index() << " name:" << zn.name()
forAll(mesh.faceZones(), zoneI) << " size:" << zn.size() << endl;
{
const faceZone& fz = mesh.faceZones()[zoneI];
Pout<< " " << zoneI << " name:" << fz.name()
<< " size:" << fz.size()
<< endl;
} }
}
if (mesh.cellZones().size()) if (!mesh.cellZones().empty()) Pout<< "CellZones:" << endl;
for (const auto& zn : mesh.cellZones())
{ {
Pout<< "CellZones:" << endl; Pout<< " " << zn.index() << " name:" << zn.name()
forAll(mesh.cellZones(), zoneI) << " size:" << zn.size() << endl;
{
const cellZone& cz = mesh.cellZones()[zoneI];
Pout<< " " << zoneI << " name:" << cz.name()
<< " size:" << cz.size()
<< endl;
}
} }
} }
@ -960,7 +943,7 @@ void Foam::fvMeshDistribute::getCouplingData
// Collect coupled (collocated) points // Collect coupled (collocated) points
sourcePointMaster.setSize(mesh_.nPoints()); sourcePointMaster.resize_nocopy(mesh_.nPoints());
sourcePointMaster = -1; sourcePointMaster = -1;
{ {
// Assign global master point // Assign global master point
@ -1208,9 +1191,9 @@ void Foam::fvMeshDistribute::findCouples
{ {
if (meshes.set(meshi)) if (meshes.set(meshi))
{ {
dynLocalFace[meshi].setCapacity(nProcFaces[meshi]); dynLocalFace[meshi].reserve(nProcFaces[meshi]);
dynRemoteProc[meshi].setCapacity(nProcFaces[meshi]); dynRemoteProc[meshi].reserve(nProcFaces[meshi]);
dynRemoteFace[meshi].setCapacity(nProcFaces[meshi]); dynRemoteFace[meshi].reserve(nProcFaces[meshi]);
} }
} }
@ -2515,37 +2498,36 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
PtrList<fvMesh> domainMeshPtrs(Pstream::nProcs()); PtrList<fvMesh> domainMeshPtrs(Pstream::nProcs());
PtrList<PtrList<volScalarField>> vsfs(Pstream::nProcs()); // Define field storage lists
PtrList<PtrList<volVectorField>> vvfs(Pstream::nProcs()); #undef doLocalCode
PtrList<PtrList<volSphericalTensorField>> vsptfs(Pstream::nProcs()); #define doLocalCode(FieldType, Variable) \
PtrList<PtrList<volSymmTensorField>> vsytfs(Pstream::nProcs()); PtrList<PtrList<FieldType>> Variable(UPstream::nProcs());
PtrList<PtrList<volTensorField>> vtfs(Pstream::nProcs());
PtrList<PtrList<surfaceScalarField>> ssfs(Pstream::nProcs()); doLocalCode(volScalarField, vsfs);
PtrList<PtrList<surfaceVectorField>> svfs(Pstream::nProcs()); doLocalCode(volVectorField, vvfs);
PtrList<PtrList<surfaceSphericalTensorField>> ssptfs doLocalCode(volSphericalTensorField, vsptfs);
( doLocalCode(volSymmTensorField, vsytfs);
Pstream::nProcs() doLocalCode(volTensorField, vtfs);
);
PtrList<PtrList<surfaceSymmTensorField>> ssytfs(Pstream::nProcs()); doLocalCode(surfaceScalarField, ssfs);
PtrList<PtrList<surfaceTensorField>> stfs(Pstream::nProcs()); doLocalCode(surfaceVectorField, svfs);
doLocalCode(surfaceSphericalTensorField, ssptfs);
doLocalCode(surfaceSymmTensorField, ssytfs);
doLocalCode(surfaceTensorField, stfs);
doLocalCode(volScalarField::Internal, dsfs);
doLocalCode(volVectorField::Internal, dvfs);
doLocalCode(volSphericalTensorField::Internal, dsptfs)
doLocalCode(volSymmTensorField::Internal, dsytfs);
doLocalCode(volTensorField::Internal, dtfs);
#undef doLocalCode
PtrList<PtrList<volScalarField::Internal>> dsfs(Pstream::nProcs());
PtrList<PtrList<volVectorField::Internal>> dvfs(Pstream::nProcs());
PtrList<PtrList<volSphericalTensorField::Internal>> dstfs
(
Pstream::nProcs()
);
PtrList<PtrList<volSymmTensorField::Internal>> dsytfs
(
Pstream::nProcs()
);
PtrList<PtrList<volTensorField::Internal>> dtfs(Pstream::nProcs());
forAll(nRecvCells, sendProc) forAll(nRecvCells, sendProc)
{ {
// Did processor sendProc send anything to me? // Did processor sendProc send anything to me?
if (sendProc != Pstream::myProcNo() && nRecvCells[sendProc] > 0) if (sendProc != UPstream::myProcNo() && nRecvCells[sendProc] > 0)
{ {
if (debug) if (debug)
{ {
@ -2561,25 +2543,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
UIPstream str(sendProc, pBufs); UIPstream str(sendProc, pBufs);
// Receive from sendProc // Receive from sendProc - opposite of sendMesh
domainSourceFaces.set(sendProc, new labelList(0));
labelList& domainSourceFace = domainSourceFaces[sendProc];
domainSourceProcs.set(sendProc, new labelList(0));
labelList& domainSourceProc = domainSourceProcs[sendProc];
domainSourcePatchs.set(sendProc, new labelList(0));
labelList& domainSourcePatch = domainSourcePatchs[sendProc];
domainSourceNewNbrProcs.set(sendProc, new labelList(0));
labelList& domainSourceNewNbrProc =
domainSourceNewNbrProcs[sendProc];
domainSourcePointMasters.set(sendProc, new labelList(0));
labelList& domainSourcePointMaster =
domainSourcePointMasters[sendProc];
// Opposite of sendMesh
{ {
autoPtr<fvMesh> domainMeshPtr = receiveMesh autoPtr<fvMesh> domainMeshPtr = receiveMesh
( (
@ -2589,14 +2553,15 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
cellZoneNames, cellZoneNames,
const_cast<Time&>(mesh_.time()), const_cast<Time&>(mesh_.time()),
domainSourceFace,
domainSourceProc, domainSourceFaces.emplace_set(sendProc),
domainSourcePatch, domainSourceProcs.emplace_set(sendProc),
domainSourceNewNbrProc, domainSourcePatchs.emplace_set(sendProc),
domainSourcePointMaster, domainSourceNewNbrProcs.emplace_set(sendProc),
domainSourcePointMasters.emplace_set(sendProc),
str str
); );
domainMeshPtrs.set(sendProc, domainMeshPtr.ptr()); domainMeshPtrs.set(sendProc, std::move(domainMeshPtr));
fvMesh& domainMesh = domainMeshPtrs[sendProc]; fvMesh& domainMesh = domainMeshPtrs[sendProc];
// Force construction of various on mesh. // Force construction of various on mesh.
//(void)domainMesh.globalData(); //(void)domainMesh.globalData();
@ -2606,174 +2571,39 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// of problems reading consecutive fields from single stream. // of problems reading consecutive fields from single stream.
dictionary fieldDicts(str); dictionary fieldDicts(str);
// Vol fields #undef doLocalCode
vsfs.set(sendProc, new PtrList<volScalarField>(0)); #define doLocalCode(FieldType, Variable) \
receiveFields<volScalarField> receiveFields<FieldType> \
( ( \
sendProc, sendProc, \
allFieldNames, allFieldNames, \
domainMesh, domainMesh, \
vsfs[sendProc], Variable.emplace_set(sendProc), \
fieldDicts fieldDicts \
); )
vvfs.set(sendProc, new PtrList<volVectorField>(0));
receiveFields<volVectorField>
(
sendProc,
allFieldNames,
domainMesh,
vvfs[sendProc],
fieldDicts
);
vsptfs.set
(
sendProc,
new PtrList<volSphericalTensorField>(0)
);
receiveFields<volSphericalTensorField>
(
sendProc,
allFieldNames,
domainMesh,
vsptfs[sendProc],
fieldDicts
);
vsytfs.set(sendProc, new PtrList<volSymmTensorField>(0));
receiveFields<volSymmTensorField>
(
sendProc,
allFieldNames,
domainMesh,
vsytfs[sendProc],
fieldDicts
);
vtfs.set(sendProc, new PtrList<volTensorField>(0));
receiveFields<volTensorField>
(
sendProc,
allFieldNames,
domainMesh,
vtfs[sendProc],
fieldDicts
);
// Surface fields // Volume Fields
ssfs.set(sendProc, new PtrList<surfaceScalarField>(0)); doLocalCode(volScalarField, vsfs);
receiveFields<surfaceScalarField> doLocalCode(volVectorField, vvfs);
( doLocalCode(volSphericalTensorField, vsptfs);
sendProc, doLocalCode(volSymmTensorField, vsytfs);
allFieldNames, doLocalCode(volTensorField, vtfs);
domainMesh,
ssfs[sendProc],
fieldDicts
);
svfs.set(sendProc, new PtrList<surfaceVectorField>(0));
receiveFields<surfaceVectorField>
(
sendProc,
allFieldNames,
domainMesh,
svfs[sendProc],
fieldDicts
);
ssptfs.set
(
sendProc,
new PtrList<surfaceSphericalTensorField>(0)
);
receiveFields<surfaceSphericalTensorField>
(
sendProc,
allFieldNames,
domainMesh,
ssptfs[sendProc],
fieldDicts
);
ssytfs.set(sendProc, new PtrList<surfaceSymmTensorField>(0));
receiveFields<surfaceSymmTensorField>
(
sendProc,
allFieldNames,
domainMesh,
ssytfs[sendProc],
fieldDicts
);
stfs.set(sendProc, new PtrList<surfaceTensorField>(0));
receiveFields<surfaceTensorField>
(
sendProc,
allFieldNames,
domainMesh,
stfs[sendProc],
fieldDicts
);
// Dimensioned fields // Surface Fields
dsfs.set doLocalCode(surfaceScalarField, ssfs);
( doLocalCode(surfaceVectorField, svfs);
sendProc, doLocalCode(surfaceSphericalTensorField, ssptfs);
new PtrList<volScalarField::Internal>(0) doLocalCode(surfaceSymmTensorField, ssytfs);
); doLocalCode(surfaceTensorField, stfs);
receiveFields<volScalarField::Internal>
( // Dimensioned Fields
sendProc, doLocalCode(volScalarField::Internal, dsfs);
allFieldNames, doLocalCode(volVectorField::Internal, dvfs);
domainMesh, doLocalCode(volSphericalTensorField::Internal, dsptfs);
dsfs[sendProc], doLocalCode(volSymmTensorField::Internal, dsytfs);
fieldDicts doLocalCode(volTensorField::Internal, dtfs);
);
dvfs.set #undef doLocalCode
(
sendProc,
new PtrList<volVectorField::Internal>(0)
);
receiveFields<volVectorField::Internal>
(
sendProc,
allFieldNames,
domainMesh,
dvfs[sendProc],
fieldDicts
);
dstfs.set
(
sendProc,
new PtrList<volSphericalTensorField::Internal>(0)
);
receiveFields<volSphericalTensorField::Internal>
(
sendProc,
allFieldNames,
domainMesh,
dstfs[sendProc],
fieldDicts
);
dsytfs.set
(
sendProc,
new PtrList<volSymmTensorField::Internal>(0)
);
receiveFields<volSymmTensorField::Internal>
(
sendProc,
allFieldNames,
domainMesh,
dsytfs[sendProc],
fieldDicts
);
dtfs.set
(
sendProc,
new PtrList<volTensorField::Internal>(0)
);
receiveFields<volTensorField::Internal>
(
sendProc,
allFieldNames,
domainMesh,
dtfs[sendProc],
fieldDicts
);
} }
} }
} }
@ -2796,33 +2626,25 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// 'Receive' from myself // 'Receive' from myself
{ {
meshes.set(Pstream::myProcNo(), &mesh_); meshes.set(UPstream::myProcNo(), &mesh_);
fvMeshes.set(Pstream::myProcNo(), &mesh_); fvMeshes.set(UPstream::myProcNo(), &mesh_);
//domainSourceFaces.set(Pstream::myProcNo(), std::move(sourceFace)); domainSourceFaces.emplace_set(UPstream::myProcNo()) = sourceFace;
domainSourceFaces.set(Pstream::myProcNo(), new labelList(0)); domainSourceProcs.emplace_set(UPstream::myProcNo()) = sourceProc;
domainSourceFaces[Pstream::myProcNo()] = sourceFace; domainSourcePatchs.emplace_set(UPstream::myProcNo()) = sourcePatch;
domainSourceProcs.set(Pstream::myProcNo(), new labelList(0)); domainSourceNewNbrProcs.emplace_set(UPstream::myProcNo()) =
//std::move(sourceProc)); sourceNewNbrProc;
domainSourceProcs[Pstream::myProcNo()] = sourceProc;
domainSourcePatchs.set(Pstream::myProcNo(), new labelList(0)); domainSourcePointMasters.emplace_set(UPstream::myProcNo()) =
//, std::move(sourcePatch)); sourcePointMaster;
domainSourcePatchs[Pstream::myProcNo()] = sourcePatch;
domainSourceNewNbrProcs.set(Pstream::myProcNo(), new labelList(0));
domainSourceNewNbrProcs[Pstream::myProcNo()] = sourceNewNbrProc;
domainSourcePointMasters.set(Pstream::myProcNo(), new labelList(0));
domainSourcePointMasters[Pstream::myProcNo()] = sourcePointMaster;
} }
// Find matching faces that need to be stitched // Find matching faces that need to be stitched
labelListList localBoundaryFace(Pstream::nProcs()); labelListList localBoundaryFace(UPstream::nProcs());
labelListList remoteFaceProc(Pstream::nProcs()); labelListList remoteFaceProc(UPstream::nProcs());
labelListList remoteBoundaryFace(Pstream::nProcs()); labelListList remoteBoundaryFace(UPstream::nProcs());
findCouples findCouples
( (
meshes, meshes,
@ -2887,15 +2709,15 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
{ {
//- Combine sourceProc, sourcePatch, sourceFace //- Combine sourceProc, sourcePatch, sourceFace
sourceProc.setSize(mesh_.nBoundaryFaces()); sourceProc.resize_nocopy(mesh_.nBoundaryFaces());
sourceProc = -1; sourceProc = -1;
sourcePatch.setSize(mesh_.nBoundaryFaces()); sourcePatch.resize_nocopy(mesh_.nBoundaryFaces());
sourcePatch = -1; sourcePatch = -1;
sourceFace.setSize(mesh_.nBoundaryFaces()); sourceFace.resize_nocopy(mesh_.nBoundaryFaces());
sourceFace = -1; sourceFace = -1;
sourceNewNbrProc.setSize(mesh_.nBoundaryFaces()); sourceNewNbrProc.resize_nocopy(mesh_.nBoundaryFaces());
sourceNewNbrProc = -1; sourceNewNbrProc = -1;
sourcePointMaster.setSize(mesh_.nPoints()); sourcePointMaster.resize_nocopy(mesh_.nPoints());
sourcePointMaster = -1; sourcePointMaster = -1;
if (mesh_.nPoints() > 0) if (mesh_.nPoints() > 0)

View File

@ -402,7 +402,7 @@ public:
static void printFieldInfo(const fvMesh&); static void printFieldInfo(const fvMesh&);
//- Print some info on mesh. //- Print some info on mesh.
static void printMeshInfo(const fvMesh&); static void printMeshInfo(const polyMesh&);
//- Generate a test field on faces //- Generate a test field on faces
static tmp<surfaceScalarField> generateTestField(const fvMesh&); static tmp<surfaceScalarField> generateTestField(const fvMesh&);

View File

@ -142,9 +142,11 @@ void Foam::fvPatchMapper::calcAddressing() const
else else
{ {
// Need to recalculate weights to exclude hits into internal // Need to recalculate weights to exclude hits into internal
labelList newAddr(curAddr.size(), false); labelList newAddr(curAddr.size());
scalarField newWeights(curAddr.size()); scalarField newWeights(curAddr.size());
label nActive = 0; label nActive = 0;
scalar sumWeight = 0;
forAll(curAddr, lfI) forAll(curAddr, lfI)
{ {
@ -156,17 +158,19 @@ void Foam::fvPatchMapper::calcAddressing() const
{ {
newAddr[nActive] = curAddr[lfI] - oldPatchStart; newAddr[nActive] = curAddr[lfI] - oldPatchStart;
newWeights[nActive] = curW[lfI]; newWeights[nActive] = curW[lfI];
nActive++;
sumWeight += curW[lfI];
++nActive;
} }
} }
newAddr.setSize(nActive); newAddr.resize(nActive);
newWeights.setSize(nActive); newWeights.resize(nActive);
// Re-scale the weights // Re-scale the weights
if (nActive > 0) if (nActive > 0)
{ {
newWeights /= sum(newWeights); newWeights /= sumWeight;
} }
else else
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -87,31 +87,27 @@ Foam::functionObjects::fieldCoordinateSystemTransform::transformFieldName
const Foam::surfaceTensorField& const Foam::surfaceTensorField&
Foam::functionObjects::fieldCoordinateSystemTransform::srotTensor() const Foam::functionObjects::fieldCoordinateSystemTransform::srotTensor() const
{ {
typedef surfaceTensorField FieldType;
typedef surfaceTensorField::Boundary BoundaryType; typedef surfaceTensorField::Boundary BoundaryType;
if (!rotTensorSurface_) if (!rotTensorSurface_)
{ {
tensorField rotations(csysPtr_->R(mesh_.faceCentres())); tensorField rotations(csysPtr_->R(mesh_.faceCentres()));
rotTensorSurface_.reset rotTensorSurface_.emplace
(
new FieldType
( (
IOobject IOobject
( (
"surfRotation", "surfRotation",
mesh_.objectRegistry::instance(), mesh_.objectRegistry::instance(),
mesh_.objectRegistry::db(), mesh_.objectRegistry::db(),
IOobject::NO_READ, IOobjectOption::NO_READ,
IOobject::NO_WRITE, IOobjectOption::NO_WRITE,
IOobject::NO_REGISTER IOobjectOption::NO_REGISTER
), ),
mesh_, mesh_,
dimless, dimless,
std::move(rotations) std::move(rotations)
// calculatedType // calculatedType
)
); );
auto& rot = *rotTensorSurface_; auto& rot = *rotTensorSurface_;
@ -132,31 +128,27 @@ Foam::functionObjects::fieldCoordinateSystemTransform::srotTensor() const
const Foam::volTensorField& const Foam::volTensorField&
Foam::functionObjects::fieldCoordinateSystemTransform::vrotTensor() const Foam::functionObjects::fieldCoordinateSystemTransform::vrotTensor() const
{ {
typedef volTensorField FieldType;
typedef volTensorField::Boundary BoundaryType; typedef volTensorField::Boundary BoundaryType;
if (!rotTensorVolume_) if (!rotTensorVolume_)
{ {
tensorField rotations(csysPtr_->R(mesh_.cellCentres())); tensorField rotations(csysPtr_->R(mesh_.cellCentres()));
rotTensorVolume_.reset rotTensorVolume_.emplace
(
new FieldType
( (
IOobject IOobject
( (
"volRotation", "volRotation",
mesh_.objectRegistry::instance(), mesh_.objectRegistry::instance(),
mesh_.objectRegistry::db(), mesh_.objectRegistry::db(),
IOobject::NO_READ, IOobjectOption::NO_READ,
IOobject::NO_WRITE, IOobjectOption::NO_WRITE,
IOobject::NO_REGISTER IOobjectOption::NO_REGISTER
), ),
mesh_, mesh_,
dimless, dimless,
std::move(rotations) std::move(rotations)
// calculatedType // calculatedType
)
); );
auto& rot = *rotTensorVolume_; auto& rot = *rotTensorVolume_;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -85,29 +85,30 @@ void Foam::areaWrite::performAction
Info<< "write: " << fieldName << endl; Info<< "write: " << fieldName << endl;
} }
refPtr<GeoField> tfield;
if (loadFromFiles_) if (loadFromFiles_)
{ {
const GeoField fld tfield.emplace
( (
IOobject IOobject
( (
fieldName, fieldName,
time_.timeName(), time_.timeName(),
areaMesh.thisDb(), areaMesh.thisDb(),
IOobject::MUST_READ IOobjectOption::MUST_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::NO_REGISTER
), ),
areaMesh areaMesh
); );
writeSurface(writer, &fld, fieldName);
} }
else else
{ {
const auto* fieldPtr = tfield.cref(areaMesh.thisDb().cfindObject<GeoField>(fieldName));
areaMesh.thisDb().cfindObject<GeoField>(fieldName);
writeSurface(writer, fieldPtr, fieldName);
} }
writeSurface(writer, tfield.get(), fieldName);
} }
} }

View File

@ -2377,13 +2377,12 @@ Foam::label Foam::meshRefinement::appendPatch
const_cast<polyBoundaryMesh&>(mesh.boundaryMesh()); const_cast<polyBoundaryMesh&>(mesh.boundaryMesh());
fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh.boundary()); fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh.boundary());
label patchi = polyPatches.size(); // The new location (at the end)
const label patchi = polyPatches.size();
// Add polyPatch at the end // Add polyPatch at the end
polyPatches.setSize(patchi+1); polyPatches.push_back
polyPatches.set
( (
patchi,
polyPatch::New polyPatch::New
( (
patchName, patchName,
@ -2392,10 +2391,9 @@ Foam::label Foam::meshRefinement::appendPatch
polyPatches polyPatches
) )
); );
fvPatches.setSize(patchi+1);
fvPatches.set fvPatches.push_back
( (
patchi,
fvPatch::New fvPatch::New
( (
polyPatches[patchi], // point to newly added polyPatch polyPatches[patchi], // point to newly added polyPatch
@ -2678,17 +2676,12 @@ Foam::label Foam::meshRefinement::addPointZone(const word& name)
{ {
zoneI = pointZones.size(); zoneI = pointZones.size();
pointZones.clearAddressing(); pointZones.clearAddressing();
pointZones.setSize(zoneI+1);
pointZones.set pointZones.emplace_back
(
zoneI,
new pointZone
( (
name, // name name, // name
labelList(0), // addressing
zoneI, // index zoneI, // index
pointZones // pointZoneMesh pointZones // pointZoneMesh
)
); );
} }
return zoneI; return zoneI;

View File

@ -1526,18 +1526,12 @@ void Foam::meshRefinement::selectIntersectedFaces
// if (zonei == -1) // if (zonei == -1)
// { // {
// zonei = faceZones.size(); // zonei = faceZones.size();
// faceZones.setSize(zonei+1); //
// faceZones.set // faceZones.emplace_back
// (
// zonei,
// new faceZone
// ( // (
// "frozenFaces", // name // "frozenFaces", // name
// labelList(0), // addressing
// boolList(0), // flip
// zonei, // index // zonei, // index
// faceZones // faceZoneMesh // faceZones
// )
// ); // );
// } // }
// //
@ -1653,17 +1647,13 @@ void Foam::meshRefinement::selectIntersectedFaces
// // if (zonei == -1) // // if (zonei == -1)
// // { // // {
// // zonei = pointZones.size(); // // zonei = pointZones.size();
// // pointZones.setSize(zonei+1); // //
// // pointZones.set // // pointZones.emplace_back
// // (
// // zonei,
// // new pointZone
// // ( // // (
// // "frozenPoints", // name // // "frozenPoints", // name
// // isFrozenPoint.sortedToc(), // addressing // // isFrozenPoint.sortedToc(), // addressing
// // zonei, // index // // zonei, // index
// // pointZones // pointZoneMesh // // pointZones // pointZoneMesh
// // )
// // ); // // );
// // } // // }
// //} // //}

View File

@ -432,25 +432,22 @@ Foam::label Foam::surfaceZonesInfo::addCellZone
{ {
cellZoneMesh& cellZones = mesh.cellZones(); cellZoneMesh& cellZones = mesh.cellZones();
label zoneI = cellZones.findZoneID(name); label zoneID = cellZones.findZoneID(name);
if (zoneI == -1) if (zoneID == -1)
{ {
zoneI = cellZones.size(); zoneID = cellZones.size();
cellZones.setSize(zoneI+1);
cellZones.set cellZones.emplace_back
( (
zoneI, name,
new cellZone addressing,
( zoneID,
name, // name cellZones
addressing, // addressing
zoneI, // index
cellZones // cellZoneMesh
)
); );
} }
return zoneI;
return zoneID;
} }
@ -474,7 +471,7 @@ Foam::labelList Foam::surfaceZonesInfo::addCellZonesToMesh
label zoneI = addCellZone label zoneI = addCellZone
( (
cellZoneName, cellZoneName,
labelList(0), // addressing labelList(), // addressing
mesh mesh
); );
@ -515,24 +512,19 @@ Foam::label Foam::surfaceZonesInfo::addFaceZone
{ {
faceZoneMesh& faceZones = mesh.faceZones(); faceZoneMesh& faceZones = mesh.faceZones();
label zoneI = faceZones.findZoneID(name); label zoneID = faceZones.findZoneID(name);
if (zoneI == -1) if (zoneID == -1)
{ {
zoneI = faceZones.size(); zoneID = faceZones.size();
faceZones.setSize(zoneI+1);
faceZones.set faceZones.emplace_back
( (
zoneI, name,
new faceZone addressing,
( flipMap,
name, // name zoneID,
addressing, // addressing faceZones
flipMap, // flipMap
zoneI, // index
faceZones // faceZoneMesh
)
); );
} }
// else // else
@ -604,7 +596,8 @@ Foam::label Foam::surfaceZonesInfo::addFaceZone
// } // }
// } // }
// } // }
return zoneI;
return zoneID;
} }
@ -633,8 +626,8 @@ Foam::labelListList Foam::surfaceZonesInfo::addFaceZonesToMesh
label zoneI = addFaceZone label zoneI = addFaceZone
( (
faceZoneName, //name faceZoneName, //name
labelList(0), //addressing labelList(), //addressing
boolList(0), //flipmap boolList(), //flipmap
mesh mesh
); );

View File

@ -246,17 +246,12 @@ bool Foam::cellZoneSet::writeObject
{ {
zoneID = cellZones.size(); zoneID = cellZones.size();
cellZones.setSize(zoneID+1); cellZones.emplace_back
cellZones.set
(
zoneID,
new cellZone
( (
name(), name(),
addressing_, addressing_,
zoneID, zoneID,
cellZones cellZones
)
); );
} }
else else

View File

@ -462,18 +462,13 @@ bool Foam::faceZoneSet::writeObject
{ {
zoneID = faceZones.size(); zoneID = faceZones.size();
faceZones.setSize(zoneID+1); faceZones.emplace_back
faceZones.set
(
zoneID,
new faceZone
( (
name(), name(),
addressing_, addressing_,
flipMap_, flipMap_,
zoneID, zoneID,
faceZones faceZones
)
); );
} }
else else

View File

@ -246,17 +246,12 @@ bool Foam::pointZoneSet::writeObject
{ {
zoneID = pointZones.size(); zoneID = pointZones.size();
pointZones.setSize(zoneID+1); pointZones.emplace_back
pointZones.set
(
zoneID,
new pointZone
( (
name(), name(),
addressing_, addressing_,
zoneID, zoneID,
pointZones pointZones
)
); );
} }
else else

View File

@ -45,18 +45,12 @@ void Foam::lagrangianFieldDecomposer::readFields
lagrangianObjects.sorted<IOField<Type>>() lagrangianObjects.sorted<IOField<Type>>()
); );
lagrangianFields.set auto& cloudFields =
( lagrangianFields.emplace_set(cloudi, fieldObjects.size());
cloudi,
new PtrList<IOField<Type>>(fieldObjects.size())
);
forAll(fieldObjects, fieldi)
label fieldi = 0;
for (const IOobject& io : fieldObjects)
{ {
lagrangianFields[cloudi].set(fieldi++, new IOField<Type>(io)); cloudFields.emplace_set(fieldi, fieldObjects[fieldi]);
} }
} }
@ -70,14 +64,12 @@ void Foam::lagrangianFieldDecomposer::readFieldFields
) )
{ {
// List of lagrangian field objects // List of lagrangian field objects
UPtrList<const IOobject> fieldObjects; UPtrList<const IOobject> fieldObjects
fieldObjects.append
( (
lagrangianObjects.sorted<IOField<Field<Type>>>() lagrangianObjects.sorted<IOField<Field<Type>>>()
); );
fieldObjects.append fieldObjects.push_back
( (
lagrangianObjects.sorted<CompactIOField<Field<Type>, Type>>() lagrangianObjects.sorted<CompactIOField<Field<Type>, Type>>()
); );
@ -85,22 +77,12 @@ void Foam::lagrangianFieldDecomposer::readFieldFields
Foam::sort(fieldObjects, nameOp<IOobject>()); Foam::sort(fieldObjects, nameOp<IOobject>());
lagrangianFields.set auto& cloudFields =
( lagrangianFields.emplace_set(cloudi, fieldObjects.size());
cloudi,
new PtrList<CompactIOField<Field<Type>, Type>>(fieldObjects.size())
);
forAll(fieldObjects, fieldi)
label fieldi = 0;
for (const IOobject& io : fieldObjects)
{ {
lagrangianFields[cloudi].set cloudFields.emplace_set(fieldi, fieldObjects[fieldi]);
(
fieldi++,
new CompactIOField<Field<Type>, Type>(io)
);
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
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.
@ -34,9 +34,20 @@ License
void Foam::processorFaMeshes::read() void Foam::processorFaMeshes::read()
{ {
// Make sure to clear (and hence unregister) any previously loaded meshes
// and fields
boundaryProcAddressing_.free();
faceProcAddressing_.free();
edgeProcAddressing_.free();
pointProcAddressing_.free();
meshes_.free();
forAll(fvMeshes_, proci) forAll(fvMeshes_, proci)
{ {
meshes_.set(proci, new faMesh(fvMeshes_[proci])); // Construct from polyMesh IO information
meshes_.emplace_set(proci, fvMeshes_[proci]);
// Read the addressing information // Read the addressing information
@ -46,8 +57,8 @@ void Foam::processorFaMeshes::read()
"constant", // Placeholder "constant", // Placeholder
faMesh::meshSubDir, faMesh::meshSubDir,
meshes_[proci].thisDb(), meshes_[proci].thisDb(),
IOobject::MUST_READ, IOobjectOption::MUST_READ,
IOobject::NO_WRITE IOobjectOption::NO_WRITE
); );
const auto& runTime = meshes_[proci].thisDb().time(); const auto& runTime = meshes_[proci].thisDb().time();
@ -56,22 +67,22 @@ void Foam::processorFaMeshes::read()
// pointProcAddressing (faMesh) // pointProcAddressing (faMesh)
ioAddr.rename("pointProcAddressing"); ioAddr.rename("pointProcAddressing");
ioAddr.instance() = runTime.findInstance(meshDir, ioAddr.name()); ioAddr.instance() = runTime.findInstance(meshDir, ioAddr.name());
pointProcAddressing_.set(proci, new labelIOList(ioAddr)); pointProcAddressing_.emplace_set(proci, ioAddr);
// edgeProcAddressing (faMesh) // edgeProcAddressing (faMesh)
ioAddr.rename("edgeProcAddressing"); ioAddr.rename("edgeProcAddressing");
ioAddr.instance() = runTime.findInstance(meshDir, ioAddr.name()); ioAddr.instance() = runTime.findInstance(meshDir, ioAddr.name());
edgeProcAddressing_.set(proci, new labelIOList(ioAddr)); edgeProcAddressing_.emplace_set(proci, ioAddr);
// faceProcAddressing (faMesh) // faceProcAddressing (faMesh)
ioAddr.rename("faceProcAddressing"); ioAddr.rename("faceProcAddressing");
ioAddr.instance() = runTime.findInstance(meshDir, ioAddr.name()); ioAddr.instance() = runTime.findInstance(meshDir, ioAddr.name());
faceProcAddressing_.set(proci, new labelIOList(ioAddr)); faceProcAddressing_.emplace_set(proci, ioAddr);
// boundaryProcAddressing (faMesh) // boundaryProcAddressing (faMesh)
ioAddr.rename("boundaryProcAddressing"); ioAddr.rename("boundaryProcAddressing");
ioAddr.instance() = runTime.findInstance(meshDir, ioAddr.name()); ioAddr.instance() = runTime.findInstance(meshDir, ioAddr.name());
boundaryProcAddressing_.set(proci, new labelIOList(ioAddr)); boundaryProcAddressing_.emplace_set(proci, ioAddr);
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -46,29 +46,23 @@ void Foam::processorMeshes::read()
{ {
// Make sure to clear (and hence unregister) any previously loaded meshes // Make sure to clear (and hence unregister) any previously loaded meshes
// and fields // and fields
forAll(databases_, proci) boundaryProcAddressing_.free();
{ cellProcAddressing_.free();
boundaryProcAddressing_.set(proci, nullptr); faceProcAddressing_.free();
cellProcAddressing_.set(proci, nullptr); pointProcAddressing_.free();
faceProcAddressing_.set(proci, nullptr); meshes_.free();
pointProcAddressing_.set(proci, nullptr);
meshes_.set(proci, nullptr);
}
forAll(databases_, proci) forAll(databases_, proci)
{ {
meshes_.set meshes_.emplace_set
( (
proci, proci,
new fvMesh
(
IOobject IOobject
( (
meshName_, meshName_,
databases_[proci].timeName(), databases_[proci].timeName(),
databases_[proci] databases_[proci]
) )
)
); );
// Read the addressing information // Read the addressing information
@ -79,25 +73,25 @@ void Foam::processorMeshes::read()
meshes_[proci].facesInstance(), meshes_[proci].facesInstance(),
polyMesh::meshSubDir, polyMesh::meshSubDir,
meshes_[proci].thisDb(), meshes_[proci].thisDb(),
IOobject::MUST_READ, IOobjectOption::MUST_READ,
IOobject::NO_WRITE IOobjectOption::NO_WRITE
); );
// pointProcAddressing (polyMesh) // pointProcAddressing (polyMesh)
ioAddr.rename("pointProcAddressing"); ioAddr.rename("pointProcAddressing");
pointProcAddressing_.set(proci, new labelIOList(ioAddr)); pointProcAddressing_.emplace_set(proci, ioAddr);
// faceProcAddressing (polyMesh) // faceProcAddressing (polyMesh)
ioAddr.rename("faceProcAddressing"); ioAddr.rename("faceProcAddressing");
faceProcAddressing_.set(proci, new labelIOList(ioAddr)); faceProcAddressing_.emplace_set(proci, ioAddr);
// cellProcAddressing (polyMesh) // cellProcAddressing (polyMesh)
ioAddr.rename("cellProcAddressing"); ioAddr.rename("cellProcAddressing");
cellProcAddressing_.set(proci, new labelIOList(ioAddr)); cellProcAddressing_.emplace_set(proci, ioAddr);
// boundaryProcAddressing (polyMesh) // boundaryProcAddressing (polyMesh)
ioAddr.rename("boundaryProcAddressing"); ioAddr.rename("boundaryProcAddressing");
boundaryProcAddressing_.set(proci, new labelIOList(ioAddr)); boundaryProcAddressing_.emplace_set(proci, ioAddr);
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
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.
@ -72,26 +72,22 @@ Foam::probes::getOrLoadField(const word& fieldName) const
if (loadFromFiles_) if (loadFromFiles_)
{ {
tfield.reset tfield.emplace
(
new GeoField
( (
IOobject IOobject
( (
fieldName, fieldName,
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_.thisDb(),
IOobject::MUST_READ, IOobjectOption::MUST_READ,
IOobject::NO_WRITE, IOobjectOption::NO_WRITE,
IOobject::NO_REGISTER IOobjectOption::NO_REGISTER
), ),
mesh_ mesh_
)
); );
} }
else else
{ {
// Slightly paranoid here
tfield.cref(mesh_.cfindObject<GeoField>(fieldName)); tfield.cref(mesh_.cfindObject<GeoField>(fieldName));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 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.
@ -42,26 +42,22 @@ Foam::sampledSets::getOrLoadField(const word& fieldName) const
if (loadFromFiles_) if (loadFromFiles_)
{ {
tfield.reset tfield.emplace
(
new GeoField
( (
IOobject IOobject
( (
fieldName, fieldName,
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_.thisDb(),
IOobject::MUST_READ, IOobjectOption::MUST_READ,
IOobject::NO_WRITE, IOobjectOption::NO_WRITE,
IOobject::NO_REGISTER IOobjectOption::NO_REGISTER
), ),
mesh_ mesh_
)
); );
} }
else else
{ {
// Slightly paranoid here
tfield.cref(mesh_.cfindObject<GeoField>(fieldName)); tfield.cref(mesh_.cfindObject<GeoField>(fieldName));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 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.
@ -220,29 +220,32 @@ void Foam::sampledSurfaces::performAction
Info<< "sampleWrite: " << fieldName << endl; Info<< "sampleWrite: " << fieldName << endl;
} }
refPtr<GeoField> tfield;
if (loadFromFiles_) if (loadFromFiles_)
{ {
const GeoField fld tfield.emplace
( (
IOobject IOobject
( (
fieldName, fieldName,
time_.timeName(), time_.timeName(),
mesh_, mesh_.thisDb(),
IOobject::MUST_READ IOobjectOption::MUST_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::NO_REGISTER
), ),
mesh_ mesh_
); );
performAction(fld, request);
} }
else else
{ {
performAction tfield.cref(mesh_.thisDb().cfindObject<GeoField>(fieldName));
( }
mesh_.thisDb().lookupObject<GeoField>(fieldName),
request if (tfield)
); {
performAction(tfield(), request);
} }
} }
} }

View File

@ -946,9 +946,9 @@ void Foam::isoSurfaceCell::calcAddressing
// Determine edgeFaces // Determine edgeFaces
edgeFace0.resize(nUnique); edgeFace0.resize_nocopy(nUnique);
edgeFace0 = -1; edgeFace0 = -1;
edgeFace1.resize(nUnique); edgeFace1.resize_nocopy(nUnique);
edgeFace1 = -1; edgeFace1 = -1;
edgeFacesRest.clear(); edgeFacesRest.clear();
@ -972,19 +972,8 @@ void Foam::isoSurfaceCell::calcAddressing
// << " used by more than two triangles: " << edgeFace0[edgeI] // << " used by more than two triangles: " << edgeFace0[edgeI]
// << ", " // << ", "
// << edgeFace1[edgeI] << " and " << triI << endl; // << edgeFace1[edgeI] << " and " << triI << endl;
Map<labelList>::iterator iter = edgeFacesRest.find(edgeI);
if (iter != edgeFacesRest.end()) edgeFacesRest(edgeI).push_back(triI);
{
labelList& eFaces = iter();
label sz = eFaces.size();
eFaces.setSize(sz+1);
eFaces[sz] = triI;
}
else
{
edgeFacesRest.insert(edgeI, labelList(1, triI));
}
} }
} }
} }

View File

@ -1406,9 +1406,9 @@ Foam::isoSurfacePoint::isoSurfacePoint
); );
// Clear old value. Cannot resize it since is a slice. // Clear old value. Cannot resize it since is a slice.
bfld.set(patchi, nullptr);
// Set new value we can change // Set new value we can change
bfld.release(patchi);
bfld.set bfld.set
( (
patchi, patchi,

View File

@ -75,9 +75,9 @@ Foam::isoSurfacePoint::adaptPatchFields
) )
{ {
// Clear old value. Cannot resize it since is a slice. // Clear old value. Cannot resize it since is a slice.
sliceFldBf.set(patchi, nullptr);
// Set new value we can change // Set new value we can change
sliceFldBf.release(patchi);
sliceFldBf.set sliceFldBf.set
( (
patchi, patchi,