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
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Timo Koch
dune-common
Commits
14c79e87
Commit
14c79e87
authored
19 years ago
by
Robert Klöfkorn
Browse files
Options
Downloads
Patches
Plain Diff
use string instead of char * .
[[Imported from SVN: r2015]]
parent
2840d0f2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
io/file/asciiparser.hh
+2
-2
2 additions, 2 deletions
io/file/asciiparser.hh
io/file/grapedataio.hh
+28
-29
28 additions, 29 deletions
io/file/grapedataio.hh
with
30 additions
and
31 deletions
io/file/asciiparser.hh
+
2
−
2
View file @
14c79e87
...
...
@@ -11,10 +11,10 @@ namespace Dune {
//! if verbose is true then an output of what was read is given
//! the token '%' stands for comment
template
<
class
T
>
bool
readParameter
(
const
char
*
filename
,
bool
readParameter
(
const
std
::
basic_string
<
char
>
filename
,
const
char
keywd
[],
T
&
data
,
bool
verbose
=
true
)
{
std
::
fstream
file
(
filename
,
std
::
ios
::
in
);
std
::
fstream
file
(
filename
.
c_str
()
,
std
::
ios
::
in
);
if
(
!
file
)
{
std
::
cerr
<<
"ERROR: cannot open file '"
<<
filename
<<
"' in "
<<
__FILE__
<<
" line: "
<<
__LINE__
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
io/file/grapedataio.hh
+
28
−
29
View file @
14c79e87
...
...
@@ -8,35 +8,35 @@
namespace
Dune
{
typedef
std
::
basic_string
<
char
>
StringType
;
typedef
std
::
basic_string
<
char
>
GrapeIO
StringType
;
/** \brief convert type to string
*/
template
<
typename
T
>
inline
StringType
typeIdentifier
()
inline
GrapeIO
StringType
typeIdentifier
()
{
StringType
tmp
=
"unknown"
;
GrapeIO
StringType
tmp
=
"unknown"
;
return
tmp
;
};
template
<
>
inline
StringType
typeIdentifier
<
float
>
()
inline
GrapeIO
StringType
typeIdentifier
<
float
>
()
{
StringType
tmp
=
"float"
;
GrapeIO
StringType
tmp
=
"float"
;
return
tmp
;
};
template
<
>
inline
StringType
typeIdentifier
<
int
>
()
inline
GrapeIO
StringType
typeIdentifier
<
int
>
()
{
StringType
tmp
=
"int"
;
GrapeIO
StringType
tmp
=
"int"
;
return
tmp
;
};
template
<
>
inline
StringType
typeIdentifier
<
double
>
()
inline
GrapeIO
StringType
typeIdentifier
<
double
>
()
{
StringType
tmp
=
"double"
;
GrapeIO
StringType
tmp
=
"double"
;
return
tmp
;
};
...
...
@@ -56,12 +56,12 @@ namespace Dune {
* generated out of filename and timestep
*/
inline
bool
writeGrid
(
const
GridType
&
grid
,
const
FileFormatType
ftype
,
const
char
*
fnprefix
const
FileFormatType
ftype
,
const
GrapeIOStringType
fnprefix
,
double
time
=
0.0
,
int
timestep
=
0
,
int
precision
=
6
);
//! get Grid from file with time and timestep , return true if ok
inline
bool
readGrid
(
GridType
&
grid
,
const
char
*
fnprefix
,
double
&
time
,
int
timestep
);
const
GrapeIOStringType
fnprefix
,
double
&
time
,
int
timestep
);
/**
...
...
@@ -72,20 +72,20 @@ namespace Dune {
//! discrete function
template
<
class
DiscreteFunctionType
>
inline
bool
writeData
(
DiscreteFunctionType
&
df
,
const
FileFormatType
ftype
,
const
char
*
filename
,
const
FileFormatType
ftype
,
const
GrapeIOStringType
filename
,
int
timestep
,
int
precision
=
6
);
//! same as write only read
template
<
class
DiscreteFunctionType
>
inline
bool
readData
(
DiscreteFunctionType
&
df
,
const
char
*
filename
,
int
timestep
);
const
GrapeIOStringType
filename
,
int
timestep
);
};
template
<
class
GridType
>
inline
bool
GrapeDataIO
<
GridType
>
::
writeGrid
(
const
GridType
&
grid
,
const
FileFormatType
ftype
,
const
char
*
fnprefix
,
const
FileFormatType
ftype
,
const
GrapeIOStringType
fnprefix
,
double
time
,
int
timestep
,
int
precision
)
{
const
char
*
path
=
0
;
...
...
@@ -94,12 +94,12 @@ namespace Dune {
file
<<
"Format: "
<<
ftype
<<
std
::
endl
;
file
<<
"Precision: "
<<
precision
<<
std
::
endl
;
const
char
*
fn
=
genFilename
(
path
,
fnprefix
,
timestep
,
precision
);
const
GrapeIOStringType
fnstr
=
genFilename
(
path
,
fnprefix
,
timestep
,
precision
);
file
.
close
();
switch
(
ftype
)
{
case
xdr
:
return
grid
.
template
writeGrid
<
xdr
>
(
fn
,
time
);
case
ascii
:
return
grid
.
template
writeGrid
<
ascii
>(
fn
,
time
);
case
xdr
:
return
grid
.
template
writeGrid
<
xdr
>
(
fn
str
,
time
);
case
ascii
:
return
grid
.
template
writeGrid
<
ascii
>(
fn
str
,
time
);
default
:
{
std
::
cerr
<<
ftype
<<
" FileFormatType not supported at the moment! "
<<
__FILE__
<<
__LINE__
<<
"
\n
"
;
...
...
@@ -114,9 +114,8 @@ namespace Dune {
template
<
class
GridType
>
inline
bool
GrapeDataIO
<
GridType
>
::
readGrid
(
GridType
&
grid
,
const
char
*
fnprefix
,
double
&
time
,
int
timestep
)
(
GridType
&
grid
,
const
GrapeIOStringType
fnprefix
,
double
&
time
,
int
timestep
)
{
const
char
*
fn
;
int
helpType
;
char
gridname
[
1024
];
...
...
@@ -136,7 +135,7 @@ namespace Dune {
readParameter
(
fnprefix
,
"Precision"
,
precision
);
const
char
*
path
=
0
;
fn
=
genFilename
(
path
,
fnprefix
,
timestep
,
precision
);
GrapeIOStringType
fn
=
genFilename
(
path
,
fnprefix
,
timestep
,
precision
);
printf
(
"Read file: fnprefix = `%s'
\n
"
,
fn
);
switch
(
ftype
)
...
...
@@ -157,7 +156,7 @@ namespace Dune {
template
<
class
GridType
>
template
<
class
DiscreteFunctionType
>
inline
bool
GrapeDataIO
<
GridType
>
::
writeData
(
DiscreteFunctionType
&
df
,
const
FileFormatType
ftype
,
const
char
*
filename
,
int
timestep
,
int
precision
)
const
FileFormatType
ftype
,
const
GrapeIOStringType
filename
,
int
timestep
,
int
precision
)
{
{
typedef
typename
DiscreteFunctionType
::
FunctionSpaceType
DiscreteFunctionSpaceType
;
...
...
@@ -168,8 +167,8 @@ namespace Dune {
enum
{
m
=
DiscreteFunctionSpaceType
::
DimRange
};
std
::
fstream
file
(
filename
,
std
::
ios
::
out
);
StringType
d
=
typeIdentifier
<
DomainFieldType
>
();
StringType
r
=
typeIdentifier
<
RangeFieldType
>
();
GrapeIO
StringType
d
=
typeIdentifier
<
DomainFieldType
>
();
GrapeIO
StringType
r
=
typeIdentifier
<
RangeFieldType
>
();
file
<<
"DomainField: "
<<
d
<<
std
::
endl
;
file
<<
"RangeField: "
<<
r
<<
std
::
endl
;
...
...
@@ -183,7 +182,7 @@ namespace Dune {
}
const
char
*
path
=
0
;
const
char
*
fn
=
genFilename
(
path
,
filename
,
timestep
,
precision
);
GrapeIOStringType
fn
=
genFilename
(
path
,
filename
,
timestep
,
precision
);
if
(
ftype
==
xdr
)
return
df
.
write_xdr
(
fn
);
...
...
@@ -198,7 +197,7 @@ namespace Dune {
template
<
class
GridType
>
template
<
class
DiscreteFunctionType
>
inline
bool
GrapeDataIO
<
GridType
>
::
readData
(
DiscreteFunctionType
&
df
,
const
char
*
filename
,
int
timestep
)
readData
(
DiscreteFunctionType
&
df
,
const
GrapeIOStringType
filename
,
int
timestep
)
{
typedef
typename
DiscreteFunctionType
::
FunctionSpaceType
DiscreteFunctionSpaceType
;
typedef
typename
DiscreteFunctionSpaceType
::
DomainField
DomainFieldType
;
...
...
@@ -208,9 +207,9 @@ namespace Dune {
enum
{
tm
=
DiscreteFunctionSpaceType
::
DimRange
};
int
n
,
m
;
std
::
basic_string
<
char
>
r
,
d
;
std
::
basic_string
<
char
>
tr
(
typeIdentifier
<
RangeFieldType
>
());
std
::
basic_string
<
char
>
td
(
typeIdentifier
<
DomainFieldType
>
());
GrapeIOStringType
r
,
d
;
GrapeIOStringType
tr
(
typeIdentifier
<
RangeFieldType
>
());
GrapeIOStringType
td
(
typeIdentifier
<
DomainFieldType
>
());
readParameter
(
filename
,
"DomainField"
,
d
,
false
);
readParameter
(
filename
,
"RangeField"
,
r
,
false
);
...
...
@@ -235,7 +234,7 @@ namespace Dune {
}
const
char
*
path
=
0
;
const
char
*
fn
=
genFilename
(
path
,
filename
,
timestep
,
precision
);
GrapeIOStringType
fn
=
genFilename
(
path
,
filename
,
timestep
,
precision
);
if
(
ftype
==
xdr
)
return
df
.
read_xdr
(
fn
);
...
...
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