From 96332633f2564b5d29e00bb5bd6f4055acf95025 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 22 May 2014 16:45:44 +0100 Subject: [PATCH 1/8] ENH: snappyHexMesh: allow empty refinement surfaces #1303 --- .../meshRefinementProblemCells.C | 112 ++++++++++-------- 1 file changed, 62 insertions(+), 50 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C index 4c9f8143..37c98e6a 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C @@ -381,70 +381,82 @@ Foam::labelList Foam::meshRefinement::nearestPatch { const polyBoundaryMesh& patches = mesh_.boundaryMesh(); - // Count number of faces in adaptPatchIDs - label nFaces = 0; - forAll(adaptPatchIDs, i) + labelList nearestAdaptPatch; + + if (adaptPatchIDs.size()) { - const polyPatch& pp = patches[adaptPatchIDs[i]]; - nFaces += pp.size(); - } + nearestAdaptPatch.setSize(mesh_.nFaces(), adaptPatchIDs[0]); - // Field on cells and faces. - List cellData(mesh_.nCells()); - List faceData(mesh_.nFaces()); - // Start of changes - labelList patchFaces(nFaces); - List patchData(nFaces); - nFaces = 0; - forAll(adaptPatchIDs, i) - { - label patchI = adaptPatchIDs[i]; - const polyPatch& pp = patches[patchI]; - - forAll(pp, i) + // Count number of faces in adaptPatchIDs + label nFaces = 0; + forAll(adaptPatchIDs, i) { - patchFaces[nFaces] = pp.start()+i; - patchData[nFaces] = topoDistanceData(patchI, 0); - nFaces++; + const polyPatch& pp = patches[adaptPatchIDs[i]]; + nFaces += pp.size(); } - } - // Propagate information inwards - FaceCellWave deltaCalc - ( - mesh_, - patchFaces, - patchData, - faceData, - cellData, - mesh_.globalData().nTotalCells()+1 - ); + // Field on cells and faces. + List cellData(mesh_.nCells()); + List faceData(mesh_.nFaces()); - // And extract - labelList nearestAdaptPatch(mesh_.nFaces(), adaptPatchIDs[0]); - - bool haveWarned = false; - forAll(faceData, faceI) - { - if (!faceData[faceI].valid(deltaCalc.data())) + // Start of changes + labelList patchFaces(nFaces); + List patchData(nFaces); + nFaces = 0; + forAll(adaptPatchIDs, i) { - if (!haveWarned) + label patchI = adaptPatchIDs[i]; + const polyPatch& pp = patches[patchI]; + + forAll(pp, i) { - WarningIn("meshRefinement::nearestPatch(..)") - << "Did not visit some faces, e.g. face " << faceI - << " at " << mesh_.faceCentres()[faceI] << endl - << "Assigning these cells to patch " - << adaptPatchIDs[0] - << endl; - haveWarned = true; + patchFaces[nFaces] = pp.start()+i; + patchData[nFaces] = topoDistanceData(patchI, 0); + nFaces++; } } - else + + // Propagate information inwards + FaceCellWave deltaCalc + ( + mesh_, + patchFaces, + patchData, + faceData, + cellData, + mesh_.globalData().nTotalCells()+1 + ); + + // And extract + + bool haveWarned = false; + forAll(faceData, faceI) { - nearestAdaptPatch[faceI] = faceData[faceI].data(); + if (!faceData[faceI].valid(deltaCalc.data())) + { + if (!haveWarned) + { + WarningIn("meshRefinement::nearestPatch(..)") + << "Did not visit some faces, e.g. face " << faceI + << " at " << mesh_.faceCentres()[faceI] << endl + << "Assigning these cells to patch " + << adaptPatchIDs[0] + << endl; + haveWarned = true; + } + } + else + { + nearestAdaptPatch[faceI] = faceData[faceI].data(); + } } } + else + { + // Use patch 0 + nearestAdaptPatch.setSize(mesh_.nFaces(), 0); + } return nearestAdaptPatch; } From 5614e6f3d20ab3aebf80f6f54c1cfd1c99f4953a Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 23 May 2014 12:10:59 +0100 Subject: [PATCH 2/8] ENH: merging lagrangian developments from internal line - also resolves mantis #1304 --- .../KinematicParcel/KinematicParcel.C | 2 +- .../KinematicParcel/KinematicParcelIO.C | 35 ++++--------------- .../Templates/ThermoParcel/ThermoParcelIO.C | 18 ++++------ 3 files changed, 13 insertions(+), 42 deletions(-) diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C index eee3b7e8..4f45e019 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C @@ -275,7 +275,7 @@ bool Foam::KinematicParcel::move const scalar maxCo = td.cloud().solution().maxCo(); scalar tEnd = (1.0 - p.stepFraction())*trackTime; - const scalar dtMax = tEnd; + const scalar dtMax = maxCo*trackTime; bool tracking = true; label nTrackingStalled = 0; diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C index 281cf4ef..5bcd2242 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -76,20 +76,8 @@ Foam::KinematicParcel::KinematicParcel } else { - is.read - ( - reinterpret_cast(&active_), - sizeof(active_) - + sizeof(typeId_) - + sizeof(nParticle_) - + sizeof(d_) - + sizeof(dTarget_) - + sizeof(U_) - + sizeof(rho_) - + sizeof(age_) - + sizeof(tTurb_) - + sizeof(UTurb_) - ); + label size = long(&UTurb_) - long(&active_) + sizeof(UTurb_); + is.read(reinterpret_cast(&active_), size); } } @@ -248,20 +236,9 @@ Foam::Ostream& Foam::operator<< else { os << static_cast(p); - os.write - ( - reinterpret_cast(&p.active_), - sizeof(p.active()) - + sizeof(p.typeId()) - + sizeof(p.nParticle()) - + sizeof(p.d()) - + sizeof(p.dTarget()) - + sizeof(p.U()) - + sizeof(p.rho()) - + sizeof(p.age()) - + sizeof(p.tTurb()) - + sizeof(p.UTurb()) - ); + + label size = long(&p.UTurb_) - long(&p.active_) + sizeof(p.UTurb_); + os.write(reinterpret_cast(&p.active_), size); } // Check state of Ostream diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C index b2d39891..73621467 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -58,12 +58,8 @@ Foam::ThermoParcel::ThermoParcel } else { - is.read - ( - reinterpret_cast(&T_), - + sizeof(T_) - + sizeof(Cp_) - ); + label size = long(&Cp_) - long(&T_) + sizeof(Cp_); + is.read(reinterpret_cast(&T_), size); } } @@ -149,11 +145,9 @@ Foam::Ostream& Foam::operator<< else { os << static_cast(p); - os.write - ( - reinterpret_cast(&p.T_), - sizeof(p.T()) + sizeof(p.Cp()) - ); + + label size = long(&p.Cp_) - long(&p.T_) + sizeof(p.Cp_); + os.write(reinterpret_cast(&p.T_), size); } // Check state of Ostream From 9cfc6e5c464bfbd041922256b1309505ad741219 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 27 May 2014 15:41:13 +0100 Subject: [PATCH 3/8] STYLE: dynamicRefineFvMesh: typo --- src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C index 92b71171..201e62b7 100644 --- a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C +++ b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C @@ -1167,7 +1167,7 @@ Foam::dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) } Info<< "Detected " << returnReduce(nProtected, sumOp