mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added new interRegionExplicitPorositySource
This commit is contained in:
@ -28,11 +28,12 @@ $(derivedSources)/rotorDiskSource/trimModel/trimModel/trimModelNew.C
|
|||||||
$(derivedSources)/rotorDiskSource/trimModel/fixed/fixedTrim.C
|
$(derivedSources)/rotorDiskSource/trimModel/fixed/fixedTrim.C
|
||||||
$(derivedSources)/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C
|
$(derivedSources)/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C
|
||||||
|
|
||||||
interRegion = $(derivedSources)/interRegionHeatTransferModel
|
interRegion = sources/interRegion
|
||||||
$(interRegion)/constantHeatTransfer/constantHeatTransfer.C
|
$(interRegion)/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.C
|
||||||
$(interRegion)/interRegionHeatTransferModel/interRegionHeatTransferModel.C
|
$(interRegion)/interRegionHeatTransferModel/interRegionHeatTransferModel/interRegionHeatTransferModel.C
|
||||||
$(interRegion)/tabulatedHeatTransfer/tabulatedHeatTransfer.C
|
$(interRegion)/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.C
|
||||||
$(interRegion)/variableHeatTransfer/variableHeatTransfer.C
|
$(interRegion)/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.C
|
||||||
|
$(interRegion)/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C
|
||||||
|
|
||||||
|
|
||||||
/* constraints */
|
/* constraints */
|
||||||
|
|||||||
@ -0,0 +1,227 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 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, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
\*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "interRegionExplicitPorositySource.H"
|
||||||
|
#include "fvMesh.H"
|
||||||
|
#include "fvMatrices.H"
|
||||||
|
#include "porosityModel.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace fv
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(interRegionExplicitPorositySource, 0);
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
option,
|
||||||
|
interRegionExplicitPorositySource,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::interRegionExplicitPorositySource::initialise()
|
||||||
|
{
|
||||||
|
if (!firstIter_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fvMesh& nbrMesh =
|
||||||
|
const_cast<fvMesh&>(mesh_.time().lookupObject<fvMesh>(nbrRegionName_));
|
||||||
|
|
||||||
|
cellZoneMesh& cellZones = nbrMesh.cellZones();
|
||||||
|
|
||||||
|
const word zoneName(name_ + ".porous");
|
||||||
|
label zoneID = cellZones.findZoneID(zoneName);
|
||||||
|
|
||||||
|
if (zoneID == -1)
|
||||||
|
{
|
||||||
|
zoneID = cellZones.size();
|
||||||
|
|
||||||
|
cellZones.setSize(zoneID + 1);
|
||||||
|
|
||||||
|
cellZones.set
|
||||||
|
(
|
||||||
|
zoneID,
|
||||||
|
new cellZone
|
||||||
|
(
|
||||||
|
zoneName,
|
||||||
|
nbrMesh.faceNeighbour(), // neighbour internal cells
|
||||||
|
zoneID,
|
||||||
|
cellZones
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
cellZones.clearAddressing();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"void Foam::fv::interRegionExplicitPorositySource::initialise()"
|
||||||
|
)
|
||||||
|
<< "Unable to create porous cellZone " << zoneName
|
||||||
|
<< ": zone already exists"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
porosityPtr_.reset
|
||||||
|
(
|
||||||
|
porosityModel::New
|
||||||
|
(
|
||||||
|
name_,
|
||||||
|
nbrMesh,
|
||||||
|
coeffs_,
|
||||||
|
zoneName
|
||||||
|
).ptr()
|
||||||
|
),
|
||||||
|
|
||||||
|
fieldNames_.setSize(1, UName_);
|
||||||
|
applied_.setSize(1, false);
|
||||||
|
|
||||||
|
firstIter_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fv::interRegionExplicitPorositySource::interRegionExplicitPorositySource
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const word& modelType,
|
||||||
|
const dictionary& dict,
|
||||||
|
const fvMesh& mesh
|
||||||
|
)
|
||||||
|
:
|
||||||
|
option(name, modelType, dict, mesh, true),
|
||||||
|
porosityPtr_(NULL),
|
||||||
|
firstIter_(-1),
|
||||||
|
UName_(coeffs_.lookupOrDefault<word>("UName", "U")),
|
||||||
|
rhoName_(coeffs_.lookupOrDefault<word>("rhoName", "rho")),
|
||||||
|
muName_(coeffs_.lookupOrDefault<word>("muName", "thermo:mu"))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::interRegionExplicitPorositySource::addSup
|
||||||
|
(
|
||||||
|
fvMatrix<vector>& eqn,
|
||||||
|
const label fieldI
|
||||||
|
)
|
||||||
|
{
|
||||||
|
initialise();
|
||||||
|
|
||||||
|
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
|
||||||
|
|
||||||
|
const volVectorField& U = eqn.psi();
|
||||||
|
|
||||||
|
volVectorField UNbr
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
name_ + ".UNbr",
|
||||||
|
nbrMesh.time().timeName(),
|
||||||
|
nbrMesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
nbrMesh,
|
||||||
|
dimensionedVector("zero", U.dimensions(), vector::zero)
|
||||||
|
);
|
||||||
|
|
||||||
|
// map local velocity onto neighbour region
|
||||||
|
meshInterp().mapSrcToTgt
|
||||||
|
(
|
||||||
|
U.internalField(),
|
||||||
|
plusEqOp<vector>(),
|
||||||
|
UNbr.internalField()
|
||||||
|
);
|
||||||
|
|
||||||
|
fvMatrix<vector> nbrEqn(UNbr, eqn.dimensions());
|
||||||
|
|
||||||
|
if (eqn.dimensions() == dimForce)
|
||||||
|
{
|
||||||
|
const volScalarField& rhoNbr =
|
||||||
|
nbrMesh.lookupObject<volScalarField>(rhoName_);
|
||||||
|
const volScalarField& muNbr =
|
||||||
|
nbrMesh.lookupObject<volScalarField>(muName_);
|
||||||
|
|
||||||
|
porosityPtr_->addResistance(nbrEqn, rhoNbr, muNbr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
porosityPtr_->addResistance(nbrEqn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert source from neighbour to local region
|
||||||
|
fvMatrix<vector> porosityEqn(U, eqn.dimensions());
|
||||||
|
scalarField& Udiag = porosityEqn.diag();
|
||||||
|
vectorField& Usource = porosityEqn.source();
|
||||||
|
|
||||||
|
Udiag.setSize(eqn.diag().size(), 0.0);
|
||||||
|
Usource.setSize(eqn.source().size(), vector::zero);
|
||||||
|
|
||||||
|
meshInterp().mapTgtToSrc(nbrEqn.diag(), plusEqOp<scalar>(), Udiag);
|
||||||
|
meshInterp().mapTgtToSrc(nbrEqn.source(), plusEqOp<vector>(), Usource);
|
||||||
|
|
||||||
|
eqn -= porosityEqn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::interRegionExplicitPorositySource::writeData(Ostream& os) const
|
||||||
|
{
|
||||||
|
os << indent << name_ << endl;
|
||||||
|
dict_.write(os);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::interRegionExplicitPorositySource::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (option::read(dict))
|
||||||
|
{
|
||||||
|
coeffs_.readIfPresent("UName", UName_);
|
||||||
|
coeffs_.readIfPresent("rhoName", rhoName_);
|
||||||
|
coeffs_.readIfPresent("muName", muName_);
|
||||||
|
|
||||||
|
// reset the porosity model?
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,177 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 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, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::fv::interRegionExplicitPorositySource
|
||||||
|
|
||||||
|
Description
|
||||||
|
Inter-region explicit porosity source
|
||||||
|
|
||||||
|
Sources described by, for example using the DarcyForchheimer model:
|
||||||
|
|
||||||
|
interRegionExplicitPorositySourceCoeffs
|
||||||
|
{
|
||||||
|
type DarcyForchheimer;
|
||||||
|
DarcyForchheimerCoeffs
|
||||||
|
{
|
||||||
|
d d [0 -2 0 0 0 0 0] (5e7 -1000 -1000);
|
||||||
|
f f [0 -1 0 0 0 0 0] (0 0 0);
|
||||||
|
|
||||||
|
coordinateSystem
|
||||||
|
{
|
||||||
|
e1 (0.70710678 0.70710678 0);
|
||||||
|
e2 (0 0 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Note:
|
||||||
|
The porous region must be selected as a cellZone.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
interRegionExplicitPorositySource.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef interRegionExplicitPorositySource_H
|
||||||
|
#define interRegionExplicitPorositySource_H
|
||||||
|
|
||||||
|
#include "fvOption.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class porosityModel;
|
||||||
|
|
||||||
|
namespace fv
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class interRegionExplicitPorositySource Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class interRegionExplicitPorositySource
|
||||||
|
:
|
||||||
|
public option
|
||||||
|
{
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected data
|
||||||
|
|
||||||
|
//- Run-time selectable porosity model
|
||||||
|
autoPtr<porosityModel> porosityPtr_;
|
||||||
|
|
||||||
|
//- First iteration
|
||||||
|
bool firstIter_;
|
||||||
|
|
||||||
|
//- Velocity field name, default = U
|
||||||
|
word UName_;
|
||||||
|
|
||||||
|
//- Density field name (compressible case only), default = rho
|
||||||
|
word rhoName_;
|
||||||
|
|
||||||
|
//- Dynamic viscosity field name (compressible case only)
|
||||||
|
// default = thermo:mu
|
||||||
|
word muName_;
|
||||||
|
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Initialise
|
||||||
|
void initialise();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
interRegionExplicitPorositySource
|
||||||
|
(
|
||||||
|
const interRegionExplicitPorositySource&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const interRegionExplicitPorositySource&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("interRegionExplicitPorositySource");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
interRegionExplicitPorositySource
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const word& modelType,
|
||||||
|
const dictionary& dict,
|
||||||
|
const fvMesh& mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~interRegionExplicitPorositySource()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Add explicit and implicit contributions
|
||||||
|
|
||||||
|
//- Vector
|
||||||
|
virtual void addSup
|
||||||
|
(
|
||||||
|
fvMatrix<vector>& eqn,
|
||||||
|
const label fieldI
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// I-O
|
||||||
|
|
||||||
|
//- Write data
|
||||||
|
virtual void writeData(Ostream&) const;
|
||||||
|
|
||||||
|
//- Read dictionary
|
||||||
|
virtual bool read(const dictionary& dict);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace fv
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user