ENH: use readValueEntry, readMixedEntries for simpler program control

This commit is contained in:
Mark Olesen
2023-02-15 15:49:06 +01:00
parent 42dba36832
commit b17422ef1a
111 changed files with 328 additions and 677 deletions

View File

@ -103,14 +103,7 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
<< exit(FatalIOError); << exit(FatalIOError);
} }
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchField<scalar>::operator=(patchInternalField()); fvPatchField<scalar>::operator=(patchInternalField());
} }

View File

@ -105,18 +105,15 @@ Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
<< exit(FatalIOError); << exit(FatalIOError);
} }
if (dict.found("value")) if (this->readValueEntry(dict))
{ {
fvPatchField<vector>::operator= const auto* hasRefValue = dict.findEntry("refValue", keyType::LITERAL);
( const auto* hasFrac = dict.findEntry("valueFraction", keyType::LITERAL);
vectorField("value", dict, p.size())
);
if (dict.found("refValue") && dict.found("valueFraction")) if (hasRefValue && hasFrac)
{ {
this->refValue() = vectorField("refValue", dict, p.size()); this->refValue().assign(*hasRefValue, p.size());
this->valueFraction() = this->valueFraction().assign(*hasFrac, p.size());
scalarField("valueFraction", dict, p.size());
} }
else else
{ {

View File

@ -243,14 +243,12 @@ turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField
<< exit(FatalError); << exit(FatalError);
} }
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
if (dict.found("refValue")) this->readValueEntry(dict, IOobjectOption::MUST_READ);
if (this->readMixedEntries(dict))
{ {
// Full restart // Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
} }
else else
{ {

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -47,10 +48,10 @@ Foam::fixedValuePointPatchField<Type>::fixedValuePointPatchField
const pointPatch& p, const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF, const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict, const dictionary& dict,
const bool valueRequired IOobjectOption::readOption requireValue
) )
: :
valuePointPatchField<Type>(p, iF, dict, valueRequired) valuePointPatchField<Type>(p, iF, dict, requireValue)
{} {}

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -34,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef fixedValuePointPatchField_H #ifndef Foam_fixedValuePointPatchField_H
#define fixedValuePointPatchField_H #define Foam_fixedValuePointPatchField_H
#include "valuePointPatchField.H" #include "valuePointPatchField.H"
@ -53,7 +54,6 @@ class fixedValuePointPatchField
: :
public valuePointPatchField<Type> public valuePointPatchField<Type>
{ {
public: public:
//- Runtime type information //- Runtime type information
@ -75,9 +75,25 @@ public:
const pointPatch&, const pointPatch&,
const DimensionedField<Type, pointMesh>&, const DimensionedField<Type, pointMesh>&,
const dictionary&, const dictionary&,
const bool valueRequired=true IOobjectOption::readOption requireValue = IOobjectOption::MUST_READ
); );
//- Compatibility. Prefer with readOption
fixedValuePointPatchField
(
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict,
const bool valueReqd
)
:
fixedValuePointPatchField
(
p, iF, dict,
(valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ)
)
{}
//- Construct by mapping given patch field onto a new patch //- Construct by mapping given patch field onto a new patch
fixedValuePointPatchField fixedValuePointPatchField
( (

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -161,11 +161,11 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
( (
const pointPatch& p, const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF, const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict, const dictionary& dict
const bool valueRequired
) )
: :
parent_bctype(p, iF, dict, false), // The 'value' is optional (handled below)
parent_bctype(p, iF, dict, IOobjectOption::NO_READ),
codedBase(), codedBase(),
dict_ dict_
( (
@ -186,10 +186,7 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
{ {
updateLibrary(name_); updateLibrary(name_);
// Note: 'value' is used even with valueRequired = false ! This is if (!this->readValueEntry(dict))
// inconsistent with fixedValueFvPatchField behaviour.
if (!dict.found("value")) // Q: check for valueRequired?
{ {
// Evaluate to assign a value // Evaluate to assign a value
this->evaluate(Pstream::commsTypes::blocking); this->evaluate(Pstream::commsTypes::blocking);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -100,8 +100,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef codedFixedValuePointPatchField_H #ifndef Foam_codedFixedValuePointPatchField_H
#define codedFixedValuePointPatchField_H #define Foam_codedFixedValuePointPatchField_H
#include "fixedValuePointPatchFields.H" #include "fixedValuePointPatchFields.H"
#include "codedBase.H" #include "codedBase.H"
@ -187,8 +187,7 @@ public:
( (
const pointPatch&, const pointPatch&,
const DimensionedField<Type, pointMesh>&, const DimensionedField<Type, pointMesh>&,
const dictionary&, const dictionary&
const bool valueRequired=true
); );
//- Construct by mapping given codedFixedValuePointPatchField //- Construct by mapping given codedFixedValuePointPatchField

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd. Copyright (C) 2022-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.

View File

@ -53,7 +53,7 @@ Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchVectorField(p, iF, dict, false), fixedValueFvPatchVectorField(p, iF, dict, IOobjectOption::NO_READ),
tau0_(dict.getOrDefault<vector>("tau", Zero)) tau0_(dict.getOrDefault<vector>("tau", Zero))
{ {
fvPatchField<vector>::operator=(patchInternalField()); fvPatchField<vector>::operator=(patchInternalField());

View File

@ -67,14 +67,7 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
{ {
if (valueRequired) if (valueRequired)
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<scalar>::operator=
(
Field<scalar>("value", dict, p.size())
);
}
else
{ {
this->evaluate(Pstream::commsTypes::blocking); this->evaluate(Pstream::commsTypes::blocking);
} }

View File

@ -92,7 +92,7 @@ atmTurbulentHeatFluxTemperatureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedGradientFvPatchScalarField(p, iF), fixedGradientFvPatchScalarField(p, iF), // Bypass dictionary constructor
heatSource_ heatSource_
( (
heatSourceTypeNames.getOrDefault heatSourceTypeNames.getOrDefault
@ -106,13 +106,11 @@ atmTurbulentHeatFluxTemperatureFvPatchScalarField
Cp0_(Function1<scalar>::New("Cp0", dict, &db())), Cp0_(Function1<scalar>::New("Cp0", dict, &db())),
q_(PatchFunction1<scalar>::New(p.patch(), "q", dict)) q_(PatchFunction1<scalar>::New(p.patch(), "q", dict))
{ {
if (dict.found("value") && dict.found("gradient")) const auto* hasGrad = dict.findEntry("gradient", keyType::LITERAL);
if (hasGrad && this->readValueEntry(dict))
{ {
fvPatchField<scalar>::operator = gradient().assign(*hasGrad, p.size());
(
Field<scalar>("value", dict, p.size())
);
gradient() = Field<scalar>("gradient", dict, p.size());
} }
else else
{ {

View File

@ -56,17 +56,10 @@ freeSurfacePressureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict, false), fixedValueFvPatchScalarField(p, iF, dict, IOobjectOption::NO_READ),
pa_("pa", dict, p.size()) pa_("pa", dict, p.size())
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchScalarField::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchField<scalar>::operator=(pa_); fvPatchField<scalar>::operator=(pa_);
} }

View File

@ -48,7 +48,7 @@ Foam::fixedValueOutflowFaPatchField<Type>::fixedValueOutflowFaPatchField
const dictionary& dict const dictionary& dict
) )
: :
faPatchField<Type>(p, iF, Field<Type>("value", dict, p.size())) faPatchField<Type>(p, iF, dict, IOobjectOption::MUST_READ)
{} {}

View File

@ -56,11 +56,7 @@ timeVaryingUniformFixedValueFaPatchField
fixedValueFaPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ), fixedValueFaPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
timeSeries_(dict) timeSeries_(dict)
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
faPatchField<Type>::operator==(Field<Type>("value", dict, p.size()));
}
else
{ {
updateCoeffs(); updateCoeffs();
} }

View File

@ -57,10 +57,10 @@ Foam::calculatedFvPatchField<Type>::calculatedFvPatchField
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
const dictionary& dict, const dictionary& dict,
const bool valueRequired IOobjectOption::readOption requireValue
) )
: :
fvPatchField<Type>(p, iF, dict, valueRequired) fvPatchField<Type>(p, iF, dict, requireValue)
{} {}

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -49,8 +50,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef calculatedFvPatchField_H #ifndef Foam_calculatedFvPatchField_H
#define calculatedFvPatchField_H #define Foam_calculatedFvPatchField_H
#include "fvPatchField.H" #include "fvPatchField.H"
@ -90,9 +91,25 @@ public:
const fvPatch&, const fvPatch&,
const DimensionedField<Type, volMesh>&, const DimensionedField<Type, volMesh>&,
const dictionary&, const dictionary&,
const bool valueRequired=true IOobjectOption::readOption requireValue = IOobjectOption::MUST_READ
); );
//- Compatibility (prefer with readOption)
calculatedFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict,
const bool valueReqd
)
:
calculatedFvPatchField
(
p, iF, dict,
(valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ)
)
{}
//- Construct by mapping given patch field onto a new patch //- Construct by mapping given patch field onto a new patch
calculatedFvPatchField calculatedFvPatchField
( (

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -74,11 +75,11 @@ Foam::coupledFvPatchField<Type>::coupledFvPatchField
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
const dictionary& dict, const dictionary& dict,
const bool valueRequired IOobjectOption::readOption requireValue
) )
: :
LduInterfaceField<Type>(refCast<const lduInterface>(p, dict)), LduInterfaceField<Type>(refCast<const lduInterface>(p, dict)),
fvPatchField<Type>(p, iF, dict, valueRequired) fvPatchField<Type>(p, iF, dict, requireValue)
{} {}

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -38,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef coupledFvPatchField_H #ifndef Foam_coupledFvPatchField_H
#define coupledFvPatchField_H #define Foam_coupledFvPatchField_H
#include "LduInterfaceField.H" #include "LduInterfaceField.H"
#include "fvPatchField.H" #include "fvPatchField.H"
@ -60,7 +60,6 @@ class coupledFvPatchField
public LduInterfaceField<Type>, public LduInterfaceField<Type>,
public fvPatchField<Type> public fvPatchField<Type>
{ {
public: public:
//- Runtime type information //- Runtime type information
@ -90,9 +89,25 @@ public:
const fvPatch&, const fvPatch&,
const DimensionedField<Type, volMesh>&, const DimensionedField<Type, volMesh>&,
const dictionary&, const dictionary&,
const bool valueRequired=true IOobjectOption::readOption requireValue = IOobjectOption::MUST_READ
); );
//- Compatibility (prefer with readOption)
coupledFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict,
const bool valueReqd
)
:
coupledFvPatchField
(
p, iF, dict,
(valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ)
)
{}
//- Construct by mapping the given coupledFvPatchField onto a new patch //- Construct by mapping the given coupledFvPatchField onto a new patch
coupledFvPatchField coupledFvPatchField
( (

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -51,7 +52,7 @@ extrapolatedCalculatedFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
calculatedFvPatchField<Type>(p, iF, dict, false) calculatedFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ)
{ {
evaluate(); evaluate();
} }

View File

@ -49,8 +49,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef extrapolatedCalculatedFvPatchField_H #ifndef Foam_extrapolatedCalculatedFvPatchField_H
#define extrapolatedCalculatedFvPatchField_H #define Foam_extrapolatedCalculatedFvPatchField_H
#include "calculatedFvPatchField.H" #include "calculatedFvPatchField.H"
@ -68,7 +68,6 @@ class extrapolatedCalculatedFvPatchField
: :
public calculatedFvPatchField<Type> public calculatedFvPatchField<Type>
{ {
public: public:
//- Runtime type information //- Runtime type information

View File

@ -50,7 +50,7 @@ Foam::fixedGradientFvPatchField<Type>::fixedGradientFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
fvPatchField<Type>(p, iF, dict, false), fvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
gradient_("gradient", dict, p.size()) gradient_("gradient", dict, p.size())
{ {
evaluate(); evaluate();

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -58,10 +59,10 @@ Foam::fixedValueFvPatchField<Type>::fixedValueFvPatchField
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
const dictionary& dict, const dictionary& dict,
const bool valueRequired IOobjectOption::readOption requireValue
) )
: :
fvPatchField<Type>(p, iF, dict, valueRequired) fvPatchField<Type>(p, iF, dict, requireValue)
{} {}

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -53,8 +54,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef fixedValueFvPatchField_H #ifndef Foam_fixedValueFvPatchField_H
#define fixedValueFvPatchField_H #define Foam_fixedValueFvPatchField_H
#include "fvPatchField.H" #include "fvPatchField.H"
@ -72,7 +73,6 @@ class fixedValueFvPatchField
: :
public fvPatchField<Type> public fvPatchField<Type>
{ {
public: public:
//- Runtime type information //- Runtime type information
@ -102,9 +102,25 @@ public:
const fvPatch&, const fvPatch&,
const DimensionedField<Type, volMesh>&, const DimensionedField<Type, volMesh>&,
const dictionary&, const dictionary&,
const bool valueRequired=true IOobjectOption::readOption requireValue = IOobjectOption::MUST_READ
); );
//- Compatibility (prefer with readOption)
fixedValueFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict,
const bool valueReqd
)
:
fixedValueFvPatchField
(
p, iF, dict,
(valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ)
)
{}
//- Construct by mapping the given fixedValue patch field //- Construct by mapping the given fixedValue patch field
//- onto a new patch //- onto a new patch
fixedValueFvPatchField fixedValueFvPatchField

View File

@ -63,7 +63,7 @@ Foam::transformFvPatchField<Type>::transformFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
fvPatchField<Type>(p, iF, dict, false) fvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ)
{} {}

View File

@ -59,7 +59,7 @@ Foam::zeroGradientFvPatchField<Type>::zeroGradientFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
fvPatchField<Type>(p, iF, dict, false) fvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ)
{ {
fvPatchField<Type>::operator=(this->patchInternalField()); fvPatchField<Type>::operator=(this->patchInternalField());
} }

View File

@ -54,7 +54,7 @@ Foam::cyclicFvPatchField<Type>::cyclicFvPatchField
const bool valueRequired const bool valueRequired
) )
: :
coupledFvPatchField<Type>(p, iF, dict, false), // Pass no valueRequired coupledFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
cyclicPatch_(refCast<const cyclicFvPatch>(p, dict)) cyclicPatch_(refCast<const cyclicFvPatch>(p, dict))
{ {
if (!isA<cyclicFvPatch>(p)) if (!isA<cyclicFvPatch>(p))

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -54,7 +54,7 @@ Foam::cyclicACMIFvPatchField<Type>::cyclicACMIFvPatchField
) )
: :
cyclicACMILduInterfaceField(), cyclicACMILduInterfaceField(),
coupledFvPatchField<Type>(p, iF, dict, dict.found("value")), coupledFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
cyclicACMIPatch_(refCast<const cyclicACMIFvPatch>(p, dict)) cyclicACMIPatch_(refCast<const cyclicACMIFvPatch>(p, dict))
{ {
if (!isA<cyclicACMIFvPatch>(p)) if (!isA<cyclicACMIFvPatch>(p))
@ -68,7 +68,8 @@ Foam::cyclicACMIFvPatchField<Type>::cyclicACMIFvPatchField
<< exit(FatalIOError); << exit(FatalIOError);
} }
if (!dict.found("value") && this->coupled()) // Use 'value' supplied, or set to coupled field
if (!this->readValueEntry(dict) && this->coupled())
{ {
// Extra check: make sure that the non-overlap patch is before // Extra check: make sure that the non-overlap patch is before
// this so it has actually been read - evaluate will crash otherwise // this so it has actually been read - evaluate will crash otherwise

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2022 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -54,7 +54,7 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
) )
: :
cyclicAMILduInterfaceField(), cyclicAMILduInterfaceField(),
coupledFvPatchField<Type>(p, iF, dict, dict.found("value")), coupledFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p, dict)) cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p, dict))
{ {
if (!isA<cyclicAMIFvPatch>(p)) if (!isA<cyclicAMIFvPatch>(p))
@ -68,7 +68,8 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
<< exit(FatalIOError); << exit(FatalIOError);
} }
if (!dict.found("value")) // Use 'value' supplied, or set to coupled or internal field
if (!this->readValueEntry(dict))
{ {
if (this->coupled()) if (this->coupled())
{ {

View File

@ -70,7 +70,7 @@ Foam::processorFvPatchField<Type>::processorFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
coupledFvPatchField<Type>(p, iF, dict, dict.found("value")), coupledFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
procPatch_(refCast<const processorFvPatch>(p, dict)), procPatch_(refCast<const processorFvPatch>(p, dict)),
sendRequest_(-1), sendRequest_(-1),
recvRequest_(-1) recvRequest_(-1)
@ -86,8 +86,8 @@ Foam::processorFvPatchField<Type>::processorFvPatchField
<< exit(FatalIOError); << exit(FatalIOError);
} }
// If the value is not supplied set to the internal field // Use 'value' supplied, or set to internal field
if (!dict.found("value")) if (!this->readValueEntry(dict))
{ {
fvPatchField<Type>::operator=(this->patchInternalField()); fvPatchField<Type>::operator=(this->patchInternalField());
} }

View File

@ -88,7 +88,7 @@ activeBaffleVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchVectorField(p, iF, dict, false), fixedValueFvPatchVectorField(p, iF, dict, IOobjectOption::NO_READ),
pName_(dict.getOrDefault<word>("p", "p")), pName_(dict.getOrDefault<word>("p", "p")),
cyclicPatchName_(dict.lookup("cyclicPatch")), cyclicPatchName_(dict.lookup("cyclicPatch")),
cyclicPatchLabel_(p.patch().boundaryMesh().findPatchID(cyclicPatchName_)), cyclicPatchLabel_(p.patch().boundaryMesh().findPatchID(cyclicPatchName_)),

View File

@ -94,7 +94,7 @@ activePressureForceBaffleVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchVectorField(p, iF, dict, false), fixedValueFvPatchVectorField(p, iF, dict, IOobjectOption::NO_READ),
pName_(dict.getOrDefault<word>("p", "p")), pName_(dict.getOrDefault<word>("p", "p")),
cyclicPatchName_(dict.lookup("cyclicPatch")), cyclicPatchName_(dict.lookup("cyclicPatch")),
cyclicPatchLabel_(p.patch().boundaryMesh().findPatchID(cyclicPatchName_)), cyclicPatchLabel_(p.patch().boundaryMesh().findPatchID(cyclicPatchName_)),

View File

@ -88,14 +88,8 @@ Foam::advectiveFvPatchField<Type>::advectiveFvPatchField
fieldInf_(Zero), fieldInf_(Zero),
lInf_(-GREAT) lInf_(-GREAT)
{ {
if (dict.found("value")) // Use 'value' supplied, or set to internal field
{ if (!this->readValueEntry(dict))
fvPatchField<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
else
{ {
fvPatchField<Type>::operator=(this->patchInternalField()); fvPatchField<Type>::operator=(this->patchInternalField());
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -164,7 +164,8 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
parent_bctype(p, iF, dict, dict.found("value")), // Note: optional 'value' // The 'value' is optional
parent_bctype(p, iF, dict, IOobjectOption::NO_READ),
codedBase(), codedBase(),
dict_ dict_
( (
@ -185,7 +186,7 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
{ {
updateLibrary(name_); updateLibrary(name_);
if (!dict.found("value")) if (!this->readValueEntry(dict))
{ {
// Assign dummy value to get redirectPatchField not fail // Assign dummy value to get redirectPatchField not fail
this->operator==(this->patchInternalField()); this->operator==(this->patchInternalField());

View File

@ -102,8 +102,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef codedFixedValueFvPatchField_H #ifndef Foam_codedFixedValueFvPatchField_H
#define codedFixedValueFvPatchField_H #define Foam_codedFixedValueFvPatchField_H
#include "fixedValueFvPatchFields.H" #include "fixedValueFvPatchFields.H"
#include "codedBase.H" #include "codedBase.H"

View File

@ -172,20 +172,10 @@ electrostaticDepositionFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict, false), fixedValueFvPatchScalarField(p, iF, dict, IOobjectOption::NO_READ),
h_("h", dict, p.size()), h_("h", dict, p.size()),
qcum_ qcum_("qCumulative", dict, p.size(), IOobjectOption::LAZY_READ),
( Vfilm_("Vfilm", dict, p.size(), IOobjectOption::LAZY_READ),
dict.found("qCumulative")
? scalarField("qCumulative", dict, p.size())
: scalarField(p.size(), 0)
),
Vfilm_
(
dict.found("Vfilm")
? scalarField("Vfilm", dict, p.size())
: scalarField(p.size(), 0)
),
Ceffptr_ Ceffptr_
( (
PatchFunction1<scalar>::New(p.patch(), "CoulombicEfficiency", dict) PatchFunction1<scalar>::New(p.patch(), "CoulombicEfficiency", dict)
@ -216,14 +206,7 @@ electrostaticDepositionFvPatchScalarField
timei_(-1), timei_(-1),
master_(-1) master_(-1)
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchScalarField::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchScalarField::operator=(patchInternalField()); fvPatchScalarField::operator=(patchInternalField());
} }

View File

@ -87,14 +87,7 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
this->jumpTable_ = Function1<Type>::New("jumpTable", dict, &this->db()); this->jumpTable_ = Function1<Type>::New("jumpTable", dict, &this->db());
} }
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
else
{ {
this->evaluate(Pstream::commsTypes::blocking); this->evaluate(Pstream::commsTypes::blocking);
} }

View File

@ -52,23 +52,21 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedGradientFvPatchScalarField(p, iF), fixedGradientFvPatchScalarField(p, iF), // Bypass dictionary constructor
curTimeIndex_(-1) curTimeIndex_(-1)
{ {
fvPatchFieldBase::readDict(dict); fvPatchFieldBase::readDict(dict);
if (dict.found("value") && dict.found("gradient")) const auto* hasGrad = dict.findEntry("gradient", keyType::LITERAL);
if (hasGrad && this->readValueEntry(dict))
{ {
fvPatchField<scalar>::operator= gradient().assign(*hasGrad, p.size());
(
scalarField("value", dict, p.size())
);
gradient() = scalarField("gradient", dict, p.size());
} }
else else
{ {
fvPatchField<scalar>::operator=(patchInternalField()); fvPatchField<scalar>::operator=(patchInternalField());
gradient() = 0.0; gradient() = Zero;
} }
} }

View File

@ -84,25 +84,15 @@ Foam::fixedJumpFvPatchField<Type>::fixedJumpFvPatchField
{ {
if (valueRequired) if (valueRequired)
{ {
jump_ = Field<Type>("jump", dict, p.size()); jump_.assign("jump", dict, p.size(), IOobjectOption::MUST_READ);
} }
if (dict.found("jump0")) jump0_.assign("jump0", dict, p.size(), IOobjectOption::LAZY_READ);
{
jump0_ = Field<Type>("jump0", dict, p.size());
}
} }
if (valueRequired) if (valueRequired)
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
else
{ {
this->evaluate(Pstream::commsTypes::blocking); this->evaluate(Pstream::commsTypes::blocking);
} }

View File

@ -68,17 +68,10 @@ Foam::fixedJumpAMIFvPatchField<Type>::fixedJumpAMIFvPatchField
{ {
if (this->cyclicAMIPatch().owner()) if (this->cyclicAMIPatch().owner())
{ {
jump_ = Field<Type>("jump", dict, p.size()); jump_.assign("jump", dict, p.size(), IOobjectOption::MUST_READ);
} }
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
else
{ {
this->evaluate(Pstream::commsTypes::blocking); this->evaluate(Pstream::commsTypes::blocking);
} }

View File

@ -57,10 +57,7 @@ Foam::fixedMeanOutletInletFvPatchField<Type>::fixedMeanOutletInletFvPatchField
{ {
this->phiName_ = dict.getOrDefault<word>("phi", "phi"); this->phiName_ = dict.getOrDefault<word>("phi", "phi");
fvPatchField<Type>::operator= this->readValueEntry(dict, IOobjectOption::MUST_READ);
(
Field<Type>("value", dict, p.size())
);
this->refValue() = *this; this->refValue() = *this;
this->refGrad() = Zero; this->refGrad() = Zero;

View File

@ -67,7 +67,7 @@ Foam::fixedProfileFvPatchField<Type>::fixedProfileFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<Type>(p, iF, dict, false), fixedValueFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
profile_(Function1<Type>::New("profile", dict, &this->db())), profile_(Function1<Type>::New("profile", dict, &this->db())),
dir_(dict.lookup("direction")), dir_(dict.lookup("direction")),
origin_(dict.get<scalar>("origin")) origin_(dict.get<scalar>("origin"))

View File

@ -58,7 +58,7 @@ flowRateInletVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<vector>(p, iF, dict, false), fixedValueFvPatchField<vector>(p, iF, dict, IOobjectOption::NO_READ),
flowRate_(nullptr), flowRate_(nullptr),
rhoName_("rho"), rhoName_("rho"),
rhoInlet_(dict.getOrDefault<scalar>("rhoInlet", -VGREAT)), rhoInlet_(dict.getOrDefault<scalar>("rhoInlet", -VGREAT)),
@ -90,15 +90,8 @@ flowRateInletVelocityFvPatchVectorField
<< exit(FatalIOError); << exit(FatalIOError);
} }
// Value field require if mass based // Value field required if mass based
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<vector>::operator=
(
vectorField("value", dict, p.size())
);
}
else
{ {
evaluate(Pstream::commsTypes::blocking); evaluate(Pstream::commsTypes::blocking);
} }

View File

@ -56,7 +56,7 @@ flowRateOutletVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<vector>(p, iF, dict, false), fixedValueFvPatchField<vector>(p, iF, dict, IOobjectOption::NO_READ),
flowRate_(nullptr), flowRate_(nullptr),
rhoName_("rho"), rhoName_("rho"),
rhoOutlet_(dict.getOrDefault<scalar>("rhoOutlet", -VGREAT)), rhoOutlet_(dict.getOrDefault<scalar>("rhoOutlet", -VGREAT)),
@ -84,15 +84,8 @@ flowRateOutletVelocityFvPatchVectorField
<< exit(FatalIOError); << exit(FatalIOError);
} }
// Value field require if mass based // Value field required if mass based
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<vector>::operator=
(
vectorField("value", dict, p.size())
);
}
else
{ {
evaluate(Pstream::commsTypes::blocking); evaluate(Pstream::commsTypes::blocking);
} }

View File

@ -57,19 +57,15 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
this->phiName_ = dict.getOrDefault<word>("phi", "phi"); this->phiName_ = dict.getOrDefault<word>("phi", "phi");
if (dict.found("freestreamValue")) if
{
freestreamValue() =
Field<Type>("freestreamValue", dict, p.size());
if (dict.found("value"))
{
fvPatchField<Type>::operator=
( (
Field<Type>("value", dict, p.size()) freestreamValue().assign
); (
} "freestreamValue", dict, p.size(), IOobjectOption::LAZY_READ
else )
)
{
if (!this->readValueEntry(dict))
{ {
fvPatchField<Type>::operator=(freestreamValue()); fvPatchField<Type>::operator=(freestreamValue());
} }
@ -82,10 +78,7 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
// Force user to supply an initial value // Force user to supply an initial value
// - we do not know if the supplied BC has all dependencies available // - we do not know if the supplied BC has all dependencies available
fvPatchField<Type>::operator= this->readValueEntry(dict, IOobjectOption::MUST_READ);
(
Field<Type>("value", dict, p.size())
);
} }
} }

View File

@ -57,14 +57,7 @@ freestreamPressureFvPatchScalarField
{ {
freestreamValue() = scalarField("freestreamValue", dict, p.size()); freestreamValue() = scalarField("freestreamValue", dict, p.size());
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchScalarField::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchScalarField::operator=(freestreamValue()); fvPatchScalarField::operator=(freestreamValue());
} }

View File

@ -51,14 +51,7 @@ Foam::freestreamVelocityFvPatchVectorField::freestreamVelocityFvPatchVectorField
{ {
freestreamValue() = vectorField("freestreamValue", dict, p.size()); freestreamValue() = vectorField("freestreamValue", dict, p.size());
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchVectorField::operator=
(
vectorField("value", dict, p.size())
);
}
else
{ {
fvPatchVectorField::operator=(freestreamValue()); fvPatchVectorField::operator=(freestreamValue());
} }

View File

@ -89,14 +89,8 @@ inletOutletTotalTemperatureFvPatchScalarField
this->phiName_ = dict.getOrDefault<word>("phi", "phi"); this->phiName_ = dict.getOrDefault<word>("phi", "phi");
this->refValue() = Zero; this->refValue() = Zero;
if (dict.found("value"))
{ if (!this->readValueEntry(dict))
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchField<scalar>::operator=(T0_); fvPatchField<scalar>::operator=(T0_);
} }

View File

@ -61,7 +61,8 @@ Foam::mappedMixedFvPatchField<Type>::mappedMixedFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<Type>(p, iF, dict), // Reading of mixed entries handled later...
mixedFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
mappedPatchFieldBase<Type> mappedPatchFieldBase<Type>
( (
mappedFixedValueFvPatchField<Type>::mapper(p, iF), mappedFixedValueFvPatchField<Type>::mapper(p, iF),
@ -70,17 +71,11 @@ Foam::mappedMixedFvPatchField<Type>::mappedMixedFvPatchField
), ),
weightFieldName_(dict.getOrDefault<word>("weightField", word::null)) weightFieldName_(dict.getOrDefault<word>("weightField", word::null))
{ {
mixedFvPatchField<Type>::operator= this->readValueEntry(dict, IOobjectOption::MUST_READ);
(
Field<Type>("value", dict, p.size())
);
if (dict.found("refValue")) if (this->readMixedEntries(dict))
{ {
// Full restart // Full restart
this->refValue() = Field<Type>("refValue", dict, p.size());
this->refGrad() = Field<Type>("refGradient", dict, p.size());
this->valueFraction() = scalarField("valueFraction", dict, p.size());
} }
else else
{ {

View File

@ -42,8 +42,8 @@ matchedFlowRateOutletVelocityFvPatchVectorField
: :
fixedValueFvPatchField<vector>(p, iF), fixedValueFvPatchField<vector>(p, iF),
inletPatchName_(), inletPatchName_(),
volumetric_(false), rhoName_("rho"),
rhoName_("rho") volumetric_(false)
{} {}
@ -55,8 +55,9 @@ matchedFlowRateOutletVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<vector>(p, iF, dict, false), fixedValueFvPatchField<vector>(p, iF, dict, IOobjectOption::NO_READ),
inletPatchName_(dict.get<word>("inletPatch")), inletPatchName_(dict.get<word>("inletPatch")),
rhoName_(),
volumetric_(dict.getOrDefault("volumetric", true)) volumetric_(dict.getOrDefault("volumetric", true))
{ {
if (volumetric_) if (volumetric_)
@ -68,15 +69,8 @@ matchedFlowRateOutletVelocityFvPatchVectorField
rhoName_ = dict.getOrDefault<word>("rho", "rho"); rhoName_ = dict.getOrDefault<word>("rho", "rho");
} }
// Value field require if mass based // Value field required if mass based
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<vector>::operator=
(
vectorField("value", dict, p.size())
);
}
else
{ {
evaluate(Pstream::commsTypes::blocking); evaluate(Pstream::commsTypes::blocking);
} }
@ -94,8 +88,8 @@ matchedFlowRateOutletVelocityFvPatchVectorField
: :
fixedValueFvPatchField<vector>(ptf, p, iF, mapper), fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
inletPatchName_(ptf.inletPatchName_), inletPatchName_(ptf.inletPatchName_),
volumetric_(ptf.volumetric_), rhoName_(ptf.rhoName_),
rhoName_(ptf.rhoName_) volumetric_(ptf.volumetric_)
{} {}
@ -107,8 +101,8 @@ matchedFlowRateOutletVelocityFvPatchVectorField
: :
fixedValueFvPatchField<vector>(ptf), fixedValueFvPatchField<vector>(ptf),
inletPatchName_(ptf.inletPatchName_), inletPatchName_(ptf.inletPatchName_),
volumetric_(ptf.volumetric_), rhoName_(ptf.rhoName_),
rhoName_(ptf.rhoName_) volumetric_(ptf.volumetric_)
{} {}
@ -121,8 +115,8 @@ matchedFlowRateOutletVelocityFvPatchVectorField
: :
fixedValueFvPatchField<vector>(ptf, iF), fixedValueFvPatchField<vector>(ptf, iF),
inletPatchName_(ptf.inletPatchName_), inletPatchName_(ptf.inletPatchName_),
volumetric_(ptf.volumetric_), rhoName_(ptf.rhoName_),
rhoName_(ptf.rhoName_) volumetric_(ptf.volumetric_)
{} {}

View File

@ -82,12 +82,12 @@ class matchedFlowRateOutletVelocityFvPatchVectorField
//- Inlet patch name from which the corresponding flow rate is obtained //- Inlet patch name from which the corresponding flow rate is obtained
word inletPatchName_; word inletPatchName_;
//- Is volumetric?
bool volumetric_;
//- Name of the density field used to normalize the mass flux //- Name of the density field used to normalize the mass flux
word rhoName_; word rhoName_;
//- Is volumetric?
bool volumetric_;
// Private member functions // Private member functions

View File

@ -168,14 +168,7 @@ outletMappedUniformInletFvPatchField
} }
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
else
{ {
fvPatchField<Type>::operator=(this->patchInternalField()); fvPatchField<Type>::operator=(this->patchInternalField());
} }

View File

@ -84,14 +84,7 @@ Foam::outletPhaseMeanVelocityFvPatchVectorField
refGrad() = Zero; refGrad() = Zero;
valueFraction() = 0.0; valueFraction() = 0.0;
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchVectorField::operator=
(
vectorField("value", dict, p.size())
);
}
else
{ {
fvPatchVectorField::operator=(patchInternalField()); fvPatchVectorField::operator=(patchInternalField());
} }

View File

@ -77,10 +77,7 @@ Foam::partialSlipFvPatchField<Type>::partialSlipFvPatchField
fvPatchFieldBase::readDict(dict); fvPatchFieldBase::readDict(dict);
// Backwards compatibility - leave refValue as zero unless specified // Backwards compatibility - leave refValue as zero unless specified
if (dict.found("refValue")) refValue_.assign("refValue", dict, p.size(), IOobjectOption::LAZY_READ);
{
refValue_ = Field<Type>("refValue", dict, p.size());
}
evaluate(); evaluate();
} }

View File

@ -72,14 +72,7 @@ phaseHydrostaticPressureFvPatchScalarField
this->refValue() = pRefValue_; this->refValue() = pRefValue_;
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchScalarField::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchScalarField::operator=(this->refValue()); fvPatchScalarField::operator=(this->refValue());
} }

View File

@ -75,14 +75,7 @@ prghPermeableAlphaTotalPressureFvPatchScalarField
refGrad() = 0.0; refGrad() = 0.0;
valueFraction() = 0.0; valueFraction() = 0.0;
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<scalar>::operator=
(
Field<scalar>("value", dict, p.size())
);
}
else
{ {
fvPatchField<scalar>::operator=(refValue()); fvPatchField<scalar>::operator=(refValue());
} }

View File

@ -55,18 +55,11 @@ prghPressureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict, false), fixedValueFvPatchScalarField(p, iF, dict, IOobjectOption::NO_READ),
rhoName_(dict.getOrDefault<word>("rho", "rho")), rhoName_(dict.getOrDefault<word>("rho", "rho")),
p_("p", dict, p.size()) p_("p", dict, p.size())
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchScalarField::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchField<scalar>::operator=(p_); fvPatchField<scalar>::operator=(p_);
} }

View File

@ -56,20 +56,13 @@ Foam::prghTotalPressureFvPatchScalarField::prghTotalPressureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict, false), fixedValueFvPatchScalarField(p, iF, dict, IOobjectOption::NO_READ),
UName_(dict.getOrDefault<word>("U", "U")), UName_(dict.getOrDefault<word>("U", "U")),
phiName_(dict.getOrDefault<word>("phi", "phi")), phiName_(dict.getOrDefault<word>("phi", "phi")),
rhoName_(dict.getOrDefault<word>("rho", "rho")), rhoName_(dict.getOrDefault<word>("rho", "rho")),
p0_("p0", dict, p.size()) p0_("p0", dict, p.size())
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchScalarField::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchField<scalar>::operator=(p0_); fvPatchField<scalar>::operator=(p0_);
} }

View File

@ -55,19 +55,12 @@ rotatingWallVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<vector>(p, iF, dict, false), fixedValueFvPatchField<vector>(p, iF, dict, IOobjectOption::NO_READ),
origin_(dict.lookup("origin")), origin_(dict.lookup("origin")),
axis_(dict.lookup("axis")), axis_(dict.lookup("axis")),
omega_(Function1<scalar>::New("omega", dict, &db())) omega_(Function1<scalar>::New("omega", dict, &db()))
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<vector>::operator=
(
vectorField("value", dict, p.size())
);
}
else
{ {
// Evaluate the wall velocity // Evaluate the wall velocity
updateCoeffs(); updateCoeffs();

View File

@ -52,7 +52,7 @@ Foam::scaledFixedValueFvPatchField<Type>::scaledFixedValueFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<Type>(p, iF, dict, false), fixedValueFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
scalePtr_(PatchFunction1<scalar>::New(p.patch(), "scale", dict)), scalePtr_(PatchFunction1<scalar>::New(p.patch(), "scale", dict)),
refValuePtr_(fvPatchField<Type>::New(p, iF, dict.subDict("refValue"))) refValuePtr_(fvPatchField<Type>::New(p, iF, dict.subDict("refValue")))
{ {

View File

@ -74,14 +74,7 @@ supersonicFreestreamFvPatchVectorField
{ {
fvPatchFieldBase::readDict(dict); fvPatchFieldBase::readDict(dict);
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<vector>::operator=
(
vectorField("value", dict, p.size())
);
}
else
{ {
fvPatchField<vector>::operator=(patchInternalField()); fvPatchField<vector>::operator=(patchInternalField());
} }

View File

@ -54,7 +54,7 @@ surfaceNormalFixedValueFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchVectorField(p, iF, dict, false), fixedValueFvPatchVectorField(p, iF, dict, IOobjectOption::NO_READ),
refValue_("refValue", dict, p.size()), refValue_("refValue", dict, p.size()),
ramp_(Function1<scalar>::NewIfPresent("ramp", dict, word::null, &db())) ramp_(Function1<scalar>::NewIfPresent("ramp", dict, word::null, &db()))
{ {

View File

@ -53,7 +53,7 @@ Foam::syringePressureFvPatchScalarField::syringePressureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict, false), fixedValueFvPatchScalarField(p, iF, dict, IOobjectOption::NO_READ),
Ap_(dict.get<scalar>("Ap")), Ap_(dict.get<scalar>("Ap")),
Sp_(dict.get<scalar>("Sp")), Sp_(dict.get<scalar>("Sp")),
VsI_(dict.get<scalar>("VsI")), VsI_(dict.get<scalar>("VsI")),

View File

@ -53,7 +53,7 @@ timeVaryingMappedFixedValueFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<Type>(p, iF, dict, false), fixedValueFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
uniformValue_ uniformValue_
( (
new PatchFunction1Types::MappedFile<Type> new PatchFunction1Types::MappedFile<Type>
@ -66,11 +66,7 @@ timeVaryingMappedFixedValueFvPatchField
) )
) )
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<Type>::operator==(Field<Type>("value", dict, p.size()));
}
else
{ {
// Note: we use evaluate() here to trigger updateCoeffs followed // Note: we use evaluate() here to trigger updateCoeffs followed
// by re-setting of fvatchfield::updated_ flag. This is // by re-setting of fvatchfield::updated_ flag. This is

View File

@ -58,7 +58,7 @@ Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict, false), fixedValueFvPatchScalarField(p, iF, dict, IOobjectOption::NO_READ),
UName_(dict.getOrDefault<word>("U", "U")), UName_(dict.getOrDefault<word>("U", "U")),
phiName_(dict.getOrDefault<word>("phi", "phi")), phiName_(dict.getOrDefault<word>("phi", "phi")),
rhoName_(dict.getOrDefault<word>("rho", "rho")), rhoName_(dict.getOrDefault<word>("rho", "rho")),
@ -66,14 +66,7 @@ Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField
gamma_(psiName_ != "none" ? dict.get<scalar>("gamma") : 1), gamma_(psiName_ != "none" ? dict.get<scalar>("gamma") : 1),
p0_("p0", dict, p.size()) p0_("p0", dict, p.size())
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchField<scalar>::operator=(p0_); fvPatchField<scalar>::operator=(p0_);
} }

View File

@ -73,21 +73,14 @@ Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict, false), fixedValueFvPatchScalarField(p, iF, dict, IOobjectOption::NO_READ),
UName_(dict.getOrDefault<word>("U", "U")), UName_(dict.getOrDefault<word>("U", "U")),
phiName_(dict.getOrDefault<word>("phi", "phi")), phiName_(dict.getOrDefault<word>("phi", "phi")),
psiName_(dict.getOrDefault<word>("psi", "thermo:psi")), psiName_(dict.getOrDefault<word>("psi", "thermo:psi")),
gamma_(dict.get<scalar>("gamma")), gamma_(dict.get<scalar>("gamma")),
T0_("T0", dict, p.size()) T0_("T0", dict, p.size())
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchField<scalar>::operator=(T0_); fvPatchField<scalar>::operator=(T0_);
} }

View File

@ -52,7 +52,7 @@ translatingWallVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<vector>(p, iF, dict, false), fixedValueFvPatchField<vector>(p, iF, dict, IOobjectOption::NO_READ),
U_(Function1<vector>::New("U", dict, &db())) U_(Function1<vector>::New("U", dict, &db()))
{ {
// Evaluate the wall velocity // Evaluate the wall velocity

View File

@ -53,21 +53,14 @@ Foam::turbulentInletFvPatchField<Type>::turbulentInletFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<Type>(p, iF, dict, false), fixedValueFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
ranGen_(label(0)), ranGen_(label(0)),
fluctuationScale_(dict.get<Type>("fluctuationScale")), fluctuationScale_(dict.get<Type>("fluctuationScale")),
referenceField_("referenceField", dict, p.size()), referenceField_("referenceField", dict, p.size()),
alpha_(dict.getOrDefault<scalar>("alpha", 0.1)), alpha_(dict.getOrDefault<scalar>("alpha", 0.1)),
curTimeIndex_(-1) curTimeIndex_(-1)
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fixedValueFvPatchField<Type>::operator==
(
Field<Type>("value", dict, p.size())
);
}
else
{ {
fixedValueFvPatchField<Type>::operator==(referenceField_); fixedValueFvPatchField<Type>::operator==(referenceField_);
} }

View File

@ -56,19 +56,12 @@ uniformDensityHydrostaticPressureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict, false), fixedValueFvPatchScalarField(p, iF, dict, IOobjectOption::NO_READ),
rho_(dict.get<scalar>("rho")), rho_(dict.get<scalar>("rho")),
pRefValue_(dict.get<scalar>("pRefValue")), pRefValue_(dict.get<scalar>("pRefValue")),
pRefPoint_(dict.lookup("pRefPoint")) pRefPoint_(dict.lookup("pRefPoint"))
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
evaluate(); evaluate();
} }

View File

@ -63,7 +63,7 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
fixedGradientFvPatchField<Type>(p, iF), fixedGradientFvPatchField<Type>(p, iF), // Bypass dictionary constructor
uniformGradient_ uniformGradient_
( (
PatchFunction1<Type>::New(p.patch(), "uniformGradient", dict) PatchFunction1<Type>::New(p.patch(), "uniformGradient", dict)

View File

@ -63,17 +63,10 @@ Foam::uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<Type>(p, iF, dict, false), fixedValueFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
uniformValue_(PatchFunction1<Type>::New(p.patch(), "uniformValue", dict)) uniformValue_(PatchFunction1<Type>::New(p.patch(), "uniformValue", dict))
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
else
{ {
this->evaluate(); this->evaluate();
} }

View File

@ -66,14 +66,7 @@ Foam::uniformInletOutletFvPatchField<Type>::uniformInletOutletFvPatchField
this->refValue() = this->refValue() =
uniformInletValue_->value(this->db().time().timeOutputValue()); uniformInletValue_->value(this->db().time().timeOutputValue());
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
else
{ {
fvPatchField<Type>::operator=(this->refValue()); fvPatchField<Type>::operator=(this->refValue());
} }

View File

@ -75,14 +75,7 @@ Foam::uniformJumpFvPatchField<Type>::uniformJumpFvPatchField
jumpTable_ = Function1<Type>::New("jumpTable", dict, &this->db()); jumpTable_ = Function1<Type>::New("jumpTable", dict, &this->db());
} }
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
else
{ {
this->evaluate(Pstream::commsTypes::blocking); this->evaluate(Pstream::commsTypes::blocking);
} }

View File

@ -72,11 +72,7 @@ Foam::uniformJumpAMIFvPatchField<Type>::uniformJumpAMIFvPatchField
jumpTable_ = Function1<Type>::New("jumpTable", dict, &this->db()); jumpTable_ = Function1<Type>::New("jumpTable", dict, &this->db());
} }
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<Type>::operator=(Field<Type>("value", dict, p.size()));
}
else
{ {
this->evaluate(Pstream::commsTypes::blocking); this->evaluate(Pstream::commsTypes::blocking);
} }

View File

@ -53,18 +53,11 @@ uniformNormalFixedValueFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchVectorField(p, iF, dict, false), fixedValueFvPatchVectorField(p, iF, dict, IOobjectOption::NO_READ),
uniformValue_(PatchFunction1<scalar>::New(p.patch(), "uniformValue", dict)), uniformValue_(PatchFunction1<scalar>::New(p.patch(), "uniformValue", dict)),
ramp_(Function1<scalar>::NewIfPresent("ramp", dict, word::null, &db())) ramp_(Function1<scalar>::NewIfPresent("ramp", dict, word::null, &db()))
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchVectorField::operator=
(
vectorField("value", dict, p.size())
);
}
else
{ {
this->evaluate(); this->evaluate();
} }

View File

@ -59,7 +59,7 @@ uniformTotalPressureFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict, false), fixedValueFvPatchScalarField(p, iF, dict, IOobjectOption::NO_READ),
UName_(dict.getOrDefault<word>("U", "U")), UName_(dict.getOrDefault<word>("U", "U")),
phiName_(dict.getOrDefault<word>("phi", "phi")), phiName_(dict.getOrDefault<word>("phi", "phi")),
rhoName_(dict.getOrDefault<word>("rho", "rho")), rhoName_(dict.getOrDefault<word>("rho", "rho")),
@ -67,14 +67,7 @@ uniformTotalPressureFvPatchScalarField
gamma_(psiName_ != "none" ? dict.get<scalar>("gamma") : 1), gamma_(psiName_ != "none" ? dict.get<scalar>("gamma") : 1),
p0_(Function1<scalar>::New("p0", dict, &db())) p0_(Function1<scalar>::New("p0", dict, &db()))
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
const scalar t = this->db().time().timeOutputValue(); const scalar t = this->db().time().timeOutputValue();
fvPatchScalarField::operator==(p0_->value(t)); fvPatchScalarField::operator==(p0_->value(t));

View File

@ -84,14 +84,7 @@ Foam::variableHeightFlowRateFvPatchScalarField
fvPatchFieldBase::readDict(dict); fvPatchFieldBase::readDict(dict);
this->refValue() = 0.0; this->refValue() = 0.0;
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchScalarField::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchScalarField::operator=(this->patchInternalField()); fvPatchScalarField::operator=(this->patchInternalField());
} }

View File

@ -122,6 +122,7 @@ protected:
manipulatedMatrix_ = state; manipulatedMatrix_ = state;
} }
public: public:
//- Debug switch to disallow the use of generic fvPatchField //- Debug switch to disallow the use of generic fvPatchField

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd. Copyright (C) 2022-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -58,7 +58,7 @@ Foam::calculatedFvsPatchField<Type>::calculatedFvsPatchField
const dictionary& dict const dictionary& dict
) )
: :
fvsPatchField<Type>(p, iF, Field<Type>("value", dict, p.size())) fvsPatchField<Type>(p, iF, dict, IOobjectOption::MUST_READ)
{} {}

View File

@ -48,7 +48,7 @@ Foam::fixedValueFvsPatchField<Type>::fixedValueFvsPatchField
const dictionary& dict const dictionary& dict
) )
: :
fvsPatchField<Type>(p, iF, Field<Type>("value", dict, p.size())) fvsPatchField<Type>(p, iF, dict, IOobjectOption::MUST_READ)
{} {}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd. Copyright (C) 2022-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.

View File

@ -149,27 +149,16 @@ externalCoupledTemperatureMixedFvPatchScalarField
Tref_ = Function1<scalar>::New("Tref", dict, &db()); Tref_ = Function1<scalar>::New("Tref", dict, &db());
} }
if (dict.found("refValue")) if (this->readMixedEntries(dict))
{ {
// Initialise same way as mixed // Initialise same way as mixed
this->refValue() = scalarField("refValue", dict, p.size());
this->refGrad() = scalarField("refGradient", dict, p.size());
this->valueFraction() = scalarField("valueFraction", dict, p.size());
evaluate(); evaluate();
} }
else else
{ {
// For convenience: initialise as fixedValue with either read value // For convenience: initialise as fixedValue with either read value
// or extrapolated value // or extrapolated value
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchField<scalar>::operator=(this->patchInternalField()); fvPatchField<scalar>::operator=(this->patchInternalField());
} }

View File

@ -101,14 +101,7 @@ timeVaryingMappedFixedValuePointPatchField
fieldTableName_ fieldTableName_
); );
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fixedValuePointPatchField<Type>::operator==
(
Field<Type>("value", dict, p.size())
);
}
else
{ {
// Note: use evaluate to do updateCoeffs followed by a reset // Note: use evaluate to do updateCoeffs followed by a reset
// of the pointPatchField::updated_ flag. This is // of the pointPatchField::updated_ flag. This is

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -73,7 +73,7 @@ uniformFixedValuePointPatchField
const dictionary& dict const dictionary& dict
) )
: :
fixedValuePointPatchField<Type>(p, iF, dict, false), fixedValuePointPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
uniformValue_ uniformValue_
( (
PatchFunction1<Type>::New PatchFunction1<Type>::New
@ -85,14 +85,7 @@ uniformFixedValuePointPatchField
) )
) )
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fixedValuePointPatchField<Type>::operator==
(
Field<Type>("value", dict, p.size())
);
}
else
{ {
this->evaluate(); this->evaluate();
} }

View File

@ -65,13 +65,8 @@ Foam::adjointOutletFluxFvPatchField<Type>::adjointOutletFluxFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<Type>(p, iF) fixedValueFvPatchField<Type>(p, iF, dict, IOobjectOption::MUST_READ)
{ {}
fvPatchField<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
template<class Type> template<class Type>

View File

@ -83,7 +83,7 @@ Foam::oversetFvPatchField<Type>::oversetFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
coupledFvPatchField<Type>(p, iF, dict, false), coupledFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
oversetPatch_(refCast<const oversetFvPatch>(p, dict)), oversetPatch_(refCast<const oversetFvPatch>(p, dict)),
setHoleCellValue_(dict.getOrDefault("setHoleCellValue", false)), setHoleCellValue_(dict.getOrDefault("setHoleCellValue", false)),
fluxCorrection_ fluxCorrection_
@ -110,14 +110,8 @@ Foam::oversetFvPatchField<Type>::oversetFvPatchField
fringeFaces_(), fringeFaces_(),
zoneId_(dict.getOrDefault<label>("zone", -1)) zoneId_(dict.getOrDefault<label>("zone", -1))
{ {
if (dict.found("value")) // Use 'value' supplied, or set to internal field
{ if (!this->readValueEntry(dict))
Field<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
else
{ {
Field<Type>::operator=(this->patchInternalField()); Field<Type>::operator=(this->patchInternalField());
} }

View File

@ -85,14 +85,7 @@ timeVaryingMassSorptionFvPatchScalarField
max_(dict.getCheck<scalar>("max", scalarMinMax::ge(0))), max_(dict.getCheck<scalar>("max", scalarMinMax::ge(0))),
kdes_(dict.getCheckOrDefault<scalar>("kdes", 0, scalarMinMax::ge(0))) kdes_(dict.getCheckOrDefault<scalar>("kdes", 0, scalarMinMax::ge(0)))
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchScalarField::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
fvPatchField<scalar>::operator=(Zero); fvPatchField<scalar>::operator=(Zero);
} }

View File

@ -102,14 +102,11 @@ velocityFilmShellFvPatchVectorField::velocityFilmShellFvPatchVectorField
curTimeIndex_(-1), curTimeIndex_(-1),
zeroWallVelocity_(dict.getOrDefault<bool>("zeroWallVelocity", true)) zeroWallVelocity_(dict.getOrDefault<bool>("zeroWallVelocity", true))
{ {
fvPatchVectorField::operator=(vectorField("value", dict, p.size())); this->readValueEntry(dict, IOobjectOption::MUST_READ);
if (dict.found("refValue")) if (this->readMixedEntries(dict))
{ {
// Full restart // Full restart
refValue() = vectorField("refValue", dict, p.size());
refGrad() = vectorField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
} }
else else
{ {

View File

@ -96,14 +96,11 @@ vibrationShellFvPatchScalarField::vibrationShellFvPatchScalarField
) )
) )
{ {
fvPatchScalarField::operator=(scalarField("value", dict, p.size())); this->readValueEntry(dict, IOobjectOption::MUST_READ);
if (dict.found("refValue")) if (this->readMixedEntries(dict))
{ {
// Full restart // Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
} }
else else
{ {

View File

@ -178,14 +178,11 @@ filmPyrolysisRadiativeCoupledMixedFvPatchScalarField
<< exit(FatalError); << exit(FatalError);
} }
fvPatchScalarField::operator=(scalarField("value", dict, p.size())); this->readValueEntry(dict, IOobjectOption::MUST_READ);
if (dict.found("refValue")) if (this->readMixedEntries(dict))
{ {
// Full restart // Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
} }
else else
{ {

View File

@ -136,8 +136,6 @@ externalWallHeatFluxTemperatureFvPatchScalarField
} }
} }
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
if (qrName_ != "none") if (qrName_ != "none")
{ {
if (dict.found("qrPrevious")) if (dict.found("qrPrevious"))
@ -150,12 +148,11 @@ externalWallHeatFluxTemperatureFvPatchScalarField
} }
} }
if (dict.found("refValue")) this->readValueEntry(dict, IOobjectOption::MUST_READ);
if (this->readMixedEntries(dict))
{ {
// Full restart // Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
} }
else else
{ {

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2019,2021 OpenCFD Ltd. Copyright (C) 2016-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -73,14 +73,15 @@ fixedIncidentRadiationFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedGradientFvPatchScalarField(p, iF), fixedGradientFvPatchScalarField(p, iF), // Bypass dictionary constructor
temperatureCoupledBase(patch(), dict), temperatureCoupledBase(patch(), dict),
qrIncident_("qrIncident", dict, p.size()) qrIncident_("qrIncident", dict, p.size())
{ {
if (dict.found("value") && dict.found("gradient")) const auto* hasGrad = dict.findEntry("gradient", keyType::LITERAL);
if (hasGrad && this->readValueEntry(dict))
{ {
fvPatchField<scalar>::operator=(Field<scalar>("value", dict, p.size())); gradient().assign(*hasGrad, p.size());
gradient() = Field<scalar>("gradient", dict, p.size());
} }
else else
{ {

View File

@ -248,7 +248,7 @@ humidityTemperatureCoupledMixedFvPatchScalarField
<< exit(FatalIOError); << exit(FatalIOError);
} }
fvPatchScalarField::operator=(scalarField("value", dict, p.size())); this->readValueEntry(dict, IOobjectOption::MUST_READ);
if (massModeTypeNames_.readIfPresent("mode", dict, mode_)) if (massModeTypeNames_.readIfPresent("mode", dict, mode_))
{ {
@ -315,13 +315,9 @@ humidityTemperatureCoupledMixedFvPatchScalarField
} }
if (this->readMixedEntries(dict))
if (dict.found("refValue"))
{ {
// Full restart // Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
} }
else else
{ {

View File

@ -100,7 +100,7 @@ thermalBaffle1DFvPatchScalarField
TName_("T"), TName_("T"),
baffleActivated_(dict.getOrDefault("baffleActivated", true)), baffleActivated_(dict.getOrDefault("baffleActivated", true)),
thickness_(), thickness_(),
qs_(p.size(), 0), qs_(p.size(), Zero),
solidDict_(dict), solidDict_(dict),
solidPtr_(), solidPtr_(),
qrPrevious_(p.size(), Zero), qrPrevious_(p.size(), Zero),
@ -110,7 +110,7 @@ thermalBaffle1DFvPatchScalarField
), ),
qrName_(dict.getOrDefault<word>("qr", "none")) qrName_(dict.getOrDefault<word>("qr", "none"))
{ {
fvPatchScalarField::operator=(scalarField("value", dict, p.size())); this->readValueEntry(dict, IOobjectOption::MUST_READ);
if (dict.found("thickness")) if (dict.found("thickness"))
{ {
@ -127,12 +127,9 @@ thermalBaffle1DFvPatchScalarField
qrPrevious_ = scalarField("qrPrevious", dict, p.size()); qrPrevious_ = scalarField("qrPrevious", dict, p.size());
} }
if (dict.found("refValue") && baffleActivated_) if (baffleActivated_ && this->readMixedEntries(dict))
{ {
// Full restart // Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
} }
else else
{ {

View File

@ -71,14 +71,7 @@ totalFlowRateAdvectiveDiffusiveFvPatchScalarField
refGrad() = 0.0; refGrad() = 0.0;
valueFraction() = 0.0; valueFraction() = 0.0;
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<scalar>::operator=
(
Field<scalar>("value", dict, p.size())
);
}
else
{ {
fvPatchField<scalar>::operator=(refValue()); fvPatchField<scalar>::operator=(refValue());
} }

View File

@ -143,14 +143,11 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
); );
fvPatchScalarField::operator=(scalarField("value", dict, p.size())); this->readValueEntry(dict, IOobjectOption::MUST_READ);
if (dict.found("refValue")) if (this->readMixedEntries(dict))
{ {
// Full restart // Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
} }
else else
{ {

View File

@ -191,14 +191,11 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
); );
} }
fvPatchScalarField::operator=(scalarField("value", dict, p.size())); this->readValueEntry(dict, IOobjectOption::MUST_READ);
if (dict.found("refValue")) if (this->readMixedEntries(dict))
{ {
// Full restart // Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
} }
else else
{ {

View File

@ -274,7 +274,7 @@ sorptionWallFunctionFvPatchScalarField::sorptionWallFunctionFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedGradientFvPatchScalarField(p, iF), fixedGradientFvPatchScalarField(p, iF), // Bypass dictionary constructor
wallFunctionBlenders(dict, blenderType::STEPWISE, scalar(2)), wallFunctionBlenders(dict, blenderType::STEPWISE, scalar(2)),
laminar_(dict.getOrDefault<bool>("laminar", false)), laminar_(dict.getOrDefault<bool>("laminar", false)),
kAbsPtr_(PatchFunction1<scalar>::New(p.patch(), "kAbs", dict)), kAbsPtr_(PatchFunction1<scalar>::New(p.patch(), "kAbs", dict)),
@ -303,13 +303,11 @@ sorptionWallFunctionFvPatchScalarField::sorptionWallFunctionFvPatchScalarField
<< exit(FatalIOError); << exit(FatalIOError);
} }
if (dict.found("value") && dict.found("gradient")) const auto* hasGrad = dict.findEntry("gradient", keyType::LITERAL);
if (hasGrad && this->readValueEntry(dict))
{ {
fvPatchField<scalar>::operator = gradient().assign(*hasGrad, p.size());
(
Field<scalar>("value", dict, p.size())
);
gradient() = Field<scalar>("gradient", dict, p.size());
} }
else else
{ {

View File

@ -77,14 +77,7 @@ Foam::wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField
refGrad() = 0.0; refGrad() = 0.0;
valueFraction() = 0.0; valueFraction() = 0.0;
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
evaluate(); evaluate();
} }

View File

@ -64,14 +64,7 @@ Foam::energyJumpFvPatchScalarField::energyJumpFvPatchScalarField
: :
fixedJumpFvPatchField<scalar>(p, iF) fixedJumpFvPatchField<scalar>(p, iF)
{ {
if (dict.found("value")) if (!this->readValueEntry(dict))
{
fvPatchScalarField::operator=
(
scalarField("value", dict, p.size())
);
}
else
{ {
evaluate(Pstream::commsTypes::blocking); evaluate(Pstream::commsTypes::blocking);
} }

Some files were not shown because too many files have changed in this diff Show More