mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
fvOptions/constraints/fixedValueConstraint: Replacement for the nonsensical ExplicitSetValue
Description
Constrain the field values within a specified region.
For example to set the turbulence properties within a porous region:
\verbatim
porosityTurbulence
{
type scalarFixedValueConstraint;
active yes;
scalarFixedValueConstraintCoeffs
{
selectionMode cellZone;
cellZone porosity;
fieldValues
{
k 30.7;
epsilon 1.5;
}
}
}
\endverbatim
See tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff
constant/fvOptions for an example of this fvOption in action.
This commit is contained in:
@ -49,11 +49,8 @@ $(interRegion)/interRegionExplicitPorositySource/interRegionExplicitPorositySour
|
|||||||
|
|
||||||
/* Constraints */
|
/* Constraints */
|
||||||
|
|
||||||
generalConstraints=constraints/general
|
constraints/fixedValueConstraint/fixedValueConstraints.C
|
||||||
$(generalConstraints)/explicitSetValue/explicitSetValue.C
|
constraints/fixedTemperatureConstraint/fixedTemperatureConstraint.C
|
||||||
|
|
||||||
derivedConstraints=constraints/derived
|
|
||||||
$(derivedConstraints)/fixedTemperatureConstraint/fixedTemperatureConstraint.C
|
|
||||||
|
|
||||||
|
|
||||||
/* Corrections */
|
/* Corrections */
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,35 +23,15 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "ExplicitSetValue.H"
|
#include "FixedValueConstraint.H"
|
||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
#include "fvMatrices.H"
|
#include "fvMatrices.H"
|
||||||
#include "DimensionedField.H"
|
#include "DimensionedField.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::fv::ExplicitSetValue<Type>::setFieldData(const dictionary& dict)
|
|
||||||
{
|
|
||||||
fieldNames_.setSize(dict.toc().size());
|
|
||||||
injectionRate_.setSize(fieldNames_.size());
|
|
||||||
|
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
|
|
||||||
label i = 0;
|
|
||||||
forAllConstIter(dictionary, dict, iter)
|
|
||||||
{
|
|
||||||
fieldNames_[i] = iter().keyword();
|
|
||||||
dict.lookup(iter().keyword()) >> injectionRate_[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::fv::ExplicitSetValue<Type>::ExplicitSetValue
|
Foam::fv::FixedValueConstraint<Type>::FixedValueConstraint
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const word& modelType,
|
const word& modelType,
|
||||||
@ -59,8 +39,7 @@ Foam::fv::ExplicitSetValue<Type>::ExplicitSetValue
|
|||||||
const fvMesh& mesh
|
const fvMesh& mesh
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
cellSetOption(name, modelType, dict, mesh),
|
cellSetOption(name, modelType, dict, mesh)
|
||||||
injectionRate_()
|
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
}
|
}
|
||||||
@ -69,21 +48,47 @@ Foam::fv::ExplicitSetValue<Type>::ExplicitSetValue
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::fv::ExplicitSetValue<Type>::constrain
|
bool Foam::fv::FixedValueConstraint<Type>::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (cellSetOption::read(dict))
|
||||||
|
{
|
||||||
|
const dictionary& fieldValuesDict = coeffs_.subDict("fieldValues");
|
||||||
|
|
||||||
|
fieldNames_.setSize(fieldValuesDict.size());
|
||||||
|
fieldValues_.setSize(fieldNames_.size());
|
||||||
|
|
||||||
|
label i = 0;
|
||||||
|
forAllConstIter(dictionary, fieldValuesDict, iter)
|
||||||
|
{
|
||||||
|
fieldNames_[i] = iter().keyword();
|
||||||
|
fieldValuesDict.lookup(iter().keyword()) >> fieldValues_[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
applied_.setSize(fieldNames_.size(), false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::fv::FixedValueConstraint<Type>::constrain
|
||||||
(
|
(
|
||||||
fvMatrix<Type>& eqn,
|
fvMatrix<Type>& eqn,
|
||||||
const label fieldi
|
const label fieldi
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "FixedValueConstraint<"
|
||||||
Info<< "ExplicitSetValue<"<< pTraits<Type>::typeName
|
<< pTraits<Type>::typeName
|
||||||
<< ">::constrain for source " << name_ << endl;
|
<< ">::constrain for source " << name_ << endl;
|
||||||
}
|
|
||||||
|
|
||||||
List<Type> values(cells_.size(), injectionRate_[fieldi]);
|
eqn.setValues(cells_, List<Type>(cells_.size(), fieldValues_[fieldi]));
|
||||||
|
|
||||||
eqn.setValues(cells_, values);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -22,20 +22,27 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fv::explicitSetValue
|
Foam::fv::FixedValueConstraint
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Set values field values explicity.
|
Constrain the field values within a specified region.
|
||||||
|
|
||||||
Sources described by:
|
|
||||||
|
|
||||||
|
For example to set the turbulence properties within a porous region:
|
||||||
\verbatim
|
\verbatim
|
||||||
<Type>ExplicitSetValueCoeffs
|
porosityTurbulence
|
||||||
{
|
{
|
||||||
injectionRate
|
type scalarFixedValueConstraint;
|
||||||
|
active yes;
|
||||||
|
|
||||||
|
scalarFixedValueConstraintCoeffs
|
||||||
{
|
{
|
||||||
k 30.7;
|
selectionMode cellZone;
|
||||||
epsilon 1.5;
|
cellZone porosity;
|
||||||
|
fieldValues
|
||||||
|
{
|
||||||
|
k 1;
|
||||||
|
epsilon 150;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
@ -44,15 +51,15 @@ SeeAlso
|
|||||||
Foam::fvOption
|
Foam::fvOption
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
explicitSetValue.C
|
FixedValueConstraint.C
|
||||||
|
fixedValueConstraints.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef ExplicitSetValue_H
|
#ifndef FixedValueConstraint_H
|
||||||
#define ExplicitSetValue_H
|
#define FixedValueConstraint_H
|
||||||
|
|
||||||
#include "cellSetOption.H"
|
#include "cellSetOption.H"
|
||||||
#include "Tuple2.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -62,39 +69,30 @@ namespace fv
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class explicitSetValue Declaration
|
Class FixedValueConstraint Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
class ExplicitSetValue
|
class FixedValueConstraint
|
||||||
:
|
:
|
||||||
public cellSetOption
|
public cellSetOption
|
||||||
{
|
{
|
||||||
|
// Private member data
|
||||||
|
|
||||||
protected:
|
//- Field values
|
||||||
|
List<Type> fieldValues_;
|
||||||
// Protected data
|
|
||||||
|
|
||||||
//- Source value per field
|
|
||||||
List<Type> injectionRate_;
|
|
||||||
|
|
||||||
|
|
||||||
// Protected functions
|
|
||||||
|
|
||||||
//- Set the local field data
|
|
||||||
void setFieldData(const dictionary& dict);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
TypeName("explicitSetValue");
|
TypeName("FixedValueConstraint");
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
ExplicitSetValue
|
FixedValueConstraint
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const word& modelType,
|
const word& modelType,
|
||||||
@ -105,16 +103,11 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Evaluation
|
//- Read source dictionary
|
||||||
|
virtual bool read(const dictionary& dict);
|
||||||
|
|
||||||
//- Set value on field
|
//- Set value on field
|
||||||
virtual void constrain(fvMatrix<Type>& eqn, const label fieldi);
|
virtual void constrain(fvMatrix<Type>& eqn, const label fieldi);
|
||||||
|
|
||||||
|
|
||||||
// IO
|
|
||||||
|
|
||||||
//- Read source dictionary
|
|
||||||
virtual bool read(const dictionary& dict);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -126,8 +119,7 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "ExplicitSetValue.C"
|
#include "FixedValueConstraint.C"
|
||||||
#include "ExplicitSetValueIO.C"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -24,15 +24,14 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "makeFvOption.H"
|
#include "makeFvOption.H"
|
||||||
#include "ExplicitSetValue.H"
|
#include "FixedValueConstraint.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
makeFvOption(ExplicitSetValue, scalar);
|
makeFvOption(FixedValueConstraint, scalar);
|
||||||
makeFvOption(ExplicitSetValue, vector);
|
makeFvOption(FixedValueConstraint, vector);
|
||||||
makeFvOption(ExplicitSetValue, sphericalTensor);
|
makeFvOption(FixedValueConstraint, sphericalTensor);
|
||||||
makeFvOption(ExplicitSetValue, symmTensor);
|
makeFvOption(FixedValueConstraint, symmTensor);
|
||||||
makeFvOption(ExplicitSetValue, tensor);
|
makeFvOption(FixedValueConstraint, tensor);
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -1,45 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
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 "ExplicitSetValue.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
bool Foam::fv::ExplicitSetValue<Type>::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
if (cellSetOption::read(dict))
|
|
||||||
{
|
|
||||||
setFieldData(coeffs_.subDict("injectionRate"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -15,22 +15,7 @@ FoamFile
|
|||||||
}
|
}
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
fixedTemperaure1
|
porosity
|
||||||
{
|
|
||||||
type fixedTemperatureConstraint;
|
|
||||||
active yes;
|
|
||||||
|
|
||||||
fixedTemperatureConstraintCoeffs
|
|
||||||
{
|
|
||||||
selectionMode cellZone;
|
|
||||||
cellZone porosity;
|
|
||||||
mode uniform;
|
|
||||||
temperature 350;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
porosity1
|
|
||||||
{
|
{
|
||||||
type explicitPorositySource;
|
type explicitPorositySource;
|
||||||
active yes;
|
active yes;
|
||||||
@ -65,4 +50,37 @@ porosity1
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fixedTemperature
|
||||||
|
{
|
||||||
|
type fixedTemperatureConstraint;
|
||||||
|
active yes;
|
||||||
|
|
||||||
|
fixedTemperatureConstraintCoeffs
|
||||||
|
{
|
||||||
|
selectionMode cellZone;
|
||||||
|
cellZone porosity;
|
||||||
|
mode uniform;
|
||||||
|
temperature 350;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
porosityTurbulence
|
||||||
|
{
|
||||||
|
type scalarFixedValueConstraint;
|
||||||
|
active yes;
|
||||||
|
|
||||||
|
scalarFixedValueConstraintCoeffs
|
||||||
|
{
|
||||||
|
selectionMode cellZone;
|
||||||
|
cellZone porosity;
|
||||||
|
fieldValues
|
||||||
|
{
|
||||||
|
k 1;
|
||||||
|
epsilon 150;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user