diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C index c3262e6b9c..4796f4b4f1 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C @@ -428,7 +428,43 @@ void Foam::ensightMesh::writePrimsBinary } -void Foam::ensightMesh::writePolys +void Foam::ensightMesh::writePolysNFaces +( + const labelList& polys, + const cellList& cellFaces, + OFstream& ensightGeometryFile +) const +{ + forAll(polys, i) + { + ensightGeometryFile + << setw(10) << cellFaces[polys[i]].size() << nl; + } +} + + +void Foam::ensightMesh::writePolysNPointsPerFace +( + const labelList& polys, + const cellList& cellFaces, + const faceList& faces, + OFstream& ensightGeometryFile +) const +{ + forAll(polys, i) + { + const labelList& cf = cellFaces[polys[i]]; + + forAll(cf, faceI) + { + ensightGeometryFile + << setw(10) << faces[cf[faceI]].size() << nl; + } + } +} + + +void Foam::ensightMesh::writePolysPoints ( const labelList& polys, const cellList& cellFaces, @@ -437,50 +473,190 @@ void Foam::ensightMesh::writePolys OFstream& ensightGeometryFile ) const { - if (polys.size()) + label po = pointOffset + 1; + + forAll(polys, i) { - ensightGeometryFile - << "nfaced" << nl << setw(10) << polys.size() << nl; + const labelList& cf = cellFaces[polys[i]]; - label po = pointOffset + 1; - - forAll(polys, i) + forAll(cf, faceI) { - ensightGeometryFile - << setw(10) << cellFaces[polys[i]].size() << nl; - } + const face& f = faces[cf[faceI]]; - forAll(polys, i) - { - const labelList& cf = cellFaces[polys[i]]; - - forAll(cf, faceI) + forAll(f, pointI) { - ensightGeometryFile - << setw(10) << faces[cf[faceI]].size() << nl; - } - } - - forAll(polys, i) - { - const labelList& cf = cellFaces[polys[i]]; - - forAll(cf, faceI) - { - const face& f = faces[cf[faceI]]; - - forAll(f, pointI) - { - ensightGeometryFile << setw(10) << f[pointI] + po; - } - ensightGeometryFile << nl; + ensightGeometryFile << setw(10) << f[pointI] + po; } + ensightGeometryFile << nl; } } } -void Foam::ensightMesh::writePolysBinary +void Foam::ensightMesh::writeAllPolys +( + const labelList& pointOffsets, + OFstream& ensightGeometryFile +) const +{ + if (meshCellSets_.nPolys) + { + const cellList& cellFaces = mesh_.cells(); + const faceList& faces = mesh_.faces(); + + if (Pstream::master()) + { + ensightGeometryFile + << "nfaced" << nl << setw(10) << meshCellSets_.nPolys << nl; + } + + // Number of faces for each poly cell + if (Pstream::master()) + { + // Master + writePolysNFaces + ( + meshCellSets_.polys, + cellFaces, + ensightGeometryFile + ); + // Slaves + for (int slave=1; slave& iF +) +: + fixedValueFvPatchField(p, iF), + U_(vector::zero) +{} + + +translatingWallVelocityFvPatchVectorField:: +translatingWallVelocityFvPatchVectorField +( + const translatingWallVelocityFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchField(ptf, p, iF, mapper), + U_(ptf.U_) +{} + + +translatingWallVelocityFvPatchVectorField:: +translatingWallVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchField(p, iF), + U_(dict.lookup("U")) +{ + // Evaluate the wall velocity + updateCoeffs(); +} + + +translatingWallVelocityFvPatchVectorField:: +translatingWallVelocityFvPatchVectorField +( + const translatingWallVelocityFvPatchVectorField& twvpvf +) +: + fixedValueFvPatchField(twvpvf), + U_(twvpvf.U_) +{} + + +translatingWallVelocityFvPatchVectorField:: +translatingWallVelocityFvPatchVectorField +( + const translatingWallVelocityFvPatchVectorField& twvpvf, + const DimensionedField& iF +) +: + fixedValueFvPatchField(twvpvf, iF), + U_(twvpvf.U_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void translatingWallVelocityFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Remove the component of U normal to the wall in case the wall is not flat + vectorField n = patch().nf(); + vectorField::operator=(U_ - n*(n & U_)); + + fixedValueFvPatchVectorField::updateCoeffs(); +} + + +void translatingWallVelocityFvPatchVectorField::write(Ostream& os) const +{ + fvPatchVectorField::write(os); + os.writeKeyword("U") << U_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchVectorField, + translatingWallVelocityFvPatchVectorField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/translatingWallVelocity/translatingWallVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/translatingWallVelocity/translatingWallVelocityFvPatchVectorField.H new file mode 100644 index 0000000000..68345ae537 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/translatingWallVelocity/translatingWallVelocityFvPatchVectorField.H @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::translatingWallVelocityFvPatchVectorField + +Description + Foam::translatingWallVelocityFvPatchVectorField + +SourceFiles + translatingWallVelocityFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef translatingWallVelocityFvPatchVectorField_H +#define translatingWallVelocityFvPatchVectorField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class translatingWallVelocityFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +class translatingWallVelocityFvPatchVectorField +: + public fixedValueFvPatchVectorField +{ + // Private data + + //- Origin of the rotation + vector U_; + + +public: + + //- Runtime type information + TypeName("translatingWallVelocity"); + + + // Constructors + + //- Construct from patch and internal field + translatingWallVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + translatingWallVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given a + // translatingWallVelocityFvPatchVectorField onto a new patch + translatingWallVelocityFvPatchVectorField + ( + const translatingWallVelocityFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + translatingWallVelocityFvPatchVectorField + ( + const translatingWallVelocityFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new translatingWallVelocityFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + translatingWallVelocityFvPatchVectorField + ( + const translatingWallVelocityFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new translatingWallVelocityFvPatchVectorField(*this, iF) + ); + } + + + + // Member functions + + // Access functions + + //- Return the velocity + const vector& U() const + { + return U_; + } + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //