Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-solvers
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
agnumpde
dune-solvers
Commits
e5439f82
Commit
e5439f82
authored
11 years ago
by
Uli Sack
Committed by
usack
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
corrected bugs introduced in yesterweeks changes
[[Imported from SVN: r12159]]
parent
0bfc50fb
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/solvers/norms/diagnorm.hh
+46
-27
46 additions, 27 deletions
dune/solvers/norms/diagnorm.hh
with
46 additions
and
27 deletions
dune/solvers/norms/diagnorm.hh
+
46
−
27
View file @
e5439f82
...
...
@@ -15,43 +15,53 @@
* \tparam Diagonal some container type having the random access operator[]; used to store the diagonal entries of the matrix
* \tparam VectorType the vector type the norm may be applied to
*/
template
<
class
Diagonal
=
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>
>
,
class
V
ectorType
=
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>
>
>
template
<
class
Diagonal
=
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>
>
,
class
V
=
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>
>
>
class
DiagNorm
:
public
Norm
<
V
ectorType
>
public
Norm
<
V
>
{
public:
typedef
V
VectorType
;
typedef
typename
VectorType
::
field_type
field_type
;
private:
typedef
typename
VectorType
::
size_type
SizeType
;
public:
DiagNorm
(
const
doubl
e
alpha
,
const
Diagonal
&
d
)
:
DiagNorm
(
const
field_typ
e
alpha
,
const
Diagonal
&
d
)
:
d
(
d
),
alpha
(
alpha
)
{}
//! Compute the norm of the given vector
double
operator
()(
const
VectorType
&
v
)
const
field_type
operator
()(
const
VectorType
&
f
)
const
{
return
std
::
sqrt
(
this
->
DiagNorm
<
Diagonal
,
VectorType
>::
normSquared
(
f
));
}
//! Compute the square of the norm of the given vector
virtual
field_type
normSquared
(
const
VectorType
&
f
)
const
{
doubl
e
r
=
0.0
;
field_typ
e
r
=
0.0
;
typename
VectorType
::
value_type
Dv
(
0.0
);
for
(
SizeType
row
=
0
;
row
<
v
.
size
();
++
row
)
for
(
SizeType
row
=
0
;
row
<
f
.
size
();
++
row
)
{
d
[
row
].
mv
(
v
[
row
],
Dv
);
r
+=
Dv
*
v
[
row
];
d
[
row
].
mv
(
f
[
row
],
Dv
);
r
+=
Dv
*
f
[
row
];
}
return
std
::
sqrt
(
std
::
abs
(
alpha
*
r
)
)
;
return
std
::
abs
(
alpha
*
r
);
}
//! Compute the norm of the difference of two vectors
doubl
e
diff
(
const
VectorType
&
v
1
,
const
VectorType
&
v
2
)
const
field_typ
e
diff
(
const
VectorType
&
f
1
,
const
VectorType
&
f
2
)
const
{
doubl
e
r
=
0.0
;
field_typ
e
r
=
0.0
;
typename
VectorType
::
value_type
Dv
(
0.0
);
for
(
SizeType
row
=
0
;
row
<
v
1
.
size
();
++
row
)
for
(
SizeType
row
=
0
;
row
<
f
1
.
size
();
++
row
)
{
d
[
row
].
mv
(
v
1
[
row
]
-
v
2
[
row
],
Dv
);
r
+=
Dv
*
(
v
1
[
row
]
-
v
2
[
row
]);
d
[
row
].
mv
(
f
1
[
row
]
-
f
2
[
row
],
Dv
);
r
+=
Dv
*
(
f
1
[
row
]
-
f
2
[
row
]);
}
return
std
::
sqrt
(
std
::
abs
(
alpha
*
r
));
...
...
@@ -60,7 +70,7 @@ class DiagNorm:
private
:
const
Diagonal
&
d
;
const
doubl
e
alpha
;
const
field_typ
e
alpha
;
};
...
...
@@ -68,33 +78,42 @@ template<>
class
DiagNorm
<
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>
>
,
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>
>
>:
public
Norm
<
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>
>
>
{
typedef
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>
>
VectorType
;
public:
typedef
double
field_type
;
typedef
Dune
::
BlockVector
<
Dune
::
FieldVector
<
field_type
,
1
>
>
VectorType
;
private:
typedef
VectorType
::
size_type
SizeType
;
public:
DiagNorm
(
const
doubl
e
alpha
,
const
VectorType
&
d
)
:
DiagNorm
(
const
field_typ
e
alpha
,
const
VectorType
&
d
)
:
d
(
d
),
alpha
(
alpha
)
{}
//! Compute the norm of the given vector
double
operator
()(
const
VectorType
&
v
)
const
field_type
operator
()(
const
VectorType
&
f
)
const
{
return
std
::
sqrt
(
this
->
DiagNorm
<>::
normSquared
(
f
));
}
//! Compute the square of the norm of the given vector
virtual
field_type
normSquared
(
const
VectorType
&
f
)
const
{
doubl
e
r
=
0.0
;
field_typ
e
r
=
0.0
;
for
(
SizeType
row
=
0
;
row
<
v
.
size
();
++
row
)
r
+=
d
[
row
]
*
v
[
row
]
*
v
[
row
];
for
(
SizeType
row
=
0
;
row
<
f
.
size
();
++
row
)
r
+=
d
[
row
]
*
f
[
row
]
*
f
[
row
];
return
std
::
sqrt
(
std
::
abs
(
alpha
*
r
)
)
;
return
std
::
abs
(
alpha
*
r
);
}
//! Compute the norm of the difference of two vectors
doubl
e
diff
(
const
VectorType
&
v
1
,
const
VectorType
&
v
2
)
const
field_typ
e
diff
(
const
VectorType
&
f
1
,
const
VectorType
&
f
2
)
const
{
doubl
e
r
=
0.0
;
field_typ
e
r
=
0.0
;
for
(
SizeType
row
=
0
;
row
<
v
1
.
size
();
++
row
)
r
+=
(
doubl
e
)
d
[
row
]
*
(
v
1
[
row
]
-
v
2
[
row
])
*
(
v
1
[
row
]
-
v
2
[
row
]);
for
(
SizeType
row
=
0
;
row
<
f
1
.
size
();
++
row
)
r
+=
(
field_typ
e
)
d
[
row
]
*
(
f
1
[
row
]
-
f
2
[
row
])
*
(
f
1
[
row
]
-
f
2
[
row
]);
return
std
::
sqrt
(
std
::
abs
(
alpha
*
r
));
}
...
...
@@ -102,7 +121,7 @@ class DiagNorm<Dune::BlockVector<Dune::FieldVector <double,1> >, Dune::BlockVect
private
:
const
VectorType
&
d
;
const
doubl
e
alpha
;
const
field_typ
e
alpha
;
};
...
...
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