Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
da720bbf
Commit
da720bbf
authored
Jan 10, 2012
by
sergio
Browse files
ENH: Adding interpolation2D table
parent
31f1478c
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C
0 → 100644
View file @
da720bbf
This diff is collapsed.
Click to expand it.
src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.H
0 → 100644
View file @
da720bbf
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::interpolation2DTable
Description
2D table interpolation. The data must be in ascending order in both dimensions
x and y.
SourceFiles
interpolation2DTable.C
\*---------------------------------------------------------------------------*/
#ifndef interpolation2DTable_H
#define interpolation2DTable_H
#include
"List.H"
#include
"Tuple2.H"
#include
"tableReader.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
/*---------------------------------------------------------------------------*\
Class interpolation2DTable Declaration
\*---------------------------------------------------------------------------*/
template
<
class
Type
>
class
interpolation2DTable
:
public
List
<
Tuple2
<
scalar
,
List
<
Tuple2
<
scalar
,
Type
>
>
>
>
{
public:
// Public data types
//- Enumeration for handling out-of-bound values
enum
boundsHandling
{
ERROR
,
/*!< Exit with a FatalError */
WARN
,
/*!< Issue warning and clamp value (default) */
CLAMP
/*!< Clamp value to the start/end value */
};
private:
// Private data
//- Enumeration for handling out-of-bound values
boundsHandling
boundsHandling_
;
//- File name
fileName
fileName_
;
//- the actual reader
autoPtr
<
tableReader
<
Type
>
>
reader_
;
// Private Member Functions
//- Read the table of data from file
void
readTable
();
//- Return interpolated value in List
Type
interpolateValue
(
const
List
<
Tuple2
<
scalar
,
Type
>
>&
data
,
const
scalar
)
const
;
public:
// Constructors
//- Construct null
interpolation2DTable
();
//- Construct from components
interpolation2DTable
(
const
List
<
Tuple2
<
scalar
,
List
<
Tuple2
<
scalar
,
Type
>
>
>
>&
values
,
const
boundsHandling
bounds
,
const
fileName
&
fName
);
//- Construct given the name of the file containing the table of data
interpolation2DTable
(
const
fileName
&
fName
);
//- Construct by reading the fileName and boundsHandling from dictionary
interpolation2DTable
(
const
dictionary
&
dict
);
//- Construct copy
interpolation2DTable
(
const
interpolation2DTable
&
interpTable
);
// Member Functions
//- Return the out-of-bounds handling as a word
word
boundsHandlingToWord
(
const
boundsHandling
&
bound
)
const
;
//- Return the out-of-bounds handling as an enumeration
boundsHandling
wordToBoundsHandling
(
const
word
&
bound
)
const
;
//- Set the out-of-bounds handling from enum, return previous setting
boundsHandling
outOfBounds
(
const
boundsHandling
&
bound
);
//- Check that list is monotonically increasing
// Exit with a FatalError if there is a problem
void
check
()
const
;
//- Write
void
write
(
Ostream
&
os
)
const
;
// Member Operators
//- Return an element of constant Tuple2<scalar, Type>
const
List
<
Tuple2
<
scalar
,
Type
>
>&
operator
[](
const
label
)
const
;
//- Return an interpolated value
Type
operator
()(
const
scalar
,
const
scalar
)
const
;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "interpolation2DTable.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C
View file @
da720bbf
...
...
@@ -162,6 +162,17 @@ void Foam::csvTableReader<Type>::operator()
}
template
<
class
Type
>
void
Foam
::
csvTableReader
<
Type
>::
operator
()
(
const
fileName
&
fName
,
List
<
Tuple2
<
scalar
,
List
<
Tuple2
<
scalar
,
Type
>
>
>
>&
data
)
{
notImplemented
(
"csvTableReader<Type>::operator()"
);
}
template
<
class
Type
>
void
Foam
::
csvTableReader
<
Type
>::
write
(
Ostream
&
os
)
const
{
...
...
src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.H
View file @
da720bbf
...
...
@@ -103,6 +103,13 @@ public:
//- Read the table
virtual
void
operator
()(
const
fileName
&
,
List
<
Tuple2
<
scalar
,
Type
>
>&
);
//- Read 2D table
virtual
void
operator
()
(
const
fileName
&
,
List
<
Tuple2
<
scalar
,
List
<
Tuple2
<
scalar
,
Type
>
>
>
>&
);
//- write the remaining parameters
virtual
void
write
(
Ostream
&
os
)
const
;
};
...
...
src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.C
View file @
da720bbf
...
...
@@ -56,4 +56,16 @@ void Foam::openFoamTableReader<Type>::operator()
}
template
<
class
Type
>
void
Foam
::
openFoamTableReader
<
Type
>::
operator
()
(
const
fileName
&
fName
,
List
<
Tuple2
<
scalar
,
List
<
Tuple2
<
scalar
,
Type
>
>
>
>&
data
)
{
// Read data from file
IFstream
(
fName
)()
>>
data
;
}
// ************************************************************************* //
src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.H
View file @
da720bbf
...
...
@@ -84,6 +84,13 @@ public:
//- Read the table
virtual
void
operator
()(
const
fileName
&
,
List
<
Tuple2
<
scalar
,
Type
>
>
&
);
//- Read 2D table
virtual
void
operator
()
(
const
fileName
&
,
List
<
Tuple2
<
scalar
,
List
<
Tuple2
<
scalar
,
Type
>
>
>
>&
);
};
...
...
src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.H
View file @
da720bbf
...
...
@@ -103,6 +103,13 @@ public:
List
<
Tuple2
<
scalar
,
Type
>
>&
)
=
0
;
//- Read the 2D table
virtual
void
operator
()
(
const
fileName
&
,
List
<
Tuple2
<
scalar
,
List
<
Tuple2
<
scalar
,
Type
>
>
>
>&
)
=
0
;
//- Write additional information
virtual
void
write
(
Ostream
&
os
)
const
;
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment