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
ffd9c0cb
Commit
ffd9c0cb
authored
17 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
prepare element-based datasets
parent
975c2277
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Post/PViewDataGModel.cpp
+18
-6
18 additions, 6 deletions
Post/PViewDataGModel.cpp
Post/PViewDataGModel.h
+15
-18
15 additions, 18 deletions
Post/PViewDataGModel.h
Post/PViewDataGModelIO.cpp
+17
-12
17 additions, 12 deletions
Post/PViewDataGModelIO.cpp
with
50 additions
and
36 deletions
Post/PViewDataGModel.cpp
+
18
−
6
View file @
ffd9c0cb
// $Id: PViewDataGModel.cpp,v 1.3
7
2008-03-29 2
1:36:30
geuzaine Exp $
// $Id: PViewDataGModel.cpp,v 1.3
8
2008-03-29 2
3:40:56
geuzaine Exp $
//
//
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
//
//
...
@@ -24,8 +24,10 @@
...
@@ -24,8 +24,10 @@
#include
"PViewDataGModel.h"
#include
"PViewDataGModel.h"
#include
"MElement.h"
#include
"MElement.h"
#include
"Message.h"
PViewDataGModel
::
PViewDataGModel
()
:
_min
(
VAL_INF
),
_max
(
-
VAL_INF
)
PViewDataGModel
::
PViewDataGModel
()
:
_min
(
VAL_INF
),
_max
(
-
VAL_INF
),
_type
(
NodeData
)
{
{
}
}
...
@@ -159,8 +161,13 @@ int PViewDataGModel::getNumComponents(int step, int ent, int ele)
...
@@ -159,8 +161,13 @@ int PViewDataGModel::getNumComponents(int step, int ent, int ele)
void
PViewDataGModel
::
getValue
(
int
step
,
int
ent
,
int
ele
,
int
nod
,
int
comp
,
double
&
val
)
void
PViewDataGModel
::
getValue
(
int
step
,
int
ent
,
int
ele
,
int
nod
,
int
comp
,
double
&
val
)
{
{
// no sanity checks (assumed to be guarded by skipElement)
// no sanity checks (assumed to be guarded by skipElement)
MVertex
*
v
=
_steps
[
step
]
->
getEntity
(
ent
)
->
getMeshElement
(
ele
)
->
getVertex
(
nod
);
if
(
_type
==
NodeData
){
val
=
_steps
[
step
]
->
getData
(
v
->
getNum
())[
comp
];
MVertex
*
v
=
_steps
[
step
]
->
getEntity
(
ent
)
->
getMeshElement
(
ele
)
->
getVertex
(
nod
);
val
=
_steps
[
step
]
->
getData
(
v
->
getNum
())[
comp
];
}
else
{
Msg
(
GERROR
,
"Element-based data sets not yet ready!"
);
}
}
}
int
PViewDataGModel
::
getNumEdges
(
int
step
,
int
ent
,
int
ele
)
int
PViewDataGModel
::
getNumEdges
(
int
step
,
int
ent
,
int
ele
)
...
@@ -181,8 +188,13 @@ bool PViewDataGModel::skipElement(int step, int ent, int ele)
...
@@ -181,8 +188,13 @@ bool PViewDataGModel::skipElement(int step, int ent, int ele)
if
(
!
_steps
[
step
]
->
getNumData
())
return
true
;
if
(
!
_steps
[
step
]
->
getNumData
())
return
true
;
MElement
*
e
=
data
->
getEntity
(
ent
)
->
getMeshElement
(
ele
);
MElement
*
e
=
data
->
getEntity
(
ent
)
->
getMeshElement
(
ele
);
if
(
!
e
->
getVisibility
())
return
true
;
if
(
!
e
->
getVisibility
())
return
true
;
for
(
int
i
=
0
;
i
<
e
->
getNumVertices
();
i
++
)
if
(
_type
==
NodeData
){
if
(
!
data
->
getData
(
e
->
getVertex
(
i
)
->
getNum
()))
return
true
;
for
(
int
i
=
0
;
i
<
e
->
getNumVertices
();
i
++
)
if
(
!
data
->
getData
(
e
->
getVertex
(
i
)
->
getNum
()))
return
true
;
}
else
{
if
(
!
data
->
getData
(
e
->
getNum
()))
return
true
;
}
return
false
;
return
false
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Post/PViewDataGModel.h
+
15
−
18
View file @
ffd9c0cb
...
@@ -27,12 +27,6 @@
...
@@ -27,12 +27,6 @@
template
<
class
real
>
template
<
class
real
>
class
stepData
{
class
stepData
{
public:
enum
DataType
{
NodeData
=
1
,
ElementData
=
2
,
ElementNodeData
=
3
};
private:
private:
// a pointer to the underlying model
// a pointer to the underlying model
GModel
*
_model
;
GModel
*
_model
;
...
@@ -40,8 +34,6 @@ class stepData{
...
@@ -40,8 +34,6 @@ class stepData{
std
::
vector
<
GEntity
*>
_entities
;
std
::
vector
<
GEntity
*>
_entities
;
// the bounding box of the view
// the bounding box of the view
SBoundingBox3d
_bbox
;
SBoundingBox3d
_bbox
;
// the type of the dataset
DataType
_type
;
// the file the data was read from (if empty, refer to PViewData)
// the file the data was read from (if empty, refer to PViewData)
std
::
string
_fileName
;
std
::
string
_fileName
;
// the index in the file (if negative, refer to PViewData)
// the index in the file (if negative, refer to PViewData)
...
@@ -59,11 +51,10 @@ class stepData{
...
@@ -59,11 +51,10 @@ class stepData{
// MElement)
// MElement)
std
::
vector
<
real
*>
*
_data
;
std
::
vector
<
real
*>
*
_data
;
public:
public:
stepData
(
GModel
*
model
,
DataType
type
,
int
numComp
,
stepData
(
GModel
*
model
,
int
numComp
,
std
::
string
fileName
=
""
,
int
fileIndex
=-
1
,
std
::
string
fileName
=
""
,
int
fileIndex
=-
1
,
double
time
=
0.
,
double
time
=
0.
,
double
min
=
VAL_INF
,
double
max
=-
VAL_INF
)
double
min
=
VAL_INF
,
double
max
=-
VAL_INF
)
:
_model
(
model
),
_fileName
(
fileName
),
_fileIndex
(
fileIndex
),
_time
(
time
),
:
_model
(
model
),
_type
(
type
),
_fileName
(
fileName
),
_fileIndex
(
fileIndex
),
_min
(
min
),
_max
(
max
),
_numComp
(
numComp
),
_data
(
0
)
_time
(
time
),
_min
(
min
),
_max
(
max
),
_numComp
(
numComp
),
_data
(
0
)
{
{
// store vector of GEntities so we can index them efficiently
// store vector of GEntities so we can index them efficiently
for
(
GModel
::
eiter
it
=
_model
->
firstEdge
();
it
!=
_model
->
lastEdge
();
++
it
)
for
(
GModel
::
eiter
it
=
_model
->
firstEdge
();
it
!=
_model
->
lastEdge
();
++
it
)
...
@@ -79,8 +70,6 @@ class stepData{
...
@@ -79,8 +70,6 @@ class stepData{
SBoundingBox3d
getBoundingBox
(){
return
_bbox
;
}
SBoundingBox3d
getBoundingBox
(){
return
_bbox
;
}
int
getNumEntities
(){
return
_entities
.
size
();
}
int
getNumEntities
(){
return
_entities
.
size
();
}
GEntity
*
getEntity
(
int
ent
){
return
_entities
[
ent
];
}
GEntity
*
getEntity
(
int
ent
){
return
_entities
[
ent
];
}
DataType
getType
(){
return
_type
;
}
void
setType
(
DataType
type
){
_type
=
type
;
}
int
getNumComponents
(){
return
_numComp
;
}
int
getNumComponents
(){
return
_numComp
;
}
std
::
string
getFileName
(){
return
_fileName
;
}
std
::
string
getFileName
(){
return
_fileName
;
}
void
setFileName
(
std
::
string
name
){
_fileName
=
name
;
}
void
setFileName
(
std
::
string
name
){
_fileName
=
name
;
}
...
@@ -126,6 +115,12 @@ class stepData{
...
@@ -126,6 +115,12 @@ class stepData{
// data container using elements from a GModel
// data container using elements from a GModel
class
PViewDataGModel
:
public
PViewData
{
class
PViewDataGModel
:
public
PViewData
{
public:
enum
DataType
{
NodeData
=
1
,
ElementData
=
2
,
ElementNodeData
=
3
};
private
:
private
:
// the data, indexed by time step
// the data, indexed by time step
std
::
vector
<
stepData
<
double
>*>
_steps
;
std
::
vector
<
stepData
<
double
>*>
_steps
;
...
@@ -133,6 +128,8 @@ class PViewDataGModel : public PViewData {
...
@@ -133,6 +128,8 @@ class PViewDataGModel : public PViewData {
double
_min
,
_max
;
double
_min
,
_max
;
// a set of all "partitions" encountered in the input data
// a set of all "partitions" encountered in the input data
std
::
set
<
int
>
_partitions
;
std
::
set
<
int
>
_partitions
;
// the type of the dataset
DataType
_type
;
public
:
public
:
PViewDataGModel
();
PViewDataGModel
();
~
PViewDataGModel
();
~
PViewDataGModel
();
...
@@ -159,9 +156,9 @@ class PViewDataGModel : public PViewData {
...
@@ -159,9 +156,9 @@ class PViewDataGModel : public PViewData {
bool
hasPartition
(
int
part
);
bool
hasPartition
(
int
part
);
bool
hasMultipleMeshes
();
bool
hasMultipleMeshes
();
//
create old-style list-based dataset from this on
e
//
get/set the data typ
e
//PViewDataList *convertToPViewDataList();
DataType
getType
(){
return
_type
;
}
void
setType
(
DataType
type
){
_type
=
type
;
}
// direct access to GModel entities
// direct access to GModel entities
GEntity
*
getEntity
(
int
step
,
int
ent
);
GEntity
*
getEntity
(
int
step
,
int
ent
);
// direct access to value by index
// direct access to value by index
...
...
This diff is collapsed.
Click to expand it.
Post/PViewDataGModelIO.cpp
+
17
−
12
View file @
ffd9c0cb
// $Id: PViewDataGModelIO.cpp,v 1.
19
2008-03-29 2
2:58:45
geuzaine Exp $
// $Id: PViewDataGModelIO.cpp,v 1.
20
2008-03-29 2
3:40:56
geuzaine Exp $
//
//
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
//
//
...
@@ -37,8 +37,7 @@ bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp,
...
@@ -37,8 +37,7 @@ bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp,
step
,
time
,
partition
,
numNodes
);
step
,
time
,
partition
,
numNodes
);
while
(
step
>=
(
int
)
_steps
.
size
())
while
(
step
>=
(
int
)
_steps
.
size
())
_steps
.
push_back
(
new
stepData
<
double
>
(
GModel
::
current
(),
_steps
.
push_back
(
new
stepData
<
double
>
(
GModel
::
current
(),
numComp
));
stepData
<
double
>::
NodeData
,
numComp
));
_steps
[
step
]
->
setFileName
(
fileName
);
_steps
[
step
]
->
setFileName
(
fileName
);
_steps
[
step
]
->
setFileIndex
(
fileIndex
);
_steps
[
step
]
->
setFileIndex
(
fileIndex
);
...
@@ -213,15 +212,16 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex)
...
@@ -213,15 +212,16 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex)
Msg
(
GERROR
,
"Nothing to import from MED file"
);
Msg
(
GERROR
,
"Nothing to import from MED file"
);
return
false
;
return
false
;
}
}
else
{
for
(
int
step
=
0
;
step
<
numSteps
;
step
++
){
med_entite_maillage
ent
=
entType
[
pairs
[
0
].
first
];
med_entite_maillage
ent
=
entType
[
pairs
[
0
].
first
];
stepData
<
double
>::
DataType
entGmsh
=
setType
((
ent
==
MED_NOEUD
)
?
NodeData
:
(
ent
==
MED_NOEUD
)
?
stepData
<
double
>::
NodeData
:
(
ent
==
MED_MAILLE
)
?
ElementData
:
(
ent
==
MED_MAILLE
)
?
stepData
<
double
>::
ElementData
:
ElementNodeData
);
stepData
<
double
>::
ElementNodeData
;
}
for
(
int
step
=
0
;
step
<
numSteps
;
step
++
){
int
numCompGmsh
=
(
numComp
==
2
)
?
3
:
numComp
;
int
numCompGmsh
=
(
numComp
==
2
)
?
3
:
numComp
;
_steps
.
push_back
(
new
stepData
<
double
>
(
GModel
::
current
(),
entGmsh
,
numCompGmsh
));
_steps
.
push_back
(
new
stepData
<
double
>
(
GModel
::
current
(),
numCompGmsh
));
_steps
.
back
()
->
setFileName
(
fileName
);
_steps
.
back
()
->
setFileName
(
fileName
);
_steps
.
back
()
->
setFileIndex
(
fileIndex
);
_steps
.
back
()
->
setFileIndex
(
fileIndex
);
}
}
...
@@ -286,6 +286,7 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex)
...
@@ -286,6 +286,7 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex)
}
}
}
}
else
{
else
{
Msg
(
GERROR
,
"Element-based MED import not ready yet!"
);
// TODO... PS: since MED index elements by subgroups of
// TODO... PS: since MED index elements by subgroups of
// elements of the same type, we need to define an order of
// elements of the same type, we need to define an order of
// element types in stepData and STICK WITH IT! We need a
// element types in stepData and STICK WITH IT! We need a
...
@@ -342,6 +343,10 @@ bool PViewDataGModel::writeMED(std::string fileName)
...
@@ -342,6 +343,10 @@ bool PViewDataGModel::writeMED(std::string fileName)
nums
.
push_back
(
i
);
nums
.
push_back
(
i
);
}
}
}
}
if
(
profile
.
empty
()){
Msg
(
GERROR
,
"Nothing to save"
);
return
false
;
}
char
*
profileName
=
(
char
*
)
"nodeProfile"
;
char
*
profileName
=
(
char
*
)
"nodeProfile"
;
if
(
MEDprofilEcr
(
fid
,
&
profile
[
0
],
(
med_int
)
profile
.
size
(),
profileName
)
<
0
){
if
(
MEDprofilEcr
(
fid
,
&
profile
[
0
],
(
med_int
)
profile
.
size
(),
profileName
)
<
0
){
Msg
(
GERROR
,
"Could not create MED profile"
);
Msg
(
GERROR
,
"Could not create MED profile"
);
...
@@ -371,10 +376,10 @@ bool PViewDataGModel::writeMED(std::string fileName)
...
@@ -371,10 +376,10 @@ bool PViewDataGModel::writeMED(std::string fileName)
continue
;
continue
;
}
}
double
time
=
_steps
[
step
]
->
getTime
();
double
time
=
_steps
[
step
]
->
getTime
();
std
::
vector
<
double
>
val
(
numNodes
*
numComp
);
std
::
vector
<
double
>
val
(
profile
.
size
()
*
numComp
);
for
(
unsigned
int
i
=
0
;
i
<
profile
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
profile
.
size
();
i
++
)
for
(
int
k
=
0
;
k
<
numComp
;
k
++
)
for
(
int
k
=
0
;
k
<
numComp
;
k
++
)
val
[
(
profile
[
i
]
-
1
)
*
numComp
+
k
]
=
_steps
[
step
]
->
getData
(
nums
[
i
])[
k
];
val
[
i
*
numComp
+
k
]
=
_steps
[
step
]
->
getData
(
nums
[
i
])[
k
];
if
(
MEDchampEcr
(
fid
,
meshName
,
fieldName
,
(
unsigned
char
*
)
&
val
[
0
],
if
(
MEDchampEcr
(
fid
,
meshName
,
fieldName
,
(
unsigned
char
*
)
&
val
[
0
],
MED_FULL_INTERLACE
,
numNodes
,
MED_NOGAUSS
,
MED_ALL
,
MED_FULL_INTERLACE
,
numNodes
,
MED_NOGAUSS
,
MED_ALL
,
profileName
,
MED_COMPACT
,
MED_NOEUD
,
MED_NONE
,
(
med_int
)
step
,
profileName
,
MED_COMPACT
,
MED_NOEUD
,
MED_NONE
,
(
med_int
)
step
,
...
...
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