ENH: additional uniform boundary conditions (#2703)

- provide uniformMixed conditions for finite-area and finite-volume.

  These are intended to replace the exprMixed condition but allow
  the full range of different PatchFunction1 and Function1 types.

- add uniformFixedGradient to finite-area for completeness.

Note:
   - still some possible difficulties with the order of evaluation.
   - eg, using an expression within the 'U' field that depends
     of the surface 'phi' field before that is constructed.
     In this case, the 'value' entry is really needed.
This commit is contained in:
Mark Olesen 2023-02-16 17:09:17 +01:00
parent 3d091a0d6a
commit e8bcf4cb1b
21 changed files with 1589 additions and 38 deletions

View File

@ -68,7 +68,9 @@ $(derivedFaPatchFields)/outletInlet/outletInletFaPatchFields.C
$(derivedFaPatchFields)/slip/slipFaPatchFields.C
$(derivedFaPatchFields)/edgeNormalFixedValue/edgeNormalFixedValueFaPatchVectorField.C
$(derivedFaPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C
$(derivedFaPatchFields)/uniformFixedGradient/uniformFixedGradientFaPatchFields.C
$(derivedFaPatchFields)/uniformFixedValue/uniformFixedValueFaPatchFields.C
$(derivedFaPatchFields)/uniformMixed/uniformMixedFaPatchFields.C
$(derivedFaPatchFields)/ignore/ignoreFaPatchFields.C
$(derivedFaPatchFields)/clampedPlate/clampedPlateFaPatchFields.C

View File

@ -0,0 +1,161 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "uniformFixedGradientFaPatchField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::uniformFixedGradientFaPatchField<Type>::uniformFixedGradientFaPatchField
(
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF
)
:
fixedGradientFaPatchField<Type>(p, iF),
refGradFunc_(nullptr)
{}
template<class Type>
Foam::uniformFixedGradientFaPatchField<Type>::uniformFixedGradientFaPatchField
(
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF,
const Field<Type>& fld
)
:
fixedGradientFaPatchField<Type>(p, iF, fld),
refGradFunc_(nullptr)
{}
template<class Type>
Foam::uniformFixedGradientFaPatchField<Type>::uniformFixedGradientFaPatchField
(
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF,
const dictionary& dict
)
:
fixedGradientFaPatchField<Type>(p, iF), // Bypass dictionary constructor
refGradFunc_
(
Function1<Type>::New
(
/* p.patch(), */
"uniformGradient",
dict
)
)
{
this->evaluate();
}
template<class Type>
Foam::uniformFixedGradientFaPatchField<Type>::uniformFixedGradientFaPatchField
(
const uniformFixedGradientFaPatchField<Type>& ptf,
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF,
const faPatchFieldMapper& mapper
)
:
fixedGradientFaPatchField<Type>(ptf, p, iF, mapper),
refGradFunc_(ptf.refGradFunc_.clone(/*p.patch()*/))
{}
template<class Type>
Foam::uniformFixedGradientFaPatchField<Type>::uniformFixedGradientFaPatchField
(
const uniformFixedGradientFaPatchField<Type>& ptf
)
:
fixedGradientFaPatchField<Type>(ptf),
refGradFunc_(ptf.refGradFunc_.clone(/*p.patch()*/))
{}
template<class Type>
Foam::uniformFixedGradientFaPatchField<Type>::uniformFixedGradientFaPatchField
(
const uniformFixedGradientFaPatchField<Type>& ptf,
const DimensionedField<Type, areaMesh>& iF
)
:
fixedGradientFaPatchField<Type>(ptf, iF),
refGradFunc_(ptf.refGradFunc_.clone(/*this->patch().patch()*/))
{
// Evaluate the profile if defined
if (refGradFunc_)
{
this->evaluate();
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::uniformFixedGradientFaPatchField<Type>::updateCoeffs()
{
if (this->updated())
{
return;
}
const scalar t = this->db().time().timeOutputValue();
// Extra safety on the evaluation
if (refGradFunc_)
{
this->gradient() = refGradFunc_->value(t);
}
else
{
this->gradient() = Zero;
}
fixedGradientFaPatchField<Type>::updateCoeffs();
}
template<class Type>
void Foam::uniformFixedGradientFaPatchField<Type>::write(Ostream& os) const
{
fixedGradientFaPatchField<Type>::write(os);
if (refGradFunc_)
{
refGradFunc_->writeData(os);
}
faPatchField<Type>::writeValueEntry(os);
}
// ************************************************************************* //

View File

@ -0,0 +1,188 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::uniformFixedGradientFaPatchField
Group
grpGenericBoundaryConditions
Description
This boundary condition provides a uniform fixed gradient condition.
Usage
\table
Property | Description | Required | Default
uniformGradient | uniform gradient | yes |
\endtable
Example of the boundary condition specification:
\verbatim
<patchName>
{
type uniformFixedGradient;
uniformGradient constant 0.2;
}
\endverbatim
Note
The uniformGradient entry is a Function1 type.
The example above gives the usage for supplying a constant value.
See also
Foam::Function1Types
Foam::fixedGradientFaPatchField
SourceFiles
uniformFixedGradientFaPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef Foam_uniformFixedGradientFaPatchField_H
#define Foam_uniformFixedGradientFaPatchField_H
#include "fixedGradientFaPatchField.H"
#include "PatchFunction1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class uniformFixedGradientFaPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class uniformFixedGradientFaPatchField
:
public fixedGradientFaPatchField<Type>
{
// Private Data
//- Function providing the gradient
autoPtr<Function1<Type>> refGradFunc_;
public:
//- Runtime type information
TypeName("uniformFixedGradient");
// Constructors
//- Construct from patch and internal field
uniformFixedGradientFaPatchField
(
const faPatch&,
const DimensionedField<Type, areaMesh>&
);
//- Construct from patch and internal field and patch field
uniformFixedGradientFaPatchField
(
const faPatch&,
const DimensionedField<Type, areaMesh>&,
const Field<Type>& fld
);
//- Construct from patch, internal field and dictionary
uniformFixedGradientFaPatchField
(
const faPatch&,
const DimensionedField<Type, areaMesh>&,
const dictionary&
);
//- Construct by mapping onto a new patch
uniformFixedGradientFaPatchField
(
const uniformFixedGradientFaPatchField<Type>&,
const faPatch&,
const DimensionedField<Type, areaMesh>&,
const faPatchFieldMapper&
);
//- Construct as copy
uniformFixedGradientFaPatchField
(
const uniformFixedGradientFaPatchField<Type>&
);
//- Construct and return a clone
virtual tmp<faPatchField<Type>> clone() const
{
return tmp<faPatchField<Type>>
(
new uniformFixedGradientFaPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
uniformFixedGradientFaPatchField
(
const uniformFixedGradientFaPatchField<Type>&,
const DimensionedField<Type, areaMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<faPatchField<Type>> clone
(
const DimensionedField<Type, areaMesh>& iF
) const
{
return tmp<faPatchField<Type>>
(
new uniformFixedGradientFaPatchField<Type>(*this, iF)
);
}
// Member functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "uniformFixedGradientFaPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,40 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "uniformFixedGradientFaPatchFields.H"
#include "addToRunTimeSelectionTable.H"
#include "areaFields.H"
#include "edgeFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
makeFaPatchFields(uniformFixedGradient);
}
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef Foam_uniformFixedGradientFaPatchFields_H
#define Foam_uniformFixedGradientFaPatchFields_H
#include "uniformFixedGradientFaPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makeFaPatchTypeFieldTypedefs(uniformFixedGradient);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -73,11 +73,7 @@ Foam::uniformFixedValueFaPatchField<Type>::uniformFixedValueFaPatchField
)
)
{
if (this->readValueEntry(dict))
{
// Full restart
}
else
if (!this->readValueEntry(dict))
{
this->evaluate();
}

View File

@ -0,0 +1,245 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "uniformMixedFaPatchField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::uniformMixedFaPatchField<Type>::uniformMixedFaPatchField
(
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF
)
:
mixedFaPatchField<Type>(p, iF),
refValueFunc_(nullptr),
refGradFunc_(nullptr),
valueFractionFunc_(nullptr)
{}
template<class Type>
Foam::uniformMixedFaPatchField<Type>::uniformMixedFaPatchField
(
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF,
const Field<Type>& fld
)
:
mixedFaPatchField<Type>(p, iF, fld),
refValueFunc_(nullptr),
refGradFunc_(nullptr),
valueFractionFunc_(nullptr)
{}
template<class Type>
Foam::uniformMixedFaPatchField<Type>::uniformMixedFaPatchField
(
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF,
const dictionary& dict
)
:
mixedFaPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
refValueFunc_
(
Function1<Type>::NewIfPresent
(
/* p.patch(), */
"uniformValue",
dict
)
),
refGradFunc_
(
Function1<Type>::NewIfPresent
(
// p.patch(),
"uniformGradient",
dict
)
),
valueFractionFunc_(nullptr)
{
if (refValueFunc_)
{
if (refGradFunc_)
{
// Both value + gradient: needs valueFraction
valueFractionFunc_.reset
(
Function1<scalar>::New
(
/* p.patch(), */
"uniformValueFraction",
dict
)
);
}
}
else if (!refGradFunc_)
{
// Missing both value and gradient: FatalIOError
FatalIOErrorInFunction(dict)
<< "For " << this->internalField().name() << " on "
<< this->patch().name() << nl
<< "Require either or both: uniformValue and uniformGradient"
<< " (possibly uniformValueFraction as well)" << nl
<< exit(FatalIOError);
}
// Use restart value if provided...
if (!this->readValueEntry(dict))
{
this->evaluate();
}
}
template<class Type>
Foam::uniformMixedFaPatchField<Type>::uniformMixedFaPatchField
(
const uniformMixedFaPatchField<Type>& ptf,
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF,
const faPatchFieldMapper& mapper
)
:
mixedFaPatchField<Type>(ptf, p, iF, mapper),
refValueFunc_(ptf.refValueFunc_.clone(/*p.patch()*/)),
refGradFunc_(ptf.refGradFunc_.clone(/*p.patch()*/)),
valueFractionFunc_(ptf.valueFractionFunc_.clone(/*p.patch()*/))
{}
template<class Type>
Foam::uniformMixedFaPatchField<Type>::uniformMixedFaPatchField
(
const uniformMixedFaPatchField<Type>& ptf
)
:
mixedFaPatchField<Type>(ptf),
refValueFunc_(ptf.refValueFunc_.clone(/*this->patch().patch()*/)),
refGradFunc_(ptf.refGradFunc_.clone(/*this->patch().patch()*/)),
valueFractionFunc_(ptf.valueFractionFunc_.clone(/*this->patch().patch()*/))
{}
template<class Type>
Foam::uniformMixedFaPatchField<Type>::uniformMixedFaPatchField
(
const uniformMixedFaPatchField<Type>& ptf,
const DimensionedField<Type, areaMesh>& iF
)
:
mixedFaPatchField<Type>(ptf, iF),
refValueFunc_(ptf.refValueFunc_.clone(/*this->patch().patch()*/)),
refGradFunc_(ptf.refGradFunc_.clone(/*this->patch().patch()*/)),
valueFractionFunc_(ptf.valueFractionFunc_.clone(/*this->patch().patch()*/))
{
// Evaluate the profile if defined
if (ptf.refValueFunc_ || ptf.refGradFunc_)
{
this->evaluate();
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::uniformMixedFaPatchField<Type>::updateCoeffs()
{
if (this->updated())
{
return;
}
const scalar t = this->db().time().timeOutputValue();
if (refValueFunc_)
{
this->refValue() = refValueFunc_->value(t);
if (refGradFunc_)
{
// Both value + gradient: has valueFraction too
this->valueFraction() = valueFractionFunc_->value(t);
}
else
{
// Has value only
this->valueFraction() = 1;
}
}
else
{
this->refValue() = Zero;
this->valueFraction() = 0;
}
if (refGradFunc_)
{
this->refGrad() = refGradFunc_->value(t);
}
else
{
this->refGrad() = Zero;
}
// Missing both value and gradient is caught as an error in
// dictionary constructor, but treated as zero-gradient here.
mixedFaPatchField<Type>::updateCoeffs();
}
template<class Type>
void Foam::uniformMixedFaPatchField<Type>::write(Ostream& os) const
{
faPatchField<Type>::write(os);
if (refValueFunc_)
{
refValueFunc_->writeData(os);
}
if (refGradFunc_)
{
refGradFunc_->writeData(os);
}
if (valueFractionFunc_)
{
valueFractionFunc_->writeData(os);
}
// Eg, for visualisation
faPatchField<Type>::writeValueEntry(os);
}
// ************************************************************************* //

View File

@ -0,0 +1,210 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::uniformMixedFaPatchField
Group
grpGenericBoundaryConditions
Description
This boundary condition provides 'mixed' type boundary condition
that mix a \em uniform fixed value and a \em uniform patch-normal
gradient condition. The term "uniform" is a legacy name since the
prescribed values were previously spatially uniform across that patch.
Usage
\table
Property | Description | Required | Default
uniformValue | uniform value | partly | 0
uniformGradient | uniform gradient | partly | 0
uniformValueFraction | uniform valueFraction | partly | depends
\endtable
Example of the boundary condition specification:
\verbatim
<patchName>
{
type uniformMixed;
uniformValue constant 0.2;
uniformGradient constant 0.2;
uniformValueFraction
{
type sine;
...
}
}
\endverbatim
Note
This boundary condition allows \em lazier definitions so that either
or both: \c uniformValue and \c uniformGradient must be defined.
If only of these entries is defined, the value fraction is automatically
treated appropriately (ie, 0 with \c uniformGradient and 1 with
uniformValue).
If both \c uniformValue and \c uniformGradient are defined,
the \c uniformValueFraction must also be defined.
See also
Foam::Function1Types
Foam::mixedFaPatchField
SourceFiles
uniformMixedFaPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef Foam_uniformMixedFaPatchField_H
#define Foam_uniformMixedFaPatchField_H
#include "mixedFaPatchField.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class uniformMixedFaPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class uniformMixedFaPatchField
:
public mixedFaPatchField<Type>
{
// Private Data
//- Function providing the value
autoPtr<Function1<Type>> refValueFunc_;
//- Function providing the gradient
autoPtr<Function1<Type>> refGradFunc_;
//- Function providing the value-fraction
autoPtr<Function1<scalar>> valueFractionFunc_;
public:
//- Runtime type information
TypeName("uniformMixed");
// Constructors
//- Construct from patch and internal field
uniformMixedFaPatchField
(
const faPatch&,
const DimensionedField<Type, areaMesh>&
);
//- Construct from patch and internal field and patch field
uniformMixedFaPatchField
(
const faPatch&,
const DimensionedField<Type, areaMesh>&,
const Field<Type>& fld
);
//- Construct from patch, internal field and dictionary
uniformMixedFaPatchField
(
const faPatch&,
const DimensionedField<Type, areaMesh>&,
const dictionary&
);
//- Construct by mapping onto a new patch
uniformMixedFaPatchField
(
const uniformMixedFaPatchField<Type>&,
const faPatch&,
const DimensionedField<Type, areaMesh>&,
const faPatchFieldMapper&
);
//- Construct as copy
uniformMixedFaPatchField
(
const uniformMixedFaPatchField<Type>&
);
//- Construct and return a clone
virtual tmp<faPatchField<Type>> clone() const
{
return tmp<faPatchField<Type>>
(
new uniformMixedFaPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
uniformMixedFaPatchField
(
const uniformMixedFaPatchField<Type>&,
const DimensionedField<Type, areaMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<faPatchField<Type>> clone
(
const DimensionedField<Type, areaMesh>& iF
) const
{
return tmp<faPatchField<Type>>
(
new uniformMixedFaPatchField<Type>(*this, iF)
);
}
// Member Functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "uniformMixedFaPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,40 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "uniformMixedFaPatchFields.H"
#include "addToRunTimeSelectionTable.H"
#include "areaFields.H"
#include "edgeFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
makeFaPatchFields(uniformMixed);
}
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef Foam_uniformMixedFaPatchFields_H
#define Foam_uniformMixedFaPatchFields_H
#include "uniformMixedFaPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makeFaPatchTypeFieldTypedefs(uniformMixed);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -227,6 +227,7 @@ $(derivedFvPatchFields)/turbulentIntensityKineticEnergyInlet/turbulentIntensityK
$(derivedFvPatchFields)/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C
$(derivedFvPatchFields)/uniformFixedGradient/uniformFixedGradientFvPatchFields.C
$(derivedFvPatchFields)/uniformFixedValue/uniformFixedValueFvPatchFields.C
$(derivedFvPatchFields)/uniformMixed/uniformMixedFvPatchFields.C
$(derivedFvPatchFields)/uniformInletOutlet/uniformInletOutletFvPatchFields.C
$(derivedFvPatchFields)/uniformJump/uniformJumpFvPatchFields.C
$(derivedFvPatchFields)/uniformJumpAMI/uniformJumpAMIFvPatchFields.C

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,7 +38,7 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
)
:
fixedGradientFvPatchField<Type>(p, iF),
uniformGradient_(nullptr)
refGradFunc_(nullptr)
{}
@ -51,7 +51,7 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
)
:
fixedGradientFvPatchField<Type>(p, iF, fld),
uniformGradient_(nullptr)
refGradFunc_(nullptr)
{}
@ -64,7 +64,7 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
)
:
fixedGradientFvPatchField<Type>(p, iF), // Bypass dictionary constructor
uniformGradient_
refGradFunc_
(
PatchFunction1<Type>::New(p.patch(), "uniformGradient", dict)
)
@ -84,7 +84,7 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
)
:
fixedGradientFvPatchField<Type>(ptf, p, iF, mapper),
uniformGradient_(ptf.uniformGradient_.clone())
refGradFunc_(ptf.refGradFunc_.clone())
{}
@ -95,7 +95,7 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
)
:
fixedGradientFvPatchField<Type>(ptf),
uniformGradient_(ptf.uniformGradient_.clone())
refGradFunc_(ptf.refGradFunc_.clone())
{}
@ -107,10 +107,10 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField
)
:
fixedGradientFvPatchField<Type>(ptf, iF),
uniformGradient_(ptf.uniformGradient_.clone())
refGradFunc_(ptf.refGradFunc_.clone())
{
// Evaluate the profile if defined
if (ptf.uniformGradient_)
if (refGradFunc_)
{
this->evaluate();
}
@ -128,7 +128,15 @@ void Foam::uniformFixedGradientFvPatchField<Type>::updateCoeffs()
}
const scalar t = this->db().time().timeOutputValue();
this->gradient() = uniformGradient_->value(t);
// Extra safety on the evaluation
if (refGradFunc_)
{
this->gradient() = refGradFunc_->value(t);
}
else
{
this->gradient() = Zero;
}
fixedGradientFvPatchField<Type>::updateCoeffs();
}
@ -138,7 +146,10 @@ template<class Type>
void Foam::uniformFixedGradientFvPatchField<Type>::write(Ostream& os) const
{
fixedGradientFvPatchField<Type>::write(os);
uniformGradient_->writeData(os);
if (refGradFunc_)
{
refGradFunc_->writeData(os);
}
fvPatchField<Type>::writeValueEntry(os);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -62,8 +62,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef uniformFixedGradientFvPatchField_H
#define uniformFixedGradientFvPatchField_H
#ifndef Foam_uniformFixedGradientFvPatchField_H
#define Foam_uniformFixedGradientFvPatchField_H
#include "fixedGradientFvPatchFields.H"
#include "PatchFunction1.H"
@ -84,8 +84,8 @@ class uniformFixedGradientFvPatchField
{
// Private Data
//- Gradient
autoPtr<PatchFunction1<Type>> uniformGradient_;
//- Function providing the gradient
autoPtr<PatchFunction1<Type>> refGradFunc_;
public:

View File

@ -134,12 +134,12 @@ void Foam::uniformFixedValueFvPatchField<Type>::autoMap
if (refValueFunc_)
{
refValueFunc_().autoMap(mapper);
}
if (refValueFunc_().constant())
{
// If mapper is not dependent on time we're ok to evaluate
this->evaluate();
if (refValueFunc_().constant())
{
// If mapper is not dependent on time we're ok to evaluate
this->evaluate();
}
}
}
@ -156,7 +156,7 @@ void Foam::uniformFixedValueFvPatchField<Type>::rmap
const uniformFixedValueFvPatchField& tiptf =
refCast<const uniformFixedValueFvPatchField>(ptf);
if (refValueFunc_)
if (refValueFunc_ && tiptf.refValueFunc_)
{
refValueFunc_().rmap(tiptf.refValueFunc_(), addr);
}
@ -172,6 +172,7 @@ void Foam::uniformFixedValueFvPatchField<Type>::updateCoeffs()
}
const scalar t = this->db().time().timeOutputValue();
fvPatchField<Type>::operator==(refValueFunc_->value(t));
fixedValueFvPatchField<Type>::updateCoeffs();
}
@ -181,12 +182,10 @@ template<class Type>
void Foam::uniformFixedValueFvPatchField<Type>::write(Ostream& os) const
{
fvPatchField<Type>::write(os);
if (refValueFunc_)
{
refValueFunc_->writeData(os);
}
fvPatchField<Type>::writeValueEntry(os);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

View File

@ -0,0 +1,235 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "uniformMixedFvPatchField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::uniformMixedFvPatchField<Type>::uniformMixedFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF
)
:
mixedFvPatchField<Type>(p, iF),
refValueFunc_(nullptr),
refGradFunc_(nullptr),
valueFractionFunc_(nullptr)
{}
template<class Type>
Foam::uniformMixedFvPatchField<Type>::uniformMixedFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const Field<Type>& fld
)
:
mixedFvPatchField<Type>(p, iF, fld),
refValueFunc_(nullptr),
refGradFunc_(nullptr),
valueFractionFunc_(nullptr)
{}
template<class Type>
Foam::uniformMixedFvPatchField<Type>::uniformMixedFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict
)
:
mixedFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
refValueFunc_
(
PatchFunction1<Type>::NewIfPresent(p.patch(), "uniformValue", dict)
),
refGradFunc_
(
PatchFunction1<Type>::NewIfPresent(p.patch(), "uniformGradient", dict)
),
valueFractionFunc_(nullptr)
{
if (refValueFunc_)
{
if (refGradFunc_)
{
// Both value + gradient: needs valueFraction
valueFractionFunc_.reset
(
PatchFunction1<scalar>::New
(
p.patch(),
"uniformValueFraction",
dict
)
);
}
}
else if (!refGradFunc_)
{
// Missing both value and gradient: FatalIOError
FatalIOErrorInFunction(dict)
<< "For " << this->internalField().name() << " on "
<< this->patch().name() << nl
<< "Require either or both: uniformValue and uniformGradient"
<< " (possibly uniformValueFraction as well)" << nl
<< exit(FatalIOError);
}
// Use restart value if provided...
if (!this->readValueEntry(dict))
{
this->evaluate();
}
}
template<class Type>
Foam::uniformMixedFvPatchField<Type>::uniformMixedFvPatchField
(
const uniformMixedFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
mixedFvPatchField<Type>(ptf, p, iF, mapper),
refValueFunc_(ptf.refValueFunc_.clone(p.patch())),
refGradFunc_(ptf.refGradFunc_.clone(p.patch())),
valueFractionFunc_(ptf.valueFractionFunc_.clone(p.patch()))
{}
template<class Type>
Foam::uniformMixedFvPatchField<Type>::uniformMixedFvPatchField
(
const uniformMixedFvPatchField<Type>& ptf
)
:
mixedFvPatchField<Type>(ptf),
refValueFunc_(ptf.refValueFunc_.clone(this->patch().patch())),
refGradFunc_(ptf.refGradFunc_.clone(this->patch().patch())),
valueFractionFunc_(ptf.valueFractionFunc_.clone(this->patch().patch()))
{}
template<class Type>
Foam::uniformMixedFvPatchField<Type>::uniformMixedFvPatchField
(
const uniformMixedFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF
)
:
mixedFvPatchField<Type>(ptf, iF),
refValueFunc_(ptf.refValueFunc_.clone(this->patch().patch())),
refGradFunc_(ptf.refGradFunc_.clone(this->patch().patch())),
valueFractionFunc_(ptf.valueFractionFunc_.clone(this->patch().patch()))
{
// Evaluate the profile if defined
if (ptf.refValueFunc_ || ptf.refGradFunc_)
{
this->evaluate();
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::uniformMixedFvPatchField<Type>::updateCoeffs()
{
if (this->updated())
{
return;
}
const scalar t = this->db().time().timeOutputValue();
if (refValueFunc_)
{
this->refValue() = refValueFunc_->value(t);
if (refGradFunc_)
{
// Both value + gradient: has valueFraction too
this->valueFraction() = valueFractionFunc_->value(t);
}
else
{
// Has value only
this->valueFraction() = 1;
}
}
else
{
this->refValue() = Zero;
this->valueFraction() = 0;
}
if (refGradFunc_)
{
this->refGrad() = refGradFunc_->value(t);
}
else
{
this->refGrad() = Zero;
}
// Missing both value and gradient is caught as an error in
// dictionary constructor, but treated as zero-gradient here.
mixedFvPatchField<Type>::updateCoeffs();
}
template<class Type>
void Foam::uniformMixedFvPatchField<Type>::write(Ostream& os) const
{
fvPatchField<Type>::write(os);
if (refValueFunc_)
{
refValueFunc_->writeData(os);
}
if (refGradFunc_)
{
refGradFunc_->writeData(os);
}
if (valueFractionFunc_)
{
valueFractionFunc_->writeData(os);
}
// Eg, for visualisation
fvPatchField<Type>::writeValueEntry(os);
}
// ************************************************************************* //

View File

@ -0,0 +1,213 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::uniformMixedFvPatchField
Group
grpGenericBoundaryConditions
Description
This boundary condition provides 'mixed' type boundary condition
that mix a \em uniform fixed value and a \em uniform patch-normal
gradient condition. The term "uniform" is a legacy name since the
prescribed values were previously spatially uniform across that patch.
In the meantime, a PatchFunction1 is used, which can have both
spatial and temporal dependencies.
Usage
\table
Property | Description | Required | Default
uniformValue | uniform value | partly | 0
uniformGradient | uniform gradient | partly | 0
uniformValueFraction | uniform valueFraction | partly | depends
\endtable
Example of the boundary condition specification:
\verbatim
<patchName>
{
type uniformMixed;
uniformValue constant 0.2;
uniformGradient constant 0.2;
uniformValueFraction
{
type sine;
...
}
}
\endverbatim
Note
This boundary condition allows \em lazier definitions so that either
or both: \c uniformValue and \c uniformGradient must be defined.
If only of these entries is defined, the value fraction is automatically
treated appropriately (ie, 0 with \c uniformGradient and 1 with
uniformValue).
If both \c uniformValue and \c uniformGradient are defined,
the \c uniformValueFraction must also be defined.
See also
Foam::Function1Types
Foam::mixedFvPatchField
SourceFiles
uniformMixedFvPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef Foam_uniformMixedFvPatchField_H
#define Foam_uniformMixedFvPatchField_H
#include "mixedFvPatchField.H"
#include "PatchFunction1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class uniformMixedFvPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class uniformMixedFvPatchField
:
public mixedFvPatchField<Type>
{
// Private Data
//- Function providing the value
autoPtr<PatchFunction1<Type>> refValueFunc_;
//- Function providing the gradient
autoPtr<PatchFunction1<Type>> refGradFunc_;
//- Function providing the value-fraction
autoPtr<PatchFunction1<scalar>> valueFractionFunc_;
public:
//- Runtime type information
TypeName("uniformMixed");
// Constructors
//- Construct from patch and internal field
uniformMixedFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&
);
//- Construct from patch and internal field and patch field
uniformMixedFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const Field<Type>& fld
);
//- Construct from patch, internal field and dictionary
uniformMixedFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const dictionary&
);
//- Construct by mapping onto a new patch
uniformMixedFvPatchField
(
const uniformMixedFvPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
uniformMixedFvPatchField
(
const uniformMixedFvPatchField<Type>&
);
//- Construct and return a clone
virtual tmp<fvPatchField<Type>> clone() const
{
return tmp<fvPatchField<Type>>
(
new uniformMixedFvPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
uniformMixedFvPatchField
(
const uniformMixedFvPatchField<Type>&,
const DimensionedField<Type, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchField<Type>> clone
(
const DimensionedField<Type, volMesh>& iF
) const
{
return tmp<fvPatchField<Type>>
(
new uniformMixedFvPatchField<Type>(*this, iF)
);
}
// Member Functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "uniformMixedFvPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,39 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "uniformMixedFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
makePatchFields(uniformMixed);
}
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef Foam_uniformMixedFvPatchFields_H
#define Foam_uniformMixedFvPatchFields_H
#include "uniformMixedFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeFieldTypedefs(uniformMixed);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -152,12 +152,16 @@ void Foam::uniformFixedValuePointPatchField<Type>::autoMap
)
{
fixedValuePointPatchField<Type>::autoMap(mapper);
refValueFunc_().autoMap(mapper);
if (refValueFunc_().constant())
if (refValueFunc_)
{
// If mapper is not dependent on time we're ok to evaluate
this->evaluate();
refValueFunc_().autoMap(mapper);
if (refValueFunc_().constant())
{
// If mapper is not dependent on time we're ok to evaluate
this->evaluate();
}
}
}
@ -174,7 +178,10 @@ void Foam::uniformFixedValuePointPatchField<Type>::rmap
const uniformFixedValuePointPatchField& tiptf =
refCast<const uniformFixedValuePointPatchField>(ptf);
refValueFunc_().rmap(tiptf.refValueFunc_(), addr);
if (refValueFunc_ && tiptf.refValueFunc_)
{
refValueFunc_().rmap(tiptf.refValueFunc_(), addr);
}
}
@ -186,6 +193,7 @@ void Foam::uniformFixedValuePointPatchField<Type>::updateCoeffs()
return;
}
const scalar t = this->db().time().timeOutputValue();
fixedValuePointPatchField<Type>::operator==(refValueFunc_->value(t));
fixedValuePointPatchField<Type>::updateCoeffs();
}
@ -197,7 +205,10 @@ write(Ostream& os) const
{
// Note: write value
fixedValuePointPatchField<Type>::write(os);
refValueFunc_->writeData(os);
if (refValueFunc_)
{
refValueFunc_->writeData(os);
}
}

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2212 |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -35,9 +35,19 @@ boundaryField
outlet2
{
type inletOutlet;
inletValue uniform (0 0 0);
// A do-it-yourself inletOutlet (for demonstration purposes)
// Need 'value' entry to avoid evaluation (with phi) on startup
type uniformMixed;
value uniform (0 0 0);
uniformValue zero;
uniformGradient zero;
uniformValueFraction
{
type expression;
expression "neg(phi)";
}
}
defaultFaces