Commit 29137345 authored by Will Bainbridge's avatar Will Bainbridge
Browse files

Merge branch 'master' of https://github.com/OpenFOAM/OpenFOAM-dev

parents d401f1cf dd154781
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
#include "createFields.H"
Info<< "Reading data file" << endl;
Function1Types::CSV<scalar> pData("pressure", dict, "Data");
Function1Types::CSV<scalar> pData("pressure", dict.subDict("pressureData"));
// time history data
const scalarField t(pData.x());
......
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Web: www.OpenFOAM.org
\\/ M anipulation |
-------------------------------------------------------------------------------
Description
Calculate intensive fields:
- UMean
- translationalT
- internalT
- overallT
from averaged extensive fields from a DSMC calculation.
\*---------------------------------------------------------------------------*/
type dsmcFields;
libs ("liblagrangianFunctionObjects.so");
fields (rhoNMean rhoMMean momentumMean linearKEMean internalEMean
iDofMean fDMean);
executeControl writeTime;
writeControl writeTime;
// ************************************************************************* //
......@@ -76,8 +76,14 @@ primitives/quaternion/quaternion.C
primitives/septernion/septernion.C
primitives/triad/triad.C
/* functions, data entries */
/* Run-time selectable functions */
primitives/functions/Function1/makeDataEntries.C
primitives/functions/Function1/ramp/ramp.C
primitives/functions/Function1/linear/linear.C
primitives/functions/Function1/quadratic/quadratic.C
primitives/functions/Function1/quarterSine/quarterSine.C
primitives/functions/Function1/quarterCosine/quarterCosine.C
primitives/functions/Function1/halfCosine/halfCosine.C
primitives/functions/Polynomial/polynomialFunction.C
primitives/subModelBase/subModelBase.C
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -334,7 +334,19 @@ public:
) const;
//- Find and return a T,
// if not found return the given default value
// if not found throw a fatal error.
// If recursive, search parent dictionaries.
// If patternMatch, use regular expressions.
template<class T>
T lookupType
(
const word&,
bool recursive=false,
bool patternMatch=true
) const;
//- Find and return a T,
// if not found return the given default value.
// If recursive, search parent dictionaries.
// If patternMatch, use regular expressions.
template<class T>
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -28,6 +28,30 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
T Foam::dictionary::lookupType
(
const word& keyword,
bool recursive,
bool patternMatch
) const
{
const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
if (entryPtr == nullptr)
{
FatalIOErrorInFunction
(
*this
) << "keyword " << keyword << " is undefined in dictionary "
<< name()
<< exit(FatalIOError);
}
return pTraits<T>(entryPtr->stream());
}
template<class T>
T Foam::dictionary::lookupOrDefault
(
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -125,6 +125,9 @@ public:
//- Return const object pointer
inline const T* operator->() const;
//- Take over the object pointer from parameter
inline void operator=(T*);
//- Take over the object pointer from parameter
inline void operator=(const autoPtr<T>&);
};
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -190,6 +190,13 @@ inline const T* Foam::autoPtr<T>::operator->() const
}
template<class T>
inline void Foam::autoPtr<T>::operator=(T* p)
{
reset(p);
}
template<class T>
inline void Foam::autoPtr<T>::operator=(const autoPtr<T>& ap)
{
......
......@@ -203,18 +203,16 @@ template<class Type>
Foam::Function1Types::CSV<Type>::CSV
(
const word& entryName,
const dictionary& dict,
const word& ext
const dictionary& dict
)
:
TableBase<Type>(entryName, dict.subDict(entryName + ext)),
coeffs_(dict.subDict(entryName + ext)),
nHeaderLine_(readLabel(coeffs_.lookup("nHeaderLine"))),
refColumn_(readLabel(coeffs_.lookup("refColumn"))),
componentColumns_(coeffs_.lookup("componentColumns")),
separator_(coeffs_.lookupOrDefault<string>("separator", string(","))[0]),
mergeSeparators_(readBool(coeffs_.lookup("mergeSeparators"))),
fName_(coeffs_.lookup("file"))
TableBase<Type>(entryName, dict),
nHeaderLine_(readLabel(dict.lookup("nHeaderLine"))),
refColumn_(readLabel(dict.lookup("refColumn"))),
componentColumns_(dict.lookup("componentColumns")),
separator_(dict.lookupOrDefault<string>("separator", string(","))[0]),
mergeSeparators_(readBool(dict.lookup("mergeSeparators"))),
fName_(dict.lookup("file"))
{
if (componentColumns_.size() != pTraits<Type>::nComponents)
{
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -25,9 +25,11 @@ Class
Foam::Function1Types::CSV
Description
Templated CSV container data entry. Reference column is always a scalar,
e.g. time
Templated CSV function.
Reference column is always a scalar, e.g. time.
Usage:
\verbatim
<entryName> csvFile;
<entryName>Coeffs
......@@ -75,9 +77,6 @@ class CSV
{
// Private data
//- Coefficients dictionary (for convenience on reading)
dictionary coeffs_;
//- Number header lines
label nHeaderLine_;
......@@ -121,8 +120,7 @@ public:
CSV
(
const word& entryName,
const dictionary& dict,
const word& ext = "Coeffs"
const dictionary& dict
);
//- Copy constructor
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -25,9 +25,9 @@ Class
Foam::Function1Types::Constant
Description
Templated basic entry that holds a constant value.
Templated function that returns a constant value.
Usage - for entry \<entryName\> having the value <value>:
Usage - for entry \<entryName\> returning the value <value>:
\verbatim
<entryName> constant <value>
\endverbatim
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -195,6 +195,14 @@ public:
add##SS##Type##ConstructorToTable_;
#define makeScalarFunction1(SS) \
\
defineTypeNameAndDebug(SS, 0); \
\
Function1<scalar>::adddictionaryConstructorToTable<SS> \
add##SS##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -34,39 +34,70 @@ Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
const dictionary& dict
)
{
Istream& is(dict.lookup(entryName, false));
if (dict.isDict(entryName))
{
const dictionary& coeffsDict(dict.subDict(entryName));
token firstToken(is);
word Function1Type;
const word Function1Type(coeffsDict.lookup("type"));
if (!firstToken.isWord())
{
is.putBack(firstToken);
return autoPtr<Function1<Type>>
(
new Function1Types::Constant<Type>(entryName, is)
);
typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(Function1Type);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown Function1 type "
<< Function1Type << " for Function1 "
<< entryName << nl << nl
<< "Valid Function1 types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << nl
<< exit(FatalError);
}
return cstrIter()(entryName, coeffsDict);
}
else
{
Function1Type = firstToken.wordToken();
}
Istream& is(dict.lookup(entryName, false));
typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(Function1Type);
token firstToken(is);
word Function1Type;
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown Function1 type "
<< Function1Type << " for Function1 "
<< entryName << nl << nl
<< "Valid Function1 types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << nl
<< exit(FatalError);
}
if (!firstToken.isWord())
{
is.putBack(firstToken);
return autoPtr<Function1<Type>>
(
new Function1Types::Constant<Type>(entryName, is)
);
}
else
{
Function1Type = firstToken.wordToken();
}
typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(Function1Type);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown Function1 type "
<< Function1Type << " for Function1 "
<< entryName << nl << nl
<< "Valid Function1 types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << nl
<< exit(FatalError);
}
return cstrIter()(entryName, dict);
return cstrIter()
(
entryName,
dict.found(entryName + "Coeffs")
? dict.subDict(entryName + "Coeffs")
: dict
);
}
}
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 "OneConstant.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::Function1Types::OneConstant<Type>::OneConstant(const word& entryName)
:
Function1<Type>(entryName)
{}
template<class Type>
Foam::Function1Types::OneConstant<Type>::OneConstant
(
const word& entryName,
const dictionary& dict
)
:
Function1<Type>(entryName)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::Function1Types::OneConstant<Type>::~OneConstant()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Type Foam::Function1Types::OneConstant<Type>::value(const scalar x) const
{
return pTraits<Type>::one;
}
template<class Type>
Type Foam::Function1Types::OneConstant<Type>::integrate
(
const scalar x1,
const scalar x2
) const
{
return (x2 - x1)*pTraits<Type>::one;
}
template<class Type>
void Foam::Function1Types::OneConstant<Type>::writeData(Ostream& os) const
{
Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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::Function1Types::OneConstant
Description
Templated function that returns the corresponding 1 (one).
Usage:
\verbatim
<entryName> one;
\endverbatim
SourceFiles
OneConstant.C
\*---------------------------------------------------------------------------*/
#ifndef OneConstant_H
#define OneConstant_H
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace Function1Types
{
/*---------------------------------------------------------------------------*\
Class OneConstant Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class OneConstant
:
public Function1<Type>
{
// Private Member Functions
//- Disallow default bitwise assignment
void operator=(const OneConstant<Type>&);
public:
// Runtime type information
TypeName("one");
// Constructors
//- Construct from entry name
OneConstant(const word& entryName);
//- Construct from entry name and dictionary
OneConstant(const word& entryName, const dictionary& dict);
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return tmp<Function1<Type>>(new OneConstant<Type>(*this));
}
//- Destructor
virtual ~OneConstant();
// Member Functions
//- Return constant value
Type value(const scalar) const;
//- Integrate between two values
Type integrate(const scalar x1, const scalar x2) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Function1Types
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "OneConstant.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation