fvPatchField: Corrected propagation of patchType

The construction of some patch fields has been corrected so that the
patchType setting always propagates on mapping, IO, clone, etc...
Dictionary and mapping-based patch field constructors now call the
corresponding constructor from the base class, regardless of whether
dictionary settings or mapping are actually needed.

A "mappingRequired" flag has been added to some of the base constructors
in order to prevent unecessary mapping of field data and retain the
previous level of optimisation.

Resolves bug report https://bugs.openfoam.org/view.php?id=3144
This commit is contained in:
Will Bainbridge
2019-01-02 15:33:55 +00:00
parent 5da333af44
commit 70021b1268
18 changed files with 70 additions and 105 deletions

View File

@ -123,11 +123,10 @@ ${typeName}FixedValuePointPatch${FieldType}
(
const pointPatch& p,
const DimensionedField<${TemplateType}, pointMesh>& iF,
const dictionary& dict,
const bool valueRequired
const dictionary& dict
)
:
fixedValuePointPatchField<${TemplateType}>(p, iF, dict, valueRequired)
fixedValuePointPatchField<${TemplateType}>(p, iF, dict)
{
if (${verbose:-false})
{

View File

@ -73,8 +73,7 @@ public:
(
const pointPatch&,
const DimensionedField<${TemplateType}, pointMesh>&,
const dictionary&,
const bool valueRequired=true
const dictionary&
);
//- Construct by mapping a copy onto a new patch

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -210,11 +210,10 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
(
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict,
const bool valueRequired
const dictionary& dict
)
:
fixedValuePointPatchField<Type>(p, iF, dict, valueRequired),
fixedValuePointPatchField<Type>(p, iF, dict),
codedBase(),
dict_(dict),
name_

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -167,8 +167,7 @@ public:
(
const pointPatch&,
const DimensionedField<Type, pointMesh>&,
const dictionary&,
const bool valueRequired=true
const dictionary&
);
//- Construct by mapping given codedFixedValuePointPatchField

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-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -67,10 +67,11 @@ Foam::calculatedFvPatchField<Type>::calculatedFvPatchField
const calculatedFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
const fvPatchFieldMapper& mapper,
const bool mappingRequired
)
:
fvPatchField<Type>(ptf, p, iF, mapper)
fvPatchField<Type>(ptf, p, iF, mapper, mappingRequired)
{}

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-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -94,7 +94,8 @@ public:
const calculatedFvPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
const fvPatchFieldMapper&,
const bool mappingRequired=true
);
//- Construct as copy

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-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,11 +58,12 @@ Foam::coupledFvPatchField<Type>::coupledFvPatchField
const coupledFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
const fvPatchFieldMapper& mapper,
const bool mappingRequired
)
:
LduInterfaceField<Type>(refCast<const lduInterface>(p)),
fvPatchField<Type>(ptf, p, iF, mapper)
fvPatchField<Type>(ptf, p, iF, mapper, mappingRequired)
{}

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-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -93,7 +93,8 @@ public:
const coupledFvPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
const fvPatchFieldMapper&,
const bool mappingRequired=true
);
//- Construct as copy

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-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -69,12 +69,13 @@ Foam::fixedValueFvPatchField<Type>::fixedValueFvPatchField
const fixedValueFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
const fvPatchFieldMapper& mapper,
const bool mappingRequired
)
:
fvPatchField<Type>(ptf, p, iF, mapper)
fvPatchField<Type>(ptf, p, iF, mapper, mappingRequired)
{
if (notNull(iF) && mapper.hasUnmapped())
if (mappingRequired && notNull(iF) && mapper.hasUnmapped())
{
WarningInFunction
<< "On field " << iF.name() << " patch " << p.name()

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-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -107,7 +107,8 @@ public:
const fixedValueFvPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
const fvPatchFieldMapper&,
const bool mappingRequired=true
);
//- Construct as copy

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-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -64,15 +64,16 @@ Foam::mixedFvPatchField<Type>::mixedFvPatchField
const mixedFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
const fvPatchFieldMapper& mapper,
const bool mappingRequired
)
:
fvPatchField<Type>(ptf, p, iF, mapper),
fvPatchField<Type>(ptf, p, iF, mapper, mappingRequired),
refValue_(ptf.refValue_, mapper),
refGrad_(ptf.refGrad_, mapper),
valueFraction_(ptf.valueFraction_, mapper)
{
if (notNull(iF) && mapper.hasUnmapped())
if (mappingRequired && notNull(iF) && mapper.hasUnmapped())
{
WarningInFunction
<< "On field " << iF.name() << " patch " << p.name()

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-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -125,7 +125,8 @@ public:
const mixedFvPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
const fvPatchFieldMapper&,
const bool mappingRequired=true
);
//- Construct as copy

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,8 +34,10 @@ Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(p, iF, Zero)
{}
fixedValueFvPatchVectorField(p, iF)
{
operator==(Zero);
}
Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField
@ -45,8 +47,10 @@ Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField
const dictionary& dict
)
:
fixedValueFvPatchVectorField(p, iF, Zero)
{}
fixedValueFvPatchVectorField(p, iF, dict, false)
{
operator==(Zero);
}
Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField
@ -57,8 +61,10 @@ Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchVectorField(p, iF, Zero)
{}
fixedValueFvPatchVectorField(ptf, p, iF, mapper, false) // Don't map
{
operator==(Zero);
}
Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField

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-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -76,7 +76,7 @@ Foam::uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchField<Type>(p, iF), // Don't map
fixedValueFvPatchField<Type>(ptf, p, iF, mapper, false), // Don't map
uniformValue_(ptf.uniformValue_, false)
{
// Evaluate since value not mapped

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-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -84,7 +84,7 @@ Foam::uniformInletOutletFvPatchField<Type>::uniformInletOutletFvPatchField
const fvPatchFieldMapper& mapper
)
:
mixedFvPatchField<Type>(p, iF), // Don't map
mixedFvPatchField<Type>(ptf, p, iF, mapper, false), // Don't map
phiName_(ptf.phiName_),
uniformInletValue_(ptf.uniformInletValue_, false)
{

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-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -88,7 +88,7 @@ uniformTotalPressureFvPatchScalarField
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(p, iF), // Don't map
fixedValueFvPatchScalarField(ptf, p, iF, mapper, false), // Don't map
UName_(ptf.UName_),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),

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-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,40 +47,6 @@ Foam::fvPatchField<Type>::fvPatchField
{}
template<class Type>
Foam::fvPatchField<Type>::fvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const Type& value
)
:
Field<Type>(p.size(), value),
patch_(p),
internalField_(iF),
updated_(false),
manipulatedMatrix_(false),
patchType_(word::null)
{}
template<class Type>
Foam::fvPatchField<Type>::fvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const word& patchType
)
:
Field<Type>(p.size()),
patch_(p),
internalField_(iF),
updated_(false),
manipulatedMatrix_(false),
patchType_(patchType)
{}
template<class Type>
Foam::fvPatchField<Type>::fvPatchField
(
@ -141,7 +107,8 @@ Foam::fvPatchField<Type>::fvPatchField
const fvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
const fvPatchFieldMapper& mapper,
const bool mappingRequired
)
:
Field<Type>(p.size()),
@ -151,12 +118,15 @@ Foam::fvPatchField<Type>::fvPatchField
manipulatedMatrix_(false),
patchType_(ptf.patchType_)
{
// For unmapped faces set to internal field value (zero-gradient)
if (notNull(iF) && mapper.hasUnmapped())
if (mappingRequired)
{
fvPatchField<Type>::operator=(this->patchInternalField());
// For unmapped faces set to internal field value (zero-gradient)
if (notNull(iF) && mapper.hasUnmapped())
{
fvPatchField<Type>::operator=(this->patchInternalField());
}
this->map(ptf, mapper);
}
this->map(ptf, mapper);
}

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-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -171,22 +171,6 @@ public:
const DimensionedField<Type, volMesh>&
);
//- Construct from patch, internal field and value
fvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const Type& value
);
//- Construct from patch and internal field and patch type
fvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const word& patchType
);
//- Construct from patch and internal field and patch field
fvPatchField
(
@ -210,7 +194,8 @@ public:
const fvPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
const fvPatchFieldMapper&,
const bool mappingRequired=true
);
//- Construct as copy