From 520c14c136543e4efe097d17b6190a645d4c61db Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 14 Mar 2018 13:04:22 +0100 Subject: [PATCH] ENH: add meshTools polyFields - provides a simple means of writing an internal dimensioned field when fvMesh is not available (eg, during mesh creation). --- src/meshTools/Make/files | 1 + src/meshTools/fields/polyFields.C | 71 ++++++++++++++++++++++++ src/meshTools/fields/polyFields.H | 63 ++++++++++++++++++++++ src/meshTools/fields/polyGeoMesh.H | 86 ++++++++++++++++++++++++++++++ 4 files changed, 221 insertions(+) create mode 100644 src/meshTools/fields/polyFields.C create mode 100644 src/meshTools/fields/polyFields.H create mode 100644 src/meshTools/fields/polyGeoMesh.H diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 1beec64e855..d9a73c12548 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -76,6 +76,7 @@ meshSearch/meshSearch.C meshSearch/meshSearchFACE_CENTRE_TRISMeshObject.C meshSearch/meshSearchMeshObject.C +fields/polyFields.C meshTools/meshTools.C algorithms = algorithms diff --git a/src/meshTools/fields/polyFields.C b/src/meshTools/fields/polyFields.C new file mode 100644 index 00000000000..06ed0dce52a --- /dev/null +++ b/src/meshTools/fields/polyFields.C @@ -0,0 +1,71 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "polyFields.H" + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +// Naming to shadow volScalarField::Internal etc. +// keep synchronized with finiteVolume volFields.C + +template<> +const word DimensionedField<scalar, polyGeoMesh>::typeName +( + "volScalarField::Internal" +); + +template<> +const word DimensionedField<vector, polyGeoMesh>::typeName +( + "volVectorField::Internal" +); + +template<> +const word DimensionedField<sphericalTensor, polyGeoMesh>::typeName +( + "volSphericalTensorField::Internal" +); + +template<> +const word DimensionedField<symmTensor, polyGeoMesh>::typeName +( + "volSymmTensorField::Internal" +); + +template<> +const word DimensionedField<tensor, polyGeoMesh>::typeName +( + "volTensorField::Internal" +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/meshTools/fields/polyFields.H b/src/meshTools/fields/polyFields.H new file mode 100644 index 00000000000..0222a075a01 --- /dev/null +++ b/src/meshTools/fields/polyFields.H @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. + +InClass + Foam::polyFields + +Description + A polyMesh-based naming and storage for internal volume fields when a + Foam::fvMesh is unavailable. Use sparingly. + +SourceFields + polyFields.C + +\*---------------------------------------------------------------------------*/ + +#ifndef polyFields_H +#define polyFields_H + +#include "DimensionedField.H" +#include "polyGeoMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +typedef DimensionedField<scalar,polyGeoMesh> polyScalarField; +typedef DimensionedField<vector,polyGeoMesh> polyVectorField; +typedef DimensionedField<sphericalTensor,polyGeoMesh> polySphericalTensorField; +typedef DimensionedField<symmTensor,polyGeoMesh> polySymmTensorField; +typedef DimensionedField<tensor,polyGeoMesh> polyTensorField; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/fields/polyGeoMesh.H b/src/meshTools/fields/polyGeoMesh.H new file mode 100644 index 00000000000..57596d873cb --- /dev/null +++ b/src/meshTools/fields/polyGeoMesh.H @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. + +Class + Foam::polyGeoMesh + +Description + The polyMesh GeoMesh for holding internal fields without an fvMesh. + +\*---------------------------------------------------------------------------*/ + +#ifndef polyGeoMesh_H +#define polyGeoMesh_H + +#include "GeoMesh.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class polyGeoMesh Declaration +\*---------------------------------------------------------------------------*/ + +class polyGeoMesh +: + public GeoMesh<polyMesh> +{ +public: + + // Constructors + + //- Construct from polyMesh reference + explicit polyGeoMesh(const polyMesh& mesh) + : + GeoMesh<polyMesh>(mesh) + {} + + + // Member Functions + + //- Return size + static label size(const polyMesh& mesh) + { + return mesh.nCells(); + } + + //- Return size + label size() const + { + return size(mesh_); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // -- GitLab