/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 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::fvPatchField Description Abstract base class with a fat-interface to all derived classes covering all possible ways in which they might be used. The first level of derivation is to basic patchFields which cover zero-gradient, fixed-gradient, fixed-value and mixed conditions. The next level of derivation covers all the specialised types with specific evaluation proceedures, particularly with respect to specific fields. SourceFiles fvPatchField.C fvPatchFieldNew.C \*---------------------------------------------------------------------------*/ #ifndef fvPatchField_H #define fvPatchField_H #include "fvPatch.H" #include "DimensionedField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { // Forward declaration of classes class objectRegistry; class dictionary; class fvPatchFieldMapper; class volMesh; // Forward declaration of friend functions and operators template class fvPatchField; template class calculatedFvPatchField; template class fvMatrix; template Ostream& operator<<(Ostream&, const fvPatchField&); /*---------------------------------------------------------------------------*\ Class fvPatchField Declaration \*---------------------------------------------------------------------------*/ template class fvPatchField : public Field { // Private data //- Reference to patch const fvPatch& 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_; //- Update index used so that manipulateMatrix is called only once // during the construction of the matrix bool manipulatedMatrix_; //- 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: typedef fvPatch Patch; typedef calculatedFvPatchField Calculated; //- Runtime type information TypeName("fvPatchField"); //- Debug switch to disallow the use of genericFvPatchField static int disallowGenericFvPatchField; // Declare run-time constructor selection tables declareRunTimeSelectionTable ( tmp, fvPatchField, patch, ( const fvPatch& p, const DimensionedField& iF ), (p, iF) ); declareRunTimeSelectionTable ( tmp, fvPatchField, patchMapper, ( const fvPatchField& ptf, const fvPatch& p, const DimensionedField& iF, const fvPatchFieldMapper& m ), (dynamic_cast(ptf), p, iF, m) ); declareRunTimeSelectionTable ( tmp, fvPatchField, dictionary, ( const fvPatch& p, const DimensionedField& iF, const dictionary& dict ), (p, iF, dict) ); // Constructors //- Construct from patch and internal field fvPatchField ( const fvPatch&, const DimensionedField& ); //- Construct from patch, internal field and value fvPatchField ( const fvPatch&, const DimensionedField&, const Type& value ); //- Construct from patch and internal field and patch type fvPatchField ( const fvPatch&, const DimensionedField&, const word& patchType ); //- Construct from patch and internal field and patch field fvPatchField ( const fvPatch&, const DimensionedField&, const Field& ); //- Construct from patch, internal field and dictionary fvPatchField ( const fvPatch&, const DimensionedField&, const dictionary&, const bool valueRequired=true ); //- Construct by mapping the given fvPatchField onto a new patch fvPatchField ( const fvPatchField&, const fvPatch&, const DimensionedField&, const fvPatchFieldMapper& ); //- Construct as copy fvPatchField(const fvPatchField&); //- Construct and return a clone virtual tmp> clone() const { return tmp>(new fvPatchField(*this)); } //- Construct as copy setting internal field reference fvPatchField ( const fvPatchField&, const DimensionedField& ); //- Construct and return a clone setting internal field reference virtual tmp> clone ( const DimensionedField& iF ) const { return tmp>(new fvPatchField(*this, iF)); } // Selectors //- Return a pointer to a new patchField created on freestore given // patch and internal field // (does not set the patch field values) static tmp> New ( const word&, const fvPatch&, 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 tmp> New ( const word&, const word& actualPatchType, const fvPatch&, const DimensionedField& ); //- Return a pointer to a new patchField created on freestore from // a given fvPatchField mapped onto a new patch static tmp> New ( const fvPatchField&, const fvPatch&, const DimensionedField&, const fvPatchFieldMapper& ); //- Return a pointer to a new patchField created on freestore // from dictionary static tmp> New ( const fvPatch&, const DimensionedField&, const dictionary& ); //- Return a pointer to a new calculatedFvPatchField created on // freestore without setting patchField values static tmp> NewCalculatedType ( const fvPatch& ); //- Return a pointer to a new calculatedFvPatchField created on // freestore without setting patchField values template static tmp> NewCalculatedType ( const fvPatchField& ); //- Destructor virtual ~fvPatchField() {} // Member functions // Attributes //- Return the type of the calculated for of fvPatchField static const word& calculatedType(); //- Return 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 { return false; } //- Return 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 virtual bool coupled() const { return false; } // Access //- Return local objectRegistry const objectRegistry& db() const; //- Return patch const fvPatch& 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_; } //- 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 //- Map (and resize as needed) from self given a mapping object virtual void autoMap ( const fvPatchFieldMapper& ); //- Reverse map the given fvPatchField onto this fvPatchField virtual void rmap ( const fvPatchField&, const labelList& ); // Evaluation functions //- Return patch-normal gradient virtual tmp> snGrad() const; //- Return patch-normal gradient for coupled-patches // using the deltaCoeffs provided virtual tmp> snGrad ( const scalarField& deltaCoeffs ) const { NotImplemented; return *this; } //- Update the coefficients associated with the patch field // Sets Updated to true virtual void updateCoeffs(); //- Update the coefficients associated with the patch field // with a weight field (0..1). This weight field is ususally // provided as the amount of geometric overlap for 'duplicate' // patches. Sets Updated to true virtual void updateWeightedCoeffs(const scalarField& weights); //- Return internal field next to patch as patch field virtual tmp> patchInternalField() const; //- Return internal field next to patch as patch field virtual void patchInternalField(Field&) const; //- Return patchField on the opposite patch of a coupled patch virtual tmp> patchNeighbourField() const { NotImplemented; return *this; } //- Initialise the evaluation of the patch field virtual void initEvaluate ( const Pstream::commsTypes commsType=Pstream::blocking ) {} //- Evaluate the patch field, sets Updated to false virtual void evaluate ( const Pstream::commsTypes commsType=Pstream::blocking ); //- Return the matrix diagonal coefficients corresponding to the // evaluation of the value of this patchField with given weights virtual tmp> valueInternalCoeffs ( const tmp>& ) const { NotImplemented; return *this; } //- Return the matrix source coefficients corresponding to the // evaluation of the value of this patchField with given weights virtual tmp> valueBoundaryCoeffs ( const tmp>& ) const { NotImplemented; return *this; } //- Return the matrix diagonal coefficients corresponding to the // evaluation of the gradient of this patchField virtual tmp> gradientInternalCoeffs() const { NotImplemented; return *this; } //- Return the matrix diagonal coefficients corresponding to the // evaluation of the gradient of this coupled patchField // using the deltaCoeffs provided virtual tmp> gradientInternalCoeffs ( const scalarField& deltaCoeffs ) const { NotImplemented; return *this; } //- Return the matrix source coefficients corresponding to the // evaluation of the gradient of this patchField virtual tmp> gradientBoundaryCoeffs() const { NotImplemented; return *this; } //- Return the matrix source coefficients corresponding to the // evaluation of the gradient of this coupled patchField // using the deltaCoeffs provided virtual tmp> gradientBoundaryCoeffs ( const scalarField& deltaCoeffs ) const { NotImplemented; return *this; } //- Manipulate matrix virtual void manipulateMatrix(fvMatrix& matrix); //- Manipulate matrix with given weights virtual void manipulateMatrix ( fvMatrix& matrix, const scalarField& weights ); // I-O //- Write virtual void write(Ostream&) const; //- Helper function to write the keyword and entry only if the // values are not equal. The value is then output as value2 template void writeEntryIfDifferent ( Ostream& os, const word& entryName, const EntryType& value1, const EntryType& value2 ) const; // Check //- Check fvPatchField against given fvPatchField void check(const fvPatchField&) const; // Member operators virtual void operator=(const UList&); virtual void operator=(const fvPatchField&); virtual void operator+=(const fvPatchField&); virtual void operator-=(const fvPatchField&); virtual void operator*=(const fvPatchField&); virtual void operator/=(const fvPatchField&); virtual void operator+=(const Field&); virtual void operator-=(const Field&); virtual void operator*=(const Field&); virtual void operator/=(const Field&); virtual void operator=(const Type&); virtual void operator+=(const Type&); virtual void operator-=(const Type&); virtual void operator*=(const scalar); virtual void operator/=(const scalar); // Force an assignment irrespective of form of patch virtual void operator==(const fvPatchField&); virtual void operator==(const Field&); virtual void operator==(const Type&); // Ostream operator friend Ostream& operator<< (Ostream&, const fvPatchField&); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository #include "fvPatchField.C" #include "calculatedFvPatchField.H" #endif #define makeFvPatchField(fvPatchTypeField) \ \ defineNamedTemplateTypeNameAndDebug(fvPatchTypeField, 0); \ template<> \ int fvPatchTypeField::disallowGenericFvPatchField \ ( \ debug::debugSwitch("disallowGenericFvPatchField", 0) \ ); \ defineTemplateRunTimeSelectionTable(fvPatchTypeField, patch); \ defineTemplateRunTimeSelectionTable(fvPatchTypeField, patchMapper); \ defineTemplateRunTimeSelectionTable(fvPatchTypeField, dictionary); #define addToPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \ addToRunTimeSelectionTable \ ( \ PatchTypeField, \ typePatchTypeField, \ patch \ ); \ addToRunTimeSelectionTable \ ( \ PatchTypeField, \ typePatchTypeField, \ patchMapper \ ); \ addToRunTimeSelectionTable \ ( \ PatchTypeField, \ typePatchTypeField, \ dictionary \ ); // use with caution #define addRemovableToPatchFieldRunTimeSelection\ (PatchTypeField, typePatchTypeField) \ \ addRemovableToRunTimeSelectionTable \ ( \ PatchTypeField, \ typePatchTypeField, \ patch \ ); \ addRemovableToRunTimeSelectionTable \ ( \ PatchTypeField, \ typePatchTypeField, \ patchMapper \ ); \ addRemovableToRunTimeSelectionTable \ ( \ PatchTypeField, \ typePatchTypeField, \ dictionary \ ); // for non-templated patch fields #define makePatchTypeField(PatchTypeField, typePatchTypeField) \ defineTypeNameAndDebug(typePatchTypeField, 0); \ addToPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) // for non-templated patch fields - use with caution #define makeRemovablePatchTypeField(PatchTypeField, typePatchTypeField) \ defineTypeNameAndDebug(typePatchTypeField, 0); \ addRemovableToPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) // for templated patch fields #define makeTemplatePatchTypeField(PatchTypeField, typePatchTypeField) \ defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \ addToPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) #define makePatchFields(type) \ makeTemplatePatchTypeField \ ( \ fvPatchScalarField, \ type##FvPatchScalarField \ ); \ makeTemplatePatchTypeField \ ( \ fvPatchVectorField, \ type##FvPatchVectorField \ ); \ makeTemplatePatchTypeField \ ( \ fvPatchSphericalTensorField, \ type##FvPatchSphericalTensorField \ ); \ makeTemplatePatchTypeField \ ( \ fvPatchSymmTensorField, \ type##FvPatchSymmTensorField \ ); \ makeTemplatePatchTypeField \ ( \ fvPatchTensorField, \ type##FvPatchTensorField \ ); #define makePatchFieldsTypeName(type) \ defineNamedTemplateTypeNameAndDebug(type##FvPatchScalarField, 0); \ defineNamedTemplateTypeNameAndDebug(type##FvPatchVectorField, 0); \ defineNamedTemplateTypeNameAndDebug(type##FvPatchSphericalTensorField, 0); \ defineNamedTemplateTypeNameAndDebug(type##FvPatchSymmTensorField, 0); \ defineNamedTemplateTypeNameAndDebug(type##FvPatchTensorField, 0) #define makePatchTypeFieldTypedefs(type) \ typedef type##FvPatchField type##FvPatchScalarField; \ typedef type##FvPatchField type##FvPatchVectorField; \ typedef type##FvPatchField \ type##FvPatchSphericalTensorField; \ typedef type##FvPatchField type##FvPatchSymmTensorField; \ typedef type##FvPatchField type##FvPatchTensorField; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* //