Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
b6bcdc75
Commit
b6bcdc75
authored
Jan 5, 2019
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add output for node and cell value to VTKWriter
parent
9ec7fc19
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!10
Feature/data output
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/output/VTKWriter.hpp
+134
-1
134 additions, 1 deletion
src/output/VTKWriter.hpp
with
134 additions
and
1 deletion
src/output/VTKWriter.hpp
+
134
−
1
View file @
b6bcdc75
...
...
@@ -14,11 +14,131 @@
class
VTKWriter
{
private:
template
<
typename
DataType
>
struct
VTKType
{};
template
<
>
struct
VTKType
<
int8_t
>
{
inline
const
static
std
::
string
name
{
"Int8"
};
};
template
<
>
struct
VTKType
<
uint8_t
>
{
inline
const
static
std
::
string
name
{
"UInt8"
};
};
template
<
>
struct
VTKType
<
int16_t
>
{
inline
const
static
std
::
string
name
{
"Int16"
};
};
template
<
>
struct
VTKType
<
uint16_t
>
{
inline
const
static
std
::
string
name
{
"UInt16"
};
};
template
<
>
struct
VTKType
<
int32_t
>
{
inline
const
static
std
::
string
name
{
"Int32"
};
};
template
<
>
struct
VTKType
<
uint32_t
>
{
inline
const
static
std
::
string
name
{
"UInt32"
};
};
template
<
>
struct
VTKType
<
int64_t
>
{
inline
const
static
std
::
string
name
{
"Int64"
};
};
template
<
>
struct
VTKType
<
uint64_t
>
{
inline
const
static
std
::
string
name
{
"UInt64"
};
};
template
<
>
struct
VTKType
<
float
>
{
inline
const
static
std
::
string
name
{
"Float32"
};
};
template
<
>
struct
VTKType
<
double
>
{
inline
const
static
std
::
string
name
{
"Float64"
};
};
const
std
::
string
m_base_filename
;
unsigned
int
m_file_number
;
double
m_last_time
;
const
double
m_time_period
;
template
<
typename
DataType
>
void
_write_node_value
(
std
::
ofstream
&
os
,
const
std
::
string
&
name
,
const
NodeValue
<
const
DataType
>&
item_value
)
{
os
<<
"<DataArray type=
\"
"
<<
VTKType
<
DataType
>::
name
<<
"
\"
Name=
\"
"
<<
name
<<
"
\"
>
\n
"
;
for
(
NodeId
i
=
0
;
i
<
item_value
.
size
();
++
i
)
{
os
<<
item_value
[
i
]
<<
' '
;
}
os
<<
"
\n
</DataArray>
\n
"
;
}
template
<
size_t
N
,
typename
DataType
>
void
_write_node_value
(
std
::
ofstream
&
os
,
const
std
::
string
&
name
,
const
NodeValue
<
const
TinyVector
<
N
,
DataType
>>&
item_value
)
{
os
<<
"<DataArray type=
\"
"
<<
VTKType
<
DataType
>::
name
<<
"
\"
Name=
\"
"
<<
name
<<
"
\"
NumberOfComponents=
\"
"
<<
N
<<
"
\"
>
\n
"
;
for
(
NodeId
i
=
0
;
i
<
item_value
.
size
();
++
i
)
{
for
(
size_t
j
=
0
;
j
<
N
;
++
j
)
{
os
<<
item_value
[
i
][
j
]
<<
' '
;
}
}
os
<<
"
\n
</DataArray>
\n
"
;
}
template
<
typename
DataType
>
void
_write_node_value
(
std
::
ofstream
&
os
,
const
std
::
string
&
name
,
const
CellValue
<
const
DataType
>&
item_value
)
{}
template
<
typename
DataType
>
void
_write_cell_value
(
std
::
ofstream
&
os
,
const
std
::
string
&
name
,
const
NodeValue
<
const
DataType
>&
item_value
)
{}
template
<
typename
DataType
>
void
_write_cell_value
(
std
::
ofstream
&
os
,
const
std
::
string
&
name
,
const
CellValue
<
const
DataType
>&
item_value
)
{
os
<<
"<DataArray type=
\"
Float64
\"
Name=
\"
"
<<
name
<<
"
\"
>
\n
"
;
for
(
CellId
i
=
0
;
i
<
item_value
.
size
();
++
i
)
{
os
<<
item_value
[
i
]
<<
' '
;
}
os
<<
"
\n
</DataArray>
\n
"
;
}
template
<
size_t
N
,
typename
DataType
>
void
_write_cell_value
(
std
::
ofstream
&
os
,
const
std
::
string
&
name
,
const
CellValue
<
const
TinyVector
<
N
,
DataType
>>&
item_value
)
{
os
<<
"<DataArray type=
\"
Float64
\"
Name=
\"
"
<<
name
<<
"
\"
NumberOfComponents=
\"
"
<<
N
<<
"
\"
>
\n
"
;
for
(
CellId
i
=
0
;
i
<
item_value
.
size
();
++
i
)
{
for
(
size_t
j
=
0
;
j
<
N
;
++
j
)
{
os
<<
item_value
[
i
][
j
]
<<
' '
;
}
}
os
<<
"
\n
</DataArray>
\n
"
;
}
public
:
template
<
typename
MeshType
>
void
write
(
const
MeshType
&
mesh
,
...
...
@@ -40,7 +160,20 @@ class VTKWriter
fout
<<
"<UnstructuredGrid>
\n
"
;
fout
<<
"<Piece NumberOfPoints=
\"
"
<<
mesh
.
numberOfNodes
()
<<
"
\"
NumberOfCells=
\"
"
<<
mesh
.
numberOfCells
()
<<
"
\"
>
\n
"
;
fout
<<
"<CellData>
\n
"
;
for
(
const
auto
&
[
name
,
item_value_variant
]
:
output_named_item_value_set
)
{
std
::
visit
([
&
,
name
=
name
](
auto
&&
item_value
)
{
return
this
->
_write_cell_value
(
fout
,
name
,
item_value
);
},
item_value_variant
);
}
fout
<<
"</CellData>
\n
"
;
fout
<<
"<PointData>
\n
"
;
for
(
const
auto
&
[
name
,
item_value_variant
]
:
output_named_item_value_set
)
{
std
::
visit
([
&
,
name
=
name
](
auto
&&
item_value
)
{
return
this
->
_write_node_value
(
fout
,
name
,
item_value
);
},
item_value_variant
);
}
fout
<<
"</PointData>
\n
"
;
fout
<<
"<Points>
\n
"
;
fout
<<
"<DataArray Name=
\"
Positions
\"
NumberOfComponents=
\"
3
\"
type=
\"
Float64
\"
format=
\"
ascii
\"
>
\n
"
;
using
Rd
=
TinyVector
<
MeshType
::
dimension
>
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment