mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: boundary conditions with expressions
This commit is contained in:
@ -272,6 +272,12 @@ $(volumeExpr)/volumeExprDriverFields.C
|
|||||||
$(volumeExpr)/volumeExprLemonParser.lyy-m4
|
$(volumeExpr)/volumeExprLemonParser.lyy-m4
|
||||||
$(volumeExpr)/volumeExprScanner.cc
|
$(volumeExpr)/volumeExprScanner.cc
|
||||||
|
|
||||||
|
fieldExpr = $(expr)/fields
|
||||||
|
$(fieldExpr)/base/patchExprFieldBase.C
|
||||||
|
$(fieldExpr)/fvPatchFields/exprFixedValueFvPatchFields.C
|
||||||
|
$(fieldExpr)/fvPatchFields/exprMixedFvPatchFields.C
|
||||||
|
$(fieldExpr)/pointPatchFields/exprValuePointPatchFields.C
|
||||||
|
|
||||||
|
|
||||||
fvMatrices/fvMatrices.C
|
fvMatrices/fvMatrices.C
|
||||||
fvMatrices/fvScalarMatrix/fvScalarMatrix.C
|
fvMatrices/fvScalarMatrix/fvScalarMatrix.C
|
||||||
|
|||||||
186
src/finiteVolume/expressions/fields/base/patchExprFieldBase.C
Normal file
186
src/finiteVolume/expressions/fields/base/patchExprFieldBase.C
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Original code Copyright (C) 2011-2018 Bernhard Gschaider
|
||||||
|
Copyright (C) 2019 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 "patchExprFieldBase.H"
|
||||||
|
#include "facePointPatch.H"
|
||||||
|
#include "fvMesh.H"
|
||||||
|
#include "fvPatch.H"
|
||||||
|
#include "pointMesh.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::fvPatch&
|
||||||
|
Foam::expressions::patchExprFieldBase::getFvPatch(const facePointPatch& pp)
|
||||||
|
{
|
||||||
|
const polyMesh& pmesh = pp.boundaryMesh().mesh().mesh();
|
||||||
|
|
||||||
|
const fvMesh* meshptr = isA<fvMesh>(pmesh);
|
||||||
|
|
||||||
|
if (!meshptr)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Point patch not attached to a base fvMesh, "
|
||||||
|
<< "cannot use patch expressions" << nl << endl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return meshptr->boundary()[pp.index()];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::expressions::patchExprFieldBase::patchExprFieldBase()
|
||||||
|
:
|
||||||
|
patchExprFieldBase(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::expressions::patchExprFieldBase::patchExprFieldBase
|
||||||
|
(
|
||||||
|
bool allowGradient
|
||||||
|
)
|
||||||
|
:
|
||||||
|
debug_(false),
|
||||||
|
allowGradient_(allowGradient),
|
||||||
|
evalOnConstruct_(false),
|
||||||
|
valueExpr_(),
|
||||||
|
gradExpr_(),
|
||||||
|
fracExpr_()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::expressions::patchExprFieldBase::patchExprFieldBase
|
||||||
|
(
|
||||||
|
const dictionary& dict,
|
||||||
|
bool allowGradient,
|
||||||
|
bool isPointVal
|
||||||
|
)
|
||||||
|
:
|
||||||
|
debug_(dict.lookupOrDefault("debug", false)),
|
||||||
|
allowGradient_(allowGradient),
|
||||||
|
evalOnConstruct_(dict.lookupOrDefault<bool>("evalOnConstruct", false)),
|
||||||
|
valueExpr_(),
|
||||||
|
gradExpr_(),
|
||||||
|
fracExpr_()
|
||||||
|
{
|
||||||
|
if (debug_)
|
||||||
|
{
|
||||||
|
Info<< "Expression BC with " << dict << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
string expr;
|
||||||
|
|
||||||
|
if (dict.readIfPresent("valueExpr", expr))
|
||||||
|
{
|
||||||
|
valueExpr_ = expressions::exprString(expr, dict);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No value expression - same as Zero
|
||||||
|
if (debug_)
|
||||||
|
{
|
||||||
|
Info<< "No valueExpr" << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allowGradient)
|
||||||
|
{
|
||||||
|
if (dict.readIfPresent("gradientExpr", expr))
|
||||||
|
{
|
||||||
|
gradExpr_ = expressions::exprString(expr, dict);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No gradient expression - same as Zero
|
||||||
|
|
||||||
|
if (debug_)
|
||||||
|
{
|
||||||
|
Info<< "No gradientExpr" << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dict.readIfPresent("fractionExpr", expr))
|
||||||
|
{
|
||||||
|
if (!expr.empty() && expr != "0")
|
||||||
|
{
|
||||||
|
if (isPointVal)
|
||||||
|
{
|
||||||
|
expr = "toPoint(" + expr + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
fracExpr_ = expressions::exprString(expr, dict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No fraction expression - same as 1 (one)
|
||||||
|
// Mixed BC may elect to simply ignore gradient expression
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::expressions::patchExprFieldBase::patchExprFieldBase
|
||||||
|
(
|
||||||
|
const patchExprFieldBase& rhs
|
||||||
|
)
|
||||||
|
:
|
||||||
|
debug_(rhs.debug_),
|
||||||
|
allowGradient_(rhs.allowGradient_),
|
||||||
|
evalOnConstruct_(rhs.evalOnConstruct_),
|
||||||
|
valueExpr_(rhs.valueExpr_),
|
||||||
|
gradExpr_(rhs.gradExpr_),
|
||||||
|
fracExpr_(rhs.fracExpr_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::expressions::patchExprFieldBase::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
os.writeEntryIfDifferent<bool>("evalOnConstruct", false, evalOnConstruct_);
|
||||||
|
|
||||||
|
// Do not emit debug_ value
|
||||||
|
|
||||||
|
if (!valueExpr_.empty())
|
||||||
|
{
|
||||||
|
os.writeEntry("valueExpr", valueExpr_);
|
||||||
|
}
|
||||||
|
if (!gradExpr_.empty())
|
||||||
|
{
|
||||||
|
os.writeEntry("gradientExpr", gradExpr_);
|
||||||
|
}
|
||||||
|
if (!fracExpr_.empty())
|
||||||
|
{
|
||||||
|
os.writeEntry("fractionExpr", fracExpr_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
131
src/finiteVolume/expressions/fields/base/patchExprFieldBase.H
Normal file
131
src/finiteVolume/expressions/fields/base/patchExprFieldBase.H
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Original code Copyright (C) 2011-2018 Bernhard Gschaider
|
||||||
|
Copyright (C) 2019 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::expressions::patchExprFieldBase
|
||||||
|
|
||||||
|
Description
|
||||||
|
Base class for managing patches with expressions.
|
||||||
|
The expected input supports values, gradients and mixed conditions
|
||||||
|
|
||||||
|
Usage
|
||||||
|
\table
|
||||||
|
Property | Description | Required | Default
|
||||||
|
valueExpr | expression for fixed value | no | 0
|
||||||
|
gradientExpr | expression for patch normal gradient | no | 0
|
||||||
|
fractionExpr | expression for value fraction weight | no | 1
|
||||||
|
\endtable
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
patchExprFieldBase.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef expressions_patchExprFieldBase_H
|
||||||
|
#define expressions_patchExprFieldBase_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "exprString.H"
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
class facePointPatch;
|
||||||
|
class fvPatch;
|
||||||
|
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class patchExprFieldBase Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class patchExprFieldBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Data
|
||||||
|
|
||||||
|
bool debug_;
|
||||||
|
bool allowGradient_;
|
||||||
|
|
||||||
|
//- Slightly dodgy concept here
|
||||||
|
bool evalOnConstruct_;
|
||||||
|
|
||||||
|
// The expressions
|
||||||
|
expressions::exprString valueExpr_;
|
||||||
|
expressions::exprString gradExpr_;
|
||||||
|
expressions::exprString fracExpr_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Static Methods
|
||||||
|
|
||||||
|
//- Find (guess) fvPatch from a pointPatch
|
||||||
|
static const fvPatch& getFvPatch(const facePointPatch& fp);
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Null constructor
|
||||||
|
patchExprFieldBase();
|
||||||
|
|
||||||
|
//- Construct with specified gradient handling
|
||||||
|
explicit patchExprFieldBase(bool allowGradient);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
explicit patchExprFieldBase
|
||||||
|
(
|
||||||
|
const dictionary& dict,
|
||||||
|
bool allowGradient = false,
|
||||||
|
bool isPointVal = false
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Copy constructor
|
||||||
|
patchExprFieldBase(const patchExprFieldBase& rhs);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
void write(Ostream& os) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace expressions
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,215 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Original code Copyright (C) 2009-2018 Bernhard Gschaider
|
||||||
|
Copyright (C) 2019 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 "exprFixedValueFvPatchField.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::exprFixedValueFvPatchField<Type>::setDebug()
|
||||||
|
{
|
||||||
|
if (expressions::patchExprFieldBase::debug_ && !debug)
|
||||||
|
{
|
||||||
|
debug = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprFixedValueFvPatchField<Type>::exprFixedValueFvPatchField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<Type, volMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchField<Type>(p, iF),
|
||||||
|
expressions::patchExprFieldBase(false),
|
||||||
|
driver_(this->patch())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprFixedValueFvPatchField<Type>::exprFixedValueFvPatchField
|
||||||
|
(
|
||||||
|
const exprFixedValueFvPatchField<Type>& ptf,
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<Type, volMesh>& iF,
|
||||||
|
const fvPatchFieldMapper& mapper
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
|
||||||
|
expressions::patchExprFieldBase(ptf),
|
||||||
|
driver_(this->patch(), ptf.driver_)
|
||||||
|
{
|
||||||
|
setDebug();
|
||||||
|
DebugInFunction << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprFixedValueFvPatchField<Type>::exprFixedValueFvPatchField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<Type, volMesh>& iF,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool valueRequired
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchField<Type>(p, iF),
|
||||||
|
expressions::patchExprFieldBase(dict),
|
||||||
|
driver_(this->patch(), dict)
|
||||||
|
{
|
||||||
|
setDebug();
|
||||||
|
DebugInFunction << nl;
|
||||||
|
|
||||||
|
// Basic sanity
|
||||||
|
if (this->valueExpr_.empty())
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "The valueExpr was not defined!" << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
driver_.readDict(dict);
|
||||||
|
|
||||||
|
if (dict.found("value"))
|
||||||
|
{
|
||||||
|
fvPatchField<Type>::operator=
|
||||||
|
(
|
||||||
|
Field<Type>("value", dict, p.size())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(*this) == this->patchInternalField();
|
||||||
|
|
||||||
|
WarningInFunction
|
||||||
|
<< "No value defined for "
|
||||||
|
<< this->internalField().name() << " on "
|
||||||
|
<< this->patch().name() << " - setting to internalField value "
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->evalOnConstruct_)
|
||||||
|
{
|
||||||
|
// For potentialFoam or other solvers that don't evaluate
|
||||||
|
this->evaluate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprFixedValueFvPatchField<Type>::exprFixedValueFvPatchField
|
||||||
|
(
|
||||||
|
const exprFixedValueFvPatchField<Type>& ptf
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchField<Type>(ptf),
|
||||||
|
expressions::patchExprFieldBase(ptf),
|
||||||
|
driver_(this->patch(), ptf.driver_)
|
||||||
|
{
|
||||||
|
setDebug();
|
||||||
|
DebugInFunction << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprFixedValueFvPatchField<Type>::exprFixedValueFvPatchField
|
||||||
|
(
|
||||||
|
const exprFixedValueFvPatchField<Type>& ptf,
|
||||||
|
const DimensionedField<Type, volMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchField<Type>(ptf, iF),
|
||||||
|
expressions::patchExprFieldBase(ptf),
|
||||||
|
driver_(this->patch(), ptf.driver_)
|
||||||
|
{
|
||||||
|
setDebug();
|
||||||
|
DebugInFunction << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::exprFixedValueFvPatchField<Type>::updateCoeffs()
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
InfoInFunction
|
||||||
|
<< "Value: " << this->valueExpr_ << nl
|
||||||
|
<< "Variables: ";
|
||||||
|
driver_.writeVariableStrings(Info) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->updated())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugInFunction
|
||||||
|
<< "updating" << nl;
|
||||||
|
|
||||||
|
// Expression evaluation
|
||||||
|
{
|
||||||
|
driver_.clearVariables();
|
||||||
|
|
||||||
|
if (this->valueExpr_.empty())
|
||||||
|
{
|
||||||
|
(*this) == Zero;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmp<Field<Type>> tresult(driver_.evaluate<Type>(this->valueExpr_));
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Evaluated: " << tresult();
|
||||||
|
}
|
||||||
|
|
||||||
|
(*this) == tresult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fixedValueFvPatchField<Type>::updateCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::exprFixedValueFvPatchField<Type>::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
fixedValueFvPatchField<Type>::write(os);
|
||||||
|
expressions::patchExprFieldBase::write(os);
|
||||||
|
|
||||||
|
// driver_.writeCommon(os, this->debug_ || debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,175 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Original code Copyright (C) 2009-2018 Bernhard Gschaider
|
||||||
|
Copyright (C) 2019 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::exprFixedValueFvPatchField
|
||||||
|
|
||||||
|
Description
|
||||||
|
A fixed value boundary condition with expressions.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
\table
|
||||||
|
Property | Description | Required | Default
|
||||||
|
value | fixed value | yes |
|
||||||
|
valueExpr | expression for fixed value | yes |
|
||||||
|
\endtable
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
exprFixedValueFvPatchField.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef exprFixedValueFvPatchField_H
|
||||||
|
#define exprFixedValueFvPatchField_H
|
||||||
|
|
||||||
|
#include "fixedValueFvPatchField.H"
|
||||||
|
#include "patchExprFieldBase.H"
|
||||||
|
#include "patchExprDriver.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class exprFixedValueFvPatchField Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
class exprFixedValueFvPatchField
|
||||||
|
:
|
||||||
|
public fixedValueFvPatchField<Type>,
|
||||||
|
public expressions::patchExprFieldBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Data
|
||||||
|
|
||||||
|
//- The expression driver
|
||||||
|
expressions::patchExpr::parseDriver driver_;
|
||||||
|
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Set debug ON if "debug" is enabled
|
||||||
|
void setDebug();
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("exprFixedValue");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from patch and internal field
|
||||||
|
exprFixedValueFvPatchField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<Type, volMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from patch, internal field and dictionary
|
||||||
|
exprFixedValueFvPatchField
|
||||||
|
(
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<Type, volMesh>&,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool valueRequired=true
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct by mapping given exprFixedValueFvPatchField
|
||||||
|
//- onto a new patch
|
||||||
|
exprFixedValueFvPatchField
|
||||||
|
(
|
||||||
|
const exprFixedValueFvPatchField<Type>&,
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<Type, volMesh>&,
|
||||||
|
const fvPatchFieldMapper&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct as copy
|
||||||
|
exprFixedValueFvPatchField
|
||||||
|
(
|
||||||
|
const exprFixedValueFvPatchField<Type>&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Construct and return a clone
|
||||||
|
virtual tmp<fvPatchField<Type>> clone() const
|
||||||
|
{
|
||||||
|
return tmp<fvPatchField<Type>>
|
||||||
|
(
|
||||||
|
new exprFixedValueFvPatchField<Type>(*this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Construct as copy setting internal field reference
|
||||||
|
exprFixedValueFvPatchField
|
||||||
|
(
|
||||||
|
const exprFixedValueFvPatchField<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 exprFixedValueFvPatchField<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 "exprFixedValueFvPatchField.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2019 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 "exprFixedValueFvPatchFields.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
makePatchFields(exprFixedValue);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2019 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 exprFixedValueFvPatchFields_H
|
||||||
|
#define exprFixedValueFvPatchFields_H
|
||||||
|
|
||||||
|
#include "exprFixedValueFvPatchField.H"
|
||||||
|
#include "fieldTypes.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
makePatchTypeFieldTypedefs(exprFixedValue);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2019 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 exprFixedValueFvPatchFieldsFwd_H
|
||||||
|
#define exprFixedValueFvPatchFieldsFwd_H
|
||||||
|
|
||||||
|
#include "fieldTypes.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type> class exprFixedValueFvPatchField;
|
||||||
|
|
||||||
|
makePatchTypeFieldTypedefs(exprFixedValue);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,309 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Original code Copyright (C) 2009-2018 Bernhard Gschaider
|
||||||
|
Copyright (C) 2019 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 "exprMixedFvPatchField.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::exprMixedFvPatchField<Type>::setDebug()
|
||||||
|
{
|
||||||
|
if (expressions::patchExprFieldBase::debug_ && !debug)
|
||||||
|
{
|
||||||
|
debug = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprMixedFvPatchField<Type>::exprMixedFvPatchField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<Type, volMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
mixedFvPatchField<Type>(p, iF),
|
||||||
|
expressions::patchExprFieldBase(true), // allowGradient
|
||||||
|
driver_(this->patch())
|
||||||
|
{
|
||||||
|
this->refValue() = Zero;
|
||||||
|
this->refGrad() = Zero;
|
||||||
|
this->valueFraction() = scalar(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprMixedFvPatchField<Type>::exprMixedFvPatchField
|
||||||
|
(
|
||||||
|
const exprMixedFvPatchField<Type>& ptf,
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<Type, volMesh>& iF,
|
||||||
|
const fvPatchFieldMapper& mapper
|
||||||
|
)
|
||||||
|
:
|
||||||
|
mixedFvPatchField<Type>(ptf, p, iF, mapper),
|
||||||
|
expressions::patchExprFieldBase(ptf),
|
||||||
|
driver_(this->patch(), ptf.driver_)
|
||||||
|
{
|
||||||
|
setDebug();
|
||||||
|
DebugInFunction << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprMixedFvPatchField<Type>::exprMixedFvPatchField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<Type, volMesh>& iF,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
mixedFvPatchField<Type>(p, iF),
|
||||||
|
expressions::patchExprFieldBase(dict, true),
|
||||||
|
driver_(this->patch(), dict)
|
||||||
|
{
|
||||||
|
setDebug();
|
||||||
|
DebugInFunction << nl;
|
||||||
|
|
||||||
|
// Basic sanity checks
|
||||||
|
if (this->valueExpr_.empty() && this->gradExpr_.empty())
|
||||||
|
{
|
||||||
|
if (this->valueExpr_.empty())
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "The valueExpr was not defined!" << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
if (this->gradExpr_.empty())
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "The gradientExpr was not defined!" << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
driver_.readDict(dict);
|
||||||
|
|
||||||
|
// Similar to fvPatchField constructor, which we have bypassed
|
||||||
|
dict.readIfPresent("patchType", this->patchType());
|
||||||
|
|
||||||
|
if (dict.found("refValue"))
|
||||||
|
{
|
||||||
|
this->refValue() = Field<Type>("refValue", dict, p.size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->refValue() = this->patchInternalField();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dict.found("value"))
|
||||||
|
{
|
||||||
|
fvPatchField<Type>::operator=
|
||||||
|
(
|
||||||
|
Field<Type>("value", dict, p.size())
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!dict.found("refValue"))
|
||||||
|
{
|
||||||
|
// Ensure refValue has a sensible value for the "update" below
|
||||||
|
this->refValue() = Field<Type>("value", dict, p.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fvPatchField<Type>::operator=(this->refValue());
|
||||||
|
|
||||||
|
WarningInFunction
|
||||||
|
<< "No value defined for "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " on " << this->patch().name() << " therefore using "
|
||||||
|
<< "the internal field next to the patch"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (dict.found("refGradient"))
|
||||||
|
{
|
||||||
|
this->refGrad() = Field<Type>("refGradient", dict, p.size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->refGrad() = Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dict.found("valueFraction"))
|
||||||
|
{
|
||||||
|
this->valueFraction() = Field<scalar>("valueFraction", dict, p.size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->valueFraction() = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (this->evalOnConstruct_)
|
||||||
|
{
|
||||||
|
// For potentialFoam or other solvers that don't evaluate
|
||||||
|
this->evaluate();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Emulate mixedFvPatchField<Type>::evaluate,
|
||||||
|
// but avoid our own updateCoeffs
|
||||||
|
if (!this->updated())
|
||||||
|
{
|
||||||
|
this->mixedFvPatchField<Type>::updateCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
Field<Type>::operator=
|
||||||
|
(
|
||||||
|
this->valueFraction()*this->refValue()
|
||||||
|
+
|
||||||
|
(1.0 - this->valueFraction())*
|
||||||
|
(
|
||||||
|
this->patchInternalField()
|
||||||
|
+ this->refGrad()/this->patch().deltaCoeffs()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
fvPatchField<Type>::evaluate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprMixedFvPatchField<Type>::exprMixedFvPatchField
|
||||||
|
(
|
||||||
|
const exprMixedFvPatchField<Type>& ptf
|
||||||
|
)
|
||||||
|
:
|
||||||
|
mixedFvPatchField<Type>(ptf),
|
||||||
|
expressions::patchExprFieldBase(ptf),
|
||||||
|
driver_(this->patch(), ptf.driver_)
|
||||||
|
{
|
||||||
|
setDebug();
|
||||||
|
DebugInFunction << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprMixedFvPatchField<Type>::exprMixedFvPatchField
|
||||||
|
(
|
||||||
|
const exprMixedFvPatchField<Type>& ptf,
|
||||||
|
const DimensionedField<Type, volMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
mixedFvPatchField<Type>(ptf, iF),
|
||||||
|
expressions::patchExprFieldBase(ptf),
|
||||||
|
driver_(this->patch(), ptf.driver_)
|
||||||
|
{
|
||||||
|
setDebug();
|
||||||
|
DebugInFunction << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::exprMixedFvPatchField<Type>::updateCoeffs()
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
InfoInFunction
|
||||||
|
<< "Value: " << this->valueExpr_ << nl
|
||||||
|
<< "Gradient: " << this->gradExpr_ << nl
|
||||||
|
<< "Fraction: " << this->fracExpr_ << nl
|
||||||
|
<< "Variables: ";
|
||||||
|
|
||||||
|
driver_.writeVariableStrings(Info) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->updated())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugInFunction << " - updating" << nl;
|
||||||
|
|
||||||
|
|
||||||
|
// Expression evaluation
|
||||||
|
{
|
||||||
|
driver_.clearVariables();
|
||||||
|
|
||||||
|
if (this->valueExpr_.empty())
|
||||||
|
{
|
||||||
|
this->refValue() = Zero;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->refValue() = driver_.evaluate<Type>(this->valueExpr_);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool evalGrad = !this->gradExpr_.empty();
|
||||||
|
|
||||||
|
if (this->fracExpr_.empty() || this->fracExpr_ == "1")
|
||||||
|
{
|
||||||
|
evalGrad = false;
|
||||||
|
this->valueFraction() = scalar(1);
|
||||||
|
}
|
||||||
|
else if (this->fracExpr_ == "0")
|
||||||
|
{
|
||||||
|
this->valueFraction() = Zero;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->valueFraction() = driver_.evaluate<scalar>(this->fracExpr_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (evalGrad)
|
||||||
|
{
|
||||||
|
this->refGrad() = driver_.evaluate<Type>(this->gradExpr_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->refGrad() = Zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mixedFvPatchField<Type>::updateCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::exprMixedFvPatchField<Type>::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
mixedFvPatchField<Type>::write(os);
|
||||||
|
expressions::patchExprFieldBase::write(os);
|
||||||
|
|
||||||
|
// driver_.writeCommon(os, this->debug_ || debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,172 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Original code Copyright (C) 2009-2018 Bernhard Gschaider
|
||||||
|
Copyright (C) 2019 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::exprMixedFvPatchField
|
||||||
|
|
||||||
|
Description
|
||||||
|
Foam::exprMixedFvPatchField
|
||||||
|
|
||||||
|
Usage
|
||||||
|
\table
|
||||||
|
Property | Description | Required | Default
|
||||||
|
valueExpr | expression for fixed value | no | 0
|
||||||
|
gradientExpr | expression for patch normal gradient | no | 0
|
||||||
|
fractionExpr | expression for value weighting | no | 1
|
||||||
|
\endtable
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
exprMixedFvPatchField.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef exprMixedFvPatchField_H
|
||||||
|
#define exprMixedFvPatchField_H
|
||||||
|
|
||||||
|
#include "mixedFvPatchField.H"
|
||||||
|
#include "patchExprFieldBase.H"
|
||||||
|
#include "patchExprDriver.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class exprMixedFvPatchField Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
class exprMixedFvPatchField
|
||||||
|
:
|
||||||
|
public mixedFvPatchField<Type>,
|
||||||
|
public expressions::patchExprFieldBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Data
|
||||||
|
|
||||||
|
//- The expression driver
|
||||||
|
expressions::patchExpr::parseDriver driver_;
|
||||||
|
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Set debug ON if "debug" is enabled
|
||||||
|
void setDebug();
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("exprMixed");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from patch and internal field
|
||||||
|
exprMixedFvPatchField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<Type, volMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from patch, internal field and dictionary
|
||||||
|
exprMixedFvPatchField
|
||||||
|
(
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<Type, volMesh>&,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct by mapping given exprMixedFvPatchField onto a new patch
|
||||||
|
exprMixedFvPatchField
|
||||||
|
(
|
||||||
|
const exprMixedFvPatchField<Type>&,
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<Type, volMesh>&,
|
||||||
|
const fvPatchFieldMapper&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct as copy
|
||||||
|
exprMixedFvPatchField
|
||||||
|
(
|
||||||
|
const exprMixedFvPatchField<Type>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct and return a clone
|
||||||
|
virtual tmp<fvPatchField<Type>> clone() const
|
||||||
|
{
|
||||||
|
return tmp<fvPatchField<Type>>
|
||||||
|
(
|
||||||
|
new exprMixedFvPatchField<Type>(*this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Construct as copy setting internal field reference
|
||||||
|
exprMixedFvPatchField
|
||||||
|
(
|
||||||
|
const exprMixedFvPatchField<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 exprMixedFvPatchField<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 "exprMixedFvPatchField.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2019 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 "exprMixedFvPatchFields.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
makePatchFields(exprMixed);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2019 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 exprMixedFvPatchFields_H
|
||||||
|
#define exprMixedFvPatchFields_H
|
||||||
|
|
||||||
|
#include "exprMixedFvPatchField.H"
|
||||||
|
#include "fieldTypes.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
makePatchTypeFieldTypedefs(exprMixed);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2019 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 exprMixedFvPatchFieldsFwd_H
|
||||||
|
#define exprMixedFvPatchFieldsFwd_H
|
||||||
|
|
||||||
|
#include "fieldTypes.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type> class exprMixedFvPatchField;
|
||||||
|
|
||||||
|
makePatchTypeFieldTypedefs(exprMixed);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,219 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Original code Copyright (C) 2010-2018 Bernhard Gschaider
|
||||||
|
Copyright (C) 2019 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 "exprValuePointPatchField.H"
|
||||||
|
#include "pointPatchFieldMapper.H"
|
||||||
|
#include "typeInfo.H"
|
||||||
|
#include "facePointPatch.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprValuePointPatchField<Type>::exprValuePointPatchField
|
||||||
|
(
|
||||||
|
const pointPatch& p,
|
||||||
|
const DimensionedField<Type, pointMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
valuePointPatchField<Type>(p, iF),
|
||||||
|
expressions::patchExprFieldBase(false),
|
||||||
|
driver_
|
||||||
|
(
|
||||||
|
expressions::patchExprFieldBase::getFvPatch
|
||||||
|
(
|
||||||
|
dynamicCast<const facePointPatch>(this->patch())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprValuePointPatchField<Type>::exprValuePointPatchField
|
||||||
|
(
|
||||||
|
const exprValuePointPatchField<Type>& ptf,
|
||||||
|
const pointPatch& p,
|
||||||
|
const DimensionedField<Type, pointMesh>& iF,
|
||||||
|
const pointPatchFieldMapper& mapper
|
||||||
|
)
|
||||||
|
:
|
||||||
|
valuePointPatchField<Type>(ptf, p, iF, mapper),
|
||||||
|
expressions::patchExprFieldBase(ptf),
|
||||||
|
driver_
|
||||||
|
(
|
||||||
|
expressions::patchExprFieldBase::getFvPatch
|
||||||
|
(
|
||||||
|
dynamicCast<const facePointPatch>(this->patch())
|
||||||
|
),
|
||||||
|
ptf.driver_
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprValuePointPatchField<Type>::exprValuePointPatchField
|
||||||
|
(
|
||||||
|
const pointPatch& p,
|
||||||
|
const DimensionedField<Type, pointMesh>& iF,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
valuePointPatchField<Type>(p, iF),
|
||||||
|
expressions::patchExprFieldBase(dict, false, true),
|
||||||
|
driver_
|
||||||
|
(
|
||||||
|
expressions::patchExprFieldBase::getFvPatch
|
||||||
|
(
|
||||||
|
dynamicCast<const facePointPatch>(this->patch())
|
||||||
|
),
|
||||||
|
dict
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Basic sanity
|
||||||
|
if (this->valueExpr_.empty())
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "The valueExpr was not defined!" << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
driver_.readDict(dict);
|
||||||
|
|
||||||
|
if (dict.found("value"))
|
||||||
|
{
|
||||||
|
Field<Type>::operator=
|
||||||
|
(
|
||||||
|
Field<Type>("value", dict, p.size())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "No value defined for "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " on " << this->patch().name()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->evalOnConstruct_)
|
||||||
|
{
|
||||||
|
// For potentialFoam or other solvers that don't evaluate
|
||||||
|
this->evaluate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprValuePointPatchField<Type>::exprValuePointPatchField
|
||||||
|
(
|
||||||
|
const exprValuePointPatchField<Type>& ptf,
|
||||||
|
const DimensionedField<Type, pointMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
valuePointPatchField<Type>(ptf, iF),
|
||||||
|
expressions::patchExprFieldBase(ptf),
|
||||||
|
driver_
|
||||||
|
(
|
||||||
|
expressions::patchExprFieldBase::getFvPatch
|
||||||
|
(
|
||||||
|
dynamicCast<const facePointPatch>(this->patch())
|
||||||
|
),
|
||||||
|
ptf.driver_
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::exprValuePointPatchField<Type>::exprValuePointPatchField
|
||||||
|
(
|
||||||
|
const exprValuePointPatchField<Type>& ptf
|
||||||
|
)
|
||||||
|
:
|
||||||
|
valuePointPatchField<Type>(ptf),
|
||||||
|
expressions::patchExprFieldBase(ptf),
|
||||||
|
driver_
|
||||||
|
(
|
||||||
|
expressions::patchExprFieldBase::getFvPatch
|
||||||
|
(
|
||||||
|
dynamicCast<const facePointPatch>(this->patch())
|
||||||
|
),
|
||||||
|
ptf.driver_
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::exprValuePointPatchField<Type>::updateCoeffs()
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
InfoInFunction
|
||||||
|
<< "Value: " << this->valueExpr_ << nl
|
||||||
|
<< "Variables: ";
|
||||||
|
driver_.writeVariableStrings(Info) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->updated())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expression evaluation
|
||||||
|
{
|
||||||
|
driver_.clearVariables();
|
||||||
|
|
||||||
|
if (this->valueExpr_.empty())
|
||||||
|
{
|
||||||
|
(*this) == Zero;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Field<Type>::operator=
|
||||||
|
(
|
||||||
|
driver_.evaluate<Type>(this->valueExpr_, true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
valuePointPatchField<Type>::updateCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::exprValuePointPatchField<Type>::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
valuePointPatchField<Type>::write(os);
|
||||||
|
expressions::patchExprFieldBase::write(os);
|
||||||
|
|
||||||
|
this->writeEntry("value",os);
|
||||||
|
|
||||||
|
// driver_.writeCommon(os,this->debug_ || debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,175 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Original code Copyright (C) 2010-2018 Bernhard Gschaider
|
||||||
|
Copyright (C) 2019 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::exprValuePointPatchField
|
||||||
|
|
||||||
|
Description
|
||||||
|
A fixed value boundary condition with expressions.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
\table
|
||||||
|
Property | Description | Required | Default
|
||||||
|
value | fixed value | yes |
|
||||||
|
valueExpr | expression for fixed value | yes |
|
||||||
|
\endtable
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
exprValuePointPatchField.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef exprValuePointPatchField_H
|
||||||
|
#define exprValuePointPatchField_H
|
||||||
|
|
||||||
|
#include "valuePointPatchField.H"
|
||||||
|
#include "patchExprFieldBase.H"
|
||||||
|
#include "patchExprDriver.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class exprValuePointPatchField Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
class exprValuePointPatchField
|
||||||
|
:
|
||||||
|
public valuePointPatchField<Type>,
|
||||||
|
public expressions::patchExprFieldBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Data
|
||||||
|
|
||||||
|
//- The expression driver
|
||||||
|
expressions::patchExpr::parseDriver driver_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("exprValue");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from patch and internal field
|
||||||
|
exprValuePointPatchField
|
||||||
|
(
|
||||||
|
const pointPatch&,
|
||||||
|
const DimensionedField<Type, pointMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from patch, internal field and dictionary
|
||||||
|
exprValuePointPatchField
|
||||||
|
(
|
||||||
|
const pointPatch&,
|
||||||
|
const DimensionedField<Type, pointMesh>&,
|
||||||
|
const dictionary&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct by mapping given patchField<Type> onto a new patch
|
||||||
|
exprValuePointPatchField
|
||||||
|
(
|
||||||
|
const exprValuePointPatchField<Type>&,
|
||||||
|
const pointPatch&,
|
||||||
|
const DimensionedField<Type, pointMesh>&,
|
||||||
|
const pointPatchFieldMapper&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct as copy setting internal field reference
|
||||||
|
exprValuePointPatchField
|
||||||
|
(
|
||||||
|
const exprValuePointPatchField<Type>&,
|
||||||
|
const DimensionedField<Type, pointMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct as copy
|
||||||
|
exprValuePointPatchField
|
||||||
|
(
|
||||||
|
const exprValuePointPatchField<Type>&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Construct and return a clone
|
||||||
|
virtual autoPtr<pointPatchField<Type> > clone() const
|
||||||
|
{
|
||||||
|
return autoPtr<pointPatchField<Type>>
|
||||||
|
(
|
||||||
|
new exprValuePointPatchField<Type>
|
||||||
|
(
|
||||||
|
*this
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Construct and return a clone setting internal field reference
|
||||||
|
virtual autoPtr<pointPatchField<Type>> clone
|
||||||
|
(
|
||||||
|
const DimensionedField<Type, pointMesh>& iF
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return autoPtr<pointPatchField<Type>>
|
||||||
|
(
|
||||||
|
new exprValuePointPatchField<Type>
|
||||||
|
(
|
||||||
|
*this,
|
||||||
|
iF
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Update the patch field
|
||||||
|
virtual void updateCoeffs();
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
virtual void write(Ostream& os) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "exprValuePointPatchField.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2019 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 "exprValuePointPatchFields.H"
|
||||||
|
#include "pointPatchFields.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
makePointPatchFields(exprValue);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2019 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 exprValuePointPatchFields_H
|
||||||
|
#define exprValuePointPatchFields_H
|
||||||
|
|
||||||
|
#include "exprValuePointPatchField.H"
|
||||||
|
#include "fieldTypes.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
makePointPatchFieldTypedefs(exprValue);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user