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
48c70a91
Commit
48c70a91
authored
Apr 13, 2012
by
sergio
Browse files
ENH: Adding dimensioSet to DataEntry and modify MRFZone entry types
parent
8909ecc8
Changes
29
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C
View file @
48c70a91
...
...
@@ -154,6 +154,16 @@ dimensioned<Type>::dimensioned
}
template
<
class
Type
>
dimensioned
<
Type
>::
dimensioned
()
:
name_
(
"undefined"
),
dimensions_
(
dimless
),
value_
(
pTraits
<
Type
>::
zero
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class
Type
>
...
...
src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H
View file @
48c70a91
...
...
@@ -107,6 +107,9 @@ public:
//- Construct from an Istream with a given name and dimensions
dimensioned
(
const
word
&
,
const
dimensionSet
&
,
Istream
&
);
//- Null constructor
dimensioned
();
//- Construct from dictionary, with default value.
static
dimensioned
<
Type
>
lookupOrDefault
(
...
...
src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H
View file @
48c70a91
...
...
@@ -163,6 +163,22 @@ public:
return
TableBase
<
Type
>::
integrate
(
x1
,
x2
);
}
//- Return dimensioned constant value
virtual
dimensioned
<
Type
>
dimValue
(
const
scalar
x
)
const
{
return
TableBase
<
Type
>::
dimValue
(
x
);
}
//- Integrate between two values and return dimensioned type
virtual
dimensioned
<
Type
>
dimIntegrate
(
const
scalar
x1
,
const
scalar
x2
)
const
{
return
TableBase
<
Type
>::
dimIntegrate
(
x1
,
x2
);
}
// I/O
...
...
src/OpenFOAM/primitives/functions/DataEntry/CompatibilityConstant/CompatibilityConstant.C
View file @
48c70a91
...
...
@@ -34,9 +34,27 @@ Foam::CompatibilityConstant<Type>::CompatibilityConstant
)
:
DataEntry
<
Type
>
(
entryName
),
value_
(
pTraits
<
Type
>::
zero
)
value_
(
pTraits
<
Type
>::
zero
),
dimensions_
(
dimless
)
{
dict
.
lookup
(
entryName
)
>>
value_
;
Istream
&
is
(
dict
.
lookup
(
entryName
));
token
firstToken
(
is
);
if
(
firstToken
.
isWord
())
{
token
nextToken
(
is
);
if
(
nextToken
==
token
::
BEGIN_SQR
)
{
is
.
putBack
(
nextToken
);
is
>>
dimensions_
;
is
>>
value_
;
}
}
else
{
is
.
putBack
(
firstToken
);
is
>>
value_
;
}
}
...
...
@@ -47,10 +65,10 @@ Foam::CompatibilityConstant<Type>::CompatibilityConstant
)
:
DataEntry
<
Type
>
(
cnst
),
value_
(
cnst
.
value_
)
value_
(
cnst
.
value_
),
dimensions_
(
cnst
.
dimensions_
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template
<
class
Type
>
...
...
@@ -78,6 +96,23 @@ Type Foam::CompatibilityConstant<Type>::integrate
}
template
<
class
Type
>
Foam
::
dimensioned
<
Type
>
Foam
::
CompatibilityConstant
<
Type
>::
dimValue
(
const
scalar
x
)
const
{
return
dimensioned
<
Type
>
(
"dimensionedValue"
,
dimensions_
,
value_
);
}
template
<
class
Type
>
Foam
::
dimensioned
<
Type
>
Foam
::
CompatibilityConstant
<
Type
>::
dimIntegrate
(
const
scalar
x1
,
const
scalar
x2
)
const
{
return
dimensioned
<
Type
>
(
"dimensionedValue"
,
dimensions_
,
(
x2
-
x1
)
*
value_
);
}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include
"CompatibilityConstantIO.C"
...
...
src/OpenFOAM/primitives/functions/DataEntry/CompatibilityConstant/CompatibilityConstant.H
View file @
48c70a91
...
...
@@ -42,6 +42,7 @@ SourceFiles
#define CompatibilityConstant_H
#include
"DataEntry.H"
#include
"dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -68,6 +69,9 @@ class CompatibilityConstant
//- Constant value
Type
value_
;
//- The dimension set
dimensionSet
dimensions_
;
// Private Member Functions
...
...
@@ -111,6 +115,16 @@ public:
//- Integrate between two values
Type
integrate
(
const
scalar
x1
,
const
scalar
x2
)
const
;
//- Return dimensioned constant value
dimensioned
<
Type
>
dimValue
(
const
scalar
)
const
;
//- Integrate between two values and return dimensioned type
dimensioned
<
Type
>
dimIntegrate
(
const
scalar
x1
,
const
scalar
x2
)
const
;
// I/O
...
...
src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C
View file @
48c70a91
...
...
@@ -31,12 +31,27 @@ template<class Type>
Foam
::
Constant
<
Type
>::
Constant
(
const
word
&
entryName
,
const
dictionary
&
dict
)
:
DataEntry
<
Type
>
(
entryName
),
value_
(
pTraits
<
Type
>::
zero
)
value_
(
pTraits
<
Type
>::
zero
),
dimensions_
(
dimless
)
{
Istream
&
is
(
dict
.
lookup
(
entryName
));
word
entryType
(
is
);
is
>>
value_
;
token
firstToken
(
is
);
if
(
firstToken
.
isWord
())
{
token
nextToken
(
is
);
if
(
nextToken
==
token
::
BEGIN_SQR
)
{
is
.
putBack
(
nextToken
);
is
>>
dimensions_
;
is
>>
value_
;
}
}
else
{
is
.
putBack
(
firstToken
);
is
>>
value_
;
}
}
...
...
@@ -44,7 +59,8 @@ template<class Type>
Foam
::
Constant
<
Type
>::
Constant
(
const
Constant
<
Type
>&
cnst
)
:
DataEntry
<
Type
>
(
cnst
),
value_
(
cnst
.
value_
)
value_
(
cnst
.
value_
),
dimensions_
(
cnst
.
dimensions_
)
{}
...
...
@@ -71,6 +87,22 @@ Type Foam::Constant<Type>::integrate(const scalar x1, const scalar x2) const
}
template
<
class
Type
>
Foam
::
dimensioned
<
Type
>
Foam
::
Constant
<
Type
>::
dimValue
(
const
scalar
x
)
const
{
return
dimensioned
<
Type
>
(
"dimensionedValue"
,
dimensions_
,
value_
);
}
template
<
class
Type
>
Foam
::
dimensioned
<
Type
>
Foam
::
Constant
<
Type
>::
dimIntegrate
(
const
scalar
x1
,
const
scalar
x2
)
const
{
return
dimensioned
<
Type
>
(
"dimensionedValue"
,
dimensions_
,
(
x2
-
x1
)
*
value_
);
}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include
"ConstantIO.C"
...
...
src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H
View file @
48c70a91
...
...
@@ -41,6 +41,7 @@ SourceFiles
#define Constant_H
#include
"DataEntry.H"
#include
"dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -67,6 +68,9 @@ class Constant
//- Constant value
Type
value_
;
//- The dimension set
dimensionSet
dimensions_
;
// Private Member Functions
...
...
@@ -107,6 +111,16 @@ public:
//- Integrate between two values
Type
integrate
(
const
scalar
x1
,
const
scalar
x2
)
const
;
//- Return dimensioned constant value
dimensioned
<
Type
>
dimValue
(
const
scalar
)
const
;
//- Integrate between two values and return dimensioned type
dimensioned
<
Type
>
dimIntegrate
(
const
scalar
x1
,
const
scalar
x2
)
const
;
// I/O
...
...
src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.C
View file @
48c70a91
...
...
@@ -76,6 +76,22 @@ Type Foam::DataEntry<Type>::value(const scalar x) const
}
template
<
class
Type
>
Type
Foam
::
DataEntry
<
Type
>::
integrate
(
const
scalar
x1
,
const
scalar
x2
)
const
{
notImplemented
(
"Type Foam::DataEntry<Type>::integrate"
"("
"const scalar, "
"const scalar"
") const"
);
return
pTraits
<
Type
>::
zero
;
}
template
<
class
Type
>
Foam
::
tmp
<
Foam
::
Field
<
Type
>
>
Foam
::
DataEntry
<
Type
>::
value
(
...
...
@@ -94,34 +110,102 @@ Foam::tmp<Foam::Field<Type> > Foam::DataEntry<Type>::value
template
<
class
Type
>
Type
Foam
::
DataEntry
<
Type
>::
integrate
(
const
scalar
x1
,
const
scalar
x2
)
const
Foam
::
tmp
<
Foam
::
Field
<
Type
>
>
Foam
::
DataEntry
<
Type
>::
integrate
(
const
scalarField
&
x1
,
const
scalarField
&
x2
)
const
{
tmp
<
Field
<
Type
>
>
tfld
(
new
Field
<
Type
>
(
x1
.
size
()));
Field
<
Type
>&
fld
=
tfld
();
forAll
(
x1
,
i
)
{
fld
[
i
]
=
this
->
integrate
(
x1
[
i
],
x2
[
i
]);
}
return
tfld
;
}
template
<
class
Type
>
Foam
::
dimensioned
<
Type
>
Foam
::
DataEntry
<
Type
>::
dimValue
(
const
scalar
x
)
const
{
notImplemented
(
"Type Foam::DataEntry<Type>::integrate"
"dimensioned<Type> Foam::DataEntry<dimensioned<Type> >::dimValue"
"(const scalar) const"
);
return
dimensioned
<
Type
>
(
"zero"
,
dimless
,
pTraits
<
Type
>::
zero
);
}
template
<
class
Type
>
Foam
::
dimensioned
<
Type
>
Foam
::
DataEntry
<
Type
>::
dimIntegrate
(
const
scalar
x1
,
const
scalar
x2
)
const
{
notImplemented
(
"dimensioned<Type> Foam::DataEntry<Type>::dimIntegrate"
"("
"const scalar, "
"const scalar"
") const"
);
return
pTraits
<
Type
>::
zero
;
return
dimensioned
<
Type
>
(
"zero"
,
dimless
,
pTraits
<
Type
>::
zero
)
;
}
template
<
class
Type
>
Foam
::
tmp
<
Foam
::
Field
<
Type
>
>
Foam
::
DataEntry
<
Type
>::
integrate
Foam
::
tmp
<
Foam
::
Field
<
Foam
::
dimensioned
<
Type
>
>
>
Foam
::
DataEntry
<
Type
>::
dimValue
(
const
scalarField
&
x
)
const
{
tmp
<
Field
<
dimensioned
<
Type
>
>
>
tfld
(
new
Field
<
dimensioned
<
Type
>
>
(
x
.
size
(),
dimensioned
<
Type
>
(
"zero"
,
dimless
,
pTraits
<
Type
>::
zero
)
)
);
Field
<
dimensioned
<
Type
>
>&
fld
=
tfld
();
forAll
(
x
,
i
)
{
fld
[
i
]
=
this
->
dimValue
(
x
[
i
]);
}
return
tfld
;
}
template
<
class
Type
>
Foam
::
tmp
<
Foam
::
Field
<
Foam
::
dimensioned
<
Type
>
>
>
Foam
::
DataEntry
<
Type
>::
dimIntegrate
(
const
scalarField
&
x1
,
const
scalarField
&
x2
)
const
{
tmp
<
Field
<
Type
>
>
tfld
(
new
Field
<
Type
>
(
x1
.
size
()));
Field
<
Type
>&
fld
=
tfld
();
tmp
<
Field
<
dimensioned
<
Type
>
>
>
tfld
(
new
Field
<
dimensioned
<
Type
>
>
(
x1
.
size
())
);
Field
<
dimensioned
<
Type
>
>&
fld
=
tfld
();
forAll
(
x1
,
i
)
{
fld
[
i
]
=
this
->
i
ntegrate
(
x1
[
i
],
x2
[
i
]);
fld
[
i
]
=
this
->
dimI
ntegrate
(
x1
[
i
],
x2
[
i
]);
}
return
tfld
;
}
...
...
src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H
View file @
48c70a91
...
...
@@ -41,6 +41,7 @@ SourceFiles
#include
"dictionary.H"
#include
"Field.H"
#include
"dimensionedType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -141,23 +142,49 @@ public:
virtual
void
convertTimeBase
(
const
Time
&
t
);
// Evaluation
public:
// Evaluation
//- Return value as a function of (scalar) independent variable
virtual
Type
value
(
const
scalar
x
)
const
;
//- Return value as a function of (scalar) independent variable
virtual
Type
value
(
const
scalar
x
)
const
;
//- Return value as a function of (scalar) independent variable
virtual
tmp
<
Field
<
Type
>
>
value
(
const
scalarField
&
x
)
const
;
//- Return value as a function of (scalar) independent variable
virtual
tmp
<
Field
<
Type
>
>
value
(
const
scalarField
&
x
)
const
;
//- Integrate between two (scalar) values
virtual
Type
integrate
(
const
scalar
x1
,
const
scalar
x2
)
const
;
//- Integrate between two (scalar) values
virtual
tmp
<
Field
<
Type
>
>
integrate
(
const
scalarField
&
x1
,
const
scalarField
&
x2
)
const
;
//- Integrate between two (scalar) values
virtual
Type
integrate
(
const
scalar
x1
,
const
scalar
x2
)
const
;
//- Return dimensioned type
virtual
dimensioned
<
Type
>
dimValue
(
const
scalar
x
)
const
;
//- Integrate between two (scalar) values
virtual
tmp
<
Field
<
Type
>
>
integrate
(
const
scalarField
&
x1
,
const
scalarField
&
x2
)
const
;
//- Return dimensioned type as a function of (scalar)
virtual
tmp
<
Field
<
dimensioned
<
Type
>
>
>
dimValue
(
const
scalarField
&
x
)
const
;
//- Integrate between two scalars and returns a dimensioned type
virtual
dimensioned
<
Type
>
dimIntegrate
(
const
scalar
x1
,
const
scalar
x2
)
const
;
//- Integrate between two scalars and returns list of dimensioned type
virtual
tmp
<
Field
<
dimensioned
<
Type
>
>
>
dimIntegrate
(
const
scalarField
&
x1
,
const
scalarField
&
x2
)
const
;
// I/O
...
...
src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C
View file @
48c70a91
...
...
@@ -41,7 +41,15 @@ Foam::autoPtr<Foam::DataEntry<Type> > Foam::DataEntry<Type>::New
word
DataEntryType
;
if
(
firstToken
.
isWord
())
{
DataEntryType
=
firstToken
.
wordToken
();
// Dimensioned type default compatibility
if
(
firstToken
.
wordToken
()
==
entryName
)
{
DataEntryType
=
"CompatibilityConstant"
;
}
else
{
DataEntryType
=
firstToken
.
wordToken
();
}
}
else
{
...
...
src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C
View file @
48c70a91
...
...
@@ -36,6 +36,12 @@ Foam::Table<Type>::Table(const word& entryName, const dictionary& dict)
Istream
&
is
(
dict
.
lookup
(
entryName
));
word
entryType
(
is
);
token
firstToken
(
is
);
is
.
putBack
(
firstToken
);
if
(
firstToken
==
token
::
BEGIN_SQR
)
{
is
>>
this
->
dimensions_
;
}
is
>>
this
->
table_
;
TableBase
<
Type
>::
check
();
...
...
src/OpenFOAM/primitives/functions/DataEntry/Table/Table.H
View file @
48c70a91
...
...
@@ -30,7 +30,7 @@ Description
in the form, e.g. for an entry \<entryName\> that is (scalar, vector):
\verbatim
<entryName> table
<entryName> table
[0 1 0 0 0] //dimension set optional
(
0.0 (1 2 3)
1.0 (4 5 6)
...
...
@@ -129,6 +129,22 @@ public:
return
TableBase
<
Type
>::
integrate
(
x1
,
x2
);
}
//- Return dimensioned constant value
virtual
dimensioned
<
Type
>
dimValue
(
const
scalar
x
)
const
{
return
TableBase
<
Type
>::
dimValue
(
x
);
}
//- Integrate between two values and return dimensioned type
virtual
dimensioned
<
Type
>
dimIntegrate
(
const
scalar
x1
,
const
scalar
x2
)
{
return
TableBase
<
Type
>::
dimIntegrate
(
x1
,
x2
);
}
// I/O
...
...
src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C
View file @
48c70a91
...
...
@@ -39,7 +39,8 @@ Foam::TableBase<Type>::TableBase(const word& name, const dictionary& dict)
dict
.
lookupOrDefault
<
word
>
(
"outOfBounds"
,
"clamp"
)
)
),
table_
()
table_
(),
dimensions_
(
dimless
)
{}
...
...
@@ -48,7 +49,8 @@ Foam::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
:
name_
(
tbl
.
name_
),
boundsHandling_
(
tbl
.
boundsHandling_
),
table_
(
tbl
.
table_
)
table_
(
tbl
.
table_
),
dimensions_
(
tbl
.
dimensions_
)
{}
...
...
@@ -330,6 +332,11 @@ Type Foam::TableBase<Type>::value(const scalar x) const
i
++
;
}
Info
<<
(
xDash
-
table_
[
i
].
first
())
/
(
table_
[
i
+
1
].
first
()
-
table_
[
i
].
first
())
*
(
table_
[
i
+
1
].
second
()
-
table_
[
i
].
second
())
+
table_
[
i
].
second
()
<<
endl
;
// Linear interpolation to find value
return
Type
(
...
...
@@ -403,6 +410,28 @@ Type Foam::TableBase<Type>::integrate(const scalar x1, const scalar x2) const
}
template
<
class
Type
>
Foam
::
dimensioned
<
Type
>
Foam
::
TableBase
<
Type
>::
dimValue
(
const
scalar
x
)
const
{
return
dimensioned
<
Type
>
(
"dimensionedValue"
,
dimensions_
,
this
->
value
(
x
));
}
template
<
class
Type
>
Foam
::
dimensioned
<
Type
>
Foam
::
TableBase
<
Type
>::
dimIntegrate
(
const
scalar
x1
,
const
scalar
x2
)
const
{
return
dimensioned
<
Type
>
(
"dimensionedValue"
,
dimensions_
,
this
->
integrate
(
x2
,
x1
)
);
}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include
"TableBaseIO.C"
...
...
src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H
View file @
48c70a91
...
...
@@ -37,6 +37,7 @@ SourceFiles
#include
"DataEntry.H"
#include
"Tuple2.H"
#include
"dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -87,6 +88,9 @@ protected:
//- Table data
List
<
Tuple2
<
scalar
,
Type
>
>
table_
;
//- The dimension set
dimensionSet
dimensions_
;