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
Aland, Sebastian
amdis
Commits
50f57133
Commit
50f57133
authored
13 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
Initfile with variable replacement
parent
5695b4dd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
AMDiS/src/Initfile.cc
+35
-6
35 additions, 6 deletions
AMDiS/src/Initfile.cc
AMDiS/src/Initfile.h
+5
-0
5 additions, 0 deletions
AMDiS/src/Initfile.h
AMDiS/src/ProblemStat.h
+6
-0
6 additions, 0 deletions
AMDiS/src/ProblemStat.h
demo/init/ellipt.dat.2d
+2
-3
2 additions, 3 deletions
demo/init/ellipt.dat.2d
with
48 additions
and
9 deletions
AMDiS/src/Initfile.cc
+
35
−
6
View file @
50f57133
...
...
@@ -46,7 +46,7 @@ namespace AMDiS {
// initialize global strcutures using parameters
Global
::
init
();
}
}
;
/// Fill an initfile from a file with filename fn
...
...
@@ -62,7 +62,7 @@ namespace AMDiS {
fn_include_list
.
insert
(
fn
);
read
(
inputFile
);
}
}
}
;
/// Fill an initfile from an input stream
...
...
@@ -80,7 +80,8 @@ namespace AMDiS {
&&
sw
[
pos0
]
!=
'#'
&&
sw
[
pos0
]
!=
0
)
{
// parse line and extract map: tag->value
Parser
parser
(
sw
);
operator
[](
parser
.
name
)
=
parser
.
value
;
operator
[](
variableReplacement
(
InitfileInternal
::
trim
(
parser
.
name
)))
=
variableReplacement
(
InitfileInternal
::
trim
(
parser
.
value
));
}
else
if
(
sw
[
pos0
]
==
'#'
&&
static_cast
<
size_t
>
(
sw
.
find
(
"#include"
))
==
pos0
)
{
// include file by '#include "filename"' or '#include <filename>'
...
...
@@ -109,7 +110,35 @@ namespace AMDiS {
}
in
.
getline
(
swap
,
line_length
);
}
}
};
std
::
string
Initfile
::
variableReplacement
(
const
std
::
string
&
input
)
const
{
std
::
string
whitespaces
=
"
\t\r\f
"
;
std
::
string
inputSwap
=
input
;
size_t
posVar
=
inputSwap
.
find_first_of
(
'$'
);
while
(
posVar
!=
string
::
npos
)
{
size_t
posVarBegin
,
posVarEnd
;
if
(
inputSwap
[
posVar
+
1
]
==
'{'
)
{
posVarEnd
=
inputSwap
.
find_first_of
(
'}'
,
posVar
+
2
);
posVarBegin
=
posVar
+
1
;
}
else
{
posVarEnd
=
inputSwap
.
find_first_of
(
whitespaces
,
posVar
+
1
);
posVarBegin
=
posVar
;
}
std
::
string
varName
=
inputSwap
.
substr
(
posVarBegin
+
1
,
posVarEnd
-
posVarBegin
-
1
);
std
::
string
varParam
=
checkedGet
(
varName
);
// if varname is found in parameter list then replace variable by value
// otherwise throw tarNotFound exception
std
::
string
replaceName
=
inputSwap
.
substr
(
posVar
,
posVarEnd
-
posVar
+
(
posVarBegin
-
posVar
));
inputSwap
.
replace
(
inputSwap
.
find
(
replaceName
),
replaceName
.
length
(),
varParam
);
posVar
=
inputSwap
.
find_first_of
(
'$'
);
}
return
inputSwap
;
};
void
Initfile
::
readArgv
(
int
argc
,
char
**
argv
)
...
...
@@ -144,7 +173,7 @@ namespace AMDiS {
if
(
msgInfo
==
0
)
paramInfo
=
0
;
}
}
;
/// print all parameters to std::cout
...
...
@@ -153,7 +182,7 @@ namespace AMDiS {
initIntern
();
for
(
Initfile
::
iterator
it
=
singlett
->
begin
();
it
!=
singlett
->
end
();
it
++
)
std
::
cout
<<
(
*
it
).
first
<<
" => "
<<
(
*
it
).
second
<<
std
::
endl
;
}
}
;
/// Write data-map to initfile
...
...
This diff is collapsed.
Click to expand it.
AMDiS/src/Initfile.h
+
5
−
0
View file @
50f57133
...
...
@@ -581,6 +581,11 @@ protected:
return
it
->
second
;
}
/// replace variables by its value defined as parameter previousely
/// variable definition is simple parameter definition
/// variable evaluation by ${variablename} or $variablename
/// the last version only for variablenames without whitespaces
std
::
string
variableReplacement
(
const
std
::
string
&
input
)
const
;
/** Fill the initfile from an input stream.
* @param in: the stream to fill the data from.
...
...
This diff is collapsed.
Click to expand it.
AMDiS/src/ProblemStat.h
+
6
−
0
View file @
50f57133
...
...
@@ -519,6 +519,12 @@ namespace AMDiS {
return
exactSolutionFcts
[
i
];
}
///
vector
<
AbstractFunction
<
double
,
WorldVector
<
double
>
>*
>
getExactSolutionFcts
()
{
return
exactSolutionFcts
;
}
///
void
setComputeExactError
(
bool
v
)
{
...
...
This diff is collapsed.
Click to expand it.
demo/init/ellipt.dat.2d
+
2
−
3
View file @
50f57133
...
...
@@ -6,10 +6,9 @@ elliptMesh->global refinements: 0
ellipt->mesh: elliptMesh
ellipt->dim: 2
ellipt->polynomial degree[0]: 1
ellipt->polynomial degree[1]: 1
ellipt->components: 2
ellipt->components: 1
ellipt->solver:
umfpack %
cg
ellipt->solver: cg
ellipt->solver->symmetric strategy: 1
ellipt->solver->store symbolic: 0
ellipt->solver->max iteration: 1000
...
...
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