mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
updates to sources
This commit is contained in:
@ -4,5 +4,5 @@ timeActivatedExplicitMulticomponentPointSource pointMassSources
|
|||||||
"pointMassSources",
|
"pointMassSources",
|
||||||
mesh,
|
mesh,
|
||||||
Y,
|
Y,
|
||||||
dimMass/dimTime/dimVolume
|
dimMass/dimVolume/dimTime
|
||||||
);
|
);
|
||||||
|
|||||||
@ -319,6 +319,7 @@ $(SRF)/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVect
|
|||||||
fieldSources = $(general)/fieldSources
|
fieldSources = $(general)/fieldSources
|
||||||
$(fieldSources)/pressureGradientExplicitSource/pressureGradientExplicitSource.C
|
$(fieldSources)/pressureGradientExplicitSource/pressureGradientExplicitSource.C
|
||||||
$(fieldSources)/timeActivatedExplicitSource/timeActivatedExplicitSource.C
|
$(fieldSources)/timeActivatedExplicitSource/timeActivatedExplicitSource.C
|
||||||
|
$(fieldSources)/timeActivatedExplicitCellSource/timeActivatedExplicitCellSource.C
|
||||||
|
|
||||||
$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/timeActivatedExplicitMulticomponentPointSource.C
|
$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/timeActivatedExplicitMulticomponentPointSource.C
|
||||||
$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourceProperties.C
|
$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourceProperties.C
|
||||||
|
|||||||
@ -0,0 +1,175 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ 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 2 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 "timeActivatedExplicitCellSource.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::timeActivatedExplicitCellSource::updateCellSet()
|
||||||
|
{
|
||||||
|
cellSelector_->applyToSet(topoSetSource::NEW, selectedCellSet_);
|
||||||
|
|
||||||
|
Info<< " " << name_ << ": selected "
|
||||||
|
<< returnReduce(selectedCellSet_.size(), sumOp<label>())
|
||||||
|
<< " cells" << nl << endl;
|
||||||
|
|
||||||
|
V_ = scalarField(selectedCellSet_.size(), 1.0);
|
||||||
|
if (volumeType_ == vtAbsolute)
|
||||||
|
{
|
||||||
|
label i = 0;
|
||||||
|
forAllConstIter(cellSet, selectedCellSet_, iter)
|
||||||
|
{
|
||||||
|
V_[i++] = mesh_.V()[iter.key()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::timeActivatedExplicitCellSource::timeActivatedExplicitCellSource
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const dimensionSet& dims
|
||||||
|
)
|
||||||
|
:
|
||||||
|
timeActivatedExplicitSource(name, mesh, dims),
|
||||||
|
onValue_(readScalar(lookup("onValue"))),
|
||||||
|
offValue_(readScalar(lookup("offValue"))),
|
||||||
|
V_(0),
|
||||||
|
cellSource_(lookup("cellSource")),
|
||||||
|
cellSelector_
|
||||||
|
(
|
||||||
|
topoSetSource::New
|
||||||
|
(
|
||||||
|
cellSource_,
|
||||||
|
mesh,
|
||||||
|
subDict(cellSource_ + "Coeffs")
|
||||||
|
)
|
||||||
|
),
|
||||||
|
selectedCellSet_
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
name + "SourceCellSet",
|
||||||
|
mesh.nCells()/10 + 1 // Reasonable size estimate.
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Create the cell set
|
||||||
|
updateCellSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::scalar Foam::timeActivatedExplicitCellSource::onValue() const
|
||||||
|
{
|
||||||
|
return onValue_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::scalar Foam::timeActivatedExplicitCellSource::offValue() const
|
||||||
|
{
|
||||||
|
return offValue_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
|
||||||
|
Foam::timeActivatedExplicitCellSource::Su()
|
||||||
|
{
|
||||||
|
tmp<DimensionedField<scalar, volMesh> > tSource
|
||||||
|
(
|
||||||
|
new DimensionedField<scalar, volMesh>
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
name_ + "Su",
|
||||||
|
runTime_.timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
mesh_,
|
||||||
|
dimensionedScalar("zero", dimensions_, 0.0)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
scalar value = offValue_;
|
||||||
|
if
|
||||||
|
(
|
||||||
|
active_
|
||||||
|
&& (runTime_.time().value() >= timeStart_)
|
||||||
|
&& (runTime_.time().value() <= timeStart_ + duration_)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Update the cell set if the mesh is changing
|
||||||
|
if (mesh_.changing())
|
||||||
|
{
|
||||||
|
updateCellSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
value = onValue_;
|
||||||
|
}
|
||||||
|
|
||||||
|
DimensionedField<scalar, volMesh>& sourceField = tSource();
|
||||||
|
|
||||||
|
label i = 0;
|
||||||
|
forAllConstIter(cellSet, selectedCellSet_, iter)
|
||||||
|
{
|
||||||
|
sourceField[iter.key()] = value/V_[i++];
|
||||||
|
}
|
||||||
|
|
||||||
|
return tSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::timeActivatedExplicitCellSource::read()
|
||||||
|
{
|
||||||
|
if (timeActivatedExplicitSource::read())
|
||||||
|
{
|
||||||
|
lookup("onValue") >> onValue_;
|
||||||
|
lookup("offValue") >> offValue_;
|
||||||
|
lookup("cellSource") >> cellSource_;
|
||||||
|
cellSelector_ =
|
||||||
|
topoSetSource::New
|
||||||
|
(
|
||||||
|
cellSource_,
|
||||||
|
mesh_,
|
||||||
|
subDict(cellSource_ + "Coeffs")
|
||||||
|
);
|
||||||
|
updateCellSet();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,143 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ 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 2 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::timeActivatedExplicitSourceNew
|
||||||
|
|
||||||
|
Description
|
||||||
|
Creates a cell set source that is activated at a given time, and remains
|
||||||
|
active for a specified duration. The source value is either in specific
|
||||||
|
(XX/m3) or absolute (XX) units.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
timeActivatedExplicitCellSource.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef timeActivatedExplicitCellSource_H
|
||||||
|
#define timeActivatedExplicitCellSource_H
|
||||||
|
|
||||||
|
#include "timeActivatedExplicitSource.H"
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "cellSet.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class timeActivatedExplicitCellSource Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class timeActivatedExplicitCellSource
|
||||||
|
:
|
||||||
|
public timeActivatedExplicitSource
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private member functions
|
||||||
|
|
||||||
|
//- Update the cell set that the source is acting on
|
||||||
|
void updateCellSet();
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
timeActivatedExplicitCellSource(const timeActivatedExplicitCellSource&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const timeActivatedExplicitCellSource&);
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected data
|
||||||
|
|
||||||
|
// Source properties
|
||||||
|
|
||||||
|
//- Value when "on"
|
||||||
|
scalar onValue_;
|
||||||
|
|
||||||
|
//- Value when "off"
|
||||||
|
scalar offValue_;
|
||||||
|
|
||||||
|
|
||||||
|
// Cell set
|
||||||
|
|
||||||
|
//- Cell volumes
|
||||||
|
scalarList V_;
|
||||||
|
|
||||||
|
//- Name of cell source (XXXToCell)
|
||||||
|
word cellSource_;
|
||||||
|
|
||||||
|
//- Method by which the cells will be selected
|
||||||
|
autoPtr<topoSetSource> cellSelector_;
|
||||||
|
|
||||||
|
//- Set of selected cells
|
||||||
|
cellSet selectedCellSet_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from explicit source name and mesh
|
||||||
|
timeActivatedExplicitCellSource
|
||||||
|
(
|
||||||
|
const word&,
|
||||||
|
const fvMesh&,
|
||||||
|
const dimensionSet&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Return the "on" value
|
||||||
|
virtual scalar onValue() const;
|
||||||
|
|
||||||
|
//- Return the "off" value
|
||||||
|
virtual scalar offValue() const;
|
||||||
|
|
||||||
|
//- Return a tmp field of the source
|
||||||
|
virtual tmp<DimensionedField<scalar, volMesh> > Su();
|
||||||
|
|
||||||
|
|
||||||
|
//- Read properties dictionary
|
||||||
|
virtual bool read();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -97,7 +97,7 @@ void Foam::timeActivatedExplicitMulticomponentPointSource::updateAddressing()
|
|||||||
Foam::timeActivatedExplicitMulticomponentPointSource::
|
Foam::timeActivatedExplicitMulticomponentPointSource::
|
||||||
timeActivatedExplicitMulticomponentPointSource
|
timeActivatedExplicitMulticomponentPointSource
|
||||||
(
|
(
|
||||||
const word& sourceName,
|
const word& name,
|
||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
const PtrList<volScalarField>& carrierFields,
|
const PtrList<volScalarField>& carrierFields,
|
||||||
const dimensionSet& dims
|
const dimensionSet& dims
|
||||||
@ -107,14 +107,14 @@ timeActivatedExplicitMulticomponentPointSource
|
|||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
sourceName + "Properties",
|
name + "Properties",
|
||||||
mesh.time().constant(),
|
mesh.time().constant(),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
sourceName_(sourceName),
|
name_(name),
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
runTime_(mesh.time()),
|
runTime_(mesh.time()),
|
||||||
dimensions_(dims),
|
dimensions_(dims),
|
||||||
@ -148,7 +148,7 @@ Foam::timeActivatedExplicitMulticomponentPointSource::Su
|
|||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
sourceName_ + carrierFields_[fieldI].name() + "Su",
|
name_ + carrierFields_[fieldI].name() + "Su",
|
||||||
runTime_.timeName(),
|
runTime_.timeName(),
|
||||||
mesh_,
|
mesh_,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
@ -159,8 +159,13 @@ Foam::timeActivatedExplicitMulticomponentPointSource::Su
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (active_)
|
||||||
|
{
|
||||||
DimensionedField<scalar, volMesh>& sourceField = tSource();
|
DimensionedField<scalar, volMesh>& sourceField = tSource();
|
||||||
|
|
||||||
|
const scalarField& V = mesh_.V();
|
||||||
|
const scalar dt = runTime_.deltaT().value();
|
||||||
|
|
||||||
forAll(pointSources_, sourceI)
|
forAll(pointSources_, sourceI)
|
||||||
{
|
{
|
||||||
const pointSourceProperties& psp = pointSources_[sourceI];
|
const pointSourceProperties& psp = pointSources_[sourceI];
|
||||||
@ -175,7 +180,63 @@ Foam::timeActivatedExplicitMulticomponentPointSource::Su
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
const label cid = cellOwners_[sourceI];
|
const label cid = cellOwners_[sourceI];
|
||||||
sourceField[cid] += psp.fieldData()[i].second();
|
sourceField[cid] += dt*psp.fieldData()[i].second()/V[cid];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
|
||||||
|
Foam::timeActivatedExplicitMulticomponentPointSource::Su()
|
||||||
|
{
|
||||||
|
if (mesh_.changing())
|
||||||
|
{
|
||||||
|
updateAddressing();
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp<DimensionedField<scalar, volMesh> > tSource
|
||||||
|
(
|
||||||
|
new DimensionedField<scalar, volMesh>
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
name_ + "TotalSu",
|
||||||
|
runTime_.timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
mesh_,
|
||||||
|
dimensionedScalar("zero", dimensions_, 0.0)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (active_)
|
||||||
|
{
|
||||||
|
DimensionedField<scalar, volMesh>& sourceField = tSource();
|
||||||
|
|
||||||
|
const scalarField& V = mesh_.V();
|
||||||
|
const scalar dt = runTime_.deltaT().value();
|
||||||
|
|
||||||
|
forAll(pointSources_, sourceI)
|
||||||
|
{
|
||||||
|
const pointSourceProperties& psp = pointSources_[sourceI];
|
||||||
|
|
||||||
|
forAll(fieldIds_[sourceI], i)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
(runTime_.time().value() >= psp.timeStart())
|
||||||
|
&& (runTime_.time().value() <= psp.timeEnd())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const label cid = cellOwners_[sourceI];
|
||||||
|
sourceField[cid] += dt*psp.fieldData()[i].second()/V[cid];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,10 @@ Description
|
|||||||
Carrier fields are supplied on consruction, and interrogated to provide the
|
Carrier fields are supplied on consruction, and interrogated to provide the
|
||||||
field indices of the sources.
|
field indices of the sources.
|
||||||
|
|
||||||
Properties are described in a <sourceName>Properties dictionary, e.g.:
|
Source values are assumed to be in <quantity>/s, and divided through by the
|
||||||
|
cell volumes before being returned, e.g. for a kg/s source
|
||||||
|
|
||||||
|
Properties are described in a <name>Properties dictionary
|
||||||
|
|
||||||
active true; // are sources active (true/false)
|
active true; // are sources active (true/false)
|
||||||
|
|
||||||
@ -43,8 +46,8 @@ Description
|
|||||||
location (0 0 0);
|
location (0 0 0);
|
||||||
fieldData
|
fieldData
|
||||||
(
|
(
|
||||||
(H2O 0.1)
|
(H2O 0.1) // kg/s
|
||||||
(O2 0.05)
|
(O2 0.05) // kg/s
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
source2 // source name
|
source2 // source name
|
||||||
@ -54,9 +57,9 @@ Description
|
|||||||
location (1 1 1);
|
location (1 1 1);
|
||||||
fieldData
|
fieldData
|
||||||
(
|
(
|
||||||
(NO 0.1)
|
(NO 0.1) // kg/s
|
||||||
(CO2 0.05)
|
(CO2 0.05) // kg/s
|
||||||
(H2 0.001)
|
(H2 0.001) // kg/s
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -93,7 +96,7 @@ protected:
|
|||||||
// Protected data
|
// Protected data
|
||||||
|
|
||||||
//- Name of the source
|
//- Name of the source
|
||||||
word sourceName_;
|
word name_;
|
||||||
|
|
||||||
//- Reference to the mesh
|
//- Reference to the mesh
|
||||||
const fvMesh& mesh_;
|
const fvMesh& mesh_;
|
||||||
@ -156,12 +159,15 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Return a tmp field of the source
|
//- Return a tmp field of the source for field fieldI
|
||||||
virtual tmp<DimensionedField<scalar, volMesh> > Su
|
virtual tmp<DimensionedField<scalar, volMesh> > Su
|
||||||
(
|
(
|
||||||
const label fieldI
|
const label fieldI
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Return a tmp field of the total source
|
||||||
|
virtual tmp<DimensionedField<scalar, volMesh> > Su();
|
||||||
|
|
||||||
|
|
||||||
//- Read properties dictionary
|
//- Read properties dictionary
|
||||||
virtual bool read();
|
virtual bool read();
|
||||||
|
|||||||
@ -44,33 +44,11 @@ const Foam::NamedEnum<Foam::timeActivatedExplicitSource::volumeType, 2>
|
|||||||
Foam::timeActivatedExplicitSource::volumeTypeNames_;
|
Foam::timeActivatedExplicitSource::volumeTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void Foam::timeActivatedExplicitSource::updateCellSet()
|
|
||||||
{
|
|
||||||
cellSelector_->applyToSet(topoSetSource::NEW, selectedCellSet_);
|
|
||||||
|
|
||||||
Info<< " " << sourceName_ << ": selected "
|
|
||||||
<< returnReduce(selectedCellSet_.size(), sumOp<label>())
|
|
||||||
<< " cells" << nl << endl;
|
|
||||||
|
|
||||||
V_ = scalarField(selectedCellSet_.size(), 1.0);
|
|
||||||
if (volumeType_ == vtAbsolute)
|
|
||||||
{
|
|
||||||
label i = 0;
|
|
||||||
forAllConstIter(cellSet, selectedCellSet_, iter)
|
|
||||||
{
|
|
||||||
V_[i++] = mesh_.V()[iter.key()];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::timeActivatedExplicitSource::timeActivatedExplicitSource
|
Foam::timeActivatedExplicitSource::timeActivatedExplicitSource
|
||||||
(
|
(
|
||||||
const word& sourceName,
|
const word& name,
|
||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
const dimensionSet& dims
|
const dimensionSet& dims
|
||||||
)
|
)
|
||||||
@ -79,51 +57,63 @@ Foam::timeActivatedExplicitSource::timeActivatedExplicitSource
|
|||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
sourceName + "Properties",
|
name + "Properties",
|
||||||
mesh.time().constant(),
|
mesh.time().constant(),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
sourceName_(sourceName),
|
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
runTime_(mesh.time()),
|
runTime_(mesh.time()),
|
||||||
|
name_(name),
|
||||||
|
active_(lookup("active")),
|
||||||
dimensions_(dims),
|
dimensions_(dims),
|
||||||
volumeType_(volumeTypeNames_.read(lookup("volumeType"))),
|
volumeType_(volumeTypeNames_.read(lookup("volumeType"))),
|
||||||
timeStart_(readScalar(lookup("timeStart"))),
|
timeStart_(readScalar(lookup("timeStart"))),
|
||||||
duration_(readScalar(lookup("duration"))),
|
duration_(readScalar(lookup("duration")))
|
||||||
onValue_(readScalar(lookup("onValue"))),
|
{}
|
||||||
offValue_(readScalar(lookup("offValue"))),
|
|
||||||
currentValue_(0.0),
|
|
||||||
V_(0),
|
|
||||||
cellSource_(lookup("cellSource")),
|
|
||||||
cellSelector_
|
|
||||||
(
|
|
||||||
topoSetSource::New
|
|
||||||
(
|
|
||||||
cellSource_,
|
|
||||||
mesh,
|
|
||||||
subDict(cellSource_ + "Coeffs")
|
|
||||||
)
|
|
||||||
),
|
|
||||||
selectedCellSet_
|
|
||||||
(
|
|
||||||
mesh,
|
|
||||||
sourceName + "SourceCellSet",
|
|
||||||
mesh.nCells()/10 + 1 // Reasonable size estimate.
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Create the cell set
|
|
||||||
updateCellSet();
|
|
||||||
|
|
||||||
// Initialise the value
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::fvMesh& Foam::timeActivatedExplicitSource::mesh() const
|
||||||
|
{
|
||||||
|
return mesh_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::Time& Foam::timeActivatedExplicitSource::runTime() const
|
||||||
|
{
|
||||||
|
return runTime_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::word& Foam::timeActivatedExplicitSource::name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::Switch& Foam::timeActivatedExplicitSource::active() const
|
||||||
|
{
|
||||||
|
return active_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::dimensionSet& Foam::timeActivatedExplicitSource::dimensions() const
|
||||||
|
{
|
||||||
|
return dimensions_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::timeActivatedExplicitSource::volumeType&
|
||||||
|
Foam::timeActivatedExplicitSource::volume() const
|
||||||
|
{
|
||||||
|
return volumeType_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar Foam::timeActivatedExplicitSource::timeStart() const
|
Foam::scalar Foam::timeActivatedExplicitSource::timeStart() const
|
||||||
{
|
{
|
||||||
return timeStart_;
|
return timeStart_;
|
||||||
@ -136,69 +126,16 @@ Foam::scalar Foam::timeActivatedExplicitSource::duration() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::dimensionedScalar
|
|
||||||
Foam::timeActivatedExplicitSource::currentValue() const
|
|
||||||
{
|
|
||||||
return dimensionedScalar
|
|
||||||
(
|
|
||||||
sourceName_,
|
|
||||||
dimensions_,
|
|
||||||
currentValue_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
|
|
||||||
Foam::timeActivatedExplicitSource::Su() const
|
|
||||||
{
|
|
||||||
tmp<DimensionedField<scalar, volMesh> > tSource
|
|
||||||
(
|
|
||||||
new DimensionedField<scalar, volMesh>
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
sourceName_ + "Su",
|
|
||||||
runTime_.timeName(),
|
|
||||||
mesh_,
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE
|
|
||||||
),
|
|
||||||
mesh_,
|
|
||||||
dimensionedScalar("zero", dimensions_, 0.0)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
DimensionedField<scalar, volMesh>& sourceField = tSource();
|
|
||||||
|
|
||||||
label i = 0;
|
|
||||||
forAllConstIter(cellSet, selectedCellSet_, iter)
|
|
||||||
{
|
|
||||||
sourceField[iter.key()] = currentValue_/V_[i++];
|
|
||||||
}
|
|
||||||
|
|
||||||
return tSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::timeActivatedExplicitSource::read()
|
bool Foam::timeActivatedExplicitSource::read()
|
||||||
{
|
{
|
||||||
if (regIOobject::read())
|
if (regIOobject::read())
|
||||||
|
{
|
||||||
|
lookup("active") >> active_;
|
||||||
|
if (active_)
|
||||||
{
|
{
|
||||||
volumeType_ = volumeTypeNames_.read(lookup("volumeType"));
|
volumeType_ = volumeTypeNames_.read(lookup("volumeType"));
|
||||||
lookup("timeStart") >> duration_;
|
lookup("timeStart") >> duration_;
|
||||||
lookup("duration") >> duration_;
|
lookup("duration") >> duration_;
|
||||||
lookup("onValue") >> onValue_;
|
|
||||||
lookup("offValue") >> offValue_;
|
|
||||||
lookup("cellSource") >> cellSource_;
|
|
||||||
cellSelector_ =
|
|
||||||
topoSetSource::New
|
|
||||||
(
|
|
||||||
cellSource_,
|
|
||||||
mesh_,
|
|
||||||
subDict(cellSource_ + "Coeffs")
|
|
||||||
);
|
|
||||||
updateCellSet();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -206,30 +143,13 @@ bool Foam::timeActivatedExplicitSource::read()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::timeActivatedExplicitSource::update()
|
|
||||||
{
|
|
||||||
// Set the source value
|
|
||||||
if
|
|
||||||
(
|
|
||||||
(runTime_.time().value() >= timeStart_)
|
|
||||||
&& (runTime_.time().value() <= timeStart_ + duration_)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
currentValue_ = onValue_;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentValue_ = offValue_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the cell set if the mesh is changing
|
|
||||||
if (mesh_.changing())
|
|
||||||
{
|
|
||||||
updateCellSet();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -23,15 +23,20 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::timeActivatedExplicitSourceNew
|
Foam::timeActivatedExplicitSource
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Creates a cell set source that is activated at a given time, and remains
|
Base class for field sources. Provides:
|
||||||
active for a specified duration. The source value is either in specific
|
- name
|
||||||
(XX/m3) or absolute (XX) units.
|
- references to mesh and time
|
||||||
|
- dimensions
|
||||||
|
- volume type
|
||||||
|
- startTime
|
||||||
|
- duration
|
||||||
|
- read (from <sourceName>Properties dictionary)
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
timeActivatedExplicitSourceNew.C
|
timeActivatedExplicitSource.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -40,8 +45,6 @@ SourceFiles
|
|||||||
|
|
||||||
#include "IOdictionary.H"
|
#include "IOdictionary.H"
|
||||||
#include "autoPtr.H"
|
#include "autoPtr.H"
|
||||||
#include "topoSetSource.H"
|
|
||||||
#include "cellSet.H"
|
|
||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "NamedEnum.H"
|
#include "NamedEnum.H"
|
||||||
@ -72,19 +75,19 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Private member functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Update the cell set that the source is acting on
|
//- Disallow default bitwise copy construct
|
||||||
void updateCellSet();
|
timeActivatedExplicitSource(const timeActivatedExplicitSource&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const timeActivatedExplicitSource&);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Protected data
|
// Protected data
|
||||||
|
|
||||||
//- Name of the source
|
|
||||||
word sourceName_;
|
|
||||||
|
|
||||||
//- Reference to the mesh
|
//- Reference to the mesh
|
||||||
const fvMesh& mesh_;
|
const fvMesh& mesh_;
|
||||||
|
|
||||||
@ -94,6 +97,12 @@ protected:
|
|||||||
|
|
||||||
// Source properties
|
// Source properties
|
||||||
|
|
||||||
|
//- Name of the source
|
||||||
|
word name_;
|
||||||
|
|
||||||
|
//- Active flag
|
||||||
|
Switch active_;
|
||||||
|
|
||||||
//- Dimensions
|
//- Dimensions
|
||||||
const dimensionSet dimensions_;
|
const dimensionSet dimensions_;
|
||||||
|
|
||||||
@ -106,39 +115,6 @@ protected:
|
|||||||
//- Duration [s]
|
//- Duration [s]
|
||||||
scalar duration_;
|
scalar duration_;
|
||||||
|
|
||||||
//- Value when "on"
|
|
||||||
scalar onValue_;
|
|
||||||
|
|
||||||
//- Value when "off"
|
|
||||||
scalar offValue_;
|
|
||||||
|
|
||||||
//- Current source value
|
|
||||||
scalar currentValue_;
|
|
||||||
|
|
||||||
|
|
||||||
// Cell set
|
|
||||||
|
|
||||||
//- Cell volumes
|
|
||||||
scalarList V_;
|
|
||||||
|
|
||||||
//- Name of cell source (XXXToCell)
|
|
||||||
word cellSource_;
|
|
||||||
|
|
||||||
//- Method by which the cells will be selected
|
|
||||||
autoPtr<topoSetSource> cellSelector_;
|
|
||||||
|
|
||||||
//- Set of selected cells
|
|
||||||
cellSet selectedCellSet_;
|
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
|
||||||
timeActivatedExplicitSource(const timeActivatedExplicitSource&);
|
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
|
||||||
void operator=(const timeActivatedExplicitSource&);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -157,24 +133,33 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
|
//- Return the reference to the mesh
|
||||||
|
virtual const fvMesh& mesh() const;
|
||||||
|
|
||||||
|
//- Return the reference to the time database
|
||||||
|
virtual const Time& runTime() const;
|
||||||
|
|
||||||
|
//- Return the source name
|
||||||
|
virtual const word& name() const;
|
||||||
|
|
||||||
|
//- Return the active flag
|
||||||
|
virtual const Switch& active() const;
|
||||||
|
|
||||||
|
//- Return the dimensions
|
||||||
|
virtual const dimensionSet& dimensions() const;
|
||||||
|
|
||||||
|
//- Return the volume type
|
||||||
|
virtual const volumeType& volume() const;
|
||||||
|
|
||||||
//- Return the start time
|
//- Return the start time
|
||||||
scalar timeStart() const;
|
virtual scalar timeStart() const;
|
||||||
|
|
||||||
//- Return the duration
|
//- Return the duration
|
||||||
scalar duration() const;
|
virtual scalar duration() const;
|
||||||
|
|
||||||
//- Return the current value of the source
|
|
||||||
const dimensionedScalar currentValue() const;
|
|
||||||
|
|
||||||
//- Return a tmp field of the source
|
|
||||||
virtual tmp<DimensionedField<scalar, volMesh> > Su() const;
|
|
||||||
|
|
||||||
|
|
||||||
//- Read properties dictionary
|
//- Read properties dictionary
|
||||||
virtual bool read();
|
virtual bool read();
|
||||||
|
|
||||||
//- Update
|
|
||||||
virtual void update();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user