patchFields: Consistent patchType handling across field types

The patchType override logic has been simplified and made consistent
between fv, fvs and point patch fields. The "constraintType" attribute
has been removed from point fields as it was not being used.
This commit is contained in:
Will Bainbridge
2021-07-02 08:38:09 +01:00
parent 261d5ccd6d
commit 2fe27ab56e
23 changed files with 122 additions and 234 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -115,15 +115,6 @@ public:
// Member Functions
// Constraint handling
//- Return the constraint type this pointPatchField implements
virtual const word& constraintType() const
{
return cyclicPointPatch::typeName;
}
// Cyclic coupled interface functions
//- Return transformation between the coupled patches

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -107,17 +107,6 @@ public:
)
);
}
// Member Functions
//- Constraint handling
//- Return the constraint type this pointPatchField implements
virtual const word& constraintType() const
{
return type();
}
};

View File

@ -108,15 +108,6 @@ public:
)
);
}
// Member Functions
//- Return the constraint type this pointPatchField implements
virtual const word& constraintType() const
{
return internalPointPatch::typeName;
}
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -135,15 +135,6 @@ public:
}
// Constraint handling
//- Return the constraint type this pointPatchField implements
virtual const word& constraintType() const
{
return type();
}
// Evaluation functions
//- Evaluate the patch field

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -107,16 +107,6 @@ public:
)
);
}
// Member Functions
//- Return the constraint type this pointPatchField implements
virtual const word& constraintType() const
{
return symmetryPointPatch::typeName;
}
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -116,12 +116,6 @@ public:
// Member Functions
//- Return the constraint type this pointPatchField implements
virtual const word& constraintType() const
{
return symmetryPlanePointPatch::typeName;
}
//- Update the patch field
virtual void evaluate
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -110,12 +110,6 @@ public:
// Member Functions
//- Return the constraint type this pointPatchField implements
virtual const word& constraintType() const
{
return type();
}
//- Update the patch field
virtual void evaluate
(

View File

@ -283,16 +283,10 @@ public:
return false;
}
//- Return the constraint type this pointPatchField implements.
virtual const word& constraintType() const
{
return word::null;
}
//- Return true if this overrides the underlying constraint type
bool overridesConstraint() const
{
if (constraintType() == patch_.constraintType())
if (type() == patch_.type())
{
return false;
}

View File

@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
template<class Type>
Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
@ -36,7 +36,11 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
{
if (debug)
{
InfoInFunction << "Constructing pointPatchField<Type>" << endl;
InfoInFunction
<< "patchFieldType = " << patchFieldType
<< ", actualPatchType = " << actualPatchType
<< ", patchType = " << p.type()
<< endl;
}
typename pointPatchConstructorTable::iterator cstrIter =
@ -45,41 +49,35 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
if (cstrIter == pointPatchConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown patchFieldType type "
<< "Unknown patchField type "
<< patchFieldType << nl << nl
<< "Valid patchField types are :" << endl
<< pointPatchConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
autoPtr<pointPatchField<Type>> pfPtr(cstrIter()(p, iF));
if
(
actualPatchType == word::null
|| actualPatchType != p.type()
)
{
if (pfPtr().constraintType() != p.constraintType())
typename pointPatchConstructorTable::iterator patchTypeCstrIter =
pointPatchConstructorTablePtr_->find(p.type());
if (patchTypeCstrIter != pointPatchConstructorTablePtr_->end())
{
// Use default constraint type
typename pointPatchConstructorTable::iterator patchTypeCstrIter =
pointPatchConstructorTablePtr_->find(p.type());
if (patchTypeCstrIter == pointPatchConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "inconsistent patch and patchField types for \n"
<< " patch type " << p.type()
<< " and patchField type " << patchFieldType
<< exit(FatalError);
}
return patchTypeCstrIter()(p, iF);
}
else
{
return cstrIter()(p, iF);
}
}
else
{
return cstrIter()(p, iF);
}
return pfPtr;
}
@ -103,13 +101,18 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
const dictionary& dict
)
{
word patchFieldType(dict.lookup("type"));
if (debug)
{
InfoInFunction << "Constructing pointPatchField<Type>" << endl;
InfoInFunction
<< "patchFieldType = " << patchFieldType
<< ", actualPatchType = "
<< dict.lookupOrDefault<word>("patchType", word::null)
<< ", patchType = " << p.type()
<< endl;
}
word patchFieldType(dict.lookup("type"));
typename dictionaryConstructorTable::iterator cstrIter
= dictionaryConstructorTablePtr_->find(patchFieldType);
@ -133,38 +136,28 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
}
}
// Construct (but not necessarily returned)
autoPtr<pointPatchField<Type>> pfPtr(cstrIter()(p, iF, dict));
if
(
!dict.found("patchType")
|| word(dict.lookup("patchType")) != p.type()
)
{
if (pfPtr().constraintType() == p.constraintType())
{
// Compatible (constraint-wise) with the patch type
return pfPtr;
}
else
{
// Use default constraint type
typename dictionaryConstructorTable::iterator patchTypeCstrIter
= dictionaryConstructorTablePtr_->find(p.type());
typename dictionaryConstructorTable::iterator patchTypeCstrIter =
dictionaryConstructorTablePtr_->find(p.type());
if (patchTypeCstrIter == dictionaryConstructorTablePtr_->end())
{
FatalIOErrorInFunction
(
dict
) << "inconsistent patch and patchField types for \n"
<< " patch type " << p.type()
<< " and patchField type " << patchFieldType
<< exit(FatalIOError);
}
return patchTypeCstrIter()(p, iF, dict);
if
(
patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
&& patchTypeCstrIter() != cstrIter()
)
{
FatalIOErrorInFunction
(
dict
) << "inconsistent patch and patchField types for \n"
<< " patch type " << p.type()
<< " and patchField type " << patchFieldType
<< exit(FatalIOError);
}
}
@ -192,8 +185,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
if (cstrIter == patchMapperConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown patchField type "
<< ptf.type() << nl << nl
<< "Unknown patchField type " << ptf.type() << nl << nl
<< "Valid patchField types are :" << endl
<< patchMapperConstructorTablePtr_->sortedToc()
<< exit(FatalError);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -112,12 +112,6 @@ public:
// Access
//- Return the constraint type this pointPatch implements.
virtual const word& constraintType() const
{
return type();
}
//- Return the underlying cyclicPolyPatch
const cyclicPolyPatch& cyclicPatch() const
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -73,12 +73,6 @@ public:
// Member Functions
//- Return the constraint type this pointPatch implements.
virtual const word& constraintType() const
{
return type();
}
//- Accumulate the effect of constraint direction of this patch
virtual void applyConstraint
(

View File

@ -72,15 +72,6 @@ public:
:
facePointPatch(patch, bm)
{}
// Member Functions
//- Return the constraint type this pointPatch implements.
virtual const word& constraintType() const
{
return type();
}
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -127,12 +127,6 @@ public:
return procPolyPatch_.comm();
}
//- Return the constraint type this pointPatch implements.
virtual const word& constraintType() const
{
return type();
}
//- Return processor number
int myProcNo() const
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -76,12 +76,6 @@ public:
// Member Functions
//- Return the constraint type this pointPatch implements.
virtual const word& constraintType() const
{
return type();
}
//- Accumulate the effect of constraint direction of this patch
virtual void applyConstraint
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -75,12 +75,6 @@ public:
// Member Functions
//- Return the constraint type this pointPatch implements.
virtual const word& constraintType() const
{
return type();
}
//- Accumulate the effect of constraint direction of this patch
virtual void applyConstraint
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -75,12 +75,6 @@ public:
// Member Functions
//- Return the constraint type this pointPatch implements.
virtual const word& constraintType() const
{
return type();
}
//- Accumulate the effect of constraint direction of this patch
virtual void applyConstraint
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -151,12 +151,6 @@ public:
//- Return point normals
virtual const vectorField& pointNormals() const = 0;
//- Return the constraint type this pointPatch implements.
virtual const word& constraintType() const
{
return word::null;
}
//- Accumulate the effect of constraint direction of this patch
virtual void applyConstraint
(

View File

@ -38,7 +38,8 @@ Foam::tmp<Foam::fvPatchField<Type>> Foam::fvPatchField<Type>::New
{
InfoInFunction
<< "patchFieldType = " << patchFieldType
<< " : " << p.type()
<< ", actualPatchType = " << actualPatchType
<< ", patchType = " << p.type()
<< endl;
}
@ -106,6 +107,9 @@ Foam::tmp<Foam::fvPatchField<Type>> Foam::fvPatchField<Type>::New
{
InfoInFunction
<< "patchFieldType = " << patchFieldType
<< ", actualPatchType = "
<< dict.lookupOrDefault<word>("patchType", word::null)
<< ", patchType = " << p.type()
<< endl;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -161,6 +161,12 @@ template<class Type>
void Foam::fvsPatchField<Type>::write(Ostream& os) const
{
writeEntry(os, "type", type());
if (overridesConstraint())
{
writeEntry(os, "patchType", patch().type());
}
writeEntry(os, "value", *this);
}

View File

@ -282,6 +282,42 @@ public:
// Member Functions
// Attributes
//- Return the type of the calculated for of fvsPatchField
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 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 patchConstructorTable::iterator patchTypeCstrIter
= patchConstructorTablePtr_->find(patch_.type());
return
patchTypeCstrIter
!= patchConstructorTablePtr_->end();
}
// Access
//- Return local objectRegistry
@ -306,23 +342,6 @@ public:
return internalField_;
}
//- Return the type of the calculated for of fvsPatchField
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 this patch field is coupled
virtual bool coupled() const
{
return false;
}
// Mapping functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,7 +36,11 @@ Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
{
if (debug)
{
InfoInFunction << "Constructing fvsPatchField<Type>" << endl;
InfoInFunction
<< "patchFieldType = " << patchFieldType
<< ", actualPatchType = " << actualPatchType
<< ", patchType = " << p.type()
<< endl;
}
typename patchConstructorTable::iterator cstrIter =
@ -97,13 +101,18 @@ Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
const dictionary& dict
)
{
const word patchFieldType(dict.lookup("type"));
if (debug)
{
InfoInFunction << "Constructing fvsPatchField<Type>" << endl;
InfoInFunction
<< "patchFieldType = " << patchFieldType
<< ", actualPatchType = "
<< dict.lookupOrDefault<word>("patchType", word::null)
<< ", patchType = " << p.type()
<< endl;
}
const word patchFieldType(dict.lookup("type"));
typename dictionaryConstructorTable::iterator cstrIter
= dictionaryConstructorTablePtr_->find(patchFieldType);
@ -129,7 +138,7 @@ Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
if
(
!dict.found("patchType")
!dict.found("patchType")
|| word(dict.lookup("patchType")) != p.type()
)
{
@ -182,17 +191,7 @@ Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
<< exit(FatalError);
}
typename patchMapperConstructorTable::iterator
patchTypeCstrIter = patchMapperConstructorTablePtr_->find(p.type());
if (patchTypeCstrIter != patchMapperConstructorTablePtr_->end())
{
return patchTypeCstrIter()(ptf, p, iF, pfMapper);
}
else
{
return cstrIter()(ptf, p, iF, pfMapper);
}
return cstrIter()(ptf, p, iF, pfMapper);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -109,12 +109,6 @@ public:
//- Return true if this patch field is coupled
virtual bool coupled() const;
//- Return the constraint type this pointPatch implements.
virtual const word& constraintType() const
{
return type();
}
//- Return the underlying cyclicAMIPolyPatch
const cyclicAMIPolyPatch& cyclicAMIPatch() const
{

View File

@ -160,15 +160,6 @@ public:
// Member Functions
// Constraint handling
//- Return the constraint type this pointPatchField implements
virtual const word& constraintType() const
{
return type();
}
// Cyclic AMI coupled interface functions
//- Return transformation between the coupled patches