From 16bc63864ea4f9d6c8c0db0116bc5df7a6bf90a6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 24 Jan 2019 00:03:26 +0100 Subject: [PATCH] ENH: added polySurface storage with fields (#1206) - This simple container provides a means of storing faces/points (ie, surfaces) with registered dimensioned fields. The main registry is used to hold face-based data, a secondary sub-registry is used to hold point-based data. This allows the same name for CellData and PointData fields without name collisions. --- .../sampledSurface/sampledSurfaceRegister.C | 294 ++++++++++ src/surfMesh/Make/files | 14 +- .../polySurface/fields/polySurfaceFields.C | 64 +++ .../polySurface/fields/polySurfaceFields.H | 46 ++ .../polySurface/fields/polySurfaceFieldsFwd.H | 92 ++++ .../polySurface/fields/polySurfaceGeoMesh.H | 86 +++ .../fields/polySurfacePointFields.C | 64 +++ .../fields/polySurfacePointFields.H | 46 ++ .../fields/polySurfacePointFieldsFwd.H | 71 +++ .../fields/polySurfacePointGeoMesh.H | 86 +++ src/surfMesh/polySurface/polySurface.C | 519 ++++++++++++++++++ src/surfMesh/polySurface/polySurface.H | 483 ++++++++++++++++ src/surfMesh/polySurface/polySurfaceClear.C | 66 +++ src/surfMesh/polySurface/polySurfaceIO.C | 42 ++ .../polySurface/polySurfaceTemplates.C | 174 ++++++ src/surfMesh/surfMesh/surfMesh.C | 118 +++- src/surfMesh/surfMesh/surfMesh.H | 66 ++- src/surfMesh/surfMesh/surfMeshClear.C | 7 + src/surfMesh/surfMesh/surfMeshTemplates.C | 111 ++++ 19 files changed, 2439 insertions(+), 10 deletions(-) create mode 100644 src/sampling/sampledSurface/sampledSurface/sampledSurfaceRegister.C create mode 100644 src/surfMesh/polySurface/fields/polySurfaceFields.C create mode 100644 src/surfMesh/polySurface/fields/polySurfaceFields.H create mode 100644 src/surfMesh/polySurface/fields/polySurfaceFieldsFwd.H create mode 100644 src/surfMesh/polySurface/fields/polySurfaceGeoMesh.H create mode 100644 src/surfMesh/polySurface/fields/polySurfacePointFields.C create mode 100644 src/surfMesh/polySurface/fields/polySurfacePointFields.H create mode 100644 src/surfMesh/polySurface/fields/polySurfacePointFieldsFwd.H create mode 100644 src/surfMesh/polySurface/fields/polySurfacePointGeoMesh.H create mode 100644 src/surfMesh/polySurface/polySurface.C create mode 100644 src/surfMesh/polySurface/polySurface.H create mode 100644 src/surfMesh/polySurface/polySurfaceClear.C create mode 100644 src/surfMesh/polySurface/polySurfaceIO.C create mode 100644 src/surfMesh/polySurface/polySurfaceTemplates.C create mode 100644 src/surfMesh/surfMesh/surfMeshTemplates.C diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurfaceRegister.C b/src/sampling/sampledSurface/sampledSurface/sampledSurfaceRegister.C new file mode 100644 index 0000000000..c7fa0297d0 --- /dev/null +++ b/src/sampling/sampledSurface/sampledSurface/sampledSurfaceRegister.C @@ -0,0 +1,294 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2010, 2018-2019 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- + | Copyright (C) 2011-2016 OpenFOAM Foundation +------------------------------------------------------------------------------- +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 "sampledSurface.H" +#include "polyMesh.H" +#include "demandDrivenData.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(sampledSurface, 0); + defineRunTimeSelectionTable(sampledSurface, word); +} + + +const Foam::wordList Foam::sampledSurface::surfaceFieldTypes +({ + "surfaceScalarField", + "surfaceVectorField", + "surfaceSphericalTensorField", + "surfaceSymmTensorField", + "surfaceTensorField" +}); + + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::sampledSurface::clearGeom() const +{ + area_ = -1; +} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // + +Foam::autoPtr Foam::sampledSurface::New +( + const word& name, + const polyMesh& mesh, + const dictionary& dict +) +{ + const word sampleType(dict.get("type")); + + if (debug) + { + Info<< "Selecting sampledType " << sampleType << endl; + } + + auto cstrIter = wordConstructorTablePtr_->cfind(sampleType); + + if (!cstrIter.found()) + { + FatalErrorInFunction + << "Unknown sample type " + << sampleType << nl << nl + << "Valid sample types :" << endl + << wordConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr(cstrIter()(name, mesh, dict)); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::sampledSurface::sampledSurface(const word& name, std::nullptr_t) +: + name_(name), + mesh_(NullObjectRef()), + enabled_(true), + interpolate_(false), + area_(-1), + writerType_(), + formatOptions_() +{} + + +Foam::sampledSurface::sampledSurface +( + const word& name, + const polyMesh& mesh, + const bool interpolate +) +: + name_(name), + mesh_(mesh), + enabled_(true), + interpolate_(interpolate), + area_(-1), + writerType_(), + formatOptions_() +{} + + +Foam::sampledSurface::sampledSurface +( + const word& name, + const polyMesh& mesh, + const dictionary& dict +) +: + name_(dict.lookupOrDefault("name", name)), + mesh_(mesh), + enabled_(dict.lookupOrDefault("enabled", true)), + interpolate_(dict.lookupOrDefault("interpolate", false)), + area_(-1), + writerType_(dict.lookupOrDefault("surfaceFormat", "")), + formatOptions_(dict.subOrEmptyDict("formatOptions")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::sampledSurface::~sampledSurface() +{ + clearGeom(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::scalar Foam::sampledSurface::area() const +{ + if (area_ < 0) + { + area_ = gSum(magSf()); + } + + return area_; +} + + +bool Foam::sampledSurface::withSurfaceFields() const +{ + return false; +} + + +Foam::tmp Foam::sampledSurface::sample +( + const surfaceScalarField& sField +) const +{ + NotImplemented; + return nullptr; +} + + +Foam::tmp Foam::sampledSurface::sample +( + const surfaceVectorField& sField +) const +{ + NotImplemented; + return nullptr; +} + + +Foam::tmp Foam::sampledSurface::sample +( + const surfaceSphericalTensorField& sField +) const +{ + NotImplemented; + return nullptr; +} + + +Foam::tmp Foam::sampledSurface::sample +( + const surfaceSymmTensorField& sField +) const +{ + NotImplemented; + return nullptr; +} + + +Foam::tmp Foam::sampledSurface::sample +( + const surfaceTensorField& sField +) const +{ + NotImplemented; + return nullptr; +} + + +void Foam::sampledSurface::print(Ostream& os) const +{ + os << type(); +} + + +Foam::polySurface* Foam::sampledSurface::getRegistrySurface +( + const objectRegistry& obr, + word lookupName +) const +{ + if (lookupName.empty()) + { + lookupName = this->name(); + } + + return obr.getObjectPtr(lookupName); +} + + +Foam::polySurface* Foam::sampledSurface::storeRegistrySurface +( + objectRegistry& obr, + word lookupName +) const +{ + if (lookupName.empty()) + { + lookupName = this->name(); + } + + polySurface* surfptr = getRegistrySurface(obr, lookupName); + + if (!surfptr) + { + surfptr = new polySurface + ( + lookupName, + obr, + true // Add to registry - owned by registry + ); + } + + surfptr->deepCopy(*this); // Copy in geometry (removes old fields) + + return surfptr; +} + + +bool Foam::sampledSurface::removeRegistrySurface +( + objectRegistry& obr, + word lookupName +) const +{ + polySurface* surfptr = getRegistrySurface(obr, lookupName); + + if (surfptr) + { + return obr.checkOut(*surfptr); + } + + return false; +} + + +// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<<(Ostream& os, const sampledSurface& s) +{ + s.print(os); + os.check(FUNCTION_NAME); + return os; +} + + +// ************************************************************************* // diff --git a/src/surfMesh/Make/files b/src/surfMesh/Make/files index d78c9fa946..c2ca286e1f 100644 --- a/src/surfMesh/Make/files +++ b/src/surfMesh/Make/files @@ -1,16 +1,17 @@ -surfZone/surfZone.C -surfZone/surfZoneIOList.C - MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.C - MeshedSurface/MeshedSurfaceCore.C MeshedSurface/MeshedSurfaces.C UnsortedMeshedSurface/UnsortedMeshedSurfaces.C - MeshedSurfaceProxy/MeshedSurfaceProxys.C mergedSurf/mergedSurf.C +polySurface/polySurface.C +polySurface/polySurfaceClear.C +polySurface/polySurfaceIO.C +polySurface/fields/polySurfaceFields.C +polySurface/fields/polySurfacePointFields.C + surfaceRegistry/surfaceRegistry.C surfMesh/surfMesh.C surfMesh/surfMeshClear.C @@ -18,6 +19,9 @@ surfMesh/surfMeshIO.C surfMesh/fields/surfFields.C surfMesh/fields/surfPointFields.C +surfZone/surfZone.C +surfZone/surfZoneIOList.C + surfaceFormats = surfaceFormats $(surfaceFormats)/surfaceFormatsCore.C diff --git a/src/surfMesh/polySurface/fields/polySurfaceFields.C b/src/surfMesh/polySurface/fields/polySurfaceFields.C new file mode 100644 index 0000000000..3904ced6a9 --- /dev/null +++ b/src/surfMesh/polySurface/fields/polySurfaceFields.C @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 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 "polySurfaceFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template<> +const word polySurfaceLabelField::typeName +("polySurfaceLabelField"); + +template<> +const word polySurfaceScalarField::typeName +("polySurfaceScalarField"); + +template<> +const word polySurfaceVectorField::typeName +("polySurfaceVectorField"); + +template<> +const word polySurfaceSphericalTensorField::typeName +("polySurfaceSphericalTensorField"); + +template<> +const word polySurfaceSymmTensorField::typeName +("polySurfaceSymmTensorField"); + +template<> +const word polySurfaceTensorField::typeName +("polySurfaceTensorField"); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/surfMesh/polySurface/fields/polySurfaceFields.H b/src/surfMesh/polySurface/fields/polySurfaceFields.H new file mode 100644 index 0000000000..ce0d3271c4 --- /dev/null +++ b/src/surfMesh/polySurface/fields/polySurfaceFields.H @@ -0,0 +1,46 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 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 . + +InClass + Foam::polySurfaceFields + +Description + Fields for polySurface + +SourceFiles + polySurfaceFields.C + +\*---------------------------------------------------------------------------*/ + +#ifndef polySurfaceFields_H +#define polySurfaceFields_H + +#include "DimensionedField.H" +#include "polySurfaceGeoMesh.H" +#include "polySurfaceFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/surfMesh/polySurface/fields/polySurfaceFieldsFwd.H b/src/surfMesh/polySurface/fields/polySurfaceFieldsFwd.H new file mode 100644 index 0000000000..59e0a01cc6 --- /dev/null +++ b/src/surfMesh/polySurface/fields/polySurfaceFieldsFwd.H @@ -0,0 +1,92 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 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 polySurfacePointFieldsFwd_H +#define polySurfacePointFieldsFwd_H + +#include "fieldTypes.H" +#include "polySurface.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +class DimensionedField; + +class polySurfaceGeoMesh; + +typedef DimensionedField + polySurfaceLabelField; + +typedef Foam::DimensionedField + polySurfaceScalarField; + +typedef Foam::DimensionedField + polySurfaceVectorField; + +typedef Foam::DimensionedField + polySurfaceSphericalTensorField; + +typedef Foam::DimensionedField + polySurfaceSymmTensorField; + +typedef Foam::DimensionedField + polySurfaceTensorField; + + +class polySurfacePointGeoMesh; + +typedef Foam::DimensionedField + polySurfacePointLabelField; + +typedef Foam::DimensionedField + polySurfacePointScalarField; + +typedef Foam::DimensionedField + polySurfacePointVectorField; + +typedef Foam::DimensionedField + polySurfacePointSphericalTensorField; + +typedef Foam::DimensionedField + polySurfacePointSymmTensorField; + +typedef Foam::DimensionedField + polySurfacePointTensorField; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/surfMesh/polySurface/fields/polySurfaceGeoMesh.H b/src/surfMesh/polySurface/fields/polySurfaceGeoMesh.H new file mode 100644 index 0000000000..eec60d45d7 --- /dev/null +++ b/src/surfMesh/polySurface/fields/polySurfaceGeoMesh.H @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 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::polySurfaceGeoMesh + +Description + The polySurface GeoMesh (for holding fields). + +\*---------------------------------------------------------------------------*/ + +#ifndef polySurfaceGeoMesh_H +#define polySurfaceGeoMesh_H + +#include "polySurface.H" +#include "GeoMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class polySurfaceGeoMesh Declaration +\*---------------------------------------------------------------------------*/ + +class polySurfaceGeoMesh +: + public GeoMesh +{ +public: + + // Constructors + + //- Construct from polySurface reference + explicit polySurfaceGeoMesh(const polySurface& mesh) + : + GeoMesh(mesh) + {} + + + // Member Functions + + //- Return size + static label size(const polySurface& mesh) + { + return mesh.faces().size(); + } + + //- Return size + label size() const + { + return size(mesh_); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/surfMesh/polySurface/fields/polySurfacePointFields.C b/src/surfMesh/polySurface/fields/polySurfacePointFields.C new file mode 100644 index 0000000000..c2fcbb3b1d --- /dev/null +++ b/src/surfMesh/polySurface/fields/polySurfacePointFields.C @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 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 "polySurfacePointFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template<> +const word polySurfacePointLabelField::typeName +("polySurfacePointLabelField"); + +template<> +const word polySurfacePointScalarField::typeName +("polySurfacePointScalarField"); + +template<> +const word polySurfacePointVectorField::typeName +("polySurfacePointVectorField"); + +template<> +const word polySurfacePointSphericalTensorField::typeName +("polySurfacePointSphericalTensorField"); + +template<> +const word polySurfacePointSymmTensorField::typeName +("polySurfacePointSymmTensorField"); + +template<> +const word polySurfacePointTensorField::typeName +("polySurfacePointTensorField"); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/surfMesh/polySurface/fields/polySurfacePointFields.H b/src/surfMesh/polySurface/fields/polySurfacePointFields.H new file mode 100644 index 0000000000..118d47222c --- /dev/null +++ b/src/surfMesh/polySurface/fields/polySurfacePointFields.H @@ -0,0 +1,46 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 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 . + +InClass + Foam::polySurfacePointFields + +Description + Point fields for polySurface + +SourceFiles + polySurfacePointFields.C + +\*---------------------------------------------------------------------------*/ + +#ifndef polySurfacePointFields_H +#define polySurfacePointFields_H + +#include "DimensionedField.H" +#include "polySurfacePointGeoMesh.H" +#include "polySurfacePointFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/surfMesh/polySurface/fields/polySurfacePointFieldsFwd.H b/src/surfMesh/polySurface/fields/polySurfacePointFieldsFwd.H new file mode 100644 index 0000000000..32fed3a656 --- /dev/null +++ b/src/surfMesh/polySurface/fields/polySurfacePointFieldsFwd.H @@ -0,0 +1,71 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 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 polySurfacePointFieldsFwd_H +#define polySurfacePointFieldsFwd_H + +#include "fieldTypes.H" +#include "polySurface.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +class DimensionedField; + +class polySurfacePointGeoMesh; + +typedef Foam::DimensionedField + polySurfacePointLabelField; + +typedef Foam::DimensionedField + polySurfacePointScalarField; + +typedef Foam::DimensionedField + polySurfacePointVectorField; + +typedef Foam::DimensionedField + polySurfacePointSphericalTensorField; + +typedef Foam::DimensionedField + polySurfacePointSymmTensorField; + +typedef Foam::DimensionedField + polySurfacePointTensorField; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/surfMesh/polySurface/fields/polySurfacePointGeoMesh.H b/src/surfMesh/polySurface/fields/polySurfacePointGeoMesh.H new file mode 100644 index 0000000000..f347d9b033 --- /dev/null +++ b/src/surfMesh/polySurface/fields/polySurfacePointGeoMesh.H @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 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::polySurfacePointGeoMesh + +Description + The polySurface GeoMesh (for holding point fields). + +\*---------------------------------------------------------------------------*/ + +#ifndef polySurfacePointGeoMesh_H +#define polySurfacePointGeoMesh_H + +#include "polySurface.H" +#include "GeoMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class polySurfacePointGeoMesh Declaration +\*---------------------------------------------------------------------------*/ + +class polySurfacePointGeoMesh +: + public GeoMesh +{ +public: + + // Constructors + + //- Construct from polySurface reference + explicit polySurfacePointGeoMesh(const polySurface& mesh) + : + GeoMesh(mesh) + {} + + + // Member Functions + + //- Return size + static label size(const polySurface& mesh) + { + return mesh.points().size(); + } + + //- Return size + label size() const + { + return size(mesh_); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/surfMesh/polySurface/polySurface.C b/src/surfMesh/polySurface/polySurface.C new file mode 100644 index 0000000000..eaed15e8a7 --- /dev/null +++ b/src/surfMesh/polySurface/polySurface.C @@ -0,0 +1,519 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 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 "polySurface.H" +#include "Time.H" +#include "ModifiableMeshedSurface.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(polySurface, 0); +} + +const Foam::word Foam::polySurface::pointDataName("PointData"); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::polySurface::calculateZoneIds(const UList& zones) +{ + if (returnReduce(zones.empty(), andOp())) + { + zoneIds_.clear(); + return; + } + + // Extra safety, ensure we have at some zones + // and they cover all the faces - fix start silently + + zoneIds_.resize(size(), Zero); + + label off = 0; + for (const surfZone& zn : zones) + { + const label sz = zn.size(); + + SubList