Files
openfoam/src/dynamicMesh/fvMeshSubsetProxy/fvMeshSubsetProxyTemplates.C
Mark Olesen 2fb382bf8a ENH: multiple zone selection for fvMeshSubsetProxy (#973)
- handle tmp fields in interpolate methods

- special method interpolateInternal() for creating a volume field
  with zero-gradient treatment for patches from an internal field.

  This method was previously also called interpolate(), but that
  masked the ability to subset the internal field only.

  Ensight output needs the volume field:
      uses interpolateInternal().

  VTK output has separate handling of internal and patch fields:
      uses interpolate().

ENH: added fvMeshSubset mesh() method for baseMesh or subMesh.

- simplies coding when the fvMeshSubset may or may not be in active use.

ENH: update foamToEnsight to use newer methods in wrapped form

- static interpolate functions with renaming for manual use with
  fvMeshSubset (when fvMeshSubsetProxy may be too limiting in
  functionality)
2018-10-02 17:06:44 +02:00

198 lines
4.8 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "fvMeshSubsetProxy.H"
#include "volFields.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Type>
Foam::tmp
<
Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>
>
Foam::fvMeshSubsetProxy::zeroGradientField
(
const DimensionedField<Type, volMesh>& df
)
{
IOobject io(df);
io.readOpt() = IOobject::NO_READ;
io.writeOpt() = IOobject::NO_WRITE;
io.registerObject() = false;
auto tfield = tmp<GeometricField<Type, fvPatchField, volMesh>>::New
(
io,
df.mesh(),
dimensioned<Type>(df.dimensions(), Zero),
zeroGradientFvPatchField<Type>::typeName
);
tfield.ref().primitiveFieldRef() = df;
tfield.ref().oriented() = df.oriented();
tfield.ref().correctBoundaryConditions();
return tfield;
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::fvMeshSubsetProxy::interpolateInternal
(
const fvMeshSubset& subsetter,
const DimensionedField<Type, volMesh>& df
)
{
auto tfield = zeroGradientField<Type>(df);
if (subsetter.hasSubMesh())
{
return interpolate(subsetter, tfield());
}
return tfield;
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::fvMeshSubsetProxy::interpolateInternal
(
const fvMeshSubset& subsetter,
const tmp<DimensionedField<Type, volMesh>>& tdf
)
{
// TODO - move dimensioned mesh into internal,
// but needs different GeometricField constructors
if (tdf.valid())
{
if (subsetter.hasSubMesh())
{
auto tproxied = interpolate(subsetter, tdf);
auto tfield = zeroGradientField<Type>(tproxied());
tdf.clear();
tproxied.clear();
return tfield;
}
else
{
auto tfield = zeroGradientField<Type>(tdf());
tdf.clear();
return tfield;
}
}
return nullptr;
}
template<class GeoField>
Foam::tmp<GeoField>
Foam::fvMeshSubsetProxy::interpolate
(
const fvMeshSubset& subsetter,
const GeoField& fld
)
{
if (subsetter.hasSubMesh())
{
auto tfield = subsetter.interpolate(fld);
tfield.ref().checkOut();
tfield.ref().rename(fld.name());
return tfield;
}
return fld;
}
template<class GeoField>
Foam::tmp<GeoField>
Foam::fvMeshSubsetProxy::interpolate
(
const fvMeshSubset& subsetter,
const tmp<GeoField>& tfield
)
{
if (tfield.valid() && subsetter.hasSubMesh())
{
auto tproxied = interpolate(subsetter, tfield());
tfield.clear();
return tproxied;
}
// Nothing to be done
return tfield;
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::fvMeshSubsetProxy::interpolateInternal
(
const DimensionedField<Type, volMesh>& df
) const
{
return interpolateInternal(subsetter_, df);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::fvMeshSubsetProxy::interpolateInternal
(
const tmp<DimensionedField<Type, volMesh>>& tdf
) const
{
return interpolateInternal(subsetter_, tdf);
}
template<class GeoField>
Foam::tmp<GeoField>
Foam::fvMeshSubsetProxy::interpolate(const GeoField& fld) const
{
return interpolate(subsetter_, fld);
}
template<class GeoField>
Foam::tmp<GeoField>
Foam::fvMeshSubsetProxy::interpolate(const tmp<GeoField>& tfield) const
{
return interpolate(subsetter_, tfield);
}
// ************************************************************************* //