diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict
index 156b7cf54f..0dd02c0d58 100644
--- a/applications/utilities/postProcessing/sampling/sample/sampleDict
+++ b/applications/utilities/postProcessing/sampling/sample/sampleDict
@@ -166,6 +166,18 @@ surfaces
// triangulate false;
}
+ movingNearWall_interpolated
+ {
+ // Sample cell values off patch. Does not need to be the near-wall
+ // cell, can be arbitrarily far away.
+ type patchInternalField;
+ patchName movingWall;
+ distance 0.0001;
+ interpolate true;
+ // Optional: whether to leave as faces (=default) or triangulate
+ // triangulate false;
+ }
+
interpolatedIso
{
// Iso surface for interpolated values only
diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files
index 14aa39935e..87438ae313 100644
--- a/src/finiteVolume/Make/files
+++ b/src/finiteVolume/Make/files
@@ -142,6 +142,7 @@ $(derivedFvPatchFields)/pressureInletUniformVelocity/pressureInletUniformVelocit
$(derivedFvPatchFields)/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C
$(derivedFvPatchFields)/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C
$(derivedFvPatchFields)/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.C
+$(derivedFvPatchFields)/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchFields.C
$(derivedFvPatchFields)/slip/slipFvPatchFields.C
$(derivedFvPatchFields)/supersonicFreestream/supersonicFreestreamFvPatchVectorField.C
$(derivedFvPatchFields)/surfaceNormalFixedValue/surfaceNormalFixedValueFvPatchVectorField.C
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchField.C
new file mode 100644
index 0000000000..bfa22a1406
--- /dev/null
+++ b/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchField.C
@@ -0,0 +1,380 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-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 "selfContainedDirectMappedFixedValueFvPatchField.H"
+#include "volFields.H"
+#include "interpolationCell.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+template
+selfContainedDirectMappedFixedValueFvPatchField::selfContainedDirectMappedFixedValueFvPatchField
+(
+ const fvPatch& p,
+ const DimensionedField& iF
+)
+:
+ directMappedPatchBase(p.patch()),
+ fixedValueFvPatchField(p, iF),
+ fieldName_(iF.name()),
+ setAverage_(false),
+ average_(pTraits::zero),
+ interpolationScheme_(interpolationCell::typeName)
+{}
+
+
+template
+selfContainedDirectMappedFixedValueFvPatchField::selfContainedDirectMappedFixedValueFvPatchField
+(
+ const selfContainedDirectMappedFixedValueFvPatchField& ptf,
+ const fvPatch& p,
+ const DimensionedField& iF,
+ const fvPatchFieldMapper& mapper
+)
+:
+ directMappedPatchBase(p.patch(), ptf),
+ fixedValueFvPatchField(ptf, p, iF, mapper),
+ fieldName_(ptf.fieldName_),
+ setAverage_(ptf.setAverage_),
+ average_(ptf.average_),
+ interpolationScheme_(ptf.interpolationScheme_)
+{}
+
+
+template
+selfContainedDirectMappedFixedValueFvPatchField::
+selfContainedDirectMappedFixedValueFvPatchField
+(
+ const fvPatch& p,
+ const DimensionedField& iF,
+ const dictionary& dict
+)
+:
+ directMappedPatchBase(p.patch(), dict),
+ fixedValueFvPatchField(p, iF, dict),
+ fieldName_(dict.lookupOrDefault("fieldName", iF.name())),
+ setAverage_(readBool(dict.lookup("setAverage"))),
+ average_(pTraits(dict.lookup("average"))),
+ interpolationScheme_(interpolationCell::typeName)
+{
+ if (mode() == directMappedPatchBase::NEARESTCELL)
+ {
+ dict.lookup("interpolationScheme") >> interpolationScheme_;
+ }
+}
+
+
+template
+selfContainedDirectMappedFixedValueFvPatchField::
+selfContainedDirectMappedFixedValueFvPatchField
+(
+ const fvPatch& p,
+ const DimensionedField& iF,
+
+ // directMappedPatchBase
+ const word& sampleRegion,
+ const sampleMode sampleMode,
+ const word& samplePatch,
+ const scalar distance,
+
+ // My settings
+ const word& fieldName,
+ const bool setAverage,
+ const Type average,
+ const word& interpolationScheme
+)
+:
+ directMappedPatchBase
+ (
+ p.patch(),
+ sampleRegion,
+ sampleMode,
+ samplePatch,
+ distance
+ ),
+ fixedValueFvPatchField(p, iF),
+ fieldName_(fieldName),
+ setAverage_(setAverage),
+ average_(average),
+ interpolationScheme_(interpolationScheme)
+{}
+
+
+
+template
+selfContainedDirectMappedFixedValueFvPatchField::selfContainedDirectMappedFixedValueFvPatchField
+(
+ const selfContainedDirectMappedFixedValueFvPatchField& ptf
+)
+:
+ directMappedPatchBase(ptf.patch().patch(), ptf),
+ fixedValueFvPatchField(ptf),
+ fieldName_(ptf.fieldName_),
+ setAverage_(ptf.setAverage_),
+ average_(ptf.average_),
+ interpolationScheme_(ptf.interpolationScheme_)
+{}
+
+
+template
+selfContainedDirectMappedFixedValueFvPatchField::selfContainedDirectMappedFixedValueFvPatchField
+(
+ const selfContainedDirectMappedFixedValueFvPatchField& ptf,
+ const DimensionedField& iF
+)
+:
+ directMappedPatchBase(ptf.patch().patch(), ptf),
+ fixedValueFvPatchField(ptf, iF),
+ fieldName_(ptf.fieldName_),
+ setAverage_(ptf.setAverage_),
+ average_(ptf.average_),
+ interpolationScheme_(ptf.interpolationScheme_)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+template
+const GeometricField&
+selfContainedDirectMappedFixedValueFvPatchField::sampleField() const
+{
+ typedef GeometricField fieldType;
+
+ const fvMesh& nbrMesh = refCast(sampleMesh());
+
+ if (sameRegion())
+ {
+ if (fieldName_ == this->dimensionedInternalField().name())
+ {
+ // Optimisation: bypass field lookup
+ return
+ dynamic_cast
+ (
+ this->dimensionedInternalField()
+ );
+ }
+ else
+ {
+ const fvMesh& thisMesh = this->patch().boundaryMesh().mesh();
+ return thisMesh.lookupObject(fieldName_);
+ }
+ }
+ else
+ {
+ return nbrMesh.lookupObject(fieldName_);
+ }
+}
+
+
+template
+const interpolation&
+selfContainedDirectMappedFixedValueFvPatchField::interpolator() const
+{
+ if (!interpolator_.valid())
+ {
+ interpolator_ = interpolation::New
+ (
+ interpolationScheme_,
+ sampleField()
+ );
+ }
+ return interpolator_();
+}
+
+
+template
+void selfContainedDirectMappedFixedValueFvPatchField::updateCoeffs()
+{
+ if (this->updated())
+ {
+ return;
+ }
+
+ typedef GeometricField fieldType;
+
+ const fvMesh& thisMesh = this->patch().boundaryMesh().mesh();
+ const fvMesh& nbrMesh = refCast(sampleMesh());
+ const mapDistribute& distMap = directMappedPatchBase::map();
+
+ // Result of obtaining remote values
+ Field newValues;
+
+ switch (mode())
+ {
+ case NEARESTCELL:
+ {
+ if (interpolationScheme_ != interpolationCell::typeName)
+ {
+ // Need to do interpolation so need cells to sample.
+
+ // Send back sample points to the processor that holds the cell
+ vectorField samples(samplePoints());
+ distMap.reverseDistribute
+ (
+ (sameRegion() ? thisMesh.nCells() : nbrMesh.nCells()),
+ point::max,
+ samples
+ );
+
+ const interpolation& interp = interpolator();
+
+ newValues.setSize(samples.size(), pTraits::max);
+ forAll(samples, cellI)
+ {
+ if (samples[cellI] != point::max)
+ {
+ newValues[cellI] = interp.interpolate
+ (
+ samples[cellI],
+ cellI
+ );
+ }
+ }
+ }
+ else
+ {
+ newValues = sampleField();
+ }
+
+ distMap.distribute(newValues);
+
+ break;
+ }
+ case NEARESTPATCHFACE:
+ {
+ const label nbrPatchID = nbrMesh.boundaryMesh().findPatchID
+ (
+ samplePatch()
+ );
+ if (nbrPatchID < 0)
+ {
+ FatalErrorIn
+ (
+ "void selfContainedDirectMappedFixedValueFvPatchField::"
+ "updateCoeffs()"
+ )<< "Unable to find sample patch " << samplePatch()
+ << " in region " << sampleRegion()
+ << " for patch " << this->patch().name() << nl
+ << abort(FatalError);
+ }
+
+ const fieldType& nbrField = sampleField();
+
+ newValues = nbrField.boundaryField()[nbrPatchID];
+ distMap.distribute(newValues);
+
+ break;
+ }
+ case NEARESTFACE:
+ {
+ Field allValues(nbrMesh.nFaces(), pTraits::zero);
+
+ const fieldType& nbrField = sampleField();
+
+ forAll(nbrField.boundaryField(), patchI)
+ {
+ const fvPatchField& pf =
+ nbrField.boundaryField()[patchI];
+ label faceStart = pf.patch().start();
+
+ forAll(pf, faceI)
+ {
+ allValues[faceStart++] = pf[faceI];
+ }
+ }
+
+ distMap.distribute(allValues);
+
+ newValues.transfer(allValues);
+
+ break;
+ }
+ default:
+ {
+ FatalErrorIn
+ (
+ "selfContainedDirectMappedFixedValueFvPatchField::updateCoeffs()"
+ )<< "Unknown sampling mode: " << mode()
+ << nl << abort(FatalError);
+ }
+ }
+
+ if (setAverage_)
+ {
+ Type averagePsi =
+ gSum(this->patch().magSf()*newValues)
+ /gSum(this->patch().magSf());
+
+ if (mag(averagePsi)/mag(average_) > 0.5)
+ {
+ newValues *= mag(average_)/mag(averagePsi);
+ }
+ else
+ {
+ newValues += (average_ - averagePsi);
+ }
+ }
+
+ this->operator==(newValues);
+
+ if (debug)
+ {
+ Info<< "selfContainedDirectMapped on field:"
+ << this->dimensionedInternalField().name()
+ << " patch:" << this->patch().name()
+ << " avg:" << gAverage(*this)
+ << " min:" << gMin(*this)
+ << " max:" << gMax(*this)
+ << endl;
+ }
+
+ fixedValueFvPatchField::updateCoeffs();
+}
+
+
+template
+void selfContainedDirectMappedFixedValueFvPatchField::write(Ostream& os) const
+{
+ fvPatchField::write(os);
+ directMappedPatchBase::write(os);
+ os.writeKeyword("fieldName") << fieldName_ << token::END_STATEMENT << nl;
+ os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl;
+ os.writeKeyword("average") << average_ << token::END_STATEMENT << nl;
+ os.writeKeyword("interpolationScheme") << interpolationScheme_
+ << token::END_STATEMENT << nl;
+ this->writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchField.H
new file mode 100644
index 0000000000..815663902f
--- /dev/null
+++ b/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchField.H
@@ -0,0 +1,200 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-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 .
+
+Class
+ Foam::selfContainedDirectMappedFixedValueFvPatchField
+
+Description
+ Self-contained version of directMapped. Does not use information on
+ patch, instead holds it locally (and possibly duplicate) so use
+ normal directMapped in preference and only use this if you cannot
+ change the underlying patch type to directMapped.
+
+SourceFiles
+ selfContainedDirectMappedFixedValueFvPatchField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef selfContainedDirectMappedFixedValueFvPatchField_H
+#define selfContainedDirectMappedFixedValueFvPatchField_H
+
+#include "directMappedPatchBase.H"
+#include "fixedValueFvPatchFields.H"
+#include "interpolation.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+ Class selfContainedDirectMappedFixedValueFvPatch Declaration
+\*---------------------------------------------------------------------------*/
+
+template
+class selfContainedDirectMappedFixedValueFvPatchField
+:
+ public directMappedPatchBase,
+ public fixedValueFvPatchField
+{
+ // Private data
+
+ //- Name of field to sample - defaults to field associated with this
+ // patchField if not specified
+ word fieldName_;
+
+ //- If true adjust the mapped field to maintain average value average_
+ const bool setAverage_;
+
+ //- Average value the mapped field is adjusted to maintain if
+ // setAverage_ is set true
+ const Type average_;
+
+ //- Interpolation scheme to use for nearestcell mode
+ word interpolationScheme_;
+
+ mutable autoPtr > interpolator_;
+
+ // Private Member Functions
+
+ //- Field to sample. Either on my or nbr mesh
+ const GeometricField& sampleField() const;
+
+ //- Access the interpolation method
+ const interpolation& interpolator() const;
+
+public:
+
+ //- Runtime type information
+ TypeName("selfContainedDirectMapped");
+
+
+ // Constructors
+
+ //- Construct from patch and internal field
+ selfContainedDirectMappedFixedValueFvPatchField
+ (
+ const fvPatch&,
+ const DimensionedField&
+ );
+
+ //- Construct from patch, internal field and dictionary
+ selfContainedDirectMappedFixedValueFvPatchField
+ (
+ const fvPatch&,
+ const DimensionedField&,
+ const dictionary&
+ );
+
+ //- Construct from patch, internal field and distance for normal type
+ // sampling
+ selfContainedDirectMappedFixedValueFvPatchField
+ (
+ const fvPatch&,
+ const DimensionedField&,
+
+ // directMappedPatchBase
+ const word& sampleRegion,
+ const sampleMode sampleMode,
+ const word& samplePatch,
+ const scalar distance,
+
+ // My settings
+ const word& fieldName,
+ const bool setAverage,
+ const Type average,
+ const word& interpolationScheme
+ );
+
+ //- Construct by mapping given selfContainedDirectMappedFixedValueFvPatchField
+ // onto a new patch
+ selfContainedDirectMappedFixedValueFvPatchField
+ (
+ const selfContainedDirectMappedFixedValueFvPatchField&,
+ const fvPatch&,
+ const DimensionedField&,
+ const fvPatchFieldMapper&
+ );
+
+ //- Construct as copy
+ selfContainedDirectMappedFixedValueFvPatchField
+ (
+ const selfContainedDirectMappedFixedValueFvPatchField&
+ );
+
+ //- Construct and return a clone
+ virtual tmp > clone() const
+ {
+ return tmp >
+ (
+ new selfContainedDirectMappedFixedValueFvPatchField(*this)
+ );
+ }
+
+ //- Construct as copy setting internal field reference
+ selfContainedDirectMappedFixedValueFvPatchField
+ (
+ const selfContainedDirectMappedFixedValueFvPatchField&,
+ const DimensionedField&
+ );
+
+ //- Construct and return a clone setting internal field reference
+ virtual tmp > clone
+ (
+ const DimensionedField& iF
+ ) const
+ {
+ return tmp >
+ (
+ new selfContainedDirectMappedFixedValueFvPatchField(*this, iF)
+ );
+ }
+
+
+ // Member functions
+
+ // Evaluation functions
+
+ //- Update the coefficients associated with the patch field
+ virtual void updateCoeffs();
+
+ //- Write
+ virtual void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+# include "selfContainedDirectMappedFixedValueFvPatchField.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchFields.C
new file mode 100644
index 0000000000..4338386527
--- /dev/null
+++ b/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchFields.C
@@ -0,0 +1,43 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-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 "selfContainedDirectMappedFixedValueFvPatchFields.H"
+#include "volMesh.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+makePatchFields(selfContainedDirectMappedFixedValue);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchFields.H
new file mode 100644
index 0000000000..9eb1154c2d
--- /dev/null
+++ b/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchFields.H
@@ -0,0 +1,49 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-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 .
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef selfContainedDirectMappedFixedValueFvPatchFields_H
+#define selfContainedDirectMappedFixedValueFvPatchFields_H
+
+#include "selfContainedDirectMappedFixedValueFvPatchField.H"
+#include "fieldTypes.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeFieldTypedefs(selfContainedDirectMappedFixedValue)
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchFieldsFwd.H b/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchFieldsFwd.H
new file mode 100644
index 0000000000..f284fc3bd7
--- /dev/null
+++ b/src/finiteVolume/fields/fvPatchFields/derived/selfContainedDirectMapped/selfContainedDirectMappedFixedValueFvPatchFieldsFwd.H
@@ -0,0 +1,50 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-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 .
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef selfContainedDirectMappedFixedValueFvPatchFieldsFwd_H
+#define selfContainedDirectMappedFixedValueFvPatchFieldsFwd_H
+
+#include "fieldTypes.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+template class selfContainedDirectMappedFixedValueFvPatchField;
+
+makePatchTypeFieldTypedefs(selfContainedDirectMappedFixedValue)
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files
index e869e24b1c..c1497c5e54 100644
--- a/src/postProcessing/functionObjects/field/Make/files
+++ b/src/postProcessing/functionObjects/field/Make/files
@@ -12,6 +12,9 @@ fieldValues/faceSource/faceSourceFunctionObject.C
fieldValues/cellSource/cellSource.C
fieldValues/cellSource/cellSourceFunctionObject.C
+nearWallFields/nearWallFields.C
+nearWallFields/nearWallFieldsFunctionObject.C
+
readFields/readFields.C
readFields/readFieldsFunctionObject.C
diff --git a/src/postProcessing/functionObjects/field/nearWallFields/IOnearWallFields.H b/src/postProcessing/functionObjects/field/nearWallFields/IOnearWallFields.H
new file mode 100644
index 0000000000..0d843b1470
--- /dev/null
+++ b/src/postProcessing/functionObjects/field/nearWallFields/IOnearWallFields.H
@@ -0,0 +1,49 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2010-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 .
+
+Typedef
+ Foam::IOnearWallFields
+
+Description
+ Instance of the generic IOOutputFilter for nearWallFields.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef IOnearWallFields_H
+#define IOnearWallFields_H
+
+#include "nearWallFields.H"
+#include "IOOutputFilter.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+ typedef IOOutputFilter IOnearWallFields;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C
new file mode 100644
index 0000000000..228fa5ad32
--- /dev/null
+++ b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C
@@ -0,0 +1,179 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2010-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 "nearWallFields.H"
+//#include "volFields.H"
+//#include "selfContainedDirectMappedFixedValueFvPatchFields.H"
+//#include "interpolationCellPoint.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+ defineTypeNameAndDebug(nearWallFields, 0);
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::nearWallFields::nearWallFields
+(
+ const word& name,
+ const objectRegistry& obr,
+ const dictionary& dict,
+ const bool loadFromFiles
+)
+:
+ name_(name),
+ obr_(obr),
+ active_(true),
+ fieldSet_()
+{
+ // Check if the available mesh is an fvMesh otherise deactivate
+ if (!isA(obr_))
+ {
+ active_ = false;
+ WarningIn
+ (
+ "nearWallFields::nearWallFields"
+ "("
+ "const word&, "
+ "const objectRegistry&, "
+ "const dictionary&, "
+ "const bool"
+ ")"
+ ) << "No fvMesh available, deactivating."
+ << endl;
+ }
+
+ read(dict);
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::nearWallFields::~nearWallFields()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+void Foam::nearWallFields::read(const dictionary& dict)
+{
+ if (active_)
+ {
+ const fvMesh& mesh = refCast(obr_);
+
+ dict.lookup("fields") >> fieldSet_;
+ patchSet_ =
+ mesh.boundaryMesh().patchSet(wordList(dict.lookup("patches")));
+ distance_ = readScalar(dict.lookup("distance"));
+
+
+ // Clear out any previously loaded fields
+ vsf_.clear();
+ vvf_.clear();
+ vSpheretf_.clear();
+ vSymmtf_.clear();
+ vtf_.clear();
+ fieldMap_.clear();
+ reverseFieldMap_.clear();
+
+
+ // Generate fields with selfContainedDirectMapped bc.
+
+ // Convert field to map
+ fieldMap_.resize(2*fieldSet_.size());
+ reverseFieldMap_.resize(2*fieldSet_.size());
+ forAll(fieldSet_, setI)
+ {
+ const word& fldName = fieldSet_[setI].first();
+ const word& sampleFldName = fieldSet_[setI].second();
+
+ fieldMap_.insert(fldName, sampleFldName);
+ reverseFieldMap_.insert(sampleFldName, fldName);
+ }
+
+ createFields(vsf_);
+ createFields(vvf_);
+ createFields(vSpheretf_);
+ createFields(vSymmtf_);
+ createFields(vtf_);
+ }
+}
+
+
+void Foam::nearWallFields::execute()
+{
+ if (active_)
+ {
+ sampleFields(vsf_);
+ sampleFields(vvf_);
+ sampleFields(vSpheretf_);
+ sampleFields(vSymmtf_);
+ sampleFields(vtf_);
+ }
+}
+
+
+void Foam::nearWallFields::end()
+{
+ // Do nothing
+}
+
+
+void Foam::nearWallFields::write()
+{
+ // Do nothing
+ if (active_)
+ {
+ Info<< "Writing sampled fields to " << obr_.time().timeName()
+ << endl;
+
+ forAll(vsf_, i)
+ {
+ vsf_[i].write();
+ }
+ forAll(vvf_, i)
+ {
+ vvf_[i].write();
+ }
+ forAll(vSpheretf_, i)
+ {
+ vSpheretf_[i].write();
+ }
+ forAll(vSymmtf_, i)
+ {
+ vSymmtf_[i].write();
+ }
+ forAll(vtf_, i)
+ {
+ vtf_[i].write();
+ }
+ }
+}
+
+
+// ************************************************************************* //
diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.H b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.H
new file mode 100644
index 0000000000..76da3c0e22
--- /dev/null
+++ b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.H
@@ -0,0 +1,206 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2010-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 .
+
+Class
+ Foam::nearWallFields
+
+Description
+ Samples near-patch volFields
+
+ Holds fields
+ - every timestep the field get updated with new values
+ - at write it writes the fields
+ so this functionObject can either be used to calculate a new field
+ as a postprocessing step or (since the fields are registered)
+ use these in another functionObject (e.g. faceSource).
+
+ surfaceValues
+ {
+ type nearWallFields;
+ ..
+ enabled true;
+ outputControl outputTime;
+ ..
+ // Name of volField and corresponding surfaceField
+ fields ((p pNear)(U UNear));
+ // Name of patch to sample
+ patches (movingWall);
+ // Distance away from the wall
+ distance 0.13; // distance away from wall
+ }
+
+
+SourceFiles
+ nearWallFields.C
+ IOnearWallFields.H
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef nearWallFields_H
+#define nearWallFields_H
+
+#include "OFstream.H"
+#include "volFields.H"
+#include "Tuple2.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Forward declaration of classes
+class objectRegistry;
+class dictionary;
+class mapPolyMesh;
+
+/*---------------------------------------------------------------------------*\
+ Class nearWallFields Declaration
+\*---------------------------------------------------------------------------*/
+
+class nearWallFields
+{
+protected:
+
+ // Protected data
+
+ //- Name of this set of nearWallFields object
+ word name_;
+
+ const objectRegistry& obr_;
+
+ //- on/off switch
+ bool active_;
+
+ // Read from dictionary
+
+ //- Fields to process
+ List > fieldSet_;
+
+ //- Patches to sample
+ labelHashSet patchSet_;
+
+ //- Distance away from wall
+ scalar distance_;
+
+ //- From original field to sampled result
+ HashTable fieldMap_;
+
+ //- From resulting back to original field
+ HashTable reverseFieldMap_;
+
+ //- Locally constructed fields
+ PtrList vsf_;
+ PtrList vvf_;
+ PtrList vSpheretf_;
+ PtrList vSymmtf_;
+ PtrList vtf_;
+
+
+ // Protected Member Functions
+
+ //- Disallow default bitwise copy construct
+ nearWallFields(const nearWallFields&);
+
+ //- Disallow default bitwise assignment
+ void operator=(const nearWallFields&);
+
+ template
+ void createFields
+ (
+ PtrList >&
+ ) const;
+
+ template
+ void sampleFields
+ (
+ PtrList >&
+ ) const;
+
+public:
+
+ //- Runtime type information
+ TypeName("nearWallFields");
+
+
+ // Constructors
+
+ //- Construct for given objectRegistry and dictionary.
+ // Allow the possibility to load fields from files
+ nearWallFields
+ (
+ const word& name,
+ const objectRegistry&,
+ const dictionary&,
+ const bool loadFromFiles = false
+ );
+
+
+ //- Destructor
+ virtual ~nearWallFields();
+
+
+ // Member Functions
+
+ //- Return name of the nearWallFields object
+ virtual const word& name() const
+ {
+ return name_;
+ }
+
+ //- Read the field min/max data
+ virtual void read(const dictionary&);
+
+ //- Execute, currently does nothing
+ virtual void execute();
+
+ //- Execute at the final time-loop, currently does nothing
+ virtual void end();
+
+ //- Write
+ virtual void write();
+
+ //- Update for changes of mesh
+ virtual void updateMesh(const mapPolyMesh&)
+ {}
+
+ //- Update for changes of mesh
+ virtual void movePoints(const pointField&)
+ {}
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+# include "nearWallFieldsTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.C b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.C
new file mode 100644
index 0000000000..a75f6f59a3
--- /dev/null
+++ b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.C
@@ -0,0 +1,46 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2010-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 "nearWallFieldsFunctionObject.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+ defineNamedTemplateTypeNameAndDebug
+ (
+ nearWallFieldsFunctionObject,
+ 0
+ );
+
+ addToRunTimeSelectionTable
+ (
+ functionObject,
+ nearWallFieldsFunctionObject,
+ dictionary
+ );
+}
+
+// ************************************************************************* //
diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.H b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.H
new file mode 100644
index 0000000000..3542b51bf8
--- /dev/null
+++ b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.H
@@ -0,0 +1,54 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2010-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 .
+
+Typedef
+ Foam::nearWallFieldsFunctionObject
+
+Description
+ FunctionObject wrapper around nearWallFields to allow
+ them to be created via the functions entry within controlDict.
+
+SourceFiles
+ nearWallFieldsFunctionObject.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef nearWallFieldsFunctionObject_H
+#define nearWallFieldsFunctionObject_H
+
+#include "nearWallFields.H"
+#include "OutputFilterFunctionObject.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+ typedef OutputFilterFunctionObject
+ nearWallFieldsFunctionObject;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsTemplates.C b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsTemplates.C
new file mode 100644
index 0000000000..62de2c1e95
--- /dev/null
+++ b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsTemplates.C
@@ -0,0 +1,124 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2010-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 "nearWallFields.H"
+#include "selfContainedDirectMappedFixedValueFvPatchFields.H"
+#include "interpolationCellPoint.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+template
+void Foam::nearWallFields::createFields
+(
+ PtrList >& sflds
+) const
+{
+ typedef GeometricField vfType;
+
+ HashTable flds(obr_.lookupClass());
+
+ forAllConstIter(typename HashTable, flds, iter)
+ {
+ const vfType& fld = *iter();
+
+ if (fieldMap_.found(fld.name()))
+ {
+ const word& sampleFldName = fieldMap_[fld.name()];
+
+ if (obr_.found(sampleFldName))
+ {
+ Info<< " a field " << sampleFldName
+ << " already exists on the mesh."
+ << endl;
+ }
+ else
+ {
+ label sz = sflds.size();
+ sflds.setSize(sz+1);
+
+ IOobject io(fld);
+ io.readOpt() = IOobject::NO_READ;
+ io.rename(sampleFldName);
+
+ sflds.set(sz, new vfType(io, fld));
+ vfType& sampleFld = sflds[sz];
+
+ // Reset the bcs to be directMapped
+ forAllConstIter(labelHashSet, patchSet_, iter)
+ {
+ label patchI = iter.key();
+
+ sampleFld.boundaryField().set
+ (
+ patchI,
+ new selfContainedDirectMappedFixedValueFvPatchField
+
+ (
+ sampleFld.mesh().boundary()[patchI],
+ sampleFld.dimensionedInternalField(),
+
+ sampleFld.mesh().name(),
+ directMappedPatchBase::NEARESTCELL,
+ word::null, // samplePatch
+ -distance_,
+
+ sampleFld.name(), // fieldName
+ false, // setAverage
+ pTraits::zero, // average
+ interpolationCellPoint::typeName
+ )
+ );
+ }
+
+ Info<< " created " << sampleFld.name() << " to sample "
+ << fld.name() << endl;
+ }
+ }
+ }
+}
+
+
+template
+void Foam::nearWallFields::sampleFields
+(
+ PtrList >& sflds
+) const
+{
+ typedef GeometricField vfType;
+
+ forAll(sflds, i)
+ {
+ const word& fldName = reverseFieldMap_[sflds[i].name()];
+ const vfType& fld = obr_.lookupObject(fldName);
+
+ // Take over internal and boundary values
+ sflds[i] == fld;
+ // Evaluate to update the directMapped
+ sflds[i].correctBoundaryConditions();
+ }
+}
+
+
+// ************************************************************************* //
diff --git a/src/sampling/Make/files b/src/sampling/Make/files
index 6fee75b8f7..8097a2567f 100644
--- a/src/sampling/Make/files
+++ b/src/sampling/Make/files
@@ -27,6 +27,7 @@ $(setWriters)/xmgrace/xmgraceSetWriterRunTime.C
cuttingPlane/cuttingPlane.C
sampledSurface/sampledPatch/sampledPatch.C
+sampledSurface/sampledPatchInternalField/sampledPatchInternalField.C
sampledSurface/sampledPlane/sampledPlane.C
sampledSurface/isoSurface/isoSurface.C
sampledSurface/isoSurface/sampledIsoSurface.C
diff --git a/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalField.C b/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalField.C
new file mode 100644
index 0000000000..3b4a150ad7
--- /dev/null
+++ b/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalField.C
@@ -0,0 +1,176 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-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 "sampledPatchInternalField.H"
+#include "dictionary.H"
+#include "polyMesh.H"
+#include "polyPatch.H"
+#include "volFields.H"
+
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+ defineTypeNameAndDebug(sampledPatchInternalField, 0);
+ addNamedToRunTimeSelectionTable
+ (
+ sampledSurface,
+ sampledPatchInternalField,
+ word,
+ patchInternalField
+ );
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::sampledPatchInternalField::sampledPatchInternalField
+(
+ const word& name,
+ const polyMesh& mesh,
+ const dictionary& dict
+)
+:
+ sampledPatch(name, mesh, dict),
+ directMappedPatchBase
+ (
+ mesh.boundaryMesh()[sampledPatch::patchIndex()],
+ mesh.name(), // sampleRegion
+ directMappedPatchBase::NEARESTCELL, // sampleMode
+ word::null, // samplePatch
+ -readScalar(dict.lookup("distance"))
+ )
+{}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::sampledPatchInternalField::~sampledPatchInternalField()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+Foam::tmp Foam::sampledPatchInternalField::sample
+(
+ const volScalarField& vField
+) const
+{
+ return sampleField(vField);
+}
+
+
+Foam::tmp Foam::sampledPatchInternalField::sample
+(
+ const volVectorField& vField
+) const
+{
+ return sampleField(vField);
+}
+
+Foam::tmp Foam::sampledPatchInternalField::sample
+(
+ const volSphericalTensorField& vField
+) const
+{
+ return sampleField(vField);
+}
+
+
+Foam::tmp Foam::sampledPatchInternalField::sample
+(
+ const volSymmTensorField& vField
+) const
+{
+ return sampleField(vField);
+}
+
+
+Foam::tmp Foam::sampledPatchInternalField::sample
+(
+ const volTensorField& vField
+) const
+{
+ return sampleField(vField);
+}
+
+
+Foam::tmp Foam::sampledPatchInternalField::interpolate
+(
+ const interpolation& interpolator
+) const
+{
+ return interpolateField(interpolator);
+}
+
+
+Foam::tmp Foam::sampledPatchInternalField::interpolate
+(
+ const interpolation& interpolator
+) const
+{
+ return interpolateField(interpolator);
+}
+
+Foam::tmp
+Foam::sampledPatchInternalField::interpolate
+(
+ const interpolation& interpolator
+) const
+{
+ return interpolateField(interpolator);
+}
+
+
+Foam::tmp Foam::sampledPatchInternalField::interpolate
+(
+ const interpolation& interpolator
+) const
+{
+ return interpolateField(interpolator);
+}
+
+
+Foam::tmp Foam::sampledPatchInternalField::interpolate
+(
+ const interpolation& interpolator
+) const
+{
+ return interpolateField(interpolator);
+}
+
+
+void Foam::sampledPatchInternalField::print(Ostream& os) const
+{
+ os << "sampledPatchInternalField: " << name() << " :"
+ << " patch:" << patchName()
+ << " faces:" << faces().size()
+ << " points:" << points().size();
+}
+
+
+// ************************************************************************* //
diff --git a/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalField.H b/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalField.H
new file mode 100644
index 0000000000..d492dd9f99
--- /dev/null
+++ b/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalField.H
@@ -0,0 +1,177 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-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 .
+
+Class
+ Foam::sampledPatchInternalField
+
+Description
+ Variation of sampledPatch that samples the internalField (at a given
+ normal distance from the patch) instead of the patchField.
+ Note:
+ - interpolate=false : get cell value on faces
+ - interpolate=true : interpolate inside cell and interpolate to points
+ There is no option to get interpolated value inside the cell on the faces.
+
+SourceFiles
+ sampledPatchInternalField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef sampledPatchInternalField_H
+#define sampledPatchInternalField_H
+
+#include "sampledPatch.H"
+#include "directMappedPatchBase.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+ Class sampledPatchInternalField Declaration
+\*---------------------------------------------------------------------------*/
+
+class sampledPatchInternalField
+:
+ public sampledPatch,
+ public directMappedPatchBase
+{
+
+ // Private Member Functions
+
+ //- sample field on faces
+ template
+ tmp > sampleField
+ (
+ const GeometricField& vField
+ ) const;
+
+ template
+ tmp > interpolateField(const interpolation&) const;
+
+public:
+
+ //- Runtime type information
+ TypeName("sampledPatchInternalField");
+
+
+ // Constructors
+
+ //- Construct from dictionary
+ sampledPatchInternalField
+ (
+ const word& name,
+ const polyMesh& mesh,
+ const dictionary& dict
+ );
+
+
+ //- Destructor
+ virtual ~sampledPatchInternalField();
+
+
+ // Member Functions
+
+ //- sample field on surface
+ virtual tmp sample
+ (
+ const volScalarField&
+ ) const;
+
+ //- sample field on surface
+ virtual tmp sample
+ (
+ const volVectorField&
+ ) const;
+
+ //- sample field on surface
+ virtual tmp sample
+ (
+ const volSphericalTensorField&
+ ) const;
+
+ //- sample field on surface
+ virtual tmp sample
+ (
+ const volSymmTensorField&
+ ) const;
+
+ //- sample field on surface
+ virtual tmp sample
+ (
+ const volTensorField&
+ ) const;
+
+
+ //- interpolate field on surface
+ virtual tmp interpolate
+ (
+ const interpolation&
+ ) const;
+
+
+ //- interpolate field on surface
+ virtual tmp interpolate
+ (
+ const interpolation&
+ ) const;
+
+ //- interpolate field on surface
+ virtual tmp interpolate
+ (
+ const interpolation&
+ ) const;
+
+ //- interpolate field on surface
+ virtual tmp interpolate
+ (
+ const interpolation&
+ ) const;
+
+ //- interpolate field on surface
+ virtual tmp interpolate
+ (
+ const interpolation&
+ ) const;
+
+ //- Write
+ virtual void print(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+# include "sampledPatchInternalFieldTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalFieldTemplates.C b/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalFieldTemplates.C
new file mode 100644
index 0000000000..1da319db8a
--- /dev/null
+++ b/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalFieldTemplates.C
@@ -0,0 +1,114 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 1991-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 "sampledPatchInternalField.H"
+#include "interpolationCellPoint.H"
+#include "PrimitivePatchInterpolation.H"
+
+// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+
+template
+Foam::tmp >
+Foam::sampledPatchInternalField::sampleField
+(
+ const GeometricField& vField
+) const
+{
+ const mapDistribute& distMap = map();
+
+ // One value per face
+ tmp > tvalues(new Field(patchFaceLabels().size()));
+ Field& values = tvalues();
+
+ if (patchIndex() != -1)
+ {
+ Field interpVals = vField.internalField();
+ distMap.distribute(interpVals);
+
+ forAll(patchFaceLabels(), elemI)
+ {
+ values[elemI] = interpVals[patchFaceLabels()[elemI]];
+ }
+ }
+
+ return tvalues;
+}
+
+
+template
+Foam::tmp >
+Foam::sampledPatchInternalField::interpolateField
+(
+ const interpolation& interpolator
+) const
+{
+ // One value per vertex
+
+ if (patchIndex() != -1)
+ {
+ // See directMappedFixedValueFvPatchField
+ const mapDistribute& distMap = map();
+
+ const polyPatch& pp = mesh().boundaryMesh()[patchIndex()];
+
+ // Send back sample points to processor that holds the cell.
+ // Mark cells with point::max so we know which ones we need
+ // to interpolate (since expensive).
+ vectorField samples(pp.faceCentres());
+ distMap.reverseDistribute(mesh().nCells(), point::max, samples);
+
+ Field patchVals(mesh().nCells());
+
+ forAll(samples, cellI)
+ {
+ if (samples[cellI] != point::max)
+ {
+ patchVals[cellI] = interpolator.interpolate
+ (
+ samples[cellI],
+ cellI
+ );
+ }
+ }
+
+ distMap.distribute(patchVals);
+
+ // Now patchVals holds the interpolated data in patch face order.
+ // Interpolate to points. Note: points are patch.localPoints() so
+ // can use standard interpolation
+
+ return PrimitivePatchInterpolation
+ (
+ pp
+ ).faceToPointInterpolate(patchVals);
+ }
+ else
+ {
+ return tmp >(new Field(points().size()));
+ }
+}
+
+
+// ************************************************************************* //