From 7240fdd5f86364eeac5ad6f777473ec303de080a Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 7 Aug 2012 17:39:24 +0100 Subject: [PATCH 01/15] ENH: moveDynamicMesh: added option to dump AMI weights --- .../moveDynamicMesh/moveDynamicMesh.C | 86 ++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C index 47f1dba097..00c97614de 100644 --- a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C +++ b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.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-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,19 +32,98 @@ Description #include "argList.H" #include "Time.H" #include "dynamicFvMesh.H" +#include "vtkSurfaceWriter.H" +#include "cyclicAMIPolyPatch.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Dump patch + weights to vtk file +void writeWeights +( + const scalarField& wghtSum, + const primitivePatch& patch, + const fileName& folder, + const fileName& prefix, + const word& timeName +) +{ + vtkSurfaceWriter writer; + + writer.write + ( + folder, + prefix + "_proc" + Foam::name(Pstream::myProcNo()) + "_" + timeName, + patch.localPoints(), + patch.localFaces(), + "weightsSum", + wghtSum, + false + ); +} + + +void writeWeights(const polyMesh& mesh) +{ + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); + + const word tmName(mesh.time().timeName()); + + forAll(pbm, patchI) + { + if (isA(pbm[patchI])) + { + const cyclicAMIPolyPatch& cpp = + refCast(pbm[patchI]); + + if (cpp.owner()) + { + const AMIPatchToPatchInterpolation& ami = + cpp.AMI(); + writeWeights + ( + ami.tgtWeightsSum(), + cpp.neighbPatch(), + "output", + "tgt", + tmName + ); + writeWeights + ( + ami.srcWeightsSum(), + cpp, + "output", + "src", + tmName + ); + } + } + } +} + + // Main program: int main(int argc, char *argv[]) { + argList::addBoolOption + ( + "checkAMI", + "check AMI weights" + ); # include "setRootCase.H" # include "createTime.H" # include "createDynamicFvMesh.H" + const bool checkAMI = args.optionFound("checkAMI"); + + if (checkAMI) + { + Info<< "Writing VTK files with weights of AMI patches." << nl << endl; + } + while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << endl; @@ -52,6 +131,11 @@ int main(int argc, char *argv[]) mesh.update(); mesh.checkMesh(true); + if (checkAMI) + { + writeWeights(mesh); + } + runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" From 9bb7fad6aa1e2d20ab2ee91d6095422bacb3cd63 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 17 Aug 2012 10:29:29 +0100 Subject: [PATCH 02/15] COMP: moveDynamicMesh: add vtk writing libraries --- .../utilities/mesh/manipulation/moveDynamicMesh/Make/options | 2 ++ 1 file changed, 2 insertions(+) diff --git a/applications/utilities/mesh/manipulation/moveDynamicMesh/Make/options b/applications/utilities/mesh/manipulation/moveDynamicMesh/Make/options index 36fba156e5..f7e149613f 100644 --- a/applications/utilities/mesh/manipulation/moveDynamicMesh/Make/options +++ b/applications/utilities/mesh/manipulation/moveDynamicMesh/Make/options @@ -1,9 +1,11 @@ EXE_INC = \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ -ldynamicFvMesh \ -lmeshTools \ + -lsampling \ -ldynamicMesh From 831bcdc6b926abf90459c01780e650ec83f41f01 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 17 Aug 2012 12:30:55 +0100 Subject: [PATCH 03/15] STYLE: scripts: removed trailing spaces --- .../chemFoam/nc7h16/validation/createGraph | 4 ++-- tutorials/mesh/cvMesh/blob/system/cvMeshDict | 2 +- tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict | 2 +- tutorials/mesh/snappyHexMesh/Allrun | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) mode change 100755 => 100644 tutorials/combustion/chemFoam/nc7h16/validation/createGraph diff --git a/tutorials/combustion/chemFoam/nc7h16/validation/createGraph b/tutorials/combustion/chemFoam/nc7h16/validation/createGraph old mode 100755 new mode 100644 index 634beebec7..2302a2fe42 --- a/tutorials/combustion/chemFoam/nc7h16/validation/createGraph +++ b/tutorials/combustion/chemFoam/nc7h16/validation/createGraph @@ -11,10 +11,10 @@ gnuplot< Date: Fri, 17 Aug 2012 16:04:37 +0100 Subject: [PATCH 04/15] BUG: applyBoundaryLayer: consistent boundary values --- .../preProcessing/applyBoundaryLayer/applyBoundaryLayer.C | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C b/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C index 7ed970aff4..828ba5d9c7 100644 --- a/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C +++ b/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.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-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -93,6 +93,7 @@ int main(int argc, char *argv[]) U[celli] *= ::pow(y[celli]/yblv, (1.0/7.0)); } } + U.correctBoundaryConditions(); Info<< "Writing U\n" << endl; U.write(); From 97d133bcf402e89dfc9861ff9d17111771232d6f Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 20 Aug 2012 10:19:14 +0100 Subject: [PATCH 05/15] ENH: wallHeatFlux: generalise for solids --- .../wall/wallHeatFlux/Make/options | 9 ++-- .../wall/wallHeatFlux/createFields.H | 49 ++++++++++++------- .../wall/wallHeatFlux/wallHeatFlux.C | 12 ++++- .../solidThermo/makeSolidThermo.H | 7 +++ 4 files changed, 54 insertions(+), 23 deletions(-) diff --git a/applications/utilities/postProcessing/wall/wallHeatFlux/Make/options b/applications/utilities/postProcessing/wall/wallHeatFlux/Make/options index 4d244f56ba..52ab08bdcc 100644 --- a/applications/utilities/postProcessing/wall/wallHeatFlux/Make/options +++ b/applications/utilities/postProcessing/wall/wallHeatFlux/Make/options @@ -1,15 +1,18 @@ EXE_INC = \ -I$(LIB_SRC)/turbulenceModels \ - -I$(LIB_SRC)/turbulenceModels/compressible/RAS/RASModel \ + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ - -lcompressibleRASModels \ + -lcompressibleTurbulenceModel \ -lreactionThermophysicalModels \ -lfiniteVolume \ -lgenericPatchFields \ -lspecie \ - -lbasicThermophysicalModels + -lsolid \ + -lbasicThermophysicalModels \ + -lbasicSolidThermo diff --git a/applications/utilities/postProcessing/wall/wallHeatFlux/createFields.H b/applications/utilities/postProcessing/wall/wallHeatFlux/createFields.H index 4461a3aa55..f1096d657e 100644 --- a/applications/utilities/postProcessing/wall/wallHeatFlux/createFields.H +++ b/applications/utilities/postProcessing/wall/wallHeatFlux/createFields.H @@ -5,6 +5,7 @@ autoPtr thermo const volScalarField& h = thermo->he(); +// Register copy of thermo density volScalarField rho ( IOobject @@ -16,28 +17,40 @@ volScalarField rho thermo->rho() ); -volVectorField U -( - IOobject +// Construct turbulence model (if fluid) +autoPtr UPtr; +autoPtr phiPtr; +autoPtr turbulence; + +if (!isA(thermo())) +{ + UPtr.reset ( - "U", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh -); + new volVectorField + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ) + ); + const volVectorField& U = UPtr(); -#include "compressibleCreatePhi.H" + #include "compressibleCreatePhi.H" + // Copy phi to autoPtr. Rename to make sure copy is now registered as 'phi'. + phi.rename("phiFluid"); + phiPtr.reset(new surfaceScalarField("phi", phi)); -autoPtr RASModel -( - compressible::RASModel::New + turbulence = compressible::turbulenceModel::New ( rho, U, - phi, + phiPtr(), thermo() - ) -); + ); +} diff --git a/applications/utilities/postProcessing/wall/wallHeatFlux/wallHeatFlux.C b/applications/utilities/postProcessing/wall/wallHeatFlux/wallHeatFlux.C index 18a0dbf6d4..137c4c0cfb 100644 --- a/applications/utilities/postProcessing/wall/wallHeatFlux/wallHeatFlux.C +++ b/applications/utilities/postProcessing/wall/wallHeatFlux/wallHeatFlux.C @@ -32,7 +32,8 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "RASModel.H" +#include "turbulenceModel.H" +#include "solidThermo.H" #include "wallFvPatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,7 +57,14 @@ int main(int argc, char *argv[]) surfaceScalarField heatFlux ( - fvc::interpolate(RASModel->alphaEff())*fvc::snGrad(h) + fvc::interpolate + ( + ( + turbulence.valid() + ? turbulence->alphaEff()() + : thermo->alpha() + ) + )*fvc::snGrad(h) ); const surfaceScalarField::GeometricBoundaryField& patchHeatFlux = diff --git a/src/thermophysicalModels/basicSolidThermo/solidThermo/makeSolidThermo.H b/src/thermophysicalModels/basicSolidThermo/solidThermo/makeSolidThermo.H index c6fed868b5..4a911e8c0f 100644 --- a/src/thermophysicalModels/basicSolidThermo/solidThermo/makeSolidThermo.H +++ b/src/thermophysicalModels/basicSolidThermo/solidThermo/makeSolidThermo.H @@ -33,6 +33,7 @@ Description #define makesolidThermo_H #include "addToRunTimeSelectionTable.H" +#include "basicThermo.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -127,6 +128,12 @@ addToRunTimeSelectionTable \ BaseThermo, \ Cthermo##Mixture##Transport##Radiation##Type##Thermo##Rho##BaseThermo, \ mesh \ +); \ +addToRunTimeSelectionTable \ +( \ + basicThermo, \ + Cthermo##Mixture##Transport##Radiation##Type##Thermo##Rho##BaseThermo, \ + fvMesh \ ); \ \ addToRunTimeSelectionTable \ From 0b97b9aeafd98256baf231e7ccd53d80f08c440c Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 20 Aug 2012 11:21:17 +0100 Subject: [PATCH 06/15] ENH: checkMesh: check all points on coupled boundaries. --- .../manipulation/checkMesh/checkGeometry.C | 127 +++++++++++++++--- 1 file changed, 108 insertions(+), 19 deletions(-) diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index 443576601d..e987f2ac28 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -262,6 +262,74 @@ bool Foam::checkWedges } +namespace Foam +{ + //- Default transformation behaviour for position + class transformPositionList + { + public: + + //- Transform patch-based field + void operator() + ( + const coupledPolyPatch& cpp, + List& pts + ) const + { + // Each element of pts is all the points in the face. Convert into + // lists of size cpp to transform. + + List newPts(pts.size()); + forAll(pts, faceI) + { + newPts[faceI].setSize(pts.size()); + } + + label index = 0; + while (true) + { + label n = 0; + + // Extract for every face the i'th position + pointField ptsAtIndex(pts.size(), vector::zero); + forAll(cpp, faceI) + { + const pointField& facePts = pts[faceI]; + if (facePts.size() > index) + { + ptsAtIndex[faceI] = facePts[index]; + n++; + } + } + + if (n == 0) + { + break; + } + + // Now ptsAtIndex will have for every face either zero or + // the position of the i'th vertex. Transform. + cpp.transformPosition(ptsAtIndex); + + // Extract back from ptsAtIndex into newPts + forAll(cpp, faceI) + { + pointField& facePts = newPts[faceI]; + if (facePts.size() > index) + { + facePts[index] = ptsAtIndex[faceI]; + } + } + + index++; + } + + pts.transfer(newPts); + } + }; +} + + bool Foam::checkCoupledPoints ( const polyMesh& mesh, @@ -274,7 +342,8 @@ bool Foam::checkCoupledPoints const polyBoundaryMesh& patches = mesh.boundaryMesh(); // Zero'th point on coupled faces - pointField nbrZeroPoint(fcs.size()-mesh.nInternalFaces(), vector::max); + //pointField nbrZeroPoint(fcs.size()-mesh.nInternalFaces(), vector::max); + List nbrPoints(fcs.size()-mesh.nInternalFaces()); // Exchange zero point forAll(patches, patchI) @@ -289,17 +358,28 @@ bool Foam::checkCoupledPoints forAll(cpp, i) { label bFaceI = cpp.start()+i-mesh.nInternalFaces(); - const point& p0 = p[cpp[i][0]]; - nbrZeroPoint[bFaceI] = p0; + const face& f = cpp[i]; + nbrPoints[bFaceI].setSize(f.size()); + forAll(f, fp) + { + const point& p0 = p[f[fp]]; + nbrPoints[bFaceI][fp] = p0; + } } } } - syncTools::swapBoundaryFacePositions(mesh, nbrZeroPoint); + syncTools::syncBoundaryFaceList + ( + mesh, + nbrPoints, + eqOp(), + transformPositionList() + ); // Compare to local ones. Use same tolerance as for matching label nErrorFaces = 0; scalar avgMismatch = 0; - label nCoupledFaces = 0; + label nCoupledPoints = 0; forAll(patches, patchI) { @@ -326,20 +406,28 @@ bool Foam::checkCoupledPoints forAll(cpp, i) { label bFaceI = cpp.start()+i-mesh.nInternalFaces(); - const point& p0 = p[cpp[i][0]]; + const face& f = cpp[i]; - scalar d = mag(p0 - nbrZeroPoint[bFaceI]); - - if (d > smallDist[i]) + label fp = 0; + forAll(f, j) { - if (setPtr) + const point& p0 = p[f[fp]]; + scalar d = mag(p0 - nbrPoints[bFaceI][j]); + + if (d > smallDist[i]) { - setPtr->insert(cpp.start()+i); + if (setPtr) + { + setPtr->insert(cpp.start()+i); + } + nErrorFaces++; + break; } - nErrorFaces++; + avgMismatch += d; + nCoupledPoints++; + + fp = f.rcIndex(fp); } - avgMismatch += d; - nCoupledFaces++; } } } @@ -347,11 +435,11 @@ bool Foam::checkCoupledPoints reduce(nErrorFaces, sumOp