Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Tobias Leibner
dune-common
Commits
239180e6
Commit
239180e6
authored
20 years ago
by
Oliver Sander
Browse files
Options
Downloads
Patches
Plain Diff
Hack: a method for writing BlockVectors as AmiraMesh files
[[Imported from SVN: r1112]]
parent
79d81d37
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
io/file/amiramesh/amirameshwriter.cc
+54
-9
54 additions, 9 deletions
io/file/amiramesh/amirameshwriter.cc
io/file/amirameshwriter.hh
+4
-1
4 additions, 1 deletion
io/file/amirameshwriter.hh
with
58 additions
and
10 deletions
io/file/amiramesh/amirameshwriter.cc
+
54
−
9
View file @
239180e6
...
...
@@ -4,6 +4,8 @@
#include
<algorithm>
#include
<dune/istl/bvector.hh>
#if _3
/** \todo Make sure that the grid is three-dimensional */
template
<
class
GridType
,
class
DiscFuncType
>
...
...
@@ -28,7 +30,6 @@ void Dune::AmiraMeshWriter<GridType, DiscFuncType>::writeGrid(const GridType& gr
}
}
printf
(
"This is the AmiraMesh writer!
\n
"
);
int
maxVerticesPerElement
=
(
containsOnlyTetrahedra
)
?
4
:
8
;
const
int
DIM
=
3
;
...
...
@@ -179,7 +180,6 @@ void Dune::AmiraMeshWriter<GridType, DiscFuncType>::writeGrid(const GridType& gr
}
}
printf
(
"This is the 2D AmiraMesh writer!
\n
"
);
int
maxVerticesPerElement
=
(
containsOnlyTetrahedra
)
?
3
:
4
;
const
int
DIM
=
2
;
...
...
@@ -187,14 +187,9 @@ void Dune::AmiraMeshWriter<GridType, DiscFuncType>::writeGrid(const GridType& gr
int
noOfNodes
=
grid
.
size
(
level
,
DIM
);
int
noOfElem
=
grid
.
size
(
level
,
0
);
printf
(
"noOfNodes %d, nodeOfElem: %d
\n
"
,
noOfNodes
,
noOfElem
);
int
i
;
//int tl, k, noOfBndTri, MarkKey, ncomp, maxSubDom;
std
::
string
solFilename
;
// Construct the name for the
geometry
file
// Construct the name for the file
std
::
string
geoFilename
(
filename
);
geoFilename
+=
".am"
;
...
...
@@ -264,7 +259,6 @@ void Dune::AmiraMeshWriter<GridType, DiscFuncType>::writeGrid(const GridType& gr
McPrimType
::
mc_int32
,
maxVerticesPerElement
);
am_geometry
.
insert
(
element_data
);
//int *(dPtr[maxVerticesPerElement]) = (int*)element_data->dataPtr();
int
*
dPtr
=
(
int
*
)
element_data
->
dataPtr
();
typename
GridType
::
template
Traits
<
0
>
::
LevelIterator
element2
=
grid
.
template
lbegin
<
0
>(
level
);
...
...
@@ -357,3 +351,54 @@ void Dune::AmiraMeshWriter<GridType, DiscFuncType>::writeFunction(const DiscFunc
std
::
cout
<<
"Solution written successfully to: "
<<
filename
<<
std
::
endl
;
}
template
<
class
GridType
,
class
DiscFuncType
>
void
Dune
::
AmiraMeshWriter
<
GridType
,
DiscFuncType
>::
writeBlockVector
(
const
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
3
>
>&
f
,
const
std
::
string
&
filename
)
{
typedef
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
3
>
>
VectorType
;
// Get number of components
/** \todo Must depend on the BlockVector and not on the grid! */
const
int
ncomp
=
GridType
::
dimension
;
// Create AmiraMesh object
AmiraMesh
am
;
// Set the appropriate content type for 2D grid data
if
(
GridType
::
dimension
==
2
)
am
.
parameters
.
set
(
"ContentType"
,
"HxTriangularData"
);
AmiraMesh
::
Location
*
sol_nodes
=
new
AmiraMesh
::
Location
(
"Nodes"
,
f
.
size
());
am
.
insert
(
sol_nodes
);
AmiraMesh
::
Data
*
nodeData
=
new
AmiraMesh
::
Data
(
"Data"
,
sol_nodes
,
McPrimType
::
mc_double
,
ncomp
);
am
.
insert
(
nodeData
);
AmiraMesh
::
Field
*
nodeField
=
new
AmiraMesh
::
Field
(
"sol"
,
ncomp
,
McPrimType
::
mc_double
,
AmiraMesh
::
t_linear
,
nodeData
);
am
.
insert
(
nodeField
);
// write the data into the AmiraMesh object
typedef
typename
VectorType
::
ConstIterator
Iterator
;
Iterator
dit
=
f
.
begin
();
Iterator
ditend
=
f
.
end
();
int
i
=
0
;
for
(;
dit
!=
ditend
;
++
dit
)
{
for
(
int
j
=
0
;
j
<
ncomp
;
j
++
)
((
double
*
)
nodeData
->
dataPtr
())[
i
++
]
=
(
*
dit
)[
j
];
}
// actually save the solution file
// (the 1 means: ascii)
if
(
!
am
.
write
(
filename
.
c_str
(),
1
)
)
DUNE_THROW
(
IOError
,
"An error has occured writing file "
<<
filename
);
std
::
cout
<<
"Solution written successfully to: "
<<
filename
<<
std
::
endl
;
}
This diff is collapsed.
Click to expand it.
io/file/amirameshwriter.hh
+
4
−
1
View file @
239180e6
...
...
@@ -4,6 +4,7 @@
#define __DUNE_AMIRAMESHWRITER_HH__
#include
<string>
#include
<dune/istl/bvector.hh>
namespace
Dune
{
...
...
@@ -41,6 +42,8 @@ namespace Dune {
static
void
writeFunction
(
const
DiscFuncType
&
f
,
const
std
::
string
&
filename
);
static
void
writeBlockVector
(
const
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
3
>
>&
f
,
const
std
::
string
&
filename
);
AmiraMeshWriter
()
{}
};
...
...
@@ -51,6 +54,6 @@ namespace Dune {
#include
"amiramesh/amirameshwriter.cc"
// the amiramesh writer for SGrid
#include
"amiramesh/amsgridwriter.cc"
//
#include "amiramesh/amsgridwriter.cc"
#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