Commit 6db445c8 authored by Henry Weller's avatar Henry Weller
Browse files

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.
parent f7667ae0
......@@ -49,11 +49,8 @@ $(interRegion)/interRegionExplicitPorositySource/interRegionExplicitPorositySour
/* Constraints */
generalConstraints=constraints/general
$(generalConstraints)/explicitSetValue/explicitSetValue.C
derivedConstraints=constraints/derived
$(derivedConstraints)/fixedTemperatureConstraint/fixedTemperatureConstraint.C
constraints/fixedValueConstraint/fixedValueConstraints.C
constraints/fixedTemperatureConstraint/fixedTemperatureConstraint.C
/* Corrections */
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -23,35 +23,15 @@ License
\*---------------------------------------------------------------------------*/
#include "ExplicitSetValue.H"
#include "FixedValueConstraint.H"
#include "fvMesh.H"
#include "fvMatrices.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 * * * * * * * * * * * * * * //
template<class Type>
Foam::fv::ExplicitSetValue<Type>::ExplicitSetValue
Foam::fv::FixedValueConstraint<Type>::FixedValueConstraint
(
const word& name,
const word& modelType,
......@@ -59,8 +39,7 @@ Foam::fv::ExplicitSetValue<Type>::ExplicitSetValue
const fvMesh& mesh
)
:
cellSetOption(name, modelType, dict, mesh),
injectionRate_()
cellSetOption(name, modelType, dict, mesh)
{
read(dict);
}
......@@ -69,21 +48,47 @@ Foam::fv::ExplicitSetValue<Type>::ExplicitSetValue
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
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,
const label fieldi
)
{
if (debug)
{
Info<< "ExplicitSetValue<"<< pTraits<Type>::typeName
<< ">::constrain for source " << name_ << endl;
}
List<Type> values(cells_.size(), injectionRate_[fieldi]);
DebugInfo
<< "FixedValueConstraint<"
<< pTraits<Type>::typeName
<< ">::constrain for source " << name_ << endl;
eqn.setValues(cells_, values);
eqn.setValues(cells_, List<Type>(cells_.size(), fieldValues_[fieldi]));
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -22,20 +22,27 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fv::explicitSetValue
Foam::fv::FixedValueConstraint
Description
Set values field values explicity.
Sources described by:
Constrain the field values within a specified region.
For example to set the turbulence properties within a porous region:
\verbatim
<Type>ExplicitSetValueCoeffs
porosityTurbulence
{
injectionRate
type scalarFixedValueConstraint;
active yes;
scalarFixedValueConstraintCoeffs
{
k 30.7;
epsilon 1.5;
selectionMode cellZone;
cellZone porosity;
fieldValues
{
k 1;
epsilon 150;
}
}
}
\endverbatim
......@@ -44,15 +51,15 @@ SeeAlso
Foam::fvOption
SourceFiles
explicitSetValue.C
FixedValueConstraint.C
fixedValueConstraints.C
\*---------------------------------------------------------------------------*/
#ifndef ExplicitSetValue_H
#define ExplicitSetValue_H
#ifndef FixedValueConstraint_H
#define FixedValueConstraint_H
#include "cellSetOption.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -62,39 +69,30 @@ namespace fv
{
/*---------------------------------------------------------------------------*\
Class explicitSetValue Declaration
Class FixedValueConstraint Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class ExplicitSetValue
class FixedValueConstraint
:
public cellSetOption
{
// Private member data
protected:
// Protected data
//- Source value per field
List<Type> injectionRate_;
// Protected functions
//- Set the local field data
void setFieldData(const dictionary& dict);
//- Field values
List<Type> fieldValues_;
public:
//- Runtime type information
TypeName("explicitSetValue");
TypeName("FixedValueConstraint");
// Constructors
//- Construct from components
ExplicitSetValue
FixedValueConstraint
(
const word& name,
const word& modelType,
......@@ -105,16 +103,11 @@ public:
// Member Functions
// Evaluation
//- Set value on field
virtual void constrain(fvMatrix<Type>& eqn, const label fieldi);
// IO
//- Read source dictionary
virtual bool read(const dictionary& dict);
//- Read source dictionary
virtual bool read(const dictionary& dict);
//- Set value on field
virtual void constrain(fvMatrix<Type>& eqn, const label fieldi);
};
......@@ -126,8 +119,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "ExplicitSetValue.C"
#include "ExplicitSetValueIO.C"
#include "FixedValueConstraint.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,15 +24,14 @@ License
\*---------------------------------------------------------------------------*/
#include "makeFvOption.H"
#include "ExplicitSetValue.H"
#include "FixedValueConstraint.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makeFvOption(ExplicitSetValue, scalar);
makeFvOption(ExplicitSetValue, vector);
makeFvOption(ExplicitSetValue, sphericalTensor);
makeFvOption(ExplicitSetValue, symmTensor);
makeFvOption(ExplicitSetValue, tensor);
makeFvOption(FixedValueConstraint, scalar);
makeFvOption(FixedValueConstraint, vector);
makeFvOption(FixedValueConstraint, sphericalTensor);
makeFvOption(FixedValueConstraint, symmTensor);
makeFvOption(FixedValueConstraint, tensor);
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
{
type fixedTemperatureConstraint;
active yes;
fixedTemperatureConstraintCoeffs
{
selectionMode cellZone;
cellZone porosity;
mode uniform;
temperature 350;
}
}
porosity1
porosity
{
type explicitPorositySource;
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;
}
}
}
// ************************************************************************* //
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment