Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kirill Terekhov
INMOST
Commits
75b7cb29
Commit
75b7cb29
authored
Oct 24, 2016
by
chrmaier
Browse files
Added Set_file_option VTK_OUTPUT_FACES
parent
aa2a4e83
Changes
2
Hide whitespace changes
Inline
Side-by-side
Source/Headers/inmost_mesh.h
View file @
75b7cb29
...
...
@@ -2964,6 +2964,7 @@ namespace INMOST
/// Set file option.
/// Current availible file options:
/// - "VTK_GRID_DIMS" - set "2" for two-dimensional vtk grids, "3" for three-dimensional vtk grids
/// - "VTK_OUTPUT_FACES" - set "1" for vtk output of values on faces
/// - "VERBOSITY" - set "2" for progress messages, "1" for reports, "0" for silence
/// - "ECL_SPLIT_GLUED" - set "TRUE" to triangulate faces of the blocks that degenerate on three pillars.
///
...
...
Source/IO/mesh_vtk_file.cpp
View file @
75b7cb29
...
...
@@ -107,6 +107,16 @@ namespace INMOST
fprintf
(
f
,
"file is written by INMOST
\n
"
);
fprintf
(
f
,
"ASCII
\n
"
);
fprintf
(
f
,
"DATASET UNSTRUCTURED_GRID
\n
"
);
bool
output_faces
=
false
;
for
(
INMOST_DATA_ENUM_TYPE
k
=
0
;
k
<
file_options
.
size
();
++
k
)
{
if
(
file_options
[
k
].
first
==
"VTK_OUTPUT_FACES"
)
{
output_faces
=
true
;
}
}
//ReorderEmpty(CELL | NODE);
Tag
set_id
=
CreateTag
(
"TEMPORARY_ELEMENT_ID"
,
DATA_INTEGER
,
CELL
|
FACE
|
NODE
,
NONE
,
1
);
Storage
::
integer
cur_num
=
0
;
...
...
@@ -114,7 +124,9 @@ namespace INMOST
cur_num
=
0
;
for
(
Mesh
::
iteratorCell
it
=
BeginCell
();
it
!=
EndCell
();
++
it
)
it
->
IntegerDF
(
set_id
)
=
cur_num
++
;
cur_num
=
0
;
for
(
Mesh
::
iteratorFace
it
=
BeginFace
();
it
!=
EndFace
();
++
it
)
it
->
IntegerDF
(
set_id
)
=
cur_num
++
;
if
(
output_faces
)
for
(
Mesh
::
iteratorFace
it
=
BeginFace
();
it
!=
EndFace
();
++
it
)
it
->
IntegerDF
(
set_id
)
=
cur_num
++
;
fprintf
(
f
,
"POINTS %u double
\n
"
,
NumberOfNodes
());
for
(
Mesh
::
iteratorNode
it
=
BeginNode
();
it
!=
EndNode
();
it
++
)
{
...
...
@@ -214,34 +226,40 @@ safe_output:
default:
printf
(
"This should not happen %s
\n
"
,
Element
::
GeometricTypeName
(
it
->
GetGeometricType
()));
}
}
for
(
Mesh
::
iteratorFace
it
=
BeginFace
();
it
!=
EndFace
();
it
++
)
if
(
output_faces
)
{
switch
(
it
->
GetGeometricType
())
{
case
Element
::
Line
:
{
ElementArray
<
Node
>
nodes
=
it
->
getNodes
();
values
.
push_back
(
static_cast
<
integer
>
(
nodes
.
size
()));
for
(
ElementArray
<
Node
>::
iterator
jt
=
nodes
.
begin
();
jt
!=
nodes
.
end
();
jt
++
)
values
.
push_back
(
jt
->
IntegerDF
(
set_id
));
break
;
}
case
Element
::
Tri
:
case
Element
::
Quad
:
case
Element
::
MultiLine
:
case
Element
::
Polygon
:
for
(
Mesh
::
iteratorFace
it
=
BeginFace
();
it
!=
EndFace
();
it
++
)
{
ElementArray
<
Node
>
nodes
=
it
->
getNodes
();
values
.
push_back
(
static_cast
<
integer
>
(
nodes
.
size
()));
for
(
ElementArray
<
Node
>::
iterator
jt
=
nodes
.
begin
();
jt
!=
nodes
.
end
();
jt
++
)
values
.
push_back
(
jt
->
IntegerDF
(
set_id
));
break
;
}
default:
printf
(
"This should not happen %s
\n
"
,
Element
::
GeometricTypeName
(
it
->
GetGeometricType
()));
switch
(
it
->
GetGeometricType
())
{
case
Element
::
Line
:
{
ElementArray
<
Node
>
nodes
=
it
->
getNodes
();
values
.
push_back
(
static_cast
<
integer
>
(
nodes
.
size
()));
for
(
ElementArray
<
Node
>::
iterator
jt
=
nodes
.
begin
();
jt
!=
nodes
.
end
();
jt
++
)
values
.
push_back
(
jt
->
IntegerDF
(
set_id
));
break
;
}
case
Element
::
Tri
:
case
Element
::
Quad
:
case
Element
::
MultiLine
:
case
Element
::
Polygon
:
{
ElementArray
<
Node
>
nodes
=
it
->
getNodes
();
values
.
push_back
(
static_cast
<
integer
>
(
nodes
.
size
()));
for
(
ElementArray
<
Node
>::
iterator
jt
=
nodes
.
begin
();
jt
!=
nodes
.
end
();
jt
++
)
values
.
push_back
(
jt
->
IntegerDF
(
set_id
));
break
;
}
default:
printf
(
"This should not happen %s
\n
"
,
Element
::
GeometricTypeName
(
it
->
GetGeometricType
()));
}
}
fprintf
(
f
,
"CELLS %u %ld
\n
"
,
NumberOfCells
()
+
NumberOfFaces
(),
values
.
size
());
}
else
fprintf
(
f
,
"CELLS %u %ld
\n
"
,
NumberOfCells
(),
values
.
size
());
fprintf
(
f
,
"CELLS %u %ld
\n
"
,
NumberOfCells
()
+
NumberOfFaces
(),
values
.
size
());
for
(
dynarray
<
Storage
::
integer
,
64
>::
size_type
i
=
0
;
i
<
values
.
size
();
i
++
)
{
fprintf
(
f
,
"%d "
,
values
[
i
]);
...
...
@@ -249,7 +267,12 @@ safe_output:
}
fprintf
(
f
,
"
\n
"
);
}
fprintf
(
f
,
"CELL_TYPES %u
\n
"
,
NumberOfCells
()
+
NumberOfFaces
());
if
(
output_faces
){
fprintf
(
f
,
"CELL_TYPES %u
\n
"
,
NumberOfCells
()
+
NumberOfFaces
());
}
else
fprintf
(
f
,
"CELL_TYPES %u
\n
"
,
NumberOfCells
());
for
(
Mesh
::
iteratorCell
it
=
BeginCell
();
it
!=
EndCell
();
it
++
)
{
INMOST_DATA_ENUM_TYPE
nnodes
=
VtkElementNodes
(
it
->
GetGeometricType
());
...
...
@@ -258,13 +281,15 @@ safe_output:
else
//number of nodes mismatch with expected - some topology checks must be off
fprintf
(
f
,
"%d
\n
"
,
VtkElementType
(
Element
::
MultiPolygon
));
}
for
(
Mesh
::
iteratorFace
it
=
BeginFace
();
it
!=
EndFace
();
it
++
)
{
INMOST_DATA_ENUM_TYPE
nnodes
=
VtkElementNodes
(
it
->
GetGeometricType
());
if
(
nnodes
==
ENUMUNDEF
||
nnodes
==
it
->
nbAdjElements
(
NODE
))
//nodes match - output correct type
fprintf
(
f
,
"%d
\n
"
,
VtkElementType
(
it
->
GetGeometricType
()));
else
//number of nodes mismatch with expected - some topology checks must be off
fprintf
(
f
,
"%d
\n
"
,
VtkElementType
(
Element
::
MultiPolygon
));
if
(
output_faces
){
for
(
Mesh
::
iteratorFace
it
=
BeginFace
();
it
!=
EndFace
();
it
++
)
{
INMOST_DATA_ENUM_TYPE
nnodes
=
VtkElementNodes
(
it
->
GetGeometricType
());
if
(
nnodes
==
ENUMUNDEF
||
nnodes
==
it
->
nbAdjElements
(
NODE
))
//nodes match - output correct type
fprintf
(
f
,
"%d
\n
"
,
VtkElementType
(
it
->
GetGeometricType
()));
else
//number of nodes mismatch with expected - some topology checks must be off
fprintf
(
f
,
"%d
\n
"
,
VtkElementType
(
Element
::
MultiPolygon
));
}
}
DeleteTag
(
set_id
);
{
...
...
@@ -276,7 +301,7 @@ safe_output:
Tag
t
=
GetTag
(
tag_names
[
i
]);
//printf("%s %d %d %d\n",tag_names[i].c_str(),t.isDefined(CELL),!t.isSparse(CELL),t.GetDataType() != DATA_BULK);
if
((
t
.
isDefined
(
CELL
)
&&
!
t
.
isSparse
(
CELL
)
||
t
.
isDefined
(
FACE
)
)
&&
||
(
t
.
isDefined
(
FACE
)
&&
output_faces
)
)
&&
t
.
GetDataType
()
!=
DATA_BULK
&&
t
.
GetDataType
()
!=
DATA_REFERENCE
&&
t
.
GetDataType
()
!=
DATA_REMOTE_REFERENCE
&&
...
...
@@ -290,7 +315,12 @@ safe_output:
}
}
if
(
!
tags
.
empty
()
)
fprintf
(
f
,
"CELL_DATA %u
\n
"
,
NumberOfCells
()
+
NumberOfFaces
());
if
(
!
tags
.
empty
()
&&
output_faces
)
{
fprintf
(
f
,
"CELL_DATA %u
\n
"
,
NumberOfCells
()
+
NumberOfFaces
());
}
else
if
(
!
tags
.
empty
())
fprintf
(
f
,
"CELL_DATA %u
\n
"
,
NumberOfCells
());
for
(
unsigned
int
i
=
0
;
i
<
tags
.
size
();
i
++
)
{
unsigned
int
comps
=
tags
[
i
].
GetSize
();
...
...
@@ -361,50 +391,54 @@ safe_output:
}
}
for
(
Mesh
::
iteratorFace
it
=
BeginFace
();
it
!=
EndFace
();
it
++
)
{
switch
(
tags
[
i
].
GetDataType
())
{
case
DATA_REAL
:
{
if
(
tags
[
i
].
isDefined
(
FACE
))
{
Storage
::
real_array
arr
=
it
->
RealArray
(
tags
[
i
]);
for
(
unsigned
int
m
=
0
;
m
<
comps
;
m
++
)
fprintf
(
f
,
"%14e "
,
arr
[
m
]);
}
else
for
(
unsigned
int
m
=
0
;
m
<
comps
;
m
++
)
fprintf
(
f
,
"0.0"
);
fprintf
(
f
,
"
\n
"
);
}
break
;
case
DATA_INTEGER
:
{
if
(
tags
[
i
].
isDefined
(
FACE
))
{
Storage
::
integer_array
arr
=
it
->
IntegerArray
(
tags
[
i
]);
for
(
unsigned
int
m
=
0
;
m
<
comps
;
m
++
)
fprintf
(
f
,
"%d "
,
arr
[
m
]);
}
else
for
(
unsigned
int
m
=
0
;
m
<
comps
;
m
++
)
fprintf
(
f
,
"0"
);
fprintf
(
f
,
"
\n
"
);
}
break
;
if
(
output_faces
){
for
(
Mesh
::
iteratorFace
it
=
BeginFace
();
it
!=
EndFace
();
it
++
)
{
switch
(
tags
[
i
].
GetDataType
())
{
case
DATA_REAL
:
{
if
(
tags
[
i
].
isDefined
(
FACE
))
{
Storage
::
real_array
arr
=
it
->
RealArray
(
tags
[
i
]);
for
(
unsigned
int
m
=
0
;
m
<
comps
;
m
++
)
fprintf
(
f
,
"%14e "
,
arr
[
m
]);
}
else
for
(
unsigned
int
m
=
0
;
m
<
comps
;
m
++
)
fprintf
(
f
,
"0.0"
);
fprintf
(
f
,
"
\n
"
);
}
break
;
case
DATA_INTEGER
:
{
if
(
tags
[
i
].
isDefined
(
FACE
))
{
Storage
::
integer_array
arr
=
it
->
IntegerArray
(
tags
[
i
]);
for
(
unsigned
int
m
=
0
;
m
<
comps
;
m
++
)
fprintf
(
f
,
"%d "
,
arr
[
m
]);
}
else
for
(
unsigned
int
m
=
0
;
m
<
comps
;
m
++
)
fprintf
(
f
,
"0"
);
fprintf
(
f
,
"
\n
"
);
}
break
;
#if defined(USE_AUTODIFF)
case
DATA_VARIABLE
:
{
if
(
tags
[
i
].
isDefined
(
FACE
))
{
Storage
::
var_array
arr
=
it
->
VariableArray
(
tags
[
i
]);
for
(
unsigned
int
m
=
0
;
m
<
comps
;
m
++
)
{
double
val
=
static_cast
<
double
>
(
arr
[
m
].
GetValue
());
fprintf
(
f
,
"%14e "
,
isbad
(
val
)
?
-
0.9999E30
:
val
);
}
}
else
fprintf
(
f
,
"0.0"
);
fprintf
(
f
,
"
\n
"
);
}
break
;
case
DATA_VARIABLE
:
{
if
(
tags
[
i
].
isDefined
(
FACE
))
{
Storage
::
var_array
arr
=
it
->
VariableArray
(
tags
[
i
]);
for
(
unsigned
int
m
=
0
;
m
<
comps
;
m
++
)
{
double
val
=
static_cast
<
double
>
(
arr
[
m
].
GetValue
());
fprintf
(
f
,
"%14e "
,
isbad
(
val
)
?
-
0.9999E30
:
val
);
}
}
else
fprintf
(
f
,
"0.0"
);
fprintf
(
f
,
"
\n
"
);
}
break
;
#endif
default:
continue
;
default:
continue
;
}
}
}
}
...
...
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