STYLE: use Internal typedef within GeometricBoundaryField

- aligns with GeometricField usage etc
This commit is contained in:
Mark Olesen
2024-01-02 17:57:26 +01:00
parent f625a9a0dd
commit a4cbb33373
2 changed files with 58 additions and 57 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017,2022 OpenFOAM Foundation Copyright (C) 2011-2017,2022 OpenFOAM Foundation
Copyright (C) 2016-2023 OpenCFD Ltd. Copyright (C) 2016-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -189,7 +189,7 @@ bool Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::checkConsistency
template<class Type, template<class> class PatchField, class GeoMesh> template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
( (
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const dictionary& dict const dictionary& dict
) )
{ {
@ -210,7 +210,9 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
for (const entry& dEntry : dict) for (const entry& dEntry : dict)
{ {
if (dEntry.isDict() && dEntry.keyword().isLiteral()) const auto* subdict = dEntry.dictPtr();
if (subdict && dEntry.keyword().isLiteral())
{ {
const label patchi = bmesh_.findPatchID(dEntry.keyword()); const label patchi = bmesh_.findPatchID(dEntry.keyword());
@ -222,11 +224,11 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
PatchField<Type>::New PatchField<Type>::New
( (
bmesh_[patchi], bmesh_[patchi],
field, iField,
dEntry.dict() *subdict
) )
); );
nUnset--; --nUnset;
} }
} }
} }
@ -245,8 +247,9 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
for (auto iter = dict.crbegin(); iter != dict.crend(); ++iter) for (auto iter = dict.crbegin(); iter != dict.crend(); ++iter)
{ {
const entry& dEntry = *iter; const entry& dEntry = *iter;
const auto* subdict = dEntry.dictPtr();
if (dEntry.isDict() && dEntry.keyword().isLiteral()) if (subdict && dEntry.keyword().isLiteral())
{ {
const labelList patchIds = const labelList patchIds =
bmesh_.indices(dEntry.keyword(), true); // use patchGroups bmesh_.indices(dEntry.keyword(), true); // use patchGroups
@ -261,8 +264,8 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
PatchField<Type>::New PatchField<Type>::New
( (
bmesh_[patchi], bmesh_[patchi],
field, iField,
dEntry.dict() *subdict
) )
); );
} }
@ -285,15 +288,15 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
( (
emptyPolyPatch::typeName, emptyPolyPatch::typeName,
bmesh_[patchi], bmesh_[patchi],
field iField
) )
); );
} }
else else
{ {
bool found = dict.found(bmesh_[patchi].name()); const auto* subdict = dict.findDict(bmesh_[patchi].name());
if (found) if (subdict)
{ {
this->set this->set
( (
@ -301,8 +304,8 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
PatchField<Type>::New PatchField<Type>::New
( (
bmesh_[patchi], bmesh_[patchi],
field, iField,
dict.subDict(bmesh_[patchi].name()) *subdict
) )
); );
} }
@ -353,7 +356,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
( (
const BoundaryMesh& bmesh, const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const word& patchFieldType const word& patchFieldType
) )
: :
@ -374,7 +377,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
( (
patchFieldType, patchFieldType,
bmesh_[patchi], bmesh_[patchi],
field iField
) )
); );
} }
@ -385,7 +388,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
( (
const BoundaryMesh& bmesh, const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const wordList& patchFieldTypes, const wordList& patchFieldTypes,
const wordList& constraintTypes const wordList& constraintTypes
) )
@ -424,7 +427,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
patchFieldTypes[patchi], patchFieldTypes[patchi],
constraintTypes[patchi], constraintTypes[patchi],
bmesh_[patchi], bmesh_[patchi],
field iField
) )
); );
} }
@ -440,7 +443,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
( (
patchFieldTypes[patchi], patchFieldTypes[patchi],
bmesh_[patchi], bmesh_[patchi],
field iField
) )
); );
} }
@ -452,7 +455,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
( (
const BoundaryMesh& bmesh, const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const PtrList<PatchField<Type>>& ptfl const PtrList<PatchField<Type>>& ptfl
) )
: :
@ -466,7 +469,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
forAll(bmesh_, patchi) forAll(bmesh_, patchi)
{ {
this->set(patchi, ptfl[patchi].clone(field)); this->set(patchi, ptfl[patchi].clone(iField));
} }
} }
@ -474,7 +477,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
template<class Type, template<class> class PatchField, class GeoMesh> template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
( (
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf
) )
: :
@ -488,7 +491,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
forAll(bmesh_, patchi) forAll(bmesh_, patchi)
{ {
this->set(patchi, btf[patchi].clone(field)); this->set(patchi, btf[patchi].clone(iField));
} }
} }
@ -496,7 +499,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
template<class Type, template<class> class PatchField, class GeoMesh> template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
( (
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf, const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf,
const labelList& patchIDs, const labelList& patchIDs,
const word& patchFieldType const word& patchFieldType
@ -519,7 +522,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
( (
patchFieldType, patchFieldType,
bmesh_[patchi], bmesh_[patchi],
field iField
) )
); );
} }
@ -528,7 +531,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
{ {
if (!this->set(patchi)) if (!this->set(patchi))
{ {
this->set(patchi, btf[patchi].clone(field)); this->set(patchi, btf[patchi].clone(iField));
} }
} }
} }
@ -554,14 +557,14 @@ template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
( (
const BoundaryMesh& bmesh, const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const dictionary& dict const dictionary& dict
) )
: :
FieldField<PatchField, Type>(bmesh.size()), FieldField<PatchField, Type>(bmesh.size()),
bmesh_(bmesh) bmesh_(bmesh)
{ {
readField(field, dict); readField(iField, dict);
} }
@ -835,18 +838,24 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::types() const
template<class Type, template<class> class PatchField, class GeoMesh> template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh> Foam::tmp<Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>:: Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::
boundaryInternalField() const boundaryInternalField() const
{ {
GeometricBoundaryField<Type, PatchField, GeoMesh> result(*this); auto tresult = tmp<GeometricBoundaryField<Type, PatchField, GeoMesh>>::New
(
DimensionedField<Type, GeoMesh>::null(),
*this
);
auto& result = tresult;
forAll(result, patchi) forAll(result, patchi)
{ {
result[patchi] == this->operator[](patchi).patchInternalField(); result[patchi] == this->operator[](patchi).patchInternalField();
} }
return result; return tresult;
} }
@ -858,13 +867,11 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::interfaces() const
forAll(list, patchi) forAll(list, patchi)
{ {
const auto* lduPtr = list.set
isA<LduInterfaceField<Type>>(this->operator[](patchi)); (
patchi,
if (lduPtr) isA<LduInterfaceField<Type>>(this->operator[](patchi))
{ );
list.set(patchi, lduPtr);
}
} }
return list; return list;
@ -880,13 +887,11 @@ scalarInterfaces() const
forAll(list, patchi) forAll(list, patchi)
{ {
const auto* lduPtr = list.set
isA<lduInterfaceField>(this->operator[](patchi)); (
patchi,
if (lduPtr) isA<lduInterfaceField>(this->operator[](patchi))
{ );
list.set(patchi, lduPtr);
}
} }
return list; return list;

View File

@ -117,7 +117,7 @@ public:
GeometricBoundaryField GeometricBoundaryField
( (
const BoundaryMesh& bmesh, const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const word& patchFieldType = PatchField<Type>::calculatedType() const word& patchFieldType = PatchField<Type>::calculatedType()
); );
@ -127,7 +127,7 @@ public:
GeometricBoundaryField GeometricBoundaryField
( (
const BoundaryMesh& bmesh, const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const wordList& wantedPatchTypes, const wordList& wantedPatchTypes,
const wordList& actualPatchTypes = wordList() const wordList& actualPatchTypes = wordList()
); );
@ -137,14 +137,14 @@ public:
GeometricBoundaryField GeometricBoundaryField
( (
const BoundaryMesh& bmesh, const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const PtrList<PatchField<Type>>& ptfl const PtrList<PatchField<Type>>& ptfl
); );
//- Construct as copy, setting the reference to the internal field //- Construct as copy, setting the reference to the internal field
GeometricBoundaryField GeometricBoundaryField
( (
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf
); );
@ -152,7 +152,7 @@ public:
//- and resetting type of field for given patch IDs //- and resetting type of field for given patch IDs
GeometricBoundaryField GeometricBoundaryField
( (
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf, const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf,
const labelList& patchIDs, const labelList& patchIDs,
const word& patchFieldName const word& patchFieldName
@ -169,7 +169,7 @@ public:
GeometricBoundaryField GeometricBoundaryField
( (
const BoundaryMesh& bmesh, const BoundaryMesh& bmesh,
const DimensionedField<Type, GeoMesh>& field, const Internal& iField,
const dictionary& dict const dictionary& dict
); );
@ -177,11 +177,7 @@ public:
// Member Functions // Member Functions
//- Read the boundary field //- Read the boundary field
void readField void readField(const Internal& iField, const dictionary& dict);
(
const DimensionedField<Type, GeoMesh>& field,
const dictionary& dict
);
//- Update the boundary condition coefficients //- Update the boundary condition coefficients
void updateCoeffs(); void updateCoeffs();
@ -203,7 +199,7 @@ public:
wordList types() const; wordList types() const;
//- Return boundary field of values neighbouring the boundary //- Return boundary field of values neighbouring the boundary
GeometricBoundaryField boundaryInternalField() const; tmp<GeometricBoundaryField> boundaryInternalField() const;
//- Return a list of pointers for each patch field with only those //- Return a list of pointers for each patch field with only those
//- pointing to interfaces being set //- pointing to interfaces being set