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
22ec6d6e
Commit
22ec6d6e
authored
17 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
added Element+ElementNode support in MSH format
parent
8484b79f
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Post/PViewDataGModel.cpp
+3
-3
3 additions, 3 deletions
Post/PViewDataGModel.cpp
Post/PViewDataGModel.h
+2
-3
2 additions, 3 deletions
Post/PViewDataGModel.h
Post/PViewDataGModelIO.cpp
+34
-17
34 additions, 17 deletions
Post/PViewDataGModelIO.cpp
Post/PViewIO.cpp
+15
-6
15 additions, 6 deletions
Post/PViewIO.cpp
with
54 additions
and
29 deletions
Post/PViewDataGModel.cpp
+
3
−
3
View file @
22ec6d6e
// $Id: PViewDataGModel.cpp,v 1.4
6
2008-04-0
2 16:30:29
geuzaine Exp $
// $Id: PViewDataGModel.cpp,v 1.4
7
2008-04-0
3 07:48:54
geuzaine Exp $
//
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
//
...
...
@@ -27,8 +27,8 @@
#include
"Numeric.h"
#include
"Message.h"
PViewDataGModel
::
PViewDataGModel
()
:
_min
(
VAL_INF
),
_max
(
-
VAL_INF
),
_type
(
NodeData
)
PViewDataGModel
::
PViewDataGModel
(
DataType
type
)
:
_min
(
VAL_INF
),
_max
(
-
VAL_INF
),
_type
(
type
)
{
}
...
...
This diff is collapsed.
Click to expand it.
Post/PViewDataGModel.h
+
2
−
3
View file @
22ec6d6e
...
...
@@ -143,7 +143,7 @@ class PViewDataGModel : public PViewData {
// the type of the dataset
DataType
_type
;
public
:
PViewDataGModel
();
PViewDataGModel
(
DataType
type
=
NodeData
);
~
PViewDataGModel
();
bool
finalize
();
int
getNumTimeSteps
();
...
...
@@ -170,9 +170,8 @@ class PViewDataGModel : public PViewData {
bool
hasMultipleMeshes
();
bool
useGaussPoints
(){
return
_type
==
GaussPointData
;
}
// get
/set
the data type
// get the data type
DataType
getType
(){
return
_type
;
}
void
setType
(
DataType
type
){
_type
=
type
;
}
// direct access to GModel entities
GEntity
*
getEntity
(
int
step
,
int
ent
);
// direct access to value by index
...
...
This diff is collapsed.
Click to expand it.
Post/PViewDataGModelIO.cpp
+
34
−
17
View file @
22ec6d6e
// $Id: PViewDataGModelIO.cpp,v 1.3
6
2008-04-0
2 20:00:38
geuzaine Exp $
// $Id: PViewDataGModelIO.cpp,v 1.3
7
2008-04-0
3 07:48:54
geuzaine Exp $
//
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
//
...
...
@@ -32,10 +32,10 @@
bool
PViewDataGModel
::
readMSH
(
std
::
string
fileName
,
int
fileIndex
,
FILE
*
fp
,
bool
binary
,
bool
swap
,
int
step
,
double
time
,
int
partition
,
int
numComp
,
int
num
Nodes
)
int
partition
,
int
numComp
,
int
num
Ent
)
{
Msg
(
INFO
,
"Reading step %d (time %g) partition %d: %d
node
s"
,
step
,
time
,
partition
,
num
Nodes
);
Msg
(
INFO
,
"Reading step %d (time %g) partition %d: %d
record
s"
,
step
,
time
,
partition
,
num
Ent
);
while
(
step
>=
(
int
)
_steps
.
size
())
_steps
.
push_back
(
new
stepData
<
double
>
(
GModel
::
current
(),
numComp
));
...
...
@@ -50,9 +50,9 @@ bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp,
numSteps
+=
_steps
[
i
]
->
getNumData
()
?
1
:
0
;
if
(
numSteps
>
maxSteps
)
return
true
;
_steps
[
step
]
->
resizeData
(
num
Nodes
);
_steps
[
step
]
->
resizeData
(
num
Ent
);
for
(
int
i
=
0
;
i
<
num
Nodes
;
i
++
){
for
(
int
i
=
0
;
i
<
num
Ent
;
i
++
){
int
num
;
if
(
binary
){
if
(
fread
(
&
num
,
sizeof
(
int
),
1
,
fp
)
!=
1
)
return
false
;
...
...
@@ -61,18 +61,31 @@ bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp,
else
{
if
(
fscanf
(
fp
,
"%d"
,
&
num
)
!=
1
)
return
false
;
}
double
*
d
=
_steps
[
step
]
->
getData
(
num
,
true
);
int
mult
=
1
;
if
(
_type
==
ElementNodeData
||
_type
==
GaussPointData
){
if
(
binary
){
if
(
fread
(
&
mult
,
sizeof
(
int
),
1
,
fp
)
!=
1
)
return
false
;
if
(
swap
)
swapBytes
((
char
*
)
&
mult
,
sizeof
(
int
),
1
);
}
else
{
if
(
fscanf
(
fp
,
"%d"
,
&
mult
)
!=
1
)
return
false
;
}
}
double
*
d
=
_steps
[
step
]
->
getData
(
num
,
true
,
mult
);
if
(
binary
){
if
((
int
)
fread
(
d
,
sizeof
(
double
),
numComp
,
fp
)
!=
numComp
)
return
false
;
if
(
swap
)
swapBytes
((
char
*
)
d
,
sizeof
(
double
),
numComp
);
if
((
int
)
fread
(
d
,
sizeof
(
double
),
numComp
*
mult
,
fp
)
!=
numComp
*
mult
)
return
false
;
if
(
swap
)
swapBytes
((
char
*
)
d
,
sizeof
(
double
),
numComp
*
mult
);
}
else
{
for
(
int
j
=
0
;
j
<
numComp
;
j
++
)
for
(
int
j
=
0
;
j
<
numComp
*
mult
;
j
++
)
if
(
fscanf
(
fp
,
"%lf"
,
&
d
[
j
])
!=
1
)
return
false
;
}
double
s
=
ComputeScalarRep
(
numComp
,
d
);
_steps
[
step
]
->
setMin
(
std
::
min
(
_steps
[
step
]
->
getMin
(),
s
));
_steps
[
step
]
->
setMax
(
std
::
max
(
_steps
[
step
]
->
getMax
(),
s
));
for
(
int
j
=
0
;
j
<
mult
;
j
++
){
double
s
=
ComputeScalarRep
(
numComp
,
&
d
[
numComp
*
j
]);
_steps
[
step
]
->
setMin
(
std
::
min
(
_steps
[
step
]
->
getMin
(),
s
));
_steps
[
step
]
->
setMax
(
std
::
max
(
_steps
[
step
]
->
getMax
(),
s
));
}
}
_partitions
.
insert
(
partition
);
...
...
@@ -90,6 +103,11 @@ bool PViewDataGModel::writeMSH(std::string fileName, bool binary)
return
false
;
}
if
(
_type
!=
NodeData
){
Msg
(
GERROR
,
"Can only export node-based datasets for now"
);
return
false
;
}
GModel
*
model
=
_steps
[
0
]
->
getModel
();
binary
=
true
;
...
...
@@ -217,9 +235,8 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex)
}
else
{
med_entite_maillage
ent
=
entType
[
pairs
[
0
].
first
];
setType
((
ent
==
MED_NOEUD
)
?
NodeData
:
(
ent
==
MED_MAILLE
)
?
ElementData
:
ElementNodeData
);
_type
=
(
ent
==
MED_NOEUD
)
?
NodeData
:
(
ent
==
MED_MAILLE
)
?
ElementData
:
ElementNodeData
;
}
for
(
int
step
=
0
;
step
<
numSteps
;
step
++
){
...
...
@@ -263,7 +280,7 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex)
}
else
if
(
ngauss
!=
MED_NOPG
){
mult
=
ngauss
;
setType
(
GaussPointData
)
;
_type
=
GaussPointData
;
}
_steps
[
step
]
->
resizeData
(
numVal
/
mult
);
...
...
This diff is collapsed.
Click to expand it.
Post/PViewIO.cpp
+
15
−
6
View file @
22ec6d6e
// $Id: PViewIO.cpp,v 1.
3
2008-0
3-29 10:19:43
geuzaine Exp $
// $Id: PViewIO.cpp,v 1.
4
2008-0
4-03 07:48:54
geuzaine Exp $
//
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
//
...
...
@@ -145,25 +145,34 @@ bool PView::readMSH(std::string fileName, int fileIndex)
}
}
}
else
if
(
!
strncmp
(
&
str
[
1
],
"NodeData"
,
8
))
{
else
if
(
!
strncmp
(
&
str
[
1
],
"NodeData"
,
8
)
||
!
strncmp
(
&
str
[
1
],
"ElementData"
,
11
)
||
!
strncmp
(
&
str
[
1
],
"ElementNodeData"
,
15
))
{
index
++
;
if
(
fileIndex
<
0
||
fileIndex
==
index
){
PViewDataGModel
::
DataType
type
;
if
(
!
strncmp
(
&
str
[
1
],
"NodeData"
,
8
))
type
=
PViewDataGModel
::
NodeData
;
else
if
(
!
strncmp
(
&
str
[
1
],
"ElementData"
,
11
))
type
=
PViewDataGModel
::
ElementData
;
else
type
=
PViewDataGModel
::
ElementNodeData
;
// read data info
if
(
!
fgets
(
str
,
sizeof
(
str
),
fp
))
return
false
;
std
::
string
name
=
extractDoubleQuotedString
(
str
,
sizeof
(
str
));
int
timeStep
,
partition
,
interpolationScheme
,
numComp
,
num
Nodes
;
int
timeStep
,
partition
,
interpolationScheme
,
numComp
,
num
Ent
;
double
time
;
if
(
!
fgets
(
str
,
sizeof
(
str
),
fp
))
return
false
;
if
(
sscanf
(
str
,
"%d %lf %d %d %d %d"
,
&
timeStep
,
&
time
,
&
partition
,
&
interpolationScheme
,
&
numComp
,
&
num
Nodes
)
!=
6
)
return
false
;
&
interpolationScheme
,
&
numComp
,
&
num
Ent
)
!=
6
)
return
false
;
// either get existing viewData, or create new one
PView
*
p
=
getViewByName
(
name
,
timeStep
,
partition
);
PViewDataGModel
*
d
=
0
;
if
(
p
)
d
=
dynamic_cast
<
PViewDataGModel
*>
(
p
->
getData
());
bool
create
=
d
?
false
:
true
;
if
(
create
)
d
=
new
PViewDataGModel
();
if
(
create
)
d
=
new
PViewDataGModel
(
type
);
if
(
!
d
->
readMSH
(
fileName
,
fileIndex
,
fp
,
binary
,
swap
,
timeStep
,
time
,
partition
,
numComp
,
num
Nodes
)){
time
,
partition
,
numComp
,
num
Ent
)){
Msg
(
GERROR
,
"Could not read data in msh file"
);
if
(
create
)
delete
d
;
return
false
;
...
...
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