Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
amfe
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
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
Aerospace and Mechanical Engineering
amfe
Commits
fb9deb4b
Commit
fb9deb4b
authored
5 months ago
by
Adrien Crovato
Browse files
Options
Downloads
Patches
Plain Diff
Add capability to save mesh and results as list in Gmsh for adaptive mesh refinement
parent
c11ff6ee
Branches
feat_amr
No related tags found
No related merge requests found
Pipeline
#50457
passed
5 months ago
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
tbox/src/wGmshExport.cpp
+67
-0
67 additions, 0 deletions
tbox/src/wGmshExport.cpp
tbox/src/wGmshExport.h
+1
-0
1 addition, 0 deletions
tbox/src/wGmshExport.h
tbox/src/wMshExport.cpp
+4
-0
4 additions, 0 deletions
tbox/src/wMshExport.cpp
tbox/src/wMshExport.h
+1
-0
1 addition, 0 deletions
tbox/src/wMshExport.h
with
73 additions
and
0 deletions
tbox/src/wGmshExport.cpp
+
67
−
0
View file @
fb9deb4b
...
@@ -298,6 +298,73 @@ void GmshExport::save(std::string const &fname, Results const &r) const
...
@@ -298,6 +298,73 @@ void GmshExport::save(std::string const &fname, Results const &r) const
std
::
cout
<<
"done"
<<
std
::
endl
;
std
::
cout
<<
"done"
<<
std
::
endl
;
}
}
/**
* @brief Save results as a list view, i.e. with the underlying mesh, on disk
* @todo Check if useful with newer Gmsh versions
* @todo Remove if remeshing is not done through Gmsh
*/
void
GmshExport
::
saveList
(
std
::
string
const
&
fname
,
Results
const
&
r
)
const
{
std
::
string
wname
=
fname
+
".pos"
;
std
::
cout
<<
"writing file: "
<<
wname
<<
"... "
<<
std
::
flush
;
FILE
*
file
;
file
=
fopen
(
wname
.
c_str
(),
"wt"
);
if
(
!
file
)
throw
std
::
runtime_error
(
"tbox::GmshExport::saveList Error opening file!
\n
"
);
if
(
!
r
.
scalars_at_elems
.
empty
()
||
!
r
.
vectors_at_nodes
.
empty
()
||
!
r
.
vectors_at_elems
.
empty
()
||
!
r
.
tensors_at_nodes
.
empty
()
||
!
r
.
tensors_at_elems
.
empty
())
throw
std
::
runtime_error
(
"tbox::GmshExport::saveList Only scalars_at_nodes Result type is supported!
\n
"
);
for
(
auto
&
p
:
r
.
scalars_at_nodes
)
{
// name of view
fprintf
(
file
,
"View
\"
%s
\"
{
\n
"
,
p
.
first
.
c_str
());
// element and data
for
(
auto
e
:
msh
->
elems
)
{
std
::
string
str
;
if
(
e
->
type
()
==
ElType
::
POINT1
)
{
str
=
"SP("
;
}
else
if
(
e
->
type
()
==
ElType
::
LINE2
)
{
str
=
"SL("
;
}
else
if
(
e
->
type
()
==
ElType
::
TRI3
)
{
str
=
"ST("
;
}
else
if
(
e
->
type
()
==
ElType
::
TETRA4
)
{
str
=
"SS("
;
}
else
throw
std
::
runtime_error
(
"tbox::GmshExport::saveList Element type not supported!
\n
"
);
// node coordinates and values
for
(
auto
n
:
e
->
nodes
)
str
+=
std
::
to_string
(
n
->
pos
(
0
))
+
","
+
std
::
to_string
(
n
->
pos
(
1
))
+
","
+
std
::
to_string
(
n
->
pos
(
2
))
+
","
;
str
.
erase
(
str
.
length
()
-
1
);
str
+=
"){"
;
for
(
auto
n
:
e
->
nodes
)
{
if
(
std
::
isnan
((
*
(
p
.
second
))[
n
->
row
]))
str
+=
"-nan,"
;
// find a nicer way to handle nan
else
str
+=
std
::
to_string
((
*
(
p
.
second
))[
n
->
row
])
+
","
;
}
str
.
erase
(
str
.
length
()
-
1
);
str
+=
"};
\n
"
;
fprintf
(
file
,
"%s"
,
str
.
c_str
());
}
fprintf
(
file
,
"};
\n
"
);
}
// close file
fclose
(
file
);
std
::
cout
<<
"done"
<<
std
::
endl
;
}
void
GmshExport
::
write
(
std
::
ostream
&
out
)
const
void
GmshExport
::
write
(
std
::
ostream
&
out
)
const
{
{
out
<<
"GmshExport on "
<<
*
msh
<<
std
::
endl
;
out
<<
"GmshExport on "
<<
*
msh
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
tbox/src/wGmshExport.h
+
1
−
0
View file @
fb9deb4b
...
@@ -39,6 +39,7 @@ public:
...
@@ -39,6 +39,7 @@ public:
virtual
void
save
(
std
::
string
const
&
fname
)
const
override
;
virtual
void
save
(
std
::
string
const
&
fname
)
const
override
;
#ifndef SWIG
#ifndef SWIG
virtual
void
save
(
std
::
string
const
&
fname
,
Results
const
&
r
)
const
override
;
virtual
void
save
(
std
::
string
const
&
fname
,
Results
const
&
r
)
const
override
;
virtual
void
saveList
(
std
::
string
const
&
fname
,
Results
const
&
r
)
const
override
;
#endif
#endif
virtual
void
write
(
std
::
ostream
&
out
)
const
override
;
virtual
void
write
(
std
::
ostream
&
out
)
const
override
;
...
...
This diff is collapsed.
Click to expand it.
tbox/src/wMshExport.cpp
+
4
−
0
View file @
fb9deb4b
...
@@ -32,3 +32,7 @@ void MshExport::save(std::string const &fname, Results const &r) const
...
@@ -32,3 +32,7 @@ void MshExport::save(std::string const &fname, Results const &r) const
{
{
throw
std
::
runtime_error
(
"tbox::MshExport::save not implemented!
\n
"
);
throw
std
::
runtime_error
(
"tbox::MshExport::save not implemented!
\n
"
);
}
}
void
MshExport
::
saveList
(
std
::
string
const
&
fname
,
Results
const
&
r
)
const
{
throw
std
::
runtime_error
(
"tbox::MshExport::save_ not implemented!
\n
"
);
}
This diff is collapsed.
Click to expand it.
tbox/src/wMshExport.h
+
1
−
0
View file @
fb9deb4b
...
@@ -54,6 +54,7 @@ public:
...
@@ -54,6 +54,7 @@ public:
virtual
void
save
(
std
::
string
const
&
fname
)
const
;
virtual
void
save
(
std
::
string
const
&
fname
)
const
;
#ifndef SWIG
#ifndef SWIG
virtual
void
save
(
std
::
string
const
&
fname
,
Results
const
&
r
)
const
;
virtual
void
save
(
std
::
string
const
&
fname
,
Results
const
&
r
)
const
;
virtual
void
saveList
(
std
::
string
const
&
fname
,
Results
const
&
r
)
const
;
#endif
#endif
};
};
...
...
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