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
898 additions
and
0 deletions
+898
-0
OpenFOAM-v2112/applications/test/dynamicLibrary/Make/files
OpenFOAM-v2112/applications/test/dynamicLibrary/Make/files
+3
-0
OpenFOAM-v2112/applications/test/dynamicLibrary/Make/options
OpenFOAM-v2112/applications/test/dynamicLibrary/Make/options
+2
-0
OpenFOAM-v2112/applications/test/dynamicLibrary/Test-dynamicLibrary.C
...12/applications/test/dynamicLibrary/Test-dynamicLibrary.C
+143
-0
OpenFOAM-v2112/applications/test/edges/Make/files
OpenFOAM-v2112/applications/test/edges/Make/files
+3
-0
OpenFOAM-v2112/applications/test/edges/Make/options
OpenFOAM-v2112/applications/test/edges/Make/options
+2
-0
OpenFOAM-v2112/applications/test/edges/Test-edges.C
OpenFOAM-v2112/applications/test/edges/Test-edges.C
+150
-0
OpenFOAM-v2112/applications/test/ensightFile/Make/files
OpenFOAM-v2112/applications/test/ensightFile/Make/files
+3
-0
OpenFOAM-v2112/applications/test/ensightFile/Make/options
OpenFOAM-v2112/applications/test/ensightFile/Make/options
+8
-0
OpenFOAM-v2112/applications/test/ensightFile/Test-ensightFile.C
...AM-v2112/applications/test/ensightFile/Test-ensightFile.C
+79
-0
OpenFOAM-v2112/applications/test/error/Make/files
OpenFOAM-v2112/applications/test/error/Make/files
+3
-0
OpenFOAM-v2112/applications/test/error/Make/options
OpenFOAM-v2112/applications/test/error/Make/options
+2
-0
OpenFOAM-v2112/applications/test/error/Test-error.C
OpenFOAM-v2112/applications/test/error/Test-error.C
+121
-0
OpenFOAM-v2112/applications/test/etcFiles/Make/files
OpenFOAM-v2112/applications/test/etcFiles/Make/files
+3
-0
OpenFOAM-v2112/applications/test/etcFiles/Make/options
OpenFOAM-v2112/applications/test/etcFiles/Make/options
+2
-0
OpenFOAM-v2112/applications/test/etcFiles/Test-etcFiles.C
OpenFOAM-v2112/applications/test/etcFiles/Test-etcFiles.C
+153
-0
OpenFOAM-v2112/applications/test/exprEntry/Make/files
OpenFOAM-v2112/applications/test/exprEntry/Make/files
+3
-0
OpenFOAM-v2112/applications/test/exprEntry/Make/options
OpenFOAM-v2112/applications/test/exprEntry/Make/options
+1
-0
OpenFOAM-v2112/applications/test/exprEntry/Test-exprEntry.C
OpenFOAM-v2112/applications/test/exprEntry/Test-exprEntry.C
+145
-0
OpenFOAM-v2112/applications/test/exprEntry/testDict1
OpenFOAM-v2112/applications/test/exprEntry/testDict1
+69
-0
OpenFOAM-v2112/applications/test/exprTraits/Make/files
OpenFOAM-v2112/applications/test/exprTraits/Make/files
+3
-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/dynamicLibrary/Make/files
0 → 100644
View file @
55e5a777
Test-dynamicLibrary.C
EXE = $(FOAM_USER_APPBIN)/Test-dynamicLibrary
OpenFOAM-v2112/applications/test/dynamicLibrary/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = */
/* EXE_LIBS = */
OpenFOAM-v2112/applications/test/dynamicLibrary/Test-dynamicLibrary.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) 2020-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-dynamicLibrary
Description
Test loading/unloading of libraries
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "profiling.H"
#include "DynamicList.H"
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
addNote
(
"Low-level test of library load/unload"
);
profiling
::
disable
();
// No profiling output
argList
::
noBanner
();
argList
::
noParallel
();
argList
::
removeOption
(
"case"
);
argList
::
removeOption
(
"noFunctionObjects"
);
argList
::
addBoolOption
(
"no-close"
,
"Skip dlclose"
);
argList
::
addBoolOption
(
"quiet"
,
"Disable verbosity"
);
argList
::
addArgument
(
"lib..."
);
argList
::
noMandatoryArgs
();
// Arguments are optional
argList
args
(
argc
,
argv
,
false
,
true
);
const
bool
noClose
=
args
.
found
(
"no-close"
);
const
bool
verbose
=
!
args
.
found
(
"quiet"
);
//- Pointers to the loaded libraries
DynamicList
<
void
*>
libPtrs_
;
//- Names of loaded libraries, or of libraries to be loaded
DynamicList
<
fileName
>
libNames_
;
label
nbad
=
0
;
wordHashSet
loaded
;
for
(
int
argi
=
1
;
argi
<
args
.
size
();
++
argi
)
{
const
auto
libName
=
args
.
get
<
fileName
>
(
argi
);
if
(
libName
.
empty
())
{
continue
;
}
void
*
ptr
=
Foam
::
dlOpen
(
libName
,
false
);
if
(
!
ptr
)
{
++
nbad
;
}
else
{
libPtrs_
.
append
(
ptr
);
libNames_
.
append
(
libName
);
if
(
verbose
)
{
const
word
addr
(
Foam
::
name
(
ptr
));
if
(
loaded
.
insert
(
addr
))
{
InfoErr
<<
"Can load "
<<
libName
<<
nl
;
}
else
{
InfoErr
<<
"Already loaded "
<<
libName
<<
nl
;
}
}
}
}
if
(
!
noClose
)
{
forAllReverse
(
libPtrs_
,
i
)
{
void
*
ptr
=
libPtrs_
[
i
];
if
(
ptr
==
nullptr
)
{
libNames_
[
i
].
clear
();
continue
;
}
const
bool
ok
=
Foam
::
dlClose
(
ptr
);
if
(
verbose
)
{
if
(
ok
)
{
InfoErr
<<
"Closed "
;
}
else
{
InfoErr
<<
"Failed closing "
;
}
InfoErr
<<
libNames_
[
i
]
<<
" with handle "
<<
Foam
::
name
(
ptr
)
<<
nl
;
}
}
}
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/edges/Make/files
0 → 100644
View file @
55e5a777
Test-edges.C
EXE = $(FOAM_USER_APPBIN)/Test-edges
OpenFOAM-v2112/applications/test/edges/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = */
/* EXE_LIBS = */
OpenFOAM-v2112/applications/test/edges/Test-edges.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 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-edges
Description
Simple tests for edges
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "edgeList.H"
#include "edgeHashes.H"
using
namespace
Foam
;
void
printInfo
(
const
edge
&
e
)
{
Info
<<
"edge: "
<<
e
<<
" count:"
<<
e
.
count
()
<<
nl
;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
edge
e1
;
printInfo
(
e1
);
Info
<<
"has '2'? "
<<
e1
.
found
(
2
)
<<
endl
;
edge
e2
(
1
,
2
);
printInfo
(
e2
);
Info
<<
"has '2'? "
<<
e2
.
found
(
2
)
<<
endl
;
edge
e3
{
2
,
3
};
printInfo
(
e3
);
Info
<<
"has '2'? "
<<
e3
.
found
(
2
)
<<
endl
;
edge
e4
(
4
,
4
);
printInfo
(
e4
);
Info
<<
"has '2'? "
<<
e4
.
found
(
2
)
<<
endl
;
Info
<<
"collapse? -> "
<<
e4
.
collapse
()
<<
endl
;
printInfo
(
e4
);
Info
<<
e3
<<
" connects "
<<
e2
<<
" => "
<<
e2
.
connects
(
e3
)
<<
endl
;
labelPair
labels
(
e3
);
Info
<<
"as labelPair: "
<<
labels
<<
endl
;
edge
e5
;
// Good: this fails (explicit constructor): printInfo(labels);
// Good: this also fails (no assignment operator): e5 = labels;
// OK: explicit
edge
e6
(
labels
);
Info
<<
nl
<<
"hash-like functionality"
<<
nl
;
// doesn't work e4 = -1;
e4
.
start
()
=
e4
.
end
()
=
-
1
;
printInfo
(
e4
);
for
(
label
i
:
{
2
,
-
1
,
2
,
1
,
4
,
1
,
2
,
3
})
{
bool
ok
=
e4
.
insert
(
i
);
Info
<<
"insert("
<<
i
<<
") = "
<<
ok
<<
" resulting "
;
printInfo
(
e4
);
}
e4
.
start
()
=
e4
.
end
()
=
-
1
;
Info
<<
"insert from list
\n
"
;
labelHashSet
newIndices
({
2
,
-
1
,
2
,
1
,
4
,
1
,
2
,
3
});
e4
.
insert
(
newIndices
.
toc
());
printInfo
(
e4
);
e4
.
start
()
=
e4
.
end
()
=
-
1
;
Info
<<
"insert from list
\n
"
;
e4
.
insert
({
0
,
5
,
2
,
-
1
,
2
,
1
,
4
,
1
,
2
,
3
});
printInfo
(
e4
);
FixedList
<
label
,
8
>
otherIndices
{
12
,
2
,
-
1
,
1
,
4
,
1
,
2
,
3
};
e4
.
start
()
=
e4
.
end
()
=
-
1
;
Info
<<
"insert from list: "
<<
otherIndices
<<
nl
;
e4
.
insert
(
otherIndices
);
printInfo
(
e4
);
e4
.
start
()
=
e4
.
end
();
Info
<<
"erase from list: "
<<
otherIndices
<<
nl
;
Info
<<
"removed "
<<
e4
.
erase
(
otherIndices
)
<<
" values"
<<
nl
;
printInfo
(
e4
);
for
(
label
i
:
{
-
1
,
0
,
1
,
3
})
{
bool
ok
=
e4
.
erase
(
i
);
Info
<<
"erase("
<<
i
<<
") = "
<<
ok
<<
" resulting "
;
printInfo
(
e4
);
}
for
(
label
i
:
{
-
1
,
0
,
1
,
3
})
{
bool
ok
=
e4
.
insert
(
i
);
Info
<<
"insert("
<<
i
<<
") = "
<<
ok
<<
" resulting "
;
printInfo
(
e4
);
}
e4
.
flip
();
Info
<<
"flipped "
;
printInfo
(
e4
);
for
(
label
i
:
{
-
1
,
0
,
1
,
3
})
{
bool
ok
=
e4
.
erase
(
i
);
Info
<<
"erase("
<<
i
<<
") = "
<<
ok
<<
" resulting "
;
printInfo
(
e4
);
}
e4
.
sort
();
Info
<<
"sorted "
;
printInfo
(
e4
);
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/ensightFile/Make/files
0 → 100644
View file @
55e5a777
Test-ensightFile.C
EXE = $(FOAM_USER_APPBIN)/Test-ensightFile
OpenFOAM-v2112/applications/test/ensightFile/Make/options
0 → 100644
View file @
55e5a777
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude
EXE_LIBS = \
-lmeshTools \
-lconversion
OpenFOAM-v2112/applications/test/ensightFile/Test-ensightFile.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) 2016 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-ensightFile
Description
check cleanup of ensight file and variable names
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "ensightFileName.H"
#include "ensightVarName.H"
#include "IOstreams.H"
using
namespace
Foam
;
void
printCleaning
(
const
fileName
&
pathName
)
{
Info
<<
"input = "
<<
pathName
<<
nl
;
Info
<<
"file = "
<<
ensight
::
FileName
(
pathName
)
<<
nl
;
Info
<<
"var = "
<<
ensight
::
VarName
(
pathName
)
<<
nl
;
Info
<<
nl
;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noBanner
();
argList
::
noParallel
();
argList
::
addArgument
(
"fileName .. fileNameN"
);
argList
args
(
argc
,
argv
,
false
,
true
);
if
(
args
.
size
()
<=
1
&&
args
.
options
().
empty
())
{
args
.
printUsage
();
}
fileName
pathName
;
for
(
label
argI
=
1
;
argI
<
args
.
size
();
++
argI
)
{
pathName
=
args
[
argI
];
printCleaning
(
pathName
);
}
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/error/Make/files
0 → 100644
View file @
55e5a777
Test-error.C
EXE = $(FOAM_USER_APPBIN)/Test-error
OpenFOAM-v2112/applications/test/error/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
/* EXE_LIBS = -lfiniteVolume */
OpenFOAM-v2112/applications/test/error/Test-error.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-2015 OpenFOAM Foundation
Copyright (C) 2020-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 "argList.H"
#include "dictionary.H"
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
addBoolOption
(
"no-throw"
,
"Use error, no exceptions"
);
argList
::
addBoolOption
(
"ioerror"
,
"Use IOerror instead"
);
argList
::
noBanner
();
argList
args
(
argc
,
argv
);
#if 0
if (true)
{
InfoErr<< "Called with " << (args.size()-1) << " args\n";
InfoErr<< "... some error\n";
return 2;
}
#endif
const
bool
useIOerr
=
args
.
found
(
"ioerror"
);
if
(
!
args
.
found
(
"no-throw"
))
{
FatalIOError
.
throwing
(
true
);
FatalError
.
throwing
(
true
);
}
try
{
WarningInFunction
<<
"warning 1"
<<
endl
;
IOWarningInFunction
(
Serr
)
<<
"warning 2"
<<
endl
;
dictionary
dict
;
IOWarningInFunction
(
dict
)
<<
"warning 3"
<<
endl
;
if
(
useIOerr
)
{
FatalIOErrorInFunction
(
dict
)
<<
"This is an error from 1"
<<
nl
<<
"Explanation to follow:"
<<
endl
;
FatalIOError
<<
"Error 2"
<<
exit
(
FatalIOError
);
}
else
{
FatalErrorInFunction
<<
"This is an error from 1"
<<
nl
<<
"Explanation to follow:"
<<
endl
;
FatalError
<<
"Error 2"
<<
exit
(
FatalError
);
}
}
catch
(
const
Foam
::
IOerror
&
err
)
{
Serr
<<
"Caught IO error "
<<
err
<<
nl
<<
endl
;
}
catch
(
const
Foam
::
error
&
err
)
{
Serr
<<
"Caught error "
<<
err
<<
nl
<<
endl
;
}
try
{
FatalErrorInFunction
<<
"Error# 3"
<<
exit
(
FatalError
);
}
catch
(
const
Foam
::
IOerror
&
err
)
{
Serr
<<
"Caught IO error "
<<
err
<<
nl
<<
endl
;
}
catch
(
const
Foam
::
error
&
err
)
{
Serr
<<
"Caught error "
<<
err
<<
nl
<<
endl
;
}
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/etcFiles/Make/files
0 → 100644
View file @
55e5a777
Test-etcFiles.C
EXE = $(FOAM_USER_APPBIN)/Test-etcFiles
OpenFOAM-v2112/applications/test/etcFiles/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = */
/* EXE_LIBS = */
OpenFOAM-v2112/applications/test/etcFiles/Test-etcFiles.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-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/>.
Application
Test-etcFiles
Description
Test etcFiles functionality.
Similar to foamEtcFile script, but automatically prunes nonexistent
directories from the list.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "etcFiles.H"
#include "foamVersion.H"
using
namespace
Foam
;
void
printList
(
const
fileNameList
&
list
)
{
for
(
const
fileName
&
f
:
list
)
{
Info
<<
f
.
c_str
()
<<
nl
;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noBanner
();
argList
::
noParallel
();
argList
::
noFunctionObjects
();
argList
::
removeOption
(
"case"
);
argList
::
addBoolOption
(
"config"
,
"Print compile-time configuration values"
);
argList
::
addBoolOption
(
"all"
,
"Return all files (otherwise stop after the first match)"
);
argList
::
addBoolOption
(
"list"
,
"List directories or files to be checked"
);
argList
::
addBoolOption
(
"list-all"
,
"List all directories (including non-existent ones)"
);
argList
::
addArgument
(
"file..."
);
argList
::
addNote
(
"Locate user/group/other file with semantics similar to the "
"<etc>/fileName expansion."
);
argList
args
(
argc
,
argv
,
false
,
true
);
// First handle no parameters
if
(
args
.
size
()
==
1
)
{
if
(
args
.
found
(
"config"
))
{
Info
<<
"config:project="
<<
foamVersion
::
configuredProjectDir
<<
nl
;
Info
<<
"config:etc="
<<
foamVersion
::
configuredEtcDir
<<
nl
;
return
0
;
}
else
if
(
args
.
found
(
"list-all"
))
{
fileNameList
results
=
etcDirs
(
false
);
printList
(
results
);
return
0
;
}
else
if
(
args
.
found
(
"list"
))
{
fileNameList
results
=
etcDirs
();
printList
(
results
);
return
0
;
}
else
{
Info
<<
"Error: Missing filename"
<<
endl
;
args
.
printUsage
();
return
1
;
}
}
// This should and will fail:
//// Info<<"find bad file:" << nl
//// << findEtcFile("##BadName##", true) << "FAIL" << endl;
const
bool
listAll
=
(
args
.
found
(
"all"
)
||
args
.
found
(
"list"
));
int
error
=
0
;
for
(
int
argi
=
1
;
argi
<
args
.
size
();
++
argi
)
{
const
std
::
string
file
=
args
[
argi
];
fileNameList
results
=
findEtcFiles
(
file
);
if
(
results
.
empty
())
{
Info
<<
"Not found: "
<<
file
<<
nl
;
error
=
2
;
}
else
if
(
listAll
)
{
printList
(
results
);
}
else
{
Info
<<
results
[
0
].
c_str
()
<<
nl
;
}
}
return
error
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/exprEntry/Make/files
0 → 100644
View file @
55e5a777
Test-exprEntry.C
EXE = $(FOAM_USER_APPBIN)/Test-exprEntry
OpenFOAM-v2112/applications/test/exprEntry/Make/options
0 → 100644
View file @
55e5a777
EXE_INC =
OpenFOAM-v2112/applications/test/exprEntry/Test-exprEntry.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-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-exprEntry
Description
Read in the given dictionaries and attempt to use exprEntry expansion
on any strings.
Note
Since this is only for testing purposes, only handles simple dictionary
entries without attempting to descend into sub-dicts.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "dictionary.H"
#include "stringOps.H"
#include "exprString.H"
using
namespace
Foam
;
bool
hasStrings
(
const
primitiveEntry
&
e
)
{
for
(
const
token
&
tok
:
e
.
stream
())
{
if
(
tok
.
isString
())
{
return
true
;
}
}
return
false
;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noBanner
();
argList
::
noParallel
();
argList
::
addArgument
(
"dict .. dictN"
);
argList
args
(
argc
,
argv
,
false
,
true
);
if
(
args
.
size
()
<=
1
)
{
Info
<<
"Must supply a dictionary name!"
<<
nl
;
}
for
(
label
argi
=
1
;
argi
<
args
.
size
();
++
argi
)
{
IOobject
::
writeDivider
(
Info
);
IFstream
is
(
args
.
get
<
fileName
>
(
argi
));
const
dictionary
dict
(
is
);
Info
<<
"Input dictionary:"
<<
dict
<<
nl
<<
"With any expansions"
<<
nl
<<
endl
;
for
(
const
entry
&
dEntry
:
dict
)
{
const
auto
*
eptr
=
isA
<
primitiveEntry
>
(
dEntry
);
if
(
!
eptr
||
!
hasStrings
(
*
eptr
))
{
continue
;
}
const
primitiveEntry
&
e
=
*
eptr
;
Info
<<
e
<<
endl
;
for
(
const
token
&
t
:
e
.
stream
())
{
if
(
t
.
isString
())
{
string
str
(
t
.
stringToken
());
const
bool
oldThrowingError
=
FatalError
.
throwing
(
true
);
const
bool
oldThrowingIOErr
=
FatalIOError
.
throwing
(
true
);
try
{
// Can get an error if we have things like
// ${{ ... $[...] }}
Info
<<
"str : "
<<
stringOps
::
expand
(
str
,
dict
)
<<
nl
;
}
catch
(
const
Foam
::
error
&
err
)
{
Info
<<
err
.
message
().
c_str
()
<<
nl
;
}
try
{
// Should not trigger any errors
expressions
::
exprString
expr
(
str
,
dict
,
false
);
Info
<<
"expr: "
<<
expr
<<
nl
;
}
catch
(
const
Foam
::
error
&
err
)
{
Info
<<
err
.
message
().
c_str
()
<<
nl
;
}
FatalError
.
throwing
(
oldThrowingError
);
FatalIOError
.
throwing
(
oldThrowingIOErr
);
Info
<<
nl
;
}
}
}
}
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/exprEntry/testDict1
0 → 100644
View file @
55e5a777
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2112 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scalar1 10;
scalar2 20;
vector1 (1 2 3);
vector2 (2 3 4);
aVector 1;
bVector 2;
string1 "This is a scalar $scalar1, or $[ scalar1 ]";
string2 "This is a vector $vector1, or $[vector1]";
string3 "This is a vector $vector1, or $[(vector)vector1]";
string3b "This is a vector ${vector1}, or $[(vector)vector1]";
string4 "This is a vector ${{ 5 * 12 }} or $[(vector)vector1]";
string5 "This is a vector ${{ 5 * 12 }} or $[(vector)vector1]";
string8 "This is a vector ${{ 5 * 12 * $[(vector)vector1] }}";
// These actually work
string10 #{
Cond is ${{ ${{ sin(degToRad(4*$scalar1)) }} * $[(vector) vector${aVector}] }}
#};
// These actually work
string10b #{
Cond is ${{ ${{ sin(degToRad(4*$scalar1)) }} * $[(vector) vector$bVector] }}
#};
// Fairly simple idea
angle 35;
valueExpr1 "vector(${{cos(degToRad($angle))}}, 2, 3)";
// Slightly stranger ideas:
axis1 (1 0 0);
axis2 (0 1 0);
axis3 (0 0 1);
index 100;
valueExpr2 "$[(vector) axis${{ ($index % 3) +1 }}] / ${{max(1, $index)}}";
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
OpenFOAM-v2112/applications/test/exprTraits/Make/files
0 → 100644
View file @
55e5a777
Test-exprTraits.C
EXE = $(FOAM_USER_APPBIN)/Test-exprTraits
Prev
1
…
22
23
24
25
26
27
28
29
30
…
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