Commit 56dfd190 authored by Andrew Heather's avatar Andrew Heather
Browse files

initial commit of new multicomponent point source

parent 47e65edf
......@@ -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;
}
}