diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 663a3f64f6..dd19738246 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -704,13 +704,19 @@ int main(int argc, char *argv[]) << " for particle with index " << iter().index() << " at position " - << iter().position() << nl + << iter().position(meshes.completeMesh()) + << nl << "Cell number should be between 0 and " << meshes.completeMesh().nCells()-1 << nl << "On this mesh the particle should" << " be in cell " << meshes.completeMesh().findCell - (iter().position()) + ( + iter().position + ( + meshes.completeMesh() + ) + ) << exit(FatalError); } diff --git a/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C b/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C index 7648484fc8..97ee475d74 100644 --- a/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C +++ b/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -88,7 +88,7 @@ Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer ppi.coordinates(), procCelli, mappedTetFace, - ppi.procTetPt(procMesh, procCelli, mappedTetFace) + ppi.procTetPt(mesh, procMesh, procCelli, mappedTetFace) ) ); } diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructLagrangianPositions.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructLagrangianPositions.C index a6fae4e05d..283aba65e4 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructLagrangianPositions.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructLagrangianPositions.C @@ -70,7 +70,7 @@ void Foam::reconstructLagrangianPositions ppi.coordinates(), mappedCell, mappedTetFace, - ppi.procTetPt(mesh, mappedCell, mappedTetFace) + ppi.procTetPt(meshes[i], mesh, mappedCell, mappedTetFace) ) ); } diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightParticlePositions.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightParticlePositions.C index 62069b9aed..01fe82de71 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightParticlePositions.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightParticlePositions.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -84,7 +84,7 @@ void ensightParticlePositions // Output positions forAllConstIter(Cloud, parcels, elmnt) { - const vector& p = elmnt().position(); + const vector& p = elmnt().position(mesh); ensightFile << setw(8) << ++nParcels diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputFunctions.C b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputFunctions.C index f7560dff54..09a35f4c55 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputFunctions.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputFunctions.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -123,7 +123,7 @@ void Foam::ensightParticlePositions forAllConstIter(Cloud, parcels, elmnt) { - const vector& p = elmnt().position(); + const vector& p = elmnt().position(mesh); os.write(p.x()); os.write(p.y()); @@ -136,7 +136,7 @@ void Foam::ensightParticlePositions forAllConstIter(Cloud, parcels, elmnt) { - const vector& p = elmnt().position(); + const vector& p = elmnt().position(mesh); os.write(++nParcels, 8); // unusual width os.write(p.x()); diff --git a/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutputLagrangian.H b/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutputLagrangian.H index 3d7c4827a0..1c59c6ca39 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutputLagrangian.H +++ b/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutputLagrangian.H @@ -1,21 +1,23 @@ gmvFile << "tracers " << particles.size() << nl; -forAllConstIter(Cloud, particles, iter) -{ - gmvFile << iter().position().x() << ' '; -} -gmvFile << nl; -forAllConstIter(Cloud, particles, iter) { - gmvFile << iter().position().y() << ' '; -} -gmvFile << nl; + pointField positions(particles.size()); -forAllConstIter(Cloud, particles, iter) -{ - gmvFile << iter().position().z() << ' '; + label particlei = 0; + forAllConstIter(Cloud, particles, iter) + { + positions[particlei ++] = iter().position(mesh); + } + + for (i = 0; i < pTraits::nComponents; i ++) + { + forAll(positions, particlei) + { + gmvFile << component(positions[particlei], i) << ' '; + } + gmvFile << nl; + } } -gmvFile << nl; forAll(lagrangianScalarNames, i) { @@ -44,8 +46,6 @@ forAll(lagrangianScalarNames, i) } gmvFile << nl; } - - } forAll(lagrangianVectorNames, i) diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriter.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriter.C index 832bd17973..eaa7ede9f9 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriter.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -70,7 +70,7 @@ Foam::lagrangianWriter::lagrangianWriter DynamicList partField(3*parcels.size()); forAllConstIter(Cloud, parcels, elmnt) { - vtkWriteOps::insert(elmnt().position(), partField); + vtkWriteOps::insert(elmnt().position(mesh), partField); } vtkWriteOps::write(os_, binary_, partField); diff --git a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamMeshLagrangian.C b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamMeshLagrangian.C index fd31bbbfaf..205e4f63c4 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamMeshLagrangian.C +++ b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamMeshLagrangian.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -84,7 +84,7 @@ vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh vtkIdType particleId = 0; forAllConstIter(Cloud, parcels, iter) { - vtkInsertNextOpenFOAMPoint(vtkpoints, iter().position()); + vtkInsertNextOpenFOAMPoint(vtkpoints, iter().position(mesh)); vtkcells->InsertNextCell(1, &particleId); particleId++; diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_part_coords.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_part_coords.H index 9cc17a1ec6..e35d72cc10 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_part_coords.H +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_part_coords.H @@ -44,9 +44,10 @@ int USERD_get_part_coords forAllConstIter(Cloud, *sprayPtr, iter) { - coord_array[0][indx] = float(iter().position().x()); - coord_array[1][indx] = float(iter().position().y()); - coord_array[2][indx] = float(iter().position().z()); + const point p = iter().position(*meshPtr); + coord_array[0][indx] = float(p.x()); + coord_array[1][indx] = float(p.y()); + coord_array[2][indx] = float(p.z()); indx++; } diff --git a/applications/utilities/postProcessing/lagrangian/particleTracks/particleTracks.C b/applications/utilities/postProcessing/lagrangian/particleTracks/particleTracks.C index bd15d013fb..10c97c9043 100644 --- a/applications/utilities/postProcessing/lagrangian/particleTracks/particleTracks.C +++ b/applications/utilities/postProcessing/lagrangian/particleTracks/particleTracks.C @@ -159,7 +159,7 @@ int main(int argc, char *argv[]) label i = 0; forAllConstIter(passiveParticleCloud, myCloud, iter) { - allPositions[Pstream::myProcNo()][i] = iter().position(); + allPositions[Pstream::myProcNo()][i] = iter().position(mesh); allOrigIds[Pstream::myProcNo()][i] = iter().origId(); allOrigProcs[Pstream::myProcNo()][i] = iter().origProc(); i++; diff --git a/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C b/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C index 0c6dd08c4c..ba29f0e389 100644 --- a/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C +++ b/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -279,7 +279,8 @@ int main(int argc, char *argv[]) forAll(ids, j) { const label localId = particleIds[j]; - const vector& pos = particles[localId].position(); + const vector pos = + particles[localId].position(mesh); os << pos.x() << ' ' << pos.y() << ' ' << pos.z() << nl; } diff --git a/applications/utilities/preProcessing/mapFields/mapLagrangian.C b/applications/utilities/preProcessing/mapFields/mapLagrangian.C index 6c14aaa72c..82ca57a055 100644 --- a/applications/utilities/preProcessing/mapFields/mapLagrangian.C +++ b/applications/utilities/preProcessing/mapFields/mapLagrangian.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -189,7 +189,13 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp) ); passiveParticle& newP = newPtr(); - newP.track(iter().position() - newP.position(), 0); + newP.track + ( + meshTarget, + iter().position(meshSource) + - newP.position(meshTarget), + 0 + ); if (!newP.onFace()) { @@ -228,7 +234,11 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp) if (unmappedSource.found(sourceParticleI)) { label targetCell = - findCell(targetParcels, iter().position()); + findCell + ( + targetParcels, + iter().position(meshSource) + ); if (targetCell >= 0) { @@ -239,7 +249,7 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp) new passiveParticle ( meshTarget, - iter().position(), + iter().position(meshSource), targetCell ) ); diff --git a/applications/utilities/preProcessing/mapFieldsPar/mapLagrangian.C b/applications/utilities/preProcessing/mapFieldsPar/mapLagrangian.C index 86e4124160..586dabe268 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/mapLagrangian.C +++ b/applications/utilities/preProcessing/mapFieldsPar/mapLagrangian.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -178,7 +178,13 @@ void mapLagrangian(const meshToMesh& interp) ); passiveParticle& newP = newPtr(); - newP.track(iter().position() - newP.position(), 0); + newP.track + ( + meshTarget, + iter().position(meshSource) + - newP.position(meshTarget), + 0 + ); if (!newP.onFace()) { @@ -217,7 +223,11 @@ void mapLagrangian(const meshToMesh& interp) if (unmappedSource.found(sourceParticleI)) { label targetCell = - findCell(targetParcels, iter().position()); + findCell + ( + targetParcels, + iter().position(meshSource) + ); if (targetCell >= 0) { @@ -228,7 +238,7 @@ void mapLagrangian(const meshToMesh& interp) new passiveParticle ( meshTarget, - iter().position(), + iter().position(meshSource), targetCell ) ); diff --git a/src/functionObjects/field/nearWallFields/findCellParticle.C b/src/functionObjects/field/nearWallFields/findCellParticle.C index 89f9e7965c..bc5083afc6 100644 --- a/src/functionObjects/field/nearWallFields/findCellParticle.C +++ b/src/functionObjects/field/nearWallFields/findCellParticle.C @@ -59,14 +59,9 @@ Foam::findCellParticle::findCellParticle {} -Foam::findCellParticle::findCellParticle -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::findCellParticle::findCellParticle(Istream& is, bool readFields) : - particle(mesh, is, readFields) + particle(is, readFields) { if (readFields) { @@ -117,7 +112,7 @@ bool Foam::findCellParticle::move // Hit endpoint or patch. If patch hit could do fancy stuff but just // to use the patch point is good enough for now. td.cellToData()[cell()].append(data()); - td.cellToEnd()[cell()].append(position()); + td.cellToEnd()[cell()].append(position(td.mesh)); } return td.keepParticle; @@ -188,7 +183,10 @@ void Foam::findCellParticle::hitProcessorPatch ) { const processorPolyPatch& ppp = - static_cast(mesh().boundaryMesh()[patch()]); + static_cast + ( + td.mesh.boundaryMesh()[patch(td.mesh)] + ); if (ppp.transform().transforms()) { diff --git a/src/functionObjects/field/nearWallFields/findCellParticle.H b/src/functionObjects/field/nearWallFields/findCellParticle.H index c13dfbb525..e0d07b187a 100644 --- a/src/functionObjects/field/nearWallFields/findCellParticle.H +++ b/src/functionObjects/field/nearWallFields/findCellParticle.H @@ -140,12 +140,7 @@ public: ); //- Construct from Istream - findCellParticle - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); + findCellParticle(Istream& is, bool readFields = true); //- Construct and return a clone autoPtr clone() const @@ -153,27 +148,11 @@ public: return autoPtr(new findCellParticle(*this)); } - //- Factory class to read-construct particles used for - // parallel transfer - class iNew + //- Construct from Istream and return + static autoPtr New(Istream& is) { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr operator()(Istream& is) const - { - return autoPtr - ( - new findCellParticle(mesh_, is, true) - ); - } - }; + return autoPtr(new findCellParticle(is)); + } // Member Functions diff --git a/src/functionObjects/field/nearWallFields/nearWallFields.C b/src/functionObjects/field/nearWallFields/nearWallFields.C index 7d4861e1be..6ad8536fdc 100644 --- a/src/functionObjects/field/nearWallFields/nearWallFields.C +++ b/src/functionObjects/field/nearWallFields/nearWallFields.C @@ -108,7 +108,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing() forAllConstIter(Cloud, cloud, iter) { - const vector p = iter().position(); + const vector p = iter().position(mesh_); str.write(linePointRef(p, p + iter().displacement())); } } @@ -135,7 +135,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing() forAllConstIter(Cloud, cloud, iter) { const findCellParticle& tp = iter(); - start[nPatchFaces++] = tp.position(); + start[nPatchFaces++] = tp.position(mesh_); } } diff --git a/src/functionObjects/field/streamlines/streamlinesParticle.C b/src/functionObjects/field/streamlines/streamlinesParticle.C index be097260f6..edcf23030d 100644 --- a/src/functionObjects/field/streamlines/streamlinesParticle.C +++ b/src/functionObjects/field/streamlines/streamlinesParticle.C @@ -145,14 +145,9 @@ Foam::streamlinesParticle::streamlinesParticle {} -Foam::streamlinesParticle::streamlinesParticle -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::streamlinesParticle::streamlinesParticle(Istream& is, bool readFields) : - particle(mesh, is, readFields) + particle(is, readFields) { if (readFields) { @@ -212,7 +207,7 @@ bool Foam::streamlinesParticle::move td.keepParticle = true; td.sendToProc = -1; - const scalar maxDt = mesh().bounds().mag(); + const scalar maxDt = td.mesh.bounds().mag(); while (td.keepParticle && td.sendToProc == -1 && lifeTime_ > 0) { @@ -229,11 +224,11 @@ bool Foam::streamlinesParticle::move sampledPositions_.append ( td.trackOutside_ - ? transform_.invTransformPosition(position()) - : position() + ? transform_.invTransformPosition(position(td.mesh)) + : position(td.mesh) ); sampledAges_.append(age_); - vector U = interpolateFields(td, position(), cell(), face()); + vector U = interpolateFields(td, position(td.mesh), cell(), face()); if (!td.trackForward_) { @@ -260,7 +255,7 @@ bool Foam::streamlinesParticle::move { // Sub-cycling. Cross the cell in nSubCycle steps. particle copy(*this); - copy.trackToFace(maxDt*U, 1); + copy.trackToFace(td.mesh, maxDt*U, 1); dt *= (copy.stepFraction() - stepFraction())/td.nSubCycle_; } else if (subIter == td.nSubCycle_ - 1) @@ -289,7 +284,7 @@ bool Foam::streamlinesParticle::move if (debug) { Pout<< "streamlinesParticle: Removing stagnant particle:" - << position() << " sampled positions:" + << position(td.mesh) << " sampled positions:" << sampledPositions_.size() << endl; } td.keepParticle = false; @@ -300,17 +295,17 @@ bool Foam::streamlinesParticle::move sampledPositions_.append ( td.trackOutside_ - ? transform_.invTransformPosition(position()) - : position() + ? transform_.invTransformPosition(position(td.mesh)) + : position(td.mesh) ); sampledAges_.append(age_); - interpolateFields(td, position(), cell(), face()); + interpolateFields(td, position(td.mesh), cell(), face()); if (debug) { - Pout<< "streamlinesParticle: Removing particle:" << position() - << " sampled positions:" << sampledPositions_.size() - << endl; + Pout<< "streamlinesParticle: Removing particle:" + << position(td.mesh) << " sampled positions:" + << sampledPositions_.size() << endl; } } @@ -362,7 +357,10 @@ void Foam::streamlinesParticle::hitCyclicPatch ) { const cyclicPolyPatch& cpp = - static_cast(mesh().boundaryMesh()[patch()]); + static_cast + ( + td.mesh.boundaryMesh()[patch(td.mesh)] + ); // End this track if (!td.trackOutside_ && cpp.transform().transformsPosition()) @@ -424,7 +422,10 @@ void Foam::streamlinesParticle::hitProcessorPatch ) { const processorPolyPatch& ppp = - static_cast(mesh().boundaryMesh()[patch()]); + static_cast + ( + td.mesh.boundaryMesh()[patch(td.mesh)] + ); // End this track if (!td.trackOutside_ && ppp.transform().transformsPosition()) diff --git a/src/functionObjects/field/streamlines/streamlinesParticle.H b/src/functionObjects/field/streamlines/streamlinesParticle.H index 7b58cbbc96..e20376881a 100644 --- a/src/functionObjects/field/streamlines/streamlinesParticle.H +++ b/src/functionObjects/field/streamlines/streamlinesParticle.H @@ -205,7 +205,7 @@ public: //- Construct from components streamlinesParticle ( - const polyMesh& c, + const polyMesh& mesh, const vector& position, const label celli, const label lifeTime, @@ -213,12 +213,7 @@ public: ); //- Construct from Istream - streamlinesParticle - ( - const polyMesh& c, - Istream& is, - bool readFields = true - ); + streamlinesParticle(Istream& is, bool readFields = true); //- Construct copy streamlinesParticle(const streamlinesParticle& p); @@ -229,26 +224,11 @@ public: return autoPtr(new streamlinesParticle(*this)); } - //- Factory class to read-construct particles used for parallel transfer - class iNew + //- Construct from Istream and return + static autoPtr New(Istream& is) { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr operator()(Istream& is) const - { - return autoPtr - ( - new streamlinesParticle(mesh_, is, true) - ); - } - }; + return autoPtr(new streamlinesParticle(is)); + } // Member Functions diff --git a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C index 96e906a6c2..45ed7795da 100644 --- a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C +++ b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C @@ -243,7 +243,7 @@ void Foam::DSMCCloud::collisions() forAll(cellParcels, i) { const ParcelType& p = *cellParcels[i]; - vector relPos = p.position() - cC; + vector relPos = p.position(mesh()) - cC; label subCell = pos0(relPos.x()) + 2*pos0(relPos.y()) + 4*pos0(relPos.z()); @@ -1071,12 +1071,9 @@ void Foam::DSMCCloud::dumpParticlePositions() const forAllConstIter(typename DSMCCloud, *this, iter) { - const ParcelType& p = iter(); + const point pos = iter().position(mesh()); - pObj<< "v " << p.position().x() - << " " << p.position().y() - << " " << p.position().z() - << nl; + pObj<< "v " << pos.x() << " " << pos.y() << " " << pos.z() << nl; } pObj.flush(); diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C index 31311935a5..a626f7815b 100644 --- a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C +++ b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C @@ -60,7 +60,7 @@ bool Foam::DSMCParcel::move meshTools::constrainDirection(mesh, mesh.solutionD(), Utracking); // Deviation from the mesh centre for reduced-D cases - const vector d = p.deviationFromMeshCentre(); + const vector d = p.deviationFromMeshCentre(mesh); const scalar f = 1 - p.stepFraction(); p.trackToAndHitFace(f*trackTime*Utracking - d, f, cloud, td); @@ -78,12 +78,12 @@ void Foam::DSMCParcel::hitWallPatch trackingData& ) { - const label wppIndex = this->patch(); + const label wppIndex = this->patch(cloud.pMesh()); const wallPolyPatch& wpp = static_cast ( - this->mesh().boundaryMesh()[wppIndex] + cloud.pMesh().boundaryMesh()[wppIndex] ); const label wppLocalFace = wpp.whichFace(this->face()); diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H index d2f6e6b5b7..8243196ac2 100644 --- a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H +++ b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H @@ -184,12 +184,7 @@ public: ); //- Construct from Istream - DSMCParcel - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); + DSMCParcel(Istream& is, bool readFields = true); //- Construct and return a clone virtual autoPtr clone() const @@ -197,27 +192,11 @@ public: return autoPtr(new DSMCParcel(*this)); } - //- Factory class to read-construct particles used for - // parallel transfer - class iNew + //- Construct from Istream and return + static autoPtr New(Istream& is) { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr> operator()(Istream& is) const - { - return autoPtr> - ( - new DSMCParcel(mesh_, is, true) - ); - } - }; + return autoPtr(new DSMCParcel(is)); + } // Member Functions diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelI.H b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelI.H index 06dadc6eae..c6b0b463ae 100644 --- a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelI.H +++ b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,6 +23,7 @@ License \*---------------------------------------------------------------------------*/ +#include "DSMCParcel.H" #include "mathematicalConstants.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelIO.C b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelIO.C index 73bcf401a5..30ec4d80d6 100644 --- a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelIO.C +++ b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,14 +40,9 @@ const std::size_t Foam::DSMCParcel::sizeofFields_ // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::DSMCParcel::DSMCParcel -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::DSMCParcel::DSMCParcel(Istream& is, bool readFields) : - ParcelType(mesh, is, readFields), + ParcelType(is, readFields), U_(Zero), Ei_(0.0), typeId_(-1) diff --git a/src/lagrangian/DSMC/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.C b/src/lagrangian/DSMC/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.C index a6845a23dd..746e79674e 100644 --- a/src/lagrangian/DSMC/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.C +++ b/src/lagrangian/DSMC/submodels/WallInteractionModel/MaxwellianThermal/MaxwellianThermal.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -56,19 +56,21 @@ void Foam::MaxwellianThermal::correct typename CloudType::parcelType& p ) { + const polyMesh& mesh = this->owner().mesh(); + vector& U = p.U(); scalar& Ei = p.Ei(); label typeId = p.typeId(); - const label wppIndex = p.patch(); + const label wppIndex = p.patch(mesh); - const polyPatch& wpp = p.mesh().boundaryMesh()[wppIndex]; + const polyPatch& wpp = mesh.boundaryMesh()[wppIndex]; label wppLocalFace = wpp.whichFace(p.face()); - const vector nw = p.normal(); + const vector nw = p.normal(mesh); // Normal velocity magnitude scalar U_dot_nw = U & nw; diff --git a/src/lagrangian/DSMC/submodels/WallInteractionModel/MixedDiffuseSpecular/MixedDiffuseSpecular.C b/src/lagrangian/DSMC/submodels/WallInteractionModel/MixedDiffuseSpecular/MixedDiffuseSpecular.C index 8d5bb66f34..ec2850ac95 100644 --- a/src/lagrangian/DSMC/submodels/WallInteractionModel/MixedDiffuseSpecular/MixedDiffuseSpecular.C +++ b/src/lagrangian/DSMC/submodels/WallInteractionModel/MixedDiffuseSpecular/MixedDiffuseSpecular.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,19 +57,21 @@ void Foam::MixedDiffuseSpecular::correct typename CloudType::parcelType& p ) { + const polyMesh& mesh = this->owner().mesh(); + vector& U = p.U(); scalar& Ei = p.Ei(); label typeId = p.typeId(); - const label wppIndex = p.patch(); + const label wppIndex = p.patch(mesh); - const polyPatch& wpp = p.mesh().boundaryMesh()[wppIndex]; + const polyPatch& wpp = mesh.boundaryMesh()[wppIndex]; label wppLocalFace = wpp.whichFace(p.face()); - const vector nw = p.normal(); + const vector nw = p.normal(mesh); // Normal velocity magnitude scalar U_dot_nw = U & nw; diff --git a/src/lagrangian/DSMC/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.C b/src/lagrangian/DSMC/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.C index f5d326c108..ad698911c2 100644 --- a/src/lagrangian/DSMC/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.C +++ b/src/lagrangian/DSMC/submodels/WallInteractionModel/SpecularReflection/SpecularReflection.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -55,9 +55,11 @@ void Foam::SpecularReflection::correct typename CloudType::parcelType& p ) { + const polyMesh& mesh = this->owner().mesh(); + vector& U = p.U(); - const vector nw = p.normal(); + const vector nw = p.normal(mesh); scalar U_dot_nw = U & nw; diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index 95844049bc..115bc14351 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -41,7 +41,7 @@ License template void Foam::Cloud::checkPatches() const { - const polyBoundaryMesh& pbm = polyMesh_.boundaryMesh(); + const polyBoundaryMesh& pbm = pMesh_.boundaryMesh(); bool ok = true; forAll(pbm, patchi) { @@ -165,7 +165,7 @@ Foam::labelListList Foam::Cloud::patchNonConformalCyclicPatches template void Foam::Cloud::storeRays() const { - const polyBoundaryMesh& pbm = polyMesh_.boundaryMesh(); + const polyBoundaryMesh& pbm = pMesh_.boundaryMesh(); forAll(patchNonConformalCyclicPatches_, patchi) { @@ -195,7 +195,7 @@ Foam::Cloud::Cloud : cloud(pMesh, cloudName), IDLList(), - polyMesh_(pMesh), + pMesh_(pMesh), patchNbrProc_(patchNbrProc(pMesh)), patchNbrProcPatch_(patchNbrProcPatch(pMesh)), patchNonConformalCyclicPatches_(patchNonConformalCyclicPatches(pMesh)), @@ -206,8 +206,8 @@ Foam::Cloud::Cloud // Ask for the tetBasePtIs and oldCellCentres to trigger all processors to // build them, otherwise, if some processors have no particles then there // is a comms mismatch. - polyMesh_.tetBasePtIs(); - polyMesh_.oldCellCentres(); + pMesh_.tetBasePtIs(); + pMesh_.oldCellCentres(); if (particles.size()) { @@ -242,8 +242,8 @@ void Foam::Cloud::deleteLostParticles() if (p.cell() == -1) { WarningInFunction - << "deleting lost particle at position " << p.position() - << endl; + << "deleting lost particle at position " + << p.position(pMesh_) << endl; deleteParticle(p); } @@ -313,7 +313,7 @@ void Foam::Cloud::move if (td.sendToProc != -1) { #ifdef FULLDEBUG - if (!Pstream::parRun() || !p.onBoundaryFace()) + if (!Pstream::parRun() || !p.onBoundaryFace(pMesh_)) { FatalErrorInFunction << "Switch processor flag is true when no parallel " @@ -386,11 +386,7 @@ void Foam::Cloud::move const labelList receivePatchIndices(particleStream); - IDLList newParticles - ( - particleStream, - typename ParticleType::iNew(polyMesh_) - ); + IDLList newParticles(particleStream); label i = 0; @@ -426,15 +422,15 @@ void Foam::Cloud::topoChange(const polyTopoChangeMap& map) // Ask for the tetBasePtIs to trigger all processors to build // them, otherwise, if some processors have no particles then // there is a comms mismatch. - polyMesh_.tetBasePtIs(); - polyMesh_.oldCellCentres(); + pMesh_.tetBasePtIs(); + pMesh_.oldCellCentres(); const vectorField& positions = globalPositionsPtr_(); label i = 0; forAllIter(typename Cloud, *this, iter) { - iter().autoMap(positions[i], map); + iter().autoMap(pMesh_, positions[i], map); ++ i; } } @@ -464,9 +460,9 @@ void Foam::Cloud::writePositions() const forAllConstIter(typename Cloud, *this, pIter) { - const ParticleType& p = pIter(); - pObj<< "v " << p.position().x() << " " << p.position().y() << " " - << p.position().z() << nl; + const point& pos = pIter().position(pMesh_); + + pObj<< "v " << pos.x() << " " << pos.y() << " " << pos.z() << nl; } pObj.flush(); @@ -488,7 +484,7 @@ void Foam::Cloud::storeGlobalPositions() const label i = 0; forAllConstIter(typename Cloud, *this, iter) { - positions[i] = iter().position(); + positions[i] = iter().position(pMesh_); ++ i; } } diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H index 04914b4838..cf49d6862e 100644 --- a/src/lagrangian/basic/Cloud/Cloud.H +++ b/src/lagrangian/basic/Cloud/Cloud.H @@ -76,7 +76,7 @@ class Cloud // Private Data //- Reference to the mesh - const polyMesh& polyMesh_; + const polyMesh& pMesh_; //- Map from patch index to the neighbouring processor index const labelList patchNbrProc_; @@ -165,7 +165,7 @@ public: //- Return the polyMesh reference const polyMesh& pMesh() const { - return polyMesh_; + return pMesh_; } //- Map from patch index to the neighbouring processor index diff --git a/src/lagrangian/basic/Cloud/CloudIO.C b/src/lagrangian/basic/Cloud/CloudIO.C index 1658ab64d0..004631c886 100644 --- a/src/lagrangian/basic/Cloud/CloudIO.C +++ b/src/lagrangian/basic/Cloud/CloudIO.C @@ -133,7 +133,7 @@ void Foam::Cloud::initCloud(const bool checkClass) // Ask for the tetBasePtIs to trigger all processors to build // them, otherwise, if some processors have no particles then // there is a comms mismatch. - polyMesh_.tetBasePtIs(); + pMesh_.tetBasePtIs(); } @@ -148,7 +148,7 @@ Foam::Cloud::Cloud ) : cloud(pMesh, cloudName), - polyMesh_(pMesh), + pMesh_(pMesh), patchNbrProc_(patchNbrProc(pMesh)), patchNbrProcPatch_(patchNbrProcPatch(pMesh)), patchNonConformalCyclicPatches_(patchNonConformalCyclicPatches(pMesh)), @@ -156,8 +156,8 @@ Foam::Cloud::Cloud { checkPatches(); - polyMesh_.tetBasePtIs(); - polyMesh_.oldCellCentres(); + pMesh_.tetBasePtIs(); + pMesh_.oldCellCentres(); initCloud(checkClass); } diff --git a/src/lagrangian/basic/IOPosition/IOPosition.C b/src/lagrangian/basic/IOPosition/IOPosition.C index 183a6428d5..214c1e0cf7 100644 --- a/src/lagrangian/basic/IOPosition/IOPosition.C +++ b/src/lagrangian/basic/IOPosition/IOPosition.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -75,8 +75,6 @@ bool Foam::IOPosition::writeData(Ostream& os) const template void Foam::IOPosition::readData(Istream& is, CloudType& c) { - const polyMesh& mesh = c.pMesh(); - token firstToken(is); if (firstToken.isLabel()) @@ -92,7 +90,7 @@ void Foam::IOPosition::readData(Istream& is, CloudType& c) for (label i=0; i::readData(Istream& is, CloudType& c) is.putBack(lastToken); // Read position only - c.append(new typename CloudType::particleType(mesh, is, false)); + c.append(new typename CloudType::particleType(is, false)); is >> lastToken; } } diff --git a/src/lagrangian/basic/InteractionLists/InteractionLists.C b/src/lagrangian/basic/InteractionLists/InteractionLists.C index 2254407e26..83f5a51f21 100644 --- a/src/lagrangian/basic/InteractionLists/InteractionLists.C +++ b/src/lagrangian/basic/InteractionLists/InteractionLists.C @@ -966,7 +966,7 @@ void Foam::InteractionLists::prepareParticleToBeReferred globalTransforms.transformIndex(ciat) ); - particle->prepareForInteractionListReferral(transform); + particle->prepareForInteractionListReferral(mesh_, transform); } @@ -1215,11 +1215,8 @@ void Foam::InteractionLists::receiveReferredData forAll(constructMap, i) { - referredParticles_[constructMap[i]] = IDLList - ( - str, - typename ParticleType::iNew(mesh_) - ); + referredParticles_[constructMap[i]] = + IDLList(str); } } } @@ -1229,7 +1226,11 @@ void Foam::InteractionLists::receiveReferredData IDLList& refCell = referredParticles_[refCelli]; forAllIter(typename IDLList, refCell, iter) { - iter().correctAfterInteractionListReferral(ril_[refCelli][0]); + iter().correctAfterInteractionListReferral + ( + mesh_, + ril_[refCelli][0] + ); } } diff --git a/src/lagrangian/basic/indexedParticle/indexedParticle.H b/src/lagrangian/basic/indexedParticle/indexedParticle.H index cc7dd968bb..b813e1af18 100644 --- a/src/lagrangian/basic/indexedParticle/indexedParticle.H +++ b/src/lagrangian/basic/indexedParticle/indexedParticle.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -77,14 +77,9 @@ public: {} //- Construct from Istream - indexedParticle - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ) + indexedParticle(Istream& is, bool readFields = true) : - particle(mesh, is, readFields) + particle(is, readFields) {} //- Construct as a copy @@ -99,6 +94,12 @@ public: return autoPtr(new indexedParticle(*this)); } + //- Construct from Istream and return + static autoPtr New(Istream& is) + { + return autoPtr(new indexedParticle(is)); + } + // Member Functions diff --git a/src/lagrangian/basic/particle/particle.C b/src/lagrangian/basic/particle/particle.C index 079c3f4658..6627783768 100644 --- a/src/lagrangian/basic/particle/particle.C +++ b/src/lagrangian/basic/particle/particle.C @@ -45,12 +45,13 @@ namespace Foam void Foam::particle::stationaryTetReverseTransform ( + const polyMesh& mesh, vector& centre, scalar& detA, barycentricTensor& T ) const { - barycentricTensor A = stationaryTetTransform(); + barycentricTensor A = stationaryTetTransform(mesh); const vector ab = A.b() - A.a(); const vector ac = A.c() - A.a(); @@ -74,13 +75,14 @@ void Foam::particle::stationaryTetReverseTransform void Foam::particle::movingTetReverseTransform ( + const polyMesh& mesh, const scalar fraction, Pair& centre, FixedList& detA, FixedList& T ) const { - Pair A = movingTetTransform(fraction); + Pair A = movingTetTransform(mesh, fraction); const Pair ab(A[0].b() - A[0].a(), A[1].b() - A[1].a()); const Pair ac(A[0].c() - A[0].a(), A[1].c() - A[1].a()); @@ -151,21 +153,21 @@ void Foam::particle::rotate(const bool reverse) } -void Foam::particle::changeTet(const label tetTriI) +void Foam::particle::changeTet(const polyMesh& mesh, const label tetTriI) { if (debug) { Info << "Particle " << origId() << nl << FUNCTION_NAME << nl << endl; } - const bool isOwner = mesh_.faceOwner()[tetFacei_] == celli_; + const bool isOwner = mesh.faceOwner()[tetFacei_] == celli_; const label firstTetPtI = 1; - const label lastTetPtI = mesh_.faces()[tetFacei_].size() - 2; + const label lastTetPtI = mesh.faces()[tetFacei_].size() - 2; if (tetTriI == 1) { - changeFace(tetTriI); + changeFace(mesh, tetTriI); } else if (tetTriI == 2) { @@ -173,7 +175,7 @@ void Foam::particle::changeTet(const label tetTriI) { if (tetPti_ == lastTetPtI) { - changeFace(tetTriI); + changeFace(mesh, tetTriI); } else { @@ -185,7 +187,7 @@ void Foam::particle::changeTet(const label tetTriI) { if (tetPti_ == firstTetPtI) { - changeFace(tetTriI); + changeFace(mesh, tetTriI); } else { @@ -200,7 +202,7 @@ void Foam::particle::changeTet(const label tetTriI) { if (tetPti_ == firstTetPtI) { - changeFace(tetTriI); + changeFace(mesh, tetTriI); } else { @@ -212,7 +214,7 @@ void Foam::particle::changeTet(const label tetTriI) { if (tetPti_ == lastTetPtI) { - changeFace(tetTriI); + changeFace(mesh, tetTriI); } else { @@ -231,7 +233,7 @@ void Foam::particle::changeTet(const label tetTriI) } -void Foam::particle::changeFace(const label tetTriI) +void Foam::particle::changeFace(const polyMesh& mesh, const label tetTriI) { if (debug) { @@ -239,7 +241,7 @@ void Foam::particle::changeFace(const label tetTriI) } // Get the old topology - const triFace triOldIs(currentTetIndices().faceTriIs(mesh_)); + const triFace triOldIs(currentTetIndices(mesh).faceTriIs(mesh)); // Get the shared edge and the pre-rotation edge sharedEdge; @@ -268,11 +270,11 @@ void Foam::particle::changeFace(const label tetTriI) // Find the face in the same cell that shares the edge, and the // corresponding tetrahedra point tetPti_ = -1; - forAll(mesh_.cells()[celli_], cellFaceI) + forAll(mesh.cells()[celli_], cellFaceI) { - const label newFaceI = mesh_.cells()[celli_][cellFaceI]; - const class face& newFace = mesh_.faces()[newFaceI]; - const label newOwner = mesh_.faceOwner()[newFaceI]; + const label newFaceI = mesh.cells()[celli_][cellFaceI]; + const class face& newFace = mesh.faces()[newFaceI]; + const label newOwner = mesh.faceOwner()[newFaceI]; // Exclude the current face if (tetFacei_ == newFaceI) @@ -298,7 +300,7 @@ void Foam::particle::changeFace(const label tetTriI) } // Make the edge index relative to the base point - const label newBaseI = max(0, mesh_.tetBasePtIs()[newFaceI]); + const label newBaseI = max(0, mesh.tetBasePtIs()[newFaceI]); edgeI = (edgeI - newBaseI + newFace.size()) % newFace.size(); // If the edge is next the base point (i.e., the index is 0 or n - 1), @@ -332,7 +334,7 @@ void Foam::particle::changeFace(const label tetTriI) } // Get the new topology - const triFace triNewIs = currentTetIndices().faceTriIs(mesh_); + const triFace triNewIs = currentTetIndices(mesh).faceTriIs(mesh); // Reflect to account for the change of triangle orientation on the new face reflect(); @@ -349,7 +351,7 @@ void Foam::particle::changeFace(const label tetTriI) } -void Foam::particle::changeCell() +void Foam::particle::changeCell(const polyMesh& mesh) { if (debug) { @@ -357,9 +359,9 @@ void Foam::particle::changeCell() } // Set the cell to be the one on the other side of the face - const label ownerCellI = mesh_.faceOwner()[tetFacei_]; + const label ownerCellI = mesh.faceOwner()[tetFacei_]; const bool isOwner = celli_ == ownerCellI; - celli_ = isOwner ? mesh_.faceNeighbour()[tetFacei_] : ownerCellI; + celli_ = isOwner ? mesh.faceNeighbour()[tetFacei_] : ownerCellI; // Reflect to account for the change of triangle orientation in the new cell reflect(); @@ -368,6 +370,7 @@ void Foam::particle::changeCell() void Foam::particle::locate ( + const polyMesh& mesh, const vector& position, label celli, const bool boundaryFail, @@ -382,7 +385,7 @@ void Foam::particle::locate // Find the cell, if it has not been given if (celli < 0) { - celli = mesh_.cellTree().findInside(position); + celli = mesh.cellTree().findInside(position); } if (celli < 0) { @@ -393,17 +396,17 @@ void Foam::particle::locate celli_ = celli; // Track from the centre of the cell to the desired position - const vector displacement = position - mesh_.cellCentres()[celli_]; + const vector displacement = position - mesh.cellCentres()[celli_]; // Loop all cell tets to find the one containing the position. Track // through each tet from the cell centre. If a tet contains the position // then the track will end with a single trackToTri. - const class cell& c = mesh_.cells()[celli_]; + const class cell& c = mesh.cells()[celli_]; scalar minF = vGreat; label minTetFacei = -1, minTetPti = -1; forAll(c, cellTetFacei) { - const class face& f = mesh_.faces()[c[cellTetFacei]]; + const class face& f = mesh.faces()[c[cellTetFacei]]; for (label tetPti = 1; tetPti < f.size() - 1; ++ tetPti) { coordinates_ = barycentric(1, 0, 0, 0); @@ -413,7 +416,7 @@ void Foam::particle::locate reset(1); label tetTriI = -1; - const scalar f = trackToTri(displacement, 0, tetTriI); + const scalar f = trackToTri(mesh, displacement, 0, tetTriI); if (tetTriI == -1) { @@ -437,7 +440,7 @@ void Foam::particle::locate facei_ = -1; reset(1); - track(displacement, 0); + track(mesh, displacement, 0); if (!onFace()) { return; @@ -479,7 +482,6 @@ Foam::particle::particle const label tetPti ) : - mesh_(mesh), coordinates_(coordinates), celli_(celli), tetFacei_(tetFacei), @@ -500,7 +502,6 @@ Foam::particle::particle const label celli ) : - mesh_(mesh), coordinates_(- vGreat, - vGreat, - vGreat, - vGreat), celli_(celli), tetFacei_(-1), @@ -514,6 +515,7 @@ Foam::particle::particle { locate ( + mesh, position, celli, false, @@ -524,23 +526,6 @@ Foam::particle::particle Foam::particle::particle(const particle& p) : - mesh_(p.mesh_), - coordinates_(p.coordinates_), - celli_(p.celli_), - tetFacei_(p.tetFacei_), - tetPti_(p.tetPti_), - facei_(p.facei_), - stepFraction_(p.stepFraction_), - stepFractionBehind_(p.stepFractionBehind_), - nTracksBehind_(p.nTracksBehind_), - origProc_(p.origProc_), - origId_(p.origId_) -{} - - -Foam::particle::particle(const particle& p, const polyMesh& mesh) -: - mesh_(mesh), coordinates_(p.coordinates_), celli_(p.celli_), tetFacei_(p.tetFacei_), @@ -558,6 +543,7 @@ Foam::particle::particle(const particle& p, const polyMesh& mesh) Foam::scalar Foam::particle::track ( + const polyMesh& mesh, const vector& displacement, const scalar fraction ) @@ -567,13 +553,13 @@ Foam::scalar Foam::particle::track Info << "Particle " << origId() << nl << FUNCTION_NAME << nl << endl; } - scalar f = trackToFace(displacement, fraction); + scalar f = trackToFace(mesh, displacement, fraction); - while (onInternalFace()) + while (onInternalFace(mesh)) { - changeCell(); + changeCell(mesh); - f *= trackToFace(f*displacement, f*fraction); + f *= trackToFace(mesh, f*displacement, f*fraction); } return f; @@ -582,6 +568,7 @@ Foam::scalar Foam::particle::track Foam::scalar Foam::particle::trackToCell ( + const polyMesh& mesh, const vector& displacement, const scalar fraction ) @@ -591,11 +578,11 @@ Foam::scalar Foam::particle::trackToCell Info << "Particle " << origId() << nl << FUNCTION_NAME << nl << endl; } - const scalar f = trackToFace(displacement, fraction); + const scalar f = trackToFace(mesh, displacement, fraction); - if (onInternalFace()) + if (onInternalFace(mesh)) { - changeCell(); + changeCell(mesh); } return f; @@ -604,6 +591,7 @@ Foam::scalar Foam::particle::trackToCell Foam::scalar Foam::particle::trackToFace ( + const polyMesh& mesh, const vector& displacement, const scalar fraction ) @@ -622,7 +610,7 @@ Foam::scalar Foam::particle::trackToFace // Loop the tets in the current cell while (nTracksBehind_ < maxNTracksBehind_) { - f *= trackToTri(f*displacement, f*fraction, tetTriI); + f *= trackToTri(mesh, f*displacement, f*fraction, tetTriI); if (tetTriI == -1) { @@ -638,13 +626,14 @@ Foam::scalar Foam::particle::trackToFace else { // Move to the next tet and continue the track - changeTet(tetTriI); + changeTet(mesh, tetTriI); } } // Warn if stuck, and incorrectly advance the step fraction to completion WarningInFunction - << "Particle #" << origId_ << " got stuck at " << position() << endl; + << "Particle #" << origId_ << " got stuck at " << position(mesh) + << endl; stepFraction_ += f*fraction; @@ -657,12 +646,13 @@ Foam::scalar Foam::particle::trackToFace Foam::scalar Foam::particle::trackToStationaryTri ( + const polyMesh& mesh, const vector& displacement, const scalar fraction, label& tetTriI ) { - const vector x0 = position(); + const vector x0 = position(mesh); const vector x1 = displacement; const barycentric y0 = coordinates_; @@ -676,12 +666,12 @@ Foam::scalar Foam::particle::trackToStationaryTri vector centre; scalar detA; barycentricTensor T; - stationaryTetReverseTransform(centre, detA, T); + stationaryTetReverseTransform(mesh, centre, detA, T); if (debug) { vector o, b, v1, v2; - stationaryTetGeometry(o, b, v1, v2); + stationaryTetGeometry(mesh, o, b, v1, v2); Info<< "Tet points o=" << o << ", b=" << b << ", v1=" << v1 << ", v2=" << v2 << endl << "Tet determinant = " << detA << endl @@ -762,8 +752,8 @@ Foam::scalar Foam::particle::trackToStationaryTri Info<< "Track hit no tet faces" << endl; } Info<< "End local coordinates = " << yH << endl - << "End global coordinates = " << position() << endl - << "Tracking displacement = " << position() - x0 << endl + << "End global coordinates = " << position(mesh) << endl + << "Tracking displacement = " << position(mesh) - x0 << endl << muH*detA*100 << "% of the step from " << stepFraction_ - fraction*muH*detA << " to " << stepFraction_ - fraction*muH*detA + fraction @@ -792,12 +782,13 @@ Foam::scalar Foam::particle::trackToStationaryTri Foam::scalar Foam::particle::trackToMovingTri ( + const polyMesh& mesh, const vector& displacement, const scalar fraction, label& tetTriI ) { - const vector x0 = position(); + const vector x0 = position(mesh); const vector x1 = displacement; const barycentric y0 = coordinates_; @@ -811,12 +802,12 @@ Foam::scalar Foam::particle::trackToMovingTri Pair centre; FixedList detA; FixedList T; - movingTetReverseTransform(fraction, centre, detA, T); + movingTetReverseTransform(mesh, fraction, centre, detA, T); if (debug) { Pair o, b, v1, v2; - movingTetGeometry(fraction, o, b, v1, v2); + movingTetGeometry(mesh, fraction, o, b, v1, v2); Info<< "Tet points o=" << o[0] << ", b=" << b[0] << ", v1=" << v1[0] << ", v2=" << v2[0] << endl << "Tet determinant = " << detA[0] << endl @@ -959,8 +950,8 @@ Foam::scalar Foam::particle::trackToMovingTri Info<< "Track hit no tet faces" << endl; } Info<< "End local coordinates = " << yH << endl - << "End global coordinates = " << position() << endl - << "Tracking displacement = " << position() - x0 << endl + << "End global coordinates = " << position(mesh) << endl + << "Tracking displacement = " << position(mesh) - x0 << endl << muH*detA[0]*100 << "% of the step from " << stepFraction_ - fraction*muH*detA[0] << " to " << stepFraction_ - fraction*muH*detA[0] + fraction @@ -989,28 +980,32 @@ Foam::scalar Foam::particle::trackToMovingTri Foam::scalar Foam::particle::trackToTri ( + const polyMesh& mesh, const vector& displacement, const scalar fraction, label& tetTriI ) { - if (mesh_.moving() && (stepFraction_ != 1 || fraction != 0)) + if (mesh.moving() && (stepFraction_ != 1 || fraction != 0)) { - return trackToMovingTri(displacement, fraction, tetTriI); + return trackToMovingTri(mesh, displacement, fraction, tetTriI); } else { - return trackToStationaryTri(displacement, fraction, tetTriI); + return trackToStationaryTri(mesh, displacement, fraction, tetTriI); } } -Foam::vector Foam::particle::deviationFromMeshCentre() const +Foam::vector Foam::particle::deviationFromMeshCentre +( + const polyMesh& mesh +) const { - if (cmptMin(mesh_.geometricD()) == -1) + if (cmptMin(mesh.geometricD()) == -1) { - vector pos = position(), posC = pos; - meshTools::constrainToMeshCentre(mesh_, posC); + vector pos = position(mesh), posC = pos; + meshTools::constrainToMeshCentre(mesh, posC); return pos - posC; } else @@ -1029,7 +1024,7 @@ void Foam::particle::prepareForParallelTransfer trackingData& td ) { - if (td.sendFromPatch == patch()) + if (td.sendFromPatch == patch(td.mesh)) { prepareForProcessorTransfer(td); } @@ -1037,6 +1032,7 @@ void Foam::particle::prepareForParallelTransfer { prepareForNonConformalCyclicTransfer ( + td.mesh, td.sendFromPatch, td.sendToPatchFace ); @@ -1046,7 +1042,7 @@ void Foam::particle::prepareForParallelTransfer void Foam::particle::correctAfterParallelTransfer(trackingData& td) { - const polyPatch& pp = mesh_.boundaryMesh()[td.sendToPatch]; + const polyPatch& pp = td.mesh.boundaryMesh()[td.sendToPatch]; if (isA(pp)) { @@ -1054,7 +1050,7 @@ void Foam::particle::correctAfterParallelTransfer(trackingData& td) } else if (isA(pp)) { - correctAfterNonConformalCyclicTransfer(td.sendToPatch); + correctAfterNonConformalCyclicTransfer(td.mesh, td.sendToPatch); } else { @@ -1075,7 +1071,10 @@ void Foam::particle::prepareForProcessorTransfer(trackingData& td) void Foam::particle::correctAfterProcessorTransfer(trackingData& td) { const processorPolyPatch& ppp = - refCast(mesh_.boundaryMesh()[td.sendToPatch]); + refCast + ( + td.mesh.boundaryMesh()[td.sendToPatch] + ); if (ppp.transform().transformsPosition()) { @@ -1091,7 +1090,7 @@ void Foam::particle::correctAfterProcessorTransfer(trackingData& td) // directions as their normals both point away from their connected // cells. The tet point therefore counts in the opposite direction from // the base point. - tetPti_ = mesh_.faces()[tetFacei_].size() - 1 - tetPti_; + tetPti_ = td.mesh.faces()[tetFacei_].size() - 1 - tetPti_; // Reflect to account for the change of tri orientation in the new cell reflect(); @@ -1105,16 +1104,20 @@ void Foam::particle::correctAfterProcessorTransfer(trackingData& td) void Foam::particle::prepareForNonConformalCyclicTransfer ( + const polyMesh& mesh, const label sendFromPatch, const label sendToPatchFace ) { const nonConformalCyclicPolyPatch& nccpp = static_cast - (mesh_.boundaryMesh()[sendFromPatch]); + ( + mesh.boundaryMesh()[sendFromPatch] + ); // Get the transformed position - const vector pos = nccpp.transform().invTransformPosition(position()); + const vector pos = + nccpp.transform().invTransformPosition(position(mesh)); // Store the position in the barycentric data coordinates_ = barycentric(1 - cmptSum(pos), pos.x(), pos.y(), pos.z()); @@ -1137,12 +1140,15 @@ void Foam::particle::prepareForNonConformalCyclicTransfer void Foam::particle::correctAfterNonConformalCyclicTransfer ( + const polyMesh& mesh, const label sendToPatch ) { const nonConformalCyclicPolyPatch& nccpp = static_cast - (mesh_.boundaryMesh()[sendToPatch]); + ( + mesh.boundaryMesh()[sendToPatch] + ); // Get the position from the barycentric data const vector receivePos @@ -1155,8 +1161,9 @@ void Foam::particle::correctAfterNonConformalCyclicTransfer // Locate the particle on the receiving side locate ( + mesh, receivePos, - mesh_.faceOwner()[facei_ + nccpp.origPatch().start()], + mesh.faceOwner()[facei_ + nccpp.origPatch().start()], false, "Particle crossed between " + nonConformalCyclicPolyPatch::typeName + " patches " + nccpp.name() + " and " + nccpp.nbrPatch().name() + @@ -1171,11 +1178,12 @@ void Foam::particle::correctAfterNonConformalCyclicTransfer void Foam::particle::prepareForInteractionListReferral ( + const polyMesh& mesh, const transformer& transform ) { // Get the transformed position - const vector pos = transform.invTransformPosition(position()); + const vector pos = transform.invTransformPosition(position(mesh)); // Break the topology celli_ = -1; @@ -1193,14 +1201,18 @@ void Foam::particle::prepareForInteractionListReferral } -void Foam::particle::correctAfterInteractionListReferral(const label celli) +void Foam::particle::correctAfterInteractionListReferral +( + const polyMesh& mesh, + const label celli +) { // Get the position from the barycentric data const vector pos(coordinates_.b(), coordinates_.c(), coordinates_.d()); // Create some arbitrary topology for the supplied cell celli_ = celli; - tetFacei_ = mesh_.cells()[celli_][0]; + tetFacei_ = mesh.cells()[celli_][0]; tetPti_ = 1; // Get the reverse transform and directly set the coordinates from the @@ -1210,12 +1222,12 @@ void Foam::particle::correctAfterInteractionListReferral(const label celli) // so this approximate topology is good enough. By using the nearby cell we // minimise the error associated with the incorrect topology. coordinates_ = barycentric(1, 0, 0, 0); - if (mesh_.moving() && stepFraction_ != 1) + if (mesh.moving() && stepFraction_ != 1) { Pair centre; FixedList detA; FixedList T; - movingTetReverseTransform(0, centre, detA, T); + movingTetReverseTransform(mesh, 0, centre, detA, T); coordinates_ += (pos - centre[0]) & T[0]/detA[0]; } else @@ -1223,7 +1235,7 @@ void Foam::particle::correctAfterInteractionListReferral(const label celli) vector centre; scalar detA; barycentricTensor T; - stationaryTetReverseTransform(centre, detA, T); + stationaryTetReverseTransform(mesh, centre, detA, T); coordinates_ += (pos - centre) & T/detA; } } @@ -1231,6 +1243,7 @@ void Foam::particle::correctAfterInteractionListReferral(const label celli) Foam::label Foam::particle::procTetPt ( + const polyMesh& mesh, const polyMesh& procMesh, const label procCell, const label procTetFace @@ -1242,7 +1255,7 @@ Foam::label Foam::particle::procTetPt if ( - (mesh_.faceOwner()[tetFacei_] == celli_) + (mesh.faceOwner()[tetFacei_] == celli_) == (procMesh.faceOwner()[procTetFace] == procCell) ) { @@ -1257,12 +1270,14 @@ Foam::label Foam::particle::procTetPt void Foam::particle::autoMap ( + const polyMesh& mesh, const vector& position, const polyTopoChangeMap& map ) { locate ( + mesh, position, map.reverseCellMap()[celli_], true, diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index 0a02b128df..e4c0cdab8b 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -104,6 +104,9 @@ public: // Public data + //- Reference to the mesh + const polyMesh& mesh; + //- Flag to indicate whether to keep particle (false = delete) bool keepParticle; @@ -125,6 +128,7 @@ public: template trackingData(const TrackCloudType& cloud) : + mesh(cloud.pMesh()), keepParticle(false), sendToProc(-1), sendFromPatch(-1), @@ -138,9 +142,6 @@ private: // Private Data - //- Reference to the polyMesh database - const polyMesh& mesh_; - //- Coordinates of particle barycentric coordinates_; @@ -200,6 +201,7 @@ private: //- Get the vertices of the current tet inline void stationaryTetGeometry ( + const polyMesh& mesh, vector& centre, vector& base, vector& vertex1, @@ -211,7 +213,10 @@ private: // cartesian position in the global coordinate system. The // conversion is x = A & y, where x is the cartesian position, y is // the barycentric position and A is the transformation tensor. - inline barycentricTensor stationaryTetTransform() const; + inline barycentricTensor stationaryTetTransform + ( + const polyMesh& mesh + ) const; //- Get the reverse transform associated with the current tet. The // conversion is detA*y = (x - centre) & T. The variables x, y and @@ -222,6 +227,7 @@ private: // degenerate tetrahedra. void stationaryTetReverseTransform ( + const polyMesh& mesh, vector& centre, scalar& detA, barycentricTensor& T @@ -232,6 +238,7 @@ private: // second is a linear coefficient of the track fraction. inline void movingTetGeometry ( + const polyMesh& mesh, const scalar endStepFraction, Pair& centre, Pair& base, @@ -245,6 +252,7 @@ private: // returned for each component. inline Pair movingTetTransform ( + const polyMesh& mesh, const scalar endStepFraction ) const; @@ -256,6 +264,7 @@ private: // tensor is quadratic. void movingTetReverseTransform ( + const polyMesh& mesh, const scalar endStepFraction, Pair& centre, FixedList& detA, @@ -281,13 +290,13 @@ private: // Topology changes //- Change tet within a cell. Called after a triangle is hit. - void changeTet(const label tetTriI); + void changeTet(const polyMesh& mesh, const label tetTriI); //- Change tet face within a cell. Called by changeTet. - void changeFace(const label tetTriI); + void changeFace(const polyMesh& mesh, const label tetTriI); //- Change cell. Called when the particle hits an internal face. - void changeCell(); + void changeCell(const polyMesh& mesh); // Geometry changes @@ -295,6 +304,7 @@ private: //- Locate the particle at the given position void locate ( + const polyMesh& mesh, const vector& position, label celli, const bool boundaryFail, @@ -400,38 +410,22 @@ public: ); //- Construct from Istream - particle(const polyMesh& mesh, Istream&, bool readFields = true); + particle(Istream&, bool readFields = true); //- Construct as a copy particle(const particle& p); - //- Construct as a copy with references to a new mesh - particle(const particle& p, const polyMesh& mesh); - - //- Construct a clone + //- Construct and return a clone virtual autoPtr clone() const { return autoPtr(new particle(*this)); } - //- Factory class to read-construct particles used for - // parallel transfer - class iNew + //- Construct from Istream and return + static autoPtr New(Istream& is) { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr operator()(Istream& is) const - { - return autoPtr(new particle(mesh_, is, true)); - } - }; + return autoPtr(new particle(is)); + } //- Destructor @@ -446,9 +440,6 @@ public: //- Get unique particle creation id inline label getNewParticleID() const; - //- Return the mesh database - inline const polyMesh& mesh() const; - //- Return current particle coordinates inline const barycentric& coordinates() const; @@ -490,37 +481,40 @@ public: // return Pair(0, 1), unless sub-cycling is in effect, in // which case the values will reflect the span of the sub-cycle // within the time-step. - inline Pair stepFractionSpan() const; + inline Pair stepFractionSpan(const polyMesh& mesh) const; //- Return the current fraction within the timestep. This differs // from the stored step fraction due to sub-cycling. - inline scalar currentTimeFraction() const; + inline scalar currentTimeFraction(const polyMesh& mesh) const; //- Return the indices of the current tet that the // particle occupies. - inline tetIndices currentTetIndices() const; + inline tetIndices currentTetIndices(const polyMesh& mesh) const; //- Return the current tet transformation tensor - inline barycentricTensor currentTetTransform() const; + inline barycentricTensor currentTetTransform + ( + const polyMesh& mesh + ) const; //- Return the normal of the tri on tetFacei_ for the // current tet. - inline vector normal() const; + inline vector normal(const polyMesh& mesh) const; //- Is the particle on a face? inline bool onFace() const; //- Is the particle on an internal face? - inline bool onInternalFace() const; + inline bool onInternalFace(const polyMesh& mesh) const; //- Is the particle on a boundary face? - inline bool onBoundaryFace() const; + inline bool onBoundaryFace(const polyMesh& mesh) const; //- Return the index of patch that the particle is on - inline label patch() const; + inline label patch(const polyMesh& mesh) const; //- Return current particle position - inline vector position() const; + inline vector position(const polyMesh& mesh) const; // Track @@ -538,6 +532,7 @@ public: // returned. scalar track ( + const polyMesh& mesh, const vector& displacement, const scalar fraction ); @@ -545,6 +540,7 @@ public: //- As particle::track, but stops when a new cell is reached. scalar trackToCell ( + const polyMesh& mesh, const vector& displacement, const scalar fraction ); @@ -552,6 +548,7 @@ public: //- As particle::track, but stops when a face is hit. scalar trackToFace ( + const polyMesh& mesh, const vector& displacement, const scalar fraction ); @@ -561,6 +558,7 @@ public: // or -1 if the end position was reached. scalar trackToTri ( + const polyMesh& mesh, const vector& displacement, const scalar fraction, label& tetTriI @@ -569,6 +567,7 @@ public: //- As particle::trackToTri, but for stationary meshes scalar trackToStationaryTri ( + const polyMesh& mesh, const vector& displacement, const scalar fraction, label& tetTriI @@ -577,6 +576,7 @@ public: //- As particle::trackToTri, but for moving meshes scalar trackToMovingTri ( + const polyMesh& mesh, const vector& displacement, const scalar fraction, label& tetTriI @@ -607,13 +607,18 @@ public: //- Get the displacement from the mesh centre. Used to correct the // particle position in cases with reduced dimensionality. Returns a // zero vector for three-dimensional cases. - vector deviationFromMeshCentre() const; + vector deviationFromMeshCentre(const polyMesh& mesh) const; // Patch data //- Get the normal and displacement of the current patch location - inline void patchData(vector& normal, vector& displacement) const; + inline void patchData + ( + const polyMesh& mesh, + vector& normal, + vector& displacement + ) const; // Transformations @@ -648,6 +653,7 @@ public: // topology and stores the cartesian position. void prepareForNonConformalCyclicTransfer ( + const polyMesh& mesh, const label sendToPatch, const label sendToPatchFace ); @@ -655,7 +661,11 @@ public: //- Make changes following a transfer across a non conformal cyclic // boundary. Locates the particle using the stored face index and // cartesian position. - void correctAfterNonConformalCyclicTransfer(const label sendToPatch); + void correctAfterNonConformalCyclicTransfer + ( + const polyMesh& mesh, + const label sendToPatch + ); // Interaction list referral @@ -664,13 +674,18 @@ public: // particle can be referred. void prepareForInteractionListReferral ( + const polyMesh& mesh, const transformer& transform ); //- Correct the topology after referral. Locates the particle relative // to a nearby cell/tet. The particle may end up outside this cell/tet // and cannot therefore be tracked. - void correctAfterInteractionListReferral(const label celli); + void correctAfterInteractionListReferral + ( + const polyMesh& mesh, + const label celli + ); // Decompose and reconstruct @@ -679,6 +694,7 @@ public: // to or from the given mesh. label procTetPt ( + const polyMesh& mesh, const polyMesh& procMesh, const label procCell, const label procTetFace @@ -687,8 +703,13 @@ public: // Mapping - //- Map after a topology change - void autoMap(const vector& position, const polyTopoChangeMap& map); + //- Map after a mesh change + void autoMap + ( + const polyMesh& mesh, + const point& position, + const polyTopoChangeMap& map + ); // I-O diff --git a/src/lagrangian/basic/particle/particleI.H b/src/lagrangian/basic/particle/particleI.H index d8babbbb67..99fc73c4ee 100644 --- a/src/lagrangian/basic/particle/particleI.H +++ b/src/lagrangian/basic/particle/particleI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,6 +23,7 @@ License \*---------------------------------------------------------------------------*/ +#include "particle.H" #include "polyMesh.H" #include "Time.H" @@ -30,15 +31,16 @@ License void Foam::particle::stationaryTetGeometry ( + const polyMesh& mesh, vector& centre, vector& base, vector& vertex1, vector& vertex2 ) const { - const triFace triIs(currentTetIndices().faceTriIs(mesh_)); - const vectorField& ccs = mesh_.cellCentres(); - const pointField& pts = mesh_.points(); + const triFace triIs(currentTetIndices(mesh).faceTriIs(mesh)); + const vectorField& ccs = mesh.cellCentres(); + const pointField& pts = mesh.points(); centre = ccs[celli_]; base = pts[triIs[0]]; @@ -47,10 +49,13 @@ void Foam::particle::stationaryTetGeometry } -inline Foam::barycentricTensor Foam::particle::stationaryTetTransform() const +inline Foam::barycentricTensor Foam::particle::stationaryTetTransform +( + const polyMesh& mesh +) const { vector centre, base, vertex1, vertex2; - stationaryTetGeometry(centre, base, vertex1, vertex2); + stationaryTetGeometry(mesh, centre, base, vertex1, vertex2); return barycentricTensor(centre, base, vertex1, vertex2); } @@ -58,6 +63,7 @@ inline Foam::barycentricTensor Foam::particle::stationaryTetTransform() const inline void Foam::particle::movingTetGeometry ( + const polyMesh& mesh, const scalar fraction, Pair& centre, Pair& base, @@ -65,16 +71,16 @@ inline void Foam::particle::movingTetGeometry Pair& vertex2 ) const { - const triFace triIs(currentTetIndices().faceTriIs(mesh_)); - const pointField& ptsOld = mesh_.oldPoints(); - const pointField& ptsNew = mesh_.points(); - const vector ccOld = mesh_.oldCellCentres()[celli_]; - const vector ccNew = mesh_.cellCentres()[celli_]; + const triFace triIs(currentTetIndices(mesh).faceTriIs(mesh)); + const pointField& ptsOld = mesh.oldPoints(); + const pointField& ptsNew = mesh.points(); + const vector ccOld = mesh.oldCellCentres()[celli_]; + const vector ccNew = mesh.cellCentres()[celli_]; // Old and new points and cell centres are not sub-cycled. If we are sub- // cycling, then we have to account for the timestep change here by // modifying the fractions that we take of the old and new geometry. - const Pair s = stepFractionSpan(); + const Pair s = stepFractionSpan(mesh); const scalar f0 = s[0] + stepFraction_*s[1], f1 = fraction*s[1]; centre[0] = ccOld + f0*(ccNew - ccOld); @@ -91,11 +97,12 @@ inline void Foam::particle::movingTetGeometry inline Foam::Pair Foam::particle::movingTetTransform ( + const polyMesh& mesh, const scalar fraction ) const { Pair centre, base, vertex1, vertex2; - movingTetGeometry(fraction, centre, base, vertex1, vertex2); + movingTetGeometry(mesh, fraction, centre, base, vertex1, vertex2); return Pair @@ -122,12 +129,6 @@ inline Foam::label Foam::particle::getNewParticleID() const } -inline const Foam::polyMesh& Foam::particle::mesh() const -{ - return mesh_; -} - - inline const Foam::barycentric& Foam::particle::coordinates() const { return coordinates_; @@ -194,12 +195,15 @@ inline Foam::label& Foam::particle::origId() } -inline Foam::Pair Foam::particle::stepFractionSpan() const +inline Foam::Pair Foam::particle::stepFractionSpan +( + const polyMesh& mesh +) const { - if (mesh_.time().subCycling()) + if (mesh.time().subCycling()) { - const TimeState& tsNew = mesh_.time(); - const TimeState& tsOld = mesh_.time().prevTimeState(); + const TimeState& tsNew = mesh.time(); + const TimeState& tsOld = mesh.time().prevTimeState(); const scalar tFrac = ( @@ -218,36 +222,45 @@ inline Foam::Pair Foam::particle::stepFractionSpan() const } -inline Foam::scalar Foam::particle::currentTimeFraction() const +inline Foam::scalar Foam::particle::currentTimeFraction +( + const polyMesh& mesh +) const { - const Pair s = stepFractionSpan(); + const Pair s = stepFractionSpan(mesh); return s[0] + stepFraction_*s[1]; } -inline Foam::tetIndices Foam::particle::currentTetIndices() const +inline Foam::tetIndices Foam::particle::currentTetIndices +( + const polyMesh& mesh +) const { return tetIndices(celli_, tetFacei_, tetPti_); } -inline Foam::barycentricTensor Foam::particle::currentTetTransform() const +inline Foam::barycentricTensor Foam::particle::currentTetTransform +( + const polyMesh& mesh +) const { - if (mesh_.moving() && stepFraction_ != 1) + if (mesh.moving() && stepFraction_ != 1) { - return movingTetTransform(0)[0]; + return movingTetTransform(mesh, 0)[0]; } else { - return stationaryTetTransform(); + return stationaryTetTransform(mesh); } } -inline Foam::vector Foam::particle::normal() const +inline Foam::vector Foam::particle::normal(const polyMesh& mesh) const { - return currentTetIndices().faceTri(mesh_).normal(); + return currentTetIndices(mesh).faceTri(mesh).normal(); } @@ -257,27 +270,27 @@ inline bool Foam::particle::onFace() const } -inline bool Foam::particle::onInternalFace() const +inline bool Foam::particle::onInternalFace(const polyMesh& mesh) const { - return onFace() && mesh_.isInternalFace(facei_); + return onFace() && mesh.isInternalFace(facei_); } -inline bool Foam::particle::onBoundaryFace() const +inline bool Foam::particle::onBoundaryFace(const polyMesh& mesh) const { - return onFace() && !mesh_.isInternalFace(facei_); + return onFace() && !mesh.isInternalFace(facei_); } -inline Foam::label Foam::particle::patch() const +inline Foam::label Foam::particle::patch(const polyMesh& mesh) const { - return onFace() ? mesh_.boundaryMesh().whichPatch(facei_) : -1; + return onFace() ? mesh.boundaryMesh().whichPatch(facei_) : -1; } -inline Foam::vector Foam::particle::position() const +inline Foam::vector Foam::particle::position(const polyMesh& mesh) const { - return currentTetTransform() & coordinates_; + return currentTetTransform(mesh) & coordinates_; } @@ -289,19 +302,24 @@ inline void Foam::particle::reset(const scalar stepFraction) } -void Foam::particle::patchData(vector& normal, vector& displacement) const +void Foam::particle::patchData +( + const polyMesh& mesh, + vector& normal, + vector& displacement +) const { - if (!onBoundaryFace()) + if (!onBoundaryFace(mesh)) { FatalErrorInFunction << "Patch data was requested for a particle that isn't on a patch" << exit(FatalError); } - if (mesh_.moving() && stepFraction_ != 1) + if (mesh.moving() && stepFraction_ != 1) { Pair centre, base, vertex1, vertex2; - movingTetGeometry(1, centre, base, vertex1, vertex2); + movingTetGeometry(mesh, 1, centre, base, vertex1, vertex2); normal = triPointRef(base[0], vertex1[0], vertex2[0]).normal(); @@ -315,7 +333,7 @@ void Foam::particle::patchData(vector& normal, vector& displacement) const else { vector centre, base, vertex1, vertex2; - stationaryTetGeometry(centre, base, vertex1, vertex2); + stationaryTetGeometry(mesh, centre, base, vertex1, vertex2); normal = triPointRef(base, vertex1, vertex2).normal(); diff --git a/src/lagrangian/basic/particle/particleIO.C b/src/lagrangian/basic/particle/particleIO.C index ce0a03e816..7c2c85e1c1 100644 --- a/src/lagrangian/basic/particle/particleIO.C +++ b/src/lagrangian/basic/particle/particleIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,9 +43,8 @@ const std::size_t Foam::particle::sizeofFields_ // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::particle::particle(const polyMesh& mesh, Istream& is, bool readFields) +Foam::particle::particle(Istream& is, bool readFields) : - mesh_(mesh), coordinates_(), celli_(-1), tetFacei_(-1), diff --git a/src/lagrangian/basic/particle/particleTemplates.C b/src/lagrangian/basic/particle/particleTemplates.C index 7446ad573e..a9e2e417ed 100644 --- a/src/lagrangian/basic/particle/particleTemplates.C +++ b/src/lagrangian/basic/particle/particleTemplates.C @@ -126,13 +126,13 @@ void Foam::particle::hitFace { return; } - else if (onInternalFace()) + else if (onInternalFace(td.mesh)) { - changeCell(); + changeCell(td.mesh); } - else if (onBoundaryFace()) + else if (onBoundaryFace(td.mesh)) { - forAll(cloud.patchNonConformalCyclicPatches()[p.patch()], i) + forAll(cloud.patchNonConformalCyclicPatches()[p.patch(td.mesh)], i) { if ( @@ -140,7 +140,7 @@ void Foam::particle::hitFace ( displacement, fraction, - cloud.patchNonConformalCyclicPatches()[p.patch()][i], + cloud.patchNonConformalCyclicPatches()[p.patch(td.mesh)][i], cloud, ttd ) @@ -152,7 +152,7 @@ void Foam::particle::hitFace if (!p.hitPatch(cloud, ttd)) { - const polyPatch& patch = mesh_.boundaryMesh()[p.patch()]; + const polyPatch& patch = td.mesh.boundaryMesh()[p.patch(td.mesh)]; if (isA(patch)) { @@ -205,7 +205,7 @@ Foam::scalar Foam::particle::trackToAndHitFace Info << "Particle " << origId() << nl << FUNCTION_NAME << nl << endl; } - const scalar f = trackToFace(displacement, fraction); + const scalar f = trackToFace(td.mesh, displacement, fraction); hitFace(displacement, fraction, cloud, td); @@ -243,26 +243,29 @@ void Foam::particle::hitSymmetryPlanePatch template -void Foam::particle::hitSymmetryPatch(TrackCloudType&, trackingData&) +void Foam::particle::hitSymmetryPatch(TrackCloudType&, trackingData& td) { - const vector nf = normal(); + const vector nf = normal(td.mesh); transformProperties(transformer::rotation(I - 2.0*nf*nf)); } template -void Foam::particle::hitCyclicPatch(TrackCloudType&, trackingData&) +void Foam::particle::hitCyclicPatch(TrackCloudType&, trackingData& td) { const cyclicPolyPatch& cpp = - static_cast(mesh_.boundaryMesh()[patch()]); + static_cast + ( + td.mesh.boundaryMesh()[patch(td.mesh)] + ); const cyclicPolyPatch& receiveCpp = cpp.nbrPatch(); // Set the topology facei_ = tetFacei_ = cpp.transformGlobalFace(facei_); - celli_ = mesh_.faceOwner()[facei_]; + celli_ = td.mesh.faceOwner()[facei_]; // See note in correctAfterParallelTransfer for tetPti addressing ... - tetPti_ = mesh_.faces()[tetFacei_].size() - 1 - tetPti_; + tetPti_ = td.mesh.faces()[tetFacei_].size() - 1 - tetPti_; // Reflect to account for the change of triangle orientation in the new cell reflect(); @@ -285,7 +288,10 @@ void Foam::particle::hitCyclicAMIPatch ) { const cyclicAMIPolyPatch& cpp = - static_cast(mesh_.boundaryMesh()[patch()]); + static_cast + ( + td.mesh.boundaryMesh()[patch(td.mesh)] + ); const cyclicAMIPolyPatch& receiveCpp = cpp.nbrPatch(); if (debug) @@ -296,9 +302,9 @@ void Foam::particle::hitCyclicAMIPatch // Get the send patch data vector sendNormal, sendDisplacement; - patchData(sendNormal, sendDisplacement); + patchData(td.mesh, sendNormal, sendDisplacement); - vector pos = position(); + vector pos = position(td.mesh); const labelPair receiveIs = cpp.pointAMIAndFace @@ -331,8 +337,9 @@ void Foam::particle::hitCyclicAMIPatch // Locate the particle on the receiving side locate ( + td.mesh, pos, - mesh_.faceOwner()[facei_], + td.mesh.faceOwner()[facei_], false, "Particle crossed between " + cyclicAMIPolyPatch::typeName + " patches " + cpp.name() + " and " + receiveCpp.name() + @@ -365,10 +372,10 @@ void Foam::particle::hitCyclicAMIPatch // If on a boundary and the displacement points into the receiving face // then issue a warning and remove the particle - if (onBoundaryFace()) + if (onBoundaryFace(td.mesh)) { vector receiveNormal, receiveDisplacement; - patchData(receiveNormal, receiveDisplacement); + patchData(td.mesh, receiveNormal, receiveDisplacement); if (((displacementT - fraction*receiveDisplacement)&receiveNormal) > 0) { @@ -399,20 +406,21 @@ bool Foam::particle::hitNonConformalCyclicPatch { const nonConformalCyclicPolyPatch& nccpp = static_cast - (mesh_.boundaryMesh()[patchi]); + (td.mesh.boundaryMesh()[patchi]); - const point sendPos = this->position(); + const point sendPos = position(td.mesh); // Get the send patch data vector sendNormal, sendDisplacement; - patchData(sendNormal, sendDisplacement); + patchData(td.mesh, sendNormal, sendDisplacement); // Project the particle through the non-conformal patch point receivePos; const patchToPatch::procFace receiveProcFace = nccpp.ray ( - stepFractionSpan()[0] + stepFraction_*stepFractionSpan()[1], + stepFractionSpan(td.mesh)[0] + + stepFraction_*stepFractionSpan(td.mesh)[1], nccpp.origPatch().whichFace(facei_), sendPos, displacement - fraction*sendDisplacement, @@ -439,11 +447,13 @@ bool Foam::particle::hitNonConformalCyclicPatch // If both sides are on the same process, then do the local transfer prepareForNonConformalCyclicTransfer ( + td.mesh, nccpp.index(), receiveProcFace.facei ); correctAfterNonConformalCyclicTransfer ( + td.mesh, nccpp.nbrPatchID() ); @@ -454,10 +464,11 @@ bool Foam::particle::hitNonConformalCyclicPatch template void Foam::particle::hitProcessorPatch(TrackCloudType& cloud, trackingData& td) { - td.sendToProc = cloud.patchNbrProc()[patch()]; - td.sendFromPatch = patch(); - td.sendToPatch = cloud.patchNbrProcPatch()[patch()]; - td.sendToPatchFace = mesh().boundaryMesh()[patch()].whichFace(face()); + td.sendToProc = cloud.patchNbrProc()[patch(td.mesh)]; + td.sendFromPatch = patch(td.mesh); + td.sendToPatch = cloud.patchNbrProcPatch()[patch(td.mesh)]; + td.sendToPatchFace = + td.mesh.boundaryMesh()[patch(td.mesh)].whichFace(face()); } diff --git a/src/lagrangian/basic/passiveParticle/passiveParticle.H b/src/lagrangian/basic/passiveParticle/passiveParticle.H index 5ecdcd072b..ee70e787a3 100644 --- a/src/lagrangian/basic/passiveParticle/passiveParticle.H +++ b/src/lagrangian/basic/passiveParticle/passiveParticle.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -84,14 +84,9 @@ public: {} //- Construct from Istream - passiveParticle - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ) + passiveParticle(Istream& is, bool readFields = true) : - particle(mesh, is, readFields) + particle(is, readFields) {} //- Copy constructor @@ -105,6 +100,12 @@ public: { return autoPtr(new passiveParticle(*this)); } + + //- Construct from Istream and return + static autoPtr New(Istream& is) + { + return autoPtr(new passiveParticle(is)); + } }; diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.C b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.C index 37967fb0db..d9369ffa83 100644 --- a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.C +++ b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.C @@ -135,7 +135,7 @@ bool Foam::molecule::move } } - setSitePositions(constProps); + setSitePositions(td.mesh, constProps); } else if (td.part() == trackingData::tpVelocityHalfStep1) { @@ -213,9 +213,15 @@ void Foam::molecule::transformProperties(const transformer& transform) } -void Foam::molecule::setSitePositions(const constantProperties& constProps) +void Foam::molecule::setSitePositions +( + const polyMesh& mesh, + const constantProperties& constProps +) { - sitePositions_ = position() + (Q_ & constProps.siteReferencePositions()); + sitePositions_ = + position(mesh) + + (Q_ & constProps.siteReferencePositions()); } @@ -227,9 +233,9 @@ void Foam::molecule::setSiteSizes(label size) } -void Foam::molecule::hitWallPatch(moleculeCloud&, trackingData&) +void Foam::molecule::hitWallPatch(moleculeCloud&, trackingData& td) { - const vector nw = normal(); + const vector nw = normal(td.mesh); const scalar vn = v_ & nw; // Specular reflection diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H index 45a505d923..dad76dbfc7 100644 --- a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H +++ b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H @@ -297,12 +297,7 @@ public: ); //- Construct from Istream - molecule - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); + molecule(Istream& is, bool readFields = true); //- Construct and return a clone autoPtr clone() const @@ -310,24 +305,11 @@ public: return autoPtr(new molecule(*this)); } - //- Factory class to read-construct particles used for - // parallel transfer - class iNew + //- Construct from Istream and return + static autoPtr New(Istream& is) { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr operator()(Istream& is) const - { - return autoPtr(new molecule(mesh_, is, true)); - } - }; + return autoPtr(new molecule(is)); + } // Member Functions @@ -338,7 +320,11 @@ public: virtual void transformProperties(const transformer&); - void setSitePositions(const constantProperties& constProps); + void setSitePositions + ( + const polyMesh& mesh, + const constantProperties& constProps + ); void setSiteSizes(label size); diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/moleculeI.H b/src/lagrangian/molecularDynamics/molecule/molecule/moleculeI.H index bdc16aef12..f18e6662e3 100644 --- a/src/lagrangian/molecularDynamics/molecule/molecule/moleculeI.H +++ b/src/lagrangian/molecularDynamics/molecule/molecule/moleculeI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,6 +23,8 @@ License \*---------------------------------------------------------------------------*/ +#include "molecule.H" + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // inline Foam::molecule::constantProperties::constantProperties() @@ -250,7 +252,7 @@ inline Foam::molecule::molecule siteForces_(constProps.nSites(), Zero), sitePositions_(constProps.nSites()) { - setSitePositions(constProps); + setSitePositions(mesh, constProps); } @@ -285,7 +287,7 @@ inline Foam::molecule::molecule siteForces_(constProps.nSites(), Zero), sitePositions_(constProps.nSites()) { - setSitePositions(constProps); + setSitePositions(mesh, constProps); } diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/moleculeIO.C b/src/lagrangian/molecularDynamics/molecule/molecule/moleculeIO.C index bfa580fefd..c7df91bd1e 100644 --- a/src/lagrangian/molecularDynamics/molecule/molecule/moleculeIO.C +++ b/src/lagrangian/molecularDynamics/molecule/molecule/moleculeIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,14 +37,9 @@ const std::size_t Foam::molecule::sizeofFields_ // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::molecule::molecule -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::molecule::molecule(Istream& is, bool readFields) : - particle(mesh, is, readFields), + particle(is, readFields), Q_(Zero), v_(Zero), a_(Zero), diff --git a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C index 9556baf3f3..d325f9b820 100644 --- a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C +++ b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -101,7 +101,7 @@ void Foam::moleculeCloud::setSiteSizesAndPositions() mol().setSiteSizes(cP.nSites()); - mol().setSitePositions(cP); + mol().setSitePositions(mesh(), cP); } } @@ -221,7 +221,7 @@ void Foam::moleculeCloud::calculateTetherForce() { if (mol().tethered()) { - vector rIT = mol().position() - mol().specialPosition(); + vector rIT = mol().position(mesh()) - mol().specialPosition(); label idI = mol().id(); diff --git a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloudI.H b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloudI.H index 35cccac4d3..10d3ef814e 100644 --- a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloudI.H +++ b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloudI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -95,7 +95,7 @@ inline void Foam::moleculeCloud::evaluatePair molJ.potentialEnergy() += 0.5*potentialEnergy; - vector rIJ = molI.position() - molJ.position(); + vector rIJ = molI.position(mesh()) - molJ.position(mesh()); tensor virialContribution = (rsIsJ*fsIsJ)*(rsIsJ & rIJ)/rsIsJMagSq; @@ -137,7 +137,7 @@ inline void Foam::moleculeCloud::evaluatePair molJ.potentialEnergy() += 0.5*potentialEnergy; - vector rIJ = molI.position() - molJ.position(); + vector rIJ = molI.position(mesh()) - molJ.position(mesh()); tensor virialContribution = (rsIsJ*fsIsJ)*(rsIsJ & rIJ)/rsIsJMagSq; diff --git a/src/lagrangian/parcel/clouds/Templates/MomentumCloud/MomentumCloud.C b/src/lagrangian/parcel/clouds/Templates/MomentumCloud/MomentumCloud.C index 2fa92c4933..64ecc5e900 100644 --- a/src/lagrangian/parcel/clouds/Templates/MomentumCloud/MomentumCloud.C +++ b/src/lagrangian/parcel/clouds/Templates/MomentumCloud/MomentumCloud.C @@ -709,8 +709,8 @@ void Foam::MomentumCloud::patchData vector& Up ) const { - p.patchData(nw, Up); - Up /= p.mesh().time().deltaTValue(); + p.patchData(this->mesh(), nw, Up); + Up /= this->mesh().time().deltaTValue(); // If this is a wall patch, then there may be a non-zero tangential velocity // component; the lid velocity in a lid-driven cavity case, for example. We @@ -731,7 +731,7 @@ void Foam::MomentumCloud::patchData const vector& Uw0 = U_.oldTime().boundaryField()[patchi][patchFacei]; - const scalar f = p.currentTimeFraction(); + const scalar f = p.currentTimeFraction(this->mesh()); const vector Uw = Uw0 + f*(Uw1 - Uw0); diff --git a/src/lagrangian/parcel/clouds/Templates/SprayCloud/SprayCloud.C b/src/lagrangian/parcel/clouds/Templates/SprayCloud/SprayCloud.C index b32ee6df67..a96dca3149 100644 --- a/src/lagrangian/parcel/clouds/Templates/SprayCloud/SprayCloud.C +++ b/src/lagrangian/parcel/clouds/Templates/SprayCloud/SprayCloud.C @@ -171,7 +171,7 @@ void Foam::SprayCloud::checkParcelProperties CloudType::checkParcelProperties(parcel, lagrangianDt, fullyDescribed); // store the injection position and initial drop size - parcel.position0() = parcel.position(); + parcel.position0() = parcel.position(this->mesh()); parcel.d0() = parcel.d(); parcel.y() = breakup().y0(); diff --git a/src/lagrangian/parcel/clouds/Templates/SprayCloud/SprayCloudI.H b/src/lagrangian/parcel/clouds/Templates/SprayCloud/SprayCloudI.H index 2e2407da84..36369eb8be 100644 --- a/src/lagrangian/parcel/clouds/Templates/SprayCloud/SprayCloudI.H +++ b/src/lagrangian/parcel/clouds/Templates/SprayCloud/SprayCloudI.H @@ -80,6 +80,8 @@ inline Foam::scalar Foam::SprayCloud::penetration << exit(FatalError); } + const polyMesh& mesh = this->mesh(); + scalar distance = 0.0; const label nParcel = this->size(); @@ -107,7 +109,7 @@ inline Foam::scalar Foam::SprayCloud::penetration { const parcelType& p = iter(); scalar m = p.nParticle()*p.mass(); - scalar d = mag(p.position() - p.position0()); + scalar d = mag(p.position(mesh) - p.position0()); mSum += m; mass[i] = m; diff --git a/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcel.C b/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcel.C index ddf75c92f8..e8cbf94a37 100644 --- a/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcel.C +++ b/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcel.C @@ -41,21 +41,6 @@ Foam::CollidingParcel::CollidingParcel {} -template -Foam::CollidingParcel::CollidingParcel -( - const CollidingParcel& p, - const polyMesh& mesh -) -: - ParcelType(p, mesh), - f_(p.f_), - angularMomentum_(p.angularMomentum_), - torque_(p.torque_), - collisionRecords_(p.collisionRecords_) -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcel.H b/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcel.H index 23148ce443..0acf726840 100644 --- a/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcel.H +++ b/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -232,53 +232,23 @@ public: ); //- Construct from Istream - CollidingParcel - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); + CollidingParcel(Istream& is, bool readFields = true); //- Construct as a copy CollidingParcel(const CollidingParcel& p); - //- Construct as a copy - CollidingParcel(const CollidingParcel& p, const polyMesh& mesh); - - //- Construct and return a (basic particle) clone + //- Construct and return a clone virtual autoPtr clone() const { return autoPtr(new CollidingParcel(*this)); } - //- Construct and return a (basic particle) clone - virtual autoPtr clone(const polyMesh& mesh) const + //- Construct from Istream and return + static autoPtr New(Istream& is) { - return autoPtr(new CollidingParcel(*this, mesh)); + return autoPtr(new CollidingParcel(is)); } - //- Factory class to read-construct particles used for - // parallel transfer - class iNew - { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr> operator()(Istream& is) const - { - return autoPtr> - ( - new CollidingParcel(mesh_, is, true) - ); - } - }; - // Member Functions diff --git a/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcelI.H b/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcelI.H index 96854e9b33..28140e6b71 100644 --- a/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcelI.H +++ b/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -62,14 +62,14 @@ inline Foam::CollidingParcel::constantProperties::constantProperties template inline Foam::CollidingParcel::CollidingParcel ( - const polyMesh& owner, + const polyMesh& mesh, const barycentric& coordinates, const label celli, const label tetFacei, const label tetPti ) : - ParcelType(owner, coordinates, celli, tetFacei, tetPti), + ParcelType(mesh, coordinates, celli, tetFacei, tetPti), f_(Zero), angularMomentum_(Zero), torque_(Zero), @@ -80,12 +80,12 @@ inline Foam::CollidingParcel::CollidingParcel template inline Foam::CollidingParcel::CollidingParcel ( - const polyMesh& owner, + const polyMesh& mesh, const vector& position, const label celli ) : - ParcelType(owner, position, celli), + ParcelType(mesh, position, celli), f_(Zero), angularMomentum_(Zero), torque_(Zero), diff --git a/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcelIO.C b/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcelIO.C index ea5a80e3fb..c18deb49c9 100644 --- a/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcelIO.C +++ b/src/lagrangian/parcel/parcels/Templates/CollidingParcel/CollidingParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -44,14 +44,9 @@ const std::size_t Foam::CollidingParcel::sizeofFields_ // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::CollidingParcel::CollidingParcel -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::CollidingParcel::CollidingParcel(Istream& is, bool readFields) : - ParcelType(mesh, is, readFields), + ParcelType(is, readFields), f_(Zero), angularMomentum_(Zero), torque_(Zero), diff --git a/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcel.C b/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcel.C index 4eeb19d691..ec2c2aa855 100644 --- a/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcel.C +++ b/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcel.C @@ -38,18 +38,6 @@ Foam::MPPICParcel::MPPICParcel {} -template -Foam::MPPICParcel::MPPICParcel -( - const MPPICParcel& p, - const polyMesh& mesh -) -: - ParcelType(p, mesh), - UCorrect_(p.UCorrect_) -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcel.H b/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcel.H index 33a564f50b..d5f17431ee 100644 --- a/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcel.H +++ b/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -204,53 +204,23 @@ public: ); //- Construct from Istream - MPPICParcel - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); + MPPICParcel(Istream& is, bool readFields = true); //- Construct as a copy MPPICParcel(const MPPICParcel& p); - //- Construct as a copy - MPPICParcel(const MPPICParcel& p, const polyMesh& mesh); - - //- Construct and return a (basic particle) clone + //- Construct and return a clone virtual autoPtr clone() const { return autoPtr(new MPPICParcel(*this)); } - //- Construct and return a (basic particle) clone - virtual autoPtr clone(const polyMesh& mesh) const + //- Construct from Istream and return + static autoPtr New(Istream& is) { - return autoPtr(new MPPICParcel(*this, mesh)); + return autoPtr(new MPPICParcel(is)); } - //- Factory class to read-construct particles used for - // parallel transfer - class iNew - { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr> operator()(Istream& is) const - { - return autoPtr> - ( - new MPPICParcel(mesh_, is, true) - ); - } - }; - // Member Functions diff --git a/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcelI.H b/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcelI.H index a2af743f8a..787cdb9389 100644 --- a/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcelI.H +++ b/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,19 +23,21 @@ License \*---------------------------------------------------------------------------*/ +#include "MPPICParcel.H" + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template inline Foam::MPPICParcel::MPPICParcel ( - const polyMesh& owner, + const polyMesh& mesh, const barycentric& coordinates, const label celli, const label tetFacei, const label tetPti ) : - ParcelType(owner, coordinates, celli, tetFacei, tetPti), + ParcelType(mesh, coordinates, celli, tetFacei, tetPti), UCorrect_(Zero) {} @@ -43,12 +45,12 @@ inline Foam::MPPICParcel::MPPICParcel template inline Foam::MPPICParcel::MPPICParcel ( - const polyMesh& owner, + const polyMesh& mesh, const vector& position, const label celli ) : - ParcelType(owner, position, celli), + ParcelType(mesh, position, celli), UCorrect_(Zero) {} diff --git a/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcelIO.C b/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcelIO.C index 5e6e932b4a..4cf4215e0d 100644 --- a/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcelIO.C +++ b/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,14 +43,9 @@ const std::size_t Foam::MPPICParcel::sizeofFields_ // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::MPPICParcel::MPPICParcel -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::MPPICParcel::MPPICParcel(Istream& is, bool readFields) : - ParcelType(mesh, is, readFields), + ParcelType(is, readFields), UCorrect_(Zero) { if (readFields) diff --git a/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcelTrackingDataI.H b/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcelTrackingDataI.H index 7e485ff344..a272ad17eb 100644 --- a/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcelTrackingDataI.H +++ b/src/lagrangian/parcel/parcels/Templates/MPPICParcel/MPPICParcelTrackingDataI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -174,7 +174,7 @@ inline void Foam::MPPICParcel::trackingData::updateAverages forAllConstIter(typename TrackCloudType, cloud, iter) { const typename TrackCloudType::parcelType& p = iter(); - const tetIndices tetIs = p.currentTetIndices(); + const tetIndices tetIs = p.currentTetIndices(cloud.mesh()); const scalar m = p.nParticle()*p.mass(); @@ -192,7 +192,7 @@ inline void Foam::MPPICParcel::trackingData::updateAverages forAllConstIter(typename TrackCloudType, cloud, iter) { const typename TrackCloudType::parcelType& p = iter(); - const tetIndices tetIs = p.currentTetIndices(); + const tetIndices tetIs = p.currentTetIndices(cloud.mesh()); const vector u = uAverage_->interpolate(p.coordinates(), tetIs); @@ -211,7 +211,7 @@ inline void Foam::MPPICParcel::trackingData::updateAverages forAllConstIter(typename TrackCloudType, cloud, iter) { const typename TrackCloudType::parcelType& p = iter(); - const tetIndices tetIs = p.currentTetIndices(); + const tetIndices tetIs = p.currentTetIndices(cloud.mesh()); weightAverage.add ( @@ -228,7 +228,7 @@ inline void Foam::MPPICParcel::trackingData::updateAverages forAllConstIter(typename TrackCloudType, cloud, iter) { const typename TrackCloudType::parcelType& p = iter(); - const tetIndices tetIs = p.currentTetIndices(); + const tetIndices tetIs = p.currentTetIndices(cloud.mesh()); const scalar a = volumeAverage_->interpolate(p.coordinates(), tetIs); const scalar r = radiusAverage_->interpolate(p.coordinates(), tetIs); diff --git a/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcel.C b/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcel.C index 6e5448ea38..92d7414fbe 100644 --- a/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcel.C +++ b/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcel.C @@ -44,7 +44,7 @@ void Foam::MomentumParcel::setCellValues trackingData& td ) { - tetIndices tetIs = this->currentTetIndices(); + tetIndices tetIs = this->currentTetIndices(td.mesh); td.rhoc() = td.rhoInterp().interpolate(this->coordinates(), tetIs); @@ -250,27 +250,6 @@ Foam::MomentumParcel::MomentumParcel {} -template -Foam::MomentumParcel::MomentumParcel -( - const MomentumParcel& p, - const polyMesh& mesh -) -: - ParcelType(p, mesh), - moving_(p.moving_), - typeId_(p.typeId_), - nParticle_(p.nParticle_), - d_(p.d_), - dTarget_(p.dTarget_), - U_(p.U_), - rho_(p.rho_), - age_(p.age_), - tTurb_(p.tTurb_), - UTurb_(p.UTurb_) -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template @@ -296,7 +275,7 @@ bool Foam::MomentumParcel::move while (ttd.keepParticle && ttd.sendToProc == -1 && p.stepFraction() < 1) { // Cache the current position, cell and step-fraction - const point start = p.position(); + const point start = p.position(td.mesh); const scalar sfrac = p.stepFraction(); // Total displacement over the time-step @@ -306,7 +285,7 @@ bool Foam::MomentumParcel::move const scalar l = cellLengthScale[p.cell()]; // Deviation from the mesh centre for reduced-D cases - const vector d = p.deviationFromMeshCentre(); + const vector d = p.deviationFromMeshCentre(td.mesh); // Fraction of the displacement to track in this loop. This is limited // to ensure that the both the time and distance tracked is less than @@ -317,7 +296,7 @@ bool Foam::MomentumParcel::move if (p.moving()) { // Track to the next face - p.trackToFace(f*s - d, f); + p.trackToFace(td.mesh, f*s - d, f); } else { @@ -377,7 +356,7 @@ bool Foam::MomentumParcel::hitPatch typename TrackCloudType::parcelType& p = static_cast(*this); - const polyPatch& pp = p.mesh().boundaryMesh()[p.patch()]; + const polyPatch& pp = td.mesh.boundaryMesh()[p.patch(td.mesh)]; // Invoke post-processing model cloud.functions().postPatch(p, pp, td.keepParticle); @@ -406,14 +385,14 @@ template void Foam::MomentumParcel::hitWallPatch ( TrackCloudType&, - trackingData& + trackingData& td ) { - const polyPatch& pp = this->mesh().boundaryMesh()[this->patch()]; + const polyPatch& pp = td.mesh.boundaryMesh()[this->patch(td.mesh)]; FatalErrorInFunction << "Particle " << this->origId() << " hit " << pp.type() << " patch " - << pp.name() << " at " << this->position() + << pp.name() << " at " << this->position(td.mesh) << " but no interaction model was specified for this patch" << exit(FatalError); } diff --git a/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcel.H b/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcel.H index 95a387d67c..bb9fe25643 100644 --- a/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcel.H +++ b/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcel.H @@ -336,53 +336,23 @@ public: ); //- Construct from Istream - MomentumParcel - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); + MomentumParcel(Istream& is, bool readFields = true); //- Construct as a copy MomentumParcel(const MomentumParcel& p); - //- Construct as a copy - MomentumParcel(const MomentumParcel& p, const polyMesh& mesh); - - //- Construct and return a (basic particle) clone + //- Construct and return a clone virtual autoPtr clone() const { return autoPtr(new MomentumParcel(*this)); } - //- Construct and return a (basic particle) clone - virtual autoPtr clone(const polyMesh& mesh) const + //- Construct from Istream and return + static autoPtr New(Istream& is) { - return autoPtr(new MomentumParcel(*this, mesh)); + return autoPtr(new MomentumParcel(is)); } - //- Factory class to read-construct particles used for - // parallel transfer - class iNew - { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr> operator()(Istream& is) const - { - return autoPtr> - ( - new MomentumParcel(mesh_, is, true) - ); - } - }; - // Member Functions diff --git a/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcelI.H b/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcelI.H index b94377f926..931665953c 100644 --- a/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcelI.H +++ b/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,6 +23,7 @@ License \*---------------------------------------------------------------------------*/ +#include "MomentumParcel.H" #include "mathematicalConstants.H" using namespace Foam::constant::mathematical; @@ -72,14 +73,14 @@ inline Foam::MomentumParcel::constantProperties::constantProperties template inline Foam::MomentumParcel::MomentumParcel ( - const polyMesh& owner, + const polyMesh& mesh, const barycentric& coordinates, const label celli, const label tetFacei, const label tetPti ) : - ParcelType(owner, coordinates, celli, tetFacei, tetPti), + ParcelType(mesh, coordinates, celli, tetFacei, tetPti), moving_(true), typeId_(-1), nParticle_(0), @@ -305,7 +306,7 @@ inline Foam::scalar Foam::MomentumParcel::massCell const trackingData& td ) const { - return td.rhoc()*this->mesh().cellVolumes()[this->cell()]; + return td.rhoc()*td.mesh.cellVolumes()[this->cell()]; } diff --git a/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcelIO.C b/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcelIO.C index 5999a65e06..cdfbfeba50 100644 --- a/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcelIO.C +++ b/src/lagrangian/parcel/parcels/Templates/MomentumParcel/MomentumParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -45,14 +45,9 @@ const std::size_t Foam::MomentumParcel::sizeofFields_ // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::MomentumParcel::MomentumParcel -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::MomentumParcel::MomentumParcel(Istream& is, bool readFields) : - ParcelType(mesh, is, readFields), + ParcelType(is, readFields), moving_(false), typeId_(0), nParticle_(0.0), diff --git a/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C b/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C index 186f90fe12..3dc7405715 100644 --- a/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C +++ b/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -723,21 +723,6 @@ Foam::ReactingMultiphaseParcel::ReactingMultiphaseParcel {} -template -Foam::ReactingMultiphaseParcel::ReactingMultiphaseParcel -( - const ReactingMultiphaseParcel& p, - const polyMesh& mesh -) -: - ParcelType(p, mesh), - YGas_(p.YGas_), - YLiquid_(p.YLiquid_), - YSolid_(p.YSolid_), - canCombust_(p.canCombust_) -{} - - // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * // #include "ReactingMultiphaseParcelIO.C" diff --git a/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H b/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H index 71db9197f9..5428dbb67d 100644 --- a/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H +++ b/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -282,7 +282,7 @@ public: // Constructors - //- Construct from mesh, position and topology + //- Construct from mesh, coordinates and topology // Other properties initialised as null inline ReactingMultiphaseParcel ( @@ -303,59 +303,26 @@ public: ); //- Construct from Istream - ReactingMultiphaseParcel - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); + ReactingMultiphaseParcel(Istream& is, bool readFields = true); //- Construct as a copy ReactingMultiphaseParcel(const ReactingMultiphaseParcel& p); - //- Construct as a copy - ReactingMultiphaseParcel - ( - const ReactingMultiphaseParcel& p, - const polyMesh& mesh - ); - - //- Construct and return a (basic particle) clone + //- Construct and return a clone virtual autoPtr clone() const { return autoPtr(new ReactingMultiphaseParcel(*this)); } - //- Construct and return a (basic particle) clone - virtual autoPtr clone(const polyMesh& mesh) const + //- Construct from Istream and return + static autoPtr New(Istream& is) { - return autoPtr(new ReactingMultiphaseParcel(*this, mesh)); - } - - //- Factory class to read-construct particles used for - // parallel transfer - class iNew - { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr> operator() - ( - Istream& is - ) const - { - return autoPtr> + return + autoPtr ( - new ReactingMultiphaseParcel(mesh_, is, true) + new ReactingMultiphaseParcel(is) ); - } - }; + } // Member Functions diff --git a/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelI.H b/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelI.H index 7edc0c4c2e..caa0c31818 100644 --- a/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelI.H +++ b/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,6 +23,8 @@ License \*---------------------------------------------------------------------------*/ +#include "ReactingMultiphaseParcel.H" + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template diff --git a/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C b/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C index dea15801c6..82e805e43d 100644 --- a/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C +++ b/src/lagrangian/parcel/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -44,12 +44,11 @@ const std::size_t Foam::ReactingMultiphaseParcel::sizeofFields_ template Foam::ReactingMultiphaseParcel::ReactingMultiphaseParcel ( - const polyMesh& mesh, Istream& is, bool readFields ) : - ParcelType(mesh, is, readFields), + ParcelType(is, readFields), YGas_(0), YLiquid_(0), YSolid_(0), diff --git a/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcel.C b/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcel.C index 7afa2118b8..40bc1a59eb 100644 --- a/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcel.C +++ b/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcel.C @@ -189,19 +189,6 @@ Foam::ReactingParcel::ReactingParcel {} -template -Foam::ReactingParcel::ReactingParcel -( - const ReactingParcel& p, - const polyMesh& mesh -) -: - ParcelType(p, mesh), - mass0_(p.mass0_), - Y_(p.Y_) -{} - - // * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * * // template @@ -217,7 +204,7 @@ void Foam::ReactingParcel::setCellValues td.pc() = td.pInterp().interpolate ( this->coordinates(), - this->currentTetIndices() + this->currentTetIndices(td.mesh) ); if (td.pc() < cloud.constProps().pMin()) diff --git a/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcel.H b/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcel.H index 85f6ce438d..78d4ac66ae 100644 --- a/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcel.H +++ b/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -210,60 +210,23 @@ public: ); //- Construct from Istream - ReactingParcel - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); - - //- Construct as a copy - ReactingParcel - ( - const ReactingParcel& p, - const polyMesh& mesh - ); + ReactingParcel(Istream& is, bool readFields = true); //- Construct as a copy ReactingParcel(const ReactingParcel& p); - //- Construct and return a (basic particle) clone + //- Construct and return a clone virtual autoPtr clone() const { return autoPtr(new ReactingParcel(*this)); } - //- Construct and return a (basic particle) clone - virtual autoPtr clone(const polyMesh& mesh) const + //- Construct from Istream and return + static autoPtr New(Istream& is) { - return autoPtr - ( - new ReactingParcel(*this, mesh) - ); + return autoPtr(new ReactingParcel(is)); } - //- Factory class to read-construct particles used for - // parallel transfer - class iNew - { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr> operator()(Istream& is) const - { - return autoPtr> - ( - new ReactingParcel(mesh_, is, true) - ); - } - }; - // Member Functions diff --git a/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcelI.H b/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcelI.H index 34cd370276..e7c0ba157b 100644 --- a/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcelI.H +++ b/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,6 +23,8 @@ License \*---------------------------------------------------------------------------*/ +#include "ReactingParcel.H" + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template diff --git a/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcelIO.C b/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcelIO.C index 7a31d794eb..11245a0fdb 100644 --- a/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcelIO.C +++ b/src/lagrangian/parcel/parcels/Templates/ReactingParcel/ReactingParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,14 +42,9 @@ const std::size_t Foam::ReactingParcel::sizeofFields_ // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::ReactingParcel::ReactingParcel -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::ReactingParcel::ReactingParcel(Istream& is, bool readFields) : - ParcelType(mesh, is, readFields), + ParcelType(is, readFields), mass0_(0.0), Y_(0) { diff --git a/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcel.C b/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcel.C index 74f5bbf5d0..8cfc7626dd 100644 --- a/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcel.C +++ b/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -171,7 +171,7 @@ void Foam::SprayParcel::calcAtomisation scalar soi = cloud.injectors().timeStart(); scalar currentTime = cloud.db().time().value(); - const vector& pos = this->position(); + const vector& pos = this->position(td.mesh); const vector& injectionPos = this->position0(); // Disregard the continuous phase when calculating the relative velocity @@ -431,30 +431,6 @@ Foam::SprayParcel::SprayParcel(const SprayParcel& p) {} -template -Foam::SprayParcel::SprayParcel -( - const SprayParcel& p, - const polyMesh& mesh -) -: - ParcelType(p, mesh), - d0_(p.d0_), - position0_(p.position0_), - sigma_(p.sigma_), - mu_(p.mu_), - liquidCore_(p.liquidCore_), - KHindex_(p.KHindex_), - y_(p.y_), - yDot_(p.yDot_), - tc_(p.tc_), - ms_(p.ms_), - injector_(p.injector_), - tMom_(p.tMom_), - user_(p.user_) -{} - - // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * // #include "SprayParcelIO.C" diff --git a/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcel.H b/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcel.H index 8b9b2cba1a..b3876d710c 100644 --- a/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcel.H +++ b/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -212,60 +212,23 @@ public: ); //- Construct from Istream - SprayParcel - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); - - //- Construct as a copy - SprayParcel - ( - const SprayParcel& p, - const polyMesh& mesh - ); + SprayParcel(Istream& is, bool readFields = true); //- Construct as a copy SprayParcel(const SprayParcel& p); - //- Construct and return a (basic particle) clone + //- Construct and return a clone virtual autoPtr clone() const { return autoPtr(new SprayParcel(*this)); } - //- Construct and return a (basic particle) clone - virtual autoPtr clone(const polyMesh& mesh) const + //- Construct from Istream and return + static autoPtr New(Istream& is) { - return autoPtr - ( - new SprayParcel(*this, mesh) - ); + return autoPtr(new SprayParcel(is)); } - //- Factory class to read-construct particles used for - // parallel transfer - class iNew - { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr> operator()(Istream& is) const - { - return autoPtr> - ( - new SprayParcel(mesh_, is, true) - ); - } - }; - // Member Functions diff --git a/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcelI.H b/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcelI.H index b554b176d3..bf20d72de3 100644 --- a/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcelI.H +++ b/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,6 +23,8 @@ License \*---------------------------------------------------------------------------*/ +#include "SprayParcel.H" + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -115,7 +117,7 @@ inline Foam::SprayParcel::SprayParcel : ParcelType(mesh, coordinates, celli, tetFacei, tetPti), d0_(this->d()), - position0_(this->position()), + position0_(this->position(mesh)), sigma_(0.0), mu_(0.0), liquidCore_(0.0), @@ -140,7 +142,7 @@ inline Foam::SprayParcel::SprayParcel : ParcelType(mesh, position, celli), d0_(this->d()), - position0_(this->position()), + position0_(this->position(mesh)), sigma_(0.0), mu_(0.0), liquidCore_(0.0), diff --git a/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcelIO.C b/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcelIO.C index b00de5bba5..4e09951e5c 100644 --- a/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcelIO.C +++ b/src/lagrangian/parcel/parcels/Templates/SprayParcel/SprayParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,14 +38,9 @@ const std::size_t Foam::SprayParcel::sizeofFields_ // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::SprayParcel::SprayParcel -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::SprayParcel::SprayParcel(Istream& is, bool readFields) : - ParcelType(mesh, is, readFields), + ParcelType(is, readFields), d0_(0.0), position0_(Zero), sigma_(0.0), diff --git a/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcel.C b/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcel.C index c3c8b9f739..55c9f9b7a3 100644 --- a/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcel.C +++ b/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,7 +41,7 @@ void Foam::ThermoParcel::setCellValues { ParcelType::setCellValues(cloud, td); - tetIndices tetIs = this->currentTetIndices(); + tetIndices tetIs = this->currentTetIndices(td.mesh); td.Cpc() = td.CpInterp().interpolate(this->coordinates(), tetIs); @@ -123,7 +123,7 @@ void Foam::ThermoParcel::calcSurfaceValues rhos = td.rhoc()*TRatio; - tetIndices tetIs = this->currentTetIndices(); + tetIndices tetIs = this->currentTetIndices(td.mesh); mus = td.muInterp().interpolate(this->coordinates(), tetIs)/TRatio; kappas = td.kappaInterp().interpolate(this->coordinates(), tetIs)/TRatio; @@ -287,7 +287,7 @@ Foam::scalar Foam::ThermoParcel::calcHeatTransfer scalar ancp = Sh; if (cloud.radiation()) { - const tetIndices tetIs = this->currentTetIndices(); + const tetIndices tetIs = this->currentTetIndices(td.mesh); const scalar Gc = td.GInterp().interpolate(this->coordinates(), tetIs); const scalar sigma = physicoChemical::sigma.value(); const scalar epsilon = cloud.constProps().epsilon0(); @@ -327,19 +327,6 @@ Foam::ThermoParcel::ThermoParcel {} -template -Foam::ThermoParcel::ThermoParcel -( - const ThermoParcel& p, - const polyMesh& mesh -) -: - ParcelType(p, mesh), - T_(p.T_), - Cp_(p.Cp_) -{} - - // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * // #include "ThermoParcelIO.C" diff --git a/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcel.H b/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcel.H index c7b4fd6c55..d004df72ee 100644 --- a/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcel.H +++ b/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -327,53 +327,23 @@ public: ); //- Construct from Istream - ThermoParcel - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); + ThermoParcel(Istream& is, bool readFields = true); //- Construct as a copy ThermoParcel(const ThermoParcel& p); - //- Construct as a copy - ThermoParcel(const ThermoParcel& p, const polyMesh& mesh); - - //- Construct and return a (basic particle) clone + //- Construct and return a clone virtual autoPtr clone() const { return autoPtr(new ThermoParcel(*this)); } - //- Construct and return a (basic particle) clone - virtual autoPtr clone(const polyMesh& mesh) const + //- Construct from Istream and return + static autoPtr New(Istream& is) { - return autoPtr(new ThermoParcel(*this, mesh)); + return autoPtr(new ThermoParcel(is)); } - //- Factory class to read-construct particles used for - // parallel transfer - class iNew - { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr> operator()(Istream& is) const - { - return autoPtr> - ( - new ThermoParcel(mesh_, is, true) - ); - } - }; - // Member Functions diff --git a/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcelI.H b/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcelI.H index e2cc013573..b25dd327cd 100644 --- a/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcelI.H +++ b/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,6 +23,8 @@ License \*---------------------------------------------------------------------------*/ +#include "ThermoParcel.H" + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template diff --git a/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcelIO.C b/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcelIO.C index 616b9f3159..4f75005283 100644 --- a/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcelIO.C +++ b/src/lagrangian/parcel/parcels/Templates/ThermoParcel/ThermoParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,14 +43,9 @@ const std::size_t Foam::ThermoParcel::sizeofFields_ // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::ThermoParcel::ThermoParcel -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::ThermoParcel::ThermoParcel(Istream& is, bool readFields) : - ParcelType(mesh, is, readFields), + ParcelType(is, readFields), T_(0.0), Cp_(0.0) { diff --git a/src/lagrangian/parcel/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C b/src/lagrangian/parcel/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C index 81a725f6f2..c0fa3746c0 100644 --- a/src/lagrangian/parcel/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C +++ b/src/lagrangian/parcel/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -644,12 +644,20 @@ void Foam::ParticleCollector::postMove { case mtPolygon: { - collectParcelPolygon(position0, p.position()); + collectParcelPolygon + ( + position0, + p.position(this->owner().mesh()) + ); break; } case mtConcentricCircle: { - collectParcelConcentricCircles(position0, p.position()); + collectParcelConcentricCircles + ( + position0, + p.position(this->owner().mesh()) + ); break; } default: diff --git a/src/lagrangian/parcel/submodels/CloudFunctionObjects/ParticleTracks/ParticleTracks.C b/src/lagrangian/parcel/submodels/CloudFunctionObjects/ParticleTracks/ParticleTracks.C index ab1ac18e08..e9a6980d04 100644 --- a/src/lagrangian/parcel/submodels/CloudFunctionObjects/ParticleTracks/ParticleTracks.C +++ b/src/lagrangian/parcel/submodels/CloudFunctionObjects/ParticleTracks/ParticleTracks.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -142,7 +142,7 @@ void Foam::ParticleTracks::postFace(const parcelType& p, bool&) { cloudPtr_->append ( - static_cast(p.clone(this->owner().mesh()).ptr()) + static_cast(p.clone().ptr()) ); } } diff --git a/src/lagrangian/parcel/submodels/CloudFunctionObjects/RelativeVelocity/RelativeVelocity.C b/src/lagrangian/parcel/submodels/CloudFunctionObjects/RelativeVelocity/RelativeVelocity.C index 243fd64a3a..940f27b7c4 100644 --- a/src/lagrangian/parcel/submodels/CloudFunctionObjects/RelativeVelocity/RelativeVelocity.C +++ b/src/lagrangian/parcel/submodels/CloudFunctionObjects/RelativeVelocity/RelativeVelocity.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2019-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2019-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -53,7 +53,7 @@ void Foam::RelativeVelocity::write() - UcInterp->interpolate ( iter().coordinates(), - iter().currentTetIndices() + iter().currentTetIndices(this->owner().mesh()) ); ++ i; } diff --git a/src/lagrangian/parcel/submodels/MPPIC/DampingModels/Relaxation/Relaxation.C b/src/lagrangian/parcel/submodels/MPPIC/DampingModels/Relaxation/Relaxation.C index d16a662456..89245c68b0 100644 --- a/src/lagrangian/parcel/submodels/MPPIC/DampingModels/Relaxation/Relaxation.C +++ b/src/lagrangian/parcel/submodels/MPPIC/DampingModels/Relaxation/Relaxation.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -139,7 +139,7 @@ Foam::vector Foam::DampingModels::Relaxation::velocityCorrection const scalar deltaT ) const { - const tetIndices tetIs(p.currentTetIndices()); + const tetIndices tetIs(p.currentTetIndices(this->owner().mesh())); const scalar x = deltaT*oneByTimeScaleAverage_->interpolate(p.coordinates(), tetIs); diff --git a/src/lagrangian/parcel/submodels/MPPIC/IsotropyModels/Stochastic/Stochastic.C b/src/lagrangian/parcel/submodels/MPPIC/IsotropyModels/Stochastic/Stochastic.C index 1db4ca0ee4..0c16edad26 100644 --- a/src/lagrangian/parcel/submodels/MPPIC/IsotropyModels/Stochastic/Stochastic.C +++ b/src/lagrangian/parcel/submodels/MPPIC/IsotropyModels/Stochastic/Stochastic.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -166,7 +166,7 @@ void Foam::IsotropyModels::Stochastic::calculate() forAllIter(typename CloudType, this->owner(), iter) { typename CloudType::parcelType& p = iter(); - const tetIndices tetIs(p.currentTetIndices()); + const tetIndices tetIs(p.currentTetIndices(mesh)); const scalar x = exponentAverage.interpolate(p.coordinates(), tetIs); @@ -201,7 +201,7 @@ void Foam::IsotropyModels::Stochastic::calculate() forAllIter(typename CloudType, this->owner(), iter) { typename CloudType::parcelType& p = iter(); - const tetIndices tetIs(p.currentTetIndices()); + const tetIndices tetIs(p.currentTetIndices(mesh)); uTildeAverage.add(p.coordinates(), tetIs, p.nParticle()*p.mass()*p.U()); } uTildeAverage.average(massAverage); @@ -224,7 +224,7 @@ void Foam::IsotropyModels::Stochastic::calculate() forAllIter(typename CloudType, this->owner(), iter) { typename CloudType::parcelType& p = iter(); - const tetIndices tetIs(p.currentTetIndices()); + const tetIndices tetIs(p.currentTetIndices(mesh)); const vector uTilde = uTildeAverage.interpolate(p.coordinates(), tetIs); uTildeSqrAverage.add ( @@ -239,7 +239,7 @@ void Foam::IsotropyModels::Stochastic::calculate() forAllIter(typename CloudType, this->owner(), iter) { typename CloudType::parcelType& p = iter(); - const tetIndices tetIs(p.currentTetIndices()); + const tetIndices tetIs(p.currentTetIndices(mesh)); const vector u = uAverage.interpolate(p.coordinates(), tetIs); const scalar uRms = diff --git a/src/lagrangian/parcel/submodels/MPPIC/PackingModels/Explicit/Explicit.C b/src/lagrangian/parcel/submodels/MPPIC/PackingModels/Explicit/Explicit.C index a8228283d5..f248e74360 100644 --- a/src/lagrangian/parcel/submodels/MPPIC/PackingModels/Explicit/Explicit.C +++ b/src/lagrangian/parcel/submodels/MPPIC/PackingModels/Explicit/Explicit.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -143,7 +143,7 @@ Foam::vector Foam::PackingModels::Explicit::velocityCorrection const scalar deltaT ) const { - const tetIndices tetIs(p.currentTetIndices()); + const tetIndices tetIs(p.currentTetIndices(this->owner().mesh())); // interpolated quantities const scalar alpha = diff --git a/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/PairCollision.C b/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/PairCollision.C index 372ec5c413..71718c9ca4 100644 --- a/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/PairCollision.C +++ b/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/PairCollision.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -220,7 +220,7 @@ void Foam::PairCollision::wallInteraction() typename CloudType::parcelType& p = *cellOccupancy[realCelli][cellParticleI]; - const point& pos = p.position(); + const point& pos = p.position(mesh); scalar r = wallModel_->pREff(p); diff --git a/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.C b/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.C index cd9baa4c2d..d2d0136937 100644 --- a/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.C +++ b/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "PairSpringSliderDashpot.H" +#include "polyMesh.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -172,7 +173,9 @@ void Foam::PairSpringSliderDashpot::evaluatePair typename CloudType::parcelType& pB ) const { - vector r_AB = (pA.position() - pB.position()); + const polyMesh& mesh = this->owner().mesh(); + + vector r_AB = pA.position(mesh) - pB.position(mesh); scalar dAEff = pA.d(); @@ -232,7 +235,7 @@ void Foam::PairSpringSliderDashpot::evaluatePair U_AB - (U_AB & rHat_AB)*rHat_AB - ((dAEff/2*pA.omega() + dBEff/2*pB.omega()) ^ rHat_AB); - scalar deltaT = this->owner().mesh().time().deltaTValue(); + scalar deltaT = mesh.time().deltaTValue(); vector& tangentialOverlap_AB = pA.collisionRecords().matchPairRecord diff --git a/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallLocalSpringSliderDashpot/WallLocalSpringSliderDashpot.C b/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallLocalSpringSliderDashpot/WallLocalSpringSliderDashpot.C index fa68241a3f..d8bc939966 100644 --- a/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallLocalSpringSliderDashpot/WallLocalSpringSliderDashpot.C +++ b/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallLocalSpringSliderDashpot/WallLocalSpringSliderDashpot.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,6 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "WallLocalSpringSliderDashpot.H" +#include "polyMesh.H" +#include "wallPolyPatch.H" +#include "mathematicalConstants.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -80,6 +83,8 @@ void Foam::WallLocalSpringSliderDashpot::evaluateWall bool cohesion ) const { + const polyMesh& mesh = this->owner().mesh(); + // wall patch index label wPI = patchMap_[data.patchIndex()]; @@ -92,7 +97,7 @@ void Foam::WallLocalSpringSliderDashpot::evaluateWall scalar cohesionEnergyDensity = cohesionEnergyDensity_[wPI]; cohesion = cohesion && cohesion_[wPI]; - vector r_PW = p.position() - site; + vector r_PW = p.position(mesh) - site; vector U_PW = p.U() - data.wallData(); @@ -116,7 +121,7 @@ void Foam::WallLocalSpringSliderDashpot::evaluateWall { fN_PW += -cohesionEnergyDensity - *mathematical::pi*(sqr(pREff) - sqr(r_PW_mag)) + *constant::mathematical::pi*(sqr(pREff) - sqr(r_PW_mag)) *rHat_PW; } diff --git a/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallLocalSpringSliderDashpot/WallLocalSpringSliderDashpot.H b/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallLocalSpringSliderDashpot/WallLocalSpringSliderDashpot.H index 40d1f366b9..46ec2f14da 100644 --- a/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallLocalSpringSliderDashpot/WallLocalSpringSliderDashpot.H +++ b/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallLocalSpringSliderDashpot/WallLocalSpringSliderDashpot.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,6 +34,8 @@ Description #define WallLocalSpringSliderDashpot_H #include "WallModel.H" +#include "scalarList.H" +#include "boolList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallModel/WallModel.H b/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallModel/WallModel.H index 075186a132..8bb012ef15 100644 --- a/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallModel/WallModel.H +++ b/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallModel/WallModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,6 +40,7 @@ SourceFiles #include "autoPtr.H" #include "runTimeSelectionTables.H" #include "WallSiteData.H" +#include "point.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallSpringSliderDashpot/WallSpringSliderDashpot.C b/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallSpringSliderDashpot/WallSpringSliderDashpot.C index 0791245fe0..c2d3394052 100644 --- a/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallSpringSliderDashpot/WallSpringSliderDashpot.C +++ b/src/lagrangian/parcel/submodels/Momentum/CollisionModel/PairCollision/WallModel/WallSpringSliderDashpot/WallSpringSliderDashpot.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,6 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "WallSpringSliderDashpot.H" +#include "polyMesh.H" +#include "mathematicalConstants.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -81,7 +83,9 @@ void Foam::WallSpringSliderDashpot::evaluateWall bool cohesion ) const { - vector r_PW = p.position() - site; + const polyMesh& mesh = this->owner().mesh(); + + vector r_PW = p.position(mesh) - site; vector U_PW = p.U() - data.wallData(); @@ -103,7 +107,7 @@ void Foam::WallSpringSliderDashpot::evaluateWall { fN_PW += -cohesionEnergyDensity_ - *mathematical::pi*(sqr(pREff) - sqr(r_PW_mag)) + *constant::mathematical::pi*(sqr(pREff) - sqr(r_PW_mag)) *rHat_PW; } diff --git a/src/lagrangian/parcel/submodels/Momentum/InjectionModel/ConeInjection/ConeInjection.C b/src/lagrangian/parcel/submodels/Momentum/InjectionModel/ConeInjection/ConeInjection.C index dc2e82b2e0..ba10c0eeda 100644 --- a/src/lagrangian/parcel/submodels/Momentum/InjectionModel/ConeInjection/ConeInjection.C +++ b/src/lagrangian/parcel/submodels/Momentum/InjectionModel/ConeInjection/ConeInjection.C @@ -378,6 +378,8 @@ void Foam::ConeInjection::setProperties typename CloudType::parcelType& parcel ) { + const polyMesh& mesh = this->owner().mesh(); + Random& rndGen = this->owner().rndGen(); const scalar t = time - this->SOI_; @@ -412,9 +414,9 @@ void Foam::ConeInjection::setProperties } case imDisc: { - const scalar r = mag(parcel.position() - position_.value(t)); + const scalar r = mag(parcel.position(mesh) - position_.value(t)); const scalar frac = (2*r - dInner_)/(dOuter_ - dInner_); - tanVec = normalised(parcel.position() - position_.value(t)); + tanVec = normalised(parcel.position(mesh) - position_.value(t)); theta = degToRad ( diff --git a/src/lagrangian/parcel/submodels/Momentum/InjectionModel/InflationInjection/InflationInjection.C b/src/lagrangian/parcel/submodels/Momentum/InjectionModel/InflationInjection/InflationInjection.C index 4bf055b75c..b237727722 100644 --- a/src/lagrangian/parcel/submodels/Momentum/InjectionModel/InflationInjection/InflationInjection.C +++ b/src/lagrangian/parcel/submodels/Momentum/InjectionModel/InflationInjection/InflationInjection.C @@ -286,7 +286,7 @@ Foam::label Foam::InflationInjection::parcelsToInject continue; } - const point& pP = pPtr->position(); + const point& pP = pPtr->position(mesh); const vector& pU = pPtr->U(); // Generate a tetrahedron of new positions with the diff --git a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Drag/ErgunWenYuDrag/ErgunWenYuDragForce.C b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Drag/ErgunWenYuDrag/ErgunWenYuDragForce.C index aa68e55f28..fae196cf17 100644 --- a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Drag/ErgunWenYuDrag/ErgunWenYuDragForce.C +++ b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Drag/ErgunWenYuDrag/ErgunWenYuDragForce.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -73,7 +73,7 @@ Foam::forceSuSp Foam::ErgunWenYuDragForce::calcCoupled this->alphacInterp().interpolate ( p.coordinates(), - p.currentTetIndices() + p.currentTetIndices(td.mesh) ); if (alphac < 0.8) diff --git a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Drag/PlessisMasliyahDrag/PlessisMasliyahDragForce.C b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Drag/PlessisMasliyahDrag/PlessisMasliyahDragForce.C index 406dc42989..005b547468 100644 --- a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Drag/PlessisMasliyahDrag/PlessisMasliyahDragForce.C +++ b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Drag/PlessisMasliyahDrag/PlessisMasliyahDragForce.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -74,7 +74,7 @@ Foam::forceSuSp Foam::PlessisMasliyahDragForce::calcCoupled this->alphacInterp().interpolate ( p.coordinates(), - p.currentTetIndices() + p.currentTetIndices(td.mesh) ); const scalar cbrtAlphap = pow(1 - alphac, 1.0/3.0); diff --git a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Drag/WenYuDrag/WenYuDragForce.C b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Drag/WenYuDrag/WenYuDragForce.C index ddf085def7..da3b2195e8 100644 --- a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Drag/WenYuDrag/WenYuDragForce.C +++ b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Drag/WenYuDrag/WenYuDragForce.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -87,8 +87,9 @@ Foam::forceSuSp Foam::WenYuDragForce::calcCoupled this->alphacInterp().interpolate ( p.coordinates(), - p.currentTetIndices() + p.currentTetIndices(td.mesh) ); + const scalar CdRe = SchillerNaumannDragForce::CdRe(alphac*Re); return forceSuSp diff --git a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Lift/LiftForce/LiftForce.C b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Lift/LiftForce/LiftForce.C index 9ab8364370..b7e7ef0570 100644 --- a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Lift/LiftForce/LiftForce.C +++ b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Lift/LiftForce/LiftForce.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -138,10 +138,14 @@ Foam::forceSuSp Foam::LiftForce::calcCoupled { forceSuSp value(Zero, 0.0); - vector curlUc = - curlUcInterp().interpolate(p.coordinates(), p.currentTetIndices()); + const vector curlUc = + curlUcInterp().interpolate + ( + p.coordinates(), + p.currentTetIndices(td.mesh) + ); - scalar Cl = this->Cl(p, td, curlUc, Re, muc); + const scalar Cl = this->Cl(p, td, curlUc, Re, muc); value.Su() = mass/p.rho()*td.rhoc()*Cl*((td.Uc() - p.U())^curlUc); diff --git a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/NonInertialFrame/NonInertialFrameForce.C b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/NonInertialFrame/NonInertialFrameForce.C index c35ce0e5a1..f339de0ceb 100644 --- a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/NonInertialFrame/NonInertialFrameForce.C +++ b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/NonInertialFrame/NonInertialFrameForce.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -190,7 +190,7 @@ Foam::forceSuSp Foam::NonInertialFrameForce::calcNonCoupled { forceSuSp value(Zero, 0.0); - const vector r = p.position() - centreOfRotation_; + const vector r = p.position(td.mesh) - centreOfRotation_; value.Su() = mass diff --git a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Paramagnetic/ParamagneticForce.C b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Paramagnetic/ParamagneticForce.C index 511eae682e..d2c19111cf 100644 --- a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Paramagnetic/ParamagneticForce.C +++ b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/Paramagnetic/ParamagneticForce.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -111,7 +111,11 @@ Foam::forceSuSp Foam::ParamagneticForce::calcNonCoupled value.Su()= mass*3.0*constant::electromagnetic::mu0.value()/p.rho() *magneticSusceptibility_/(magneticSusceptibility_ + 3) - *HdotGradHInterp.interpolate(p.coordinates(), p.currentTetIndices()); + *HdotGradHInterp.interpolate + ( + p.coordinates(), + p.currentTetIndices(td.mesh) + ); return value; } diff --git a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/PressureGradient/PressureGradientForce.C b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/PressureGradient/PressureGradientForce.C index 9028a935cb..7edc2c7050 100644 --- a/src/lagrangian/parcel/submodels/Momentum/ParticleForces/PressureGradient/PressureGradientForce.C +++ b/src/lagrangian/parcel/submodels/Momentum/ParticleForces/PressureGradient/PressureGradientForce.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -128,8 +128,12 @@ Foam::forceSuSp Foam::PressureGradientForce::calcCoupled { forceSuSp value(Zero, 0.0); - vector DUcDt = - DUcDtInterp().interpolate(p.coordinates(), p.currentTetIndices()); + const vector DUcDt = + DUcDtInterp().interpolate + ( + p.coordinates(), + p.currentTetIndices(td.mesh) + ); value.Su() = mass*td.rhoc()/p.rho()*DUcDt; diff --git a/src/lagrangian/parcel/submodels/Spray/StochasticCollision/TrajectoryCollision/TrajectoryCollision.C b/src/lagrangian/parcel/submodels/Spray/StochasticCollision/TrajectoryCollision/TrajectoryCollision.C index 575ef7ca0a..3475798066 100644 --- a/src/lagrangian/parcel/submodels/Spray/StochasticCollision/TrajectoryCollision/TrajectoryCollision.C +++ b/src/lagrangian/parcel/submodels/Spray/StochasticCollision/TrajectoryCollision/TrajectoryCollision.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -50,8 +50,8 @@ bool Foam::TrajectoryCollision::collideParcels { bool coalescence = false; - const vector& pos1 = p1.position(); - const vector& pos2 = p2.position(); + const point pos1 = p1.position(this->owner().mesh()); + const point pos2 = p2.position(this->owner().mesh()); const vector& U1 = p1.U(); const vector& U2 = p2.U(); diff --git a/src/lagrangian/parcel/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.C b/src/lagrangian/parcel/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.C index 92b3887e39..b7b2cf3ae9 100644 --- a/src/lagrangian/parcel/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.C +++ b/src/lagrangian/parcel/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -456,7 +456,7 @@ void Foam::ThermoSurfaceFilm::splashInteraction } // Perturb new parcels towards the owner cell centre - pPtr->track(0.5*rndGen_.sample01()*(posC - posCf), 0); + pPtr->track(mesh, 0.5*rndGen_.sample01()*(posC - posCf), 0); pPtr->nParticle() = npNew[i]; diff --git a/src/lagrangian/solidParticle/solidParticle.C b/src/lagrangian/solidParticle/solidParticle.C index 3ccbc5f368..cd9d6edcd2 100644 --- a/src/lagrangian/solidParticle/solidParticle.C +++ b/src/lagrangian/solidParticle/solidParticle.C @@ -49,7 +49,7 @@ bool Foam::solidParticle::move { if (debug) { - Info<< "Time = " << mesh().time().timeName() + Info<< "Time = " << td.mesh.time().timeName() << " trackTime = " << trackTime << " stepFraction() = " << stepFraction() << endl; } @@ -62,7 +62,7 @@ bool Foam::solidParticle::move const scalar dt = (stepFraction() - sfrac)*trackTime; - const tetIndices tetIs = this->currentTetIndices(); + const tetIndices tetIs = this->currentTetIndices(td.mesh); scalar rhoc = td.rhoInterp().interpolate(this->coordinates(), tetIs); vector Uc = td.UInterp().interpolate(this->coordinates(), tetIs); scalar nuc = td.nuInterp().interpolate(this->coordinates(), tetIs); @@ -87,9 +87,13 @@ bool Foam::solidParticle::move } -void Foam::solidParticle::hitWallPatch(solidParticleCloud& cloud, trackingData&) +void Foam::solidParticle::hitWallPatch +( + solidParticleCloud& cloud, + trackingData& td +) { - const vector nw = normal(); + const vector nw = normal(td.mesh); const scalar Un = U_ & nw; const vector Ut = U_ - Un*nw; diff --git a/src/lagrangian/solidParticle/solidParticle.H b/src/lagrangian/solidParticle/solidParticle.H index 6217cf404f..e67455fc73 100644 --- a/src/lagrangian/solidParticle/solidParticle.H +++ b/src/lagrangian/solidParticle/solidParticle.H @@ -84,6 +84,7 @@ public: friend class Cloud; + //- Class used to pass tracking data to the trackToFace function class trackingData : @@ -144,12 +145,7 @@ public: ); //- Construct from Istream - solidParticle - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); + solidParticle(Istream& is, bool readFields = true); //- Construct and return a clone virtual autoPtr clone() const @@ -157,27 +153,11 @@ public: return autoPtr(new solidParticle(*this)); } - //- Factory class to read-construct particles used for - // parallel transfer - class iNew + //- Construct from Istream and return + static autoPtr New(Istream& is) { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr operator()(Istream& is) const - { - return autoPtr - ( - new solidParticle(mesh_, is, true) - ); - } - }; + return autoPtr(new solidParticle(is)); + } // Member Functions diff --git a/src/lagrangian/solidParticle/solidParticleCloud.H b/src/lagrangian/solidParticle/solidParticleCloud.H index 61c65ebbb0..728dc8de9b 100644 --- a/src/lagrangian/solidParticle/solidParticleCloud.H +++ b/src/lagrangian/solidParticle/solidParticleCloud.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -64,7 +64,9 @@ class solidParticleCloud IOdictionary particleProperties_; scalar rhop_; + scalar e_; + scalar mu_; @@ -95,7 +97,9 @@ public: inline const fvMesh& mesh() const; inline scalar rhop() const; + inline scalar e() const; + inline scalar mu() const; diff --git a/src/lagrangian/solidParticle/solidParticleI.H b/src/lagrangian/solidParticle/solidParticleI.H index 614fdf62bd..f1bb9a1227 100644 --- a/src/lagrangian/solidParticle/solidParticleI.H +++ b/src/lagrangian/solidParticle/solidParticleI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,6 +23,8 @@ License \*---------------------------------------------------------------------------*/ +#include "solidParticle.H" + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // inline Foam::solidParticle::trackingData::trackingData diff --git a/src/lagrangian/solidParticle/solidParticleIO.C b/src/lagrangian/solidParticle/solidParticleIO.C index 7fb9cf8dde..c7622fde75 100644 --- a/src/lagrangian/solidParticle/solidParticleIO.C +++ b/src/lagrangian/solidParticle/solidParticleIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "solidParticle.H" +#include "solidParticleCloud.H" #include "IOstreams.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -36,14 +37,9 @@ const std::size_t Foam::solidParticle::sizeofFields_ // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::solidParticle::solidParticle -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::solidParticle::solidParticle(Istream& is, bool readFields) : - particle(mesh, is, readFields) + particle(is, readFields) { if (readFields) { diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C index 25d0afafae..7722ac590d 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C @@ -531,7 +531,7 @@ void Foam::meshRefinement::markFeatureCellLevel label otherPointi = e.otherVertex(pointi); trackedParticle* tp(new trackedParticle(startTp)); - tp->start() = tp->position(); + tp->start() = tp->position(mesh_); tp->end() = featureMesh.points()[otherPointi]; tp->j() = otherPointi; tp->k() = edgei; @@ -539,7 +539,7 @@ void Foam::meshRefinement::markFeatureCellLevel if (debug&meshRefinement::FEATURESEEDS) { Pout<< "Adding particle for point:" << pointi - << " coord:" << tp->position() + << " coord:" << tp->position(mesh_) << " feature:" << feati << " to track to:" << tp->end() << endl; @@ -592,7 +592,7 @@ void Foam::meshRefinement::markFeatureCellLevel const edge& e = featureMesh.edges()[edgei]; const label otherPointi = e.otherVertex(pointi); - tp.start() = tp.position(); + tp.start() = tp.position(mesh_); tp.end() = featureMesh.points()[otherPointi]; tp.j() = otherPointi; tp.k() = edgei; diff --git a/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.C b/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.C index ed34155964..16a88cd8c4 100644 --- a/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.C +++ b/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.C @@ -43,7 +43,7 @@ Foam::trackedParticle::trackedParticle ) : particle(mesh, coordinates, celli, tetFacei, tetPtI), - start_(position()), + start_(position(mesh)), end_(end), level_(level), i_(i), @@ -65,7 +65,7 @@ Foam::trackedParticle::trackedParticle ) : particle(mesh, position, celli), - start_(this->position()), + start_(this->position(mesh)), end_(end), level_(level), i_(i), @@ -74,14 +74,9 @@ Foam::trackedParticle::trackedParticle {} -Foam::trackedParticle::trackedParticle -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::trackedParticle::trackedParticle(Istream& is, bool readFields) : - particle(mesh, is, readFields) + particle(is, readFields) { if (readFields) { @@ -124,7 +119,7 @@ bool Foam::trackedParticle::move { scalar tEnd = (1.0 - stepFraction())*trackTime; - if (tEnd <= small && onBoundaryFace()) + if (tEnd <= small && onBoundaryFace(td.mesh)) { // This is a hack to handle particles reaching their endpoint on a // processor boundary. This prevents a particle being endlessly diff --git a/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.H b/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.H index 114c94cc1b..c6c106b1f7 100644 --- a/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.H +++ b/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.H @@ -147,12 +147,7 @@ public: ); //- Construct from Istream - trackedParticle - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); + trackedParticle(Istream& is, bool readFields = true); //- Construct and return a clone autoPtr clone() const @@ -160,27 +155,11 @@ public: return autoPtr(new trackedParticle(*this)); } - //- Factory class to read-construct particles used for - // parallel transfer - class iNew + //- Construct from Istream and return + static autoPtr New(Istream& is) { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr operator()(Istream& is) const - { - return autoPtr - ( - new trackedParticle(mesh_, is, true) - ); - } - }; + return autoPtr(new trackedParticle(is)); + } // Member Functions diff --git a/src/sampling/sampledSet/lineFace/lineFace.C b/src/sampling/sampledSet/lineFace/lineFace.C index 8e1e566d91..87e34b0890 100644 --- a/src/sampling/sampledSet/lineFace/lineFace.C +++ b/src/sampling/sampledSet/lineFace/lineFace.C @@ -173,7 +173,7 @@ void Foam::sampledSets::lineFace::calcSamples returnReduce ( particles.size() - ? mag(particles.first()->position() - start) + ? mag(particles.first()->position(mesh) - start) /mag(end - start) : i == 0 ? vGreat : -vGreat, [i](const scalar a, const scalar b) @@ -207,13 +207,16 @@ void Foam::sampledSets::lineFace::calcSamples if (proci == Pstream::myProcNo() && i == 0 && storeCells) { particle trackBwd(mesh, p, celli), trackFwd(trackBwd); - trackBwd.trackToFace(start - p, 0); - trackFwd.trackToFace(end - p, 0); + trackBwd.trackToFace(mesh, start - p, 0); + trackFwd.trackToFace(mesh, end - p, 0); if (trackBwd.onFace() && trackFwd.onFace()) { samplingPositions.append ( - (trackBwd.position() + trackFwd.position())/2 + ( + trackBwd.position(mesh) + + trackFwd.position(mesh) + )/2 ); samplingSegments.append(segmenti); samplingCells.append(celli); diff --git a/src/sampling/sampledSet/sampledSet/sampledSetParticle.C b/src/sampling/sampledSet/sampledSet/sampledSetParticle.C index 5070a9ac30..883089de52 100644 --- a/src/sampling/sampledSet/sampledSet/sampledSetParticle.C +++ b/src/sampling/sampledSet/sampledSet/sampledSetParticle.C @@ -47,14 +47,9 @@ Foam::sampledSetParticle::sampledSetParticle {} -Foam::sampledSetParticle::sampledSetParticle -( - const polyMesh& mesh, - Istream& is, - bool readFields -) +Foam::sampledSetParticle::sampledSetParticle(Istream& is, bool readFields) : - particle(mesh, is, readFields) + particle(is, readFields) { if (readFields) { @@ -87,7 +82,7 @@ void Foam::sampledSetParticle::store trackingData& td ) { - td.positions_.append(position()); + td.positions_.append(position(td.mesh)); td.distances_.append(distance_); td.cells_.append(cell()); td.faces_.append(face()); @@ -112,14 +107,14 @@ void Foam::sampledSetParticle::storeCell { if (havePosition0_) { - td.positions_.append((position() + position0_)/2); - td.distances_.append(distance_ - mag(position() - position0_)/2); + td.positions_.append((position(td.mesh) + position0_)/2); + td.distances_.append(distance_ - mag(position(td.mesh) - position0_)/2); td.cells_.append(cell()); td.faces_.append(-1); } havePosition0_ = true; - position0_ = position(); + position0_ = position(td.mesh); } @@ -138,18 +133,18 @@ bool Foam::sampledSetParticle::move const vector s = td.set_[seti_ + 1] - td.set_[seti_]; const scalar magS = mag(s); - const scalar f = trackToFace(setF_*s, 0); + const scalar f = trackToFace(td.mesh, setF_*s, 0); distance_ += (1 - f)*setF_*magS; setF_ *= f; - while (onInternalFace()) + while (onInternalFace(td.mesh)) { if (td.storeCells_) storeCell(cloud, td); if (td.storeFaces_) storeFace(cloud, td); hitFace(setF_*s, 0, cloud, td); - const scalar f = trackToFace(setF_*s, 0); + const scalar f = trackToFace(td.mesh, setF_*s, 0); distance_ += (1 - f)*setF_*magS; setF_ *= f; } @@ -162,7 +157,7 @@ bool Foam::sampledSetParticle::move hitFace(setF_*s, 0, cloud, td); } - if (onBoundaryFace() && setF_ < rootSmall) + if (onBoundaryFace(td.mesh) && setF_ < rootSmall) { if (td.storeSet_) store(cloud, td); } @@ -239,7 +234,10 @@ void Foam::sampledSetParticle::hitProcessorPatch ) { const processorPolyPatch& ppp = - static_cast(mesh().boundaryMesh()[patch()]); + static_cast + ( + td.mesh.boundaryMesh()[patch(td.mesh)] + ); if (ppp.transform().transformsPosition()) { diff --git a/src/sampling/sampledSet/sampledSet/sampledSetParticle.H b/src/sampling/sampledSet/sampledSet/sampledSetParticle.H index 6774b2bbde..22d45ffea5 100644 --- a/src/sampling/sampledSet/sampledSet/sampledSetParticle.H +++ b/src/sampling/sampledSet/sampledSet/sampledSetParticle.H @@ -155,12 +155,7 @@ public: ); //- Construct from Istream - sampledSetParticle - ( - const polyMesh& mesh, - Istream& is, - bool readFields = true - ); + sampledSetParticle(Istream& is, bool readFields = true); //- Copy constructor sampledSetParticle(const sampledSetParticle&); @@ -171,26 +166,11 @@ public: return autoPtr(new sampledSetParticle(*this)); } - //- Factory class to read-construct particles used for parallel transfer - class iNew + //- Construct from Istream and return + static autoPtr New(Istream& is) { - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr operator()(Istream& is) const - { - return autoPtr - ( - new sampledSetParticle(mesh_, is, true) - ); - } - }; + return autoPtr(new sampledSetParticle(is)); + } // Member Functions