Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
e748e6b8
Commit
e748e6b8
authored
13 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
first pass at a fromVector/toVector serialization of PViews
parent
d040e0c1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Post/PViewData.h
+2
-0
2 additions, 0 deletions
Post/PViewData.h
Post/PViewDataIO.cpp
+68
-13
68 additions, 13 deletions
Post/PViewDataIO.cpp
with
70 additions
and
13 deletions
Post/PViewData.h
+
2
−
0
View file @
e748e6b8
...
@@ -255,6 +255,8 @@ class PViewData {
...
@@ -255,6 +255,8 @@ class PViewData {
bool
append
=
false
);
bool
append
=
false
);
virtual
bool
writeMSH
(
std
::
string
fileName
,
bool
binary
=
false
,
bool
savemesh
=
true
);
virtual
bool
writeMSH
(
std
::
string
fileName
,
bool
binary
=
false
,
bool
savemesh
=
true
);
virtual
bool
writeMED
(
std
::
string
fileName
);
virtual
bool
writeMED
(
std
::
string
fileName
);
virtual
bool
toVector
(
std
::
vector
<
std
::
vector
<
double
>
>
&
vec
);
virtual
bool
fromVector
(
const
std
::
vector
<
std
::
vector
<
double
>
>
&
vec
);
};
};
class
nameData
{
class
nameData
{
...
...
This diff is collapsed.
Click to expand it.
Post/PViewDataIO.cpp
+
68
−
13
View file @
e748e6b8
...
@@ -41,7 +41,7 @@ bool PViewData::writeSTL(std::string fileName)
...
@@ -41,7 +41,7 @@ bool PViewData::writeSTL(std::string fileName)
fprintf
(
fp
,
"facet normal %g %g %g
\n
"
,
n
[
0
],
n
[
1
],
n
[
2
]);
fprintf
(
fp
,
"facet normal %g %g %g
\n
"
,
n
[
0
],
n
[
1
],
n
[
2
]);
fprintf
(
fp
,
" outer loop
\n
"
);
fprintf
(
fp
,
" outer loop
\n
"
);
fprintf
(
fp
,
" vertex %g %g %g
\n
"
,
x
[
0
],
y
[
0
],
z
[
0
]);
fprintf
(
fp
,
" vertex %g %g %g
\n
"
,
x
[
0
],
y
[
0
],
z
[
0
]);
fprintf
(
fp
,
" vertex %g %g %g
\n
"
,
x
[
1
],
y
[
1
],
z
[
1
]);
fprintf
(
fp
,
" vertex %g %g %g
\n
"
,
x
[
1
],
y
[
1
],
z
[
1
]);
fprintf
(
fp
,
" vertex %g %g %g
\n
"
,
x
[
2
],
y
[
2
],
z
[
2
]);
fprintf
(
fp
,
" vertex %g %g %g
\n
"
,
x
[
2
],
y
[
2
],
z
[
2
]);
fprintf
(
fp
,
" endloop
\n
"
);
fprintf
(
fp
,
" endloop
\n
"
);
fprintf
(
fp
,
"endfacet
\n
"
);
fprintf
(
fp
,
"endfacet
\n
"
);
...
@@ -65,7 +65,7 @@ bool PViewData::writeSTL(std::string fileName)
...
@@ -65,7 +65,7 @@ bool PViewData::writeSTL(std::string fileName)
}
}
}
}
fprintf
(
fp
,
"endsolid Created by Gmsh
\n
"
);
fprintf
(
fp
,
"endsolid Created by Gmsh
\n
"
);
fclose
(
fp
);
fclose
(
fp
);
return
true
;
return
true
;
}
}
...
@@ -78,16 +78,16 @@ bool PViewData::writeTXT(std::string fileName)
...
@@ -78,16 +78,16 @@ bool PViewData::writeTXT(std::string fileName)
return
false
;
return
false
;
}
}
for
(
int
step
=
0
;
step
<
getNumTimeSteps
();
step
++
){
for
(
int
step
=
0
;
step
<
getNumTimeSteps
();
step
++
){
for
(
int
ent
=
0
;
ent
<
getNumEntities
(
step
);
ent
++
){
for
(
int
ent
=
0
;
ent
<
getNumEntities
(
step
);
ent
++
){
for
(
int
ele
=
0
;
ele
<
getNumElements
(
step
,
ent
);
ele
++
){
for
(
int
ele
=
0
;
ele
<
getNumElements
(
step
,
ent
);
ele
++
){
if
(
skipElement
(
step
,
ent
,
ele
))
continue
;
if
(
skipElement
(
step
,
ent
,
ele
))
continue
;
for
(
int
nod
=
0
;
nod
<
getNumNodes
(
step
,
ent
,
ele
);
nod
++
){
for
(
int
nod
=
0
;
nod
<
getNumNodes
(
step
,
ent
,
ele
);
nod
++
){
double
x
,
y
,
z
;
double
x
,
y
,
z
;
getNode
(
step
,
ent
,
ele
,
nod
,
x
,
y
,
z
);
getNode
(
step
,
ent
,
ele
,
nod
,
x
,
y
,
z
);
fprintf
(
fp
,
"%d %.16g %d %d %.16g %.16g %.16g "
,
step
,
getTime
(
step
),
fprintf
(
fp
,
"%d %.16g %d %d %.16g %.16g %.16g "
,
step
,
getTime
(
step
),
ent
,
ele
,
x
,
y
,
z
);
ent
,
ele
,
x
,
y
,
z
);
for
(
int
comp
=
0
;
comp
<
getNumComponents
(
step
,
ent
,
ele
);
comp
++
){
for
(
int
comp
=
0
;
comp
<
getNumComponents
(
step
,
ent
,
ele
);
comp
++
){
double
val
;
double
val
;
getValue
(
step
,
ent
,
ele
,
nod
,
comp
,
val
);
getValue
(
step
,
ent
,
ele
,
nod
,
comp
,
val
);
fprintf
(
fp
,
"%.16g "
,
val
);
fprintf
(
fp
,
"%.16g "
,
val
);
...
@@ -103,7 +103,7 @@ bool PViewData::writeTXT(std::string fileName)
...
@@ -103,7 +103,7 @@ bool PViewData::writeTXT(std::string fileName)
}
}
bool
PViewData
::
writePOS
(
std
::
string
fileName
,
bool
binary
,
bool
parsed
,
bool
append
)
bool
PViewData
::
writePOS
(
std
::
string
fileName
,
bool
binary
,
bool
parsed
,
bool
append
)
{
{
if
(
_adaptive
){
if
(
_adaptive
){
Msg
::
Warning
(
"Writing adapted dataset (will only export current time step)"
);
Msg
::
Warning
(
"Writing adapted dataset (will only export current time step)"
);
return
_adaptive
->
getData
()
->
writePOS
(
fileName
,
binary
,
parsed
,
append
);
return
_adaptive
->
getData
()
->
writePOS
(
fileName
,
binary
,
parsed
,
append
);
...
@@ -125,7 +125,7 @@ bool PViewData::writePOS(std::string fileName, bool binary, bool parsed, bool ap
...
@@ -125,7 +125,7 @@ bool PViewData::writePOS(std::string fileName, bool binary, bool parsed, bool ap
fprintf
(
fp
,
"View
\"
%s
\"
{
\n
"
,
getName
().
c_str
());
fprintf
(
fp
,
"View
\"
%s
\"
{
\n
"
,
getName
().
c_str
());
int
firstNonEmptyStep
=
getFirstNonEmptyTimeStep
();
int
firstNonEmptyStep
=
getFirstNonEmptyTimeStep
();
for
(
int
ent
=
0
;
ent
<
getNumEntities
(
firstNonEmptyStep
);
ent
++
){
for
(
int
ent
=
0
;
ent
<
getNumEntities
(
firstNonEmptyStep
);
ent
++
){
for
(
int
ele
=
0
;
ele
<
getNumElements
(
firstNonEmptyStep
,
ent
);
ele
++
){
for
(
int
ele
=
0
;
ele
<
getNumElements
(
firstNonEmptyStep
,
ent
);
ele
++
){
if
(
skipElement
(
firstNonEmptyStep
,
ent
,
ele
))
continue
;
if
(
skipElement
(
firstNonEmptyStep
,
ent
,
ele
))
continue
;
...
@@ -155,7 +155,7 @@ bool PViewData::writePOS(std::string fileName, bool binary, bool parsed, bool ap
...
@@ -155,7 +155,7 @@ bool PViewData::writePOS(std::string fileName, bool binary, bool parsed, bool ap
for
(
int
step
=
0
;
step
<
getNumTimeSteps
();
step
++
){
for
(
int
step
=
0
;
step
<
getNumTimeSteps
();
step
++
){
if
(
hasTimeStep
(
step
)){
if
(
hasTimeStep
(
step
)){
for
(
int
nod
=
0
;
nod
<
numNod
;
nod
++
){
for
(
int
nod
=
0
;
nod
<
numNod
;
nod
++
){
for
(
int
comp
=
0
;
comp
<
numComp
;
comp
++
){
for
(
int
comp
=
0
;
comp
<
numComp
;
comp
++
){
double
val
;
double
val
;
getValue
(
step
,
ent
,
ele
,
nod
,
comp
,
val
);
getValue
(
step
,
ent
,
ele
,
nod
,
comp
,
val
);
if
(
first
){
fprintf
(
fp
,
"){%.16g"
,
val
);
first
=
false
;
}
if
(
first
){
fprintf
(
fp
,
"){%.16g"
,
val
);
first
=
false
;
}
...
@@ -170,18 +170,73 @@ bool PViewData::writePOS(std::string fileName, bool binary, bool parsed, bool ap
...
@@ -170,18 +170,73 @@ bool PViewData::writePOS(std::string fileName, bool binary, bool parsed, bool ap
}
}
fprintf
(
fp
,
"};
\n
"
);
fprintf
(
fp
,
"};
\n
"
);
return
true
;
return
true
;
}
}
bool
PViewData
::
writeMSH
(
std
::
string
fileName
,
bool
binary
,
bool
savemesh
)
bool
PViewData
::
writeMSH
(
std
::
string
fileName
,
bool
binary
,
bool
savemesh
)
{
{
Msg
::
Error
(
"MSH export not implemented for this view type"
);
Msg
::
Error
(
"MSH export not implemented for this view type"
);
return
false
;
return
false
;
}
}
bool
PViewData
::
writeMED
(
std
::
string
fileName
)
bool
PViewData
::
writeMED
(
std
::
string
fileName
)
{
{
Msg
::
Error
(
"MED export onnly available for mesh-based post-processing views"
);
Msg
::
Error
(
"MED export onnly available for mesh-based post-processing views"
);
return
false
;
return
false
;
}
bool
PViewData
::
toVector
(
std
::
vector
<
std
::
vector
<
double
>
>
&
vec
)
{
vec
.
resize
(
getNumTimeSteps
());
for
(
int
step
=
0
;
step
<
getNumTimeSteps
();
step
++
){
vec
[
step
].
clear
();
for
(
int
ent
=
0
;
ent
<
getNumEntities
(
step
);
ent
++
){
for
(
int
ele
=
0
;
ele
<
getNumElements
(
step
,
ent
);
ele
++
){
if
(
skipElement
(
step
,
ent
,
ele
))
continue
;
for
(
int
nod
=
0
;
nod
<
getNumNodes
(
step
,
ent
,
ele
);
nod
++
){
for
(
int
comp
=
0
;
comp
<
getNumComponents
(
step
,
ent
,
ele
);
comp
++
){
double
val
;
getValue
(
step
,
ent
,
ele
,
nod
,
comp
,
val
);
vec
[
step
].
push_back
(
val
);
}
}
}
}
}
return
true
;
}
bool
PViewData
::
fromVector
(
const
std
::
vector
<
std
::
vector
<
double
>
>
&
vec
)
{
if
(
vec
.
size
()
!=
getNumTimeSteps
()){
Msg
::
Error
(
"Incompatible number of steps in vector (%d) and view (%d)"
,
(
int
)
vec
.
size
(),
getNumTimeSteps
());
return
false
;
}
for
(
int
step
=
0
;
step
<
getNumTimeSteps
();
step
++
){
int
i
=
0
;
for
(
int
ent
=
0
;
ent
<
getNumEntities
(
step
);
ent
++
){
for
(
int
ele
=
0
;
ele
<
getNumElements
(
step
,
ent
);
ele
++
){
if
(
skipElement
(
step
,
ent
,
ele
))
continue
;
for
(
int
nod
=
0
;
nod
<
getNumNodes
(
step
,
ent
,
ele
);
nod
++
){
double
x
,
y
,
z
;
int
tag
=
getNode
(
step
,
ent
,
ele
,
nod
,
x
,
y
,
z
);
if
(
tag
)
continue
;
// node has already been modified
tagNode
(
step
,
ent
,
ele
,
nod
,
1
);
for
(
int
comp
=
0
;
comp
<
getNumComponents
(
step
,
ent
,
ele
);
comp
++
){
if
(
i
<
vec
[
step
].
size
()){
setValue
(
step
,
ent
,
ele
,
nod
,
comp
,
vec
[
step
][
i
++
]);
}
else
{
Msg
::
Error
(
"Bad index (%d) in vector (%d)"
,
i
,
(
int
)
vec
[
step
].
size
());
return
false
;
}
}
}
}
}
}
return
true
;
}
}
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