Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Aland, Sebastian
amdis
Commits
705566b3
Commit
705566b3
authored
Jun 11, 2012
by
Praetorius, Simon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initfile-parser extended
parent
694a35a3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
30 deletions
+63
-30
AMDiS/src/AMDiS.cc
AMDiS/src/AMDiS.cc
+4
-1
AMDiS/src/DOFIndexed.h
AMDiS/src/DOFIndexed.h
+10
-4
AMDiS/src/Global.h
AMDiS/src/Global.h
+15
-0
AMDiS/src/Initfile.cc
AMDiS/src/Initfile.cc
+32
-13
AMDiS/src/Initfile.h
AMDiS/src/Initfile.h
+1
-11
AMDiS/src/io/VtkWriter.cc
AMDiS/src/io/VtkWriter.cc
+1
-1
No files found.
AMDiS/src/AMDiS.cc
View file @
705566b3
...
...
@@ -41,7 +41,10 @@ namespace AMDiS {
Zoltan_Initialize
(
argc
,
argv
,
&
zoltanVersion
);
#endif
#endif
Parameters
::
clearData
();
Parameters
::
readArgv
(
argc
,
argv
);
if
(
initFileName
==
""
)
{
TEST_EXIT
(
argc
>=
2
)(
"No init file!
\n
"
);
Parameters
::
init
(
string
(
argv
[
1
]));
...
...
AMDiS/src/DOFIndexed.h
View file @
705566b3
...
...
@@ -92,20 +92,26 @@ namespace AMDiS {
template
<
typename
T
>
class
DOFIndexed
:
public
DOFIndexedBase
{
public:
typedef
T
value_type
;
typedef
DegreeOfFreedom
size_type
;
typedef
value_type
&
reference
;
typedef
value_type
const
&
const_reference
;
public:
virtual
~
DOFIndexed
()
{}
/// Returns iterator to the begin of container
virtual
typename
std
::
vector
<
T
>::
iterator
begin
()
=
0
;
virtual
typename
std
::
vector
<
value_type
>::
iterator
begin
()
=
0
;
/// Returns iterator to the end of container
virtual
typename
std
::
vector
<
T
>::
iterator
end
()
=
0
;
virtual
typename
std
::
vector
<
value_type
>::
iterator
end
()
=
0
;
/// Returns container element at index i
virtual
T
&
operator
[](
DegreeOfFreedom
i
)
=
0
;
virtual
reference
operator
[](
size_type
i
)
=
0
;
/// Returns container element at index i
virtual
const
T
&
operator
[](
DegreeOfFreedom
i
)
const
=
0
;
virtual
const
_reference
operator
[](
size_type
i
)
const
=
0
;
};
void
mv
(
MatrixTranspose
transpose
,
...
...
AMDiS/src/Global.h
View file @
705566b3
...
...
@@ -57,6 +57,7 @@
#endif
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/trim.hpp>
#include "boost/tuple/tuple.hpp"
#include "AMDiS_fwd.h"
...
...
@@ -123,6 +124,20 @@ namespace AMDiS {
}
};
/// check for file existence
inline
bool
file_exists
(
const
std
::
string
filename
)
{
return
access
(
filename
.
c_str
(),
F_OK
)
==
0
;
};
/// trim std::string
inline
std
::
string
trim
(
const
std
::
string
&
oldStr
)
{
std
::
string
swap
(
oldStr
);
boost
::
algorithm
::
trim
(
swap
);
return
swap
;
};
// ===== some simple template functions ======================================
template
<
typename
T
>
inline
T
abs
(
T
a
)
...
...
AMDiS/src/Initfile.cc
View file @
705566b3
...
...
@@ -39,7 +39,6 @@ namespace AMDiS {
void
Initfile
::
init
(
std
::
string
in
)
{
initIntern
();
singlett
->
clear
();
fn_include_list
.
clear
();
singlett
->
read
(
in
);
singlett
->
getInternalParameters
();
...
...
@@ -84,8 +83,8 @@ namespace AMDiS {
Parser
parser
(
sw
);
// add parameter to map after variable replacement
std
::
string
paramName
=
variableReplacement
(
InitfileInternal
::
trim
(
parser
.
name
));
std
::
string
paramValue
=
variableReplacement
(
InitfileInternal
::
trim
(
parser
.
value
));
std
::
string
paramName
=
variableReplacement
(
trim
(
parser
.
name
));
std
::
string
paramValue
=
variableReplacement
(
trim
(
parser
.
value
));
paramValue
=
variableEvaluation
(
paramValue
);
operator
[](
paramName
)
=
paramValue
;
...
...
@@ -164,7 +163,7 @@ namespace AMDiS {
std
::
string
replaceName
=
inputSwap
.
substr
(
posVar
,
posVarEnd
-
posVar
+
(
posVarBegin
-
posVar
));
inputSwap
.
replace
(
inputSwap
.
find
(
replaceName
),
replaceName
.
length
(),
varParam
);
posVar
=
inputSwap
.
find_first_of
(
'$'
,
posVar
End
);
posVar
=
inputSwap
.
find_first_of
(
'$'
,
posVar
Begin
);
}
return
inputSwap
;
...
...
@@ -174,16 +173,11 @@ namespace AMDiS {
{
std
::
string
whitespaces
=
"
\t\r\f
"
;
std
::
string
inputSwap
=
input
;
size_t
posVar
=
inputSwap
.
find
_first_of
(
'$'
);
size_t
posVar
=
inputSwap
.
find
(
"$("
);
while
(
posVar
!=
string
::
npos
)
{
size_t
posVarBegin
,
posVarEnd
;
if
(
inputSwap
[
posVar
+
1
]
==
'('
)
{
// $(expr)
posVarEnd
=
inputSwap
.
find_first_of
(
')'
,
posVar
+
2
);
posVarBegin
=
posVar
+
1
;
}
else
{
posVar
=
inputSwap
.
find_first_of
(
'$'
,
posVar
+
1
);
continue
;
}
posVarEnd
=
inputSwap
.
find_first_of
(
')'
,
posVar
+
2
);
posVarBegin
=
posVar
+
1
;
std
::
string
varName
=
inputSwap
.
substr
(
posVarBegin
+
1
,
posVarEnd
-
posVarBegin
-
1
);
double
value
=
0.0
;
...
...
@@ -193,7 +187,7 @@ namespace AMDiS {
std
::
string
replaceName
=
inputSwap
.
substr
(
posVar
,
posVarEnd
-
posVar
+
(
posVarBegin
-
posVar
));
inputSwap
.
replace
(
inputSwap
.
find
(
replaceName
),
replaceName
.
length
(),
varName
);
posVar
=
inputSwap
.
find
_first_of
(
'$'
);
posVar
=
inputSwap
.
find
(
"$("
,
posVarBegin
);
}
return
inputSwap
;
...
...
@@ -201,11 +195,36 @@ namespace AMDiS {
void
Initfile
::
readArgv
(
int
argc
,
char
**
argv
)
{
initIntern
();
for
(
int
i
=
0
;
i
<
argc
;
i
++
)
{
if
(
strcmp
(
"-rs"
,
argv
[
i
])
==
0
)
{
std
::
string
input
(
argv
[
i
+
1
]);
add
(
"argv->rs"
,
input
,
0
);
}
else
if
(
strcmp
(
"-parameters"
,
argv
[
i
])
==
0
)
{
std
::
string
input
(
argv
[
i
+
1
]);
int
found
=
input
.
find_first_of
(
';'
);
std
::
vector
<
std
::
string
>
parameters
;
while
(
found
!=
static_cast
<
int
>
(
std
::
string
::
npos
))
{
if
(
found
>
2
)
{
parameters
.
push_back
(
input
.
substr
(
0
,
found
).
c_str
());
}
input
=
input
.
substr
(
found
+
1
);
found
=
input
.
find_first_of
(
';'
);
}
if
(
input
.
length
()
>
2
)
parameters
.
push_back
(
input
.
c_str
());
for
(
size_t
i
=
0
;
i
<
parameters
.
size
();
i
++
)
{
int
found
=
input
.
find_first_of
(
':'
);
if
(
found
!=
static_cast
<
int
>
(
std
::
string
::
npos
))
{
std
::
string
value
=
input
.
substr
(
found
+
1
);
set
(
input
.
substr
(
0
,
found
),
value
,
0
);
}
}
}
}
}
...
...
AMDiS/src/Initfile.h
View file @
705566b3
...
...
@@ -24,7 +24,6 @@
#include <typeinfo>
#include "FixVec.h"
#include <boost/algorithm/string/trim.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/numeric/conversion/cast.hpp>
...
...
@@ -132,16 +131,7 @@ namespace AMDiS {
">
\n
Parser message: '"
+
m
+
"'"
)
{}
};
/// trim std::string
inline
std
::
string
trim
(
const
std
::
string
&
oldStr
)
{
std
::
string
swap
(
oldStr
);
boost
::
algorithm
::
trim
(
swap
);
return
swap
;
}
/// return the delimiter or throw an exception if there is no known
/// delimiter in value
...
...
AMDiS/src/io/VtkWriter.cc
View file @
705566b3
...
...
@@ -199,7 +199,7 @@ namespace AMDiS {
{
WorldVector
<
DOFVector
<
double
>*>
valuesWV
;
for
(
int
i
=
0
;
i
<
valuesWV
.
getSize
();
i
++
)
valuesWV
[
i
]
=
new
DOFVector
<
double
>
(
values
->
getFeSpace
(),
"values
WV_i
"
);
valuesWV
[
i
]
=
new
DOFVector
<
double
>
(
values
->
getFeSpace
(),
"values
["
+
boost
::
lexical_cast
<
std
::
string
>
(
i
)
+
"]
"
);
transform
(
values
,
&
valuesWV
);
writeFile
(
valuesWV
,
filename
,
writeParallel
);
for
(
int
i
=
0
;
i
<
valuesWV
.
getSize
();
i
++
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment