diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict index becaae12f7..ca79e6aa47 100644 --- a/applications/utilities/postProcessing/sampling/sample/sampleDict +++ b/applications/utilities/postProcessing/sampling/sample/sampleDict @@ -49,6 +49,9 @@ formatOptions // cell : use cell-centre value only; constant over cells (default) // cellPoint : use cell-centre and vertex values // cellPointFace : use cell-centre, vertex and face values. +// pointMVC : use point values only (Mean Value Coordinates) +// cellPatchConstrained : use cell-centre except on boundary faces where +// it uses the boundary value. For use with e.g. patchCloudSet. // 1] vertex values determined from neighbouring cell-centre values // 2] face values determined using the current face interpolation scheme // for the field (linear, gamma, etc.) @@ -83,6 +86,7 @@ fields // uniform, face, midPoint, midPointAndFace : start and end coordinate // uniform: extra number of sampling points // polyLine, cloud: list of coordinates +// patchCloud: list of coordinates and set of patches to look for nearest sets ( lineX1 @@ -113,8 +117,21 @@ sets points ((0.049 0.049 0.00501)(0.051 0.049 0.00501)); } + somePatchPoints + { + // Sample nearest points on selected patches. Use with + // interpolations: + // - cell (cell value) + // - cellPatchConstrained (boundary value) + // - cellPoint (interpolated boundary value) + type patchCloud; + axis xyz; + points ((0.049 0.099 0.005)(0.051 0.054 0.005)); + patches (".*Wall.*"); + } ); + // Surface sampling definition // // 1] patches are not triangulated by default @@ -241,4 +258,5 @@ surfaces } ); + // *********************************************************************** // diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 360ecc6b07..a66495843b 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -201,6 +201,7 @@ interpolation = interpolation/interpolation $(interpolation)/interpolation/interpolations.C $(interpolation)/interpolationCell/makeInterpolationCell.C +$(interpolation)/interpolationCellPatchConstrained/makeInterpolationCellPatchConstrained.C $(interpolation)/interpolationCellPoint/cellPointWeight/cellPointWeight.C $(interpolation)/interpolationCellPoint/makeInterpolationCellPoint.C $(interpolation)/interpolationCellPointFace/makeInterpolationCellPointFace.C diff --git a/src/finiteVolume/interpolation/interpolation/interpolationCellPatchConstrained/interpolationCellPatchConstrained.C b/src/finiteVolume/interpolation/interpolation/interpolationCellPatchConstrained/interpolationCellPatchConstrained.C new file mode 100644 index 0000000000..139121a31c --- /dev/null +++ b/src/finiteVolume/interpolation/interpolation/interpolationCellPatchConstrained/interpolationCellPatchConstrained.C @@ -0,0 +1,76 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\/ 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 "interpolationCellPatchConstrained.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // + +template +interpolationCellPatchConstrained::interpolationCellPatchConstrained +( + const GeometricField& psi +) +: + interpolation(psi) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Type interpolationCellPatchConstrained::interpolate +( + const vector& pt, + const label cellI, + const label faceI +) const +{ + if (faceI >= 0 && faceI >= this->psi_.mesh().nInternalFaces()) + { + // Use boundary value + const polyBoundaryMesh& pbm = this->psi_.mesh().boundaryMesh(); + label patchI = pbm.patchID()[faceI-this->psi_.mesh().nInternalFaces()]; + label patchFaceI = pbm[patchI].whichFace(faceI); + + return this->psi_.boundaryField()[patchI][patchFaceI]; + } + else + { + return this->psi_[cellI]; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/interpolation/interpolation/interpolationCellPatchConstrained/interpolationCellPatchConstrained.H b/src/finiteVolume/interpolation/interpolation/interpolationCellPatchConstrained/interpolationCellPatchConstrained.H new file mode 100644 index 0000000000..814988a9f3 --- /dev/null +++ b/src/finiteVolume/interpolation/interpolation/interpolationCellPatchConstrained/interpolationCellPatchConstrained.H @@ -0,0 +1,97 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ 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::interpolationCellPatchConstrained + +Description + Uses the cell value for any point in the cell apart from a boundary face + where it uses the boundary value directly. + Note: will not work on an empty patch. + +\*---------------------------------------------------------------------------*/ + +#ifndef interpolationCellPatchConstrained_H +#define interpolationCellPatchConstrained_H + +#include "interpolation.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class fvMesh; + +/*---------------------------------------------------------------------------*\ + Class interpolationCellPatchConstrained Declaration +\*---------------------------------------------------------------------------*/ + +template +class interpolationCellPatchConstrained +: + public interpolation +{ + +public: + + //- Runtime type information + TypeName("cellPatchConstrained"); + + + // Constructors + + //- Construct from components + interpolationCellPatchConstrained + ( + const GeometricField& psi + ); + + + // Member Functions + + //- Interpolate field to the given point in the given cell + Type interpolate + ( + const vector& position, + const label cellI, + const label faceI = -1 + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "interpolationCellPatchConstrained.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/interpolation/interpolation/interpolationCellPatchConstrained/makeInterpolationCellPatchConstrained.C b/src/finiteVolume/interpolation/interpolation/interpolationCellPatchConstrained/makeInterpolationCellPatchConstrained.C new file mode 100644 index 0000000000..adae604e0e --- /dev/null +++ b/src/finiteVolume/interpolation/interpolation/interpolationCellPatchConstrained/makeInterpolationCellPatchConstrained.C @@ -0,0 +1,41 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ 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 "interpolationCellPatchConstrained.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makeInterpolation(interpolationCellPatchConstrained); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/sampling/Make/files b/src/sampling/Make/files index ddf46a17e8..0c679f52d8 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -5,6 +5,7 @@ probes/probesFunctionObject/probesFunctionObject.C sampledSet/cloud/cloudSet.C sampledSet/coordSet/coordSet.C +sampledSet/patchCloud/patchCloudSet.C sampledSet/polyLine/polyLineSet.C sampledSet/face/faceOnlySet.C sampledSet/midPoint/midPointSet.C diff --git a/src/sampling/sampledSet/patchCloud/patchCloudSet.C b/src/sampling/sampledSet/patchCloud/patchCloudSet.C new file mode 100644 index 0000000000..85877da3b8 --- /dev/null +++ b/src/sampling/sampledSet/patchCloud/patchCloudSet.C @@ -0,0 +1,322 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ 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 "patchCloudSet.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" +#include "pointIndexHit.H" +#include "Tuple2.H" +#include "treeBoundBox.H" +#include "indexedOctree.H" +#include "treeDataFace.H" +#include "Time.H" +#include "meshTools.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(patchCloudSet, 0); + addToRunTimeSelectionTable(sampledSet, patchCloudSet, word); + + + //- Helper class for finding nearest + // Nearest: + // - point+local index + // - sqr(distance) + // - processor + typedef Tuple2 > nearInfo; + + class nearestEqOp + { + + public: + + void operator()(nearInfo& x, const nearInfo& y) const + { + if (y.first().hit()) + { + if (!x.first().hit()) + { + x = y; + } + else if (y.second().first() < x.second().first()) + { + x = y; + } + } + } + }; +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::patchCloudSet::calcSamples +( + DynamicList& samplingPts, + DynamicList