Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis
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
Container registry
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iwr
amdis
Commits
5f59d416
Commit
5f59d416
authored
15 years ago
by
Backofen, Rainer
Browse files
Options
Downloads
Patches
Plain Diff
GridWriter extended to vector of Dof's and add control for precission for output
parent
1213fbef
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
AMDiS/src/GridWriter.h
+11
-2
11 additions, 2 deletions
AMDiS/src/GridWriter.h
AMDiS/src/GridWriter.hh
+120
-2
120 additions, 2 deletions
AMDiS/src/GridWriter.hh
with
131 additions
and
4 deletions
AMDiS/src/GridWriter.h
+
11
−
2
View file @
5f59d416
...
...
@@ -35,7 +35,7 @@ namespace AMDiS {
class
GridWriter
{
public:
/** \brief
* Produces a grid-based output of a dof-vector
* Produces a grid-based output of a dof-vector
or vector of dof-vectors
* \param p array of world coordinates.
* - p[0] defines origin of grid-system.
* - p[1] defines first basis vector by p[1] - p[0].
...
...
@@ -51,12 +51,21 @@ namespace AMDiS {
* - dist[2] distance in the third direction
* \param vec DOFVector which is interpolated to the grid.
* \param filename file to which the grid will be written
* \param outFilePrecision precision used to write file
*/
static
void
writeGrid
(
const
WorldVector
<
double
>
*
p
,
int
*
numPoints
,
double
*
dist
,
DOFVector
<
T
>
*
vec
,
char
*
filename
);
const
char
*
filename
,
int
outFilePrecision
=
6
);
static
void
writeGrid
(
const
WorldVector
<
double
>
*
p
,
int
*
numPoints
,
double
*
dist
,
std
::
vector
<
DOFVector
<
T
>
*
>
vec
,
const
char
*
filename
,
int
outFilePrecision
=
6
);
};
}
...
...
This diff is collapsed.
Click to expand it.
AMDiS/src/GridWriter.hh
+
120
−
2
View file @
5f59d416
...
...
@@ -12,7 +12,8 @@ namespace AMDiS {
int
*
numPoints
,
double
*
dist
,
DOFVector
<
T
>
*
vec
,
char
*
filename
)
const
char
*
filename
,
int
outFilePrecision
)
{
FUNCNAME
(
"GridWriter<T>::writeGrid()"
);
...
...
@@ -20,7 +21,9 @@ namespace AMDiS {
TEST_EXIT
(
filename
)(
"no filename
\n
"
);
TEST_EXIT
(
vec
->
getFESpace
()
->
getBasisFcts
())(
"no basis fcts
\n
"
);
std
::
ofstream
outFile
=
std
::
ofstream
(
filename
);
std
::
ofstream
outFile
(
filename
);
outFile
.
precision
(
outFilePrecision
);
outFile
.
setf
(
std
::
ios_base
::
scientific
);
const
Mesh
*
mesh
=
vec
->
getFESpace
()
->
getMesh
();
int
dim
=
mesh
->
getDim
();
...
...
@@ -115,4 +118,119 @@ namespace AMDiS {
delete
[]
step
;
}
template
<
typename
T
>
void
GridWriter
<
T
>::
writeGrid
(
const
WorldVector
<
double
>
*
p
,
int
*
numPoints
,
double
*
dist
,
std
::
vector
<
DOFVector
<
T
>
*
>
vec
,
const
char
*
filename
,
int
outFilePrecision
)
{
FUNCNAME
(
"GridWriter<T>::writeGrid()"
);
TEST_EXIT
(
vec
.
size
()
>
0
)(
"no dof vector
\n
"
);
TEST_EXIT
(
filename
)(
"no filename
\n
"
);
TEST_EXIT
(
vec
[
0
]
->
getFESpace
()
->
getBasisFcts
())(
"no basis fcts
\n
"
);
std
::
ofstream
outFile
(
filename
);
outFile
.
precision
(
outFilePrecision
);
outFile
.
setf
(
std
::
ios_base
::
scientific
);
const
Mesh
*
mesh
=
vec
[
0
]
->
getFESpace
()
->
getMesh
();
int
dim
=
mesh
->
getDim
();
TEST_EXIT
(
dim
==
Global
::
getGeo
(
WORLD
))(
"not for DIM != DIM_OF_WORLD
\n
"
);
WorldVector
<
double
>
*
basis
=
new
WorldVector
<
double
>
[
dim
];
double
*
lengthBasis
=
new
double
[
dim
];
WorldVector
<
double
>
*
step
=
new
WorldVector
<
double
>
[
3
];
for
(
int
i
=
0
;
i
<
dim
;
i
++
)
{
TEST_EXIT
(
numPoints
[
i
]
>
0
)(
"numPoints < 1
\n
"
);
TEST_EXIT
(
dist
[
i
]
>=
0
)(
"dist < 0
\n
"
);
lengthBasis
[
i
]
=
0
;
}
WorldVector
<
double
>
curCoord
;
DimVec
<
double
>
bary
(
dim
,
NO_INIT
);
Element
*
elp
;
const
BasisFunction
*
basFcts
=
vec
[
0
]
->
getFESpace
()
->
getBasisFcts
();
const
double
*
uhLoc
;
// get basis of grid
for
(
int
i
=
0
;
i
<
dim
;
i
++
)
{
for
(
int
j
=
0
;
j
<
dim
;
j
++
)
{
basis
[
i
][
j
]
=
p
[
i
+
1
][
j
]
-
p
[
0
][
j
];
lengthBasis
[
i
]
+=
basis
[
i
][
j
]
*
basis
[
i
][
j
];
}
lengthBasis
[
i
]
=
sqrt
(
lengthBasis
[
i
]);
}
// norm basis, get steps
for
(
int
i
=
0
;
i
<
dim
;
i
++
)
{
for
(
int
j
=
0
;
j
<
dim
;
j
++
)
{
basis
[
i
][
j
]
/=
lengthBasis
[
i
];
step
[
i
][
j
]
=
basis
[
i
][
j
]
*
dist
[
j
];
}
}
/* write grid points */
int
localNumPoints
[
3
]
=
{
1
,
1
,
1
};
for
(
int
i
=
0
;
i
<
dim
;
i
++
)
localNumPoints
[
i
]
=
numPoints
[
i
];
// Warning "Coords not in mesh domain" should be printed at most one time.
bool
warning
=
false
;
for
(
int
i
=
0
;
i
<
localNumPoints
[
0
];
i
++
)
{
for
(
int
j
=
0
;
j
<
localNumPoints
[
1
];
j
++
)
{
// pseudo-loop for dim < 2
for
(
int
k
=
0
;
k
<
localNumPoints
[
2
];
k
++
)
{
// pseudo-loop for dim < 3
// clac current coords
for
(
int
l
=
0
;
l
<
dim
;
l
++
)
{
curCoord
[
l
]
=
p
[
0
][
l
]
+
(
i
*
step
[
0
][
l
])
+
(
j
*
step
[
1
][
l
])
// j = 0 for dim > 1
+
(
k
*
step
[
2
][
l
]);
// k = 0 for dim > 2
}
int
inside
=
(
const_cast
<
Mesh
*>
(
mesh
))
->
findElementAtPoint
(
curCoord
,
&
elp
,
bary
,
NULL
,
NULL
,
NULL
);
// write coords
for
(
int
l
=
0
;
l
<
dim
;
l
++
)
outFile
<<
curCoord
[
l
]
<<
" "
;
if
(
!
inside
)
{
if
(
!
warning
)
{
WARNING
(
"Coords not in mesh domain
\n
"
);
warning
=
true
;
}
// write value
outFile
<<
"0.0"
<<
std
::
endl
;
}
else
{
// get value at coords
double
value
;
for
(
int
rr
=
0
;
rr
<
vec
.
size
();
rr
++
)
{
uhLoc
=
vec
[
rr
]
->
getLocalVector
(
elp
,
NULL
);
value
=
basFcts
->
evalUh
(
bary
,
uhLoc
);
/* write value */
outFile
<<
value
<<
"
\t
"
;
}
outFile
<<
std
::
endl
;
}
}
if
(
localNumPoints
[
2
]
>
1
)
outFile
<<
std
::
endl
;
}
if
(
localNumPoints
[
1
]
>
1
)
outFile
<<
std
::
endl
;
}
delete
[]
basis
;
delete
[]
lengthBasis
;
delete
[]
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