Commit 1bf31fb9 authored by Will Bainbridge's avatar Will Bainbridge Committed by Andrew Heather
Browse files

ENH: semiPermeableBaffle: Added two new boundary conditions and a tutorial

Two boundary conditions for the modelling of semi-permeable baffles have
been added. These baffles are permeable to a number of species within
the flow, and are impermeable to others. The flux of a given species is
calculated as a constant multipled by the drop in mass fraction across
the baffle.

The species mass-fraction condition requires the transfer constant and
the name of the patch on the other side of the baffle:

boundaryField
{
    // ...

    membraneA
    {
        type            semiPermeableBaffleMassFraction;
        samplePatch     membranePipe;
        c               0.1;
        value           uniform 0;
    }
    membraneB
    {
        type            semiPermeableBaffleMassFraction;
        samplePatch     membraneSleeve;
        c               0.1;
        value           uniform 1;
    }
}

If the value of c is omitted, or set to zero, then the patch is
considered impermeable to the species in question. The samplePatch entry
can also be omitted in this case.

The velocity condition does not require any special input:

boundaryField
{
    // ...

    membraneA
    {
        type            semiPermeableBaffleVelocity;
        value           uniform (0 0 0);
    }
    membraneB
    {
        type            semiPermeableBaffleVelocity;
        value           uniform (0 0 0);
    }
}

These two boundary conditions must be used in conjunction, and the
mass-fraction condition must be applied to all species in the
simulation. The calculation will fail with an error message if either is
used in isolation.

A tutorial, combustion/reactingFoam/RAS/membrane, has been added which
demonstrates this transfer process.

This work was done with support from Stefan Lipp, at BASF.
parent 861b97bf
......@@ -81,6 +81,7 @@ wmake $targetType sixDoFRigidBodyMotion
wmake $targetType sixDoFRigidBodyState
wmake $targetType rigidBodyDynamics
wmake $targetType rigidBodyMeshMotion
wmake $targetType semiPermeableBaffle
# Needs access to Turbulence
......
derivedFvPatchFields/semiPermeableBaffleMassFraction/semiPermeableBaffleMassFractionFvPatchScalarField.C
derivedFvPatchFields/semiPermeableBaffleVelocity/semiPermeableBaffleVelocityFvPatchVectorField.C
LIB = $(FOAM_LIBBIN)/libsemiPermeableBaffle
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lspecie \
-lreactionThermophysicalModels \
-lturbulenceModels
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 "semiPermeableBaffleMassFractionFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "turbulenceModel.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::semiPermeableBaffleMassFractionFvPatchScalarField::
semiPermeableBaffleMassFractionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
mappedPatchBase(p.patch()),
mixedFvPatchScalarField(p, iF),
c_(0),
phiName_("phi")
{
refValue() = Zero;
refGrad() = Zero;
valueFraction() = Zero;
}
Foam::semiPermeableBaffleMassFractionFvPatchScalarField::
semiPermeableBaffleMassFractionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
mappedPatchBase(p.patch(), NEARESTPATCHFACE, dict),
mixedFvPatchScalarField(p, iF),
c_(dict.lookupOrDefault<scalar>("c", scalar(0))),
phiName_(dict.lookupOrDefault<word>("phi", "phi"))
{
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
refValue() = Zero;
refGrad() = Zero;
valueFraction() = Zero;
}
Foam::semiPermeableBaffleMassFractionFvPatchScalarField::
semiPermeableBaffleMassFractionFvPatchScalarField
(
const semiPermeableBaffleMassFractionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
mappedPatchBase(p.patch(), ptf),
mixedFvPatchScalarField(ptf, p, iF, mapper),
c_(ptf.c_),
phiName_(ptf.phiName_)
{}
Foam::semiPermeableBaffleMassFractionFvPatchScalarField::
semiPermeableBaffleMassFractionFvPatchScalarField
(
const semiPermeableBaffleMassFractionFvPatchScalarField& ptf
)
:
mappedPatchBase(ptf.patch().patch(), ptf),
mixedFvPatchScalarField(ptf),
c_(ptf.c_),
phiName_(ptf.phiName_)
{}
Foam::semiPermeableBaffleMassFractionFvPatchScalarField::
semiPermeableBaffleMassFractionFvPatchScalarField
(
const semiPermeableBaffleMassFractionFvPatchScalarField& ptf,
const DimensionedField<scalar, volMesh>& iF
)
:
mappedPatchBase(ptf.patch().patch(), ptf),
mixedFvPatchScalarField(ptf, iF),
c_(ptf.c_),
phiName_(ptf.phiName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField>
Foam::semiPermeableBaffleMassFractionFvPatchScalarField::phiY() const
{
if (c_ == scalar(0))
{
return tmp<scalarField>(new scalarField(patch().size(), Zero));
}
const word& YName = internalField().name();
const label nbrPatchi = samplePolyPatch().index();
const fvPatch& nbrPatch = patch().boundaryMesh()[nbrPatchi];
const fvPatchScalarField& nbrYp =
nbrPatch.lookupPatchField<volScalarField, scalar>(YName);
scalarField nbrYc(nbrYp.patchInternalField());
mappedPatchBase::map().distribute(nbrYc);
return c_*patch().magSf()*(patchInternalField() - nbrYc);
}
void Foam::semiPermeableBaffleMassFractionFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
const scalarField& phip =
patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
const turbulenceModel& turbModel =
db().lookupObject<turbulenceModel>
(
turbulenceModel::propertiesName
);
const scalarField muEffp(turbModel.muEff(patch().index()));
const scalarField AMuEffp(patch().magSf()*muEffp);
valueFraction() = phip/(phip - patch().deltaCoeffs()*AMuEffp);
refGrad() = - phiY()/AMuEffp;
mixedFvPatchScalarField::updateCoeffs();
}
void Foam::semiPermeableBaffleMassFractionFvPatchScalarField::write
(
Ostream& os
) const
{
fvPatchScalarField::write(os);
mappedPatchBase::write(os);
writeEntryIfDifferent<scalar>(os, "c", scalar(0), c_);
writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * Build Macro Function * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
semiPermeableBaffleMassFractionFvPatchScalarField
);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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/>.
Class
Foam::semiPermeableBaffleMassFractionFvPatchScalarField
Group
grpGenericBoundaryConditions
Description
This is a mass-fraction boundary condition for a semi-permeable baffle.
This condition models a baffle which is permeable to a some species and
impermeable to others. It must be used in conjunction with the
corresponding velocity condition,
semiPermeableBaffleVelocityFvPatchVectorField.
The mass flux of a species is calculated as a coefficient multiplied by the
difference in mass fraction across the baffle.
\f[
\phi_{Yi} = c A (Y_i - Y_{i,n})
\f]
where
\vartable
\phi_{Yi} | flux of the permeable species [kg/s]
c | transfer coefficient [kg/m2/s]
A | patch face area [m2]
Y_i | mass fraction on the patch []
Y_{i,n} | mass fraction on the neighbour patch []
\endvartable
A species that the baffle is permable to will, therefore, have a
coefficient greater than zero, whilst a species that does not transfer will
have a coefficient equal to zero.
This condition calculates the species flux. The fluxes are summed up by the
velocity consition to generate the net mass transfer across the baffle.
This mass-fraction condition then generates a corrective diffusive flux to
ensure that the correct amounts of the permeable species are transferred.
Usage
\table
Property | Description | Req'd? | Default
c | Transfer coefficient | no | 0
phi | Name of the flux field | no | phi
\endtable
See also
Foam::semiPermeableBaffleVelocityFvPatchVectorField
SourceFiles
semiPermeableBaffleMassFractionFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef semiPermeableBaffleMassFractionFvPatchScalarField_H
#define semiPermeableBaffleMassFractionFvPatchScalarField_H
#include "mappedPatchBase.H"
#include "mixedFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class semiPermeableBaffleMassFractionFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class semiPermeableBaffleMassFractionFvPatchScalarField
:
public mappedPatchBase,
public mixedFvPatchScalarField
{
// Private data
//- Transfer coefficient
const scalar c_;
//- Name of the flux field
const word phiName_;
public:
//- Runtime type information
TypeName("semiPermeableBaffleMassFraction");
// Constructors
//- Construct from patch and internal field
semiPermeableBaffleMassFractionFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
semiPermeableBaffleMassFractionFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given fixedValueTypeFvPatchField
// onto a new patch
semiPermeableBaffleMassFractionFvPatchScalarField
(
const semiPermeableBaffleMassFractionFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
semiPermeableBaffleMassFractionFvPatchScalarField
(
const semiPermeableBaffleMassFractionFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new semiPermeableBaffleMassFractionFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
semiPermeableBaffleMassFractionFvPatchScalarField
(
const semiPermeableBaffleMassFractionFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new semiPermeableBaffleMassFractionFvPatchScalarField
(
*this,
iF
)
);
}
// Member functions
// Evaluation functions
//- Return the flux of this species through the baffle
tmp<scalarField> phiY() const;
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 "semiPermeableBaffleVelocityFvPatchVectorField.H"
#include "semiPermeableBaffleMassFractionFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "psiReactionThermo.H"
#include "rhoReactionThermo.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const Foam::basicSpecieMixture&
Foam::semiPermeableBaffleVelocityFvPatchVectorField::composition() const
{
const word& name = basicThermo::dictName;
if (db().foundObject<psiReactionThermo>(name))
{
return db().lookupObject<psiReactionThermo>(name).composition();
}
else if (db().foundObject<rhoReactionThermo>(name))
{
return db().lookupObject<rhoReactionThermo>(name).composition();
}
else
{
FatalErrorInFunction
<< "Could not find a multi-component thermodynamic model."
<< exit(FatalError);
return NullObjectRef<basicSpecieMixture>();
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::semiPermeableBaffleVelocityFvPatchVectorField::
semiPermeableBaffleVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(p, iF),
rhoName_("rho")
{}
Foam::semiPermeableBaffleVelocityFvPatchVectorField::
semiPermeableBaffleVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchVectorField(p, iF),
rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
{
fvPatchVectorField::operator==(vectorField("value", dict, p.size()));
}
Foam::semiPermeableBaffleVelocityFvPatchVectorField::
semiPermeableBaffleVelocityFvPatchVectorField
(
const semiPermeableBaffleVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchVectorField(ptf, p, iF, mapper),
rhoName_(ptf.rhoName_)
{}
Foam::semiPermeableBaffleVelocityFvPatchVectorField::
semiPermeableBaffleVelocityFvPatchVectorField
(
const semiPermeableBaffleVelocityFvPatchVectorField& ptf
)
:
fixedValueFvPatchVectorField(ptf),
rhoName_(ptf.rhoName_)
{}
Foam::semiPermeableBaffleVelocityFvPatchVectorField::
semiPermeableBaffleVelocityFvPatchVectorField
(
const semiPermeableBaffleVelocityFvPatchVectorField& ptf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(ptf, iF),
rhoName_(ptf.rhoName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::semiPermeableBaffleVelocityFvPatchVectorField::updateCoeffs()
{
if (updated())
{