Commit 1da5da2a authored by andy's avatar andy
Browse files

BUG/ENH: Added use of engine time to cloud injection models - mantis #407

parent 4cd343ec
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -139,17 +139,28 @@ public:
// Member Functions
//- Return Table value
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
// Manipulation
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const
{
return TableBase<Type>::integrate(x1, x2);
}
//- Convert time
virtual void convertTimeBase(const Time& t)
{
TableBase<Type>::convertTimeBase(t);
}
// Evaluation
//- Return Table value
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const
{
return TableBase<Type>::integrate(x1, x2);
}
// I/O
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "DataEntry.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
......@@ -59,6 +60,13 @@ const Foam::word& Foam::DataEntry<Type>::name() const
}
template<class Type>
void Foam::DataEntry<Type>::convertTimeBase(const Time&)
{
// do nothing
}
template<class Type>
Type Foam::DataEntry<Type>::value(const scalar x) const
{
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -45,6 +45,7 @@ SourceFiles
namespace Foam
{
class Time;
template<class Type>
class DataEntry;
......@@ -133,6 +134,12 @@ public:
const word& name() const;
// Manipulation
//- Convert time
virtual void convertTimeBase(const Time& t);
// Evaluation
//- Return value as a function of (scalar) independent variable
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -106,17 +106,28 @@ public:
// Member Functions
//- Return Table value
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
// Manipulation
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const
{
return TableBase<Type>::integrate(x1, x2);
}
//- Convert time
virtual void convertTimeBase(const Time& t)
{
TableBase<Type>::convertTimeBase(t);
}
// Evaluation
//- Return Table value
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const
{
return TableBase<Type>::integrate(x1, x2);
}
// I/O
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "TableBase.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -296,6 +297,17 @@ bool Foam::TableBase<Type>::checkMaxBounds
}
template<class Type>
void Foam::TableBase<Type>::convertTimeBase(const Time& t)
{
forAll(table_, i)
{
scalar value = table_[i].first();
table_[i].first() = t.userTimeToTime(value);
}
}
template<class Type>
Type Foam::TableBase<Type>::value(const scalar x) const
{
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -129,6 +129,9 @@ public:
//- Check maximum table bounds
bool checkMaxBounds(const scalar x, scalar& xDash) const;
//- Convert time
virtual void convertTimeBase(const Time& t);
//- Return Table value
virtual Type value(const scalar x) const;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -122,17 +122,28 @@ public:
// Member Functions
//- Return TableFile value
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
// Manipulation
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const
{
return TableBase<Type>::integrate(x1, x2);
}
//- Convert time
virtual void convertTimeBase(const Time& t)
{
TableBase<Type>::convertTimeBase(t);
}
// Evaluation
//- Return TableFile value
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const
{
return TableBase<Type>::integrate(x1, x2);
}
// I/O
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "polynomial.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -89,6 +90,16 @@ Foam::polynomial::~polynomial()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::polynomial::convertTimeBase(const Time& t)
{
forAll(coeffs_, i)
{
scalar value = coeffs_[i].first();
coeffs_[i].first() = t.userTimeToTime(value);
}
}
Foam::scalar Foam::polynomial::value(const scalar x) const
{
scalar y = 0.0;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -112,11 +112,19 @@ public:
// Member Functions
//- Return polynomial value
scalar value(const scalar x) const;
// Manipulation
//- Integrate between two (scalar) values
scalar integrate(const scalar x1, const scalar x2) const;
//- Convert time
virtual void convertTimeBase(const Time& t);
// Evaluation
//- Return polynomial value
scalar value(const scalar x) const;
//- Integrate between two (scalar) values
scalar integrate(const scalar x1, const scalar x2) const;
// I/O
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 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 "TimeDataEntry.H"
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::TimeDataEntry<Type>::TimeDataEntry
(
const Time& t,
const word& name,
const dictionary& dict
)
:
time_(t),
name_(name),
entry_(DataEntry<Type>::New(name, dict))
{
entry_->convertTimeBase(t);
}
template<class Type>
Foam::TimeDataEntry<Type>::TimeDataEntry(const Time& t, const word& name)
:
time_(t),
name_(name),
entry_(NULL)
{}
template<class Type>
Foam::TimeDataEntry<Type>::TimeDataEntry
(
const TimeDataEntry<Type>& tde
)
:
time_(tde.time_),
name_(tde.name_),
entry_(tde.entry_->clone().ptr())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::TimeDataEntry<Type>::~TimeDataEntry()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::TimeDataEntry<Type>::reset(const dictionary& dict)
{
entry_.reset
(
DataEntry<Type>::New
(
name_,
dict
).ptr()
);
entry_->convertTimeBase(time_);
}
template<class Type>
const Foam::word& Foam::TimeDataEntry<Type>::name() const
{
return entry_->name();
}
template<class Type>
Type Foam::TimeDataEntry<Type>::value(const scalar x) const
{
return entry_->value(x);
}
template<class Type>
Type Foam::TimeDataEntry<Type>::integrate
(
const scalar x1,
const scalar x2
) const
{
return entry_->integrate(x1, x2);
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const TimeDataEntry<Type>& de
)
{
return de.entry_->operator<<(os, de);
}
template<class Type>
void Foam::TimeDataEntry<Type>::writeData(Ostream& os) const
{
entry_->writeData(os);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 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::TimeDataEntry
Description
Light wrapper around DataEntry to provide a mechanism to update time-based
entries.
SourceFiles
TimeDataEntry.C
\*---------------------------------------------------------------------------*/
#ifndef TimeDataEntry_H
#define TimeDataEntry_H
#include "DataEntry.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
class TimeDataEntry;
template<class Type>
Ostream& operator<<
(
Ostream&,
const TimeDataEntry<Type>&
);
/*---------------------------------------------------------------------------*\
Class TimeDataEntry Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class TimeDataEntry
{
protected:
// Protected data
//- Reference to the time database
const Time& time_;
//- Name of the data entry
const word name_;
//- The underlying DataEntry
autoPtr<DataEntry<Type> > entry_;
public:
// Constructor
//- Construct from entry name
TimeDataEntry
(
const Time& t,
const word& name,
const dictionary& dict
);
//- Construct null from entry name
TimeDataEntry
(
const Time& t,
const word& entryName
);
//- Copy constructor
TimeDataEntry(const TimeDataEntry<Type>& tde);
//- Destructor
virtual ~TimeDataEntry();
// Member Functions
// Access
//- Reset entry by re-reading from dictionary
void reset(const dictionary& dict);
//- Return the name of the entry
const word& name() const;
// Evaluation
//- Return value as a function of (scalar) independent variable
virtual Type value(const scalar x) const;
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const;
// I/O
//- Ostream Operator
friend Ostream& operator<< <Type>
(
Ostream& os,
const TimeDataEntry<Type>& de
);
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
};