mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
UniformField: New field type
This commit is contained in:
3
applications/test/UniformField/Make/files
Normal file
3
applications/test/UniformField/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-UniformField.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-UniformField
|
||||||
2
applications/test/UniformField/Make/options
Normal file
2
applications/test/UniformField/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
|
||||||
|
/* EXE_LIBS = -lfiniteVolume */
|
||||||
15
applications/test/UniformField/Test-UniformField.C
Normal file
15
applications/test/UniformField/Test-UniformField.C
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#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;
|
||||||
|
}
|
||||||
82
src/OpenFOAM/fields/Fields/uniformField/UniformField.H
Normal file
82
src/OpenFOAM/fields/Fields/uniformField/UniformField.H
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
51
src/OpenFOAM/fields/Fields/uniformField/UniformFieldI.H
Normal file
51
src/OpenFOAM/fields/Fields/uniformField/UniformFieldI.H
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user