Skip to content
Snippets Groups Projects
Commit 00db27b9 authored by Henry's avatar Henry
Browse files

UniformField: New field type

parent 1e85b525
Branches
Tags
No related merge requests found
Test-UniformField.C
EXE = $(FOAM_USER_APPBIN)/Test-UniformField
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
/* EXE_LIBS = -lfiniteVolume */
#include "UniformField.H"
#include "vector.H"
#include "IOstreams.H"
using namespace Foam;
int main()
{
UniformField<scalar> uf1(13.1);
UniformField<vector> uf2(vector(1, 2, 3));
Info<< "uf1 = " << uf1[22] << "; uf2 = " << uf2[1002] << endl;
return 0;
}
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 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::UniformField
Description
A class representing the concept of a uniform field which stores only
the single value and providing the operator[] to return it.
\*---------------------------------------------------------------------------*/
#ifndef UniformField_H
#define UniformField_H
#include "label.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class UniformField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class UniformField
{
// Private data
Type value_;
public:
// Constructors
//- Construct given value
inline UniformField(const Type& value);
// Member Operators
inline Type operator[](const label) const;
inline UniformField field() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "UniformFieldI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 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 "UniformField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
inline Foam::UniformField<Type>::UniformField(const Type& value)
:
value_(value)
{}
template<class Type>
inline Type Foam::UniformField<Type>::operator[](const label) const
{
return value_;
}
template<class Type>
inline Foam::UniformField<Type> Foam::UniformField<Type>::field() const
{
return UniformField(value_);
}
// ************************************************************************* //
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment