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
dfd7d851
Commit
dfd7d851
authored
Oct 03, 2018
by
Praetorius, Simon
Browse files
Copy constructor for DOFVector that does proper resizing of the data-vectors before
parent
d7c6313f
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/amdis/Output.hpp
View file @
dfd7d851
#pragma once
#pragma once
#include
<iomanip>
#include
<iostream>
#include
<iostream>
#include
<sstream>
#include
<string>
#include
<string>
#include
<fmt/core.h>
/**
/**
* \def AMDIS_NO_THROW
* \def AMDIS_NO_THROW
* \brief The preprocessor constant sets whether to use c-asserts (if defined) or
* \brief The preprocessor constant sets whether to use c-asserts (if defined) or
...
@@ -18,10 +14,14 @@
...
@@ -18,10 +14,14 @@
#include
<stdexcept>
#include
<stdexcept>
#endif
#endif
#ifdef
AMDIS_HAS
_MPI
#ifdef
HAVE
_MPI
#include
<mpi.h>
#include
<mpi.h>
#endif
#endif
/// Use the formatting librart fmtlib::fmt
#include
<fmt/core.h>
#include
<fmt/ostream.h>
/**
/**
* \def AMDIS_ENABLE_MSG_DBG
* \def AMDIS_ENABLE_MSG_DBG
* \brief The preprocessor constant enables the functions \ref AMDiS::MSG_DBG
* \brief The preprocessor constant enables the functions \ref AMDiS::MSG_DBG
...
@@ -65,12 +65,13 @@ namespace AMDiS
...
@@ -65,12 +65,13 @@ namespace AMDiS
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
num_ranks
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
num_ranks
);
if
(
num_ranks
>
1
&&
rank
==
0
)
{
if
(
num_ranks
>
1
&&
rank
==
0
)
{
out
<<
"[0] "
<<
fmt
::
format
(
std
::
forward
<
Args
>
(
args
)...);
out
<<
"[0] "
;
fmt
::
print
(
out
,
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
num_ranks
==
1
)
{
}
else
if
(
num_ranks
==
1
)
{
out
<<
fmt
::
format
(
std
::
forward
<
Args
>
(
args
)...);
fmt
::
print
(
out
,
std
::
forward
<
Args
>
(
args
)...);
}
}
#else
#else
out
<<
fmt
::
format
(
std
::
forward
<
Args
>
(
args
)...);
fmt
::
print
(
out
,
std
::
forward
<
Args
>
(
args
)...);
#endif
#endif
return
out
;
return
out
;
}
}
...
...
src/amdis/ProblemInstat.hpp
View file @
dfd7d851
...
@@ -52,13 +52,19 @@ namespace AMDiS
...
@@ -52,13 +52,19 @@ namespace AMDiS
virtual
void
closeTimestep
(
AdaptInfo
&
adaptInfo
)
override
;
virtual
void
closeTimestep
(
AdaptInfo
&
adaptInfo
)
override
;
/// Returns \ref problemStat.
/// Returns \ref problemStat.
ProblemType
&
getStatProblem
()
ProblemType
const
&
getProblemStat
()
const
{
return
problemStat_
;
}
/// Returns \ref problemStat.
ProblemType
&
getProblemStat
()
{
{
return
problemStat_
;
return
problemStat_
;
}
}
/// Returns \ref oldSolution.
/// Returns \ref oldSolution.
std
::
unique_ptr
<
SystemVector
>
getOldSolutionVector
()
const
std
::
unique_ptr
<
SystemVector
>
const
&
getOldSolutionVector
()
const
{
{
test_exit_dbg
(
oldSolution_
,
test_exit_dbg
(
oldSolution_
,
"OldSolution need to be created. Call initialize with INIT_UH_OLD."
);
"OldSolution need to be created. Call initialize with INIT_UH_OLD."
);
...
@@ -70,7 +76,7 @@ namespace AMDiS
...
@@ -70,7 +76,7 @@ namespace AMDiS
auto
getOldSolution
(
TreePath
const
&
path
=
{})
auto
getOldSolution
(
TreePath
const
&
path
=
{})
{
{
auto
&&
tp
=
makeTreePath
(
path
);
auto
&&
tp
=
makeTreePath
(
path
);
return
makeDOFVectorView
(
*
o
ldSolution
_
,
tp
);
return
makeDOFVectorView
(
*
getO
ldSolution
Vector
()
,
tp
);
}
}
/// Return a const view to a oldSolution component
/// Return a const view to a oldSolution component
...
@@ -78,7 +84,7 @@ namespace AMDiS
...
@@ -78,7 +84,7 @@ namespace AMDiS
auto
getOldSolution
(
TreePath
const
&
path
=
{})
const
auto
getOldSolution
(
TreePath
const
&
path
=
{})
const
{
{
auto
&&
tp
=
makeTreePath
(
path
);
auto
&&
tp
=
makeTreePath
(
path
);
return
makeDOFVectorView
(
*
o
ldSolution
_
,
tp
);
return
makeDOFVectorView
(
*
getO
ldSolution
Vector
()
,
tp
);
}
}
/// Implementation of \ref ProblemTimeInterface::transferInitialSolution().
/// Implementation of \ref ProblemTimeInterface::transferInitialSolution().
...
...
src/amdis/ProblemInstat.inc.hpp
View file @
dfd7d851
...
@@ -33,7 +33,7 @@ void ProblemInstat<Traits>::initialize(Flag initFlag)
...
@@ -33,7 +33,7 @@ void ProblemInstat<Traits>::initialize(Flag initFlag)
{
{
// create vector for old solution
// create vector for old solution
if
(
initFlag
.
isSet
(
INIT_UH_OLD
))
if
(
initFlag
.
isSet
(
INIT_UH_OLD
))
createUhOld
();
createUhOld
();
}
}
...
...
src/amdis/linear_algebra/DOFVectorBase.hpp
View file @
dfd7d851
...
@@ -19,7 +19,7 @@ namespace AMDiS
...
@@ -19,7 +19,7 @@ namespace AMDiS
using
Self
=
DOFVectorBase
;
using
Self
=
DOFVectorBase
;
public:
public:
/// The type of the
\ref basis
/// The type of the
functionspace basis associated to this vector
using
Basis
=
BasisType
;
using
Basis
=
BasisType
;
/// The index/size - type
/// The index/size - type
...
@@ -28,6 +28,7 @@ namespace AMDiS
...
@@ -28,6 +28,7 @@ namespace AMDiS
/// The type of the elements of the DOFVector
/// The type of the elements of the DOFVector
using
value_type
=
typename
Backend
::
value_type
;
using
value_type
=
typename
Backend
::
value_type
;
/// The type of the data vector used in the backend
using
BaseVector
=
typename
Backend
::
BaseVector
;
using
BaseVector
=
typename
Backend
::
BaseVector
;
public:
public:
...
@@ -38,6 +39,30 @@ namespace AMDiS
...
@@ -38,6 +39,30 @@ namespace AMDiS
compress
();
compress
();
}
}
DOFVectorBase
(
Self
const
&
)
=
default
;
DOFVectorBase
(
Self
&&
)
=
default
;
/// Copy assignment operator
Self
&
operator
=
(
Self
const
&
that
)
{
assert
(
basis_
==
that
.
basis_
);
backend_
.
resize
(
that
.
size
());
backend_
=
that
.
backend_
;
return
*
this
;
}
/// Move assignment
Self
&
operator
=
(
Self
&&
that
)
=
default
;
/// Sets each DOFVector to the scalar \p value.
template
<
class
Scalar
,
std
::
enable_if_t
<
Concepts
::
Arithmetic
<
Scalar
>,
int
>
=
0
>
Self
&
operator
=
(
Scalar
value
)
{
vector
()
=
value
;
return
*
this
;
}
/// Return the basis \ref basis_ associated to the vector
/// Return the basis \ref basis_ associated to the vector
Basis
const
&
basis
()
const
Basis
const
&
basis
()
const
{
{
...
@@ -67,7 +92,7 @@ namespace AMDiS
...
@@ -67,7 +92,7 @@ namespace AMDiS
backend_
.
resize
(
size_type
(
s
));
backend_
.
resize
(
size_type
(
s
));
}
}
/// Resize the \ref vector to the size of the \ref basis
.
/// Resize the \ref vector to the size of the \ref basis
and set to zero
virtual
void
compress
()
override
virtual
void
compress
()
override
{
{
if
(
backend_
.
size
()
!=
size
())
{
if
(
backend_
.
size
()
!=
size
())
{
...
@@ -105,15 +130,6 @@ namespace AMDiS
...
@@ -105,15 +130,6 @@ namespace AMDiS
}
}
}
}
/// Sets each DOFVector to the scalar \p value.
template
<
class
Scalar
,
std
::
enable_if_t
<
Concepts
::
Arithmetic
<
Scalar
>,
int
>
=
0
>
Self
&
operator
=
(
Scalar
value
)
{
vector
()
=
value
;
return
*
this
;
}
private:
private:
/// The finite element space / basis associated with the data vector
/// The finite element space / basis associated with the data vector
Basis
const
*
basis_
;
Basis
const
*
basis_
;
...
...
src/amdis/linear_algebra/istl/DOFVector.hpp
View file @
dfd7d851
...
@@ -24,10 +24,16 @@ namespace AMDiS
...
@@ -24,10 +24,16 @@ namespace AMDiS
{
{
public:
public:
/// The type of the elements of the DOFVector
/// The type of the elements of the DOFVector
using
value_type
=
typename
BlockVectorType
<
ValueType
>::
type
;
using
block_type
=
typename
BlockVectorType
<
ValueType
>::
type
;
/// The type of the elements of the DOFVector
using
value_type
=
block_type
;
/// The underlying field type
using
field_type
=
typename
block_type
::
field_type
;
/// The vector type of the underlying base vector
/// The vector type of the underlying base vector
using
BaseVector
=
Dune
::
BlockVector
<
value
_type
>
;
using
BaseVector
=
Dune
::
BlockVector
<
block
_type
>
;
/// The index/size - type
/// The index/size - type
using
size_type
=
typename
BaseVector
::
size_type
;
using
size_type
=
typename
BaseVector
::
size_type
;
...
@@ -63,7 +69,7 @@ namespace AMDiS
...
@@ -63,7 +69,7 @@ namespace AMDiS
/// Access the entry \p i of the \ref vector with read-access.
/// Access the entry \p i of the \ref vector with read-access.
value
_type
const
&
operator
[](
size_type
i
)
const
block
_type
const
&
operator
[](
size_type
i
)
const
{
{
test_exit_dbg
(
i
<
vector_
.
size
(),
test_exit_dbg
(
i
<
vector_
.
size
(),
"Index {} out of range [0,{})"
,
i
,
vector_
.
size
());
"Index {} out of range [0,{})"
,
i
,
vector_
.
size
());
...
@@ -71,7 +77,7 @@ namespace AMDiS
...
@@ -71,7 +77,7 @@ namespace AMDiS
}
}
/// Access the entry \p i of the \ref vector with write-access.
/// Access the entry \p i of the \ref vector with write-access.
value
_type
&
operator
[](
size_type
i
)
block
_type
&
operator
[](
size_type
i
)
{
{
test_exit_dbg
(
i
<
vector_
.
size
(),
test_exit_dbg
(
i
<
vector_
.
size
(),
"Index {} out of range [0,{})"
,
i
,
vector_
.
size
());
"Index {} out of range [0,{})"
,
i
,
vector_
.
size
());
...
...
src/amdis/linear_algebra/mtl/DOFVector.hpp
View file @
dfd7d851
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
#include
<boost/numeric/mtl/vector/dense_vector.hpp>
#include
<boost/numeric/mtl/vector/dense_vector.hpp>
#include
<dune/common/ftraits.hh>
#include
<amdis/Output.hpp>
#include
<amdis/Output.hpp>
#include
<amdis/linear_algebra/DOFVectorBase.hpp>
#include
<amdis/linear_algebra/DOFVectorBase.hpp>
...
@@ -12,15 +14,21 @@ namespace AMDiS
...
@@ -12,15 +14,21 @@ namespace AMDiS
class
MtlVector
class
MtlVector
{
{
public:
public:
/// The type of the elements of the DOFVector
using
value_type
=
ValueType
;
/// The type of the elements of the DOFVector
using
block_type
=
ValueType
;
/// The underlying field type
using
field_type
=
typename
Dune
::
FieldTraits
<
ValueType
>::
field_type
;
/// The type of the base vector
/// The type of the base vector
using
BaseVector
=
mtl
::
vec
::
dense_vector
<
ValueType
>
;
using
BaseVector
=
mtl
::
vec
::
dense_vector
<
ValueType
>
;
/// The index/size - type
/// The index/size - type
using
size_type
=
typename
BaseVector
::
size_type
;
using
size_type
=
typename
BaseVector
::
size_type
;
/// The type of the elements of the DOFVector
using
value_type
=
ValueType
;
public:
public:
/// Constructor. Constructs new BaseVector.
/// Constructor. Constructs new BaseVector.
MtlVector
()
=
default
;
MtlVector
()
=
default
;
...
...
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