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
1089 additions
and
0 deletions
+1089
-0
OpenFOAM-v2112/applications/test/foamVersion/Test-foamVersion.C
...AM-v2112/applications/test/foamVersion/Test-foamVersion.C
+115
-0
OpenFOAM-v2112/applications/test/fstreamPointer/Make/files
OpenFOAM-v2112/applications/test/fstreamPointer/Make/files
+3
-0
OpenFOAM-v2112/applications/test/fstreamPointer/Make/options
OpenFOAM-v2112/applications/test/fstreamPointer/Make/options
+2
-0
OpenFOAM-v2112/applications/test/fstreamPointer/Test-fstreamPointer.C
...12/applications/test/fstreamPointer/Test-fstreamPointer.C
+114
-0
OpenFOAM-v2112/applications/test/fvSolutionCombine/Make/files
...FOAM-v2112/applications/test/fvSolutionCombine/Make/files
+3
-0
OpenFOAM-v2112/applications/test/fvSolutionCombine/Make/options
...AM-v2112/applications/test/fvSolutionCombine/Make/options
+5
-0
OpenFOAM-v2112/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C
...lications/test/fvSolutionCombine/Test-fvSolutionCombine.C
+227
-0
OpenFOAM-v2112/applications/test/fvc/Make/files
OpenFOAM-v2112/applications/test/fvc/Make/files
+3
-0
OpenFOAM-v2112/applications/test/fvc/Make/options
OpenFOAM-v2112/applications/test/fvc/Make/options
+7
-0
OpenFOAM-v2112/applications/test/fvc/Test-fvc.C
OpenFOAM-v2112/applications/test/fvc/Test-fvc.C
+68
-0
OpenFOAM-v2112/applications/test/fvc2D/Make/files
OpenFOAM-v2112/applications/test/fvc2D/Make/files
+3
-0
OpenFOAM-v2112/applications/test/fvc2D/Make/options
OpenFOAM-v2112/applications/test/fvc2D/Make/options
+7
-0
OpenFOAM-v2112/applications/test/fvc2D/Test-fvc2D.C
OpenFOAM-v2112/applications/test/fvc2D/Test-fvc2D.C
+76
-0
OpenFOAM-v2112/applications/test/gatherValues1/Make/files
OpenFOAM-v2112/applications/test/gatherValues1/Make/files
+3
-0
OpenFOAM-v2112/applications/test/gatherValues1/Make/options
OpenFOAM-v2112/applications/test/gatherValues1/Make/options
+2
-0
OpenFOAM-v2112/applications/test/gatherValues1/Test-gatherValues1.C
...2112/applications/test/gatherValues1/Test-gatherValues1.C
+189
-0
OpenFOAM-v2112/applications/test/globalIndex/Make/files
OpenFOAM-v2112/applications/test/globalIndex/Make/files
+3
-0
OpenFOAM-v2112/applications/test/globalIndex/Make/options
OpenFOAM-v2112/applications/test/globalIndex/Make/options
+1
-0
OpenFOAM-v2112/applications/test/globalIndex/Test-globalIndex.C
...AM-v2112/applications/test/globalIndex/Test-globalIndex.C
+255
-0
OpenFOAM-v2112/applications/test/globalMeshData/Make/files
OpenFOAM-v2112/applications/test/globalMeshData/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/foamVersion/Test-foamVersion.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-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-foamVersion
Description
Print the OpenFOAM version information.
\*---------------------------------------------------------------------------*/
#include <typeinfo>
#include "foamVersion.H"
#include "Switch.H"
#include "IOstreams.H"
using
namespace
Foam
;
// Test extraction
void
testExtraction
(
const
std
::
string
&
str
)
{
Info
<<
"Extract: "
<<
str
<<
" =>"
<<
" label: "
<<
foamVersion
::
labelByteSize
(
str
)
<<
" bytes"
<<
" scalar: "
<<
foamVersion
::
scalarByteSize
(
str
)
<<
" bytes"
<<
nl
;
}
int
main
()
{
Info
<<
"
\n
Version information (function)"
<<
nl
;
foamVersion
::
printBuildInfo
(
Info
.
stdStream
());
Info
<<
"
\n
Version information (macros)"
<<
nl
<<
"version "
<<
Foam
::
FOAMversion
<<
nl
<<
"build "
<<
Foam
::
FOAMbuild
<<
nl
<<
"buildArch "
<<
Foam
::
FOAMbuildArch
<<
nl
;
Info
<<
"
\n
Version information (namespace)"
<<
nl
<<
"patched? = "
<<
Switch
(
foamVersion
::
patched
())
<<
nl
<<
"api "
<<
foamVersion
::
api
<<
nl
<<
"patch "
<<
foamVersion
::
patch
<<
nl
<<
"version "
<<
foamVersion
::
version
<<
nl
<<
"build "
<<
foamVersion
::
build
<<
nl
<<
"buildArch "
<<
foamVersion
::
buildArch
<<
nl
;
Info
<<
"
\n
Types"
<<
nl
<<
"version "
<<
typeid
(
foamVersion
::
version
).
name
()
<<
nl
<<
"build "
<<
typeid
(
foamVersion
::
build
).
name
()
<<
nl
<<
"buildArch "
<<
typeid
(
foamVersion
::
buildArch
).
name
()
<<
nl
<<
"FOAMversion "
<<
typeid
(
Foam
::
FOAMversion
).
name
()
<<
nl
<<
"FOAMbuild "
<<
typeid
(
Foam
::
FOAMbuild
).
name
()
<<
nl
;
Info
<<
"
\n
Verify memory addresses are identical:"
<<
nl
<<
"macro "
<<
name
(
Foam
::
FOAMversion
)
<<
nl
<<
"namespace "
<<
name
(
&
(
foamVersion
::
version
[
0
]))
<<
nl
;
// Test extraction
{
Info
<<
"
\n
Test size extraction routines"
<<
nl
;
for
(
const
std
::
string
&
str
:
{
"MSB;label=32;scalar=64"
,
"LSB;label=64;scalar=32"
,
"LSB;label=;scalar=junk"
,
"LSB;label==;scalar=128"
,
""
,
"LSB;label;scalar"
,
"LSB label=32 scalar=64"
,
}
)
{
testExtraction
(
str
);
}
}
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/fstreamPointer/Make/files
0 → 100644
View file @
55e5a777
Test-fstreamPointer.C
EXE = $(FOAM_USER_APPBIN)/Test-fstreamPointer
OpenFOAM-v2112/applications/test/fstreamPointer/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = */
/* EXE_LIBS = */
OpenFOAM-v2112/applications/test/fstreamPointer/Test-fstreamPointer.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, distributed under GPL-3.0-or-later.
Application
Test-fstreamPointer
Description
Low-level fstream tests
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "refPtr.H"
#include "fstreamPointer.H"
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noBanner
();
argList
::
noParallel
();
argList
::
addOption
(
"output"
,
"file"
,
"Output file name for cat"
);
argList
::
addArgument
(
"file1"
);
argList
::
addArgument
(
"..."
);
argList
::
addArgument
(
"fileN"
);
argList
::
noMandatoryArgs
();
#include "setRootCase.H"
if
(
args
.
size
()
<=
1
)
{
InfoErr
<<
"
\n
No input files specified .. stopping
\n
"
<<
endl
;
return
0
;
}
refPtr
<
std
::
ostream
>
osRef
;
fileName
outputName
;
if
(
args
.
readIfPresent
(
"output"
,
outputName
))
{
InfoErr
<<
"output: "
<<
outputName
;
IOstreamOption
::
compressionType
comp
(
IOstreamOption
::
UNCOMPRESSED
);
if
(
outputName
.
hasExt
(
"gz"
))
{
comp
=
IOstreamOption
::
COMPRESSED
;
outputName
.
removeExt
();
InfoErr
<<
" [compress]"
;
}
InfoErr
<<
nl
;
osRef
.
reset
(
ofstreamPointer
(
outputName
,
comp
).
release
());
}
else
{
osRef
.
ref
(
std
::
cout
);
InfoErr
<<
"output: stdout"
<<
nl
;
}
auto
&
os
=
osRef
.
ref
();
for
(
label
argi
=
1
;
argi
<
args
.
size
();
++
argi
)
{
const
auto
inputName
=
args
.
get
<
fileName
>
(
argi
);
InfoErr
<<
"input: "
<<
inputName
;
ifstreamPointer
isPtr
(
inputName
);
if
(
!
isPtr
.
get
()
||
!
isPtr
->
good
())
{
InfoErr
<<
" (not good)"
<<
nl
;
continue
;
}
InfoErr
<<
nl
;
auto
&
is
=
*
isPtr
;
// Loop getting single characters
// - not efficient, but that is not the test here anyhow
char
c
;
while
(
is
.
get
(
c
))
{
os
<<
c
;
}
}
InfoErr
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/fvSolutionCombine/Make/files
0 → 100644
View file @
55e5a777
Test-fvSolutionCombine.C
EXE = $(FOAM_USER_APPBIN)/Test-fvSolutionCombine
OpenFOAM-v2112/applications/test/fvSolutionCombine/Make/options
0 → 100644
View file @
55e5a777
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-lfiniteVolume
OpenFOAM-v2112/applications/test/fvSolutionCombine/Test-fvSolutionCombine.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-2013 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
fvSolutionCombine
Description
Simple utility for combining fvSolution solution entries.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "wordRe.H"
#include "OSspecific.H"
using
namespace
Foam
;
// check for identical dictionary content, regardless of the order
bool
checkDictionaryContent
(
const
dictionary
&
dict1
,
const
dictionary
&
dict2
)
{
// trivial cases first
if
(
&
dict1
==
&
dict2
)
{
return
true
;
}
else
if
(
dict1
.
size
()
!=
dict2
.
size
())
{
return
false
;
}
for
(
const
entry
&
entry1
:
dict1
)
{
const
entry
*
eptr
=
dict2
.
findEntry
(
entry1
.
keyword
(),
keyType
::
LITERAL
);
if
(
!
eptr
)
{
return
false
;
}
const
entry
&
entry2
=
*
eptr
;
bool
ok
=
false
;
if
(
entry1
.
isDict
())
{
if
(
entry2
.
isDict
())
{
ok
=
checkDictionaryContent
(
entry1
.
dict
(),
entry2
.
dict
());
}
}
else
{
ok
=
(
entry1
==
entry2
);
}
if
(
!
ok
)
{
return
false
;
}
}
return
true
;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noParallel
();
argList
::
addBoolOption
(
"rewrite"
);
argList
::
addBoolOption
(
"show"
);
argList
args
(
argc
,
argv
);
Time
runTime
(
args
.
rootPath
(),
args
.
caseName
());
const
word
dictName
(
"fvSolution"
);
bool
optRewrite
=
args
.
found
(
"rewrite"
);
bool
optShow
=
args
.
found
(
"show"
);
IOdictionary
solutionDict
(
IOobject
(
dictName
,
runTime
.
system
(),
runTime
,
IOobject
::
MUST_READ_IF_MODIFIED
,
IOobject
::
NO_WRITE
,
false
)
);
if
(
!
solutionDict
.
found
(
"solvers"
))
{
Info
<<
"no solvers entry found in : "
<<
dictName
<<
endl
;
return
2
;
}
if
(
optRewrite
&&
solutionDict
.
instance
()
!=
runTime
.
system
())
{
Info
<<
"instance is not "
<<
runTime
.
system
()
<<
"- disabling rewrite for this file"
<<
nl
;
optRewrite
=
false
;
}
dictionary
&
solverDict
=
solutionDict
.
subDict
(
"solvers"
);
wordList
names
=
solverDict
.
toc
();
wordList
oldNames
=
names
;
bool
changed
=
false
;
for
(
label
orig
=
0
;
orig
<
names
.
size
()
-
1
;
++
orig
)
{
// Skip patterns or entries that have already been done
if
(
names
[
orig
].
empty
()
||
regExp
::
is_meta
(
names
[
orig
]))
{
continue
;
}
const
dictionary
&
dict1
=
solverDict
.
subDict
(
names
[
orig
]);
for
(
label
check
=
orig
+
1
;
check
<
names
.
size
();
++
check
)
{
// Skip patterns or entries that have already been done
if
(
names
[
check
].
empty
()
||
regExp
::
is_meta
(
names
[
check
]))
{
continue
;
}
const
dictionary
&
dict2
=
solverDict
.
subDict
(
names
[
check
]);
// Check for identical content
if
(
checkDictionaryContent
(
dict1
,
dict2
))
{
names
[
orig
]
+=
"|"
+
names
[
check
];
names
[
check
].
clear
();
changed
=
true
;
}
}
}
if
(
changed
)
{
forAll
(
names
,
nameI
)
{
if
(
names
[
nameI
].
empty
())
{
solverDict
.
remove
(
oldNames
[
nameI
]);
Info
<<
" #remove "
<<
oldNames
[
nameI
];
}
else
{
Info
<<
" "
<<
oldNames
[
nameI
];
if
(
names
[
nameI
]
!=
oldNames
[
nameI
])
{
// make "(abc|def)" pattern
keyType
renamed
(
"("
+
names
[
nameI
]
+
")"
,
keyType
::
REGEX
);
solverDict
.
changeKeyword
(
oldNames
[
nameI
],
renamed
);
Info
<<
" -> "
<<
renamed
;
}
}
Info
<<
endl
;
}
if
(
optRewrite
)
{
mvBak
(
solutionDict
.
objectPath
(),
"orig"
);
Info
<<
"Backup to .orig"
<<
nl
<<
"Writing "
<<
solutionDict
.
objectPath
()
<<
nl
<<
endl
;
solutionDict
.
regIOobject
::
write
();
}
else
if
(
optShow
)
{
IOobject
::
writeDivider
(
Info
);
solutionDict
.
dictionary
::
write
(
Info
,
false
);
}
else
{
Info
<<
"
\n
File not rewritten"
<<
endl
;
}
}
else
{
Info
<<
"no changes"
<<
endl
;
}
Info
<<
"Done
\n
"
<<
endl
;
return
changed
?
0
:
1
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/fvc/Make/files
0 → 100644
View file @
55e5a777
Test-fvc.C
EXE = $(FOAM_USER_APPBIN)/Test-fvc
OpenFOAM-v2112/applications/test/fvc/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/fvc/Test-fvc.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-2013 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/>.
Application
test
Description
Finite volume method test code.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int
main
(
int
argc
,
char
*
argv
[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
volScalarField
fx
(
pow
(
mesh
.
C
().
component
(
vector
::
X
),
1
));
fx
.
write
();
volScalarField
gradx4
(
fvc
::
grad
(
fx
)().
component
(
vector
::
X
));
gradx4
.
write
();
volVectorField
curlC
(
fvc
::
curl
(
1
.
0
*
mesh
.
C
()));
curlC
.
write
();
surfaceScalarField
xf
(
mesh
.
Cf
().
component
(
vector
::
X
));
surfaceScalarField
xf4
(
pow
(
xf
,
4
));
for
(
int
i
=
1
;
i
<
xf4
.
size
()
-
1
;
i
++
)
{
scalar
gradx4a
=
(
xf4
[
i
]
-
xf4
[
i
-
1
])
/
(
xf
[
i
]
-
xf
[
i
-
1
]);
Info
<<
(
gradx4a
-
gradx4
[
i
])
/
gradx4a
<<
endl
;
}
Info
<<
"End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/fvc2D/Make/files
0 → 100644
View file @
55e5a777
Test-fvc2D.C
EXE = $(FOAM_USER_APPBIN)/Test-fvc2D
OpenFOAM-v2112/applications/test/fvc2D/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/fvc2D/Test-fvc2D.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
Description
Finite volume method test code for 2-D space.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "vector2D.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
typedef
GeometricField
<
vector2D
,
fvPatchField
,
volMesh
>
volVector2DField
;
defineTemplate2TypeNameAndDebug
(
volVector2DField
::
Internal
,
0
);
defineTemplateTypeNameAndDebug
(
volVector2DField
,
0
);
typedef
fvPatchField
<
vector2D
>
fvPatchVector2DField
;
makeFvPatchField
(
fvPatchVector2DField
)
}
int
main
(
int
argc
,
char
*
argv
[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
GeometricField
<
vector2D
,
fvPatchField
,
volMesh
>
fld
(
IOobject
(
"U"
,
runTime
.
timeName
(),
mesh
,
IOobject
::
MUST_READ
,
IOobject
::
AUTO_WRITE
),
mesh
);
Info
<<
"End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/gatherValues1/Make/files
0 → 100644
View file @
55e5a777
Test-gatherValues1.C
EXE = $(FOAM_USER_APPBIN)/Test-gatherValues1
OpenFOAM-v2112/applications/test/gatherValues1/Make/options
0 → 100644
View file @
55e5a777
/* EXE_INC = */
/* EXE_LIBS = */
OpenFOAM-v2112/applications/test/gatherValues1/Test-gatherValues1.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) 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-gatherValues1
Description
Test list gather functionality
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "IPstream.H"
#include "OPstream.H"
#include "vector.H"
#include "IOstreams.H"
#include "Pstream.H"
#include "globalIndex.H"
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noCheckProcessorDirectories
();
#include "setRootCase.H"
const
labelList
localValues
(
identity
(
2
*
(
Pstream
::
myProcNo
()
+
1
),
-
5
*
Pstream
::
myProcNo
())
);
// Test resize
{
globalIndex
globIdx
(
localValues
.
size
());
Info
<<
"globIdx = "
<<
flatOutput
(
globIdx
.
offsets
())
<<
nl
;
globIdx
.
setLocalSize
(
4
,
0
);
Info
<<
"globIdx = "
<<
flatOutput
(
globIdx
.
offsets
())
<<
nl
;
globIdx
.
setLocalSize
(
3
,
0
);
Info
<<
"globIdx = "
<<
flatOutput
(
globIdx
.
offsets
())
<<
nl
;
}
// Gather all values
{
const
auto
&
sendData
=
localValues
;
// One-sided sizing! master only
const
globalIndex
allProcAddr
(
UPstream
::
listGatherValues
<
label
>
(
sendData
.
size
()),
globalIndex
::
SIZES
);
Pout
<<
"listGather sizes: "
<<
flatOutput
(
allProcAddr
.
sizes
())
<<
nl
;
// Collect all values
labelList
allValues
(
allProcAddr
.
mpiGather
(
sendData
)
);
Pout
<<
"all-data: "
<<
allValues
<<
endl
;
}
{
const
labelList
::
subList
&
sendData
=
(
Pstream
::
master
()
?
SubList
<
label
>
(
localValues
,
0
)
// exclude
:
SubList
<
label
>
(
localValues
)
);
const
labelList
sendSizes
(
UPstream
::
listGatherValues
<
label
>
(
sendData
.
size
())
);
const
label
sendSize
(
UPstream
::
listScatterValues
<
label
>
(
sendSizes
)
);
const
globalIndex
subProcAddr
(
sendSizes
,
globalIndex
::
SIZES
);
Pout
<<
"listGather "
<<
localValues
.
size
()
<<
" = "
<<
flatOutput
(
sendSizes
)
<<
" offsets "
<<
flatOutput
(
subProcAddr
.
offsets
())
<<
nl
;
label
newLocalValue
=
5
+
UPstream
::
listScatterValues
(
sendSizes
);
Pout
<<
"listScattered: "
<<
newLocalValue
<<
nl
;
// Can also scatter a longer list
Pout
<<
"listScatter off "
<<
UPstream
::
listScatterValues
(
subProcAddr
.
offsets
())
<<
nl
;
Pout
<<
endl
<<
"local list ["
<<
Pstream
::
myProcNo
()
<<
"] "
<<
flatOutput
(
localValues
)
<<
nl
;
Pout
<<
endl
<<
"local send ["
<<
Pstream
::
myProcNo
()
<<
"] "
<<
sendSize
<<
nl
;
// Collect all off-processor values
labelList
allValues
(
subProcAddr
.
mpiGather
(
sendData
)
);
Pout
<<
"off-proc: "
<<
allValues
<<
endl
;
if
(
Pstream
::
master
())
{
Info
<<
"master: "
<<
flatOutput
(
localValues
)
<<
nl
;
label
proci
=
0
;
for
(
const
labelRange
&
range
:
subProcAddr
)
{
Info
<<
proci
<<
": "
<<
flatOutput
(
allValues
.
slice
(
range
))
<<
nl
;
++
proci
;
}
Info
<<
nl
<<
"verify ranges"
<<
nl
;
{
globalIndex
glob
;
Info
<<
"empty:"
<<
nl
;
for
(
const
labelRange
&
range
:
glob
)
{
Info
<<
" range: "
<<
range
<<
endl
;
}
}
{
globalIndex
glob
(
labelList
(
Foam
::
one
{},
0
),
globalIndex
::
OFFSETS
);
Info
<<
"degenerate:"
<<
nl
;
for
(
const
labelRange
&
range
:
glob
)
{
Info
<<
" range: "
<<
range
<<
endl
;
}
}
{
globalIndex
glob
(
labelList
(
Foam
::
one
{},
0
),
globalIndex
::
SIZES
);
Info
<<
"single:"
<<
nl
;
for
(
const
labelRange
&
range
:
glob
)
{
Info
<<
" range: "
<<
range
<<
endl
;
}
}
}
}
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/globalIndex/Make/files
0 → 100644
View file @
55e5a777
Test-globalIndex.C
EXE = $(FOAM_USER_APPBIN)/Test-globalIndex
OpenFOAM-v2112/applications/test/globalIndex/Make/options
0 → 100644
View file @
55e5a777
EXE_INC = /* -DFULLDEBUG -g -O0 */
OpenFOAM-v2112/applications/test/globalIndex/Test-globalIndex.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) 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
globalIndexTest
Description
Simple tests for the globalIndex class.
\*---------------------------------------------------------------------------*/
#include "globalIndex.H"
#include "globalMeshData.H"
#include "argList.H"
#include "Time.H"
#include "polyMesh.H"
#include "IndirectList.H"
#include "IOstreams.H"
#include "Random.H"
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createPolyMesh.H"
// Global numbering of cells (proc0 elements first, then proc1, etc.)
globalIndex
globalNumbering
(
mesh
.
nCells
());
if
(
globalNumbering
.
localSize
()
!=
mesh
.
nCells
())
{
FatalErrorInFunction
<<
"Problem."
<<
abort
(
FatalError
);
}
if
(
!
Pstream
::
parRun
())
{
WarningInFunction
<<
"globalIndex class is only useful in parallel code."
<<
endl
;
}
// convert from local to global and back.
for
(
label
celli
=
0
;
celli
<
mesh
.
nCells
();
celli
++
)
{
// to global index
label
globalCelli
=
globalNumbering
.
toGlobal
(
celli
);
// and back
label
proci
=
globalNumbering
.
whichProcID
(
globalCelli
);
label
localCelli
=
globalNumbering
.
toLocal
(
globalCelli
);
if
(
proci
!=
Pstream
::
myProcNo
()
||
localCelli
!=
celli
)
{
FatalErrorInFunction
<<
"Problem. celli:"
<<
celli
<<
" localCelli:"
<<
localCelli
<<
" proci:"
<<
proci
<<
abort
(
FatalError
);
}
if
(
!
globalNumbering
.
isLocal
(
globalCelli
))
{
FatalErrorInFunction
<<
"Problem. celli:"
<<
celli
<<
" globalCelli:"
<<
globalCelli
<<
" not local"
<<
abort
(
FatalError
);
}
}
Info
<<
"Max number of cells: "
<<
globalNumbering
.
maxSize
()
<<
nl
;
Pout
<<
"nCells: "
<<
globalNumbering
.
localSize
()
<<
" Max off-processor: "
<<
globalNumbering
.
maxNonLocalSize
()
<<
nl
;
// Try whichProcID on a few borderline cases.
if
(
mesh
.
nCells
()
<
1
)
{
FatalErrorInFunction
<<
"Test needs to be run on a case with at least one"
<<
" cell per processor."
<<
abort
(
FatalError
);
}
if
(
Pstream
::
myProcNo
()
>
0
)
{
// We already checked that toGlobal(0) maps back correctly to myProcNo
// so now check that the index one before maps to the previous processor
label
prevProcCelli
=
globalNumbering
.
toGlobal
(
0
)
-
1
;
label
proci
=
globalNumbering
.
whichProcID
(
prevProcCelli
);
if
(
proci
!=
Pstream
::
myProcNo
()
-
1
)
{
FatalErrorInFunction
<<
"Problem. global:"
<<
prevProcCelli
<<
" expected on processor:"
<<
Pstream
::
myProcNo
()
-
1
<<
" but is calculated to be on proci:"
<<
proci
<<
abort
(
FatalError
);
}
if
(
globalNumbering
.
isLocal
(
prevProcCelli
))
{
FatalErrorInFunction
<<
"Problem. globalCelli:"
<<
prevProcCelli
<<
" calculated as local"
<<
abort
(
FatalError
);
}
if
(
!
globalNumbering
.
isLocal
(
proci
,
prevProcCelli
))
{
FatalErrorInFunction
<<
"Problem. globalCelli:"
<<
prevProcCelli
<<
" not calculated as local on processor:"
<<
proci
<<
abort
(
FatalError
);
}
}
if
(
Pstream
::
myProcNo
()
<
Pstream
::
nProcs
()
-
1
)
{
label
nextProcCelli
=
globalNumbering
.
toGlobal
(
mesh
.
nCells
()
-
1
)
+
1
;
label
proci
=
globalNumbering
.
whichProcID
(
nextProcCelli
);
if
(
proci
!=
Pstream
::
myProcNo
()
+
1
)
{
FatalErrorInFunction
<<
"Problem. global:"
<<
nextProcCelli
<<
" expected on processor:"
<<
Pstream
::
myProcNo
()
+
1
<<
" but is calculated to be on proci:"
<<
proci
<<
abort
(
FatalError
);
}
if
(
globalNumbering
.
isLocal
(
nextProcCelli
))
{
FatalErrorInFunction
<<
"Problem. globalCelli:"
<<
nextProcCelli
<<
" calculated as local"
<<
abort
(
FatalError
);
}
if
(
!
globalNumbering
.
isLocal
(
proci
,
nextProcCelli
))
{
FatalErrorInFunction
<<
"Problem. globalCelli:"
<<
nextProcCelli
<<
" not calculated as local on processor:"
<<
proci
<<
abort
(
FatalError
);
}
}
// Get a few cell indices
const
label
nTotalCells
=
globalNumbering
.
size
();
Random
rndGen
(
Pstream
::
myProcNo
());
DynamicList
<
label
>
globalIDs
;
for
(
label
i
=
0
;
i
<
100
;
i
++
)
{
globalIDs
.
append
(
rndGen
.
position
(
label
(
0
),
nTotalCells
-
1
));
}
// Get the cell centres at those cell indices
List
<
point
>
ccs
;
globalNumbering
.
get
(
ccs
,
globalIDs
,
[
&
mesh
](
List
<
point
>&
ccs
,
const
labelUList
&
localIds
)
{
ccs
=
UIndirectList
<
point
>
(
mesh
.
cellCentres
(),
localIds
);
}
);
// Do the brute-force method as well : collect all cell centres on all
// processors
pointField
allCcs
(
globalNumbering
.
size
());
globalNumbering
.
gather
(
Pstream
::
worldComm
,
Pstream
::
procID
(
Pstream
::
worldComm
),
mesh
.
cellCentres
(),
allCcs
);
Pstream
::
scatter
(
allCcs
);
// Compare
forAll
(
ccs
,
i
)
{
const
point
&
cc
=
ccs
[
i
];
const
point
&
allCc
=
allCcs
[
globalIDs
[
i
]];
if
(
cc
!=
allCc
)
{
FatalErrorInFunction
<<
"Problem cc:"
<<
cc
<<
" allCc:"
<<
allCc
<<
exit
(
FatalError
);
}
}
Info
<<
"Gather indirect list of boundary points (patch = 0)
\n
"
;
{
const
polyPatch
&
pp
=
mesh
.
boundaryMesh
()[
0
];
// Map mesh point index to local (compact) point index
labelList
pointToGlobal
;
labelList
uniqueMeshPointLabels
;
autoPtr
<
globalIndex
>
globalPointsPtr
=
mesh
.
globalData
().
mergePoints
(
pp
.
meshPoints
(),
pp
.
meshPointMap
(),
pointToGlobal
,
uniqueMeshPointLabels
);
Info
<<
"local-sizes: "
<<
globalPointsPtr
().
sizes
()
<<
nl
;
UIndirectList
<
point
>
procPoints
(
mesh
.
points
(),
uniqueMeshPointLabels
);
pointField
patchPoints
;
globalPointsPtr
().
gather
(
procPoints
,
patchPoints
);
Info
<<
"gathered point field = "
<<
patchPoints
.
size
()
<<
" points
\n
"
;
}
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
OpenFOAM-v2112/applications/test/globalMeshData/Make/files
0 → 100644
View file @
55e5a777
Test-globalMeshData.C
EXE = $(FOAM_USER_APPBIN)/Test-globalMeshData
Prev
1
…
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