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
1536 additions
and
0 deletions
+1536
-0
OpenFOAM-v2112/applications/test/fieldTypes/Test-fieldTypes.C
...FOAM-v2112/applications/test/fieldTypes/Test-fieldTypes.C
+65
-0
OpenFOAM-v2112/applications/test/fileName/Make/files
OpenFOAM-v2112/applications/test/fileName/Make/files
+3
-0
OpenFOAM-v2112/applications/test/fileName/Make/options
OpenFOAM-v2112/applications/test/fileName/Make/options
+2
-0
OpenFOAM-v2112/applications/test/fileName/Test-fileName.C
OpenFOAM-v2112/applications/test/fileName/Test-fileName.C
+804
-0
OpenFOAM-v2112/applications/test/fileNameClean/Make/files
OpenFOAM-v2112/applications/test/fileNameClean/Make/files
+3
-0
OpenFOAM-v2112/applications/test/fileNameClean/Make/options
OpenFOAM-v2112/applications/test/fileNameClean/Make/options
+2
-0
OpenFOAM-v2112/applications/test/fileNameClean/Test-fileNameClean.C
...2112/applications/test/fileNameClean/Test-fileNameClean.C
+128
-0
OpenFOAM-v2112/applications/test/fileNameOS/Make/files
OpenFOAM-v2112/applications/test/fileNameOS/Make/files
+3
-0
OpenFOAM-v2112/applications/test/fileNameOS/Make/options
OpenFOAM-v2112/applications/test/fileNameOS/Make/options
+2
-0
OpenFOAM-v2112/applications/test/fileNameOS/Test-fileNameOS.C
...FOAM-v2112/applications/test/fileNameOS/Test-fileNameOS.C
+108
-0
OpenFOAM-v2112/applications/test/fileOperation1/Make/files
OpenFOAM-v2112/applications/test/fileOperation1/Make/files
+3
-0
OpenFOAM-v2112/applications/test/fileOperation1/Make/options
OpenFOAM-v2112/applications/test/fileOperation1/Make/options
+2
-0
OpenFOAM-v2112/applications/test/fileOperation1/Test-fileOperation1.C
...12/applications/test/fileOperation1/Test-fileOperation1.C
+125
-0
OpenFOAM-v2112/applications/test/findCell-octree/Make/files
OpenFOAM-v2112/applications/test/findCell-octree/Make/files
+3
-0
OpenFOAM-v2112/applications/test/findCell-octree/Make/options
...FOAM-v2112/applications/test/findCell-octree/Make/options
+7
-0
OpenFOAM-v2112/applications/test/findCell-octree/Test-findCell-octree.C
.../applications/test/findCell-octree/Test-findCell-octree.C
+126
-0
OpenFOAM-v2112/applications/test/findSphereFeatureEdges-octree/Make/files
...pplications/test/findSphereFeatureEdges-octree/Make/files
+3
-0
OpenFOAM-v2112/applications/test/findSphereFeatureEdges-octree/Make/options
...lications/test/findSphereFeatureEdges-octree/Make/options
+7
-0
OpenFOAM-v2112/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C
...eFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C
+137
-0
OpenFOAM-v2112/applications/test/findTimes/Make/files
OpenFOAM-v2112/applications/test/findTimes/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/fieldTypes/Test-fieldTypes.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) 2018 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-fieldTypes
Description
Print fieldTypes
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "argList.H"
#include "IOobject.H"
#include "IOstreams.H"
#include "areaFields.H"
#include "fieldTypes.H"
#include "pointFields.H"
#include "volFields.H"
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noParallel
();
Info
<<
"basic: "
<<
flatOutput
(
fieldTypes
::
basic
)
<<
nl
<<
"area: "
<<
flatOutput
(
fieldTypes
::
area
)
<<
nl
<<
"volume: "
<<
flatOutput
(
fieldTypes
::
volume
)
<<
nl
<<
"internal: "
<<
flatOutput
(
fieldTypes
::
internal
)
<<
nl
<<
"point: "
<<
flatOutput
(
fieldTypes
::
point
)
<<
nl
<<
endl
;
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/fileName/Make/files
0 → 100644
View file @
55e5a777
Test-fileName.C
EXE = $(FOAM_USER_APPBIN)/Test-fileName
OpenFOAM-v2112/applications/test/fileName/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = */
/* EXE_LIBS = */
OpenFOAM-v2112/applications/test/fileName/Test-fileName.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-2016 OpenFOAM Foundation
Copyright (C) 2016-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-fileName
Description
Test some basic fileName functionality
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "fileName.H"
#include "SubList.H"
#include "DynamicList.H"
#include "IOobject.H"
#include "IOstreams.H"
#include "OSspecific.H"
#include "POSIX.H"
#include "Switch.H"
#include "etcFiles.H"
#include "Pair.H"
#include "Tuple2.H"
#include <fstream>
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
unsigned
testClean
(
std
::
initializer_list
<
Pair
<
std
::
string
>>
tests
)
{
unsigned
nFail
=
0
;
for
(
const
Pair
<
std
::
string
>&
test
:
tests
)
{
const
std
::
string
&
input
=
test
.
first
();
const
std
::
string
&
expected
=
test
.
second
();
fileName
cleaned
(
test
.
first
());
cleaned
.
clean
();
// Remove unneeded ".."
if
(
cleaned
==
expected
)
{
Info
<<
"(pass)"
<<
" clean "
<<
input
<<
" -> "
<<
cleaned
<<
nl
;
}
else
{
Info
<<
"(fail)"
<<
" clean "
<<
input
<<
" -> "
<<
cleaned
<<
" expected="
<<
expected
<<
nl
;
++
nFail
;
}
}
return
nFail
;
}
unsigned
testStrip
(
const
bool
doClean
,
std
::
initializer_list
<
Tuple2
<
bool
,
std
::
string
>
>
tests
)
{
Info
<<
nl
<<
"Checking with clean="
<<
Switch
(
doClean
)
<<
nl
<<
endl
;
unsigned
nFail
=
0
;
for
(
const
Tuple2
<
bool
,
std
::
string
>&
test
:
tests
)
{
const
bool
expected
=
test
.
first
();
const
std
::
string
&
input
=
test
.
second
();
fileName
output
(
fileName
::
validate
(
input
,
doClean
));
// Check for real failure (invalid chars) vs.
// spurious failure (removed double slashes with 'doClean').
const
bool
same
=
(
doClean
?
fileName
::
equals
(
input
,
output
)
:
(
input
==
output
)
);
if
(
same
)
{
if
(
expected
)
{
Info
<<
"(pass) validated "
<<
input
<<
" = "
<<
output
<<
nl
;
}
else
{
++
nFail
;
Info
<<
"(fail) unexpected success for "
<<
input
<<
nl
;
}
}
else
{
if
(
expected
)
{
++
nFail
;
Info
<<
"(fail) unexpected"
;
}
else
{
Info
<<
"(pass) expected"
;
}
Info
<<
" failure for "
<<
input
<<
nl
;
}
}
return
nFail
;
}
unsigned
testEquals
(
std
::
initializer_list
<
Tuple2
<
bool
,
Pair
<
std
::
string
>>
>
tests
)
{
Info
<<
nl
<<
"Checking fileName::equals()"
<<
nl
<<
endl
;
unsigned
nFail
=
0
;
for
(
const
Tuple2
<
bool
,
Pair
<
std
::
string
>>&
test
:
tests
)
{
const
bool
expected
=
test
.
first
();
const
std
::
string
&
s1
=
test
.
second
().
first
();
const
std
::
string
&
s2
=
test
.
second
().
second
();
const
bool
same
=
fileName
::
equals
(
s1
,
s2
);
if
(
same
)
{
if
(
expected
)
{
Info
<<
"(pass) success"
;
}
else
{
++
nFail
;
Info
<<
"(fail) unexpected success"
;
}
}
else
{
if
(
expected
)
{
++
nFail
;
Info
<<
"(fail) unexpected failure"
;
}
else
{
Info
<<
"(pass) expected failure"
;
}
}
Info
<<
" for "
<<
s1
<<
" == "
<<
s2
<<
nl
;
}
return
nFail
;
}
unsigned
testRelative
(
std
::
initializer_list
<
Pair
<
std
::
string
>>
tests
)
{
Info
<<
nl
<<
"Checking fileName::relative()"
<<
nl
<<
endl
;
unsigned
nFail
=
0
;
for
(
const
Pair
<
std
::
string
>&
test
:
tests
)
{
const
std
::
string
&
dir
=
test
.
first
();
const
std
::
string
&
parent
=
test
.
second
();
Info
<<
"directory: "
<<
dir
<<
nl
<<
"parent : "
<<
parent
<<
nl
<<
"relative = "
<<
fileName
(
dir
).
relative
(
parent
)
<<
nl
<<
"case-rel = "
<<
fileName
(
dir
).
relative
(
parent
,
true
)
<<
nl
<<
endl
;
}
return
nFail
;
}
void
testDirname
(
const
fileName
&
input
)
{
Info
<<
"input:"
<<
input
<<
" path:"
<<
input
.
path
()
<<
" name:
\"
"
<<
input
.
name
()
<<
'"'
<<
" ext:
\"
"
<<
input
.
ext
()
<<
'"'
<<
" components: "
<<
flatOutput
(
input
.
components
())
<<
" last: "
<<
input
.
component
(
string
::
npos
)
<<
nl
;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noParallel
();
argList
::
addBoolOption
(
"validate"
,
"test fileName::validate"
);
argList
::
addBoolOption
(
"ext"
,
"test handing of file extensions"
);
argList
::
addBoolOption
(
"construct"
,
"test constructors"
);
argList
::
addBoolOption
(
"relative"
,
"test relative operations"
);
argList
::
addBoolOption
(
"system"
,
"test filesystem operations"
);
argList
::
addBoolOption
(
"default"
,
"reinstate default tests"
);
argList
::
addBoolOption
(
"clean"
,
"clean()"
);
argList
::
addBoolOption
(
"dirname"
,
"basename/dirname tables"
);
argList
::
addNote
(
"runs default tests or specified ones only"
);
#include "setRootCase.H"
// Run default tests, unless specific tests are requested
const
bool
defaultTests
=
args
.
found
(
"default"
)
||
args
.
options
().
empty
();
if
(
args
.
found
(
"construct"
))
{
Info
<<
"From initializer_list<word> = "
;
fileName
file1
{
"hello"
,
"hello1"
,
"hello2"
,
"hello3"
,
"hello4.hmm"
};
Info
<<
file1
<<
nl
;
Info
<<
"From initializer_list<fileName> = "
;
fileName
file2
{
file1
,
"some"
,
"more/things.hmm"
};
Info
<<
file2
<<
nl
;
Info
<<
"From initializer_list<fileName> with nesting = "
;
fileName
file3
{
std
::
string
(
"ffO"
),
"some"
,
"more/things.hmm"
};
Info
<<
file3
<<
nl
;
DynamicList
<
word
>
base
{
"hello"
,
"hello1"
};
fileName
file4
{
"some"
,
file3
,
"more/things.hmm"
,
file1
};
Info
<<
"All ==> "
<<
file4
<<
nl
;
}
if
(
args
.
found
(
"dirname"
))
{
testDirname
(
""
);
testDirname
(
"."
);
testDirname
(
"abc"
);
testDirname
(
"/"
);
testDirname
(
"/abc"
);
testDirname
(
"abc/def"
);
testDirname
(
"/abc/def"
);
testDirname
(
"/abc/def/"
);
testDirname
(
"/abc///def///"
);
testDirname
(
"/abc/../def"
);
}
// Test various ext() methods
if
(
args
.
found
(
"ext"
))
{
Info
<<
nl
<<
nl
<<
"handling of fileName extension"
<<
nl
;
fileName
empty
;
fileName
endWithDot
(
"some.path/name."
);
fileName
endWithSlash
(
"some.path/"
);
fileName
input0
(
"some.file/with.out/extension"
);
fileName
input1
(
"path.to/media/image.png"
);
Info
<<
"File : "
<<
input0
<<
" ext: "
<<
Switch
(
input0
.
hasExt
())
<<
" = "
<<
input0
.
ext
()
<<
nl
;
Info
<<
"File : "
<<
input1
<<
" ext: "
<<
Switch
(
input1
.
hasExt
())
<<
" = "
<<
input1
.
ext
()
<<
nl
;
Info
<<
"File : "
<<
endWithDot
<<
" ext: "
<<
Switch
(
endWithDot
.
hasExt
())
<<
" = "
<<
endWithDot
.
ext
()
<<
" <-- perhaps return false?"
<<
nl
;
Info
<<
"File : "
<<
endWithSlash
<<
" ext: "
<<
Switch
(
endWithSlash
.
hasExt
())
<<
" = "
<<
endWithSlash
.
ext
()
<<
nl
;
Info
<<
"Remove extension "
<<
(
input0
.
removeExt
());
Info
<<
" now: "
<<
input0
<<
nl
;
Info
<<
"Remove extension "
<<
(
input1
.
removeExt
());
Info
<<
" now: "
<<
input1
<<
nl
;
Info
<<
"Remove extension "
<<
(
endWithSlash
.
removeExt
());
Info
<<
" now: "
<<
endWithSlash
<<
nl
;
wordList
exts
{
"jpg"
,
"png"
,
"txt"
,
word
::
null
};
Info
<<
"Add extension(s): "
<<
input1
<<
nl
;
for
(
const
word
&
e
:
exts
)
{
Info
<<
"<"
<<
e
<<
"> -> "
<<
input1
.
ext
(
e
)
<<
nl
;
}
Info
<<
nl
;
Info
<<
"Test hasExt(word)"
<<
nl
<<
"~~~~~~~~~~~~~~~~~"
<<
nl
;
Info
<<
"Has extension(s):"
<<
nl
<<
"input: "
<<
input1
<<
nl
;
for
(
const
word
&
e
:
exts
)
{
Info
<<
" '"
<<
e
<<
"' -> "
<<
Switch
(
input1
.
hasExt
(
e
))
<<
nl
;
}
Info
<<
nl
;
Info
<<
"Has extension(s):"
<<
nl
<<
"input: "
<<
endWithDot
<<
nl
;
for
(
const
word
&
e
:
exts
)
{
Info
<<
" '"
<<
e
<<
"' -> "
<<
Switch
(
endWithDot
.
hasExt
(
e
))
<<
nl
;
}
Info
<<
nl
;
Info
<<
"Test hasExt(wordRe)"
<<
nl
<<
"~~~~~~~~~~~~~~~~~~~"
<<
nl
;
// A regex with a zero length matcher doesn't work at all:
// eg "(png|jpg|txt|)" regex matcher itself
wordRe
matcher0
(
"()"
,
wordRe
::
REGEX
);
wordRe
matcher1
(
"(png|jpg|txt)"
,
wordRe
::
REGEX
);
wordRe
matcher2
(
"(png|txt)"
,
wordRe
::
REGEX
);
Info
<<
"Has extension(s):"
<<
nl
<<
"input: "
<<
endWithDot
<<
nl
;
Info
<<
" "
<<
matcher0
<<
" -> "
<<
Switch
(
endWithDot
.
hasExt
(
matcher0
))
<<
nl
;
Info
<<
" "
<<
matcher1
<<
" -> "
<<
Switch
(
endWithDot
.
hasExt
(
matcher1
))
<<
nl
;
Info
<<
" "
<<
matcher2
<<
" -> "
<<
Switch
(
endWithDot
.
hasExt
(
matcher2
))
<<
nl
;
Info
<<
"input: "
<<
input1
<<
nl
;
Info
<<
" "
<<
matcher0
<<
" -> "
<<
Switch
(
input1
.
hasExt
(
matcher0
))
<<
nl
;
Info
<<
" "
<<
matcher1
<<
" -> "
<<
Switch
(
input1
.
hasExt
(
matcher1
))
<<
nl
;
Info
<<
" "
<<
matcher2
<<
" -> "
<<
Switch
(
input1
.
hasExt
(
matcher2
))
<<
nl
;
Info
<<
nl
;
Info
<<
"Remove extension(s):"
<<
nl
<<
"input: "
<<
input1
<<
nl
;
while
(
!
input1
.
empty
())
{
if
(
input1
.
removeExt
())
{
Info
<<
" -> "
<<
input1
<<
nl
;
}
else
{
Info
<<
"stop> "
<<
input1
<<
nl
;
break
;
}
}
Info
<<
nl
;
input0
.
clear
();
Info
<<
"test with zero-sized: "
<<
input0
<<
nl
;
Info
<<
"add extension: "
<<
input0
.
ext
(
"abc"
)
<<
nl
;
Info
<<
nl
;
input0
=
"this/"
;
Info
<<
"test add after slash: "
<<
input0
<<
nl
;
Info
<<
"add extension: "
<<
input0
.
ext
(
"abc"
)
<<
" <-- avoids accidentally creating hidden files"
<<
nl
;
Info
<<
nl
;
input0
=
"this.file."
;
Info
<<
"test after dot: "
<<
input0
<<
nl
;
Info
<<
"add extension: "
<<
input0
.
ext
(
"abc"
)
<<
" <-- No check for repeated dots (user error!)"
<<
nl
;
Info
<<
nl
;
}
if
(
args
.
found
(
"clean"
))
{
Info
<<
nl
<<
"Test fileName::clean()"
<<
nl
<<
nl
;
unsigned
nFail
=
testClean
({
{
"/"
,
"/"
},
{
"/abc/"
,
"/abc"
},
{
"/abc////def"
,
"/abc/def"
},
{
"/abc/def/./ghi/."
,
"/abc/def/ghi"
},
{
"abc/def/./"
,
"abc/def"
},
{
"./abc/"
,
"./abc"
},
{
"/abc/def/../ghi/jkl/nmo/.."
,
"/abc/ghi/jkl"
},
{
"abc/../def/ghi/../jkl"
,
"abc/../def/jkl"
},
});
Info
<<
nl
;
if
(
nFail
)
{
Info
<<
"failed "
<<
nFail
;
}
else
{
Info
<<
"passed all"
;
}
Info
<<
" fileName::clean tests"
<<
nl
;
}
if
(
args
.
found
(
"validate"
))
{
unsigned
nFail
=
0
;
Info
<<
nl
<<
"Test fileName::validate"
<<
nl
;
// Without clean
nFail
+=
testEquals
(
{
{
true
,
{
"abc"
,
"abc/"
}
},
{
true
,
{
"///abc/"
,
"//abc///"
}
},
{
false
,
{
" ab //c/"
,
"ab/c"
}
},
}
);
Info
<<
nl
<<
"Test fileName::validate"
<<
nl
;
// Without clean
nFail
+=
testStrip
(
false
,
{
{
true
,
"abc/"
},
{
true
,
"/"
,
},
{
true
,
"//"
,
},
{
true
,
"/abc/def"
,
},
{
true
,
"/abc/def/"
,
},
{
false
,
"/abc def"
},
{
true
,
"/abc////def///"
,
},
{
false
,
"/abc//// def///"
},
}
);
// With clean
nFail
+=
testStrip
(
true
,
{
{
true
,
"abc/"
},
{
true
,
"/"
},
{
true
,
"//"
},
{
true
,
"/abc/def"
},
{
true
,
"/abc/def/"
},
{
false
,
"/abc def"
},
{
true
,
"/abc////def///"
},
{
false
,
"/abc//// def///"
},
}
);
Info
<<
nl
;
if
(
nFail
)
{
Info
<<
"failed "
<<
nFail
;
}
else
{
Info
<<
"passed all"
;
}
Info
<<
" fileName::validate tests"
<<
nl
;
}
if
(
args
.
found
(
"relative"
))
{
unsigned
nFail
=
0
;
nFail
+=
testRelative
(
{
{
""
,
""
},
{
""
,
"/"
},
{
""
,
"/some"
},
{
"/some/dir/subdir/name"
,
""
},
{
"/some/dir/subdir/name"
,
"/"
},
{
"/some/dir/subdir/name"
,
"/some"
},
{
"/some/dir/subdir/name"
,
"/some/"
},
{
"/some/dir/subdir/name"
,
"/some/dir"
},
{
"/some/dir/subdir/name"
,
"/some/dir/"
},
{
"/some/dir/subdir/name"
,
"/some/dir/subdir"
},
{
"/some/dir/subdir/name"
,
"/some/dir/subdir/name"
},
{
"/some/dir/subdir/name"
,
"/some/dir/subdir/name/"
},
{
"/some/dir/subdir/name"
,
"/some/other"
},
// With single-char for name
{
"/some/dir/subdir/a"
,
""
},
{
"/some/dir/subdir/a"
,
"/"
},
{
"/some/dir/subdir/a"
,
"/some"
},
{
"/some/dir/subdir/a"
,
"/some/"
},
{
"/some/dir/subdir/a"
,
"/some/dir"
},
{
"/some/dir/subdir/a"
,
"/some/dir/"
},
{
"/some/dir/subdir/a"
,
"/some/dir/subdir"
},
{
"/some/dir/subdir/a"
,
"/some/dir/subdir/a"
},
{
"/some/dir/subdir/a"
,
"/some/dir/subdir/a/"
},
{
"/some/dir/subdir/a"
,
"/some/other"
},
// Bad input (trailing slash)
{
"/some/dir/subdir/a/"
,
""
},
{
"/some/dir/subdir/a/"
,
"/"
},
{
"/some/dir/subdir/a/"
,
"/some"
},
{
"/some/dir/subdir/a/"
,
"/some/"
},
{
"/some/dir/subdir/a/"
,
"/some/dir"
},
{
"/some/dir/subdir/a/"
,
"/some/dir/"
},
{
"/some/dir/subdir/a/"
,
"/some/dir/subdir/"
},
{
"/some/dir/subdir/a/"
,
"/some/dir/subdir/a"
},
{
"/some/dir/subdir/a/"
,
"/some/dir/subdir/a/"
},
{
"/some/dir/subdir/a/"
,
"/some/other"
},
}
);
}
// Test some copying and deletion
if
(
args
.
found
(
"system"
))
{
const
fileName
dirA
(
"dirA"
);
const
fileName
lnA
(
"lnA"
);
const
fileName
lnB
(
"lnB"
);
const
fileName
dirB
(
"dirB"
);
Foam
::
rmDir
(
dirA
);
Foam
::
rm
(
lnA
);
Foam
::
rm
(
lnB
);
Foam
::
rmDir
(
dirB
);
Info
<<
nl
<<
"========================="
<<
nl
<<
"Test some copying and deletion"
<<
endl
;
Info
<<
"Creating directory "
<<
dirA
<<
endl
;
Foam
::
mkDir
(
dirA
);
Info
<<
"Populating with various files"
<<
endl
;
for
(
const
std
::
string
name
:
{
"file-1"
,
"file-2"
,
"bad name one"
,
"bad name 2"
}
)
{
// Full path, but without any stripping
const
fileName
file
(
(
static_cast
<
const
std
::
string
&>
(
dirA
)
+
"/"
+
name
),
false
);
Info
<<
" create: "
<<
file
<<
endl
;
std
::
ofstream
os
(
file
);
os
<<
"file=<"
<<
file
<<
">"
<<
nl
;
}
const
int
oldDebug
=
POSIX
::
debug
;
POSIX
::
debug
=
1
;
// Create link and test it
Info
<<
"Creating softlink "
<<
lnA
<<
endl
;
Foam
::
ln
(
dirA
,
lnA
);
fileName
::
Type
lnAType
=
lnA
.
type
(
false
);
if
(
lnAType
!=
fileName
::
LINK
)
{
FatalErrorIn
(
"Test-fileName"
)
<<
"Type of softlink "
<<
lnA
<<
" should be "
<<
fileName
::
LINK
<<
" but is "
<<
lnAType
<<
exit
(
FatalError
);
}
fileName
::
Type
dirAType
=
lnA
.
type
(
true
);
if
(
dirAType
!=
fileName
::
DIRECTORY
)
{
FatalErrorIn
(
"Test-fileName"
)
<<
"Type of what softlink "
<<
lnA
<<
" points to should be "
<<
fileName
::
DIRECTORY
<<
" but is "
<<
dirAType
<<
exit
(
FatalError
);
}
// Copy link only
{
Info
<<
"Copying (non-follow) softlink "
<<
lnA
<<
" to "
<<
lnB
<<
endl
;
Foam
::
cp
(
lnA
,
lnB
,
false
);
if
(
lnB
.
type
(
false
)
!=
fileName
::
LINK
)
{
FatalErrorIn
(
"Test-fileName"
)
<<
"Type of softlink "
<<
lnB
<<
" should be "
<<
fileName
::
LINK
<<
" but is "
<<
lnB
.
type
(
false
)
<<
exit
(
FatalError
);
}
if
(
lnB
.
type
(
true
)
!=
fileName
::
DIRECTORY
)
{
FatalErrorIn
(
"Test-fileName"
)
<<
"Type of softlink "
<<
lnB
<<
" should be "
<<
fileName
::
DIRECTORY
<<
" but is "
<<
lnB
.
type
(
true
)
<<
exit
(
FatalError
);
}
// Delete (link)
Foam
::
rm
(
lnB
);
}
// Copy contents of link
{
Info
<<
"Copying (contents of) softlink "
<<
lnA
<<
" to "
<<
lnB
<<
endl
;
Foam
::
cp
(
lnA
,
lnB
,
true
);
if
(
lnB
.
type
(
false
)
!=
fileName
::
DIRECTORY
)
{
FatalErrorIn
(
"Test-fileName"
)
<<
"Type of softlink "
<<
lnB
<<
" should be "
<<
fileName
::
DIRECTORY
<<
" but is "
<<
lnB
.
type
(
false
)
<<
exit
(
FatalError
);
}
// Delete (directory, not link)
Foam
::
rmDir
(
lnB
);
}
POSIX
::
debug
=
oldDebug
;
// Verify that rmDir works with bad names too
Foam
::
rmDir
(
dirA
);
Foam
::
rm
(
lnA
);
}
if
(
!
defaultTests
)
{
return
0
;
}
DynamicList
<
word
>
wrdList
{
"hello"
,
"hello1"
,
"hello2"
,
"hello3"
,
"hello4.hmm"
};
fileName
pathName
(
wrdList
);
Info
<<
"pathName = "
<<
pathName
<<
nl
<<
"nameOp = "
<<
nameOp
<
fileName
>
()(
pathName
)
<<
nl
<<
"pathName.name() = >"
<<
pathName
.
name
()
<<
"<
\n
"
<<
"pathName.path() = "
<<
pathName
.
path
()
<<
nl
<<
"pathName.ext() = >"
<<
pathName
.
ext
()
<<
"<
\n
"
<<
"pathName.nameLessExt= >"
<<
pathName
.
nameLessExt
()
<<
"<
\n
"
;
Info
<<
"pathName.components() = "
<<
pathName
.
components
()
<<
nl
<<
"pathName.component(2) = "
<<
pathName
.
component
(
2
)
<<
nl
<<
endl
;
Info
<<
"hasPath = "
<<
Switch
(
pathName
.
hasPath
())
<<
nl
;
pathName
.
removePath
();
Info
<<
"removed path = "
<<
pathName
<<
nl
;
Info
<<
nl
<<
nl
;
// try with different combination
// The final one should emit warnings
for
(
label
start
=
0
;
start
<=
wrdList
.
size
();
++
start
)
{
fileName
instance
,
local
;
word
name
;
fileName
path
(
SubList
<
word
>
(
wrdList
,
wrdList
.
size
()
-
start
,
start
));
fileName
path2
=
"."
/
path
;
IOobject
::
fileNameComponents
(
path
,
instance
,
local
,
name
);
Info
<<
"IOobject::fileNameComponents for "
<<
path
<<
nl
<<
" instance = "
<<
instance
<<
nl
<<
" local = "
<<
local
<<
nl
<<
" name = "
<<
name
<<
endl
;
IOobject
::
fileNameComponents
(
path2
,
instance
,
local
,
name
);
Info
<<
"IOobject::fileNameComponents for "
<<
path2
<<
nl
<<
" instance = "
<<
instance
<<
nl
<<
" local = "
<<
local
<<
nl
<<
" name = "
<<
name
<<
endl
;
}
// test findEtcFile
Info
<<
"
\n\n
findEtcFile tests:"
<<
nl
<<
" controlDict => "
<<
findEtcFile
(
"controlDict"
)
<<
nl
<<
" badName => "
<<
findEtcFile
(
"badName"
)
<<
endl
;
{
Info
<<
nl
<<
"Expect a FatalError for findEtcFile() with a bad name:"
<<
nl
;
const
bool
oldThrowingError
=
FatalError
.
throwing
(
true
);
try
{
Info
<<
" badName(die) => "
<<
flush
<<
findEtcFile
(
"<very-badName>"
,
true
)
<<
nl
<<
endl
;
}
catch
(
const
Foam
::
error
&
err
)
{
Info
<<
nl
<<
"findEtcFile() Caught FatalError "
<<
err
<<
nl
<<
endl
;
}
FatalError
.
throwing
(
oldThrowingError
);
}
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/fileNameClean/Make/files
0 → 100644
View file @
55e5a777
Test-fileNameClean.C
EXE = $(FOAM_USER_APPBIN)/Test-fileNameClean
OpenFOAM-v2112/applications/test/fileNameClean/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = */
/* EXE_LIBS = */
OpenFOAM-v2112/applications/test/fileNameClean/Test-fileNameClean.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) 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-fileNameClean
Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "fileName.H"
#include "SubList.H"
#include "IOobject.H"
#include "IOstreams.H"
#include "OSspecific.H"
using
namespace
Foam
;
void
printCleaning
(
fileName
&
pathName
)
{
Info
<<
"fileName = "
<<
pathName
<<
nl
<<
" path() = "
<<
pathName
.
path
()
<<
nl
<<
" name() = "
<<
pathName
.
name
()
<<
nl
<<
" joined = "
<<
pathName
.
path
()
/
pathName
.
name
()
<<
nl
<<
nl
;
Info
<<
"components = "
<<
flatOutput
(
pathName
.
components
())
<<
nl
;
Info
<<
"component 2 = "
<<
pathName
.
component
(
2
)
<<
nl
;
pathName
.
clean
();
// Remove unneeded ".."
Info
<<
"cleaned = "
<<
pathName
<<
nl
<<
" path() = "
<<
pathName
.
path
()
<<
nl
<<
" name() = "
<<
pathName
.
name
()
<<
nl
<<
" joined = "
<<
pathName
.
path
()
/
pathName
.
name
()
<<
nl
<<
nl
;
IOobject
::
writeDivider
(
Info
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noBanner
();
argList
::
noParallel
();
argList
::
addArgument
(
"fileName .. fileNameN"
);
argList
::
addOption
(
"istream"
,
"file"
,
"test Istream values"
);
argList
args
(
argc
,
argv
,
false
,
true
);
if
(
args
.
size
()
<=
1
&&
args
.
options
().
empty
())
{
args
.
printUsage
();
}
fileName
pathName
;
if
(
args
.
readIfPresent
(
"case"
,
pathName
))
{
Info
<<
nl
<<
"-case"
<<
nl
<<
"path = "
<<
args
.
path
()
<<
nl
<<
"root = "
<<
args
.
rootPath
()
<<
nl
<<
"case = "
<<
args
.
caseName
()
<<
nl
<<
"FOAM_CASE="
<<
getEnv
(
"FOAM_CASE"
)
<<
nl
<<
"FOAM_CASENAME="
<<
getEnv
(
"FOAM_CASENAME"
)
<<
nl
<<
endl
;
printCleaning
(
pathName
);
}
for
(
label
argi
=
1
;
argi
<
args
.
size
();
++
argi
)
{
fileName
fn
(
args
[
argi
],
false
);
// no strip
Info
<<
"Input = "
<<
fn
<<
nl
;
fn
.
clean
();
// Remove unneeded ".."
Info
<<
"cleaned = "
<<
fn
<<
nl
;
Info
<<
"get = "
<<
args
.
get
<
fileName
>
(
argi
)
<<
nl
;
pathName
=
fileName
::
validate
(
args
[
argi
]);
printCleaning
(
pathName
);
}
if
(
args
.
readIfPresent
(
"istream"
,
pathName
))
{
Info
<<
nl
<<
"-case"
<<
nl
<<
"path = "
<<
args
.
path
()
<<
nl
<<
"root = "
<<
args
.
rootPath
()
<<
nl
<<
"case = "
<<
args
.
caseName
()
<<
nl
<<
"FOAM_CASE="
<<
getEnv
(
"FOAM_CASE"
)
<<
nl
<<
"FOAM_CASENAME="
<<
getEnv
(
"FOAM_CASENAME"
)
<<
nl
<<
endl
;
printCleaning
(
pathName
);
}
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/fileNameOS/Make/files
0 → 100644
View file @
55e5a777
Test-fileNameOS.C
EXE = $(FOAM_USER_APPBIN)/Test-fileNameOS
OpenFOAM-v2112/applications/test/fileNameOS/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = */
/* EXE_LIBS = */
OpenFOAM-v2112/applications/test/fileNameOS/Test-fileNameOS.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 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-fileNameOS
Description
Test fileName behaviour, potential OS capabilities etc.
In the distant future could possibly replace parts with C++ filesystem
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "fileName.H"
#include "OSspecific.H"
#include "Switch.H"
#include <csignal>
#include <cstdlib>
#include <iostream>
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void
testDirname
(
const
std
::
string
&
rawInput
)
{
fileName
input
(
fileName
::
validate
(
rawInput
));
Info
<<
nl
<<
"input: "
<<
rawInput
<<
nl
<<
"fileName:"
<<
input
<<
nl
<<
" path:"
<<
input
.
path
()
<<
" name:
\"
"
<<
input
.
name
()
<<
'"'
<<
" ext:
\"
"
<<
input
.
ext
()
<<
'"'
<<
" components: "
<<
flatOutput
(
input
.
components
())
<<
nl
;
if
(
rawInput
.
size
()
!=
input
.
size
())
{
Info
<<
" This would be Fatal with debug > 1"
<<
nl
;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noParallel
();
argList
::
addBoolOption
(
"no-space"
,
"allowSpaceInFileName = false"
);
argList
::
addBoolOption
(
"with-space"
,
"set allowSpaceInFileName = true"
);
#include "setRootCase.H"
if
(
args
.
found
(
"with-space"
))
{
fileName
::
allowSpaceInFileName
=
true
;
}
if
(
args
.
found
(
"no-space"
))
{
fileName
::
allowSpaceInFileName
=
false
;
}
Info
<<
"fileName with spaces? : "
<<
Switch
(
bool
(
fileName
::
allowSpaceInFileName
))
<<
nl
<<
nl
;
{
testDirname
(
"/abc"
);
testDirname
(
"/abc/with space/name"
);
testDirname
(
"/abc/with space/more space"
);
}
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/fileOperation1/Make/files
0 → 100644
View file @
55e5a777
Test-fileOperation1.C
EXE = $(FOAM_USER_APPBIN)/Test-fileOperation1
OpenFOAM-v2112/applications/test/fileOperation1/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = */
/* EXE_LIBS = */
OpenFOAM-v2112/applications/test/fileOperation1/Test-fileOperation1.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 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-fileOperation1
Description
Test string parsing and other bits for fileOperation
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "fileName.H"
#include "fileOperation.H"
#include "SubList.H"
#include "IOobject.H"
#include "IOstreams.H"
#include "OSspecific.H"
using
namespace
Foam
;
word
toString
(
const
fileOperation
::
procRangeType
&
group
)
{
if
(
group
.
empty
())
{
return
word
::
null
;
}
return
Foam
::
name
(
group
.
first
())
+
"-"
+
Foam
::
name
(
group
.
last
());
}
void
testSplitPath
(
const
fileName
&
pathName
)
{
fileName
path
,
procDir
,
local
;
fileOperation
::
procRangeType
group
;
label
nProcs
;
const
label
proci
=
fileOperation
::
splitProcessorPath
(
pathName
,
path
,
procDir
,
local
,
group
,
nProcs
);
Info
<<
nl
<<
"Input = "
<<
pathName
<<
nl
<<
" path = "
<<
path
<<
nl
<<
" proc = "
<<
procDir
<<
nl
<<
" local = "
<<
local
<<
nl
<<
" group = "
<<
group
<<
" = "
<<
toString
(
group
)
<<
nl
<<
" proci = "
<<
proci
<<
nl
<<
" nProcs = "
<<
nProcs
<<
nl
;
}
void
testSplitPaths
(
std
::
initializer_list
<
const
char
*
const
>
dirNames
)
{
for
(
const
auto
&
dirName
:
dirNames
)
{
testSplitPath
(
fileName
(
dirName
));
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
addArgument
(
"fileName .. fileNameN"
);
argList
::
addOption
(
"istream"
,
"file"
,
"test Istream values"
);
testSplitPaths
({
"foo/bar"
,
"foo/processor5/system"
,
"foo/processors100_0-5/constant"
,
"foo/processors20_12-16/constant"
,
"/new-processor-gen/case1/processors20"
,
"/new-processor-gen/case1/processors100_0-5/constant"
,
"/new-processor-gen/case1/processors/input"
,
"devel/processor/ideas/processor0/system"
,
"/path/processor0Generation1/case1/processor10/input"
,
"path/processors100_ab-cd/constant"
,
"path/processors100_a11-d00/constant"
,
});
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/findCell-octree/Make/files
0 → 100644
View file @
55e5a777
Test-findCell-octree.C
EXE = $(FOAM_USER_APPBIN)/Test-findCell-octree
OpenFOAM-v2112/applications/test/findCell-octree/Make/options
0 → 100644
View file @
55e5a777
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools
OpenFOAM-v2112/applications/test/findCell-octree/Test-findCell-octree.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
-------------------------------------------------------------------------------
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 "argList.H"
#include "Time.H"
#include "fvMesh.H"
#include "indexedOctree.H"
#include "treeDataCell.H"
#include "OFstream.H"
#include "fvCFD.H"
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
addArgument
(
"point (x y z)"
);
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
label
nReps
=
10000
;
const
point
sample
=
args
.
get
<
point
>
(
1
);
const
polyMesh
::
cellDecomposition
decompMode
=
polyMesh
::
CELL_TETS
;
treeBoundBox
meshBb
(
mesh
.
bounds
());
// Calculate typical cell related size to shift bb by.
scalar
typDim
=
meshBb
.
avgDim
()
/
(
2
.
0
*
Foam
::
cbrt
(
scalar
(
mesh
.
nCells
())));
treeBoundBox
shiftedBb
(
meshBb
.
min
(),
meshBb
.
max
()
+
vector
(
typDim
,
typDim
,
typDim
)
);
Info
<<
"Mesh"
<<
endl
;
Info
<<
" bounding box : "
<<
meshBb
<<
endl
;
Info
<<
" bounding box (shifted) : "
<<
shiftedBb
<<
endl
;
Info
<<
" typical dimension : "
<<
shiftedBb
.
typDim
()
<<
endl
;
Info
<<
"Initialised mesh in "
<<
runTime
.
cpuTimeIncrement
()
<<
" s"
<<
endl
;
{
indexedOctree
<
treeDataCell
>
ioc
(
treeDataCell
(
true
,
mesh
,
decompMode
),
//FACEDIAGTETS),
shiftedBb
,
10
,
// maxLevel
100
,
// leafsize
10
.
0
// duplicity
);
for
(
label
i
=
0
;
i
<
nReps
-
1
;
i
++
)
{
if
((
i
%
100
)
==
0
)
{
Info
<<
"indexed octree for "
<<
i
<<
endl
;
}
ioc
.
findInside
(
sample
);
}
Info
<<
"Point:"
<<
sample
<<
" is in shape "
<<
ioc
.
findInside
(
sample
)
<<
", where the possible cells were:"
<<
nl
<<
ioc
.
findIndices
(
sample
)
<<
endl
;
Info
<<
"Found in indexedOctree "
<<
nReps
<<
" times in "
<<
runTime
.
cpuTimeIncrement
()
<<
" s"
<<
endl
;
}
{
for
(
label
i
=
0
;
i
<
nReps
-
1
;
i
++
)
{
if
((
i
%
100
)
==
0
)
{
Info
<<
"linear search for "
<<
i
<<
endl
;
}
mesh
.
findCell
(
sample
,
decompMode
);
}
Info
<<
"Point:"
<<
sample
<<
" is in cell "
<<
mesh
.
findCell
(
sample
,
decompMode
)
<<
endl
;
Info
<<
"Found in mesh.findCell "
<<
nReps
<<
" times in "
<<
runTime
.
cpuTimeIncrement
()
<<
" s"
<<
endl
;
}
Info
<<
"End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/findSphereFeatureEdges-octree/Make/files
0 → 100644
View file @
55e5a777
Test-findSphereFeatureEdges-octree.C
EXE = $(FOAM_USER_APPBIN)/Test-findSphereFeatureEdges-octree
OpenFOAM-v2112/applications/test/findSphereFeatureEdges-octree/Make/options
0 → 100644
View file @
55e5a777
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools
OpenFOAM-v2112/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.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 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/>.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "fvMesh.H"
#include "indexedOctree.H"
#include "treeDataEdge.H"
#include "OFstream.H"
#include "extendedFeatureEdgeMesh.H"
#include "fvCFD.H"
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
fileName
sFeatFileName
(
"unit_cube_rotated.extendedFeatureEdgeMesh"
);
extendedFeatureEdgeMesh
efem
(
IOobject
(
sFeatFileName
,
runTime
.
time
().
constant
(),
"extendedFeatureEdgeMesh"
,
runTime
.
time
(),
IOobject
::
MUST_READ
,
IOobject
::
NO_WRITE
)
);
// Slightly extended bb. Slightly off-centred just so on symmetric
// geometry there are less face/edge aligned items.
treeBoundBox
bb
(
efem
.
points
()
);
bb
.
min
()
-=
point
::
uniform
(
ROOTVSMALL
);
bb
.
max
()
+=
point
::
uniform
(
ROOTVSMALL
);
labelList
allEdges
(
identity
(
efem
.
edges
().
size
()));
indexedOctree
<
treeDataEdge
>
edgeTree
(
treeDataEdge
(
false
,
// cachebb
efem
.
edges
(),
// edges
efem
.
points
(),
// points
allEdges
// selected edges
),
bb
,
// bb
8
,
// maxLevel
10
,
// leafsize
3
.
0
// duplicity
);
Info
<<
"Points: "
<<
efem
.
points
()
<<
nl
<<
endl
;
Info
<<
"Edges: "
<<
efem
.
edges
()
<<
nl
<<
endl
;
Info
<<
"Find edge labels within sphere from point (0, 0, 0):"
<<
endl
;
Info
<<
" Radius = 0 : "
<<
edgeTree
.
findSphere
(
point
(
0
,
0
,
0
),
0
)
<<
endl
;
Info
<<
" Radius = 1 : "
<<
edgeTree
.
findSphere
(
point
(
0
,
0
,
0
),
1
)
<<
endl
;
Info
<<
" Radius = root(1.5) : "
<<
edgeTree
.
findSphere
(
point
(
0
,
0
,
0
),
1
.
5
)
<<
endl
;
Info
<<
" Radius = root(2) : "
<<
edgeTree
.
findSphere
(
point
(
0
,
0
,
0
),
2
)
<<
endl
;
Info
<<
" Radius = root(0.5) : "
<<
edgeTree
.
findSphere
(
point
(
1
,
0
,
0
),
0
.
5
)
<<
endl
;
Info
<<
" Radius = root(0.25) : "
<<
edgeTree
.
findSphere
(
point
(
0
,
0
,
0
.
5
),
0
.
25
)
<<
endl
;
treeBoundBox
tbb
(
point
(
0
,
0
,
0
),
point
(
0
.
1
,
0
.
1
,
0
.
1
));
Info
<<
" Box = "
<<
tbb
<<
" : "
<<
edgeTree
.
findBox
(
tbb
)
<<
endl
;
treeBoundBox
tbb1
(
point
(
0
,
0
,
0
),
point
(
1
,
1
,
0
.
1
));
Info
<<
" Box = "
<<
tbb1
<<
" : "
<<
edgeTree
.
findBox
(
tbb1
)
<<
endl
;
treeBoundBox
tbb2
(
point
(
0
.
3
,
0
,
0
),
point
(
1
,
0
.
3
,
1
));
Info
<<
" Box = "
<<
tbb2
<<
" : "
<<
edgeTree
.
findBox
(
tbb2
)
<<
endl
;
treeBoundBox
tbb3
(
point
(
-
0
.
2
,
0
.
5
,
0
),
point
(
0
.
3
,
0
.
9
,
1
));
Info
<<
" Box = "
<<
tbb3
<<
" : "
<<
edgeTree
.
findBox
(
tbb3
)
<<
endl
;
Info
<<
"End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/findTimes/Make/files
0 → 100644
View file @
55e5a777
Test-findTimes.C
EXE = $(FOAM_USER_APPBIN)/Test-findTimes
Prev
1
…
25
26
27
28
29
30
31
32
33
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