Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
amdis
amdis-core
Commits
460a9b12
Commit
460a9b12
authored
Sep 30, 2019
by
Praetorius, Simon
Browse files
Cleanup the constructors of MatrixBase, VectorBase, BiLinearForm, and LinearForm
parent
e806dac8
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/amdis/BiLinearForm.hpp
View file @
460a9b12
...
...
@@ -46,9 +46,9 @@ namespace AMDiS
public:
/// Constructor. Wraps the reference into a non-destroying shared_ptr or moves the basis into a new shared_ptr.
template
<
class
RB_
,
class
CB_
,
class
Comm_
>
BiLinearForm
(
RB_
&&
rowBasis
,
CB_
&&
colBasis
,
Comm_
&&
comm
)
:
Super
(
FWD
(
rowBasis
),
FWD
(
colBasis
),
FWD
(
comm
)
)
template
<
class
RB_
,
class
CB_
,
class
...
Args
>
BiLinearForm
(
RB_
&&
rowBasis
,
CB_
&&
colBasis
,
Args
&&
...
args
)
:
Super
(
FWD
(
rowBasis
),
FWD
(
colBasis
),
FWD
(
args
)...
)
{
operators_
.
init
(
*
Super
::
rowBasis
(),
*
Super
::
colBasis
());
}
...
...
@@ -63,7 +63,7 @@ namespace AMDiS
elementMatrix_
.
resize
(
rowSize
,
colSize
);
}
/// \brief Associate a local operator with this
DOFMatrix
/// \brief Associate a local operator with this
BiLinearForm
/**
* Stores an operator in a list that gets assembled during a call to \ref assemble().
* The operator may be assigned to a specific context, i.e. either an element
...
...
@@ -80,12 +80,27 @@ namespace AMDiS
*
* [[expects: row is valid tree-path in RowBasis]]
* [[expects: col is valid tree-path in ColBasis]]
* @{
**/
// TODO: add method without contextTag.
template
<
class
ContextTag
,
class
Expr
,
class
RowTreePath
=
RootTreePath
,
class
ColTreePath
=
RootTreePath
>
void
addOperator
(
ContextTag
contextTag
,
Expr
const
&
expr
,
RowTreePath
row
=
{},
ColTreePath
col
=
{});
template
<
class
ContextTag
,
class
Expr
,
class
RowTreePath
,
class
ColTreePath
>
void
addOperator
(
ContextTag
contextTag
,
Expr
const
&
expr
,
RowTreePath
row
,
ColTreePath
col
);
// Add an operator to be assembled on the elements of the grid
template
<
class
Expr
,
class
RowTreePath
=
RootTreePath
,
class
ColTreePath
=
RootTreePath
>
void
addOperator
(
Expr
const
&
expr
,
RowTreePath
row
=
{},
ColTreePath
col
=
{})
{
using
E
=
typename
RowLocalView
::
Element
;
addOperator
(
tag
::
element_operator
<
E
>
{},
expr
,
row
,
col
);
}
// Add an operator to be assembled on the intersections of the grid
template
<
class
Expr
,
class
RowTreePath
=
RootTreePath
,
class
ColTreePath
=
RootTreePath
>
void
addIntersectionOperator
(
Expr
const
&
expr
,
RowTreePath
row
=
{},
ColTreePath
col
=
{})
{
using
I
=
typename
RowLocalView
::
GridView
::
Intersection
;
addOperator
(
tag
::
intersection_operator
<
I
>
{},
expr
,
row
,
col
);
}
/// @}
/// Assemble the matrix operators on the bound element.
void
assemble
(
RowLocalView
const
&
rowLocalView
,
...
...
@@ -103,6 +118,20 @@ namespace AMDiS
MatrixOperators
<
RowBasis
,
ColBasis
,
ElementMatrix
>
operators_
;
};
#if DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
template
<
class
RB
,
class
CB
,
class
...
Args
>
BiLinearForm
(
RB
&&
,
CB
&&
,
Args
&&
...)
->
BiLinearForm
<
Underlying_t
<
RB
>
,
Underlying_t
<
CB
>>
;
#endif
template
<
class
RB
,
class
CB
,
class
...
Args
>
auto
makeBiLinearForm
(
RB
&&
rowBasis
,
CB
&&
colBasis
,
Args
&&
...
args
)
{
using
BLF
=
BiLinearForm
<
Underlying_t
<
RB
>
,
Underlying_t
<
CB
>>
;
return
BLF
{
FWD
(
rowBasis
),
FWD
(
colBasis
),
FWD
(
args
)...};
}
}
// end namespace AMDiS
#include <amdis/BiLinearForm.inc.hpp>
src/amdis/BiLinearForm.inc.hpp
View file @
460a9b12
...
...
@@ -75,7 +75,7 @@ assemble(SymmetryStructure symmetry)
this
->
assemble
(
rowLocalView
,
colLocalView
);
colLocalView
.
unbind
();
}
rowLocalView
.
unbind
(
element
);
rowLocalView
.
unbind
();
}
this
->
finish
();
}
...
...
src/amdis/LinearForm.hpp
View file @
460a9b12
...
...
@@ -21,6 +21,7 @@ namespace AMDiS
:
public
VectorBase
<
GB
,
VectorBackend
<
BackendTraits
<
GB
,
T
>>>
{
using
Super
=
VectorBase
<
GB
,
VectorBackend
<
BackendTraits
<
GB
,
T
>>>
;
using
Self
=
LinearForm
;
public:
using
Backend
=
VectorBackend
<
BackendTraits
<
GB
,
T
>>
;
...
...
@@ -28,6 +29,7 @@ namespace AMDiS
/// The type of the functionspace basis associated to this linearform
using
GlobalBasis
=
GB
;
using
LocalView
=
typename
GlobalBasis
::
LocalView
;
/// A traits class collecting several parameters of the linear algebra backend
using
Traits
=
typename
Backend
::
Traits
;
...
...
@@ -40,9 +42,10 @@ namespace AMDiS
public:
/// Constructor. Stores the shared_ptr of the basis and creates a new DataTransfer.
template
<
class
GB_
,
class
Comm_
>
LinearForm
(
GB_
&&
basis
,
Comm_
&&
comm
)
:
Super
(
FWD
(
basis
),
FWD
(
comm
))
template
<
class
GB_
,
class
...
Args
,
Dune
::
disableCopyMove
<
Self
,
GB_
,
Args
...>
=
0
>
explicit
LinearForm
(
GB_
&&
basis
,
Args
&&
...
args
)
:
Super
(
FWD
(
basis
),
FWD
(
args
)...)
{
operators_
.
init
(
*
Super
::
basis
());
}
...
...
@@ -57,12 +60,46 @@ namespace AMDiS
elementVector_
.
resize
(
localSize
);
}
/// Associate a local operator with this LinearForm
template
<
class
ContextTag
,
class
Expr
,
class
TreePath
=
RootTreePath
>
void
addOperator
(
ContextTag
contextTag
,
Expr
const
&
expr
,
TreePath
path
=
{});
/// \brief Associate a local operator with this LinearForm
/**
* Stores an operator in a list that gets assembled during a call to \ref assemble().
* The operator may be assigned to a specific context, i.e. either an element
* operator, an intersection operator, or a boundary operator.
* The \p row and \p col tree paths specify the sub-basis for test and trial
* functions the operator is applied to.
*
* \tparam ContextTag One of \ref tag::element_operator, \ref tag::intersection_operator
* or \ref tag::boundary_operator indicating where to assemble this operator.
* \tparam Expr An pre-operator that can be bound to a gridView, or a valid
* GridOperator.
* \tparam path A tree-path for the Basis
*
* [[expects: path is valid tree-path in Basis]]
* @{
**/
template
<
class
ContextTag
,
class
Expr
,
class
TreePath
>
void
addOperator
(
ContextTag
contextTag
,
Expr
const
&
expr
,
TreePath
path
);
// Add an operator to be assembled on the elements of the grid
template
<
class
Expr
,
class
TreePath
=
RootTreePath
>
void
addOperator
(
Expr
const
&
expr
,
TreePath
path
=
{})
{
using
E
=
typename
LocalView
::
Element
;
addOperator
(
tag
::
element_operator
<
E
>
{},
expr
,
path
);
}
// Add an operator to be assembled on the intersections of the grid
template
<
class
Expr
,
class
TreePath
=
RootTreePath
>
void
addIntersectionOperator
(
Expr
const
&
expr
,
TreePath
path
=
{})
{
using
I
=
typename
LocalView
::
GridView
::
Intersection
;
addOperator
(
tag
::
intersection_operator
<
I
>
{},
expr
,
path
);
}
/// @}
/// Assemble the vector operators on the bound element.
void
assemble
(
typename
GB
::
LocalView
const
&
localView
);
void
assemble
(
LocalView
const
&
localView
);
/// Assemble all vector operators added by \ref addOperator().
void
assemble
();
...
...
@@ -75,12 +112,20 @@ namespace AMDiS
VectorOperators
<
GlobalBasis
,
ElementVector
>
operators_
;
};
#if DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
template
<
class
GB
,
class
C
>
LinearForm
(
GB
&&
basis
,
C
const
&
comm
)
->
LinearForm
<
Underlying_t
<
GB
>
,
VectorBackend
<
BackendTraits
<
Underlying_t
<
GB
>>>
>
;
template
<
class
GB
,
class
...
Args
>
LinearForm
(
GB
&&
basis
,
Args
&&
...
args
)
->
LinearForm
<
Underlying_t
<
GB
>
,
double
>
;
#endif
template
<
class
T
=
double
,
class
GB
,
class
...
Args
>
auto
makeLinearForm
(
GB
&&
basis
,
Args
&&
...
args
)
{
using
LF
=
LinearForm
<
Underlying_t
<
GB
>
,
T
>
;
return
LF
{
FWD
(
basis
),
FWD
(
args
)...};
}
}
// end namespace AMDiS
#include <amdis/LinearForm.inc.hpp>
src/amdis/linearalgebra/MatrixBase.hpp
View file @
460a9b12
...
...
@@ -43,20 +43,32 @@ namespace AMDiS
using
Comm
=
typename
B
::
Traits
::
Comm
;
public:
/// Constructor. Stores the shared_ptr to the bases.
///
(1)
Constructor. Stores the shared_ptr to the bases
and the communication object
.
MatrixBase
(
std
::
shared_ptr
<
RowBasis
>
rowBasis
,
std
::
shared_ptr
<
ColBasis
>
colBasis
,
std
::
shared_ptr
<
Comm
>
comm
)
:
rowBasis_
(
std
::
move
(
rowBasis
))
,
colBasis_
(
std
::
move
(
colBasis
))
,
backend_
(
std
::
move
(
comm
))
{}
/// Constructor.
Wraps the
reference into
a
non-destroying shared_ptr
or moves the basis into a new shared_ptr
.
///
(2)
Constructor.
Forwards to (1) by wraping
reference into non-destroying shared_ptr
, see \ref Dune::wrap_or_move
.
template
<
class
RB_
,
class
CB_
,
class
Comm_
,
REQUIRES
(
Concepts
::
Similar
<
RB_
,
RB
>
&&
Concepts
::
Similar
<
CB_
,
CB
>
&&
Concepts
::
Similar
<
Comm_
,
Comm
>
)
>
REQUIRES
(
Concepts
::
Similar
<
Types
<
RB_
,
CB_
,
Comm_
>,
Types
<
RB
,
CB
,
Comm
>
>
)
>
MatrixBase
(
RB_
&&
rowBasis
,
CB_
&&
colBasis
,
Comm_
&&
comm
)
:
MatrixBase
(
Dune
::
wrap_or_move
(
FWD
(
rowBasis
)),
Dune
::
wrap_or_move
(
FWD
(
colBasis
)),
Dune
::
wrap_or_move
(
FWD
(
comm
)))
{}
/// (3) Constructor. Forwards to (1) by creating a new communicator
MatrixBase
(
std
::
shared_ptr
<
RowBasis
>
const
&
rowBasis
,
std
::
shared_ptr
<
ColBasis
>
const
&
colBasis
)
:
MatrixBase
(
rowBasis
,
colBasis
,
std
::
shared_ptr
<
Comm
>
(
CommunicationCreator
<
Comm
>::
create
(
*
rowBasis
)))
{}
/// (4) Constructor. Forwards to (3) by wrapping references into non-destroying shared_ptr, see \ref Dune::wrap_or_move.
template
<
class
RB_
,
class
CB_
,
REQUIRES
(
Concepts
::
Similar
<
Types
<
RB_
,
CB_
>,
Types
<
RB
,
CB
>>
)
>
MatrixBase
(
RB_
&&
rowBasis
,
CB_
&&
colBasis
)
:
MatrixBase
(
Dune
::
wrap_or_move
(
FWD
(
rowBasis
)),
Dune
::
wrap_or_move
(
FWD
(
colBasis
)))
{}
/// Return the row-basis \ref rowBasis of the matrix
std
::
shared_ptr
<
RowBasis
>
const
&
rowBasis
()
const
{
...
...
src/amdis/linearalgebra/VectorBase.hpp
View file @
460a9b12
...
...
@@ -66,7 +66,7 @@ namespace AMDiS
std
::
integral_constant
<
VectorState
,
VectorState
::
insert_values
>>
;
public:
/// Constructor. Stores the shared_ptr of the basis and c
reates a new DataTransfer
.
///
(1)
Constructor. Stores the shared_ptr of the basis and c
ommunication object
.
VectorBase
(
std
::
shared_ptr
<
GB
>
basis
,
std
::
shared_ptr
<
Comm
>
comm
)
:
basis_
(
std
::
move
(
basis
))
,
comm_
(
std
::
move
(
comm
))
...
...
@@ -75,15 +75,25 @@ namespace AMDiS
resizeZero
();
}
/// Constructor. Wraps the reference into a non-destroying shared_ptr or moves
/// the basis into a new shared_ptr.
/// (2) Constructor. Forwards to (1) by wraping reference into non-destroying shared_ptr.
template
<
class
GB_
,
class
Comm_
,
REQUIRES
(
Concepts
::
Similar
<
GB_
,
GB
>),
REQUIRES
(
Concepts
::
Similar
<
Comm_
,
Comm
>
)
>
REQUIRES
(
Concepts
::
Similar
<
Types
<
GB_
,
Comm_
>,
Types
<
GB
,
Comm
>>
)
>
VectorBase
(
GB_
&&
basis
,
Comm_
&&
comm
)
:
VectorBase
(
Dune
::
wrap_or_move
(
FWD
(
basis
)),
Dune
::
wrap_or_move
(
FWD
(
comm
)))
{}
/// (3) Constructor. Forwards to (1) by creating a new communicator
explicit
VectorBase
(
std
::
shared_ptr
<
GB
>
const
&
basis
)
:
VectorBase
(
basis
,
std
::
shared_ptr
<
Comm
>
(
CommunicationCreator
<
Comm
>::
create
(
*
basis
)))
{}
/// (4) Constructor. Forwards to (3) by wrapping references into non-destroying shared_ptr, see \ref Dune::wrap_or_move.
template
<
class
GB_
,
REQUIRES
(
Concepts
::
Similar
<
GB_
,
GB
>)
>
explicit
VectorBase
(
GB_
&&
basis
)
:
VectorBase
(
Dune
::
wrap_or_move
(
FWD
(
basis
)))
{}
/// Return the basis \ref basis_ associated to the vector
std
::
shared_ptr
<
GlobalBasis
>
const
&
basis
()
const
{
return
basis_
;
}
std
::
shared_ptr
<
GlobalBasis
>
const
&
basis
()
{
return
basis_
;
}
...
...
Write
Preview
Supports
Markdown
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