/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
Class
Foam::pointPatchField
Description
Abstract base class for point-mesh patch fields.
The base-field does not store values as they are part of the
"internal field". There are derived classes to store constraint values
e.g. fixedValuePointPatchField derived from the generic
valuePointPatchField which ensures the values in the "internal field"
are reset to the fixed-values by applying the stored values.
SourceFiles
pointPatchField.C
newPointPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef pointPatchField_H
#define pointPatchField_H
#include "pointPatch.H"
#include "DimensionedField.H"
#include "pointPatchFieldMapperFwd.H"
#include "fieldTypes.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
class fieldMapper;
class pointMesh;
// Forward declaration of friend functions and operators
template
class pointPatchField;
template
class calculatedPointPatchField;
template
Ostream& operator<<(Ostream&, const pointPatchField&);
/*---------------------------------------------------------------------------*\
Class pointPatchField Declaration
\*---------------------------------------------------------------------------*/
template
class pointPatchField
{
// Private Data
//- Reference to patch
const pointPatch& patch_;
//- Reference to internal field
const DimensionedField& internalField_;
//- Update index used so that updateCoeffs is called only once during
// the construction of the matrix
bool updated_;
public:
// Public Types
//- Declare primitive type
using pType = typename FieldTraits::pType;
//- Declare component type
using cmptType = typename FieldTraits::cmptType;
//- Declare component primitive type
using pCmptType = typename FieldTraits::pCmptType;
//- Declare patch type
using Patch = pointPatch;
//- Declare element type
using value_type = Type;
//- Declare calculated patch field type
using Calculated = calculatedPointPatchField;
//- Declare component Field type
using cmptField = pointPatchField;
//- 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,
(
const pointPatch& p,
const DimensionedField& iF
),
(p, iF)
);
declareRunTimeSelectionTable
(
autoPtr,
pointPatchField,
patchMapper,
(
const pointPatchField& ptf,
const pointPatch& p,
const DimensionedField& iF,
const fieldMapper& m
),
(dynamic_cast(ptf), p, iF, m)
);
declareRunTimeSelectionTable
(
autoPtr,
pointPatchField,
dictionary,
(
const pointPatch& p,
const DimensionedField& iF,
const dictionary& dict
),
(p, iF, dict)
);
// Constructors
//- Construct from patch and internal field
pointPatchField
(
const pointPatch&,
const DimensionedField&
);
//- Construct from patch, internal field and dictionary
pointPatchField
(
const pointPatch&,
const DimensionedField&,
const dictionary&
);
//- Construct by mapping given pointPatchField onto a new patch
pointPatchField
(
const pointPatchField&,
const pointPatch&,
const DimensionedField&,
const fieldMapper&
);
//- Disallow copy without setting internal field reference
pointPatchField(const pointPatchField&) = delete;
//- Disallow clone without setting internal field reference
autoPtr> clone() const
{
NotImplemented;
return autoPtr>(nullptr);
}
//- Construct as copy setting internal field reference
pointPatchField
(
const pointPatchField&,
const DimensionedField&
);
//- Construct and return a clone setting internal field reference
virtual autoPtr> clone
(
const DimensionedField& iF
) const = 0;
//- Construct and return a clone setting internal field reference
virtual autoPtr> clone
(
const pointPatch& patch,
const DimensionedField& iF
) const
{
NotImplemented;
return autoPtr>(nullptr);
}
// Selectors
//- Return a pointer to a new patchField created on freestore given
// patch and internal field
// (does not set the patch field values)
static autoPtr> New
(
const word&,
const pointPatch&,
const DimensionedField&
);
//- Return a pointer to a new patchField created on freestore given
// patch and internal field
// (does not set the patch field values).
// Allows override of constraint type
static autoPtr> New
(
const word&,
const word& actualPatchType,
const pointPatch&,
const DimensionedField&
);
//- Return a pointer to a new patchField created on freestore from
// a given pointPatchField mapped onto a new patch
static autoPtr> New
(
const pointPatchField&,
const pointPatch&,
const DimensionedField&,
const fieldMapper&
);
//- Return a pointer to a new patchField created on freestore
// from dictionary
static autoPtr> New
(
const pointPatch&,
const DimensionedField&,
const dictionary&
);
//- Destructor
virtual ~pointPatchField()
{}
// Member Functions
// Attributes
//- Return the type of the calculated form of pointPatchField
static const word& calculatedType();
//- Return size
label size() const
{
return patch().size();
}
//- Return true if this patch field fixes a value
virtual bool fixesValue() const
{
return false;
}
//- Return true if this patch field is coupled
virtual bool coupled() const
{
return false;
}
//- Return true if this overrides the underlying constraint type
bool overridesConstraint() const
{
if (type() == patch_.type())
{
return false;
}
typename pointPatchConstructorTable::iterator patchTypeCstrIter
= pointPatchConstructorTablePtr_->find(patch_.type());
return
patchTypeCstrIter
!= pointPatchConstructorTablePtr_->end();
}
// Access
//- Return local objectRegistry
const objectRegistry& db() const;
//- Return time
const Time& time() const;
//- Return patch
const pointPatch& patch() const
{
return patch_;
}
//- Return dimensioned internal field reference
const DimensionedField& internalField() const
{
return internalField_;
}
//- Return internal field reference
const Field& primitiveField() const
{
return internalField_;
}
//- Return true if the boundary condition has already been updated
bool updated() const
{
return updated_;
}
//- Return field created from appropriate internal field values
tmp> patchInternalField() const;
//- Return field created from appropriate internal field values
// given internal field reference
template
tmp> patchInternalField
(
const Field& iF
) const;
//- Return field created from selected internal field values
// given internal field reference
template
tmp> patchInternalField
(
const Field& iF,
const labelList& meshPoints
) const;
//- Given the internal field and a patch field,
// add the patch field to the internal field
template
void addToInternalField
(
Field& iF,
const Field& pF
) const;
//- Given the internal field and a patch field,
// add selected elements of the patch field to the internal field
template
void addToInternalField
(
Field& iF,
const Field& pF,
const labelList& points
) const;
//- Given the internal field and a patch field,
// set the patch field in the internal field
template
void setInternalField
(
Field& iF,
const Field& pF,
const labelList& meshPoints
) const;
//- Given the internal field and a patch field,
// set the patch field in the internal field
template
void setInternalField
(
Field& iF,
const Field& pF
) const;
// Mapping functions
//- Map the given pointPatchField onto this pointPatchField
virtual void map(const pointPatchField&, const fieldMapper&)
{}
//- Reset the pointPatchField to the given pointPatchField
// Used for mesh to mesh mapping
virtual void reset(const pointPatchField&)
{}
// Evaluation functions
//- Update the coefficients associated with the patch field
// Sets Updated to true
virtual void updateCoeffs()
{
updated_ = true;
}
//- Initialise evaluation of the patch field (do nothing)
virtual void initEvaluate
(
const Pstream::commsTypes commsType =
Pstream::commsTypes::blocking
)
{}
//- Evaluate the patch field
virtual void evaluate
(
const Pstream::commsTypes commsType =
Pstream::commsTypes::blocking
);
// I-O
//- Write
virtual void write(Ostream&) const;
// Member Operators
virtual void operator=(const UList&) {}
virtual void operator=(const Field&) {}
virtual void operator=(const pointPatchField&) {}
virtual void operator=(pointPatchField&&) {}
virtual void operator=(const Type&) {}
//- Assign to an expression
template>
void operator=(const Expression& e) {}
void operator+=(const pointPatchField&) {}
void operator+=(const Field&) {}
void operator+=(const Type&) {}
//- Assign-add to an expression
template>
void operator+=(const Expression& e) {}
void operator-=(const pointPatchField&) {}
void operator-=(const Field&) {}
void operator-=(const Type&) {}
//- Assign-subtract to an expression
template>
void operator-=(const Expression& e) {}
void operator*=(const pointPatchField&) {}
void operator*=(const Field&) {}
void operator*=(const scalar) {}
//- Assign-multiply to an expression
template>
void operator*=(const Expression& e) {}
void operator/=(const pointPatchField&) {}
void operator/=(const Field&) {}
void operator/=(const scalar) {}
//- Assign-divide to an expression
template>
void operator/=(const Expression& e) {}
// Force an assignment irrespective of form of patch. These do nothing
// unless the patch actually has boundary values.
virtual void operator==(const pointPatchField&) {}
virtual void operator==(const Field&) {}
virtual void operator==(const Type&) {}
//- Assign to an expression
template>
void operator==(const Expression& e) {}
// Ostream operator
friend Ostream& operator<<
(
Ostream&,
const pointPatchField&
);
};
// This function is added as a hack to enable simple backward compatibility
// with versions using referenceLevel in GeometicField
template
const pointPatchField& operator+
(
const pointPatchField& ppf,
const Type&
)
{
return ppf;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pointPatchFieldExpression.H"
#ifdef NoRepository
#include "pointPatchField.C"
#include "calculatedPointPatchField.H"
#endif
#define makePointPatchField(pointPatchTypeField) \
defineNamedTemplateTypeNameAndDebug(pointPatchTypeField, 0); \
template<> \
int pointPatchTypeField::disallowGenericPointPatchField \
( \
debug::debugSwitch("disallowGenericPointPatchField", 0) \
); \
defineTemplateRunTimeSelectionTable(pointPatchTypeField, pointPatch); \
defineTemplateRunTimeSelectionTable(pointPatchTypeField, patchMapper); \
defineTemplateRunTimeSelectionTable(pointPatchTypeField, dictionary);
#define addToPointPatchFieldRunTimeSelection(PatchTypeField,typePatchTypeField)\
addToRunTimeSelectionTable \
( \
PatchTypeField, \
typePatchTypeField, \
patchMapper \
); \
addToRunTimeSelectionTable \
( \
PatchTypeField, \
typePatchTypeField, \
dictionary \
);
#define addToNullConstructablePointPatchFieldRunTimeSelection( \
PatchTypeField, typePatchTypeField) \
\
addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
\
addToRunTimeSelectionTable \
( \
PatchTypeField, \
typePatchTypeField, \
pointPatch \
);
// For non-templated patch fields
#define makePointPatchTypeField(PatchTypeField, typePatchTypeField) \
defineTypeNameAndDebug(typePatchTypeField, 0); \
addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
// For non-templated patch fields
#define makeNullConstructablePointPatchTypeField( \
PatchTypeField, typePatchTypeField) \
\
defineTypeNameAndDebug(typePatchTypeField, 0); \
addToNullConstructablePointPatchFieldRunTimeSelection \
( \
PatchTypeField, \
typePatchTypeField \
)
// For templated patch fields
#define makeTemplatePointPatchTypeField(fieldType, type) \
defineNamedTemplateTypeNameAndDebug \
( \
CAT4(type, PointPatch, CAPITALIZE(fieldType), Field), \
0 \
); \
addToPointPatchFieldRunTimeSelection \
( \
CAT3(pointPatch, CAPITALIZE(fieldType), Field), \
CAT4(type, PointPatch, CAPITALIZE(fieldType), Field) \
)
// For templated patch fields
#define makeNullConstructableTemplatePointPatchTypeField(fieldType, type) \
defineNamedTemplateTypeNameAndDebug \
( \
CAT4(type, PointPatch, CAPITALIZE(fieldType), Field), \
0 \
); \
addToNullConstructablePointPatchFieldRunTimeSelection \
( \
CAT3(pointPatch, CAPITALIZE(fieldType), Field), \
CAT4(type, PointPatch, CAPITALIZE(fieldType), Field) \
)
#define makePointPatchFields(type) \
FOR_ALL_FIELD_TYPES(makeTemplatePointPatchTypeField, type)
#define makeNullConstructablePointPatchFields(type) \
FOR_ALL_FIELD_TYPES(makeNullConstructableTemplatePointPatchTypeField, type)
#define makePointPatchFieldTypeName(fieldType, type) \
defineNamedTemplateTypeNameAndDebug \
( \
CAT4(type, PointPatch, CAPITALIZE(fieldType), Field), \
0 \
);
#define makePointPatchFieldTypeNames(type) \
FOR_ALL_FIELD_TYPES(makePointPatchFieldTypeName, type)
#define makePointPatchFieldTypedef(fieldType, type) \
typedef type##PointPatchField \
CAT4(type, PointPatch, CAPITALIZE(fieldType), Field);
#define makePointPatchFieldTypedefs(type) \
FOR_ALL_FIELD_TYPES(makePointPatchFieldTypedef, type)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //