GeometricField: Move sub-classes outside of the field

This permits forward declaration of the boundary and internal fields.
References and pointers to boundary fields and sliced internal fields
can now be used in situations where full instantiation of the geometric
field is not possible due to cyclic dependencies.

It has been possible as a result of this change to type the pointer to
the cell volumes field in fvMesh. Previously this was done with a void
pointer and explicit casting.
This commit is contained in:
Will Bainbridge
2022-02-10 09:29:32 +00:00
parent a2bfa0e911
commit a82f5a6fe2
11 changed files with 459 additions and 306 deletions

View File

@ -0,0 +1,60 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ 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 "SlicedDimensionedField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type, class GeoMesh>
Foam::SlicedDimensionedField<Type, GeoMesh>::SlicedDimensionedField
(
const IOobject& io,
const Mesh& mesh,
const dimensionSet& ds,
const Field<Type>& iField
)
:
DimensionedField<Type, GeoMesh>(io, mesh, ds, Field<Type>())
{
// Set the internalField to the slice of the complete field
UList<Type>::shallowCopy
(
typename Field<Type>::subField(iField, GeoMesh::size(mesh))
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type, class GeoMesh>
Foam::SlicedDimensionedField<Type, GeoMesh>::~SlicedDimensionedField()
{
// Set the internalField storage pointer to nullptr before its destruction
// to protect the field it a slice of.
UList<Type>::shallowCopy(UList<Type>(nullptr, 0));
}
// ************************************************************************* //

View File

@ -0,0 +1,97 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ 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::SlicedDimensionedField
Description
Specialisation of DimensionedField which holds a slice of a given complete
field in such a form that it acts as a DimensionedField.
The destructor is wrapped to avoid deallocation of the storage of the
complete fields when this is destroyed.
SourceFiles
SlicedDimensionedField.C
\*---------------------------------------------------------------------------*/
#ifndef SlicedDimensionedField_H
#define SlicedDimensionedField_H
#include "DimensionedField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class SlicedDimensionedField Declaration
\*---------------------------------------------------------------------------*/
template<class Type, class GeoMesh>
class SlicedDimensionedField
:
public DimensionedField<Type, GeoMesh>
{
public:
// Public Typedefs
//- Type of mesh on which this SlicedDimensionedField is instantiated
typedef typename GeoMesh::Mesh Mesh;
// Constructors
//- Construct from components and field to slice
SlicedDimensionedField
(
const IOobject&,
const Mesh&,
const dimensionSet&,
const Field<Type>& iField
);
//- Destructor
~SlicedDimensionedField();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "SlicedDimensionedField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,14 +23,16 @@ License
\*---------------------------------------------------------------------------*/
#include "GeometricBoundaryField.H"
#include "emptyPolyPatch.H"
#include "commSchedule.H"
#include "globalMeshData.H"
#include "cyclicPolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
readField
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
(
const DimensionedField<Type, GeoMesh>& field,
const dictionary& dict
@ -41,7 +43,7 @@ readField
this->setSize(bmesh_.size());
if (debug)
if (GeometricField<Type, PatchField, GeoMesh>::debug)
{
InfoInFunction << endl;
}
@ -195,8 +197,7 @@ readField
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
Boundary
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
const BoundaryMesh& bmesh
)
@ -207,8 +208,7 @@ Boundary
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
Boundary
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field,
@ -218,7 +218,7 @@ Boundary
FieldField<PatchField, Type>(bmesh.size()),
bmesh_(bmesh)
{
if (debug)
if (GeometricField<Type, PatchField, GeoMesh>::debug)
{
InfoInFunction << endl;
}
@ -240,8 +240,7 @@ Boundary
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
Boundary
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field,
@ -252,7 +251,7 @@ Boundary
FieldField<PatchField, Type>(bmesh.size()),
bmesh_(bmesh)
{
if (debug)
if (GeometricField<Type, PatchField, GeoMesh>::debug)
{
InfoInFunction << endl;
}
@ -308,8 +307,7 @@ Boundary
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
Boundary
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field,
@ -319,7 +317,7 @@ Boundary
FieldField<PatchField, Type>(bmesh.size()),
bmesh_(bmesh)
{
if (debug)
if (GeometricField<Type, PatchField, GeoMesh>::debug)
{
InfoInFunction << endl;
}
@ -332,18 +330,16 @@ Boundary
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
Boundary
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
const DimensionedField<Type, GeoMesh>& field,
const typename GeometricField<Type, PatchField, GeoMesh>::
Boundary& btf
const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf
)
:
FieldField<PatchField, Type>(btf.size()),
bmesh_(btf.bmesh_)
{
if (debug)
if (GeometricField<Type, PatchField, GeoMesh>::debug)
{
InfoInFunction << endl;
}
@ -356,8 +352,7 @@ Boundary
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
Boundary
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field,
@ -374,10 +369,9 @@ Boundary
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
updateCoeffs()
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::updateCoeffs()
{
if (debug)
if (GeometricField<Type, PatchField, GeoMesh>::debug)
{
InfoInFunction << endl;
}
@ -390,10 +384,9 @@ updateCoeffs()
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
evaluate()
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluate()
{
if (debug)
if (GeometricField<Type, PatchField, GeoMesh>::debug)
{
InfoInFunction << endl;
}
@ -457,8 +450,7 @@ evaluate()
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::wordList
Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
types() const
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::types() const
{
const FieldField<PatchField, Type>& pff = *this;
@ -474,18 +466,17 @@ types() const
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<typename Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary>
Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
Foam::tmp<Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::
boundaryInternalField() const
{
tmp<typename GeometricField<Type, PatchField, GeoMesh>::Boundary> tresult
tmp<GeometricBoundaryField<Type, PatchField, GeoMesh>> tresult
(
GeometricField<Type, PatchField, GeoMesh>::Internal::null(),
*this
);
typename GeometricField<Type, PatchField, GeoMesh>::Boundary& result =
tresult.ref();
GeometricBoundaryField<Type, PatchField, GeoMesh>& result = tresult.ref();
forAll(*this, patchi)
{
@ -497,21 +488,20 @@ boundaryInternalField() const
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<typename Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary>
Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
Foam::tmp<Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::
boundaryNeighbourField() const
{
tmp<typename GeometricField<Type, PatchField, GeoMesh>::Boundary> tresult
tmp<GeometricBoundaryField<Type, PatchField, GeoMesh>> tresult
(
new typename GeometricField<Type, PatchField, GeoMesh>::Boundary
new GeometricBoundaryField<Type, PatchField, GeoMesh>
(
GeometricField<Type, PatchField, GeoMesh>::Internal::null(),
*this
)
);
typename GeometricField<Type, PatchField, GeoMesh>::Boundary& result =
tresult.ref();
GeometricBoundaryField<Type, PatchField, GeoMesh>& result = tresult.ref();
if
(
@ -587,8 +577,7 @@ boundaryNeighbourField() const
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::LduInterfaceFieldPtrsList<Type>
Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
interfaces() const
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::interfaces() const
{
LduInterfaceFieldPtrsList<Type> interfaces(this->size());
@ -613,7 +602,7 @@ interfaces() const
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::lduInterfaceFieldPtrsList
Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::
scalarInterfaces() const
{
lduInterfaceFieldPtrsList interfaces(this->size());
@ -638,8 +627,11 @@ scalarInterfaces() const
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
writeEntry(const word& keyword, Ostream& os) const
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::writeEntry
(
const word& keyword,
Ostream& os
) const
{
os << keyword << nl << token::BEGIN_BLOCK << incrIndent << nl;
@ -656,7 +648,7 @@ writeEntry(const word& keyword, Ostream& os) const
// Check state of IOstream
os.check
(
"GeometricField<Type, PatchField, GeoMesh>::Boundary::"
"GeometricBoundaryField<Type, PatchField, GeoMesh>::"
"writeEntry(const word& keyword, Ostream& os) const"
);
}
@ -665,11 +657,9 @@ writeEntry(const word& keyword, Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
operator=
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::operator=
(
const typename GeometricField<Type, PatchField, GeoMesh>::
Boundary& bf
const GeometricBoundaryField<Type, PatchField, GeoMesh>& bf
)
{
FieldField<PatchField, Type>::operator=(bf);
@ -677,11 +667,9 @@ operator=
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
operator=
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::operator=
(
typename GeometricField<Type, PatchField, GeoMesh>::
Boundary&& bf
GeometricBoundaryField<Type, PatchField, GeoMesh>&& bf
)
{
FieldField<PatchField, Type>::operator=(move(bf));
@ -689,8 +677,7 @@ operator=
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
operator=
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::operator=
(
const FieldField<PatchField, Type>& ptff
)
@ -700,7 +687,7 @@ operator=
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::
operator=
(
const Type& t
@ -711,11 +698,9 @@ operator=
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
operator==
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::operator==
(
const typename GeometricField<Type, PatchField, GeoMesh>::
Boundary& bf
const GeometricBoundaryField<Type, PatchField, GeoMesh>& bf
)
{
forAll((*this), patchi)
@ -726,7 +711,7 @@ operator==
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::
operator==
(
const FieldField<PatchField, Type>& ptff
@ -740,8 +725,7 @@ operator==
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
operator==
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::operator==
(
const Type& t
)
@ -759,8 +743,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const typename GeometricField<Type, PatchField, GeoMesh>::
Boundary& bf
const GeometricBoundaryField<Type, PatchField, GeoMesh>& bf
)
{
os << static_cast<const FieldField<PatchField, Type>&>(bf);

View File

@ -0,0 +1,223 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ 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::GeometricBoundaryField
Description
Generic GeometricBoundaryField class.
SourceFiles
GeometricBoundaryField.C
\*---------------------------------------------------------------------------*/
#ifndef GeometricBoundaryField_H
#define GeometricBoundaryField_H
#include "dimensionedTypes.H"
#include "DimensionedField.H"
#include "FieldField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class dictionary;
// Forward declaration of friend functions and operators
template<class Type, template<class> class PatchField, class GeoMesh>
class GeometricField;
/*---------------------------------------------------------------------------*\
Class GeometricBoundaryField Declaration
\*---------------------------------------------------------------------------*/
template<class Type, template<class> class PatchField, class GeoMesh>
class GeometricBoundaryField
:
public FieldField<PatchField, Type>
{
public:
// Public Typedefs
//- Type of boundary mesh on which this boundary is instantiated
typedef typename GeoMesh::BoundaryMesh BoundaryMesh;
//- Type of the internal field from which this GeometricField is derived
typedef DimensionedField<Type, GeoMesh> Internal;
private:
// Private Data
//- Reference to BoundaryMesh for which this field is defined
const BoundaryMesh& bmesh_;
public:
// Constructors
//- Construct from a BoundaryMesh
GeometricBoundaryField(const BoundaryMesh&);
//- Construct from a BoundaryMesh,
// reference to the internal field
// and a patch field type
GeometricBoundaryField
(
const BoundaryMesh&,
const Internal&,
const word&
);
//- Construct from a BoundaryMesh,
// reference to the internal field
// and a wordList of patch field types and optionally
// the actual patch types (to override constraint patches)
GeometricBoundaryField
(
const BoundaryMesh&,
const Internal&,
const wordList& wantedPatchTypes,
const wordList& actualPatchTypes = wordList()
);
//- Construct from a BoundaryMesh,
// reference to the internal field
// and a PtrList<PatchField<Type>>
GeometricBoundaryField
(
const BoundaryMesh&,
const Internal&,
const PtrList<PatchField<Type>>&
);
//- Construct as copy setting the reference to the internal field
GeometricBoundaryField(const Internal&, const GeometricBoundaryField&);
//- Copy constructor deleted
// as it would not set the internalField reference correctly
GeometricBoundaryField(const GeometricBoundaryField&) = delete;
//- Move constructor deleted
// as it would not set the internalField reference correctly
GeometricBoundaryField(GeometricBoundaryField&&) = delete;
//- Construct from dictionary
GeometricBoundaryField
(
const BoundaryMesh&,
const Internal&,
const dictionary&
);
// Member Functions
//- Read the boundary field
void readField(const Internal& field, const dictionary& dict);
//- Update the boundary condition coefficients
void updateCoeffs();
//- Evaluate boundary conditions
void evaluate();
//- Return a list of the patch field types
wordList types() const;
//- Return BoundaryField of the cell values neighbouring
// the boundary
tmp<GeometricBoundaryField> boundaryInternalField() const;
//- Return BoundaryField of the values on the other side of couples
tmp<GeometricBoundaryField> boundaryNeighbourField() const;
//- Return a list of pointers for each patch field with only those
// pointing to interfaces being set
LduInterfaceFieldPtrsList<Type> interfaces() const;
//- Return a list of pointers for each patch field with only those
// pointing to interfaces being set
lduInterfaceFieldPtrsList scalarInterfaces() const;
//- Write boundary field as dictionary entry
void writeEntry(const word& keyword, Ostream& os) const;
// Member Operators
//- Assignment operator
void operator=(const GeometricBoundaryField&);
//- Move assignment operator
void operator=(GeometricBoundaryField&&);
//- Assignment to FieldField<PatchField, Type>
void operator=(const FieldField<PatchField, Type>&);
//- Assignment to Type
void operator=(const Type&);
//- Forced assignment to
// BoundaryField<Type, PatchField, BoundaryMesh>
void operator==(const GeometricBoundaryField&);
//- Forced assignment to FieldField<PatchField, Type>
void operator==(const FieldField<PatchField, Type>&);
//- Forced assignment to Type
void operator==(const Type&);
};
template<class Type, template<class> class PatchField, class GeoMesh>
Ostream& operator<<
(
Ostream&,
const GeometricBoundaryField<Type, PatchField, GeoMesh>&
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "GeometricBoundaryField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -1628,7 +1628,6 @@ Foam::Ostream& Foam::operator<<
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "GeometricBoundaryField.C"
#include "GeometricFieldFunctions.C"
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,7 +30,6 @@ Description
SourceFiles
GeometricFieldI.H
GeometricField.C
Boundary.C
GeometricFieldFunctions.H
GeometricFieldFunctions.C
@ -39,12 +38,9 @@ SourceFiles
#ifndef GeometricField_H
#define GeometricField_H
#include "regIOobject.H"
#include "dimensionedTypes.H"
#include "DimensionedField.H"
#include "FieldField.H"
#include "lduInterfaceFieldPtrsList.H"
#include "LduInterfaceFieldPtrsList.H"
#include "GeometricBoundaryField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -98,135 +94,14 @@ public:
//- Type of mesh on which this GeometricField is instantiated
typedef typename GeoMesh::Mesh Mesh;
//- Type of boundary mesh on which this
// GeometricField::Boundary is instantiated
typedef typename GeoMesh::BoundaryMesh BoundaryMesh;
//- Type of the internal field from which this GeometricField is derived
typedef DimensionedField<Type, GeoMesh> Internal;
//- Type of the patch field of which the
// GeometricField::Boundary is composed
//- Type of the patch field of which the Boundary is composed
typedef PatchField<Type> Patch;
class Boundary
:
public FieldField<PatchField, Type>
{
// Private Data
//- Reference to BoundaryMesh for which this field is defined
const BoundaryMesh& bmesh_;
public:
// Constructors
//- Construct from a BoundaryMesh
Boundary(const BoundaryMesh&);
//- Construct from a BoundaryMesh,
// reference to the internal field
// and a patch field type
Boundary(const BoundaryMesh&, const Internal&, const word&);
//- Construct from a BoundaryMesh,
// reference to the internal field
// and a wordList of patch field types and optionally
// the actual patch types (to override constraint patches)
Boundary
(
const BoundaryMesh&,
const Internal&,
const wordList& wantedPatchTypes,
const wordList& actualPatchTypes = wordList()
);
//- Construct from a BoundaryMesh,
// reference to the internal field
// and a PtrList<PatchField<Type>>
Boundary
(
const BoundaryMesh&,
const Internal&,
const PtrList<PatchField<Type>>&
);
//- Construct as copy setting the reference to the internal field
Boundary(const Internal&, const Boundary&);
//- Copy constructor deleted
// as it would not set the internalField reference correctly
Boundary(const Boundary&) = delete;
//- Move constructor deleted
// as it would not set the internalField reference correctly
Boundary(Boundary&&) = delete;
//- Construct from dictionary
Boundary(const BoundaryMesh&, const Internal&, const dictionary&);
// Member Functions
//- Read the boundary field
void readField(const Internal& field, const dictionary& dict);
//- Update the boundary condition coefficients
void updateCoeffs();
//- Evaluate boundary conditions
void evaluate();
//- Return a list of the patch field types
wordList types() const;
//- Return BoundaryField of the cell values neighbouring
// the boundary
tmp<Boundary> boundaryInternalField() const;
//- Return BoundaryField of the values on the other side of couples
tmp<Boundary> boundaryNeighbourField() const;
//- Return a list of pointers for each patch field with only those
// pointing to interfaces being set
LduInterfaceFieldPtrsList<Type> interfaces() const;
//- Return a list of pointers for each patch field with only those
// pointing to interfaces being set
lduInterfaceFieldPtrsList scalarInterfaces() const;
//- Write boundary field as dictionary entry
void writeEntry(const word& keyword, Ostream& os) const;
// Member Operators
//- Assignment operator
void operator=(const Boundary&);
//- Move assignment operator
void operator=(Boundary&&);
//- Assignment to FieldField<PatchField, Type>
void operator=(const FieldField<PatchField, Type>&);
//- Assignment to Type
void operator=(const Type&);
//- Forced assignment to
// BoundaryField<Type, PatchField, BoundaryMesh>
void operator==(const Boundary&);
//- Forced assignment to FieldField<PatchField, Type>
void operator==(const FieldField<PatchField, Type>&);
//- Forced assignment to Type
void operator==(const Type&);
};
//- Type of the boundary field
typedef GeometricBoundaryField<Type, PatchField, GeoMesh> Boundary;
private:
@ -664,8 +539,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
Ostream& operator<<
(
Ostream&,
const typename GeometricField<Type, PatchField, GeoMesh>::
Boundary&
const GeometricBoundaryField<Type, PatchField, GeoMesh>&
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -168,38 +168,6 @@ slicedBoundaryField
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
class Type,
template<class> class PatchField,
template<class> class SlicedPatchField,
class GeoMesh
>
Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
Internal::Internal
(
const IOobject& io,
const Mesh& mesh,
const dimensionSet& ds,
const Field<Type>& iField
)
:
DimensionedField<Type, GeoMesh>
(
io,
mesh,
ds,
Field<Type>()
)
{
// Set the internalField to the slice of the complete field
UList<Type>::shallowCopy
(
typename Field<Type>::subField(iField, GeoMesh::size(mesh))
);
}
template
<
class Type,
@ -383,22 +351,6 @@ Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
}
template
<
class Type,
template<class> class PatchField,
template<class> class SlicedPatchField,
class GeoMesh
>
Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
Internal::~Internal()
{
// Set the internalField storage pointer to nullptr before its destruction
// to protect the field it a slice of.
UList<Type>::shallowCopy(UList<Type>(nullptr, 0));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -44,6 +44,7 @@ SourceFiles
#define SlicedGeometricField_H
#include "GeometricField.H"
#include "SlicedDimensionedField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -67,10 +68,14 @@ class SlicedGeometricField
{
public:
typedef typename GeoMesh::Mesh Mesh;
typedef typename GeoMesh::BoundaryMesh BoundaryMesh;
// Public Typedefs
class Internal;
//- Type of mesh on which this SlicedGeometricField is instantiated
typedef typename GeoMesh::Mesh Mesh;
//- Type of the internal field from which this SlicedGeometricField is
// derived
typedef SlicedDimensionedField<Type, GeoMesh> Internal;
private:
@ -79,7 +84,7 @@ private:
//- Slice the given field and a create a PtrList of SlicedPatchField
// from which the boundary field is built
tmp<FieldField<PatchField, Type>> slicedBoundaryField
tmp<FieldField<PatchField, Type>> slicedBoundaryField
(
const Mesh& mesh,
const Field<Type>& completeField,
@ -89,7 +94,7 @@ private:
//- Slice the given field and a create a PtrList of SlicedPatchField
// from which the boundary field is built
tmp<FieldField<PatchField, Type>> slicedBoundaryField
tmp<FieldField<PatchField, Type>> slicedBoundaryField
(
const Mesh& mesh,
const FieldField<PatchField, Type>& bField,
@ -184,43 +189,6 @@ public:
};
/*---------------------------------------------------------------------------*\
Class SlicedGeometricField::Internal Declaration
\*---------------------------------------------------------------------------*/
//- The internalField of a SlicedGeometricField
template
<
class Type,
template<class> class PatchField,
template<class> class SlicedPatchField,
class GeoMesh
>
class SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
Internal
:
public GeometricField<Type, PatchField, GeoMesh>::Internal
{
public:
// Constructors
//- Construct from components and field to slice
Internal
(
const IOobject&,
const Mesh&,
const dimensionSet&,
const Field<Type>& iField
);
//- Destructor
~Internal();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -73,11 +73,7 @@ void Foam::fvMesh::clearGeomNotOldVol()
MoveableMeshObject
>(*this);
slicedVolScalarField::Internal* VPtr =
static_cast<slicedVolScalarField::Internal*>(VPtr_);
deleteDemandDrivenData(VPtr);
VPtr_ = nullptr;
deleteDemandDrivenData(VPtr_);
deleteDemandDrivenData(SfPtr_);
deleteDemandDrivenData(magSfPtr_);
deleteDemandDrivenData(CPtr_);
@ -887,7 +883,7 @@ void Foam::fvMesh::updateMesh(const mapPolyMesh& map)
}
// Few checks
if (VPtr_ && (V().size() != map.nOldCells()))
if (VPtr_ && (VPtr_->size() != map.nOldCells()))
{
FatalErrorInFunction
<< "V:" << V().size()
@ -960,7 +956,7 @@ void Foam::fvMesh::distribute(const mapDistributePolyMesh& map)
// }
//
// // Few checks
// if (VPtr_ && (V().size() != map.nOldCells()))
// if (VPtr_ && (VPtr_->size() != map.nOldCells()))
// {
// FatalErrorInFunction
// << "V:" << V().size()

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -56,6 +56,7 @@ SourceFiles
#include "fvSolution.H"
#include "data.H"
#include "DimensionedField.H"
#include "SlicedDimensionedField.H"
#include "volFieldsFwd.H"
#include "surfaceFieldsFwd.H"
#include "pointFieldsFwd.H"
@ -114,7 +115,7 @@ class fvMesh
mutable label curTimeIndex_;
//- Cell volumes old time level
mutable void* VPtr_;
mutable SlicedDimensionedField<scalar, volMesh>* VPtr_;
//- Cell volumes old time level
mutable DimensionedField<scalar, volMesh>* V0Ptr_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -192,7 +192,7 @@ const Foam::volScalarField::Internal& Foam::fvMesh::V() const
<< "Constructing from primitiveMesh::cellVolumes()" << endl;
}
VPtr_ = new slicedVolScalarField::Internal
VPtr_ = new SlicedDimensionedField<scalar, volMesh>
(
IOobject
(
@ -209,7 +209,7 @@ const Foam::volScalarField::Internal& Foam::fvMesh::V() const
);
}
return *static_cast<slicedVolScalarField::Internal*>(VPtr_);
return *VPtr_;
}