Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
ag-ohlberger
dune-community
dune-xt
Commits
69338947
Commit
69338947
authored
14 years ago
by
René Fritze
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of dune-project.uni-muenster.de:projects/dune-stuff
parents
bc0985f9
447be528
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
stuff/filesystem.hh
+5
-11
5 additions, 11 deletions
stuff/filesystem.hh
stuff/math.hh
+0
-28
0 additions, 28 deletions
stuff/math.hh
stuff/matrix.hh
+40
-0
40 additions, 0 deletions
stuff/matrix.hh
stuff/profiler.hh
+88
-0
88 additions, 0 deletions
stuff/profiler.hh
with
133 additions
and
39 deletions
stuff/filesystem.hh
+
5
−
11
View file @
69338947
...
...
@@ -5,6 +5,8 @@
#include
<string>
#include
<fstream>
#include
<dune/fem/io/file/iointerface.hh>
namespace
Stuff
{
//! strip filename from \path if present, return empty string if only filename present
...
...
@@ -42,19 +44,11 @@ std::string filenameOnly(const std::string& path)
}
//! may include filename, will be stripped
bool
testCreateDirectory
(
std
::
string
path
)
void
testCreateDirectory
(
const
std
::
string
path
)
{
std
::
string
pathonly
=
pathOnly
(
path
);
if
(
pathonly
.
empty
())
return
true
;
// no dir to create
// maybe test if dir exists??
bool
ok
=
(
mkdir
(
pathonly
.
c_str
(),
0755
)
==
0
);
if
(
!
ok
)
{
perror
(
pathonly
.
c_str
());
return
errno
==
EEXIST
;
}
return
true
;
if
(
!
pathonly
.
empty
())
Dune
::
IOInterface
::
createPath
(
pathonly
);
}
//! read a file and output all lines containing filter string to a stream
...
...
This diff is collapsed.
Click to expand it.
stuff/math.hh
+
0
−
28
View file @
69338947
...
...
@@ -63,34 +63,6 @@ static RangeType1 dyadicProduct(const RangeType2& arg1, const RangeType2& arg2)
return
ret
;
}
/**
* \brief multiplies rows of arg2 with arg1
* \todo doc
**/
template
<
class
FieldMatrixImp
>
FieldMatrixImp
rowWiseMatrixMultiplication
(
const
FieldMatrixImp
&
arg1
,
const
FieldMatrixImp
&
arg2
)
{
typedef
FieldMatrixImp
FieldMatrixType
;
typedef
typename
FieldMatrixType
::
row_type
RowType
;
typedef
typename
FieldMatrixType
::
ConstRowIterator
ConstRowIteratorType
;
typedef
typename
FieldMatrixType
::
RowIterator
RowIteratorType
;
assert
(
arg2
.
rowdim
()
==
arg1
.
coldim
());
FieldMatrixType
ret
(
0.0
);
ConstRowIteratorType
arg2RowItEnd
=
arg2
.
end
();
RowIteratorType
retRowItEnd
=
ret
.
end
();
RowIteratorType
retRowIt
=
ret
.
begin
();
for
(
ConstRowIteratorType
arg2RowIt
=
arg2
.
begin
();
arg2RowIt
!=
arg2RowItEnd
,
retRowIt
!=
retRowItEnd
;
++
arg2RowIt
,
++
retRowIt
)
{
RowType
row
(
0.0
);
arg1
.
mv
(
*
arg2RowIt
,
row
);
*
retRowIt
=
row
;
}
return
ret
;
}
/** \brief a vector wrapper for continiously updating min,max,avg of some element type vector
\todo find use? it's only used in minimal as testcase for itself...
**/
...
...
This diff is collapsed.
Click to expand it.
stuff/matrix.hh
+
40
−
0
View file @
69338947
...
...
@@ -215,6 +215,35 @@ void readSparseMatrix(SparseMatrixImpl& matrix, Input& in)
}
}
/**
* \brief multiplies rows of arg2 with arg1
* \todo doc
**/
template
<
class
FieldMatrixImp
>
FieldMatrixImp
rowWiseMatrixMultiplication
(
const
FieldMatrixImp
&
arg1
,
const
FieldMatrixImp
&
arg2
)
{
typedef
FieldMatrixImp
FieldMatrixType
;
typedef
typename
FieldMatrixType
::
row_type
RowType
;
typedef
typename
FieldMatrixType
::
ConstRowIterator
ConstRowIteratorType
;
typedef
typename
FieldMatrixType
::
RowIterator
RowIteratorType
;
assert
(
arg2
.
rowdim
()
==
arg1
.
coldim
());
FieldMatrixType
ret
(
0.0
);
ConstRowIteratorType
arg2RowItEnd
=
arg2
.
end
();
RowIteratorType
retRowItEnd
=
ret
.
end
();
RowIteratorType
retRowIt
=
ret
.
begin
();
for
(
ConstRowIteratorType
arg2RowIt
=
arg2
.
begin
();
arg2RowIt
!=
arg2RowItEnd
,
retRowIt
!=
retRowItEnd
;
++
arg2RowIt
,
++
retRowIt
)
{
RowType
row
(
0.0
);
arg1
.
mv
(
*
arg2RowIt
,
row
);
*
retRowIt
=
row
;
}
return
ret
;
}
namespace
Matrix
{
//! prints actual memusage of matrix in kB
template
<
class
MatrixType
,
class
Stream
>
...
...
@@ -271,6 +300,17 @@ public:
}
}
};
template
<
class
M
>
void
forceTranspose
(
const
M
&
arg
,
M
&
dest
)
{
assert
(
arg
.
cols
()
==
dest
.
rows
());
assert
(
dest
.
cols
()
==
arg
.
rows
());
// dest.clear();
for
(
int
i
=
0
;
i
<
arg
.
cols
();
++
i
)
for
(
int
j
=
0
;
j
<
arg
.
rows
();
++
j
)
dest
.
set
(
j
,
i
,
arg
(
i
,
j
));
}
}
}
// namespace Stuff
...
...
This diff is collapsed.
Click to expand it.
stuff/profiler.hh
+
88
−
0
View file @
69338947
...
...
@@ -3,13 +3,17 @@
#include
<dune/common/exceptions.hh>
#include
<dune/fem/misc/femtimer.hh>
#include
<string>
#include
<iostream>
#include
<map>
#include
<vector>
#include
<ctime>
#include
<boost/foreach.hpp>
#include
<boost/format.hpp>
#include
<boost/date_time/posix_time/posix_time.hpp>
#include
"misc.hh"
#include
"debug.hh"
...
...
@@ -340,4 +344,88 @@ Profiler& profiler()
return
Profiler
::
instance
();
}
namespace
Stuff
{
struct
IdentityWeights
{
double
apply
(
const
double
to_weigh
,
const
int
/*current*/
,
const
int
/*max*/
)
{
return
to_weigh
;
}
};
struct
LinearWeights
{
double
apply
(
const
double
to_weigh
,
const
int
current
,
const
int
max
)
{
return
to_weigh
/
(
current
/
double
(
max
));
}
};
struct
QuadraticWeights
{
double
apply
(
const
double
to_weigh
,
const
int
current
,
const
int
max
)
{
return
to_weigh
/
std
::
pow
(
current
/
double
(
max
),
2.0
);
}
};
struct
ProgressiveWeights
{
const
int
prog_
;
ProgressiveWeights
(
const
int
prog
)
:
prog_
(
prog
)
{
}
double
apply
(
const
double
to_weigh
,
const
int
/*current*/
,
const
int
/*max*/
)
{
return
to_weigh
*
prog_
;
}
};
//! helper class to estimate time needed to complete a loop with given counter
template
<
class
CounterType
,
class
OutputStreamType
,
class
WeightType
=
IdentityWeights
>
class
LoopTimer
{
typedef
LoopTimer
<
CounterType
,
OutputStreamType
,
WeightType
>
ThisType
;
CounterType
&
counter_
;
const
int
iteration_count_
;
int
iteration_
;
OutputStreamType
&
output_stream_
;
WeightType
weight_
;
MovingAverage
avg_time_per_iteration_
;
Dune
::
ExecutionTimer
step_timer_
;
public:
LoopTimer
(
CounterType
&
counter
,
const
int
iteration_count
,
OutputStreamType
&
output_stream
=
std
::
cout
,
WeightType
weight
=
WeightType
())
:
counter_
(
counter
)
,
iteration_count_
(
iteration_count
)
,
iteration_
(
0
)
,
output_stream_
(
output_stream
)
,
weight_
(
weight
)
{
step_timer_
.
start
();
}
ThisType
&
operator
++
()
{
++
iteration_
;
step_timer_
.
end
();
avg_time_per_iteration_
+=
weight_
.
apply
(
std
::
abs
(
step_timer_
.
read
()),
iteration_
,
iteration_count_
);
long
remaining_steps
=
iteration_count_
-
iteration_
;
double
remaining_seconds
=
remaining_steps
*
double
(
avg_time_per_iteration_
);
boost
::
posix_time
::
time_duration
diff
(
0
,
0
,
remaining_seconds
,
0
);
boost
::
posix_time
::
ptime
target
=
boost
::
posix_time
::
second_clock
::
local_time
();
target
+=
diff
;
output_stream_
<<
boost
::
format
(
"
\n
---
\n
Total Time remaining: %s -- %s (%f %%)
\n
---
\n
"
)
%
boost
::
posix_time
::
to_simple_string
(
diff
)
%
boost
::
posix_time
::
to_simple_string
(
target
)
%
(
100
*
(
remaining_steps
/
double
(
iteration_count_
)))
<<
std
::
endl
;
step_timer_
.
start
();
++
counter_
;
return
*
this
;
}
};
}
// namespace Stuff
#endif // DUNE_STUFF_PROFILER_HH_INCLUDED
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