Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
HPCAPPs
OpenFOAM-GPU-v2.0
Commits
55e5a777
Commit
55e5a777
authored
Oct 17, 2024
by
shunbo
Browse files
initial commit
parents
Changes
677
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1210 additions
and
0 deletions
+1210
-0
OpenFOAM-v2112/applications/test/IOField/Make/files
OpenFOAM-v2112/applications/test/IOField/Make/files
+3
-0
OpenFOAM-v2112/applications/test/IOField/Make/options
OpenFOAM-v2112/applications/test/IOField/Make/options
+2
-0
OpenFOAM-v2112/applications/test/IOField/Test-IOField.C
OpenFOAM-v2112/applications/test/IOField/Test-IOField.C
+242
-0
OpenFOAM-v2112/applications/test/IOobjectList/Make/files
OpenFOAM-v2112/applications/test/IOobjectList/Make/files
+3
-0
OpenFOAM-v2112/applications/test/IOobjectList/Make/options
OpenFOAM-v2112/applications/test/IOobjectList/Make/options
+3
-0
OpenFOAM-v2112/applications/test/IOobjectList/Test-IOobjectList.C
...-v2112/applications/test/IOobjectList/Test-IOobjectList.C
+337
-0
OpenFOAM-v2112/applications/test/ISLList/Make/files
OpenFOAM-v2112/applications/test/ISLList/Make/files
+3
-0
OpenFOAM-v2112/applications/test/ISLList/Make/options
OpenFOAM-v2112/applications/test/ISLList/Make/options
+2
-0
OpenFOAM-v2112/applications/test/ISLList/Test-ISLList.C
OpenFOAM-v2112/applications/test/ISLList/Test-ISLList.C
+159
-0
OpenFOAM-v2112/applications/test/IStringStream/Make/files
OpenFOAM-v2112/applications/test/IStringStream/Make/files
+3
-0
OpenFOAM-v2112/applications/test/IStringStream/Make/options
OpenFOAM-v2112/applications/test/IStringStream/Make/options
+2
-0
OpenFOAM-v2112/applications/test/IStringStream/Test-IStringStream.C
...2112/applications/test/IStringStream/Test-IStringStream.C
+64
-0
OpenFOAM-v2112/applications/test/ITstream/Make/files
OpenFOAM-v2112/applications/test/ITstream/Make/files
+3
-0
OpenFOAM-v2112/applications/test/ITstream/Make/options
OpenFOAM-v2112/applications/test/ITstream/Make/options
+2
-0
OpenFOAM-v2112/applications/test/ITstream/Test-ITstream.C
OpenFOAM-v2112/applications/test/ITstream/Test-ITstream.C
+194
-0
OpenFOAM-v2112/applications/test/IjkField/Make/files
OpenFOAM-v2112/applications/test/IjkField/Make/files
+3
-0
OpenFOAM-v2112/applications/test/IjkField/Make/options
OpenFOAM-v2112/applications/test/IjkField/Make/options
+4
-0
OpenFOAM-v2112/applications/test/IjkField/Test-IjkField.C
OpenFOAM-v2112/applications/test/IjkField/Test-IjkField.C
+176
-0
OpenFOAM-v2112/applications/test/IndirectList/Make/files
OpenFOAM-v2112/applications/test/IndirectList/Make/files
+3
-0
OpenFOAM-v2112/applications/test/IndirectList/Make/options
OpenFOAM-v2112/applications/test/IndirectList/Make/options
+2
-0
No files found.
Too many changes to show.
To preserve performance only
677 of 677+
files are displayed.
Plain diff
Email patch
OpenFOAM-v2112/applications/test/IOField/Make/files
0 → 100644
View file @
55e5a777
Test-IOField.C
EXE = $(FOAM_USER_APPBIN)/Test-IOField
OpenFOAM-v2112/applications/test/IOField/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
/* EXE_LIBS = -lfiniteVolume */
OpenFOAM-v2112/applications/test/IOField/Test-IOField.C
0 → 100644
View file @
55e5a777
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
Application
Test-IOField
Description
Test the processor-local reading of IOField (used in the lagrangian libs)
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IOField.H"
#include "primitiveFields.H"
#include "polyMesh.H"
#include "Time.H"
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
<
class
Type
>
void
doWrite
(
const
IOobject
&
io
,
const
label
sz
)
{
IOField
<
Type
>
fld
(
io
,
sz
);
forAll
(
fld
,
i
)
{
fld
[
i
]
=
i
+
1000
.
25
+
(
0
.
25
*
i
);
}
Pout
<<
"writing:"
<<
fld
<<
endl
;
fld
.
write
(
sz
>
0
);
}
template
<>
void
doWrite
<
bool
>
(
const
IOobject
&
io
,
const
label
sz
)
{
IOField
<
bool
>
fld
(
io
,
sz
);
forAll
(
fld
,
i
)
{
fld
[
i
]
=
i
%
2
;
}
Pout
<<
"writing:"
<<
fld
<<
endl
;
fld
.
write
(
sz
>
0
);
}
template
<
class
Type
>
void
doRead
(
const
IOobject
&
io
,
const
label
sz
)
{
bool
valid
=
(
sz
>
0
);
Pout
<<
" valid:"
<<
valid
<<
endl
;
IOField
<
Type
>
fld
(
io
,
valid
);
Pout
<<
" wanted:"
<<
sz
<<
" actually read:"
<<
fld
.
size
()
<<
endl
;
if
(
fld
.
size
()
!=
sz
)
{
FatalErrorInFunction
<<
"io:"
<<
io
.
objectPath
()
<<
exit
(
FatalError
);
}
}
template
<
class
Type
>
void
writeAndRead
(
const
IOobject
&
io
,
const
label
sz
,
const
word
&
writeType
,
const
IOobject
::
readOption
rOpt
,
const
word
&
readType
)
{
Pout
<<
"** Writing:"
<<
writeType
<<
" Reading:"
<<
readType
<<
endl
;
// The write handler
fileHandler
(
fileOperation
::
New
(
writeType
,
true
));
// Delete
Pout
<<
"Deleting:"
<<
fileHandler
().
filePath
(
io
.
objectPath
())
<<
endl
;
fileHandler
().
rm
(
fileHandler
().
filePath
(
io
.
objectPath
()));
// Write
Pout
<<
"Writing:"
<<
fileHandler
().
objectPath
(
io
,
io
.
name
())
<<
endl
;
doWrite
<
Type
>
(
io
,
sz
);
// The read handler
fileHandler
(
fileOperation
::
New
(
readType
,
true
));
// Read
IOobject
readIO
(
io
);
readIO
.
readOpt
(
rOpt
);
Pout
<<
"Reading:"
<<
fileHandler
().
filePath
(
readIO
.
objectPath
())
<<
endl
;
doRead
<
Type
>
(
readIO
,
sz
);
Pout
<<
"** Done writing:"
<<
writeType
<<
" Reading:"
<<
readType
<<
nl
<<
nl
<<
endl
;
}
template
<
class
Type
>
void
readIfPresent
(
IOobject
&
io
,
const
label
sz
,
const
word
&
readType
)
{
fileHandler
(
fileOperation
::
New
(
readType
,
true
));
// Read
Pout
<<
"Reading:"
<<
fileHandler
().
filePath
(
io
.
objectPath
())
<<
endl
;
io
.
readOpt
(
IOobject
::
READ_IF_PRESENT
);
doRead
<
Type
>
(
io
,
sz
);
}
template
<
class
Type
>
void
doTests
(
IOobject
&
io
,
const
label
sz
)
{
const
wordList
handlers
(
Foam
::
fileOperation
::
wordConstructorTablePtr_
->
sortedToc
()
);
Info
<<
"Found handlers: "
<<
flatOutput
(
handlers
)
<<
nl
<<
"Running tests with "
<<
pTraits
<
Type
>::
typeName
<<
nl
<<
nl
;
// for (const word& readHandler : handlers)
// {
// readIfPresent<Type>(io, sz, readHandler);
// }
for
(
const
word
&
writeHandler
:
handlers
)
{
for
(
const
word
&
readHandler
:
handlers
)
{
writeAndRead
<
Type
>
(
io
,
sz
,
writeHandler
,
IOobject
::
READ_IF_PRESENT
,
readHandler
);
}
}
}
// Main program
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noBanner
();
argList
::
addBoolOption
(
"bool"
,
"Use bool for tests"
);
argList
::
addBoolOption
(
"scalar"
,
"Use scalar for tests"
);
argList
::
addBoolOption
(
"label"
,
"Use label for tests (default)"
);
#include "addTimeOptions.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createPolyMesh.H"
label
sz
=
0
;
if
(
Pstream
::
myProcNo
()
%
2
)
{
sz
=
1
;
}
if
(
!
Pstream
::
parRun
())
{
sz
=
10
;
Info
<<
"Serial: using "
<<
sz
<<
nl
;
}
IOobject
io
(
"bla"
,
runTime
.
timeName
(),
mesh
,
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
);
{
dictionary
headerDict
;
io
.
writeHeader
(
headerDict
,
"anything"
,
IOstreamOption
());
Info
<<
"IOobjectHeader"
<<
headerDict
<<
nl
;
}
label
tested
=
0
;
if
(
args
.
found
(
"bool"
))
{
doTests
<
bool
>
(
io
,
sz
);
++
tested
;
}
if
(
args
.
found
(
"scalar"
))
{
doTests
<
scalar
>
(
io
,
sz
);
++
tested
;
}
if
(
!
tested
||
args
.
found
(
"label"
))
{
doTests
<
label
>
(
io
,
sz
);
}
Pout
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/IOobjectList/Make/files
0 → 100644
View file @
55e5a777
Test-IOobjectList.C
EXE = $(FOAM_USER_APPBIN)/Test-IOobjectList
OpenFOAM-v2112/applications/test/IOobjectList/Make/options
0 → 100644
View file @
55e5a777
EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = -lfiniteVolume
OpenFOAM-v2112/applications/test/IOobjectList/Test-IOobjectList.C
0 → 100644
View file @
55e5a777
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
Description
Basic tests of IOobjectList
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "volFields.H"
#include "timeSelector.H"
#include "IOobjectList.H"
#include "hashedWordList.H"
#include "labelIOList.H"
#include "scalarIOList.H"
using
namespace
Foam
;
void
report
(
const
IOobjectList
&
objects
)
{
Info
<<
"Names: "
<<
flatOutput
(
objects
.
sortedNames
())
<<
nl
<<
"Objects: "
<<
objects
<<
nl
<<
"----"
<<
nl
;
}
void
reportDetail
(
const
IOobjectList
&
objects
)
{
Info
<<
"Details:"
<<
nl
;
for
(
const
word
&
key
:
objects
.
sortedNames
())
{
// Canonical method name (NOV-2018)
const
IOobject
*
io
=
objects
.
findObject
(
key
);
label
count
=
0
;
// Test deprecated alternatives
{
// (const char*)
IOobject
*
ptr
=
objects
.
lookup
(
"SomeNonExistentName"
);
if
(
ptr
)
++
count
;
}
{
// (const word&)
IOobject
*
ptr
=
objects
.
lookup
(
key
);
if
(
ptr
)
++
count
;
}
Info
<<
key
<<
" ("
<<
io
->
headerClassName
()
<<
") = addr "
<<
name
(
io
)
<<
nl
;
if
(
count
!=
1
)
{
Warning
<<
key
<<
" had incorrect lookup?"
<<
nl
;
}
}
Info
<<
"===="
<<
nl
;
}
void
printFound
(
const
IOobject
*
ptr
)
{
Info
<<
(
ptr
?
"found"
:
"not found"
)
<<
nl
;
}
void
findObjectTest
(
const
IOobjectList
&
objs
)
{
Info
<<
"Test findObject()"
<<
nl
<<
nl
;
const
int
oldDebug
=
IOobject
::
debug
;
IOobject
::
debug
=
1
;
{
Info
<<
"cfindObject(U)"
<<
nl
;
const
IOobject
*
io
=
objs
.
cfindObject
(
"U"
);
printFound
(
io
);
}
{
Info
<<
"getObject(U)"
<<
nl
;
IOobject
*
io
=
objs
.
getObject
(
"U"
);
printFound
(
io
);
}
{
Info
<<
"cfindObject<void>(U)"
<<
nl
;
const
IOobject
*
io
=
objs
.
cfindObject
<
void
>
(
"U"
);
printFound
(
io
);
}
{
Info
<<
"cfindObject<volScalarField>(U)"
<<
nl
;
const
IOobject
*
io
=
objs
.
cfindObject
<
volScalarField
>
(
"U"
);
printFound
(
io
);
}
{
Info
<<
"cfindObject<volVectorField>(U)"
<<
nl
;
const
IOobject
*
io
=
objs
.
cfindObject
<
volVectorField
>
(
"U"
);
printFound
(
io
);
}
Info
<<
nl
;
IOobject
::
debug
=
oldDebug
;
}
template
<
class
Type
>
void
filterTest
(
const
IOobjectList
&
objs
,
const
wordRe
&
re
)
{
Info
<<
"Filter = "
<<
re
<<
nl
;
const
word
&
typeName
=
Type
::
typeName
;
Info
<<
" <"
<<
typeName
<<
">("
<<
re
<<
") : "
<<
objs
.
count
<
Type
>
(
re
)
<<
nl
<<
" ("
<<
typeName
<<
"::typeName, "
<<
re
<<
") : "
<<
objs
.
count
(
typeName
,
re
)
<<
nl
;
Info
<<
" <"
<<
typeName
<<
">("
<<
re
<<
") : "
<<
flatOutput
(
objs
.
sortedNames
<
Type
>
(
re
))
<<
nl
// << flatOutput(objs.names<Type>(re)) << nl
<<
" ("
<<
typeName
<<
"::typeName, "
<<
re
<<
") : "
<<
flatOutput
(
objs
.
sortedNames
(
typeName
,
re
))
<<
nl
//<< flatOutput(objs.names(typeName, re)) << nl
;
wordRe
reClass
(
"vol.*Field"
,
wordRe
::
REGEX
);
wordRe
re2
(
re
,
wordRe
::
REGEX_ICASE
);
Info
<<
"General"
<<
nl
<<
" <void>("
<<
re
<<
") : "
<<
flatOutput
(
objs
.
sortedNames
<
void
>
(
re
))
<<
nl
<<
" ("
<<
reClass
<<
", "
<<
re2
<<
" ignore-case) : "
<<
flatOutput
(
objs
.
sortedNames
(
reClass
,
re2
))
<<
nl
;
Info
<<
nl
;
}
void
registryTests
(
const
IOobjectList
&
objs
)
{
Info
<<
nl
<<
"IOobjectList "
<<
flatOutput
(
objs
.
sortedNames
())
<<
nl
;
Info
<<
"count"
<<
nl
<<
" <void>() : "
<<
objs
.
count
<
void
>
()
<<
nl
<<
" <labelList>() : "
<<
objs
.
count
<
labelIOList
>
()
<<
nl
<<
" <scalarList>() : "
<<
objs
.
count
<
scalarIOList
>
()
<<
nl
<<
nl
;
Info
<<
" <volScalarField>() : "
<<
objs
.
count
<
volScalarField
>
()
<<
nl
<<
" (volScalarField::typeName) : "
<<
objs
.
count
(
volScalarField
::
typeName
)
<<
nl
;
Info
<<
" <volVectorField>() : "
<<
objs
.
count
<
volVectorField
>
()
<<
nl
<<
" (volVectorField::typeName) : "
<<
objs
.
count
(
volVectorField
::
typeName
)
<<
nl
;
Info
<<
nl
<<
"Filter on names:"
<<
nl
;
filterTest
<
volScalarField
>
(
objs
,
wordRe
(
"[p-z].*"
,
wordRe
::
DETECT
));
Info
<<
nl
;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noParallel
();
argList
::
addOption
(
"filter"
,
"wordRes"
,
"filter keys with names or regexs"
);
argList
::
addBoolOption
(
"copy-append"
,
"test move append lists (requires -filter)"
);
argList
::
addBoolOption
(
"move-append"
,
"test move append lists (requires -filter)"
);
// timeSelector::addOptions();
timeSelector
::
addOptions
(
true
,
true
);
#include "setRootCase.H"
#include "createTime.H"
wordRes
matcher
;
if
(
args
.
readListIfPresent
<
wordRe
>
(
"filter"
,
matcher
))
{
Info
<<
"limit names: "
<<
matcher
<<
nl
;
}
if
(
args
.
found
(
"copy-append"
)
&&
matcher
.
empty
())
{
FatalError
<<
nl
<<
"The -copy-append test also requires -filter"
<<
nl
<<
exit
(
FatalError
);
}
if
(
args
.
found
(
"move-append"
)
&&
matcher
.
empty
())
{
FatalError
<<
nl
<<
"The -move-append test also requires -filter"
<<
nl
<<
exit
(
FatalError
);
}
const
hashedWordList
subsetTypes
{
volScalarField
::
typeName
,
volScalarField
::
Internal
::
typeName
,
volVectorField
::
typeName
,
};
instantList
timeDirs
=
timeSelector
::
select0
(
runTime
,
args
);
forAll
(
timeDirs
,
timeI
)
{
runTime
.
setTime
(
timeDirs
[
timeI
],
timeI
);
// Objects at this time
IOobjectList
objects
(
runTime
,
runTime
.
timeName
());
HashTable
<
wordHashSet
>
classes
=
(
matcher
.
size
()
?
objects
.
classes
(
matcher
)
:
objects
.
classes
()
);
Info
<<
"Time: "
<<
runTime
.
timeName
()
<<
nl
;
report
(
objects
);
findObjectTest
(
objects
);
classes
.
filterKeys
(
subsetTypes
);
Info
<<
"only retain: "
<<
flatOutput
(
subsetTypes
)
<<
nl
;
Info
<<
"Pruned: "
<<
classes
<<
nl
;
classes
=
objects
.
classes
();
classes
.
erase
(
subsetTypes
);
Info
<<
"remove: "
<<
flatOutput
(
subsetTypes
)
<<
nl
;
Info
<<
"Pruned: "
<<
classes
<<
nl
;
registryTests
(
objects
);
// On last time
if
(
timeI
==
timeDirs
.
size
()
-
1
)
{
if
(
args
.
found
(
"copy-append"
))
{
Info
<<
nl
<<
"Test move append"
<<
nl
;
}
else
if
(
args
.
found
(
"move-append"
))
{
Info
<<
nl
<<
"Test move append"
<<
nl
;
}
else
{
continue
;
}
IOobjectList
other
(
runTime
,
runTime
.
timeName
());
Info
<<
"==original=="
<<
nl
;
reportDetail
(
objects
);
objects
.
filterKeys
(
matcher
);
Info
<<
"==target=="
<<
nl
;
reportDetail
(
objects
);
Info
<<
"==source=="
<<
nl
;
reportDetail
(
other
);
if
(
args
.
found
(
"copy-append"
))
{
objects
.
append
(
other
);
Info
<<
nl
<<
"After copy-append"
<<
nl
;
}
else
{
objects
.
append
(
std
::
move
(
other
));
Info
<<
nl
<<
"After move-append"
<<
nl
;
}
Info
<<
"==target=="
<<
nl
;
reportDetail
(
objects
);
Info
<<
"==source=="
<<
nl
;
reportDetail
(
other
);
Info
<<
nl
;
}
}
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/ISLList/Make/files
0 → 100644
View file @
55e5a777
Test-ISLList.C
EXE = $(FOAM_USER_APPBIN)/Test-ISLList
OpenFOAM-v2112/applications/test/ISLList/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = */
/* EXE_LIBS = */
OpenFOAM-v2112/applications/test/ISLList/Test-ISLList.C
0 → 100644
View file @
55e5a777
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
Application
Description
\*---------------------------------------------------------------------------*/
#include "OSspecific.H"
#include "IOstreams.H"
#include "ISLList.H"
#include "List.H"
#include "FlatOutput.H"
#include "ListOps.H"
#include "OSspecific.H"
using
namespace
Foam
;
class
Scalar
:
public
ISLList
<
Scalar
>::
link
{
public:
scalar
data_
;
Scalar
()
:
data_
(
0
)
{}
Scalar
(
scalar
s
)
:
data_
(
s
)
{}
friend
Ostream
&
operator
<<
(
Ostream
&
os
,
const
Scalar
&
s
)
{
os
<<
s
.
data_
;
return
os
;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
ISLList
<
Scalar
>
myList
(
new
Scalar
(
0
));
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
myList
.
append
(
new
Scalar
(
1
.
3
*
i
));
}
myList
.
append
(
new
Scalar
(
100
.
3
));
myList
.
append
(
new
Scalar
(
500
.
3
));
Info
<<
"ISLList<scalar>"
<<
myList
<<
nl
;
Info
<<
nl
<<
"flat-output: "
<<
flatOutput
(
myList
)
<<
nl
;
Info
<<
nl
<<
"range-for:"
<<
nl
;
for
(
const
auto
&
val
:
myList
)
{
Info
<<
" "
<<
val
<<
nl
;
// Info<<" is " << typeid(val).name() << endl;
}
Info
<<
nl
<<
"const_iterator:"
<<
nl
;
const
ISLList
<
Scalar
>&
const_myList
=
myList
;
forAllConstIters
(
const_myList
,
iter
)
{
Info
<<
" "
<<
*
iter
<<
endl
;
}
{
Info
<<
nl
<<
"Remove element:"
<<
nl
;
Scalar
*
iter
=
myList
.
removeHead
();
Info
<<
" remove "
<<
*
iter
;
Info
<<
" => "
<<
flatOutput
(
myList
)
<<
nl
;
delete
iter
;
}
Info
<<
nl
<<
"Transfer: "
<<
nl
;
Info
<<
"original: "
<<
flatOutput
(
myList
)
<<
endl
;
ISLList
<
Scalar
>
newList
;
newList
.
transfer
(
myList
);
Info
<<
nl
<<
"source: "
<<
flatOutput
(
myList
)
<<
nl
<<
"target: "
<<
flatOutput
(
newList
)
<<
endl
;
myList
.
swap
(
newList
);
Info
<<
nl
<<
"swap: "
<<
nl
;
Info
<<
nl
<<
"source: "
<<
flatOutput
(
myList
)
<<
nl
<<
"target: "
<<
flatOutput
(
newList
)
<<
endl
;
myList
.
swap
(
newList
);
Info
<<
nl
<<
"Move Construct: "
<<
nl
;
ISLList
<
Scalar
>
list2
(
std
::
move
(
newList
));
Info
<<
nl
<<
"in : "
<<
flatOutput
(
newList
)
<<
nl
<<
"out: "
<<
flatOutput
(
list2
)
<<
nl
;
// Move back
Info
<<
nl
<<
"Move Assignment: "
<<
nl
;
newList
=
std
::
move
(
list2
);
Info
<<
nl
<<
"move assign: "
<<
nl
;
Info
<<
nl
<<
"source: "
<<
flatOutput
(
list2
)
<<
nl
<<
"target: "
<<
flatOutput
(
newList
)
<<
endl
;
Info
<<
nl
<<
"Bye."
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/IStringStream/Make/files
0 → 100644
View file @
55e5a777
Test-IStringStream.C
EXE = $(FOAM_USER_APPBIN)/Test-IStringStream
OpenFOAM-v2112/applications/test/IStringStream/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
/* EXE_LIBS = -lfiniteVolume */
OpenFOAM-v2112/applications/test/IStringStream/Test-IStringStream.C
0 → 100644
View file @
55e5a777
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
-------------------------------------------------------------------------------
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/>.
Description
\*---------------------------------------------------------------------------*/
#include "StringStream.H"
#include "wordList.H"
#include "IOstreams.H"
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
IStringStream
testStream
(
Foam
::
string
(
" 1002 abcd defg;"
));
label
i
(
readLabel
(
testStream
));
Info
<<
"label="
<<
i
<<
nl
;
word
w1
(
testStream
);
word
w2
(
testStream
);
Info
<<
"word="
<<
w1
<<
nl
;
Info
<<
"word="
<<
w2
<<
nl
;
testStream
.
reset
(
"(hello1)"
);
wordList
wl
(
testStream
);
Info
<<
wl
<<
nl
;
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/ITstream/Make/files
0 → 100644
View file @
55e5a777
Test-ITstream.C
EXE = $(FOAM_USER_APPBIN)/Test-ITstream
OpenFOAM-v2112/applications/test/ITstream/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = */
/* EXE_LIBS = */
OpenFOAM-v2112/applications/test/ITstream/Test-ITstream.C
0 → 100644
View file @
55e5a777
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
Description
\*---------------------------------------------------------------------------*/
#include "ListStream.H"
#include "UListStream.H"
#include "wordList.H"
#include "IOstreams.H"
#include "argList.H"
#include "ITstream.H"
#include "ListOps.H"
#include "flipOp.H"
using
namespace
Foam
;
template
<
class
T
>
Ostream
&
toString
(
Ostream
&
os
,
const
T
&
str
)
{
os
<<
str
;
return
os
;
}
template
<>
Ostream
&
toString
(
Ostream
&
os
,
const
UList
<
char
>&
list
)
{
for
(
const
char
c
:
list
)
{
os
<<
c
;
}
return
os
;
}
template
<>
Ostream
&
toString
(
Ostream
&
os
,
const
List
<
char
>&
list
)
{
for
(
const
char
c
:
list
)
{
os
<<
c
;
}
return
os
;
}
void
printTokens
(
Istream
&
is
)
{
label
count
=
0
;
token
t
;
while
(
is
.
good
())
{
is
>>
t
;
if
(
t
.
good
())
{
++
count
;
Info
<<
"token: "
<<
t
<<
endl
;
}
}
Info
<<
count
<<
" tokens"
<<
endl
;
}
Ostream
&
reportPeek
(
const
ITstream
&
is
)
{
Info
<<
" index : "
<<
is
.
tokenIndex
()
<<
nl
<<
" peek : "
<<
is
.
peek
().
info
()
<<
nl
;
return
Info
;
}
template
<
class
BUF
>
void
doTest
(
const
string
&
name
,
const
BUF
&
input
,
bool
verbose
=
false
,
bool
testskip
=
false
)
{
Info
<<
"test "
<<
name
.
c_str
()
<<
":"
<<
nl
<<
"===="
<<
nl
;
toString
(
Info
,
input
)
<<
nl
<<
"===="
<<
nl
<<
endl
;
ITstream
its
(
input
);
Info
<<
"got "
<<
its
.
size
()
<<
" tokens - index at "
<<
its
.
tokenIndex
()
<<
endl
;
if
(
verbose
)
{
for
(
const
token
&
tok
:
its
)
{
Info
<<
" "
<<
tok
.
info
()
<<
nl
;
}
Info
<<
nl
;
}
if
(
testskip
)
{
Info
<<
" first : "
<<
its
.
peekFirst
().
info
()
<<
nl
<<
" last : "
<<
its
.
peekLast
().
info
()
<<
nl
;
Info
<<
"rewind():"
<<
nl
;
reportPeek
(
its
);
its
.
skip
(
3
);
Info
<<
"skip(3):"
<<
nl
;
reportPeek
(
its
);
its
.
skip
(
2
);
Info
<<
"skip(2):"
<<
nl
;
reportPeek
(
its
);
its
.
skip
(
-
2
);
Info
<<
"skip(-2):"
<<
nl
;
reportPeek
(
its
);
its
.
skip
(
100
);
Info
<<
"skip(100):"
<<
nl
;
reportPeek
(
its
);
its
.
skip
(
-
1000
);
Info
<<
"skip(-1000):"
<<
nl
;
reportPeek
(
its
);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
const
char
*
charInput
=
"( const char input
\"
string
\"
to tokenize )
\n
"
"List<label> 5(0 1 2 3 4);"
;
string
stringInput
(
"( string ; input
\"
string
\"
to tokenize )"
);
List
<
char
>
listInput
(
ListOps
::
create
<
char
>
(
stringInput
.
cbegin
(),
stringInput
.
cend
(),
Foam
::
noOp
{}
)
);
doTest
(
"empty"
,
""
,
true
,
true
);
doTest
(
"char*"
,
charInput
,
true
,
true
);
doTest
(
"string"
,
stringInput
,
true
);
doTest
(
"List<char>"
,
listInput
,
true
);
reverse
(
listInput
);
doTest
(
"List<char>"
,
listInput
,
true
);
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/IjkField/Make/files
0 → 100644
View file @
55e5a777
Test-IjkField.C
EXE = $(FOAM_USER_APPBIN)/Test-IjkField
OpenFOAM-v2112/applications/test/IjkField/Make/options
0 → 100644
View file @
55e5a777
EXE_INC = -DFULLDEBUG
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
/* EXE_LIBS = -lfiniteVolume */
OpenFOAM-v2112/applications/test/IjkField/Test-IjkField.C
0 → 100644
View file @
55e5a777
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
Description
Functionality of IjkField
\*---------------------------------------------------------------------------*/
#include "point.H"
#include "IjkField.H"
#include "IOstreams.H"
using
namespace
Foam
;
template
<
class
T
>
Ostream
&
print
(
const
IjkField
<
T
>&
fld
)
{
Info
<<
static_cast
<
const
Field
<
T
>&>
(
fld
).
size
()
<<
" addr:"
<<
name
(
fld
.
cdata
())
<<
' '
<<
fld
.
sizes
()
<<
' '
<<
flatOutput
(
fld
);
return
Info
;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
// Basic addressing checks
#if 0
{
ijkAddressing addr1(3, 4, 5);
Info<< "addressing: " << addr1.sizes() << nl;
Info<< "index of (2,2,2) " << addr1.index(2,2,2) << nl;
for (const label idx : labelRange(addr1.size()))
{
Info<< "index of " << idx << " => " << addr1.index(idx) << nl;
}
for (label k=0; k < addr1.sizes().z(); ++k)
{
for (label j=0; j < addr1.sizes().y(); ++j)
{
for (label i=0; i < addr1.sizes().x(); ++i)
{
labelVector ijk(i,j,k);
Info<< "index of " << addr1.index(ijk)
<< " <= " << ijk << nl;
}
}
}
}
#endif
// Create with inconsistent sizes
IjkField
<
label
>
field0
({
1
,
2
,
3
},
identity
(
10
));
IjkField
<
scalar
>
field1
({
3
,
4
,
5
});
IjkField
<
scalar
>
field2
({
2
,
3
,
3
});
forAll
(
field1
,
i
)
{
field1
[
i
]
=
-
i
;
}
forAll
(
field2
,
i
)
{
field2
[
i
]
=
i
;
}
Info
<<
"ijk field "
;
print
(
field1
)
<<
nl
;
Info
<<
"ijk field "
;
print
(
field2
)
<<
nl
;
field1
.
resize
(
field2
.
sizes
());
Info
<<
"resized "
;
print
(
field1
)
<<
nl
;
field1
*=
2
;
Info
<<
"Multiply: "
;
print
(
field1
)
<<
nl
;
field1
.
resize
({
1
,
2
,
3
});
Info
<<
"Resize - shrink: "
;
print
(
field1
)
<<
nl
;
field1
.
resize
({
2
,
3
,
2
});
Info
<<
"Resize - grow: "
;
print
(
field1
)
<<
nl
;
field1
.
resize
({
3
,
2
,
2
});
Info
<<
"Resize - repartition: "
;
print
(
field1
)
<<
nl
;
field1
=
field2
;
Info
<<
"Copied: "
;
print
(
field1
)
<<
nl
;
field1
=
3
.
14159
;
Info
<<
"Assigned: "
;
print
(
field1
)
<<
nl
;
field1
+=
3
.
14159
;
Info
<<
"+= operator: "
;
print
(
field1
)
<<
nl
;
field1
/=
1
.
2
;
Info
<<
"/= operator: "
;
print
(
field1
)
<<
nl
;
IjkField
<
scalar
>
field3
(
std
::
move
(
field2
));
Info
<<
"Move construct: "
;
print
(
field2
)
<<
nl
;
print
(
field3
)
<<
nl
;
// Field operations are still limited, but we can bypass things too
{
Field
<
scalar
>&
tmpField
=
field1
;
tmpField
=
sqr
(
tmpField
);
Info
<<
"squared (workaround): "
;
print
(
field1
)
<<
nl
;
}
Info
<<
nl
<<
"Before transfer: addr:"
<<
name
(
field1
.
data
())
<<
" size:"
<<
field1
.
size
()
<<
nl
;
Field
<
scalar
>
sfield1
(
std
::
move
(
field1
));
field1
.
clear
();
Info
<<
"After transfer to regular field"
<<
nl
<<
" source:"
<<
name
(
field1
.
data
())
<<
nl
<<
" target:"
<<
name
(
sfield1
.
data
())
<<
nl
<<
"Values"
<<
" source:"
;
print
(
field1
)
<<
nl
;
Info
<<
" target:"
<<
flatOutput
(
sfield1
)
<<
nl
;
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/IndirectList/Make/files
0 → 100644
View file @
55e5a777
Test-IndirectList.C
EXE = $(FOAM_USER_APPBIN)/Test-IndirectList
OpenFOAM-v2112/applications/test/IndirectList/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
/* EXE_LIBS = -lfiniteVolume */
Prev
1
…
7
8
9
10
11
12
13
14
15
…
34
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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