Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-tectonic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
podlesny
dune-tectonic
Commits
b362f667
Commit
b362f667
authored
13 years ago
by
Elias Pipping
Committed by
Elias Pipping
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add a copy of ConvexProblem as MyConvexProblem
parent
1c2d7d26
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/myblockproblem.hh
+15
-15
15 additions, 15 deletions
src/myblockproblem.hh
src/myconvexproblem.hh
+55
-0
55 additions, 0 deletions
src/myconvexproblem.hh
src/one-body-sample.cc
+7
-5
7 additions, 5 deletions
src/one-body-sample.cc
with
77 additions
and
20 deletions
src/myblockproblem.hh
+
15
−
15
View file @
b362f667
...
...
@@ -4,7 +4,7 @@
#include
<dune/common/bitsetvector.hh>
#include
<dune/tnnmg/problem-classes/bisection.hh>
#include
<dune/tnnmg/problem-classes/convexproblem.hh>
//
#include <dune/tnnmg/problem-classes/convexproblem.hh>
#include
<dune/tnnmg/problem-classes/nonlinearity.hh>
#include
<dune/tnnmg/problem-classes/onedconvexfunction.hh>
...
...
@@ -14,21 +14,21 @@
/** \brief Base class for problems where each block can be solved with a scalar
* Gauss-Seidel method */
template
<
class
ConvexProblemTypeTEMPLATE
>
class
MyBlockProblem
{
template
<
class
My
ConvexProblemTypeTEMPLATE
>
class
MyBlockProblem
{
public:
typedef
ConvexProblemTypeTEMPLATE
ConvexProblemType
;
typedef
typename
ConvexProblemType
::
NonlinearityType
NonlinearityType
;
typedef
typename
ConvexProblemType
::
VectorType
VectorType
;
typedef
typename
ConvexProblemType
::
MatrixType
MatrixType
;
typedef
typename
ConvexProblemType
::
LocalVectorType
LocalVectorType
;
typedef
typename
ConvexProblemType
::
LocalMatrixType
LocalMatrixType
;
typedef
My
ConvexProblemTypeTEMPLATE
My
ConvexProblemType
;
typedef
typename
My
ConvexProblemType
::
NonlinearityType
NonlinearityType
;
typedef
typename
My
ConvexProblemType
::
VectorType
VectorType
;
typedef
typename
My
ConvexProblemType
::
MatrixType
MatrixType
;
typedef
typename
My
ConvexProblemType
::
LocalVectorType
LocalVectorType
;
typedef
typename
My
ConvexProblemType
::
LocalMatrixType
LocalMatrixType
;
static
const
int
block_size
=
ConvexProblemType
::
block_size
;
static
const
int
block_size
=
My
ConvexProblemType
::
block_size
;
/** \brief Solves one local system using a scalar Gauss-Seidel method */
class
IterateObject
;
MyBlockProblem
(
ConvexProblemType
&
problem
)
:
problem
(
problem
)
{
MyBlockProblem
(
My
ConvexProblemType
&
problem
)
:
problem
(
problem
)
{
bisection
=
Bisection
(
0.0
,
1.0
,
1e-15
,
true
,
1e-14
);
};
...
...
@@ -37,15 +37,15 @@ template <class ConvexProblemTypeTEMPLATE> class MyBlockProblem {
private
:
// problem data
ConvexProblemType
&
problem
;
My
ConvexProblemType
&
problem
;
// commonly used minimization stuff
Bisection
bisection
;
};
/** \brief Solves one local system using a scalar Gauss-Seidel method */
template
<
class
ConvexProblemTypeTEMPLATE
>
class
MyBlockProblem
<
ConvexProblemTypeTEMPLATE
>::
IterateObject
{
template
<
class
My
ConvexProblemTypeTEMPLATE
>
class
MyBlockProblem
<
My
ConvexProblemTypeTEMPLATE
>::
IterateObject
{
friend
class
MyBlockProblem
;
protected:
...
...
@@ -54,7 +54,7 @@ class MyBlockProblem<ConvexProblemTypeTEMPLATE>::IterateObject {
* \param problem The problem including quadratic part and nonlinear/nonsmooth
* part
*/
IterateObject
(
const
Bisection
&
bisection
,
ConvexProblemType
&
problem
)
IterateObject
(
const
Bisection
&
bisection
,
My
ConvexProblemType
&
problem
)
:
problem
(
problem
),
bisection
(
bisection
),
local_J
(
1.0
,
0.0
,
problem
.
phi
,
0
,
0
)
{};
...
...
@@ -126,7 +126,7 @@ class MyBlockProblem<ConvexProblemTypeTEMPLATE>::IterateObject {
private
:
// problem data
ConvexProblemType
&
problem
;
My
ConvexProblemType
&
problem
;
// commonly used minimization stuff
Bisection
bisection
;
...
...
This diff is collapsed.
Click to expand it.
src/myconvexproblem.hh
0 → 100644
+
55
−
0
View file @
b362f667
// Based on dune/tnnmg/problem-classes/convexproblem.hh
#include
<dune/istl/bcrsmatrix.hh>
#include
<dune/tnnmg/problem-classes/nonlinearity.hh>
/** \brief General convex problem for a Truncated Nonsmooth Newton Multigrid
(TNNMG) solver
\tparam NonlinearityTypeTEMPLATE The type used to implement the nonlinearity
\tparam MatrixTypeTEMPLATE The type used for the matrix of the quadratic
part
*/
template
<
class
NonlinearityTypeTEMPLATE
=
Nonlinearity
<
Dune
::
FieldVector
<
double
,
1
>,
Dune
::
FieldMatrix
<
double
,
1
,
1
>>
,
class
MatrixTypeTEMPLATE
=
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
double
,
1
,
1
>>>
class
MyConvexProblem
{
public:
typedef
NonlinearityTypeTEMPLATE
NonlinearityType
;
typedef
typename
NonlinearityType
::
VectorType
VectorType
;
typedef
MatrixTypeTEMPLATE
MatrixType
;
typedef
typename
NonlinearityType
::
LocalVectorType
LocalVectorType
;
typedef
typename
MatrixType
::
block_type
LocalMatrixType
;
static
const
int
block_size
=
NonlinearityType
::
block_size
;
/** \brief Constructor with the problem components
\param a A scalar factor in front of the quadratic part (the quadratic
part includes a factor of 1/2 already)
\param A The matrix of the quadratic part
\param am A scalar factor in front of the optional rank-one matrix
\param Am A rank-one matrix given by a single vector. The matrix is
AmAm^T
\param phi The nonlinearity
\param f The linear functional
\param u The solution vector
*/
MyConvexProblem
(
double
a
,
const
MatrixType
&
A
,
double
am
,
const
VectorType
&
Am
,
NonlinearityType
&
phi
,
const
VectorType
&
f
,
VectorType
&
u
)
:
a
(
a
),
A
(
A
),
am
(
am
),
Am
(
Am
),
phi
(
phi
),
f
(
f
),
u
(
u
)
{};
double
a
;
const
MatrixType
&
A
;
double
am
;
const
VectorType
&
Am
;
NonlinearityType
&
phi
;
const
VectorType
&
f
;
VectorType
&
u
;
};
This diff is collapsed.
Click to expand it.
src/one-body-sample.cc
+
7
−
5
View file @
b362f667
...
...
@@ -28,13 +28,14 @@
#include
<dune/grid/common/mcmgmapper.hh>
#include
<dune/tnnmg/problem-classes/convexproblem.hh>
//
#include <dune/tnnmg/problem-classes/convexproblem.hh>
#include
<dune/tnnmg/problem-classes/nonlinearity.hh>
#include
<dune/tnnmg/nonlinearities/zerononlinearity.hh>
#include
<exception>
#include
<iostream>
#include
"myconvexproblem.hh"
#include
"myblockproblem.hh"
int
const
dim
=
2
;
...
...
@@ -141,13 +142,14 @@ int main() {
typedef
ZeroNonlinearity
<
SmallVector
,
SmallMatrix
>
NonlinearityType
;
NonlinearityType
phi
;
typedef
ConvexProblem
<
NonlinearityType
,
OperatorType
>
ConvexProblemType
;
typedef
MyConvexProblem
<
NonlinearityType
,
OperatorType
>
MyConvexProblemType
;
VectorType
unused_vector
(
grid
.
size
(
grid
.
maxLevel
(),
dim
),
0
);
ConvexProblemType
myConvexProblem
(
1
,
stiffnessMatrix
,
0
,
unused_vector
,
phi
,
f
,
u1
);
My
ConvexProblemType
myConvexProblem
(
1
,
stiffnessMatrix
,
0
,
unused_vector
,
phi
,
f
,
u1
);
typedef
MyBlockProblem
<
ConvexProblemType
>
MyBlockProblemType
;
typedef
MyBlockProblem
<
My
ConvexProblemType
>
MyBlockProblemType
;
MyBlockProblemType
myBlockProblem
(
myConvexProblem
);
GenericNonlinearGS
<
MyBlockProblemType
>
nonlinearGSStep
;
...
...
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