Commit 16bc6386 authored by Mark Olesen's avatar Mark Olesen Committed by Andrew Heather
Browse files

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.
parent 48e3590b
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#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> Foam::sampledSurface::New
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
)
{
const word sampleType(dict.get<word>("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<sampledSurface>(cstrIter()(name, mesh, dict));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledSurface::sampledSurface(const word& name, std::nullptr_t)
:
name_(name),
mesh_(NullObjectRef<polyMesh>()),
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<word>("name", name)),
mesh_(mesh),
enabled_(dict.lookupOrDefault("enabled", true)),
interpolate_(dict.lookupOrDefault("interpolate", false)),
area_(-1),
writerType_(dict.lookupOrDefault<word>("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::scalarField> Foam::sampledSurface::sample
(
const surfaceScalarField& sField
) const
{
NotImplemented;
return nullptr;
}
Foam::tmp<Foam::vectorField> Foam::sampledSurface::sample
(
const surfaceVectorField& sField
) const
{
NotImplemented;
return nullptr;
}
Foam::tmp<Foam::sphericalTensorField> Foam::sampledSurface::sample
(
const surfaceSphericalTensorField& sField
) const
{
NotImplemented;
return nullptr;
}
Foam::tmp<Foam::symmTensorField> Foam::sampledSurface::sample
(
const surfaceSymmTensorField& sField
) const
{
NotImplemented;
return nullptr;
}
Foam::tmp<Foam::tensorField> 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<polySurface>(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;
}
// ************************************************************************* //
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
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#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
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
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
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef polySurfacePointFieldsFwd_H
#define polySurfacePointFieldsFwd_H
#include "fieldTypes.H"
#include "polySurface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type, class GeoMesh>
class DimensionedField;
class polySurfaceGeoMesh;
typedef DimensionedField<label, polySurfaceGeoMesh>
polySurfaceLabelField;
typedef Foam::DimensionedField<scalar, polySurfaceGeoMesh>
polySurfaceScalarField;
typedef Foam::DimensionedField<vector, polySurfaceGeoMesh>
polySurfaceVectorField;
typedef Foam::DimensionedField<sphericalTensor, polySurfaceGeoMesh>
polySurfaceSphericalTensorField;
typedef Foam::DimensionedField<symmTensor, polySurfaceGeoMesh>
polySurfaceSymmTensorField;
typedef Foam::DimensionedField<tensor, polySurfaceGeoMesh>
polySurfaceTensorField;
class polySurfacePointGeoMesh;
typedef Foam::DimensionedField<label, polySurfacePointGeoMesh>
polySurfacePointLabelField;
typedef Foam::DimensionedField<scalar, polySurfacePointGeoMesh>
polySurfacePointScalarField;
typedef Foam::DimensionedField<vector, polySurfacePointGeoMesh>
polySurfacePointVectorField;
typedef Foam::DimensionedField<sphericalTensor, polySurfacePointGeoMesh>
polySurfacePointSphericalTensorField;
typedef Foam::DimensionedField<symmTensor, polySurfacePointGeoMesh>
polySurfacePointSymmTensorField;
typedef Foam::DimensionedField<tensor, polySurfacePointGeoMesh>
polySurfacePointTensorField;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
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<polySurface>
{
public:
// Constructors
//- Construct from polySurface reference
explicit polySurfaceGeoMesh(const polySurface& mesh)
:
GeoMesh<polySurface>(mesh)
{}
// Member Functions
//- Return size
static label size(const polySurface& mesh)
{
return mesh.faces().size();
}
//- Return size
label size() const
{
return size(mesh_);
}
};