Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-istl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Core Modules
dune-istl
Commits
b34fb142
Commit
b34fb142
authored
11 months ago
by
Simon Praetorius
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup the constructors
parent
b2fdc57a
Branches
cherry-pick-3d1b5105
Branches containing commit
No related tags found
1 merge request
!463
Cleanup the VariableBlockVector implementation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/istl/vbvector.hh
+17
-16
17 additions, 16 deletions
dune/istl/vbvector.hh
with
17 additions
and
16 deletions
dune/istl/vbvector.hh
+
17
−
16
View file @
b34fb142
...
@@ -46,6 +46,8 @@ namespace Dune {
...
@@ -46,6 +46,8 @@ namespace Dune {
// on the large array. However, access operators have to be
// on the large array. However, access operators have to be
// overwritten.
// overwritten.
{
{
using
Base
=
Imp
::
block_vector_unmanaged
<
B
,
typename
A
::
size_type
>
;
// just a shorthand
// just a shorthand
using
window_type
=
Imp
::
BlockVectorWindow
<
B
,
A
>
;
using
window_type
=
Imp
::
BlockVectorWindow
<
B
,
A
>
;
...
@@ -95,7 +97,7 @@ namespace Dune {
...
@@ -95,7 +97,7 @@ namespace Dune {
* \note object cannot be used yet. The size and block sizes need to be initialized.
* \note object cannot be used yet. The size and block sizes need to be initialized.
*/
*/
VariableBlockVector
()
:
VariableBlockVector
()
:
Imp
::
block_vector_unmanaged
<
B
,
size_type
>
()
Base
()
{}
{}
/**
/**
...
@@ -105,11 +107,9 @@ namespace Dune {
...
@@ -105,11 +107,9 @@ namespace Dune {
* `createbegin()` and `createend()` create-iterators to fill the block sizes.
* `createbegin()` and `createend()` create-iterators to fill the block sizes.
*/
*/
explicit
VariableBlockVector
(
size_type
numBlocks
)
:
explicit
VariableBlockVector
(
size_type
numBlocks
)
:
Imp
::
block_vector_unmanaged
<
B
,
size_type
>
()
Base
(),
{
block
(
numBlocks
)
// we can allocate the windows now
{}
block
.
resize
(
numBlocks
);
}
/**
/**
* \brief Construct a vector with given number of blocks each having a
* \brief Construct a vector with given number of blocks each having a
...
@@ -120,14 +120,13 @@ namespace Dune {
...
@@ -120,14 +120,13 @@ namespace Dune {
* \param blockSize Number of elements in each block
* \param blockSize Number of elements in each block
*/
*/
VariableBlockVector
(
size_type
numBlocks
,
size_type
blockSize
)
:
VariableBlockVector
(
size_type
numBlocks
,
size_type
blockSize
)
:
Imp
::
block_vector_unmanaged
<
B
,
size_type
>
()
Base
(),
block
(
numBlocks
),
storage_
(
numBlocks
*
blockSize
)
{
{
// and we can allocate the big array in the base class
// and we can allocate the big array in the base class
storage_
.
resize
(
numBlocks
*
blockSize
);
syncBaseArray
();
syncBaseArray
();
block
.
resize
(
numBlocks
);
// set the windows into the big array
// set the windows into the big array
for
(
size_type
i
=
0
;
i
<
numBlocks
;
++
i
)
for
(
size_type
i
=
0
;
i
<
numBlocks
;
++
i
)
block
[
i
].
set
(
blockSize
,
this
->
p
+
(
i
*
blockSize
));
block
[
i
].
set
(
blockSize
,
this
->
p
+
(
i
*
blockSize
));
...
@@ -138,6 +137,7 @@ namespace Dune {
...
@@ -138,6 +137,7 @@ namespace Dune {
//! Copy constructor, has copy semantics
//! Copy constructor, has copy semantics
VariableBlockVector
(
const
VariableBlockVector
&
a
)
:
VariableBlockVector
(
const
VariableBlockVector
&
a
)
:
Base
(
static_cast
<
const
Base
&>
(
a
)),
block
(
a
.
block
),
block
(
a
.
block
),
storage_
(
a
.
storage_
)
storage_
(
a
.
storage_
)
{
{
...
@@ -154,15 +154,16 @@ namespace Dune {
...
@@ -154,15 +154,16 @@ namespace Dune {
initialized
=
a
.
initialized
;
initialized
=
a
.
initialized
;
}
}
~
VariableBlockVector
()
=
default
;
//! Move constructor:
//! Move constructor:
VariableBlockVector
(
VariableBlockVector
&&
tmp
)
:
VariableBlockVector
(
VariableBlockVector
&&
tmp
)
:
VariableBlockVector
()
Base
()
{
{
tmp
.
swap
(
*
this
);
tmp
.
swap
(
*
this
);
}
}
~
VariableBlockVector
()
=
default
;
//! Copy and move assignment
//! Copy and move assignment
VariableBlockVector
&
operator
=
(
VariableBlockVector
tmp
)
VariableBlockVector
&
operator
=
(
VariableBlockVector
tmp
)
{
{
...
@@ -375,7 +376,7 @@ namespace Dune {
...
@@ -375,7 +376,7 @@ namespace Dune {
#ifdef DUNE_ISTL_WITH_CHECKING
#ifdef DUNE_ISTL_WITH_CHECKING
if
(
initialized
)
DUNE_THROW
(
ISTLError
,
"no CreateIterator in initialized state"
);
if
(
initialized
)
DUNE_THROW
(
ISTLError
,
"no CreateIterator in initialized state"
);
#endif
#endif
return
CreateIterator
(
*
this
,
0
,
false
);
return
CreateIterator
(
*
this
,
0
,
false
);
}
}
//! get create iterator pointing to one after the last block
//! get create iterator pointing to one after the last block
...
@@ -540,8 +541,8 @@ namespace Dune {
...
@@ -540,8 +541,8 @@ namespace Dune {
this
->
n
=
storage_
.
size
();
this
->
n
=
storage_
.
size
();
}
}
VectorWindows
block
;
// vector of blocks pointing to the array in the base class
VectorWindows
block
=
{}
;
// vector of blocks pointing to the array in the base class
std
::
vector
<
B
,
A
>
storage_
;
std
::
vector
<
B
,
A
>
storage_
=
{}
;
bool
initialized
=
false
;
// true if vector has been initialized
bool
initialized
=
false
;
// true if vector has been initialized
};
};
...
...
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