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
Development
openfoam
Commits
418ebe4a
Commit
418ebe4a
authored
May 19, 2017
by
Mark Olesen
Browse files
ENH: replace writeFuncs in setSet with foamVtk library utilities
parent
c685f70c
Changes
11
Hide whitespace changes
Inline
Side-by-side
applications/utilities/mesh/manipulation/setSet/Make/files
View file @
418ebe4a
writePointSet.C
writeFuns.C
writePatch.C
setSet.C
EXE = $(FOAM_APPBIN)/setSet
applications/utilities/mesh/manipulation/setSet/setSet.C
View file @
418ebe4a
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -44,8 +44,9 @@ Description
#include "OFstream.H"
#include "IFstream.H"
#include "demandDrivenData.H"
#include "writePatch.H"
#include "writePointSet.H"
#include "foamVtkWriteCellSetFaces.H"
#include "foamVtkWriteFaceSet.H"
#include "foamVtkWritePointSet.H"
#include "IOobjectList.H"
#include "cellZoneSet.H"
#include "faceZoneSet.H"
...
...
@@ -81,93 +82,28 @@ void writeVTK
if
(
isA
<
faceSet
>
(
currentSet
))
{
// Faces of set with OpenFOAM faceID as value
faceList
setFaces
(
currentSet
.
size
());
labelList
faceValues
(
currentSet
.
size
());
label
setFacei
=
0
;
forAllConstIter
(
topoSet
,
currentSet
,
iter
)
{
setFaces
[
setFacei
]
=
mesh
.
faces
()[
iter
.
key
()];
faceValues
[
setFacei
]
=
iter
.
key
();
setFacei
++
;
}
primitiveFacePatch
fp
(
setFaces
,
mesh
.
points
());
writePatch
foamVtkOutput
::
writeFaceSet
(
true
,
currentSet
.
name
(),
fp
,
"faceID"
,
faceValues
,
mesh
,
currentSet
,
mesh
.
time
().
path
()
/
vtkName
);
}
else
if
(
isA
<
cellSet
>
(
currentSet
))
{
// External faces of cellset with OpenFOAM cellID as value
Map
<
label
>
cellFaces
(
currentSet
.
size
());
forAllConstIter
(
cellSet
,
currentSet
,
iter
)
{
label
celli
=
iter
.
key
();
const
cell
&
cFaces
=
mesh
.
cells
()[
celli
];
forAll
(
cFaces
,
i
)
{
label
facei
=
cFaces
[
i
];
if
(
mesh
.
isInternalFace
(
facei
))
{
label
otherCelli
=
mesh
.
faceOwner
()[
facei
];
if
(
otherCelli
==
celli
)
{
otherCelli
=
mesh
.
faceNeighbour
()[
facei
];
}
if
(
!
currentSet
.
found
(
otherCelli
))
{
cellFaces
.
insert
(
facei
,
celli
);
}
}
else
{
cellFaces
.
insert
(
facei
,
celli
);
}
}
}
faceList
setFaces
(
cellFaces
.
size
());
labelList
faceValues
(
cellFaces
.
size
());
label
setFacei
=
0
;
forAllConstIter
(
Map
<
label
>
,
cellFaces
,
iter
)
{
setFaces
[
setFacei
]
=
mesh
.
faces
()[
iter
.
key
()];
faceValues
[
setFacei
]
=
iter
();
// Cell ID
setFacei
++
;
}
primitiveFacePatch
fp
(
setFaces
,
mesh
.
points
());
writePatch
foamVtkOutput
::
writeCellSetFaces
(
true
,
currentSet
.
name
(),
fp
,
"cellID"
,
faceValues
,
mesh
,
currentSet
,
mesh
.
time
().
path
()
/
vtkName
);
}
else
if
(
isA
<
pointSet
>
(
currentSet
))
{
writePointSet
foamVtkOutput
::
writePointSet
(
true
,
mesh
,
...
...
applications/utilities/mesh/manipulation/setSet/writeFuns.C
deleted
100644 → 0
View file @
c685f70c
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "writeFuns.H"
#include "endian.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void
Foam
::
writeFuns
::
swapWord
(
int32_t
&
word32
)
{
char
*
mem
=
reinterpret_cast
<
char
*>
(
&
word32
);
char
a
=
mem
[
0
];
mem
[
0
]
=
mem
[
3
];
mem
[
3
]
=
a
;
a
=
mem
[
1
];
mem
[
1
]
=
mem
[
2
];
mem
[
2
]
=
a
;
}
void
Foam
::
writeFuns
::
swapWords
(
const
label
nWords
,
int32_t
*
words32
)
{
for
(
label
i
=
0
;
i
<
nWords
;
i
++
)
{
swapWord
(
words32
[
i
]);
}
}
void
Foam
::
writeFuns
::
write
(
std
::
ostream
&
os
,
const
bool
binary
,
List
<
floatScalar
>&
fField
)
{
if
(
binary
)
{
#ifdef WM_LITTLE_ENDIAN
swapWords
(
fField
.
size
(),
reinterpret_cast
<
int32_t
*>
(
fField
.
begin
()));
#endif
os
.
write
(
reinterpret_cast
<
char
*>
(
fField
.
begin
()),
fField
.
size
()
*
sizeof
(
float
)
);
os
<<
std
::
endl
;
}
else
{
forAll
(
fField
,
i
)
{
os
<<
fField
[
i
]
<<
' '
;
if
(
i
>
0
&&
(
i
%
10
)
==
0
)
{
os
<<
std
::
endl
;
}
}
os
<<
std
::
endl
;
}
}
void
Foam
::
writeFuns
::
write
(
std
::
ostream
&
os
,
const
bool
binary
,
DynamicList
<
floatScalar
>&
fField
)
{
List
<
floatScalar
>&
fld
=
fField
.
shrink
();
write
(
os
,
binary
,
fld
);
}
void
Foam
::
writeFuns
::
write
(
std
::
ostream
&
os
,
const
bool
binary
,
labelList
&
elems
)
{
if
(
binary
)
{
#ifdef WM_LITTLE_ENDIAN
swapWords
(
(
sizeof
(
label
)
/
4
)
*
elems
.
size
(),
reinterpret_cast
<
int32_t
*>
(
elems
.
begin
())
);
#endif
os
.
write
(
reinterpret_cast
<
char
*>
(
elems
.
begin
()),
elems
.
size
()
*
sizeof
(
label
)
);
os
<<
std
::
endl
;
}
else
{
forAll
(
elems
,
i
)
{
os
<<
elems
[
i
]
<<
' '
;
if
(
i
>
0
&&
(
i
%
10
)
==
0
)
{
os
<<
std
::
endl
;
}
}
os
<<
std
::
endl
;
}
}
void
Foam
::
writeFuns
::
write
(
std
::
ostream
&
os
,
const
bool
binary
,
DynamicList
<
label
>&
elems
)
{
labelList
&
fld
=
elems
.
shrink
();
write
(
os
,
binary
,
fld
);
}
void
Foam
::
writeFuns
::
insert
(
const
point
&
pt
,
DynamicList
<
floatScalar
>&
dest
)
{
dest
.
append
(
float
(
pt
.
x
()));
dest
.
append
(
float
(
pt
.
y
()));
dest
.
append
(
float
(
pt
.
z
()));
}
void
Foam
::
writeFuns
::
insert
(
const
labelList
&
source
,
DynamicList
<
label
>&
dest
)
{
forAll
(
source
,
i
)
{
dest
.
append
(
source
[
i
]);
}
}
void
Foam
::
writeFuns
::
insert
(
const
List
<
scalar
>&
source
,
DynamicList
<
floatScalar
>&
dest
)
{
forAll
(
source
,
i
)
{
dest
.
append
(
float
(
source
[
i
]));
}
}
void
Foam
::
writeFuns
::
insert
(
const
labelList
&
map
,
const
List
<
scalar
>&
source
,
DynamicList
<
floatScalar
>&
dest
)
{
forAll
(
map
,
i
)
{
dest
.
append
(
float
(
source
[
map
[
i
]]));
}
}
void
Foam
::
writeFuns
::
insert
(
const
List
<
point
>&
source
,
DynamicList
<
floatScalar
>&
dest
)
{
forAll
(
source
,
i
)
{
insert
(
source
[
i
],
dest
);
}
}
void
Foam
::
writeFuns
::
insert
(
const
labelList
&
map
,
const
List
<
point
>&
source
,
DynamicList
<
floatScalar
>&
dest
)
{
forAll
(
map
,
i
)
{
insert
(
source
[
map
[
i
]],
dest
);
}
}
// ************************************************************************* //
applications/utilities/mesh/manipulation/setSet/writeFuns.H
deleted
100644 → 0
View file @
c685f70c
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
Class
Foam::writeFuns
Description
Various functions for collecting and writing binary data.
The LITTLE_ENDIAN is based on 32bit words.
It is not clear how 64bit labels should be handled, currently they are
split into two 32bit words and swapWord applied to these two.
writeFuns should be a namespace rather than a class.
SourceFiles
writeFuns.C
\*---------------------------------------------------------------------------*/
#ifndef writeFuns_H
#define writeFuns_H
#include "labelList.H"
#include "floatScalar.H"
#include "OFstream.H"
#include "DynamicList.H"
#include "point.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
/*---------------------------------------------------------------------------*\
Class writeFuns Declaration
\*---------------------------------------------------------------------------*/
class
writeFuns
{
// Private member functions
//- Swap halves of word
static
void
swapWord
(
int32_t
&
word32
);
//- Swap halves of word
static
void
swapWords
(
const
label
nWords
,
int32_t
*
words32
);
public:
//- Write floats ascii or binary.
// If binary optionally in-place swaps argument
static
void
write
(
std
::
ostream
&
,
const
bool
,
DynamicList
<
floatScalar
>&
);
//- Write labels ascii or binary.
// If binary optionally in-place swaps argument
static
void
write
(
std
::
ostream
&
,
const
bool
,
DynamicList
<
label
>&
);
//- Write floats ascii or binary.
// If binary optionally in-place swaps argument
static
void
write
(
std
::
ostream
&
,
const
bool
,
List
<
floatScalar
>&
);
//- Write labels ascii or binary.
// If binary optionally in-place swaps argument
static
void
write
(
std
::
ostream
&
,
const
bool
,
labelList
&
);
//- Append point to given DynamicList
static
void
insert
(
const
point
&
,
DynamicList
<
floatScalar
>&
dest
);
//- Append elements of labelList to given DynamicList
static
void
insert
(
const
labelList
&
,
DynamicList
<
label
>&
);
//- Append elements of scalarList to given DynamicList
static
void
insert
(
const
List
<
scalar
>&
,
DynamicList
<
floatScalar
>&
);
//- Append elements of scalarList to given DynamicList using map
static
void
insert
(
const
labelList
&
map
,
const
List
<
scalar
>&
source
,
DynamicList
<
floatScalar
>&
);
//- Append points to given DynamicList of floats
static
void
insert
(
const
List
<
point
>&
source
,
DynamicList
<
floatScalar
>&
);
//- Append points to given DynamicList of floats using map
static
void
insert
(
const
labelList
&
map
,
const
List
<
point
>&
source
,
DynamicList
<
floatScalar
>&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
src/meshTools/Make/files
View file @
418ebe4a
...
...
@@ -266,6 +266,10 @@ meshStructure/meshStructure.C
meshStructure/topoDistanceData.C
meshStructure/pointTopoDistanceData.C
output/foamVtkWriteFaceSet.C
output/foamVtkWritePointSet.C
output/foamVtkWriteCellSetFaces.C
regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C
regionCoupled/patches/regionCoupledPolyPatch/regionCoupledPolyPatch.C
regionCoupled/patches/regionCoupledPolyPatch/regionCoupledWallPolyPatch.C
...
...
src/meshTools/output/foamVtkWriteCellSetFaces.C
0 → 100644
View file @
418ebe4a
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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/>.
\*---------------------------------------------------------------------------*/
#include "foamVtkWriteCellSetFaces.H"
#include "foamVtkOutputOptions.H"
#include "OFstream.H"
#include "primitiveMesh.H"
#include "cellSet.H"
#include "uindirectPrimitivePatch.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void
Foam
::
foamVtkOutput
::
writeCellSetFaces
(
const
bool
binary
,
const
primitiveMesh
&
mesh
,
const
cellSet
&
set
,
const
fileName
&
fileName
)
{
std
::
ofstream
os
(
fileName
.
c_str
());
autoPtr
<
foamVtkOutput
::
formatter
>
format
=
foamVtkOutput
::
outputOptions
().
legacy
(
true
).
ascii
(
!
binary
).
newFormatter
(
os
);
foamVtkOutput
::
legacy
::
fileHeader
(
format
(),
set
.
name
())
<<
"DATASET POLYDATA"
<<
nl
;
//-------------------------------------------------------------------------
// External faces of cellset with OpenFOAM cellID as value
Map
<
label
>
cellFaces
(
2
*
set
.
size
());
forAllConstIters
(
set
,
iter
)
{
label
celli
=
iter
.
key
();
const
cell
&
cFaces
=
mesh
.
cells
()[
celli
];
forAll
(
cFaces
,
i
)
{
label
facei
=
cFaces
[
i
];
if
(
mesh
.
isInternalFace
(
facei
))
{
label
otherCelli
=
mesh
.
faceOwner
()[
facei
];
if
(
otherCelli
==
celli
)
{
otherCelli
=
mesh
.
faceNeighbour
()[
facei
];
}
if
(
!
set
.
found
(
otherCelli
))
{
cellFaces
.
insert
(
facei
,
celli
);
}
}
else
{
cellFaces
.
insert
(
facei
,
celli
);
}
}
}
labelList
faceLabels
=
cellFaces
.
sortedToc
();
labelList
faceValues
(
cellFaces
.
size
());
forAll
(
faceLabels
,
facei
)
{
faceValues
[
facei
]
=
cellFaces
[
faceLabels
[
facei
]];
// Cell ID
}
uindirectPrimitivePatch
pp
(
UIndirectList
<
face
>
(
mesh
.
faces
(),
faceLabels
),
mesh
.
points
()
);
//-------------------------------------------------------------------------
// Write points and faces as polygons
os
<<
"POINTS "
<<
pp
.
nPoints
()
<<
" float"
<<
nl
;
foamVtkOutput
::
writeList
(
format
(),
pp
.
localPoints
());
format
().
flush
();
label
count
=
pp
.
size
();
forAll
(
pp
,
facei
)
{