From d5ef310d435491ef767ffbe7065158422f11d447 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 6 Feb 2013 11:37:45 +0000 Subject: [PATCH 1/5] ENH: timeVaryingMapped: added checking --- .../timeVaryingMappedFixedValueFvPatchField.C | 27 ++++++++++++++++++- ...meVaryingMappedFixedValuePointPatchField.C | 27 ++++++++++++++++++- .../pointToPointPlanarInterpolation.C | 8 +++--- .../pointToPointPlanarInterpolation.H | 11 +++++++- ...pointToPointPlanarInterpolationTemplates.C | 13 ++++++++- 5 files changed, 79 insertions(+), 7 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C index f613a7e6a2..6ea997f3fd 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.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 @@ -343,6 +343,18 @@ void timeVaryingMappedFixedValueFvPatchField::checkTable() ) ); + if (vals.size() != mapperPtr_().sourceSize()) + { + FatalErrorIn + ( + "timeVaryingMappedFixedValueFvPatchField::" + "checkTable()" + ) << "Number of values (" << vals.size() + << ") differs from the number of points (" + << mapperPtr_().sourceSize() + << ") in file " << vals.objectPath() << exit(FatalError); + } + startAverage_ = vals.average(); startSampledValues_ = mapperPtr_().interpolate(vals); } @@ -388,6 +400,19 @@ void timeVaryingMappedFixedValueFvPatchField::checkTable() false ) ); + + if (vals.size() != mapperPtr_().sourceSize()) + { + FatalErrorIn + ( + "timeVaryingMappedFixedValueFvPatchField::" + "checkTable()" + ) << "Number of values (" << vals.size() + << ") differs from the number of points (" + << mapperPtr_().sourceSize() + << ") in file " << vals.objectPath() << exit(FatalError); + } + endAverage_ = vals.average(); endSampledValues_ = mapperPtr_().interpolate(vals); } diff --git a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C index 1fa44b5d64..8bca126f9b 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -313,6 +313,18 @@ void Foam::timeVaryingMappedFixedValuePointPatchField::checkTable() ) ); + if (vals.size() != mapperPtr_().sourceSize()) + { + FatalErrorIn + ( + "timeVaryingMappedFixedValuePointPatchField::" + "checkTable()" + ) << "Number of values (" << vals.size() + << ") differs from the number of points (" + << mapperPtr_().sourceSize() + << ") in file " << vals.objectPath() << exit(FatalError); + } + startAverage_ = vals.average(); startSampledValues_ = mapperPtr_().interpolate(vals); } @@ -357,6 +369,19 @@ void Foam::timeVaryingMappedFixedValuePointPatchField::checkTable() false ) ); + + if (vals.size() != mapperPtr_().sourceSize()) + { + FatalErrorIn + ( + "timeVaryingMappedFixedValuePointPatchField::" + "checkTable()" + ) << "Number of values (" << vals.size() + << ") differs from the number of points (" + << mapperPtr_().sourceSize() + << ") in file " << vals.objectPath() << exit(FatalError); + } + endAverage_ = vals.average(); endSampledValues_ = mapperPtr_().interpolate(vals); } diff --git a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C index 9f8a6a5179..bc1402bd7a 100644 --- a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C +++ b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -222,7 +222,8 @@ Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation ) : perturb_(perturb), - referenceCS_(calcCoordinateSystem(sourcePoints)) + referenceCS_(calcCoordinateSystem(sourcePoints)), + nPoints_(sourcePoints.size()) { calcWeights(sourcePoints, destPoints); @@ -238,7 +239,8 @@ Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation ) : perturb_(perturb), - referenceCS_(referenceCS) + referenceCS_(referenceCS), + nPoints_(sourcePoints.size()) { calcWeights(sourcePoints, destPoints); } diff --git a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.H b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.H index daec2e4688..e3428d80fe 100644 --- a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.H +++ b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,6 +59,9 @@ class pointToPointPlanarInterpolation //- Coordinate system coordinateSystem referenceCS_; + //- Number of source points (for checking) + label nPoints_; + //- Current interpolation addressing to face centres of underlying // patch List > nearestVertex_; @@ -114,6 +117,12 @@ public: return referenceCS_; } + //- Number of source points + label sourceSize() const + { + return nPoints_; + } + // patch const List >& nearestVertex() const { diff --git a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolationTemplates.C b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolationTemplates.C index 9159a03edd..f17f249d13 100644 --- a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolationTemplates.C +++ b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolationTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,6 +33,17 @@ Foam::tmp > Foam::pointToPointPlanarInterpolation::interpolate const Field& sourceFld ) const { + if (nPoints_ != sourceFld.size()) + { + FatalErrorIn + ( + "pointToPointPlanarInterpolation::interpolate" + "(const Field&) const" + ) << "Number of source points = " << nPoints_ + << " number of values = " << sourceFld.size() + << exit(FatalError); + } + tmp > tfld(new Field(nearestVertex_.size())); Field& fld = tfld(); From 2cde70431c5b3194bf9bd80717ca59a0adaecccc Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 8 Feb 2013 11:24:42 +0000 Subject: [PATCH 2/5] BUG: Correcting coordinate system entry on fvOption in lagrangian/reactingParcelFoam/filter tutorial --- .../reactingParcelFoam/filter/system/fvOptions | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/system/fvOptions b/tutorials/lagrangian/reactingParcelFoam/filter/system/fvOptions index a6fa8898ba..ea198445a4 100644 --- a/tutorials/lagrangian/reactingParcelFoam/filter/system/fvOptions +++ b/tutorials/lagrangian/reactingParcelFoam/filter/system/fvOptions @@ -33,8 +33,14 @@ filter1 coordinateSystem { - e1 (1 0 0); - e2 (0 1 0); + type cartesian; + origin (0 0 0); + coordinateRotation + { + type axesRotation; + e1 (1 0 0); + e2 (0 1 0); + } } } } From b634d14068febe129d5fba18d11e67ccfd62dba8 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 11 Feb 2013 11:13:24 +0000 Subject: [PATCH 3/5] setFields: If field is not found in the current time directory look in "constant" --- .../preProcessing/setFields/setFields.C | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/applications/utilities/preProcessing/setFields/setFields.C b/applications/utilities/preProcessing/setFields/setFields.C index 274258ffd2..0dbc03540f 100644 --- a/applications/utilities/preProcessing/setFields/setFields.C +++ b/applications/utilities/preProcessing/setFields/setFields.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 @@ -54,6 +54,7 @@ bool setCellFieldType word fieldName(fieldValueStream); + // Check the current time directory IOobject fieldHeader ( fieldName, @@ -62,6 +63,18 @@ bool setCellFieldType IOobject::MUST_READ ); + // Check the "constant" directory + if (!fieldHeader.headerOk()) + { + fieldHeader = IOobject + ( + fieldName, + mesh.time().constant(), + mesh, + IOobject::MUST_READ + ); + } + // Check field exists if (fieldHeader.headerOk()) { @@ -193,6 +206,7 @@ bool setFaceFieldType word fieldName(fieldValueStream); + // Check the current time directory IOobject fieldHeader ( fieldName, @@ -201,6 +215,18 @@ bool setFaceFieldType IOobject::MUST_READ ); + // Check the "constant" directory + if (!fieldHeader.headerOk()) + { + fieldHeader = IOobject + ( + fieldName, + mesh.time().constant(), + mesh, + IOobject::MUST_READ + ); + } + // Check field exists if (fieldHeader.headerOk()) { From 065ebbf910c7bc5e6d122062b523eb0a6a15242f Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 11 Feb 2013 13:31:01 +0000 Subject: [PATCH 4/5] BUG: cyclicAMI: Mantis 740: using neighbourside geometry before it is updated --- .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.C | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C index 49ba94fda2..1d37199cd3 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.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 @@ -239,7 +239,11 @@ void Foam::cyclicAMIPolyPatch::resetAMI() const AMIPtr_.clear(); const polyPatch& nbr = neighbPatch(); - pointField nbrPoints = neighbPatch().localPoints(); + pointField nbrPoints + ( + neighbPatch().boundaryMesh().mesh().points(), + neighbPatch().meshPoints() + ); if (debug) { @@ -326,6 +330,9 @@ void Foam::cyclicAMIPolyPatch::initMovePoints ) { polyPatch::initMovePoints(pBufs, p); + + // See below. Clear out any local geometry + primitivePatch::movePoints(p); } @@ -339,6 +346,10 @@ void Foam::cyclicAMIPolyPatch::movePoints calcTransforms(); + // Note: resetAMI is called whilst in geometry update. So the slave + // side might not have reached 'movePoints'. Is explicitly handled by + // - clearing geometry of neighbour inside initMovePoints + // - not using localPoints() inside resetAMI resetAMI(); } From 97b65b811d881d32efdd87589563b2c63d44364b Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 11 Feb 2013 17:02:41 +0000 Subject: [PATCH 5/5] linearUpwindV: calculate interpolated field on processor patches --- .../schemes/linearUpwind/linearUpwindV.C | 89 +++++++++++++++++-- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linearUpwind/linearUpwindV.C b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linearUpwind/linearUpwindV.C index 9e5ad7f3a0..6368d2accd 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linearUpwind/linearUpwindV.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linearUpwind/linearUpwindV.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 @@ -70,8 +70,8 @@ Foam::linearUpwindV::correction const labelList& own = mesh.owner(); const labelList& nei = mesh.neighbour(); - const vectorField& C = mesh.C(); - const vectorField& Cf = mesh.Cf(); + const volVectorField& C = mesh.C(); + const surfaceVectorField& Cf = mesh.Cf(); tmp < @@ -97,8 +97,7 @@ Foam::linearUpwindV::correction if (faceFlux[facei] > 0.0) { maxCorr = - (1.0 - w[facei]) - *(vf[nei[facei]] - vf[own[facei]]); + (1.0 - w[facei])*(vf[nei[facei]] - vf[own[facei]]); sfCorr[facei] = (Cf[facei] - C[own[facei]]) & gradVf[own[facei]]; @@ -139,6 +138,86 @@ Foam::linearUpwindV::correction } } + + typename GeometricField:: + GeometricBoundaryField& bSfCorr = sfCorr.boundaryField(); + + forAll(bSfCorr, patchi) + { + fvsPatchField& pSfCorr = bSfCorr[patchi]; + + if (pSfCorr.coupled()) + { + const labelUList& pOwner = + mesh.boundary()[patchi].faceCells(); + + const vectorField& pCf = Cf.boundaryField()[patchi]; + const scalarField& pW = w.boundaryField()[patchi]; + + const scalarField& pFaceFlux = faceFlux.boundaryField()[patchi]; + + const Field::type> pGradVfNei + ( + gradVf.boundaryField()[patchi].patchNeighbourField() + ); + + const Field pVfNei + ( + vf.boundaryField()[patchi].patchNeighbourField() + ); + + // Build the d-vectors + vectorField pd(Cf.boundaryField()[patchi].patch().delta()); + + forAll(pOwner, facei) + { + label own = pOwner[facei]; + + vector maxCorr; + + if (pFaceFlux[facei] > 0) + { + pSfCorr[facei] = (pCf[facei] - C[own]) & gradVf[own]; + + maxCorr = (1.0 - pW[facei])*(pVfNei[facei] - vf[own]); + } + else + { + pSfCorr[facei] = + (pCf[facei] - pd[facei] - C[own]) & pGradVfNei[facei]; + + maxCorr = pW[facei]*(vf[own] - pVfNei[facei]); + } + + scalar pSfCorrs = magSqr(pSfCorr[facei]); + scalar maxCorrs = pSfCorr[facei] & maxCorr; + + if (pSfCorrs > 0) + { + if (maxCorrs < 0) + { + pSfCorr[facei] = vector::zero; + } + else if (pSfCorrs > maxCorrs) + { + pSfCorr[facei] *= maxCorrs/(pSfCorrs + VSMALL); + } + } + else if (pSfCorrs < 0) + { + if (maxCorrs > 0) + { + pSfCorr[facei] = vector::zero; + } + else if (pSfCorrs < maxCorrs) + { + pSfCorr[facei] *= maxCorrs/(pSfCorrs - VSMALL); + } + } + } + } + } + return tsfCorr; }