From f815a6bba4dd5f0511c8befbbe9578eb843112cc Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 15 Nov 2013 20:05:18 +0000 Subject: [PATCH 01/21] ENH: pointToPointPlanar: added comment --- .../pointToPointPlanarInterpolation.C | 32 +++++++++++++++++++ .../triSurfaceTools/triSurfaceTools.C | 8 ++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C index bc1402bd7a..a850308c6e 100644 --- a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C +++ b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C @@ -209,6 +209,38 @@ void Foam::pointToPointPlanarInterpolation::calcWeights nearestVertex_, nearestVertexWeight_ ); + + //if (debug) + //{ + // forAll(sourcePoints, i) + // { + // Pout<< "source:" << i << " at:" << sourcePoints[i] + // << " 2d:" << localVertices[i] + // << endl; + // } + // + // + // forAll(destPoints, i) + // { + // label v0 = nearestVertex_[i][0]; + // label v1 = nearestVertex_[i][1]; + // label v2 = nearestVertex_[i][2]; + // + // Pout<< "For location " << destPoints[i] + // << " 2d:" << localFaceCentres[i] + // << " sampling vertices" << nl + // << " " << v0 + // << " at:" << sourcePoints[v0] + // << " weight:" << nearestVertexWeight_[i][0] << nl + // << " " << v1 + // << " at:" << sourcePoints[v1] + // << " weight:" << nearestVertexWeight_[i][1] << nl + // << " " << v2 + // << " at:" << sourcePoints[v2] + // << " weight:" << nearestVertexWeight_[i][2] << nl + // << endl; + // } + //} } diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C index 96794adaac..0f6d31c998 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -2745,6 +2745,12 @@ void Foam::triSurfaceTools::calcInterpolationWeights calcInterpolationWeights(tri, nearest.rawPoint(), weights); + //Pout<< "calcScalingFactors : samplePt:" << samplePt + // << " distance:" << nearest.distance() + // << " to verts:" << verts + // << " weights:" << weights + // << endl; + break; } } From c3a172468447518f73a38dc9377c0588ab3d4733 Mon Sep 17 00:00:00 2001 From: mattijs Date: Sat, 16 Nov 2013 20:07:31 +0000 Subject: [PATCH 02/21] ENH: timeVaryingMapped: use value if provided --- .../timeVaryingMappedFixedValuePointPatchField.C | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C index edcd775d3a..547e1d850d 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C @@ -103,7 +103,18 @@ timeVaryingMappedFixedValuePointPatchField endAverage_(pTraits::zero) { dict.readIfPresent("fieldTableName", fieldTableName_); - updateCoeffs(); + + if (dict.found("value")) + { + fixedValuePointPatchField::operator== + ( + Field("value", dict, p.size()) + ); + } + else + { + updateCoeffs(); + } } From 5dea505798e3479f2ec9f0296287796b20753d8f Mon Sep 17 00:00:00 2001 From: mattijs Date: Sat, 16 Nov 2013 20:09:33 +0000 Subject: [PATCH 03/21] BUG: displacementLaplacianMotionSolver: startup evaluation of point bcs (since not solved for) --- .../displacementLaplacianFvMotionSolver.C | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C index 35db99fe0d..0fec1e8856 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -88,6 +88,24 @@ Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver : -1 ) { + if (debug) + { + Info<< "displacementLaplacianFvMotionSolver:" << nl + << " diffusivity : " << diffusivityPtr_().type() << nl + << " frozenPoints zone : " << frozenPointsZone_ << endl; + } + + // Weird one: if using bc on pointDisplacement that updateCoeffs() + // at construction time: + // - read pointDisplacement, some bcs do updateCoeffs + // - time gets incremented + // - laplacianMotionSolver::solve() : now uses (old!) bc values + // - laplacianMotionSolver::curPoints() : finally does + // pointDisplacement::correctBoundaryConditions + // So first iteration uses old values (but future ones are ok) + // So: + pointDisplacement_.correctBoundaryConditions(); + IOobject io ( "pointLocation", @@ -97,13 +115,6 @@ Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver IOobject::AUTO_WRITE ); - if (debug) - { - Info<< "displacementLaplacianFvMotionSolver:" << nl - << " diffusivity : " << diffusivityPtr_().type() << nl - << " frozenPoints zone : " << frozenPointsZone_ << endl; - } - if (io.headerOk()) { From 474785b8e7d50b75b7cbcb59392282efd2784980 Mon Sep 17 00:00:00 2001 From: mattijs Date: Sat, 16 Nov 2013 20:23:36 +0000 Subject: [PATCH 04/21] Revert "BUG: displacementLaplacianMotionSolver: startup evaluation of point bcs (since not solved for)" This reverts commit 5dea505798e3479f2ec9f0296287796b20753d8f. --- .../displacementLaplacianFvMotionSolver.C | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C index 0fec1e8856..35db99fe0d 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.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-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -88,24 +88,6 @@ Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver : -1 ) { - if (debug) - { - Info<< "displacementLaplacianFvMotionSolver:" << nl - << " diffusivity : " << diffusivityPtr_().type() << nl - << " frozenPoints zone : " << frozenPointsZone_ << endl; - } - - // Weird one: if using bc on pointDisplacement that updateCoeffs() - // at construction time: - // - read pointDisplacement, some bcs do updateCoeffs - // - time gets incremented - // - laplacianMotionSolver::solve() : now uses (old!) bc values - // - laplacianMotionSolver::curPoints() : finally does - // pointDisplacement::correctBoundaryConditions - // So first iteration uses old values (but future ones are ok) - // So: - pointDisplacement_.correctBoundaryConditions(); - IOobject io ( "pointLocation", @@ -115,6 +97,13 @@ Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver IOobject::AUTO_WRITE ); + if (debug) + { + Info<< "displacementLaplacianFvMotionSolver:" << nl + << " diffusivity : " << diffusivityPtr_().type() << nl + << " frozenPoints zone : " << frozenPointsZone_ << endl; + } + if (io.headerOk()) { From 867d5088a76e331c70a046ee928f185bcec0f1a2 Mon Sep 17 00:00:00 2001 From: mattijs Date: Sun, 17 Nov 2013 19:21:32 +0000 Subject: [PATCH 05/21] BUG: timeVaryingMapped: enforce re-evaluation when not providing initial values --- .../timeVaryingMappedFixedValueFvPatchField.C | 6 +++++- .../timeVaryingMappedFixedValuePointPatchField.C | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C index df9c571397..a7205577f3 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C @@ -120,7 +120,11 @@ timeVaryingMappedFixedValueFvPatchField } else { - updateCoeffs(); + // Note: we use evaluate() here to trigger updateCoeffs followed + // by re-setting of fvatchfield::updated_ flag. This is + // so if first use is in the next time step it retriggers + // a new update. + this->evaluate(Pstream::blocking); } } diff --git a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C index 547e1d850d..cf1b18b89d 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C @@ -113,7 +113,11 @@ timeVaryingMappedFixedValuePointPatchField } else { - updateCoeffs(); + // Note: use evaluate to do updateCoeffs followed by a reset + // of the pointPatchField::updated_ flag. This is + // so if first use is in the next time step it retriggers + // a new update. + pointPatchField::evaluate(Pstream::blocking); } } From ae41b74b57aad35c56c6d2f7bd2f4b91e9d1034b Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 18 Nov 2013 10:48:17 +0000 Subject: [PATCH 06/21] ENH: motionSmoother: encapsulate point calculation like motionSolver --- .../motionSmoother/motionSmoother.C | 151 +++++++++++------- .../motionSmoother/motionSmoother.H | 15 +- .../autoHexMeshDriver/autoLayerDriver.C | 4 +- .../autoHexMeshDriver/autoLayerDriver.H | 5 +- .../autoHexMeshDriver/autoLayerDriverShrink.C | 23 ++- 5 files changed, 117 insertions(+), 81 deletions(-) diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.C b/src/dynamicMesh/motionSmoother/motionSmoother.C index 3e87fbd7d5..1375099a4b 100644 --- a/src/dynamicMesh/motionSmoother/motionSmoother.C +++ b/src/dynamicMesh/motionSmoother/motionSmoother.C @@ -872,10 +872,8 @@ void Foam::motionSmoother::correctBoundaryConditions } -Foam::tmp Foam::motionSmoother::movePoints -( - pointField& newPoints -) + +void Foam::motionSmoother::modifyMotionPoints(pointField& newPoints) const { // Correct for 2-D motion if (twoDCorrector_.required()) @@ -892,8 +890,8 @@ Foam::tmp Foam::motionSmoother::movePoints const pointField& oldPoints = mesh_.points(); const edgeList& edges = mesh_.edges(); - const labelList& neIndices = twoDCorrector().normalEdgeIndices(); - const vector& pn = twoDCorrector().planeNormal(); + const labelList& neIndices = twoDCorrector_.normalEdgeIndices(); + const vector& pn = twoDCorrector_.planeNormal(); forAll(neIndices, i) { @@ -915,19 +913,19 @@ Foam::tmp Foam::motionSmoother::movePoints if (debug) { - Pout<< "motionSmoother::movePoints : testing sync of newPoints." + Pout<< "motionSmoother::modifyMotionPoints : testing sync of newPoints." << endl; testSyncPositions(newPoints, 1e-6*mesh_.bounds().mag()); } +} - // Move actual mesh points. Make sure to delete tetBasePtIs so it - // gets rebuilt. + +void Foam::motionSmoother::movePoints() +{ + // Make sure to clear out tetPtIs since used in checks (sometimes, should + // really check) mesh_.clearAdditionalGeom(); - tmp tsweptVol = mesh_.movePoints(newPoints); - pp_.movePoints(mesh_.points()); - - return tsweptVol; } @@ -983,6 +981,79 @@ bool Foam::motionSmoother::scaleMesh } +Foam::tmp Foam::motionSmoother::curPoints() const +{ + // Set newPoints as old + scale*displacement + + // Create overall displacement with same b.c.s as displacement_ + wordList actualPatchTypes; + { + const pointBoundaryMesh& pbm = displacement_.mesh().boundary(); + actualPatchTypes.setSize(pbm.size()); + forAll(pbm, patchI) + { + actualPatchTypes[patchI] = pbm[patchI].type(); + } + } + + wordList actualPatchFieldTypes; + { + const pointVectorField::GeometricBoundaryField& pfld = + displacement_.boundaryField(); + actualPatchFieldTypes.setSize(pfld.size()); + forAll(pfld, patchI) + { + if (isA >(pfld[patchI])) + { + // Get rid of funny + actualPatchFieldTypes[patchI] = + fixedValuePointPatchField::typeName; + } + else + { + actualPatchFieldTypes[patchI] = pfld[patchI].type(); + } + } + } + + pointVectorField totalDisplacement + ( + IOobject + ( + "totalDisplacement", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + scale_*displacement_, + actualPatchFieldTypes, + actualPatchTypes + ); + correctBoundaryConditions(totalDisplacement); + + if (debug) + { + Pout<< "scaleMesh : testing sync of totalDisplacement" << endl; + testSyncField + ( + totalDisplacement, + maxMagEqOp(), + vector::zero, // null value + 1e-6*mesh_.bounds().mag() + ); + } + + tmp tnewPoints(oldPoints_ + totalDisplacement.internalField()); + + // Correct for 2-D motion + modifyMotionPoints(tnewPoints()); + + return tnewPoints; +} + + bool Foam::motionSmoother::scaleMesh ( labelList& checkFaces, @@ -1052,60 +1123,18 @@ bool Foam::motionSmoother::scaleMesh vector::zero // null value ); - // Set newPoints as old + scale*displacement - pointField newPoints; - { - // Create overall displacement with same b.c.s as displacement_ - wordList actualPatchTypes; - { - const pointBoundaryMesh& pbm = displacement_.mesh().boundary(); - actualPatchTypes.setSize(pbm.size()); - forAll(pbm, patchI) - { - actualPatchTypes[patchI] = pbm[patchI].type(); - } - } - - pointVectorField totalDisplacement - ( - IOobject - ( - "totalDisplacement", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - scale_*displacement_, - displacement_.boundaryField().types(), - actualPatchTypes - ); - correctBoundaryConditions(totalDisplacement); - - if (debug) - { - Pout<< "scaleMesh : testing sync of totalDisplacement" << endl; - testSyncField - ( - totalDisplacement, - maxMagEqOp(), - vector::zero, // null value - 1e-6*mesh_.bounds().mag() - ); - } - - newPoints = oldPoints_ + totalDisplacement.internalField(); - } - Info<< "Moving mesh using displacement scaling :" << " min:" << gMin(scale_.internalField()) << " max:" << gMax(scale_.internalField()) << endl; + // Get points using current displacement and scale. Optionally 2D corrected. + pointField newPoints(curPoints()); + + // Move. No need to do 2D correction since curPoints already done that. + mesh_.movePoints(newPoints); + movePoints(); - // Move - movePoints(newPoints); // Check. Returns parallel number of incorrect faces. faceSet wrongFaces(mesh_, "wrongFaces", mesh_.nFaces()/100+100); diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.H b/src/dynamicMesh/motionSmoother/motionSmoother.H index fff07c4b94..33bb2835e2 100644 --- a/src/dynamicMesh/motionSmoother/motionSmoother.H +++ b/src/dynamicMesh/motionSmoother/motionSmoother.H @@ -403,9 +403,11 @@ public: // bc's. void correctBoundaryConditions(pointVectorField&) const; - //- Move mesh. Does 2D correction (modifies passed pointField) and - // polyMesh::movePoints. Returns swept volumes. - tmp movePoints(pointField&); + //- Apply optional point constraint (2d correction) + void modifyMotionPoints(pointField& newPoints) const; + + //- Get the current points (oldPoints+scale*displacement) + tmp curPoints() const; //- Set the errorReduction (by how much to scale the displacement // at error locations) parameter. Returns the old value. @@ -446,9 +448,14 @@ public: const label nAllow = 0 ); - //- Update topology + + //- Update for new mesh geometry + void movePoints(); + + //- Update for new mesh topology void updateMesh(); + //- Check mesh with mesh settings in dict. Collects incorrect faces // in set. Returns true if one or more faces in error. // Parallel ok. diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index 316d376def..1dcafdec3e 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -3522,7 +3522,9 @@ void Foam::autoLayerDriver::addLayers } // Reset mesh points and start again - meshMover().movePoints(oldPoints); + mesh.movePoints(oldPoints); + // Update meshmover for change of mesh geometry + meshMover().movePoints(); meshMover().correct(); diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H index 58464ad495..72c62020a0 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H @@ -58,7 +58,9 @@ class layerParameters; class autoLayerDriver { - // Static data members +public: + + // Public data types //- Extrusion controls enum extrudeMode @@ -69,6 +71,7 @@ class autoLayerDriver /*!< faces locally */ }; +private: // Private classes diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C index 328b4fd86a..3349a5f8b6 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C @@ -1756,19 +1756,10 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance Info<< "Writing wanted-displacement mesh (possibly illegal) to " << meshRefiner_.timeName() << endl; pointField oldPoints(mesh.points()); - vectorField totalDisp - ( - meshMover.scale().internalField() - * displacement.internalField() - ); - syncTools::syncPointList - ( - mesh, - totalDisp, - minMagSqrEqOp(), - vector(GREAT, GREAT, GREAT) - ); - meshMover.movePoints((mesh.points()+totalDisp)()); + + meshRefiner_.mesh().movePoints(meshMover.curPoints()); + // Warn meshMover for changed geometry + meshMover.movePoints(); // Above move will have changed the instance only on the points (which // is correct). @@ -1791,7 +1782,11 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance dispVec.write(); medialDist.write(); medialRatio.write(); - meshMover.movePoints(oldPoints); + + // Move mesh back + meshRefiner_.mesh().movePoints(oldPoints); + // Warn meshMover for changed geometry + meshMover.movePoints(); } From 26a9e37810ae69f41dae4db3393cb8f2705522ab Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 18 Nov 2013 14:51:01 +0000 Subject: [PATCH 07/21] STYLE: autoLayerDriver: typo in comment --- .../autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index 1dcafdec3e..d859cf89a9 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -833,7 +833,7 @@ Foam::autoLayerDriver::makeLayerDisplacementField forAll(numLayers, patchI) { - // 0 layers: do not allow lslip so fixedValue 0 + // 0 layers: do not allow slip so fixedValue 0 // >0 layers: fixedValue which gets adapted if (numLayers[patchI] >= 0) { From c515e42acff9b611afcf81442357dcef08a0fca4 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 18 Nov 2013 15:00:09 +0000 Subject: [PATCH 08/21] ENH: thermalBaffle1D: fatalIOerror instead of fatalError --- .../thermalBaffle1DFvPatchScalarField.C | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C index 8cd35c5166..51c250db5c 100644 --- a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C @@ -231,15 +231,15 @@ baffleThickness() const { if (thickness_.size() != patch().size()) { - FatalErrorIn + FatalIOErrorIn ( " template" " tmp thermalBaffle1DFvPatchScalarField - " baffleThickness() const" + " baffleThickness() const", + solidDict_ )<< " Field thickness has not been specified " << " for patch " << this->patch().name() - << " in dictionary " << solidDict_ - << abort(FatalError); + << exit(FatalIOError); } return thickness_; @@ -302,10 +302,15 @@ void thermalBaffle1DFvPatchScalarField::autoMap ) { mixedFvPatchScalarField::autoMap(m); - thickness_.autoMap(m); - Qs_.autoMap(m); + + if (this->owner()) + { + thickness_.autoMap(m); + Qs_.autoMap(m); + } } + template void thermalBaffle1DFvPatchScalarField::rmap ( From fe31693e30c28de39fd3b668fdbb58b834255544 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 18 Nov 2013 15:03:46 +0000 Subject: [PATCH 09/21] ENH: createBafflesDict: more comment --- .../createBaffles/createBafflesDict | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBafflesDict b/applications/utilities/mesh/manipulation/createBaffles/createBafflesDict index 27ff9d287e..a9dae64b47 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBafflesDict +++ b/applications/utilities/mesh/manipulation/createBaffles/createBafflesDict @@ -19,13 +19,18 @@ FoamFile // - or converting boundary faces into a boundary face // (internalFacesOnly=false)(though should use really createPatch // to do this) -// - can also create duplicate (overlapping) sets of baffles: -// - internalFacesOnly = false -// - have 4 entries in patches: -// - master -// - slave -// - additional master -// - additional slave +// - specification in one of two modes: +// - patchPairs : create two patches of same type, same input +// - patches : create patches separately, full control over what +// to create on what side +// (this mode can also create duplicate (overlapping) +// sets of baffles: +// - internalFacesOnly = false +// - have 4 entries in patches: +// - master +// - slave +// - additional master +// - additional slave) // Whether to convert internal faces only (so leave boundary faces intact). From 9e7e371d6fe333979609a36e4c16952472c68f11 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 19 Nov 2013 15:38:31 +0000 Subject: [PATCH 10/21] STYLE: thermalBaffle1D: typo --- .../thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C index 51c250db5c..490bec5c71 100644 --- a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C @@ -234,7 +234,7 @@ baffleThickness() const FatalIOErrorIn ( " template" - " tmp thermalBaffle1DFvPatchScalarField + " tmp thermalBaffle1DFvPatchScalarField" " baffleThickness() const", solidDict_ )<< " Field thickness has not been specified " From db4852117d9554b1ce5106c7f5ff3dd1cd83569e Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 19 Nov 2013 17:03:04 +0000 Subject: [PATCH 11/21] COMP: outputFilterControl: const access --- .../outputFilterOutputControl.H | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.H b/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.H index e27a2507d2..240ec43645 100644 --- a/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.H +++ b/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.H @@ -56,12 +56,12 @@ public: //- The output control options enum outputControls { - ocTimeStep, /*!< execution is coupled to the time-step */ - ocOutputTime, /*!< execution is coupled to the output-time */ + ocTimeStep, /*!< execution is coupled to the time-step */ + ocOutputTime, /*!< execution is coupled to the output-time */ ocAdjustableTime, /*!< Adjust time step for dumping */ ocRunTime, /*!< run time for dumping */ ocClockTime, /*!< clock time for dumping */ - ocCpuTime /*!< cpu time for dumping */ + ocCpuTime /*!< cpu time for dumping */ }; @@ -82,7 +82,7 @@ private: // a value <= 1 means execute at every time step label outputInterval_; - //- Dumping counter for ocOutputTime + //- Dumping counter for ocOutputTime or index dump for ocAdjustableTime label outputTimeLastDump_; //- Dump each deltaT (adjust Ttime) @@ -123,19 +123,19 @@ public: bool output(); //- Return outputControl - outputControls outputControl() + outputControls outputControl() const { return outputControl_; } //- Return writeInterval - scalar writeInterval() + scalar writeInterval() const { return writeInterval_; } //- Return outputTimeLastDump - label outputTimeLastDump() + label outputTimeLastDump() const { return outputTimeLastDump_; } From 19a046ed8c99e389403567688850286d05cb2525 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 20 Nov 2013 10:35:32 +0000 Subject: [PATCH 12/21] ENH: DataEntry: disallow recursive lookup --- .../primitives/functions/DataEntry/DataEntry/DataEntryNew.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C index dfbb95674b..8a355ca9a6 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,7 +34,7 @@ Foam::autoPtr > Foam::DataEntry::New const dictionary& dict ) { - Istream& is(dict.lookup(entryName)); + Istream& is(dict.lookup(entryName, false)); token firstToken(is); From d8d17a0476a6bd326d34d30602b9d794d2578511 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 20 Nov 2013 10:36:22 +0000 Subject: [PATCH 13/21] ENH: setTimeStep: new functionObject --- .../functionObjects/utilities/Make/files | 2 + .../setTimeStep/setTimeStepFunctionObject.C | 152 +++++++++++++++++ .../setTimeStep/setTimeStepFunctionObject.H | 159 ++++++++++++++++++ 3 files changed, 313 insertions(+) create mode 100644 src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C create mode 100644 src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index 01b4d0c4c9..f711fc0880 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -36,4 +36,6 @@ yPlusLES/yPlusLESFunctionObject.C yPlusRAS/yPlusRAS.C yPlusRAS/yPlusRASFunctionObject.C +setTimeStep/setTimeStepFunctionObject.C + LIB = $(FOAM_LIBBIN)/libutilityFunctionObjects diff --git a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C new file mode 100644 index 0000000000..a8d540771b --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "setTimeStepFunctionObject.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(setTimeStepFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + setTimeStepFunctionObject, + dictionary + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::setTimeStepFunctionObject::setTimeStepFunctionObject +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + functionObject(name), + time_(runTime), + enabled_(true) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::setTimeStepFunctionObject::on() +{ + enabled_ = true; +} + + +void Foam::setTimeStepFunctionObject::off() +{ + enabled_ = false; +} + + +bool Foam::setTimeStepFunctionObject::start() +{ + return true; +} + + +bool Foam::setTimeStepFunctionObject::execute(const bool forceWrite) +{ + return true; +} + + +bool Foam::setTimeStepFunctionObject::end() +{ + return true; +} + + +bool Foam::setTimeStepFunctionObject::timeSet() +{ + return true; +} + + +bool Foam::setTimeStepFunctionObject::adjustTimeStep() +{ + if (enabled()) + { + // Wanted timestep + scalar newDeltaT = timeStepPtr_().value(time_.timeOutputValue()); + + const_cast(time()).setDeltaT(newDeltaT, false); + + return true; + } + else + { + return false; + } +} + + +bool Foam::setTimeStepFunctionObject::read(const dictionary& dict) +{ + enabled_ = dict.lookupOrDefault("enabled", true); + + if (enabled_) + { + timeStepPtr_ = DataEntry::New("deltaT", dict); + + // Check that time has adjustTimeStep + const dictionary& controlDict = time_.controlDict(); + + Switch adjust; + if + ( + !controlDict.readIfPresent("adjustTimeStep", adjust) + || !adjust + ) + { + FatalIOErrorIn("setTimeStep::read(const dictionary&)", dict) + << "Need to have 'adjustTimeStep' true to enable external" + << " timestep control" << exit(FatalIOError); + } + } + return true; +} + + +void Foam::setTimeStepFunctionObject::updateMesh(const mapPolyMesh& mpm) +{} + + +void Foam::setTimeStepFunctionObject::movePoints(const polyMesh& mesh) +{} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H new file mode 100644 index 0000000000..3f03f3ddcc --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H @@ -0,0 +1,159 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::setTimeStepFunctionObject + +Group + grpUtilitiesFunctionObjects + +Description + Overrides the timeStep. Can only be used with + solvers with adjustTimeStep control (e.g. pimpleFoam). Makes no attempt + to cooperate with other timeStep 'controllers' (maxCo, other + functionObjects). Supports 'enabled' flag but none of othe other ones + 'timeStart', 'timeEnd', 'outputControl' etc. + +SourceFiles + setTimeStepFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef setTimeStepFunctionObject_H +#define setTimeStepFunctionObject_H + +#include "functionObject.H" +#include "dictionary.H" +#include "DataEntry.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class setTimeStepFunctionObject Declaration +\*---------------------------------------------------------------------------*/ + +class setTimeStepFunctionObject +: + public functionObject +{ + // Private data + + //- Reference to the time database + const Time& time_; + + + // Optional user inputs + + //- Switch for the execution - defaults to 'yes/on' + bool enabled_; + + //- Time step + autoPtr > timeStepPtr_; + + + //- Disallow default bitwise copy construct + setTimeStepFunctionObject(const setTimeStepFunctionObject&); + + //- Disallow default bitwise assignment + void operator=(const setTimeStepFunctionObject&); + + +public: + //- Runtime type information + TypeName("setTimeStep"); + + // Constructors + + //- Construct from components + setTimeStepFunctionObject + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + + // Member Functions + + // Access + + //- Return time database + virtual const Time& time() const + { + return time_; + } + + //- Return the enabled flag + virtual bool enabled() const + { + return enabled_; + } + + + // Function object control + + //- Switch the function object on + virtual void on(); + + //- Switch the function object off + virtual void off(); + + + //- Called at the start of the time-loop + virtual bool start(); + + //- Called at each ++ or += of the time-loop + virtual bool execute(const bool forceWrite); + + //- Called when Time::run() determines that the time-loop exits + virtual bool end(); + + //- Called when time was set at the end of the Time::operator++ + virtual bool timeSet(); + + //- Called at the end of Time::adjustDeltaT() if adjustTime is true + virtual bool adjustTimeStep(); + + //- Read and set the function object if its data have changed + virtual bool read(const dictionary&); + + //- Update for changes of mesh + virtual void updateMesh(const mapPolyMesh& mpm); + + //- Update for changes of mesh + virtual void movePoints(const polyMesh& mesh); + +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From d6787315d0fcd668a429a78f6c44c82f8de72ef8 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 20 Nov 2013 11:04:28 +0000 Subject: [PATCH 14/21] GIT: motionSmoother: rename --- .../motionSmoother/{motionSmoother.C => motionSmootherAlgo.C} | 0 .../motionSmoother/{motionSmoother.H => motionSmootherAlgo.H} | 0 .../{motionSmootherCheck.C => motionSmootherAlgoCheck.C} | 0 .../{motionSmootherTemplates.C => motionSmootherAlgoTemplates.C} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/dynamicMesh/motionSmoother/{motionSmoother.C => motionSmootherAlgo.C} (100%) rename src/dynamicMesh/motionSmoother/{motionSmoother.H => motionSmootherAlgo.H} (100%) rename src/dynamicMesh/motionSmoother/{motionSmootherCheck.C => motionSmootherAlgoCheck.C} (100%) rename src/dynamicMesh/motionSmoother/{motionSmootherTemplates.C => motionSmootherAlgoTemplates.C} (100%) diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.C b/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C similarity index 100% rename from src/dynamicMesh/motionSmoother/motionSmoother.C rename to src/dynamicMesh/motionSmoother/motionSmootherAlgo.C diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.H b/src/dynamicMesh/motionSmoother/motionSmootherAlgo.H similarity index 100% rename from src/dynamicMesh/motionSmoother/motionSmoother.H rename to src/dynamicMesh/motionSmoother/motionSmootherAlgo.H diff --git a/src/dynamicMesh/motionSmoother/motionSmootherCheck.C b/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C similarity index 100% rename from src/dynamicMesh/motionSmoother/motionSmootherCheck.C rename to src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C diff --git a/src/dynamicMesh/motionSmoother/motionSmootherTemplates.C b/src/dynamicMesh/motionSmoother/motionSmootherAlgoTemplates.C similarity index 100% rename from src/dynamicMesh/motionSmoother/motionSmootherTemplates.C rename to src/dynamicMesh/motionSmoother/motionSmootherAlgoTemplates.C From b1441a85e3025041e15717e75116cf70ecfec20c Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 20 Nov 2013 11:12:25 +0000 Subject: [PATCH 15/21] ENH: motionSmoother: split into storage and algorithm --- src/dynamicMesh/Make/files | 4 +- .../motionSmoother/motionSmoother.C | 86 ++++++++ .../motionSmoother/motionSmoother.H | 137 ++++++++++++ .../motionSmoother/motionSmootherAlgo.C | 199 +++++------------- .../motionSmoother/motionSmootherAlgo.H | 99 ++++----- .../motionSmoother/motionSmootherAlgoCheck.C | 12 +- .../motionSmootherAlgoTemplates.C | 16 +- .../motionSmoother/motionSmootherData.C | 124 +++++++++++ .../motionSmoother/motionSmootherData.H | 106 ++++++++++ 9 files changed, 565 insertions(+), 218 deletions(-) create mode 100644 src/dynamicMesh/motionSmoother/motionSmoother.C create mode 100644 src/dynamicMesh/motionSmoother/motionSmoother.H create mode 100644 src/dynamicMesh/motionSmoother/motionSmootherData.C create mode 100644 src/dynamicMesh/motionSmoother/motionSmootherData.H diff --git a/src/dynamicMesh/Make/files b/src/dynamicMesh/Make/files index f769607f94..c9c748ec4a 100644 --- a/src/dynamicMesh/Make/files +++ b/src/dynamicMesh/Make/files @@ -84,7 +84,9 @@ polyMeshAdder/polyMeshAdder.C fvMeshTools/fvMeshTools.C motionSmoother/motionSmoother.C -motionSmoother/motionSmootherCheck.C +motionSmoother/motionSmootherAlgo.C +motionSmoother/motionSmootherAlgoCheck.C +motionSmoother/motionSmootherData.C motionSmoother/polyMeshGeometry/polyMeshGeometry.C motionSmoother/badQualityToCell/badQualityToCell.C motionSmoother/badQualityToFace/badQualityToFace.C diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.C b/src/dynamicMesh/motionSmoother/motionSmoother.C new file mode 100644 index 0000000000..d30ee35732 --- /dev/null +++ b/src/dynamicMesh/motionSmoother/motionSmoother.C @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "motionSmoother.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(motionSmoother, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::motionSmoother::motionSmoother +( + polyMesh& mesh, + pointMesh& pMesh, + indirectPrimitivePatch& pp, + const labelList& adaptPatchIDs, + const dictionary& paramDict +) +: + motionSmootherData(pMesh), + motionSmootherAlgo + ( + mesh, + pMesh, + pp, + motionSmootherData::displacement_, + motionSmootherData::scale_, + motionSmootherData::oldPoints_, + adaptPatchIDs, + paramDict + ) +{} + + +Foam::motionSmoother::motionSmoother +( + polyMesh& mesh, + indirectPrimitivePatch& pp, + const labelList& adaptPatchIDs, + const pointVectorField& displacement, + const dictionary& paramDict +) +: + motionSmootherData(displacement), + motionSmootherAlgo + ( + mesh, + const_cast(displacement.mesh()), + pp, + motionSmootherData::displacement_, + motionSmootherData::scale_, + motionSmootherData::oldPoints_, + adaptPatchIDs, + paramDict + ) +{} + + +// ************************************************************************* // diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.H b/src/dynamicMesh/motionSmoother/motionSmoother.H new file mode 100644 index 0000000000..3366f01d05 --- /dev/null +++ b/src/dynamicMesh/motionSmoother/motionSmoother.H @@ -0,0 +1,137 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::motionSmoother + +Description + Given a displacement moves the mesh by scaling the displacement back + until there are no more mesh errors. + + Holds displacement field (read upon construction since need boundary + conditions) and scaling factor and optional patch number on which to + scale back displacement. + + E.g. + \verbatim + // Construct iterative mesh mover. + motionSmoother meshMover(mesh, labelList(1, patchI)); + + // Set desired displacement: + meshMover.displacement() = .. + + for (label iter = 0; iter < maxIter; iter++) + { + if (meshMover.scaleMesh(true)) + { + Info<< "Successfully moved mesh" << endl; + return true; + } + } + \endverbatim + +Note + - Shared points (parallel): a processor can have points which are part of + pp on another processor but have no pp itself (i.e. it has points + and/or edges but no faces of pp). Hence we have to be careful when e.g. + synchronising displacements that the value from the processor which has + faces of pp get priority. This is currently handled in setDisplacement + by resetting the internal displacement to zero before doing anything + else. The combine operator used will give preference to non-zero + values. + + - Various routines take baffles. These are sets of boundary faces that + are treated as a single internal face. This is a hack used to apply + movement to internal faces. + + - Mesh constraints are looked up from the supplied dictionary. (uses + recursive lookup) + +SourceFiles + motionSmoother.C + +\*---------------------------------------------------------------------------*/ + +#ifndef motionSmoother_H +#define motionSmoother_H + +#include "motionSmootherData.H" +#include "motionSmootherAlgo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class motionSmoother Declaration +\*---------------------------------------------------------------------------*/ + +class motionSmoother +: + public motionSmootherData, + public motionSmootherAlgo + +{ + // Private class + +public: + + ClassName("motionSmoother"); + + // Constructors + + //- Construct from mesh, patches to work on and smoothing parameters. + // Reads displacement field (only boundary conditions used) + motionSmoother + ( + polyMesh&, + pointMesh&, + indirectPrimitivePatch& pp, // 'outside' points + const labelList& adaptPatchIDs, // patches forming 'outside' + const dictionary& paramDict + ); + + //- Construct from mesh, patches to work on and smoothing parameters and + // displacementfield (only boundary conditions used) + motionSmoother + ( + polyMesh&, + indirectPrimitivePatch& pp, // 'outside' points + const labelList& adaptPatchIDs, // patches forming 'outside' + const pointVectorField&, + const dictionary& paramDict + ); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C b/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C index 1375099a4b..ad0fcac3fa 100644 --- a/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C +++ b/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C @@ -23,7 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "motionSmoother.H" +#include "motionSmootherAlgo.H" #include "twoDPointCorrector.H" #include "faceSet.H" #include "pointSet.H" @@ -37,13 +37,13 @@ License namespace Foam { - defineTypeNameAndDebug(motionSmoother, 0); + defineTypeNameAndDebug(motionSmootherAlgo, 0); } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::motionSmoother::testSyncPositions +void Foam::motionSmootherAlgo::testSyncPositions ( const pointField& fld, const scalar maxMag @@ -65,7 +65,7 @@ void Foam::motionSmoother::testSyncPositions { FatalErrorIn ( - "motionSmoother::testSyncPositions" + "motionSmootherAlgo::testSyncPositions" "(" "const pointField&, " "const scalar" @@ -78,7 +78,7 @@ void Foam::motionSmoother::testSyncPositions } -//Foam::tmp Foam::motionSmoother::sumWeights +//Foam::tmp Foam::motionSmootherAlgo::sumWeights //( // const scalarField& edgeWeight //) const @@ -122,11 +122,11 @@ void Foam::motionSmoother::testSyncPositions // From pointPatchInterpolation -void Foam::motionSmoother::makePatchPatchAddressing() +void Foam::motionSmootherAlgo::makePatchPatchAddressing() { if (debug) { - Pout<< "motionSmoother::makePatchPatchAddressing() : " + Pout<< "motionSmootherAlgo::makePatchPatchAddressing() : " << "constructing boundary addressing" << endl; } @@ -232,14 +232,14 @@ void Foam::motionSmoother::makePatchPatchAddressing() meshTools::writeOBJ(str, mesh_.points()[pointI]); } - Pout<< "motionSmoother::makePatchPatchAddressing() : " + Pout<< "motionSmootherAlgo::makePatchPatchAddressing() : " << "finished constructing boundary addressing" << endl; } } -void Foam::motionSmoother::checkFld(const pointScalarField& fld) +void Foam::motionSmootherAlgo::checkFld(const pointScalarField& fld) { forAll(fld, pointI) { @@ -249,15 +249,18 @@ void Foam::motionSmoother::checkFld(const pointScalarField& fld) {} else { - FatalErrorIn("motionSmoother::checkFld(const pointScalarField&)") - << "Problem : point:" << pointI << " value:" << val + FatalErrorIn + ( + "motionSmootherAlgo::checkFld" + "(const pointScalarField&)" + ) << "Problem : point:" << pointI << " value:" << val << abort(FatalError); } } } -Foam::labelHashSet Foam::motionSmoother::getPoints +Foam::labelHashSet Foam::motionSmootherAlgo::getPoints ( const labelHashSet& faceLabels ) const @@ -278,7 +281,7 @@ Foam::labelHashSet Foam::motionSmoother::getPoints } -Foam::tmp Foam::motionSmoother::calcEdgeWeights +Foam::tmp Foam::motionSmootherAlgo::calcEdgeWeights ( const pointField& points ) const @@ -297,7 +300,7 @@ Foam::tmp Foam::motionSmoother::calcEdgeWeights // Smooth on selected points (usually patch points) -void Foam::motionSmoother::minSmooth +void Foam::motionSmootherAlgo::minSmooth ( const scalarField& edgeWeights, const PackedBoolList& isAffectedPoint, @@ -332,7 +335,7 @@ void Foam::motionSmoother::minSmooth // Smooth on all internal points -void Foam::motionSmoother::minSmooth +void Foam::motionSmootherAlgo::minSmooth ( const scalarField& edgeWeights, const PackedBoolList& isAffectedPoint, @@ -365,7 +368,7 @@ void Foam::motionSmoother::minSmooth // Scale on all internal points -void Foam::motionSmoother::scaleField +void Foam::motionSmootherAlgo::scaleField ( const labelHashSet& pointLabels, const scalar scale, @@ -385,7 +388,7 @@ void Foam::motionSmoother::scaleField // Scale on selected points (usually patch points) -void Foam::motionSmoother::scaleField +void Foam::motionSmootherAlgo::scaleField ( const labelList& meshPoints, const labelHashSet& pointLabels, @@ -406,7 +409,7 @@ void Foam::motionSmoother::scaleField // Lower on internal points -void Foam::motionSmoother::subtractField +void Foam::motionSmootherAlgo::subtractField ( const labelHashSet& pointLabels, const scalar f, @@ -426,7 +429,7 @@ void Foam::motionSmoother::subtractField // Scale on selected points (usually patch points) -void Foam::motionSmoother::subtractField +void Foam::motionSmootherAlgo::subtractField ( const labelList& meshPoints, const labelHashSet& pointLabels, @@ -446,13 +449,13 @@ void Foam::motionSmoother::subtractField } -bool Foam::motionSmoother::isInternalPoint(const label pointI) const +bool Foam::motionSmootherAlgo::isInternalPoint(const label pointI) const { return isInternalPoint_.get(pointI) == 1; } -void Foam::motionSmoother::getAffectedFacesAndPoints +void Foam::motionSmootherAlgo::getAffectedFacesAndPoints ( const label nPointIter, const faceSet& wrongFaces, @@ -510,11 +513,14 @@ void Foam::motionSmoother::getAffectedFacesAndPoints // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::motionSmoother::motionSmoother +Foam::motionSmootherAlgo::motionSmootherAlgo ( polyMesh& mesh, pointMesh& pMesh, indirectPrimitivePatch& pp, + pointVectorField& displacement, + pointScalarField& scale, + pointField& oldPoints, const labelList& adaptPatchIDs, const dictionary& paramDict ) @@ -522,81 +528,11 @@ Foam::motionSmoother::motionSmoother mesh_(mesh), pMesh_(pMesh), pp_(pp), + displacement_(displacement), + scale_(scale), + oldPoints_(oldPoints), adaptPatchIDs_(adaptPatchIDs), paramDict_(paramDict), - displacement_ - ( - IOobject - ( - "displacement", - mesh_.time().timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - pMesh_ - ), - scale_ - ( - IOobject - ( - "scale", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - pMesh_, - dimensionedScalar("scale", dimless, 1.0) - ), - oldPoints_(mesh_.points()), - isInternalPoint_(mesh_.nPoints(), 1), - twoDCorrector_(mesh_) -{ - updateMesh(); -} - - -Foam::motionSmoother::motionSmoother -( - polyMesh& mesh, - indirectPrimitivePatch& pp, - const labelList& adaptPatchIDs, - const pointVectorField& displacement, - const dictionary& paramDict -) -: - mesh_(mesh), - pMesh_(const_cast(displacement.mesh())), - pp_(pp), - adaptPatchIDs_(adaptPatchIDs), - paramDict_(paramDict), - displacement_ - ( - IOobject - ( - "displacement", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - displacement - ), - scale_ - ( - IOobject - ( - "scale", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - pMesh_, - dimensionedScalar("scale", dimless, 1.0) - ), - oldPoints_(mesh_.points()), isInternalPoint_(mesh_.nPoints(), 1), twoDCorrector_(mesh_) { @@ -606,67 +542,43 @@ Foam::motionSmoother::motionSmoother // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::motionSmoother::~motionSmoother() +Foam::motionSmootherAlgo::~motionSmootherAlgo() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -const Foam::polyMesh& Foam::motionSmoother::mesh() const +const Foam::polyMesh& Foam::motionSmootherAlgo::mesh() const { return mesh_; } -const Foam::pointMesh& Foam::motionSmoother::pMesh() const +const Foam::pointMesh& Foam::motionSmootherAlgo::pMesh() const { return pMesh_; } -const Foam::indirectPrimitivePatch& Foam::motionSmoother::patch() const +const Foam::indirectPrimitivePatch& Foam::motionSmootherAlgo::patch() const { return pp_; } -const Foam::labelList& Foam::motionSmoother::adaptPatchIDs() const +const Foam::labelList& Foam::motionSmootherAlgo::adaptPatchIDs() const { return adaptPatchIDs_; } -const Foam::dictionary& Foam::motionSmoother::paramDict() const +const Foam::dictionary& Foam::motionSmootherAlgo::paramDict() const { return paramDict_; } -Foam::pointVectorField& Foam::motionSmoother::displacement() -{ - return displacement_; -} - - -const Foam::pointVectorField& Foam::motionSmoother::displacement() const -{ - return displacement_; -} - - -const Foam::pointScalarField& Foam::motionSmoother::scale() const -{ - return scale_; -} - - -const Foam::pointField& Foam::motionSmoother::oldPoints() const -{ - return oldPoints_; -} - - -void Foam::motionSmoother::correct() +void Foam::motionSmootherAlgo::correct() { oldPoints_ = mesh_.points(); @@ -674,11 +586,11 @@ void Foam::motionSmoother::correct() // No need to update twoDmotion corrector since only holds edge labels // which will remain the same as before. So unless the mesh was distorted - // severely outside of motionSmoother there will be no need. + // severely outside of motionSmootherAlgo there will be no need. } -void Foam::motionSmoother::setDisplacementPatchFields() +void Foam::motionSmootherAlgo::setDisplacementPatchFields() { // Adapt the fixedValue bc's (i.e. copy internal point data to // boundaryField for all affected patches) @@ -742,7 +654,7 @@ void Foam::motionSmoother::setDisplacementPatchFields() } -void Foam::motionSmoother::setDisplacement(pointField& patchDisp) +void Foam::motionSmootherAlgo::setDisplacement(pointField& patchDisp) { // See comment in .H file about shared points. const polyBoundaryMesh& patches = mesh_.boundaryMesh(); @@ -808,7 +720,7 @@ void Foam::motionSmoother::setDisplacement(pointField& patchDisp) // correctBoundaryConditions with fixedValue bc's first. -void Foam::motionSmoother::correctBoundaryConditions +void Foam::motionSmootherAlgo::correctBoundaryConditions ( pointVectorField& displacement ) const @@ -873,7 +785,7 @@ void Foam::motionSmoother::correctBoundaryConditions -void Foam::motionSmoother::modifyMotionPoints(pointField& newPoints) const +void Foam::motionSmootherAlgo::modifyMotionPoints(pointField& newPoints) const { // Correct for 2-D motion if (twoDCorrector_.required()) @@ -882,7 +794,7 @@ void Foam::motionSmoother::modifyMotionPoints(pointField& newPoints) const if (mesh_.globalData().parallel()) { - WarningIn("motionSmoother::movePoints(pointField&)") + WarningIn("motionSmootherAlgo::movePoints(pointField&)") << "2D mesh-motion probably not correct in parallel" << endl; } @@ -913,14 +825,15 @@ void Foam::motionSmoother::modifyMotionPoints(pointField& newPoints) const if (debug) { - Pout<< "motionSmoother::modifyMotionPoints : testing sync of newPoints." + Pout<< "motionSmootherAlgo::modifyMotionPoints :" + << " testing sync of newPoints." << endl; testSyncPositions(newPoints, 1e-6*mesh_.bounds().mag()); } } -void Foam::motionSmoother::movePoints() +void Foam::motionSmootherAlgo::movePoints() { // Make sure to clear out tetPtIs since used in checks (sometimes, should // really check) @@ -929,7 +842,7 @@ void Foam::motionSmoother::movePoints() } -Foam::scalar Foam::motionSmoother::setErrorReduction +Foam::scalar Foam::motionSmootherAlgo::setErrorReduction ( const scalar errorReduction ) @@ -943,7 +856,7 @@ Foam::scalar Foam::motionSmoother::setErrorReduction } -bool Foam::motionSmoother::scaleMesh +bool Foam::motionSmootherAlgo::scaleMesh ( labelList& checkFaces, const bool smoothMesh, @@ -961,7 +874,7 @@ bool Foam::motionSmoother::scaleMesh } -bool Foam::motionSmoother::scaleMesh +bool Foam::motionSmootherAlgo::scaleMesh ( labelList& checkFaces, const List& baffles, @@ -981,7 +894,7 @@ bool Foam::motionSmoother::scaleMesh } -Foam::tmp Foam::motionSmoother::curPoints() const +Foam::tmp Foam::motionSmootherAlgo::curPoints() const { // Set newPoints as old + scale*displacement @@ -1054,7 +967,7 @@ Foam::tmp Foam::motionSmoother::curPoints() const } -bool Foam::motionSmoother::scaleMesh +bool Foam::motionSmootherAlgo::scaleMesh ( labelList& checkFaces, const List& baffles, @@ -1068,7 +981,7 @@ bool Foam::motionSmoother::scaleMesh { FatalErrorIn ( - "motionSmoother::scaleMesh" + "motionSmootherAlgo::scaleMesh" "(" "labelList&, " "const List&, " @@ -1271,7 +1184,7 @@ bool Foam::motionSmoother::scaleMesh } -void Foam::motionSmoother::updateMesh() +void Foam::motionSmootherAlgo::updateMesh() { const pointBoundaryMesh& patches = pMesh_.boundary(); @@ -1290,7 +1203,7 @@ void Foam::motionSmoother::updateMesh() { FatalErrorIn ( - "motionSmoother::updateMesh" + "motionSmootherAlgo::updateMesh" ) << "Patch " << patches[patchI].name() << " has wrong boundary condition " << displacement_.boundaryField()[patchI].type() @@ -1324,7 +1237,7 @@ void Foam::motionSmoother::updateMesh() // Specialisation of applyCornerConstraints for scalars because // no constraint need be applied template<> -void Foam::motionSmoother::applyCornerConstraints +void Foam::motionSmootherAlgo::applyCornerConstraints ( GeometricField& pf ) const diff --git a/src/dynamicMesh/motionSmoother/motionSmootherAlgo.H b/src/dynamicMesh/motionSmoother/motionSmootherAlgo.H index 33bb2835e2..7cffaf6606 100644 --- a/src/dynamicMesh/motionSmoother/motionSmootherAlgo.H +++ b/src/dynamicMesh/motionSmoother/motionSmootherAlgo.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Class - Foam::motionSmoother + Foam::motionSmootherAlgo Description Given a displacement moves the mesh by scaling the displacement back @@ -68,13 +68,13 @@ Note recursive lookup) SourceFiles - motionSmoother.C - motionSmootherTemplates.C + motionSmootherAlgo.C + motionSmootherAlgoTemplates.C \*---------------------------------------------------------------------------*/ -#ifndef motionSmoother_H -#define motionSmoother_H +#ifndef motionSmootherAlgo_H +#define motionSmootherAlgo_H #include "pointFields.H" #include "HashSet.H" @@ -92,10 +92,10 @@ class polyMeshGeometry; class faceSet; /*---------------------------------------------------------------------------*\ - Class motionSmoother Declaration + Class motionSmootherAlgo Declaration \*---------------------------------------------------------------------------*/ -class motionSmoother +class motionSmootherAlgo { // Private class @@ -141,39 +141,39 @@ class motionSmoother //- Reference to face subset of all adaptPatchIDs indirectPrimitivePatch& pp_; - //- Indices of fixedValue patches that we're allowed to modify the - // displacement on. - const labelList adaptPatchIDs_; + //- Displacement field + pointVectorField& displacement_; + //- Scale factor for displacement + pointScalarField& scale_; + + //- Starting mesh position + pointField& oldPoints_; - // Smoothing and checking parameters - dictionary paramDict_; // Internal data - //- Displacement field - pointVectorField displacement_; + //- Indices of fixedValue patches that we're allowed to modify the + // displacement on. + const labelList adaptPatchIDs_; - //- Scale factor for displacement - pointScalarField scale_; + // Smoothing and checking parameters + dictionary paramDict_; - //- Starting mesh position - pointField oldPoints_; + //- Is mesh point on boundary or not + PackedBoolList isInternalPoint_; - //- Is mesh point on boundary or not - PackedBoolList isInternalPoint_; + //- Is edge master (always except if on coupled boundary and on + // lower processor) + PackedBoolList isMasterEdge_; - //- Is edge master (always except if on coupled boundary and on - // lower processor) - PackedBoolList isMasterEdge_; + //- 2-D motion corrector + twoDPointCorrector twoDCorrector_; - //- 2-D motion corrector - twoDPointCorrector twoDCorrector_; + // Muli-patch constraints (from pointPatchInterpolation) - // Muli-patch constraints (from pointPatchInterpolation) - - labelList patchPatchPointConstraintPoints_; - tensorField patchPatchPointConstraintTensors_; + labelList patchPatchPointConstraintPoints_; + tensorField patchPatchPointConstraintTensors_; // Private Member Functions @@ -303,43 +303,34 @@ class motionSmoother ) const; //- Disallow default bitwise copy construct - motionSmoother(const motionSmoother&); + motionSmootherAlgo(const motionSmootherAlgo&); //- Disallow default bitwise assignment - void operator=(const motionSmoother&); + void operator=(const motionSmootherAlgo&); public: - ClassName("motionSmoother"); + ClassName("motionSmootherAlgo"); // Constructors //- Construct from mesh, patches to work on and smoothing parameters. - // Reads displacement field (only boundary conditions used) - motionSmoother + motionSmootherAlgo ( polyMesh&, pointMesh&, indirectPrimitivePatch& pp, // 'outside' points + pointVectorField& displacement, + pointScalarField& scale, + pointField& oldPoints, const labelList& adaptPatchIDs, // patches forming 'outside' const dictionary& paramDict ); - //- Construct from mesh, patches to work on and smoothing parameters and - // displacementfield (only boundary conditions used) - motionSmoother - ( - polyMesh&, - indirectPrimitivePatch& pp, // 'outside' points - const labelList& adaptPatchIDs, // patches forming 'outside' - const pointVectorField&, - const dictionary& paramDict - ); - //- Destructor - ~motionSmoother(); + ~motionSmootherAlgo(); // Member Functions @@ -360,18 +351,6 @@ public: const dictionary& paramDict() const; - //- Reference to displacement field - pointVectorField& displacement(); - - //- Reference to displacement field - const pointVectorField& displacement() const; - - //- Reference to scale field - const pointScalarField& scale() const; - - //- Starting mesh position - const pointField& oldPoints() const; - //- Return reference to 2D point motion correction twoDPointCorrector& twoDCorrector() { @@ -532,7 +511,7 @@ public: template<> -void motionSmoother::applyCornerConstraints +void motionSmootherAlgo::applyCornerConstraints ( GeometricField& pf ) const; @@ -545,7 +524,7 @@ void motionSmoother::applyCornerConstraints // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository -# include "motionSmootherTemplates.C" +# include "motionSmootherAlgoTemplates.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C b/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C index 3efb62a995..07859539a5 100644 --- a/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C +++ b/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C @@ -23,13 +23,13 @@ License \*---------------------------------------------------------------------------*/ -#include "motionSmoother.H" +#include "motionSmootherAlgo.H" #include "polyMeshGeometry.H" #include "IOmanip.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool Foam::motionSmoother::checkMesh +bool Foam::motionSmootherAlgo::checkMesh ( const bool report, const polyMesh& mesh, @@ -50,7 +50,7 @@ bool Foam::motionSmoother::checkMesh ); } -bool Foam::motionSmoother::checkMesh +bool Foam::motionSmootherAlgo::checkMesh ( const bool report, const polyMesh& mesh, @@ -411,7 +411,7 @@ bool Foam::motionSmoother::checkMesh } -bool Foam::motionSmoother::checkMesh +bool Foam::motionSmootherAlgo::checkMesh ( const bool report, const polyMesh& mesh, @@ -429,7 +429,7 @@ bool Foam::motionSmoother::checkMesh ); } -bool Foam::motionSmoother::checkMesh +bool Foam::motionSmootherAlgo::checkMesh ( const bool report, const dictionary& dict, @@ -452,7 +452,7 @@ bool Foam::motionSmoother::checkMesh } -bool Foam::motionSmoother::checkMesh +bool Foam::motionSmootherAlgo::checkMesh ( const bool report, const dictionary& dict, diff --git a/src/dynamicMesh/motionSmoother/motionSmootherAlgoTemplates.C b/src/dynamicMesh/motionSmoother/motionSmootherAlgoTemplates.C index 89667aade3..0e9770750a 100644 --- a/src/dynamicMesh/motionSmoother/motionSmootherAlgoTemplates.C +++ b/src/dynamicMesh/motionSmoother/motionSmootherAlgoTemplates.C @@ -23,7 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "motionSmoother.H" +#include "motionSmootherAlgo.H" #include "meshTools.H" #include "processorPointPatchFields.H" #include "pointConstraint.H" @@ -32,7 +32,7 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template -void Foam::motionSmoother::checkConstraints +void Foam::motionSmootherAlgo::checkConstraints ( GeometricField& pf ) @@ -119,7 +119,7 @@ void Foam::motionSmoother::checkConstraints { FatalErrorIn ( - "motionSmoother::checkConstraints" + "motionSmootherAlgo::checkConstraints" "(GeometricField&)" ) << "Patch fields are not consistent on mesh point " << ppp << " coordinate " << mesh.points()[ppp] @@ -136,7 +136,7 @@ void Foam::motionSmoother::checkConstraints template -void Foam::motionSmoother::applyCornerConstraints +void Foam::motionSmootherAlgo::applyCornerConstraints ( GeometricField& pf ) const @@ -155,7 +155,7 @@ void Foam::motionSmoother::applyCornerConstraints // Average of connected points. template Foam::tmp > -Foam::motionSmoother::avg +Foam::motionSmootherAlgo::avg ( const GeometricField& fld, const scalarField& edgeWeight @@ -253,7 +253,7 @@ Foam::motionSmoother::avg // smooth field (point-jacobi) template -void Foam::motionSmoother::smooth +void Foam::motionSmootherAlgo::smooth ( const GeometricField& fld, const scalarField& edgeWeight, @@ -278,7 +278,7 @@ void Foam::motionSmoother::smooth //- Test synchronisation of generic field (not positions!) on points template -void Foam::motionSmoother::testSyncField +void Foam::motionSmootherAlgo::testSyncField ( const Field& fld, const CombineOp& cop, @@ -308,7 +308,7 @@ void Foam::motionSmoother::testSyncField { FatalErrorIn ( - "motionSmoother::testSyncField" + "motionSmootherAlgo::testSyncField" "(const Field&, const CombineOp&" ", const Type&, const bool)" ) << "On element " << i << " value:" << fld[i] diff --git a/src/dynamicMesh/motionSmoother/motionSmootherData.C b/src/dynamicMesh/motionSmoother/motionSmootherData.C new file mode 100644 index 0000000000..6fa5d8c095 --- /dev/null +++ b/src/dynamicMesh/motionSmoother/motionSmootherData.C @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "motionSmootherData.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::motionSmootherData::motionSmootherData +( + const pointMesh& pMesh +) +: + displacement_ + ( + IOobject + ( + "displacement", + pMesh.time().timeName(), + pMesh(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + pMesh + ), + scale_ + ( + IOobject + ( + "scale", + pMesh.time().timeName(), + pMesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + pMesh, + dimensionedScalar("scale", dimless, 1.0) + ), + oldPoints_(pMesh().points()) +{} + + +Foam::motionSmootherData::motionSmootherData +( + const pointVectorField& displacement +) +: + displacement_ + ( + IOobject + ( + "displacement", + displacement.time().timeName(), + displacement.mesh()(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + displacement + ), + scale_ + ( + IOobject + ( + "scale", + displacement.time().timeName(), + displacement.mesh()(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + displacement.mesh(), + dimensionedScalar("scale", dimless, 1.0) + ), + oldPoints_(displacement.mesh()().points()) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::pointVectorField& Foam::motionSmootherData::displacement() +{ + return displacement_; +} + + +const Foam::pointVectorField& Foam::motionSmootherData::displacement() const +{ + return displacement_; +} + + +const Foam::pointScalarField& Foam::motionSmootherData::scale() const +{ + return scale_; +} + + +const Foam::pointField& Foam::motionSmootherData::oldPoints() const +{ + return oldPoints_; +} + + +// ************************************************************************* // diff --git a/src/dynamicMesh/motionSmoother/motionSmootherData.H b/src/dynamicMesh/motionSmoother/motionSmootherData.H new file mode 100644 index 0000000000..a4f2fa8a59 --- /dev/null +++ b/src/dynamicMesh/motionSmoother/motionSmootherData.H @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::motionSmootherData + +Description + +SourceFiles + motionSmootherData.C + +\*---------------------------------------------------------------------------*/ + +#ifndef motionSmootherData_H +#define motionSmootherData_H + +#include "pointFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class motionSmootherData Declaration +\*---------------------------------------------------------------------------*/ + +class motionSmootherData +{ +protected: + + // Private data + + //- Displacement field + pointVectorField displacement_; + + //- Scale factor for displacement + pointScalarField scale_; + + //- Starting mesh position + pointField oldPoints_; + + +public: + + // Constructors + + //- Construct read + motionSmootherData + ( + const pointMesh& + ); + + //- Construct from pointDisplacement + motionSmootherData + ( + const pointVectorField& + ); + + + // Member Functions + + //- Reference to displacement field + pointVectorField& displacement(); + + //- Reference to displacement field + const pointVectorField& displacement() const; + + //- Reference to scale field + const pointScalarField& scale() const; + + //- Starting mesh position + const pointField& oldPoints() const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From b4d6f3e0a9b1689bc957709ba988046d3a20875e Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 20 Nov 2013 11:22:08 +0000 Subject: [PATCH 16/21] ENH: snappyHexMesh: added mesh shrinking as separate library --- src/mesh/autoMesh/Make/files | 6 + .../autoHexMeshDriver/autoLayerDriver.C | 10 +- .../autoHexMeshDriver/autoRefineDriver.C | 13 +- .../displacementMeshMoverMotionSolver.C | 136 ++ .../displacementMeshMoverMotionSolver.H | 114 + .../externalDisplacementMeshMover.C | 124 + .../externalDisplacementMeshMover.H | 180 ++ .../medialAxisMeshMover.C | 2039 +++++++++++++++++ .../medialAxisMeshMover.H | 355 +++ .../medialAxisMeshMoverTemplates.C | 93 + .../meshRefinement/meshRefinement.C | 5 +- .../meshRefinement/meshRefinement.H | 4 - .../meshRefinement/meshRefinementBaffles.C | 89 +- 13 files changed, 3055 insertions(+), 113 deletions(-) create mode 100644 src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/displacementMeshMoverMotionSolver.C create mode 100644 src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/displacementMeshMoverMotionSolver.H create mode 100644 src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/externalDisplacementMeshMover.C create mode 100644 src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/externalDisplacementMeshMover.H create mode 100644 src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C create mode 100644 src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.H create mode 100644 src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/medialAxisMeshMoverTemplates.C diff --git a/src/mesh/autoMesh/Make/files b/src/mesh/autoMesh/Make/files index dd0bfd0391..510d34353f 100644 --- a/src/mesh/autoMesh/Make/files +++ b/src/mesh/autoMesh/Make/files @@ -26,5 +26,11 @@ $(autoHexMesh)/shellSurfaces/shellSurfaces.C $(autoHexMesh)/trackedParticle/trackedParticle.C $(autoHexMesh)/trackedParticle/trackedParticleCloud.C +meshMover = $(autoHexMesh)/externalDisplacementMeshMover +$(meshMover)/displacementMeshMoverMotionSolver.C +$(meshMover)/externalDisplacementMeshMover.C +$(meshMover)/medialAxisMeshMover.C + + LIB = $(FOAM_LIBBIN)/libautoMesh diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index d859cf89a9..f5e220d645 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -53,6 +53,7 @@ Description #include "calculatedPointPatchFields.H" #include "cyclicSlipPointPatchFields.H" #include "fixedValueFvPatchFields.H" +#include "localPointRegion.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -2809,14 +2810,7 @@ void Foam::autoLayerDriver::mergePatchFacesUndo const fvMesh& mesh = meshRefiner_.mesh(); - List couples - ( - meshRefiner_.getDuplicateFaces // get all baffles - ( - identity(mesh.nFaces()-mesh.nInternalFaces()) - + mesh.nInternalFaces() - ) - ); + List couples(localPointRegion::findDuplicateFacePairs(mesh)); labelList duplicateFace(mesh.nFaces(), -1); forAll(couples, i) diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C index ce97c27104..1f1464d96e 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C @@ -36,6 +36,7 @@ License #include "mapDistributePolyMesh.H" #include "unitConversion.H" #include "snapParameters.H" +#include "localPointRegion.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -1036,19 +1037,11 @@ void Foam::autoRefineDriver::splitAndMergeBaffles // Merge all baffles that are still remaining after duplicating points. - List couples - ( - meshRefiner_.getDuplicateFaces // get all baffles - ( - identity(mesh.nFaces()-mesh.nInternalFaces()) - + mesh.nInternalFaces() - ) - ); + List couples(localPointRegion::findDuplicateFacePairs(mesh)); label nCouples = returnReduce(couples.size(), sumOp