ENH: template invariant base classes for {fa,fae,fv,fvs,point}PatchField
- simplifies construction/inheritance ENH: add {fa,fv}PatchField::zeroGradientType() static - can be used to avoid literal "zeroGradient" in places STYLE: adjust naming of pointPatch runtime selection table - simply use 'patch' as per fa/fv fields STYLE: add zero-size guard to patch constraintType(const word&)
This commit is contained in:
parent
88f5be479e
commit
4393ffa8dc
@ -776,6 +776,7 @@ $(Fields)/fieldTypes.C
|
||||
|
||||
|
||||
pointPatchFields = fields/pointPatchFields
|
||||
$(pointPatchFields)/pointPatchField/pointPatchFieldBase.C
|
||||
$(pointPatchFields)/pointPatchField/pointPatchFields.C
|
||||
|
||||
basicPointPatchFields = $(pointPatchFields)/basic
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -33,7 +33,7 @@ License
|
||||
template<class Type>
|
||||
const Foam::word& Foam::pointPatchField<Type>::calculatedType()
|
||||
{
|
||||
return calculatedPointPatchField<Type>::typeName;
|
||||
return Foam::calculatedPointPatchField<Type>::typeName;
|
||||
}
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ Foam::pointPatchField<Type>::NewCalculatedType
|
||||
const pointPatchField<Type2>& pf
|
||||
)
|
||||
{
|
||||
auto* patchTypeCtor = pointPatchConstructorTable(pf.patch().type());
|
||||
auto* patchTypeCtor = patchConstructorTable(pf.patch().type());
|
||||
|
||||
if (patchTypeCtor)
|
||||
{
|
||||
|
@ -27,6 +27,15 @@ License
|
||||
|
||||
#include "zeroGradientPointPatchField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::word& Foam::pointPatchField<Type>::zeroGradientType()
|
||||
{
|
||||
return Foam::zeroGradientPointPatchField<Type>::typeName;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
|
@ -34,8 +34,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef zeroGradientPointPatchField_H
|
||||
#define zeroGradientPointPatchField_H
|
||||
#ifndef Foam_zeroGradientPointPatchField_H
|
||||
#define Foam_zeroGradientPointPatchField_H
|
||||
|
||||
#include "pointPatchField.H"
|
||||
|
||||
@ -53,7 +53,6 @@ class zeroGradientPointPatchField
|
||||
:
|
||||
public pointPatchField<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -39,10 +39,8 @@ Foam::pointPatchField<Type>::pointPatchField
|
||||
const DimensionedField<Type, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
patchType_()
|
||||
pointPatchFieldBase(p),
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
@ -54,13 +52,9 @@ Foam::pointPatchField<Type>::pointPatchField
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
patchType_()
|
||||
{
|
||||
dict.readIfPresent("patchType", patchType_, keyType::LITERAL);
|
||||
}
|
||||
pointPatchFieldBase(p, dict),
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
@ -72,10 +66,8 @@ Foam::pointPatchField<Type>::pointPatchField
|
||||
const pointPatchFieldMapper&
|
||||
)
|
||||
:
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
patchType_(ptf.patchType_)
|
||||
pointPatchFieldBase(ptf, p),
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
@ -85,10 +77,8 @@ Foam::pointPatchField<Type>::pointPatchField
|
||||
const pointPatchField<Type>& ptf
|
||||
)
|
||||
:
|
||||
patch_(ptf.patch_),
|
||||
internalField_(ptf.internalField_),
|
||||
updated_(false),
|
||||
patchType_(ptf.patchType_)
|
||||
pointPatchFieldBase(ptf),
|
||||
internalField_(ptf.internalField_)
|
||||
{}
|
||||
|
||||
|
||||
@ -99,30 +89,21 @@ Foam::pointPatchField<Type>::pointPatchField
|
||||
const DimensionedField<Type, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
patch_(ptf.patch_),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
patchType_(ptf.patchType_)
|
||||
pointPatchFieldBase(ptf),
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::objectRegistry& Foam::pointPatchField<Type>::db() const
|
||||
{
|
||||
return patch_.boundaryMesh().mesh()();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::pointPatchField<Type>::write(Ostream& os) const
|
||||
{
|
||||
os.writeEntry("type", type());
|
||||
|
||||
if (!patchType_.empty())
|
||||
if (!patchType().empty())
|
||||
{
|
||||
os.writeEntry("patchType", patchType_);
|
||||
os.writeEntry("patchType", patchType());
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,15 +274,22 @@ void Foam::pointPatchField<Type>::setInInternalField
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::pointPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
pointPatchFieldBase::setUpdated(true);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::pointPatchField<Type>::evaluate(const Pstream::commsTypes)
|
||||
{
|
||||
if (!updated_)
|
||||
if (!updated())
|
||||
{
|
||||
updateCoeffs();
|
||||
}
|
||||
|
||||
updated_ = false;
|
||||
pointPatchFieldBase::setUpdated(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,7 +55,6 @@ namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class pointPatchFieldMapper;
|
||||
@ -67,6 +66,116 @@ template<class Type> class calculatedPointPatchField;
|
||||
template<class Type>
|
||||
Ostream& operator<<(Ostream&, const pointPatchField<Type>&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pointPatchFieldBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Template invariant parts for pointPatchField
|
||||
class pointPatchFieldBase
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to patch
|
||||
const pointPatch& patch_;
|
||||
|
||||
//- Update index used so that updateCoeffs is called only once during
|
||||
//- the construction of the matrix
|
||||
bool updated_;
|
||||
|
||||
//- Optional patch type
|
||||
// Used to allow specified boundary conditions to be applied
|
||||
// to constraint patches by providing the constraint
|
||||
// patch type as 'patchType'
|
||||
word patchType_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Read dictionary entries.
|
||||
// Useful when initially constructed without a dictionary
|
||||
virtual void readDict(const dictionary& dict);
|
||||
|
||||
//- Set updated state
|
||||
void setUpdated(bool state) noexcept
|
||||
{
|
||||
updated_ = state;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Debug switch to disallow the use of generic pointPatchField
|
||||
static int disallowGenericPatchField;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("pointPatchField");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch
|
||||
explicit pointPatchFieldBase(const pointPatch& p);
|
||||
|
||||
//- Construct from patch and patch type
|
||||
pointPatchFieldBase(const pointPatch& p, const word& patchType);
|
||||
|
||||
//- Construct from patch and dictionary
|
||||
pointPatchFieldBase(const pointPatch& p, const dictionary& dict);
|
||||
|
||||
//- Copy construct with new patch
|
||||
pointPatchFieldBase(const pointPatchFieldBase&, const pointPatch& p);
|
||||
|
||||
//- Copy construct
|
||||
pointPatchFieldBase(const pointPatchFieldBase&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~pointPatchFieldBase() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- The associated objectRegistry
|
||||
const objectRegistry& db() const;
|
||||
|
||||
//- Return the patch
|
||||
const pointPatch& patch() const noexcept
|
||||
{
|
||||
return patch_;
|
||||
}
|
||||
|
||||
//- The optional patch type
|
||||
const word& patchType() const noexcept
|
||||
{
|
||||
return patchType_;
|
||||
}
|
||||
|
||||
//- The optional patch type
|
||||
word& patchType() noexcept
|
||||
{
|
||||
return patchType_;
|
||||
}
|
||||
|
||||
|
||||
// Solution
|
||||
|
||||
//- True if the boundary condition has already been updated
|
||||
bool updated() const noexcept
|
||||
{
|
||||
return updated_;
|
||||
}
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Check that patches are identical
|
||||
void checkPatch(const pointPatchFieldBase& rhs) const;
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pointPatchField Declaration
|
||||
@ -74,24 +183,14 @@ Ostream& operator<<(Ostream&, const pointPatchField<Type>&);
|
||||
|
||||
template<class Type>
|
||||
class pointPatchField
|
||||
:
|
||||
public pointPatchFieldBase
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to patch
|
||||
const pointPatch& patch_;
|
||||
|
||||
//- Reference to internal field
|
||||
const DimensionedField<Type, pointMesh>& internalField_;
|
||||
|
||||
//- Update index used so that updateCoeffs is called only once during
|
||||
// the construction of the matrix
|
||||
bool updated_;
|
||||
|
||||
//- Optional patch type, used to allow specified boundary conditions
|
||||
// to be applied to constraint patches by providing the constraint
|
||||
// patch type as 'patchType'
|
||||
word patchType_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -108,20 +207,13 @@ public:
|
||||
typedef calculatedPointPatchField<Type> Calculated;
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("pointPatchField");
|
||||
|
||||
//- Debug switch to disallow the use of genericPointPatchField
|
||||
static int disallowGenericPointPatchField;
|
||||
|
||||
|
||||
// Declare run-time constructor selection tables
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
pointPatchField,
|
||||
pointPatch,
|
||||
patch,
|
||||
(
|
||||
const pointPatch& p,
|
||||
const DimensionedField<Type, pointMesh>& iF
|
||||
@ -186,9 +278,6 @@ public:
|
||||
//- Construct as copy
|
||||
pointPatchField(const pointPatchField<Type>&);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<pointPatchField<Type>> clone() const = 0;
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
pointPatchField
|
||||
(
|
||||
@ -196,6 +285,9 @@ public:
|
||||
const DimensionedField<Type, pointMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<pointPatchField<Type>> clone() const = 0;
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual autoPtr<pointPatchField<Type>> clone
|
||||
(
|
||||
@ -257,69 +349,58 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~pointPatchField<Type>() = default;
|
||||
virtual ~pointPatchField() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
//- The type name for calculated patch fields
|
||||
static const word& calculatedType();
|
||||
|
||||
//- Return local objectRegistry
|
||||
const objectRegistry& db() const;
|
||||
//- The type name for zeroGradient patch fields
|
||||
static const word& zeroGradientType();
|
||||
|
||||
//- Return size
|
||||
label size() const
|
||||
{
|
||||
return patch().size();
|
||||
}
|
||||
|
||||
//- Return patch
|
||||
const pointPatch& patch() const
|
||||
{
|
||||
return patch_;
|
||||
}
|
||||
// Attributes
|
||||
|
||||
//- Return dimensioned internal field reference
|
||||
const DimensionedField<Type, pointMesh>&
|
||||
internalField() const
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Return internal field reference
|
||||
const Field<Type>& primitiveField() const
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Optional patch type
|
||||
const word& patchType() const
|
||||
{
|
||||
return patchType_;
|
||||
}
|
||||
|
||||
//- Optional patch type
|
||||
word& patchType()
|
||||
{
|
||||
return patchType_;
|
||||
}
|
||||
|
||||
//- Return true if this patch field fixes a value
|
||||
//- True if this patch field fixes a value
|
||||
virtual bool fixesValue() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return true if this patch field is coupled
|
||||
//- True if this patch field is coupled
|
||||
virtual bool coupled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return true if the boundary condition has already been updated
|
||||
bool updated() const
|
||||
//- The constraint type this pointPatchField implements.
|
||||
virtual const word& constraintType() const
|
||||
{
|
||||
return updated_;
|
||||
return word::null;
|
||||
}
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the patch size
|
||||
label size() const
|
||||
{
|
||||
return patch().size();
|
||||
}
|
||||
|
||||
//- Return dimensioned internal field reference
|
||||
const DimensionedField<Type, pointMesh>& internalField()
|
||||
const noexcept
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Return internal field reference
|
||||
const Field<Type>& primitiveField() const noexcept
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Return field created from appropriate internal field values
|
||||
@ -380,17 +461,8 @@ public:
|
||||
const Field<Type1>& pF
|
||||
) const;
|
||||
|
||||
//- Return the type of the calculated form of pointPatchField
|
||||
static const word& calculatedType();
|
||||
|
||||
//- Return the constraint type this pointPatchField implements.
|
||||
virtual const word& constraintType() const
|
||||
{
|
||||
return word::null;
|
||||
}
|
||||
|
||||
|
||||
// Mapping functions
|
||||
// Mapping Functions
|
||||
|
||||
//- Map (and resize as needed) from self given a mapping object
|
||||
virtual void autoMap
|
||||
@ -408,14 +480,11 @@ public:
|
||||
{}
|
||||
|
||||
|
||||
// Evaluation functions
|
||||
// Evaluation Functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
// Sets Updated to true
|
||||
virtual void updateCoeffs()
|
||||
{
|
||||
updated_ = true;
|
||||
}
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Initialise evaluation of the patch field (do nothing)
|
||||
virtual void initEvaluate
|
||||
@ -470,7 +539,7 @@ public:
|
||||
virtual void operator==(const Type&){}
|
||||
|
||||
|
||||
// Ostream operator
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<< <Type>
|
||||
(
|
||||
@ -513,15 +582,19 @@ const pointPatchField<Type>& operator+
|
||||
#ifdef NoRepository
|
||||
#include "pointPatchField.C"
|
||||
#include "calculatedPointPatchField.H"
|
||||
#include "zeroGradientPointPatchField.H"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Runtime selection macros
|
||||
|
||||
#define addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
|
||||
addToRunTimeSelectionTable \
|
||||
( \
|
||||
PatchTypeField, \
|
||||
typePatchTypeField, \
|
||||
pointPatch \
|
||||
patch \
|
||||
); \
|
||||
addToRunTimeSelectionTable \
|
||||
( \
|
||||
@ -574,7 +647,7 @@ const pointPatchField<Type>& operator+
|
||||
( \
|
||||
pointPatchTensorField, \
|
||||
type##PointPatchTensorField \
|
||||
);
|
||||
);
|
||||
|
||||
|
||||
#define makePointPatchFieldsTypeName(type) \
|
||||
|
@ -0,0 +1,123 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 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 "pointPatchField.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(pointPatchFieldBase, 0);
|
||||
}
|
||||
|
||||
int Foam::pointPatchFieldBase::disallowGenericPatchField
|
||||
(
|
||||
Foam::debug::debugSwitch("disallowGenericPointPatchField", 0)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointPatchFieldBase::pointPatchFieldBase(const pointPatch& p)
|
||||
:
|
||||
patch_(p),
|
||||
updated_(false),
|
||||
patchType_()
|
||||
{}
|
||||
|
||||
|
||||
Foam::pointPatchFieldBase::pointPatchFieldBase
|
||||
(
|
||||
const pointPatch& p,
|
||||
const word& patchType
|
||||
)
|
||||
:
|
||||
pointPatchFieldBase(p)
|
||||
{
|
||||
patchType_ = patchType;
|
||||
}
|
||||
|
||||
|
||||
Foam::pointPatchFieldBase::pointPatchFieldBase
|
||||
(
|
||||
const pointPatch& p,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
pointPatchFieldBase(p)
|
||||
{
|
||||
pointPatchFieldBase::readDict(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::pointPatchFieldBase::pointPatchFieldBase
|
||||
(
|
||||
const pointPatchFieldBase& rhs,
|
||||
const pointPatch& p
|
||||
)
|
||||
:
|
||||
patch_(p),
|
||||
updated_(false),
|
||||
patchType_(rhs.patchType_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::pointPatchFieldBase::pointPatchFieldBase(const pointPatchFieldBase& rhs)
|
||||
:
|
||||
patch_(rhs.patch_),
|
||||
updated_(false),
|
||||
patchType_(rhs.patchType_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::pointPatchFieldBase::readDict(const dictionary& dict)
|
||||
{
|
||||
dict.readIfPresent("patchType", patchType_, keyType::LITERAL);
|
||||
}
|
||||
|
||||
|
||||
const Foam::objectRegistry& Foam::pointPatchFieldBase::db() const
|
||||
{
|
||||
return patch_.boundaryMesh().mesh()();
|
||||
}
|
||||
|
||||
|
||||
void Foam::pointPatchFieldBase::checkPatch(const pointPatchFieldBase& rhs) const
|
||||
{
|
||||
if (&patch_ != &(rhs.patch_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Different patches for pointPatchField"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -42,28 +42,28 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
|
||||
<< " [" << actualPatchType
|
||||
<< "] : " << p.type() << " name = " << p.name() << endl;
|
||||
|
||||
auto* ctorPtr = pointPatchConstructorTable(patchFieldType);
|
||||
auto* ctorPtr = patchConstructorTable(patchFieldType);
|
||||
|
||||
if (!ctorPtr)
|
||||
{
|
||||
FatalErrorInLookup
|
||||
(
|
||||
"patchFieldType",
|
||||
"patchField",
|
||||
patchFieldType,
|
||||
*pointPatchConstructorTablePtr_
|
||||
*patchConstructorTablePtr_
|
||||
) << exit(FatalError);
|
||||
}
|
||||
|
||||
autoPtr<pointPatchField<Type>> pfPtr(ctorPtr(p, iF));
|
||||
autoPtr<pointPatchField<Type>> tpfld(ctorPtr(p, iF));
|
||||
|
||||
if (actualPatchType.empty() || actualPatchType != p.type())
|
||||
{
|
||||
if (pfPtr().constraintType() != p.constraintType())
|
||||
if (tpfld().constraintType() != p.constraintType())
|
||||
{
|
||||
// Incompatible (constraint-wise) with the patch type
|
||||
// - use default constraint type
|
||||
|
||||
auto* patchTypeCtor = pointPatchConstructorTable(p.type());
|
||||
auto* patchTypeCtor = patchConstructorTable(p.type());
|
||||
|
||||
if (!patchTypeCtor)
|
||||
{
|
||||
@ -79,13 +79,13 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pointPatchConstructorTablePtr_->found(p.type()))
|
||||
if (patchConstructorTablePtr_->found(p.type()))
|
||||
{
|
||||
pfPtr().patchType() = actualPatchType;
|
||||
tpfld.ref().patchType() = actualPatchType;
|
||||
}
|
||||
}
|
||||
|
||||
return pfPtr;
|
||||
return tpfld;
|
||||
}
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
|
||||
|
||||
if (!ctorPtr)
|
||||
{
|
||||
if (!disallowGenericPointPatchField)
|
||||
if (!pointPatchFieldBase::disallowGenericPatchField)
|
||||
{
|
||||
ctorPtr = dictionaryConstructorTable("generic");
|
||||
}
|
||||
@ -140,11 +140,11 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
|
||||
}
|
||||
|
||||
// Construct (but not necessarily returned)
|
||||
autoPtr<pointPatchField<Type>> pfPtr(ctorPtr(p, iF, dict));
|
||||
autoPtr<pointPatchField<Type>> tpfld(ctorPtr(p, iF, dict));
|
||||
|
||||
if (actualPatchType.empty() || actualPatchType != p.type())
|
||||
{
|
||||
if (pfPtr().constraintType() != p.constraintType())
|
||||
if (tpfld().constraintType() != p.constraintType())
|
||||
{
|
||||
// Incompatible (constraint-wise) with the patch type
|
||||
// - use default constraint type
|
||||
@ -164,7 +164,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
|
||||
}
|
||||
}
|
||||
|
||||
return pfPtr;
|
||||
return tpfld;
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,13 +36,7 @@ namespace Foam
|
||||
|
||||
#define makePointPatchField(pointPatchTypeField) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(pointPatchTypeField, 0); \
|
||||
template<> \
|
||||
int pointPatchTypeField::disallowGenericPointPatchField \
|
||||
( \
|
||||
debug::debugSwitch("disallowGenericPointPatchField", 0) \
|
||||
); \
|
||||
defineTemplateRunTimeSelectionTable(pointPatchTypeField, pointPatch); \
|
||||
defineTemplateRunTimeSelectionTable(pointPatchTypeField, patch); \
|
||||
defineTemplateRunTimeSelectionTable(pointPatchTypeField, patchMapper); \
|
||||
defineTemplateRunTimeSelectionTable(pointPatchTypeField, dictionary);
|
||||
|
||||
|
@ -25,8 +25,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef pointPatchFields_H
|
||||
#define pointPatchFields_H
|
||||
#ifndef Foam_pointPatchFields_H
|
||||
#define Foam_pointPatchFields_H
|
||||
|
||||
#include "pointPatchField.H"
|
||||
#include "pointPatchFieldsFwd.H"
|
||||
|
@ -25,8 +25,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef pointPatchFieldsFwd_H
|
||||
#define pointPatchFieldsFwd_H
|
||||
#ifndef Foam_pointPatchFieldsFwd_H
|
||||
#define Foam_pointPatchFieldsFwd_H
|
||||
|
||||
#include "fieldTypes.H"
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -100,7 +100,7 @@ Foam::polyPatch::polyPatch
|
||||
faceCellsPtr_(nullptr),
|
||||
mePtr_(nullptr)
|
||||
{
|
||||
if (!patchType.empty() && constraintType(patchType))
|
||||
if (constraintType(patchType))
|
||||
{
|
||||
inGroups().appendUniq(patchType);
|
||||
}
|
||||
@ -156,7 +156,7 @@ Foam::polyPatch::polyPatch
|
||||
faceCellsPtr_(nullptr),
|
||||
mePtr_(nullptr)
|
||||
{
|
||||
if (!patchType.empty() && constraintType(patchType))
|
||||
if (constraintType(patchType))
|
||||
{
|
||||
inGroups().appendUniq(patchType);
|
||||
}
|
||||
@ -274,12 +274,13 @@ Foam::polyPatch::~polyPatch()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::polyPatch::constraintType(const word& pt)
|
||||
bool Foam::polyPatch::constraintType(const word& patchType)
|
||||
{
|
||||
return
|
||||
(
|
||||
pointPatchField<scalar>::pointPatchConstructorTablePtr_
|
||||
&& pointPatchField<scalar>::pointPatchConstructorTablePtr_->found(pt)
|
||||
!patchType.empty()
|
||||
&& pointPatchField<scalar>::patchConstructorTablePtr_
|
||||
&& pointPatchField<scalar>::patchConstructorTablePtr_->found(patchType)
|
||||
);
|
||||
}
|
||||
|
||||
@ -300,7 +301,7 @@ Foam::wordList Foam::polyPatch::constraintTypes()
|
||||
}
|
||||
}
|
||||
|
||||
cTypes.setSize(i);
|
||||
cTypes.resize(i);
|
||||
|
||||
return cTypes;
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ public:
|
||||
}
|
||||
|
||||
//- Return true if the given type is a constraint type
|
||||
static bool constraintType(const word& pt);
|
||||
static bool constraintType(const word& patchType);
|
||||
|
||||
//- Return a list of all the constraint patch types
|
||||
static wordList constraintTypes();
|
||||
|
@ -37,6 +37,7 @@ $(faMeshMapper)/faEdgeMapper.C
|
||||
$(faMeshMapper)/faPatchMapper.C
|
||||
|
||||
faPatchFields = fields/faPatchFields
|
||||
$(faPatchFields)/faPatchField/faPatchFieldBase.C
|
||||
$(faPatchFields)/faPatchField/faPatchFields.C
|
||||
|
||||
basicFaPatchFields = $(faPatchFields)/basic
|
||||
@ -68,6 +69,7 @@ $(derivedFaPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValu
|
||||
$(derivedFaPatchFields)/clampedPlate/clampedPlateFaPatchFields.C
|
||||
|
||||
faePatchFields = fields/faePatchFields
|
||||
$(faePatchFields)/faePatchField/faePatchFieldBase.C
|
||||
$(faePatchFields)/faePatchField/faePatchFields.C
|
||||
|
||||
basicFaePatchFields = $(faePatchFields)/basic
|
||||
|
@ -111,7 +111,7 @@ Foam::faPatch::faPatch
|
||||
pointLabelsPtr_(nullptr),
|
||||
pointEdgesPtr_(nullptr)
|
||||
{
|
||||
if (!patchType.empty() && constraintType(patchType))
|
||||
if (constraintType(patchType))
|
||||
{
|
||||
inGroups().appendUniq(patchType);
|
||||
}
|
||||
@ -135,7 +135,7 @@ Foam::faPatch::faPatch
|
||||
pointLabelsPtr_(nullptr),
|
||||
pointEdgesPtr_(nullptr)
|
||||
{
|
||||
if (!patchType.empty() && constraintType(patchType))
|
||||
if (constraintType(patchType))
|
||||
{
|
||||
inGroups().appendUniq(patchType);
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ public:
|
||||
// Static Member Functions
|
||||
|
||||
//- Return true if the given type is a constraint type
|
||||
static bool constraintType(const word& pt);
|
||||
static bool constraintType(const word& patchType);
|
||||
|
||||
//- Return a list of all the constraint patch types
|
||||
static wordList constraintTypes();
|
||||
|
@ -34,7 +34,7 @@ License
|
||||
template<class Type>
|
||||
const Foam::word& Foam::faPatchField<Type>::calculatedType()
|
||||
{
|
||||
return calculatedFaPatchField<Type>::typeName;
|
||||
return Foam::calculatedFaPatchField<Type>::typeName;
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,6 +28,15 @@ License
|
||||
#include "zeroGradientFaPatchField.H"
|
||||
#include "faPatchFieldMapper.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::word& Foam::faPatchField<Type>::zeroGradientType()
|
||||
{
|
||||
return Foam::zeroGradientFaPatchField<Type>::typeName;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
|
@ -57,7 +57,6 @@ class zeroGradientFaPatchField
|
||||
:
|
||||
public faPatchField<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -126,10 +125,6 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~zeroGradientFaPatchField<Type>() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Evaluation functions
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 Wikki Ltd
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -38,11 +38,9 @@ Foam::faPatchField<Type>::faPatchField
|
||||
const DimensionedField<Type, areaMesh>& iF
|
||||
)
|
||||
:
|
||||
faPatchFieldBase(p),
|
||||
Field<Type>(p.size()),
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
patchType_()
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
@ -54,11 +52,9 @@ Foam::faPatchField<Type>::faPatchField
|
||||
const Field<Type>& f
|
||||
)
|
||||
:
|
||||
faPatchFieldBase(p),
|
||||
Field<Type>(f),
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
patchType_()
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
@ -71,11 +67,9 @@ Foam::faPatchField<Type>::faPatchField
|
||||
const faPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
faPatchFieldBase(ptf, p),
|
||||
Field<Type>(ptf, mapper),
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
patchType_()
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
@ -88,14 +82,10 @@ Foam::faPatchField<Type>::faPatchField
|
||||
const bool valueRequired
|
||||
)
|
||||
:
|
||||
faPatchFieldBase(p, dict),
|
||||
Field<Type>(p.size()),
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
patchType_()
|
||||
internalField_(iF)
|
||||
{
|
||||
dict.readIfPresent("patchType", patchType_, keyType::LITERAL);
|
||||
|
||||
/// if (valueRequired) - not yet needed. Already a lazy evaluation
|
||||
|
||||
const auto* eptr = dict.findEntry("value", keyType::LITERAL);
|
||||
@ -117,11 +107,9 @@ Foam::faPatchField<Type>::faPatchField
|
||||
const faPatchField<Type>& ptf
|
||||
)
|
||||
:
|
||||
faPatchFieldBase(ptf),
|
||||
Field<Type>(ptf),
|
||||
patch_(ptf.patch_),
|
||||
internalField_(ptf.internalField_),
|
||||
updated_(false),
|
||||
patchType_(ptf.patchType_)
|
||||
internalField_(ptf.internalField_)
|
||||
{}
|
||||
|
||||
|
||||
@ -132,11 +120,9 @@ Foam::faPatchField<Type>::faPatchField
|
||||
const DimensionedField<Type, areaMesh>& iF
|
||||
)
|
||||
:
|
||||
faPatchFieldBase(ptf),
|
||||
Field<Type>(ptf),
|
||||
patch_(ptf.patch_),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
patchType_(ptf.patchType_)
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
@ -151,21 +137,16 @@ const Foam::objectRegistry& Foam::faPatchField<Type>::db() const
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::faPatchField<Type>::check(const faPatchField<Type>& ptf) const
|
||||
void Foam::faPatchField<Type>::check(const faPatchField<Type>& rhs) const
|
||||
{
|
||||
if (&patch_ != &(ptf.patch_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "different patches for faPatchField<Type>s"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
faPatchFieldBase::checkPatch(rhs);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::faPatchField<Type>::snGrad() const
|
||||
{
|
||||
return (*this - patchInternalField())*patch_.deltaCoeffs();
|
||||
return (*this - patchInternalField())*patch().deltaCoeffs();
|
||||
}
|
||||
|
||||
|
||||
@ -173,7 +154,7 @@ template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::faPatchField<Type>::patchInternalField() const
|
||||
{
|
||||
return patch_.patchInternalField(internalField_);
|
||||
return patch().patchInternalField(internalField_);
|
||||
}
|
||||
|
||||
|
||||
@ -195,15 +176,22 @@ void Foam::faPatchField<Type>::rmap
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::faPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
faPatchFieldBase::setUpdated(true);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::faPatchField<Type>::evaluate(const Pstream::commsTypes)
|
||||
{
|
||||
if (!updated_)
|
||||
if (!updated())
|
||||
{
|
||||
updateCoeffs();
|
||||
}
|
||||
|
||||
updated_ = false;
|
||||
faPatchFieldBase::setUpdated(false);
|
||||
}
|
||||
|
||||
|
||||
@ -212,9 +200,9 @@ void Foam::faPatchField<Type>::write(Ostream& os) const
|
||||
{
|
||||
os.writeEntry("type", type());
|
||||
|
||||
if (!patchType_.empty())
|
||||
if (!patchType().empty())
|
||||
{
|
||||
os.writeEntry("patchType", patchType_);
|
||||
os.writeEntry("patchType", patchType());
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,7 +225,7 @@ void Foam::faPatchField<Type>::operator=
|
||||
const faPatchField<Type>& ptf
|
||||
)
|
||||
{
|
||||
check(ptf);
|
||||
faPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator=(ptf);
|
||||
}
|
||||
|
||||
@ -248,7 +236,7 @@ void Foam::faPatchField<Type>::operator+=
|
||||
const faPatchField<Type>& ptf
|
||||
)
|
||||
{
|
||||
check(ptf);
|
||||
faPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator+=(ptf);
|
||||
}
|
||||
|
||||
@ -259,7 +247,7 @@ void Foam::faPatchField<Type>::operator-=
|
||||
const faPatchField<Type>& ptf
|
||||
)
|
||||
{
|
||||
check(ptf);
|
||||
faPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator-=(ptf);
|
||||
}
|
||||
|
||||
@ -270,13 +258,7 @@ void Foam::faPatchField<Type>::operator*=
|
||||
const faPatchField<scalar>& ptf
|
||||
)
|
||||
{
|
||||
if (&patch_ != &ptf.patch())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "incompatible patches for patch fields"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
faPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator*=(ptf);
|
||||
}
|
||||
|
||||
@ -287,13 +269,7 @@ void Foam::faPatchField<Type>::operator/=
|
||||
const faPatchField<scalar>& ptf
|
||||
)
|
||||
{
|
||||
if (&patch_ != &ptf.patch())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< " incompatible patches for patch fields"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
faPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator/=(ptf);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,8 @@ Author
|
||||
|
||||
SourceFiles
|
||||
faPatchField.C
|
||||
newPatchField.C
|
||||
faPatchFieldBase.C
|
||||
faPatchFieldNew.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -57,21 +58,128 @@ namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class faPatchFieldMapper;
|
||||
class areaMesh;
|
||||
|
||||
template<class Type>
|
||||
class faPatchField;
|
||||
|
||||
template<class Type>
|
||||
class calculatedFaPatchField;
|
||||
template<class Type> class faPatchField;
|
||||
template<class Type> class calculatedFaPatchField;
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<(Ostream&, const faPatchField<Type>&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faPatchFieldBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Template invariant parts for faPatchField
|
||||
class faPatchFieldBase
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to patch
|
||||
const faPatch& patch_;
|
||||
|
||||
//- Update index used so that updateCoeffs is called only once during
|
||||
//- the construction of the matrix
|
||||
bool updated_;
|
||||
|
||||
//- Optional patch type
|
||||
// Used to allow specified boundary conditions to be applied
|
||||
// to constraint patches by providing the constraint
|
||||
// patch type as 'patchType'
|
||||
word patchType_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Read dictionary entries.
|
||||
// Useful when initially constructed without a dictionary
|
||||
virtual void readDict(const dictionary& dict);
|
||||
|
||||
//- Set updated state
|
||||
void setUpdated(bool state) noexcept
|
||||
{
|
||||
updated_ = state;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Debug switch to disallow the use of generic faPatchField
|
||||
static int disallowGenericPatchField;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("faPatchField");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch
|
||||
explicit faPatchFieldBase(const faPatch& p);
|
||||
|
||||
//- Construct from patch and patch type
|
||||
explicit faPatchFieldBase(const faPatch& p, const word& patchType);
|
||||
|
||||
//- Construct from patch and dictionary
|
||||
faPatchFieldBase(const faPatch& p, const dictionary& dict);
|
||||
|
||||
//- Copy construct with new patch
|
||||
faPatchFieldBase(const faPatchFieldBase& rhs, const faPatch& p);
|
||||
|
||||
//- Copy construct
|
||||
faPatchFieldBase(const faPatchFieldBase& rhs);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~faPatchFieldBase() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- The associated objectRegistry
|
||||
/// const objectRegistry& db() const;
|
||||
|
||||
//- Return the patch
|
||||
const faPatch& patch() const noexcept
|
||||
{
|
||||
return patch_;
|
||||
}
|
||||
|
||||
//- The optional patch type
|
||||
const word& patchType() const noexcept
|
||||
{
|
||||
return patchType_;
|
||||
}
|
||||
|
||||
//- The optional patch type
|
||||
word& patchType() noexcept
|
||||
{
|
||||
return patchType_;
|
||||
}
|
||||
|
||||
|
||||
// Solution
|
||||
|
||||
//- True if the boundary condition has already been updated
|
||||
bool updated() const noexcept
|
||||
{
|
||||
return updated_;
|
||||
}
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Check that patches are identical
|
||||
void checkPatch(const faPatchFieldBase& rhs) const;
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faPatchField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -79,25 +187,14 @@ Ostream& operator<<(Ostream&, const faPatchField<Type>&);
|
||||
template<class Type>
|
||||
class faPatchField
|
||||
:
|
||||
public faPatchFieldBase,
|
||||
public Field<Type>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to a patch
|
||||
const faPatch& patch_;
|
||||
|
||||
//- Reference to internal field
|
||||
const DimensionedField<Type, areaMesh>& internalField_;
|
||||
|
||||
//- Update index used so that updateCoeffs is called only once during
|
||||
// the construction of the matrix
|
||||
bool updated_;
|
||||
|
||||
//- Optional patch type, used to allow specified boundary conditions
|
||||
//- to be applied to constraint patches by providing the constraint
|
||||
//- patch type as 'patchType'
|
||||
word patchType_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -111,13 +208,6 @@ public:
|
||||
typedef calculatedFaPatchField<Type> Calculated;
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("faPatchField");
|
||||
|
||||
//- Debug switch to disallow the use of
|
||||
static int disallowGenericFaPatchField;
|
||||
|
||||
|
||||
// Declare run-time constructor selection tables
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
@ -198,12 +288,6 @@ public:
|
||||
//- Construct as copy
|
||||
faPatchField(const faPatchField<Type>&);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<faPatchField<Type>> clone() const
|
||||
{
|
||||
return tmp<faPatchField<Type>>(new faPatchField<Type>(*this));
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
faPatchField
|
||||
(
|
||||
@ -211,6 +295,12 @@ public:
|
||||
const DimensionedField<Type, areaMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<faPatchField<Type>> clone() const
|
||||
{
|
||||
return tmp<faPatchField<Type>>(new faPatchField<Type>(*this));
|
||||
}
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<faPatchField<Type>> clone
|
||||
(
|
||||
@ -273,50 +363,21 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~faPatchField<Type>() = default;
|
||||
virtual ~faPatchField() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
//- The type name for calculated patch fields
|
||||
static const word& calculatedType();
|
||||
|
||||
//- Return local objectRegistry
|
||||
const objectRegistry& db() const;
|
||||
//- The type name for zeroGradient patch fields
|
||||
static const word& zeroGradientType();
|
||||
|
||||
//- Return patch
|
||||
const faPatch& patch() const
|
||||
{
|
||||
return patch_;
|
||||
}
|
||||
|
||||
//- Return dimensioned internal field reference
|
||||
const DimensionedField<Type, areaMesh>& internalField() const
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
// Attributes
|
||||
|
||||
//- Return internal field reference
|
||||
const Field<Type>& primitiveField() const
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Optional patch type
|
||||
const word& patchType() const
|
||||
{
|
||||
return patchType_;
|
||||
}
|
||||
|
||||
//- Optional patch type
|
||||
word& patchType()
|
||||
{
|
||||
return patchType_;
|
||||
}
|
||||
|
||||
//- Return the type of the calculated for of faPatchField
|
||||
static const word& calculatedType();
|
||||
|
||||
//- Return true if this patch field fixes a value.
|
||||
//- True if this patch field fixes a value.
|
||||
// Needed to check if a level has to be specified while solving
|
||||
// Poissons equations.
|
||||
virtual bool fixesValue() const
|
||||
@ -324,16 +385,29 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return true if this patch field is coupled
|
||||
//- True if this patch field is coupled
|
||||
virtual bool coupled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return true if the boundary condition has already been updated
|
||||
bool updated() const
|
||||
|
||||
// Access
|
||||
|
||||
//- Return local objectRegistry
|
||||
const objectRegistry& db() const;
|
||||
|
||||
//- Return dimensioned internal field reference
|
||||
const DimensionedField<Type, areaMesh>&
|
||||
internalField() const noexcept
|
||||
{
|
||||
return updated_;
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Return internal field reference
|
||||
const Field<Type>& primitiveField() const noexcept
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
|
||||
@ -358,13 +432,6 @@ public:
|
||||
//- Return patch-normal gradient
|
||||
virtual tmp<Field<Type>> snGrad() const;
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
// Sets Updated to true
|
||||
virtual void updateCoeffs()
|
||||
{
|
||||
updated_ = true;
|
||||
}
|
||||
|
||||
//- Return internal field next to patch as patch field
|
||||
virtual tmp<Field<Type>> patchInternalField() const;
|
||||
|
||||
@ -375,6 +442,10 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
// Sets Updated to true
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Initialise the evaluation of the patch field
|
||||
virtual void initEvaluate
|
||||
(
|
||||
@ -471,7 +542,7 @@ public:
|
||||
virtual void operator==(const Type&);
|
||||
|
||||
|
||||
// Ostream operator
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<< <Type>(Ostream&, const faPatchField<Type>&);
|
||||
};
|
||||
@ -486,9 +557,13 @@ public:
|
||||
#ifdef NoRepository
|
||||
#include "faPatchField.C"
|
||||
#include "calculatedFaPatchField.H"
|
||||
#include "zeroGradientFaPatchField.H"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Runtime selection macros
|
||||
|
||||
#define addToFaPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
|
||||
\
|
||||
addToRunTimeSelectionTable \
|
||||
|
@ -0,0 +1,123 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 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 "faPatchField.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(faPatchFieldBase, 0);
|
||||
}
|
||||
|
||||
int Foam::faPatchFieldBase::disallowGenericPatchField
|
||||
(
|
||||
Foam::debug::debugSwitch("disallowGenericFaPatchField", 0)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::faPatchFieldBase::faPatchFieldBase(const faPatch& p)
|
||||
:
|
||||
patch_(p),
|
||||
updated_(false),
|
||||
patchType_()
|
||||
{}
|
||||
|
||||
|
||||
Foam::faPatchFieldBase::faPatchFieldBase
|
||||
(
|
||||
const faPatch& p,
|
||||
const word& patchType
|
||||
)
|
||||
:
|
||||
faPatchFieldBase(p)
|
||||
{
|
||||
patchType_ = patchType;
|
||||
}
|
||||
|
||||
|
||||
Foam::faPatchFieldBase::faPatchFieldBase
|
||||
(
|
||||
const faPatch& p,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
faPatchFieldBase(p)
|
||||
{
|
||||
faPatchFieldBase::readDict(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::faPatchFieldBase::faPatchFieldBase
|
||||
(
|
||||
const faPatchFieldBase& rhs,
|
||||
const faPatch& p
|
||||
)
|
||||
:
|
||||
patch_(p),
|
||||
updated_(false),
|
||||
patchType_(rhs.patchType_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::faPatchFieldBase::faPatchFieldBase(const faPatchFieldBase& rhs)
|
||||
:
|
||||
patch_(rhs.patch_),
|
||||
updated_(false),
|
||||
patchType_(rhs.patchType_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::faPatchFieldBase::readDict(const dictionary& dict)
|
||||
{
|
||||
dict.readIfPresent("patchType", patchType_, keyType::LITERAL);
|
||||
}
|
||||
|
||||
|
||||
// const Foam::objectRegistry& Foam::faPatchFieldBase::db() const
|
||||
// {
|
||||
// return patch_.boundaryMesh().mesh().thisDb();
|
||||
// }
|
||||
|
||||
|
||||
void Foam::faPatchFieldBase::checkPatch(const faPatchFieldBase& rhs) const
|
||||
{
|
||||
if (&patch_ != &(rhs.patch_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Different patches for faPatchField"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -69,14 +69,14 @@ Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New
|
||||
}
|
||||
|
||||
|
||||
tmp<faPatchField<Type>> tfap = ctorPtr(p, iF);
|
||||
tmp<faPatchField<Type>> tpfld(ctorPtr(p, iF));
|
||||
|
||||
// Check if constraint type override and store patchType if so
|
||||
// If constraint type: override and store patchType
|
||||
if (patchTypeCtor)
|
||||
{
|
||||
tfap.ref().patchType() = actualPatchType;
|
||||
tpfld.ref().patchType() = actualPatchType;
|
||||
}
|
||||
return tfap;
|
||||
return tpfld;
|
||||
}
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New
|
||||
|
||||
if (!ctorPtr)
|
||||
{
|
||||
if (!disallowGenericFaPatchField)
|
||||
if (!faPatchFieldBase::disallowGenericPatchField)
|
||||
{
|
||||
ctorPtr = dictionaryConstructorTable("generic");
|
||||
}
|
||||
|
@ -37,13 +37,6 @@ namespace Foam
|
||||
|
||||
#define makeFaPatchField(faPatchTypeField) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(faPatchTypeField, 0); \
|
||||
template<> \
|
||||
int \
|
||||
faPatchTypeField::disallowGenericFaPatchField \
|
||||
( \
|
||||
debug::debugSwitch("disallowGenericFaPatchField", 0) \
|
||||
); \
|
||||
defineTemplateRunTimeSelectionTable(faPatchTypeField, patch); \
|
||||
defineTemplateRunTimeSelectionTable(faPatchTypeField, patchMapper); \
|
||||
defineTemplateRunTimeSelectionTable(faPatchTypeField, dictionary);
|
||||
|
@ -25,8 +25,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef faPatchFields_H
|
||||
#define faPatchFields_H
|
||||
#ifndef Foam_faPatchFields_H
|
||||
#define Foam_faPatchFields_H
|
||||
|
||||
#include "faPatchField.H"
|
||||
#include "faPatchFieldsFwd.H"
|
||||
|
@ -34,7 +34,7 @@ License
|
||||
template<class Type>
|
||||
const Foam::word& Foam::faePatchField<Type>::calculatedType()
|
||||
{
|
||||
return calculatedFaePatchField<Type>::typeName;
|
||||
return Foam::calculatedFaePatchField<Type>::typeName;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 Wikki Ltd
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,8 +38,8 @@ Foam::faePatchField<Type>::faePatchField
|
||||
const DimensionedField<Type, edgeMesh>& iF
|
||||
)
|
||||
:
|
||||
faePatchFieldBase(p),
|
||||
Field<Type>(p.size()),
|
||||
patch_(p),
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
@ -51,8 +52,8 @@ Foam::faePatchField<Type>::faePatchField
|
||||
const Field<Type>& f
|
||||
)
|
||||
:
|
||||
faePatchFieldBase(p),
|
||||
Field<Type>(f),
|
||||
patch_(p),
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
@ -66,8 +67,8 @@ Foam::faePatchField<Type>::faePatchField
|
||||
const faPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
faePatchFieldBase(ptf, p),
|
||||
Field<Type>(ptf, mapper),
|
||||
patch_(p),
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
@ -80,8 +81,8 @@ Foam::faePatchField<Type>::faePatchField
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
faePatchFieldBase(p, dict),
|
||||
Field<Type>(p.size()),
|
||||
patch_(p),
|
||||
internalField_(iF)
|
||||
{
|
||||
const auto* eptr = dict.findEntry("value", keyType::LITERAL);
|
||||
@ -103,8 +104,8 @@ Foam::faePatchField<Type>::faePatchField
|
||||
const faePatchField<Type>& ptf
|
||||
)
|
||||
:
|
||||
faePatchFieldBase(ptf),
|
||||
Field<Type>(ptf),
|
||||
patch_(ptf.patch_),
|
||||
internalField_(ptf.internalField_)
|
||||
{}
|
||||
|
||||
@ -116,8 +117,8 @@ Foam::faePatchField<Type>::faePatchField
|
||||
const DimensionedField<Type, edgeMesh>& iF
|
||||
)
|
||||
:
|
||||
faePatchFieldBase(ptf),
|
||||
Field<Type>(ptf),
|
||||
patch_(ptf.patch_),
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
@ -133,14 +134,9 @@ const Foam::objectRegistry& Foam::faePatchField<Type>::db() const
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::faePatchField<Type>::check(const faePatchField<Type>& ptf) const
|
||||
void Foam::faePatchField<Type>::check(const faePatchField<Type>& rhs) const
|
||||
{
|
||||
if (&patch_ != &(ptf.patch_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "different patches for faePatchField<Type>s"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
faePatchFieldBase::checkPatch(rhs);
|
||||
}
|
||||
|
||||
|
||||
@ -170,9 +166,9 @@ void Foam::faePatchField<Type>::write(Ostream& os) const
|
||||
{
|
||||
os.writeEntry("type", type());
|
||||
|
||||
// if (!patchType_.empty())
|
||||
// if (!patchType().empty())
|
||||
// {
|
||||
// os.writeEntry("patchType", patchType_);
|
||||
// os.writeEntry("patchType", patchType());
|
||||
// }
|
||||
}
|
||||
|
||||
@ -195,7 +191,7 @@ void Foam::faePatchField<Type>::operator=
|
||||
const faePatchField<Type>& ptf
|
||||
)
|
||||
{
|
||||
check(ptf);
|
||||
faePatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator=(ptf);
|
||||
}
|
||||
|
||||
@ -206,7 +202,7 @@ void Foam::faePatchField<Type>::operator+=
|
||||
const faePatchField<Type>& ptf
|
||||
)
|
||||
{
|
||||
check(ptf);
|
||||
faePatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator+=(ptf);
|
||||
}
|
||||
|
||||
@ -217,7 +213,7 @@ void Foam::faePatchField<Type>::operator-=
|
||||
const faePatchField<Type>& ptf
|
||||
)
|
||||
{
|
||||
check(ptf);
|
||||
faePatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator-=(ptf);
|
||||
}
|
||||
|
||||
@ -228,13 +224,7 @@ void Foam::faePatchField<Type>::operator*=
|
||||
const faePatchField<scalar>& ptf
|
||||
)
|
||||
{
|
||||
if (&patch_ != &ptf.patch())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "incompatible patches for patch fields"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
faePatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator*=(ptf);
|
||||
}
|
||||
|
||||
@ -245,13 +235,7 @@ void Foam::faePatchField<Type>::operator/=
|
||||
const faePatchField<scalar>& ptf
|
||||
)
|
||||
{
|
||||
if (&patch_ != &ptf.patch())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< " incompatible patches for patch fields"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
faePatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator/=(ptf);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,8 @@ Author
|
||||
|
||||
SourceFiles
|
||||
faePatchField.C
|
||||
newPatchField.C
|
||||
faePatchFieldBase.C
|
||||
faePatchFieldNew.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -63,16 +64,86 @@ class dictionary;
|
||||
class faPatchFieldMapper;
|
||||
class edgeMesh;
|
||||
|
||||
template<class Type>
|
||||
class faePatchField;
|
||||
|
||||
template<class Type>
|
||||
class calculatedFaePatchField;
|
||||
template<class Type> class faePatchField;
|
||||
template<class Type> class calculatedFaePatchField;
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<(Ostream&, const faePatchField<Type>&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faePatchFieldBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Template invariant parts for faePatchField
|
||||
class faePatchFieldBase
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to patch
|
||||
const faPatch& patch_;
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Read dictionary entries.
|
||||
// Useful when initially constructed without a dictionary
|
||||
virtual void readDict(const dictionary& dict);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Debug switch to disallow the use of generic faePatchField
|
||||
static int disallowGenericPatchField;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("faePatchField");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch
|
||||
explicit faePatchFieldBase(const faPatch& p);
|
||||
|
||||
//- Construct from patch and patch type
|
||||
explicit faePatchFieldBase(const faPatch& p, const word& patchType);
|
||||
|
||||
//- Construct from patch and dictionary
|
||||
faePatchFieldBase(const faPatch& p, const dictionary& dict);
|
||||
|
||||
//- Copy construct with new patch
|
||||
faePatchFieldBase(const faePatchFieldBase& rhs, const faPatch& p);
|
||||
|
||||
//- Copy construct
|
||||
faePatchFieldBase(const faePatchFieldBase& rhs);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~faePatchFieldBase() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- The associated objectRegistry
|
||||
/// const objectRegistry& db() const;
|
||||
|
||||
//- Return the patch
|
||||
const faPatch& patch() const noexcept
|
||||
{
|
||||
return patch_;
|
||||
}
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Check that patches are identical
|
||||
void checkPatch(const faePatchFieldBase& rhs) const;
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faePatchField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -80,13 +151,11 @@ Ostream& operator<<(Ostream&, const faePatchField<Type>&);
|
||||
template<class Type>
|
||||
class faePatchField
|
||||
:
|
||||
public faePatchFieldBase,
|
||||
public Field<Type>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to a patch
|
||||
const faPatch& patch_;
|
||||
|
||||
//- Reference to internal field
|
||||
const DimensionedField<Type, edgeMesh>& internalField_;
|
||||
|
||||
@ -103,13 +172,6 @@ public:
|
||||
typedef calculatedFaePatchField<Type> Calculated;
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("faePatchField");
|
||||
|
||||
//- Debug switch to disallow the use of
|
||||
static int disallowGenericFaePatchField;
|
||||
|
||||
|
||||
// Declare run-time constructor selection tables
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
@ -189,12 +251,6 @@ public:
|
||||
//- Construct as copy
|
||||
faePatchField(const faePatchField<Type>&);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<faePatchField<Type>> clone() const
|
||||
{
|
||||
return tmp<faePatchField<Type>>(new faePatchField<Type>(*this));
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
faePatchField
|
||||
(
|
||||
@ -202,6 +258,12 @@ public:
|
||||
const DimensionedField<Type, edgeMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<faePatchField<Type>> clone() const
|
||||
{
|
||||
return tmp<faePatchField<Type>>(new faePatchField<Type>(*this));
|
||||
}
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<faePatchField<Type>> clone
|
||||
(
|
||||
@ -271,35 +333,15 @@ public:
|
||||
);
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
//- The type name for calculated patch fields
|
||||
static const word& calculatedType();
|
||||
|
||||
//- Return local objectRegistry
|
||||
const objectRegistry& db() const;
|
||||
|
||||
//- Return patch
|
||||
const faPatch& patch() const
|
||||
{
|
||||
return patch_;
|
||||
}
|
||||
// Attributes
|
||||
|
||||
//- Return dimensioned internal field reference
|
||||
const DimensionedField<Type, edgeMesh>& internalField() const
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Return internal field reference
|
||||
const Field<Type>& primitiveField() const
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Return the type of the calculated for of faePatchField
|
||||
static const word& calculatedType();
|
||||
|
||||
//- Return true if this patch field fixes a value.
|
||||
//- True if this patch field fixes a value.
|
||||
// Needed to check if a level has to be specified while solving
|
||||
// Poissons equations.
|
||||
virtual bool fixesValue() const
|
||||
@ -307,14 +349,33 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return true if this patch field is coupled
|
||||
//- True if this patch field is coupled
|
||||
virtual bool coupled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Mapping functions
|
||||
// Access
|
||||
|
||||
//- Return local objectRegistry
|
||||
const objectRegistry& db() const;
|
||||
|
||||
//- Return dimensioned internal field reference
|
||||
const DimensionedField<Type, edgeMesh>& internalField()
|
||||
const noexcept
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Return internal field reference
|
||||
const Field<Type>& primitiveField() const noexcept
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
|
||||
// Mapping
|
||||
|
||||
//- Map (and resize as needed) from self given a mapping object
|
||||
virtual void autoMap
|
||||
@ -334,13 +395,13 @@ public:
|
||||
virtual void write(Ostream&) const;
|
||||
|
||||
|
||||
// Check
|
||||
// Check
|
||||
|
||||
//- Check faePatchField<Type> against given faePatchField<Type>
|
||||
void check(const faePatchField<Type>&) const;
|
||||
//- Check faePatchField<Type> against given faePatchField<Type>
|
||||
void check(const faePatchField<Type>&) const;
|
||||
|
||||
|
||||
// Member operators
|
||||
// Member Operators
|
||||
|
||||
virtual void operator=(const UList<Type>&);
|
||||
|
||||
@ -370,7 +431,7 @@ public:
|
||||
virtual void operator==(const Type&);
|
||||
|
||||
|
||||
// Ostream operator
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<< <Type>(Ostream&, const faePatchField<Type>&);
|
||||
};
|
||||
@ -388,6 +449,9 @@ public:
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Runtime selection macros
|
||||
|
||||
#define makeFaePatchTypeFieldTypeName(typePatchTypeField) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);
|
||||
|
@ -0,0 +1,113 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 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 "faePatchField.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(faePatchFieldBase, 0);
|
||||
}
|
||||
|
||||
int Foam::faePatchFieldBase::disallowGenericPatchField
|
||||
(
|
||||
Foam::debug::debugSwitch("disallowGenericFaePatchField", 0)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::faePatchFieldBase::faePatchFieldBase(const faPatch& p)
|
||||
:
|
||||
patch_(p)
|
||||
{}
|
||||
|
||||
|
||||
Foam::faePatchFieldBase::faePatchFieldBase
|
||||
(
|
||||
const faPatch& p,
|
||||
const word& patchType
|
||||
)
|
||||
:
|
||||
faePatchFieldBase(p)
|
||||
{}
|
||||
|
||||
|
||||
Foam::faePatchFieldBase::faePatchFieldBase
|
||||
(
|
||||
const faPatch& p,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
faePatchFieldBase(p)
|
||||
{
|
||||
faePatchFieldBase::readDict(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::faePatchFieldBase::faePatchFieldBase
|
||||
(
|
||||
const faePatchFieldBase& rhs,
|
||||
const faPatch& p
|
||||
)
|
||||
:
|
||||
patch_(p)
|
||||
{}
|
||||
|
||||
|
||||
Foam::faePatchFieldBase::faePatchFieldBase(const faePatchFieldBase& rhs)
|
||||
:
|
||||
patch_(rhs.patch_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::faePatchFieldBase::readDict(const dictionary& dict)
|
||||
{}
|
||||
|
||||
|
||||
// const Foam::objectRegistry& Foam::faePatchFieldBase::db() const
|
||||
// {
|
||||
// return patch_.boundaryMesh().mesh().thisDb();
|
||||
// }
|
||||
|
||||
|
||||
void Foam::faePatchFieldBase::checkPatch(const faePatchFieldBase& rhs) const
|
||||
{
|
||||
if (&patch_ != &(rhs.patch_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Different patches for faePatchField"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -106,7 +106,7 @@ Foam::tmp<Foam::faePatchField<Type>> Foam::faePatchField<Type>::New
|
||||
|
||||
if (!ctorPtr)
|
||||
{
|
||||
if (!disallowGenericFaePatchField)
|
||||
if (!faePatchFieldBase::disallowGenericPatchField)
|
||||
{
|
||||
ctorPtr = dictionaryConstructorTable("generic");
|
||||
}
|
||||
|
@ -37,13 +37,6 @@ namespace Foam
|
||||
|
||||
#define makeFaePatchField(faePatchTypeField) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(faePatchTypeField, 0); \
|
||||
template<> \
|
||||
int \
|
||||
faePatchTypeField::disallowGenericFaePatchField \
|
||||
( \
|
||||
debug::debugSwitch("disallowGenericFaPatchField", 0) \
|
||||
); \
|
||||
defineTemplateRunTimeSelectionTable(faePatchTypeField, patch); \
|
||||
defineTemplateRunTimeSelectionTable(faePatchTypeField, patchMapper); \
|
||||
defineTemplateRunTimeSelectionTable(faePatchTypeField, dictionary);
|
||||
|
@ -31,8 +31,8 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef faePatchFields_H
|
||||
#define faePatchFields_H
|
||||
#ifndef Foam_faePatchFields_H
|
||||
#define Foam_faePatchFields_H
|
||||
|
||||
#include "faePatchField.H"
|
||||
#include "faePatchFieldsFwd.H"
|
||||
|
@ -121,6 +121,7 @@ functionObjects/fieldSelections/volFieldSelection/volFieldSelection.C
|
||||
functionObjects/fieldSelections/solverFieldSelection/solverFieldSelection.C
|
||||
|
||||
fvPatchFields = fields/fvPatchFields
|
||||
$(fvPatchFields)/fvPatchField/fvPatchFieldBase.C
|
||||
$(fvPatchFields)/fvPatchField/fvPatchFields.C
|
||||
|
||||
basicFvPatchFields = $(fvPatchFields)/basic
|
||||
@ -254,6 +255,7 @@ $(derivedFvPatchFields)/mappedField/Sampled/makeSampledPatchFunction1s.C
|
||||
$(derivedFvPatchFields)/mappedField/mappedMixedFieldFvPatchField/mappedMixedFieldFvPatchFields.C
|
||||
|
||||
fvsPatchFields = fields/fvsPatchFields
|
||||
$(fvsPatchFields)/fvsPatchField/fvsPatchFieldBase.C
|
||||
$(fvsPatchFields)/fvsPatchField/fvsPatchFields.C
|
||||
|
||||
basicFvsPatchFields = $(fvsPatchFields)/basic
|
||||
|
@ -34,7 +34,7 @@ License
|
||||
template<class Type>
|
||||
const Foam::word& Foam::fvPatchField<Type>::calculatedType()
|
||||
{
|
||||
return calculatedFvPatchField<Type>::typeName;
|
||||
return Foam::calculatedFvPatchField<Type>::typeName;
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,6 +28,16 @@ License
|
||||
#include "zeroGradientFvPatchField.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::word& Foam::fvPatchField<Type>::zeroGradientType()
|
||||
{
|
||||
return zeroGradientFvPatchField<Type>::typeName;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
|
@ -41,13 +41,9 @@ Foam::fvPatchField<Type>::fvPatchField
|
||||
const DimensionedField<Type, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fvPatchFieldBase(p),
|
||||
Field<Type>(p.size()),
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
manipulatedMatrix_(false),
|
||||
useImplicit_(false),
|
||||
patchType_()
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
@ -59,13 +55,9 @@ Foam::fvPatchField<Type>::fvPatchField
|
||||
const Type& value
|
||||
)
|
||||
:
|
||||
fvPatchFieldBase(p),
|
||||
Field<Type>(p.size(), value),
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
manipulatedMatrix_(false),
|
||||
useImplicit_(false),
|
||||
patchType_()
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
@ -77,13 +69,9 @@ Foam::fvPatchField<Type>::fvPatchField
|
||||
const word& patchType
|
||||
)
|
||||
:
|
||||
fvPatchFieldBase(p, patchType),
|
||||
Field<Type>(p.size()),
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
manipulatedMatrix_(false),
|
||||
useImplicit_(false),
|
||||
patchType_(patchType)
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
@ -95,13 +83,9 @@ Foam::fvPatchField<Type>::fvPatchField
|
||||
const Field<Type>& f
|
||||
)
|
||||
:
|
||||
fvPatchFieldBase(p),
|
||||
Field<Type>(f),
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
manipulatedMatrix_(false),
|
||||
useImplicit_(false),
|
||||
patchType_()
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
@ -114,17 +98,10 @@ Foam::fvPatchField<Type>::fvPatchField
|
||||
const bool valueRequired
|
||||
)
|
||||
:
|
||||
fvPatchFieldBase(p, dict),
|
||||
Field<Type>(p.size()),
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
manipulatedMatrix_(false),
|
||||
useImplicit_(false),
|
||||
patchType_()
|
||||
internalField_(iF)
|
||||
{
|
||||
dict.readIfPresent("useImplicit", useImplicit_, keyType::LITERAL);
|
||||
dict.readIfPresent("patchType", patchType_, keyType::LITERAL);
|
||||
|
||||
if (valueRequired)
|
||||
{
|
||||
const auto* eptr = dict.findEntry("value", keyType::LITERAL);
|
||||
@ -153,13 +130,9 @@ Foam::fvPatchField<Type>::fvPatchField
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fvPatchFieldBase(ptf, p),
|
||||
Field<Type>(p.size()),
|
||||
patch_(p),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
manipulatedMatrix_(false),
|
||||
useImplicit_(ptf.useImplicit_),
|
||||
patchType_(ptf.patchType_)
|
||||
internalField_(iF)
|
||||
{
|
||||
// For unmapped faces set to internal field value (zero-gradient)
|
||||
if (notNull(iF) && mapper.hasUnmapped())
|
||||
@ -176,13 +149,9 @@ Foam::fvPatchField<Type>::fvPatchField
|
||||
const fvPatchField<Type>& ptf
|
||||
)
|
||||
:
|
||||
fvPatchFieldBase(ptf),
|
||||
Field<Type>(ptf),
|
||||
patch_(ptf.patch_),
|
||||
internalField_(ptf.internalField_),
|
||||
updated_(false),
|
||||
manipulatedMatrix_(false),
|
||||
useImplicit_(ptf.useImplicit_),
|
||||
patchType_(ptf.patchType_)
|
||||
internalField_(ptf.internalField_)
|
||||
{}
|
||||
|
||||
|
||||
@ -193,41 +162,25 @@ Foam::fvPatchField<Type>::fvPatchField
|
||||
const DimensionedField<Type, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fvPatchFieldBase(ptf),
|
||||
Field<Type>(ptf),
|
||||
patch_(ptf.patch_),
|
||||
internalField_(iF),
|
||||
updated_(false),
|
||||
manipulatedMatrix_(false),
|
||||
useImplicit_(ptf.useImplicit_),
|
||||
patchType_(ptf.patchType_)
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::objectRegistry& Foam::fvPatchField<Type>::db() const
|
||||
void Foam::fvPatchField<Type>::check(const fvPatchField<Type>& rhs) const
|
||||
{
|
||||
return patch_.boundaryMesh().mesh();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::fvPatchField<Type>::check(const fvPatchField<Type>& ptf) const
|
||||
{
|
||||
if (&patch_ != &(ptf.patch_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "different patches for fvPatchField<Type>s"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
fvPatchFieldBase::checkPatch(rhs);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::fvPatchField<Type>::snGrad() const
|
||||
{
|
||||
return patch_.deltaCoeffs()*(*this - patchInternalField());
|
||||
return patch().deltaCoeffs()*(*this - patchInternalField());
|
||||
}
|
||||
|
||||
|
||||
@ -235,14 +188,14 @@ template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::fvPatchField<Type>::patchInternalField() const
|
||||
{
|
||||
return patch_.patchInternalField(internalField_);
|
||||
return patch().patchInternalField(internalField_);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::fvPatchField<Type>::patchInternalField(Field<Type>& pif) const
|
||||
{
|
||||
patch_.patchInternalField(internalField_, pif);
|
||||
patch().patchInternalField(internalField_, pif);
|
||||
}
|
||||
|
||||
|
||||
@ -323,7 +276,7 @@ void Foam::fvPatchField<Type>::rmap
|
||||
template<class Type>
|
||||
void Foam::fvPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
updated_ = true;
|
||||
fvPatchFieldBase::setUpdated(true);
|
||||
}
|
||||
|
||||
|
||||
@ -331,11 +284,11 @@ template<class Type>
|
||||
void Foam::fvPatchField<Type>::updateWeightedCoeffs(const scalarField& weights)
|
||||
{
|
||||
// Default behaviour ignores the weights
|
||||
if (!updated_)
|
||||
if (!updated())
|
||||
{
|
||||
updateCoeffs();
|
||||
|
||||
updated_ = true;
|
||||
fvPatchFieldBase::setUpdated(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,20 +296,20 @@ void Foam::fvPatchField<Type>::updateWeightedCoeffs(const scalarField& weights)
|
||||
template<class Type>
|
||||
void Foam::fvPatchField<Type>::evaluate(const Pstream::commsTypes)
|
||||
{
|
||||
if (!updated_)
|
||||
if (!updated())
|
||||
{
|
||||
updateCoeffs();
|
||||
}
|
||||
|
||||
updated_ = false;
|
||||
manipulatedMatrix_ = false;
|
||||
fvPatchFieldBase::setUpdated(false);
|
||||
fvPatchFieldBase::setManipulated(false);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::fvPatchField<Type>::manipulateMatrix(fvMatrix<Type>& matrix)
|
||||
{
|
||||
manipulatedMatrix_ = true;
|
||||
fvPatchFieldBase::setManipulated(true);
|
||||
}
|
||||
|
||||
|
||||
@ -367,7 +320,7 @@ void Foam::fvPatchField<Type>::manipulateMatrix
|
||||
const scalarField& weights
|
||||
)
|
||||
{
|
||||
manipulatedMatrix_ = true;
|
||||
fvPatchFieldBase::setManipulated(true);
|
||||
}
|
||||
|
||||
|
||||
@ -379,7 +332,7 @@ void Foam::fvPatchField<Type>::manipulateMatrix
|
||||
const direction cmp
|
||||
)
|
||||
{
|
||||
manipulatedMatrix_ = true;
|
||||
fvPatchFieldBase::setManipulated(true);
|
||||
}
|
||||
|
||||
|
||||
@ -388,15 +341,14 @@ void Foam::fvPatchField<Type>::write(Ostream& os) const
|
||||
{
|
||||
os.writeEntry("type", type());
|
||||
|
||||
if (useImplicit_)
|
||||
if (!patchType().empty())
|
||||
{
|
||||
os.writeEntry("patchType", patchType());
|
||||
}
|
||||
if (useImplicit())
|
||||
{
|
||||
os.writeEntry("useImplicit", "true");
|
||||
}
|
||||
|
||||
if (!patchType_.empty())
|
||||
{
|
||||
os.writeEntry("patchType", patchType_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -418,7 +370,7 @@ void Foam::fvPatchField<Type>::operator=
|
||||
const fvPatchField<Type>& ptf
|
||||
)
|
||||
{
|
||||
check(ptf);
|
||||
fvPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator=(ptf);
|
||||
}
|
||||
|
||||
@ -429,7 +381,7 @@ void Foam::fvPatchField<Type>::operator+=
|
||||
const fvPatchField<Type>& ptf
|
||||
)
|
||||
{
|
||||
check(ptf);
|
||||
fvPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator+=(ptf);
|
||||
}
|
||||
|
||||
@ -440,7 +392,7 @@ void Foam::fvPatchField<Type>::operator-=
|
||||
const fvPatchField<Type>& ptf
|
||||
)
|
||||
{
|
||||
check(ptf);
|
||||
fvPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator-=(ptf);
|
||||
}
|
||||
|
||||
@ -451,13 +403,7 @@ void Foam::fvPatchField<Type>::operator*=
|
||||
const fvPatchField<scalar>& ptf
|
||||
)
|
||||
{
|
||||
if (&patch_ != &ptf.patch())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "incompatible patches for patch fields"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
fvPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator*=(ptf);
|
||||
}
|
||||
|
||||
@ -468,12 +414,7 @@ void Foam::fvPatchField<Type>::operator/=
|
||||
const fvPatchField<scalar>& ptf
|
||||
)
|
||||
{
|
||||
if (&patch_ != &ptf.patch())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
fvPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator/=(ptf);
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ Description
|
||||
|
||||
SourceFiles
|
||||
fvPatchField.C
|
||||
fvPatchFieldBase.C
|
||||
fvPatchFieldNew.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -58,7 +59,6 @@ namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class fvPatchFieldMapper;
|
||||
@ -73,22 +73,17 @@ Ostream& operator<<(Ostream&, const fvPatchField<Type>&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fvPatchField Declaration
|
||||
Class fvPatchFieldBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class fvPatchField
|
||||
:
|
||||
public Field<Type>
|
||||
//- Template invariant parts for fvPatchField
|
||||
class fvPatchFieldBase
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to patch
|
||||
const fvPatch& patch_;
|
||||
|
||||
//- Reference to internal field
|
||||
const DimensionedField<Type, volMesh>& internalField_;
|
||||
|
||||
//- Update index used so that updateCoeffs is called only once during
|
||||
//- the construction of the matrix
|
||||
bool updated_;
|
||||
@ -100,12 +95,143 @@ class fvPatchField
|
||||
//- Use implicit formulation
|
||||
bool useImplicit_;
|
||||
|
||||
//- Optional patch type, used to allow specified boundary conditions
|
||||
// to be applied to constraint patches by providing the constraint
|
||||
//- Optional patch type
|
||||
// Used to allow specified boundary conditions to be applied
|
||||
// to constraint patches by providing the constraint
|
||||
// patch type as 'patchType'
|
||||
word patchType_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Read dictionary entries.
|
||||
// Useful when initially constructed without a dictionary
|
||||
virtual void readDict(const dictionary& dict);
|
||||
|
||||
//- Set updated state
|
||||
void setUpdated(bool state) noexcept
|
||||
{
|
||||
updated_ = state;
|
||||
}
|
||||
|
||||
//- Set matrix manipulated state
|
||||
void setManipulated(bool state) noexcept
|
||||
{
|
||||
manipulatedMatrix_ = state;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//- Debug switch to disallow the use of generic fvPatchField
|
||||
static int disallowGenericPatchField;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fvPatchField");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch
|
||||
explicit fvPatchFieldBase(const fvPatch& p);
|
||||
|
||||
//- Construct from patch and patch type
|
||||
explicit fvPatchFieldBase(const fvPatch& p, const word& patchType);
|
||||
|
||||
//- Construct from patch and dictionary
|
||||
fvPatchFieldBase(const fvPatch& p, const dictionary& dict);
|
||||
|
||||
//- Copy construct with new patch
|
||||
fvPatchFieldBase(const fvPatchFieldBase& rhs, const fvPatch& p);
|
||||
|
||||
//- Copy construct
|
||||
fvPatchFieldBase(const fvPatchFieldBase& rhs);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fvPatchFieldBase() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- The associated objectRegistry
|
||||
const objectRegistry& db() const;
|
||||
|
||||
//- Return the patch
|
||||
const fvPatch& patch() const noexcept
|
||||
{
|
||||
return patch_;
|
||||
}
|
||||
|
||||
//- The optional patch type
|
||||
const word& patchType() const noexcept
|
||||
{
|
||||
return patchType_;
|
||||
}
|
||||
|
||||
//- The optional patch type
|
||||
word& patchType() noexcept
|
||||
{
|
||||
return patchType_;
|
||||
}
|
||||
|
||||
|
||||
// Solution
|
||||
|
||||
//- True if the boundary condition has already been updated
|
||||
bool updated() const noexcept
|
||||
{
|
||||
return updated_;
|
||||
}
|
||||
|
||||
//- True if the matrix has already been manipulated
|
||||
bool manipulatedMatrix() const noexcept
|
||||
{
|
||||
return manipulatedMatrix_;
|
||||
}
|
||||
|
||||
//- Use implicit formulation for coupled patches only
|
||||
bool useImplicit() const noexcept
|
||||
{
|
||||
return useImplicit_;
|
||||
}
|
||||
|
||||
//- Set useImplicit on/off
|
||||
// \return old value
|
||||
bool useImplicit(bool on) noexcept
|
||||
{
|
||||
bool old(useImplicit_);
|
||||
useImplicit_ = on;
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Check that patches are identical
|
||||
void checkPatch(const fvPatchFieldBase& rhs) const;
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fvPatchField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class fvPatchField
|
||||
:
|
||||
public fvPatchFieldBase,
|
||||
public Field<Type>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to internal field
|
||||
const DimensionedField<Type, volMesh>& internalField_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- The internal field type associated with the patch field
|
||||
@ -118,13 +244,6 @@ public:
|
||||
typedef calculatedFvPatchField<Type> Calculated;
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fvPatchField");
|
||||
|
||||
//- Debug switch to disallow the use of genericFvPatchField
|
||||
static int disallowGenericFvPatchField;
|
||||
|
||||
|
||||
// Declare run-time constructor selection tables
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
@ -221,12 +340,6 @@ public:
|
||||
//- Construct as copy
|
||||
fvPatchField(const fvPatchField<Type>&);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchField<Type>> clone() const
|
||||
{
|
||||
return tmp<fvPatchField<Type>>::New(*this);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
fvPatchField
|
||||
(
|
||||
@ -234,6 +347,12 @@ public:
|
||||
const DimensionedField<Type, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchField<Type>> clone() const
|
||||
{
|
||||
return tmp<fvPatchField<Type>>::New(*this);
|
||||
}
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchField<Type>> clone
|
||||
(
|
||||
@ -304,35 +423,21 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fvPatchField<Type>() = default;
|
||||
virtual ~fvPatchField() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Implicit Functions
|
||||
//- The type name for calculated patch fields
|
||||
static const word& calculatedType();
|
||||
|
||||
//- Use implicit formulation for coupled patches only
|
||||
bool useImplicit() const noexcept
|
||||
{
|
||||
return useImplicit_;
|
||||
}
|
||||
|
||||
//- Set useImplicit on/off
|
||||
// \return old value
|
||||
bool useImplicit(bool on) noexcept
|
||||
{
|
||||
bool old(useImplicit_);
|
||||
useImplicit_ = on;
|
||||
return old;
|
||||
}
|
||||
//- The type name for zeroGradient patch fields
|
||||
static const word& zeroGradientType();
|
||||
|
||||
|
||||
// Attributes
|
||||
|
||||
//- Return the type of the calculated for of fvPatchField
|
||||
static const word& calculatedType();
|
||||
|
||||
//- Return true if this patch field fixes a value.
|
||||
//- True if this patch field fixes a value.
|
||||
// Needed to check if a level has to be specified while solving
|
||||
// Poissons equations.
|
||||
virtual bool fixesValue() const
|
||||
@ -340,14 +445,14 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return true if the value of the patch field
|
||||
// is altered by assignment (the default)
|
||||
//- True if the value of the patch field
|
||||
//- is altered by assignment (the default)
|
||||
virtual bool assignable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return true if this patch field is coupled
|
||||
//- True if this patch field is coupled
|
||||
virtual bool coupled() const
|
||||
{
|
||||
return false;
|
||||
@ -356,51 +461,19 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return local objectRegistry
|
||||
const objectRegistry& db() const;
|
||||
|
||||
//- Return patch
|
||||
const fvPatch& patch() const
|
||||
{
|
||||
return patch_;
|
||||
}
|
||||
|
||||
//- Return dimensioned internal field reference
|
||||
const DimensionedField<Type, volMesh>& internalField() const
|
||||
const DimensionedField<Type, volMesh>& internalField()
|
||||
const noexcept
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Return internal field reference
|
||||
const Field<Type>& primitiveField() const
|
||||
const Field<Type>& primitiveField() const noexcept
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Optional patch type
|
||||
const word& patchType() const
|
||||
{
|
||||
return patchType_;
|
||||
}
|
||||
|
||||
//- Optional patch type
|
||||
word& patchType()
|
||||
{
|
||||
return patchType_;
|
||||
}
|
||||
|
||||
//- Return true if the boundary condition has already been updated
|
||||
bool updated() const
|
||||
{
|
||||
return updated_;
|
||||
}
|
||||
|
||||
//- Return true if the matrix has already been manipulated
|
||||
bool manipulatedMatrix() const
|
||||
{
|
||||
return manipulatedMatrix_;
|
||||
}
|
||||
|
||||
|
||||
// Mapping Functions
|
||||
|
||||
@ -597,7 +670,7 @@ public:
|
||||
virtual void operator==(const Type&);
|
||||
|
||||
|
||||
// Ostream operator
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<< <Type>(Ostream&, const fvPatchField<Type>&);
|
||||
};
|
||||
@ -612,22 +685,21 @@ public:
|
||||
#ifdef NoRepository
|
||||
#include "fvPatchField.C"
|
||||
#include "calculatedFvPatchField.H"
|
||||
#include "zeroGradientFvPatchField.H"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Runtime selection macros
|
||||
|
||||
#define makeFvPatchField(fvPatchTypeField) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(fvPatchTypeField, 0); \
|
||||
template<> \
|
||||
int fvPatchTypeField::disallowGenericFvPatchField \
|
||||
( \
|
||||
debug::debugSwitch("disallowGenericFvPatchField", 0) \
|
||||
); \
|
||||
defineTemplateRunTimeSelectionTable(fvPatchTypeField, patch); \
|
||||
defineTemplateRunTimeSelectionTable(fvPatchTypeField, patchMapper); \
|
||||
defineTemplateRunTimeSelectionTable(fvPatchTypeField, dictionary);
|
||||
|
||||
|
||||
#undef addToPatchFieldRunTimeSelection
|
||||
#define addToPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
|
||||
addToRunTimeSelectionTable \
|
||||
( \
|
||||
@ -650,6 +722,7 @@ defineTemplateRunTimeSelectionTable(fvPatchTypeField, dictionary);
|
||||
|
||||
|
||||
// Use with caution
|
||||
#undef addRemovableToPatchFieldRunTimeSelection
|
||||
#define addRemovableToPatchFieldRunTimeSelection\
|
||||
(PatchTypeField, typePatchTypeField) \
|
||||
\
|
||||
|
@ -0,0 +1,130 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 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 "fvPatchField.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(fvPatchFieldBase, 0);
|
||||
}
|
||||
|
||||
int Foam::fvPatchFieldBase::disallowGenericPatchField
|
||||
(
|
||||
Foam::debug::debugSwitch("disallowGenericFvPatchField", 0)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fvPatchFieldBase::fvPatchFieldBase(const fvPatch& p)
|
||||
:
|
||||
patch_(p),
|
||||
updated_(false),
|
||||
manipulatedMatrix_(false),
|
||||
useImplicit_(false),
|
||||
patchType_()
|
||||
{}
|
||||
|
||||
|
||||
Foam::fvPatchFieldBase::fvPatchFieldBase
|
||||
(
|
||||
const fvPatch& p,
|
||||
const word& patchType
|
||||
)
|
||||
:
|
||||
fvPatchFieldBase(p)
|
||||
{
|
||||
patchType_ = patchType;
|
||||
}
|
||||
|
||||
|
||||
Foam::fvPatchFieldBase::fvPatchFieldBase
|
||||
(
|
||||
const fvPatch& p,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvPatchFieldBase(p)
|
||||
{
|
||||
fvPatchFieldBase::readDict(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::fvPatchFieldBase::fvPatchFieldBase
|
||||
(
|
||||
const fvPatchFieldBase& rhs,
|
||||
const fvPatch& p
|
||||
)
|
||||
:
|
||||
patch_(p),
|
||||
updated_(false),
|
||||
manipulatedMatrix_(false),
|
||||
useImplicit_(rhs.useImplicit_),
|
||||
patchType_(rhs.patchType_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::fvPatchFieldBase::fvPatchFieldBase(const fvPatchFieldBase& rhs)
|
||||
:
|
||||
patch_(rhs.patch_),
|
||||
updated_(false),
|
||||
manipulatedMatrix_(false),
|
||||
useImplicit_(rhs.useImplicit_),
|
||||
patchType_(rhs.patchType_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fvPatchFieldBase::readDict(const dictionary& dict)
|
||||
{
|
||||
dict.readIfPresent("patchType", patchType_, keyType::LITERAL);
|
||||
dict.readIfPresent("useImplicit", useImplicit_, keyType::LITERAL);
|
||||
}
|
||||
|
||||
|
||||
const Foam::objectRegistry& Foam::fvPatchFieldBase::db() const
|
||||
{
|
||||
return patch_.boundaryMesh().mesh();
|
||||
}
|
||||
|
||||
|
||||
void Foam::fvPatchFieldBase::checkPatch(const fvPatchFieldBase& rhs) const
|
||||
{
|
||||
if (&patch_ != &(rhs.patch_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Different patches for fvPatchField"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -69,14 +69,14 @@ Foam::tmp<Foam::fvPatchField<Type>> Foam::fvPatchField<Type>::New
|
||||
}
|
||||
|
||||
|
||||
tmp<fvPatchField<Type>> tfvp = ctorPtr(p, iF);
|
||||
tmp<fvPatchField<Type>> tpfld(ctorPtr(p, iF));
|
||||
|
||||
// Check if constraint type override and store patchType if so
|
||||
// If constraint type: override and store patchType
|
||||
if (patchTypeCtor)
|
||||
{
|
||||
tfvp.ref().patchType() = actualPatchType;
|
||||
tpfld.ref().patchType() = actualPatchType;
|
||||
}
|
||||
return tfvp;
|
||||
return tpfld;
|
||||
}
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ Foam::tmp<Foam::fvPatchField<Type>> Foam::fvPatchField<Type>::New
|
||||
|
||||
if (!ctorPtr)
|
||||
{
|
||||
if (!disallowGenericFvPatchField)
|
||||
if (!fvPatchFieldBase::disallowGenericPatchField)
|
||||
{
|
||||
ctorPtr = dictionaryConstructorTable("generic");
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fvPatchFields_H
|
||||
#define fvPatchFields_H
|
||||
#ifndef Foam_fvPatchFields_H
|
||||
#define Foam_fvPatchFields_H
|
||||
|
||||
#include "fvPatchField.H"
|
||||
#include "fvPatchFieldsFwd.H"
|
||||
|
@ -25,8 +25,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fvPatchFieldsFwd_H
|
||||
#define fvPatchFieldsFwd_H
|
||||
#ifndef Foam_fvPatchFieldsFwd_H
|
||||
#define Foam_fvPatchFieldsFwd_H
|
||||
|
||||
#include "fieldTypes.H"
|
||||
|
||||
|
@ -34,7 +34,7 @@ License
|
||||
template<class Type>
|
||||
const Foam::word& Foam::fvsPatchField<Type>::calculatedType()
|
||||
{
|
||||
return calculatedFvsPatchField<Type>::typeName;
|
||||
return Foam::calculatedFvsPatchField<Type>::typeName;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
@ -41,8 +41,8 @@ Foam::fvsPatchField<Type>::fvsPatchField
|
||||
const DimensionedField<Type, surfaceMesh>& iF
|
||||
)
|
||||
:
|
||||
fvsPatchFieldBase(p),
|
||||
Field<Type>(p.size()),
|
||||
patch_(p),
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
@ -55,8 +55,8 @@ Foam::fvsPatchField<Type>::fvsPatchField
|
||||
const Field<Type>& f
|
||||
)
|
||||
:
|
||||
fvsPatchFieldBase(p),
|
||||
Field<Type>(f),
|
||||
patch_(p),
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
@ -70,8 +70,8 @@ Foam::fvsPatchField<Type>::fvsPatchField
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fvsPatchFieldBase(ptf, p),
|
||||
Field<Type>(ptf, mapper),
|
||||
patch_(p),
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
@ -85,8 +85,8 @@ Foam::fvsPatchField<Type>::fvsPatchField
|
||||
const bool valueRequired
|
||||
)
|
||||
:
|
||||
fvsPatchFieldBase(p, dict),
|
||||
Field<Type>(p.size()),
|
||||
patch_(p),
|
||||
internalField_(iF)
|
||||
{
|
||||
if (valueRequired)
|
||||
@ -111,8 +111,8 @@ Foam::fvsPatchField<Type>::fvsPatchField
|
||||
template<class Type>
|
||||
Foam::fvsPatchField<Type>::fvsPatchField(const fvsPatchField<Type>& ptf)
|
||||
:
|
||||
fvsPatchFieldBase(ptf),
|
||||
Field<Type>(ptf),
|
||||
patch_(ptf.patch_),
|
||||
internalField_(ptf.internalField_)
|
||||
{}
|
||||
|
||||
@ -124,30 +124,18 @@ Foam::fvsPatchField<Type>::fvsPatchField
|
||||
const DimensionedField<Type, surfaceMesh>& iF
|
||||
)
|
||||
:
|
||||
fvsPatchFieldBase(ptf),
|
||||
Field<Type>(ptf),
|
||||
patch_(ptf.patch_),
|
||||
internalField_(iF)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::objectRegistry& Foam::fvsPatchField<Type>::db() const
|
||||
{
|
||||
return patch_.boundaryMesh().mesh();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::fvsPatchField<Type>::check(const fvsPatchField<Type>& ptf) const
|
||||
{
|
||||
if (&patch_ != &(ptf.patch_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "different patches for fvsPatchField<Type>s"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
fvsPatchFieldBase::checkPatch(ptf);
|
||||
}
|
||||
|
||||
|
||||
@ -196,7 +184,7 @@ void Foam::fvsPatchField<Type>::operator=
|
||||
const fvsPatchField<Type>& ptf
|
||||
)
|
||||
{
|
||||
check(ptf);
|
||||
fvsPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator=(ptf);
|
||||
}
|
||||
|
||||
@ -207,7 +195,7 @@ void Foam::fvsPatchField<Type>::operator+=
|
||||
const fvsPatchField<Type>& ptf
|
||||
)
|
||||
{
|
||||
check(ptf);
|
||||
fvsPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator+=(ptf);
|
||||
}
|
||||
|
||||
@ -218,7 +206,7 @@ void Foam::fvsPatchField<Type>::operator-=
|
||||
const fvsPatchField<Type>& ptf
|
||||
)
|
||||
{
|
||||
check(ptf);
|
||||
fvsPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator-=(ptf);
|
||||
}
|
||||
|
||||
@ -229,13 +217,7 @@ void Foam::fvsPatchField<Type>::operator*=
|
||||
const fvsPatchField<scalar>& ptf
|
||||
)
|
||||
{
|
||||
if (&patch_ != &ptf.patch())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "incompatible patches for patch fields"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
fvsPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator*=(ptf);
|
||||
}
|
||||
|
||||
@ -246,12 +228,7 @@ void Foam::fvsPatchField<Type>::operator/=
|
||||
const fvsPatchField<scalar>& ptf
|
||||
)
|
||||
{
|
||||
if (&patch_ != &ptf.patch())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
fvsPatchFieldBase::checkPatch(ptf);
|
||||
Field<Type>::operator/=(ptf);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,6 @@ namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class fvPatchFieldMapper;
|
||||
@ -70,19 +69,87 @@ Ostream& operator<<(Ostream&, const fvsPatchField<Type>&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class patch Declaration
|
||||
Class fvsPatchFieldBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class fvsPatchField
|
||||
:
|
||||
public Field<Type>
|
||||
//- Template invariant parts for fvsPatchField
|
||||
class fvsPatchFieldBase
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to patch
|
||||
const fvPatch& patch_;
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Read dictionary entries.
|
||||
// Useful when initially constructed without a dictionary
|
||||
virtual void readDict(const dictionary& dict);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Debug switch to disallow the use of generic fvsPatchField
|
||||
static int disallowGenericPatchField;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fvsPatchField");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch
|
||||
explicit fvsPatchFieldBase(const fvPatch& p);
|
||||
|
||||
//- Construct from patch and dictionary (unused)
|
||||
fvsPatchFieldBase(const fvPatch& p, const dictionary& dict);
|
||||
|
||||
//- Copy construct with new patch
|
||||
fvsPatchFieldBase(const fvsPatchFieldBase& rhs, const fvPatch& p);
|
||||
|
||||
//- Copy construct
|
||||
fvsPatchFieldBase(const fvsPatchFieldBase& rhs);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fvsPatchFieldBase() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- The associated objectRegistry
|
||||
const objectRegistry& db() const;
|
||||
|
||||
//- Return the patch
|
||||
const fvPatch& patch() const noexcept
|
||||
{
|
||||
return patch_;
|
||||
}
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Check that patches are identical
|
||||
void checkPatch(const fvsPatchFieldBase& rhs) const;
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fvsPatchField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class fvsPatchField
|
||||
:
|
||||
public fvsPatchFieldBase,
|
||||
public Field<Type>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to internal field
|
||||
const DimensionedField<Type, surfaceMesh>& internalField_;
|
||||
|
||||
@ -99,13 +166,6 @@ public:
|
||||
typedef calculatedFvsPatchField<Type> Calculated;
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fvsPatchField");
|
||||
|
||||
//- Debug switch to disallow the use of genericFvsPatchField
|
||||
static int disallowGenericFvsPatchField;
|
||||
|
||||
|
||||
// Declare run-time constructor selection tables
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
@ -186,12 +246,6 @@ public:
|
||||
//- Construct as copy
|
||||
fvsPatchField(const fvsPatchField<Type>&);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvsPatchField<Type>> clone() const
|
||||
{
|
||||
return tmp<fvsPatchField<Type>>::New(*this);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
fvsPatchField
|
||||
(
|
||||
@ -199,6 +253,12 @@ public:
|
||||
const DimensionedField<Type, surfaceMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvsPatchField<Type>> clone() const
|
||||
{
|
||||
return tmp<fvsPatchField<Type>>::New(*this);
|
||||
}
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvsPatchField<Type>> clone
|
||||
(
|
||||
@ -269,38 +329,18 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fvsPatchField<Type>() = default;
|
||||
virtual ~fvsPatchField() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
//- The type name for calculated patch fields
|
||||
static const word& calculatedType();
|
||||
|
||||
//- Return local objectRegistry
|
||||
const objectRegistry& db() const;
|
||||
|
||||
//- Return patch
|
||||
const fvPatch& patch() const
|
||||
{
|
||||
return patch_;
|
||||
}
|
||||
// Attributes
|
||||
|
||||
//- Return dimensioned internal field reference
|
||||
const DimensionedField<Type, surfaceMesh>& internalField() const
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Return internal field reference
|
||||
const Field<Type>& primitiveField() const
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Return the type of the calculated for of fvsPatchField
|
||||
static const word& calculatedType();
|
||||
|
||||
//- Return true if this patch field fixes a value.
|
||||
//- True if this patch field fixes a value.
|
||||
// Needed to check if a level has to be specified while solving
|
||||
// Poissons equations.
|
||||
virtual bool fixesValue() const
|
||||
@ -308,14 +348,30 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return true if this patch field is coupled
|
||||
//- True if this patch field is coupled
|
||||
virtual bool coupled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Mapping functions
|
||||
// Access
|
||||
|
||||
//- Return dimensioned internal field reference
|
||||
const DimensionedField<Type, surfaceMesh>& internalField()
|
||||
const noexcept
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
//- Return internal field reference
|
||||
const Field<Type>& primitiveField() const noexcept
|
||||
{
|
||||
return internalField_;
|
||||
}
|
||||
|
||||
|
||||
// Mapping Functions
|
||||
|
||||
//- Map (and resize as needed) from self given a mapping object
|
||||
virtual void autoMap
|
||||
@ -341,7 +397,7 @@ public:
|
||||
void check(const fvsPatchField<Type>&) const;
|
||||
|
||||
|
||||
// Member operators
|
||||
// Member Operators
|
||||
|
||||
virtual void operator=(const UList<Type>&);
|
||||
|
||||
@ -371,7 +427,7 @@ public:
|
||||
virtual void operator==(const Type&);
|
||||
|
||||
|
||||
// Ostream operator
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
|
||||
};
|
||||
@ -389,6 +445,9 @@ public:
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Runtime selection macros
|
||||
|
||||
#define makeFvsPatchTypeFieldTypeName(type) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(type, 0);
|
||||
|
@ -0,0 +1,101 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 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 "fvsPatchField.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(fvsPatchFieldBase, 0);
|
||||
}
|
||||
|
||||
int Foam::fvsPatchFieldBase::disallowGenericPatchField
|
||||
(
|
||||
Foam::debug::debugSwitch("disallowGenericFvsPatchField", 0)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fvsPatchFieldBase::fvsPatchFieldBase(const fvPatch& p)
|
||||
:
|
||||
patch_(p)
|
||||
{}
|
||||
|
||||
|
||||
Foam::fvsPatchFieldBase::fvsPatchFieldBase
|
||||
(
|
||||
const fvPatch& p,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
patch_(p)
|
||||
{}
|
||||
|
||||
|
||||
Foam::fvsPatchFieldBase::fvsPatchFieldBase
|
||||
(
|
||||
const fvsPatchFieldBase& rhs,
|
||||
const fvPatch& p
|
||||
)
|
||||
:
|
||||
patch_(p)
|
||||
{}
|
||||
|
||||
|
||||
Foam::fvsPatchFieldBase::fvsPatchFieldBase(const fvsPatchFieldBase& rhs)
|
||||
:
|
||||
patch_(rhs.patch_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fvsPatchFieldBase::readDict(const dictionary& dict)
|
||||
{}
|
||||
|
||||
|
||||
const Foam::objectRegistry& Foam::fvsPatchFieldBase::db() const
|
||||
{
|
||||
return patch_.boundaryMesh().mesh();
|
||||
}
|
||||
|
||||
|
||||
void Foam::fvsPatchFieldBase::checkPatch(const fvsPatchFieldBase& rhs) const
|
||||
{
|
||||
if (&patch_ != &(rhs.patch_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Different patches for fvsPatchField"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -102,7 +102,7 @@ Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
|
||||
|
||||
if (!ctorPtr)
|
||||
{
|
||||
if (!disallowGenericFvsPatchField)
|
||||
if (!fvsPatchFieldBase::disallowGenericPatchField)
|
||||
{
|
||||
ctorPtr = dictionaryConstructorTable("generic");
|
||||
}
|
||||
|
@ -36,12 +36,6 @@ namespace Foam
|
||||
|
||||
#define makeFvsPatchField(fvsPatchTypeField) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(fvsPatchTypeField, 0); \
|
||||
template<> \
|
||||
int fvsPatchTypeField::disallowGenericFvsPatchField \
|
||||
( \
|
||||
debug::debugSwitch("disallowGenericFvsPatchField", 0) \
|
||||
); \
|
||||
defineTemplateRunTimeSelectionTable(fvsPatchTypeField, patch); \
|
||||
defineTemplateRunTimeSelectionTable(fvsPatchTypeField, patchMapper); \
|
||||
defineTemplateRunTimeSelectionTable(fvsPatchTypeField, dictionary);
|
||||
|
@ -30,8 +30,8 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fvsPatchFields_H
|
||||
#define fvsPatchFields_H
|
||||
#ifndef Foam_fvsPatchFields_H
|
||||
#define Foam_fvsPatchFields_H
|
||||
|
||||
#include "fvsPatchField.H"
|
||||
#include "fvsPatchFieldsFwd.H"
|
||||
|
@ -30,8 +30,8 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fvsPatchFieldsFwd_H
|
||||
#define fvsPatchFieldsFwd_H
|
||||
#ifndef Foam_fvsPatchFieldsFwd_H
|
||||
#define Foam_fvsPatchFieldsFwd_H
|
||||
|
||||
#include "fieldTypes.H"
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -78,12 +78,13 @@ Foam::fvPatch::~fvPatch()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fvPatch::constraintType(const word& pt)
|
||||
bool Foam::fvPatch::constraintType(const word& patchType)
|
||||
{
|
||||
return
|
||||
(
|
||||
fvPatchField<scalar>::patchConstructorTablePtr_
|
||||
&& fvPatchField<scalar>::patchConstructorTablePtr_->found(pt)
|
||||
!patchType.empty()
|
||||
&& fvPatchField<scalar>::patchConstructorTablePtr_
|
||||
&& fvPatchField<scalar>::patchConstructorTablePtr_->found(patchType)
|
||||
);
|
||||
}
|
||||
|
||||
@ -104,7 +105,7 @@ Foam::wordList Foam::fvPatch::constraintTypes()
|
||||
}
|
||||
}
|
||||
|
||||
cTypes.setSize(i);
|
||||
cTypes.resize(i);
|
||||
|
||||
return cTypes;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public:
|
||||
}
|
||||
|
||||
//- Return true if the given type is a constraint type
|
||||
static bool constraintType(const word& pt);
|
||||
static bool constraintType(const word& patchType);
|
||||
|
||||
//- Return a list of all the constraint patch types
|
||||
static wordList constraintTypes();
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,35 +40,35 @@ addNamedToRunTimeSelectionTable
|
||||
(
|
||||
pointPatchScalarField,
|
||||
slipPointPatchScalarField,
|
||||
pointPatch,
|
||||
patch,
|
||||
overset
|
||||
);
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
pointPatchVectorField,
|
||||
slipPointPatchVectorField,
|
||||
pointPatch,
|
||||
patch,
|
||||
overset
|
||||
);
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
pointPatchSphericalTensorField,
|
||||
slipPointPatchSphericalTensorField,
|
||||
pointPatch,
|
||||
patch,
|
||||
overset
|
||||
);
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
pointPatchSymmTensorField,
|
||||
slipPointPatchSymmTensorField,
|
||||
pointPatch,
|
||||
patch,
|
||||
overset
|
||||
);
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
pointPatchTensorField,
|
||||
slipPointPatchTensorField,
|
||||
pointPatch,
|
||||
patch,
|
||||
overset
|
||||
);
|
||||
|
||||
|
@ -41,7 +41,7 @@ cellZoneID
|
||||
fieldName,
|
||||
mesh,
|
||||
dimless,
|
||||
zeroGradientFvPatchField<scalar>::typeName
|
||||
fvPatchScalarField::zeroGradientType()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -91,7 +91,7 @@ relVelocity
|
||||
"relVelocity",
|
||||
mesh(),
|
||||
dimensionedVector(dimVelocity, Zero),
|
||||
"zeroGradient"
|
||||
fvPatchVectorField::zeroGradientType()
|
||||
);
|
||||
auto& relVel = trelVel.ref();
|
||||
auto& relVelField = relVel.primitiveFieldRef();
|
||||
|
Loading…
Reference in New Issue
Block a user