Skip to content
Snippets Groups Projects
Commit 56dfd190 authored by Andrew Heather's avatar Andrew Heather
Browse files

initial commit of new multicomponent point source

parent 47e65edf
Branches
Tags
No related merge requests found
Showing
with 831 additions and 13 deletions
......@@ -297,18 +297,31 @@ $(laplacianSchemes)/gaussLaplacianScheme/gaussLaplacianSchemes.C
finiteVolume/fvc/fvcMeshPhi.C
cfdTools/general/findRefCell/findRefCell.C
cfdTools/general/adjustPhi/adjustPhi.C
cfdTools/general/bound/bound.C
cfdTools/general/porousMedia/porousZone.C
cfdTools/general/porousMedia/porousZones.C
cfdTools/general/MRF/MRFZone.C
cfdTools/general/MRF/MRFZones.C
cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C
cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.C
cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C
cfdTools/general/SRF/SRFModel/SRFModel/newSRFModel.C
cfdTools/general/SRF/SRFModel/rpm/rpm.C
cfdTools/general/SRF/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C
general = cfdTools/general
$(general)/findRefCell/findRefCell.C
$(general)/adjustPhi/adjustPhi.C
$(general)/bound/bound.C
porousMedia = $(general)/porousMedia
$(porousMedia)/porousZone.C
$(porousMedia)/porousZones.C
MRF = $(general)/MRF
$(MRF)/MRFZone.C
$(MRF)/MRFZones.C
SRF = $(general)/SRF
$(SRF)/SRFModel/SRFModel/SRFModel.C
$(SRF)/SRFModel/SRFModel/newSRFModel.C
$(SRF)/SRFModel/rpm/rpm.C
$(SRF)/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C
fieldSources = $(general)/fieldSources
$(fieldSources)/pressureGradientExplicitSource/pressureGradientExplicitSource.C
$(fieldSources)/timeActivatedExplicitSource/timeActivatedExplicitSource.C
$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/timeActivatedExplicitMulticomponentPointSource.C
$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourceProperties.C
$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourcePropertiesIO.C
LIB = $(FOAM_LIBBIN)/libfiniteVolume
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "pointSourceProperties.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pointSourceProperties::pointSourceProperties()
:
name_("unknownPointSourceName"),
timeStart_(0.0),
duration_(0.0),
location_(point::zero),
fieldData_()
{}
Foam::pointSourceProperties::pointSourceProperties(const dictionary& dict)
:
name_(dict.name().name()),
timeStart_(readScalar(dict.lookup("timeStart"))),
duration_(readScalar(dict.lookup("duration"))),
location_(dict.lookup("location")),
fieldData_(dict.lookup("fieldData"))
{}
Foam::pointSourceProperties::pointSourceProperties
(
const pointSourceProperties& psp
)
:
name_(psp.name_),
timeStart_(psp.timeStart_),
duration_(psp.duration_),
location_(psp.location_),
fieldData_(psp.fieldData_)
{}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::pointSourceProperties::operator=(const pointSourceProperties& rhs)
{
// Check for assignment to self
if (this == &rhs)
{
FatalErrorIn
(
"pointSourceProperties::operator=(const pointSourceProperties&)"
) << "Attempted assignment to self" << nl
<< abort(FatalError);
}
// Set updated values
name_ = rhs.name_;
timeStart_ = rhs.timeStart_;
duration_ = rhs.duration_;
location_ = rhs.location_;
fieldData_ = rhs.fieldData_;}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::pointSourceProperties
Description
Helper class to describe point source properties
SourceFiles
pointSourceProperties.C
\*---------------------------------------------------------------------------*/
#ifndef pointSourceProperties_H
#define pointSourceProperties_H
#include "IOdictionary.H"
#include "fvMesh.H"
#include "Time.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class pointSourceProperties Declaration
\*---------------------------------------------------------------------------*/
class pointSourceProperties
{
protected:
// Protected data
typedef Tuple2<word, scalar> fieldNameValuePair;
//- Source name
word name_;
//- Time start
scalar timeStart_;
//- Duration
scalar duration_;
//- Point location
point location_;
//- List of source field name vs value pairs
List<fieldNameValuePair> fieldData_;
public:
// Constructors
//- Construct null
pointSourceProperties();
//- Construct from dictionary
pointSourceProperties(const dictionary& dict);
//- Construct from Istream
pointSourceProperties(Istream& is);
//- Copy constructor
pointSourceProperties(const pointSourceProperties&);
// Member Functions
// Access
//- Return const access to the source name
inline const word& name() const;
//- Return const access to the time start
inline scalar timeStart() const;
//- Return const access to the time end
inline scalar timeEnd() const;
//- Return const access to the duration
inline scalar duration() const;
//- Return const access to the point location
inline const point& location() const;
//- Return const access to the source field name vs value pairs
inline const List<fieldNameValuePair>& fieldData() const;
// Edit
//- Return access to the source name
inline word& name();
//- Return access to the time start
inline scalar& timeStart();
//- Return access to the duration
inline scalar& duration();
//- Return access to the point location
inline point& location();
//- Return access to the source field name vs value pairs
inline List<fieldNameValuePair>& fieldData();
// Member Operators
void operator=(const pointSourceProperties&);
// IOstream operators
friend Istream& operator>>(Istream&, pointSourceProperties&);
friend Ostream& operator<<(Ostream&, const pointSourceProperties&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pointSourcePropertiesI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "pointSourceProperties.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::word& Foam::pointSourceProperties::name() const
{
return name_;
}
inline Foam::scalar Foam::pointSourceProperties::timeStart() const
{
return timeStart_;
}
inline Foam::scalar Foam::pointSourceProperties::timeEnd() const
{
return timeStart_ + duration_;
}
inline Foam::scalar Foam::pointSourceProperties::duration() const
{
return duration_;
}
inline const Foam::point& Foam::pointSourceProperties::location() const
{
return location_;
}
inline const Foam::List<Foam::pointSourceProperties::fieldNameValuePair>&
Foam::pointSourceProperties::fieldData() const
{
return fieldData_;
}
inline Foam::word& Foam::pointSourceProperties::name()
{
return name_;
}
inline Foam::scalar& Foam::pointSourceProperties::timeStart()
{
return timeStart_;
}
inline Foam::scalar& Foam::pointSourceProperties::duration()
{
return duration_;
}
inline Foam::point& Foam::pointSourceProperties::location()
{
return location_;
}
inline Foam::List<Foam::pointSourceProperties::fieldNameValuePair>&
Foam::pointSourceProperties::fieldData()
{
return fieldData_;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "pointSourceProperties.H"
#include "dictionaryEntry.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pointSourceProperties::pointSourceProperties(Istream& is)
:
name_("unknownPointSourceName"),
timeStart_(0.0),
duration_(0.0),
location_(point::zero),
fieldData_()
{
is.check("pointSourceProperties(Istream&)");
const dictionaryEntry entry(dictionary::null, is);
name_ = entry.keyword();
entry.lookup("timeStart") >> timeStart_;
entry.lookup("duration") >> duration_;
entry.lookup("location") >> location_;
entry.lookup("fieldData") >> fieldData_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, pointSourceProperties& psp)
{
is.check("Istream& operator>>(Istream&, pointSourceProperties&)");
const dictionaryEntry entry(dictionary::null, is);
psp.name_ = entry.keyword();
entry.lookup("timeStart") >> psp.timeStart_;
entry.lookup("duration") >> psp.duration_;
entry.lookup("location") >> psp.location_;
entry.lookup("fieldData") >> psp.fieldData_;
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const pointSourceProperties& psp)
{
os.check("Ostream& operator<<(Ostream&, const pointSourceProperties&)");
os << psp.name_ << nl << token::BEGIN_BLOCK << nl;
os.writeKeyword("timeStart") << psp.timeStart_ << token::END_STATEMENT << nl;
os.writeKeyword("duration") << psp.duration_ << token::END_STATEMENT << nl;
os.writeKeyword("location") << psp.location_ << token::END_STATEMENT << nl;
os.writeKeyword("fieldData") << psp.fieldData_ << token::END_STATEMENT << nl;
os << token::END_BLOCK << nl;
os.check("Ostream& operator<<(Ostream&, const pointSourceProperties&)");
return os;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "timeActivatedExplicitMulticomponentPointSource.H"
#include "volFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label
Foam::timeActivatedExplicitMulticomponentPointSource::carrierFieldId
(
const word& fieldName
)
{
forAll(carrierFields_, fieldI)
{
if (carrierFields_[fieldI].name() == fieldName)
{
return fieldI;
}
}
return -1;
}
void Foam::timeActivatedExplicitMulticomponentPointSource::updateAddressing()
{
forAll(pointSources_, sourceI)
{
const pointSourceProperties& psp = pointSources_[sourceI];
cellOwners_[sourceI] = mesh_.findCell(psp.location());
forAll(psp.fieldData(), fieldI)
{
const word& fieldName = psp.fieldData()[fieldI].first();
label cfid = carrierFieldId(fieldName);
if (cfid < 0)
{
FatalErrorIn
(
"timeActivatedExplicitMulticomponentPointSource::"
"updateAddressing()"
) << "Unable to find field " << fieldName << " in carrier "
<< "fields for source " << psp.name() << nl
<< exit(FatalError);
}
else
{
fieldIds_[sourceI][fieldI] = cfid;
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::timeActivatedExplicitMulticomponentPointSource::
timeActivatedExplicitMulticomponentPointSource
(
const word& sourceName,
const fvMesh& mesh,
const PtrList<volScalarField>& carrierFields,
const dimensionSet& dims
)
:
IOdictionary
(
IOobject
(
sourceName + "Properties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
sourceName_(sourceName),
mesh_(mesh),
runTime_(mesh.time()),
dimensions_(dims),
carrierFields_(carrierFields),
active_(lookup("active")),
pointSources_(lookup("pointSources")),
cellOwners_(pointSources_.size()),
fieldIds_(pointSources_.size())
{
// Initialise the field addressing
updateAddressing();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
Foam::timeActivatedExplicitMulticomponentPointSource::Su
(
const label fieldI
)
{
if (mesh_.changing())
{
updateAddressing();
}
tmp<DimensionedField<scalar, volMesh> > tSource
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
sourceName_ + carrierFields_[fieldI].name() + "Su",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensions_, 0.0)
)
);
DimensionedField<scalar, volMesh>& sourceField = tSource();
forAll(pointSources_, sourceI)
{
const pointSourceProperties& psp = pointSources_[sourceI];
forAll(fieldIds_[sourceI], i)
{
if
(
fieldIds_[sourceI][i] == fieldI
&& (runTime_.time().value() >= psp.timeStart())
&& (runTime_.time().value() <= psp.timeEnd())
)
{
const label cid = cellOwners_[sourceI];
sourceField[cid] += psp.fieldData()[i].second();
}
}
}
return tSource;
}
bool Foam::timeActivatedExplicitMulticomponentPointSource::read()
{
if (regIOobject::read())
{
lookup("active") >> active_;
lookup("pointSources") >> pointSources_;
cellOwners_.setSize(pointSources_.size());
updateAddressing();
return true;
}
else
{
return false;
}
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::timeActivatedExplicitMulticomponentPointSourceNew
Description
Provides a mechanism to introduce point sources to a set of carrier fields.
Carrier fields are supplied on consruction, and interrogated to provide the
field indices of the sources.
Properties are described in a <sourceName>Properties dictionary, e.g.:
active true; // are sources active (true/false)
pointSources
(
source1 // source name
{
timeStart 0.0;
duration 1.0;
location (0 0 0);
fieldData
(
(H2O 0.1)
(O2 0.05)
);
}
source2 // source name
{
timeStart 0.5;
duration 2.0;
location (1 1 1);
fieldData
(
(NO 0.1)
(CO2 0.05)
(H2 0.001)
);
}
);
SourceFiles
timeActivatedExplicitMulticomponentPointSourceNew.C
\*---------------------------------------------------------------------------*/
#ifndef timeActivatedExplicitMulticomponentPointSource_H
#define timeActivatedExplicitMulticomponentPointSource_H
#include "IOdictionary.H"
#include "fvMesh.H"
#include "Time.H"
#include "pointSourceProperties.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class timeActivatedExplicitMulitcomponentPointSource Declaration
\*---------------------------------------------------------------------------*/
class timeActivatedExplicitMulticomponentPointSource
:
public IOdictionary
{
protected:
// Protected data
//- Name of the source
word sourceName_;
//- Reference to the mesh
const fvMesh& mesh_;
//- Reference to time database
const Time& runTime_;
//- Source dimensions
const dimensionSet& dimensions_;
//- Reference to the multicomponent carrier fields
const PtrList<volScalarField>& carrierFields_;
//- Active flag
bool active_;
//- List of point source properties
List<pointSourceProperties> pointSources_;
//- List of cell owners for point source locations
List<label> cellOwners_;
//- List of field ids for each source
List<labelList> fieldIds_;
// Protected Member Functions
//- Return the id of field given its name
label carrierFieldId(const word& fieldName);
//- Update the addressing between source and carrier fields
void updateAddressing();
//- Disallow default bitwise copy construct
timeActivatedExplicitMulticomponentPointSource
(
const timeActivatedExplicitMulticomponentPointSource&
);
//- Disallow default bitwise assignment
void operator=(const timeActivatedExplicitMulticomponentPointSource&);
public:
// Constructors
//- Construct from components
timeActivatedExplicitMulticomponentPointSource
(
const word&,
const fvMesh&,
const PtrList<volScalarField>&,
const dimensionSet&
);
// Member Functions
// Access
//- Return a tmp field of the source
virtual tmp<DimensionedField<scalar, volMesh> > Su
(
const label fieldI
);
//- Read properties dictionary
virtual bool read();
//- Update
virtual void update();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment