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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
ca70212f
Commit
ca70212f
authored
4 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Fix `gnuplot` in 2D and in parallel
parent
185bb1a8
No related branches found
No related tags found
1 merge request
!80
Feature/writers improvement
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/output/GnuplotWriter.cpp
+40
-23
40 additions, 23 deletions
src/output/GnuplotWriter.cpp
with
40 additions
and
23 deletions
src/output/GnuplotWriter.cpp
+
40
−
23
View file @
ca70212f
...
...
@@ -121,7 +121,7 @@ GnuplotWriter::_writeValues(const std::shared_ptr<const MeshType>& mesh,
const
OutputNamedItemValueSet
&
output_named_item_value_set
,
std
::
ostream
&
fout
)
const
{
if
constexpr
(
MeshType
::
Dimension
<
=
2
)
{
if
constexpr
(
MeshType
::
Dimension
=
=
1
)
{
auto
cell_to_node_matrix
=
mesh
->
connectivity
().
cellToNodeMatrix
();
auto
cell_is_owned
=
mesh
->
connectivity
().
cellIsOwned
();
...
...
@@ -132,17 +132,39 @@ GnuplotWriter::_writeValues(const std::shared_ptr<const MeshType>& mesh,
const
NodeId
&
node_id
=
cell_nodes
[
i_node
];
const
TinyVector
<
MeshType
::
Dimension
>&
xr
=
mesh
->
xr
()[
node_id
];
fout
<<
xr
[
0
];
if
(
MeshType
::
Dimension
==
2
)
{
fout
<<
' '
<<
xr
[
1
];
}
for
(
auto
[
name
,
item_value
]
:
output_named_item_value_set
)
{
std
::
visit
([
&
](
auto
&&
cell_value
)
{
_writeValue
(
cell_value
,
cell_id
,
node_id
,
fout
);
},
item_value
);
}
fout
<<
'\n'
;
}
fout
<<
"
\n\n
"
;
}
}
}
else
if
constexpr
(
MeshType
::
Dimension
==
2
)
{
auto
cell_to_node_matrix
=
mesh
->
connectivity
().
cellToNodeMatrix
();
auto
cell_is_owned
=
mesh
->
connectivity
().
cellIsOwned
();
for
(
CellId
cell_id
=
0
;
cell_id
<
mesh
->
numberOfCells
();
++
cell_id
)
{
if
(
cell_is_owned
[
cell_id
])
{
const
auto
&
cell_nodes
=
cell_to_node_matrix
[
cell_id
];
for
(
size_t
i_node
=
0
;
i_node
<
cell_nodes
.
size
();
++
i_node
)
{
const
NodeId
&
node_id
=
cell_nodes
[
i_node
];
const
TinyVector
<
MeshType
::
Dimension
>&
xr
=
mesh
->
xr
()[
node_id
];
fout
<<
xr
[
0
]
<<
' '
<<
xr
[
1
];
for
(
auto
[
name
,
item_value
]
:
output_named_item_value_set
)
{
std
::
visit
([
&
](
auto
&&
cell_value
)
{
_writeValue
(
cell_value
,
cell_id
,
node_id
,
fout
);
},
item_value
);
}
fout
<<
'\n'
;
}
const
NodeId
&
node_id
=
cell_nodes
[
0
];
const
TinyVector
<
MeshType
::
Dimension
>&
xr
=
mesh
->
xr
()[
node_id
];
fout
<<
xr
[
0
]
<<
' '
<<
xr
[
1
];
for
(
auto
[
name
,
item_value
]
:
output_named_item_value_set
)
{
std
::
visit
([
&
](
auto
&&
cell_value
)
{
_writeValue
(
cell_value
,
cell_id
,
node_id
,
fout
);
},
item_value
);
}
fout
<<
"
\n\n\n
"
;
}
}
}
else
{
throw
UnexpectedError
(
"invalid mesh dimension"
);
...
...
@@ -177,22 +199,26 @@ GnuplotWriter::_write(const std::shared_ptr<const MeshType>& mesh,
const
OutputNamedItemValueSet
&
output_named_item_value_set
,
double
time
)
const
{
if
(
parallel
::
size
()
==
1
)
{
if
(
parallel
::
rank
()
==
0
)
{
std
::
ofstream
fout
{
_getFilename
()};
fout
.
precision
(
15
);
fout
.
setf
(
std
::
ios_base
::
scientific
);
fout
<<
this
->
_getDateAndVersionComment
();
fout
<<
"
\n
# time = "
<<
time
<<
"
\n\n
"
;
fout
<<
"# time = "
<<
time
<<
"
\n\n
"
;
this
->
_writePreamble
<
MeshType
::
Dimension
>
(
output_named_item_value_set
,
fout
);
}
for
(
size_t
i_rank
=
0
;
i_rank
<
parallel
::
size
();
++
i_rank
)
{
if
(
i_rank
==
parallel
::
rank
())
{
std
::
ofstream
fout
(
_getFilename
(),
std
::
ios_base
::
app
);
fout
.
precision
(
15
);
fout
.
setf
(
std
::
ios_base
::
scientific
);
this
->
_writeValues
(
mesh
,
output_named_item_value_set
,
fout
);
}
else
{
throw
NotImplementedError
(
"not implemented in parallel"
);
}
parallel
::
barrier
(
);
}
}
...
...
@@ -201,22 +227,13 @@ GnuplotWriter::writeMesh(const std::shared_ptr<const IMesh>& p_mesh) const
{
OutputNamedItemValueSet
output_named_item_value_set
{};
std
::
ofstream
fout
(
_getFilename
());
fout
.
precision
(
15
);
fout
.
setf
(
std
::
ios_base
::
scientific
);
fout
<<
_getDateAndVersionComment
();
switch
(
p_mesh
->
dimension
())
{
case
1
:
{
this
->
_writePreamble
<
1
>
(
output_named_item_value_set
,
fout
);
this
->
_writeValues
(
std
::
dynamic_pointer_cast
<
const
Mesh
<
Connectivity
<
1
>>>
(
p_mesh
),
output_named_item_value_set
,
fout
);
this
->
_write
(
std
::
dynamic_pointer_cast
<
const
Mesh
<
Connectivity
<
1
>>>
(
p_mesh
),
output_named_item_value_set
,
0
);
break
;
}
case
2
:
{
this
->
_writePreamble
<
2
>
(
output_named_item_value_set
,
fout
);
this
->
_writeValues
(
std
::
dynamic_pointer_cast
<
const
Mesh
<
Connectivity
<
2
>>>
(
p_mesh
),
output_named_item_value_set
,
fout
);
this
->
_write
(
std
::
dynamic_pointer_cast
<
const
Mesh
<
Connectivity
<
2
>>>
(
p_mesh
),
output_named_item_value_set
,
0
);
break
;
}
default
:
{
...
...
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