Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
solverstack
ScalFMM
Commits
4ccc09cb
Commit
4ccc09cb
authored
Jun 06, 2018
by
COULAUD Olivier
Browse files
Add copy constructor
parent
66e764be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Src/Components/FBasicParticleContainer.hpp
View file @
4ccc09cb
...
...
@@ -2,6 +2,9 @@
#ifndef FBASIC_PARTICLE_CONTAINER_HPP_
#define FBASIC_PARTICLE_CONTAINER_HPP_
#include
<array>
#include
<algorithm>
#include
"FAbstractParticleContainer.hpp"
#include
"FAbstractSerializable.hpp"
...
...
@@ -11,8 +14,6 @@
#include
"Utils/FPoint.hpp"
#include
"FParticleType.hpp"
#include
<array>
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* Please read the license
...
...
@@ -135,7 +136,31 @@ public:
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
FBasicParticleContainer
(
const
FBasicParticleContainer
&
)
=
delete
;
// FBasicParticleContainer(const FBasicParticleContainer& leaf) = delete;
FBasicParticleContainer
(
FBasicParticleContainer
&
leaf
)
:
nbParticles
(
leaf
.
nbParticles
),
allocatedParticles
(
leaf
.
allocatedParticles
)
{
// allocate memory
const
FSize
moduloParticlesNumber
=
(
MemoryAlignement
/
sizeof
(
FReal
));
allocatedParticles
=
(
nbParticles
+
moduloParticlesNumber
-
1
)
&
~
(
moduloParticlesNumber
-
1
);
// init with 0
const
size_t
allocatedBytes
=
(
sizeof
(
FReal
)
*
3
+
sizeof
(
AttributeClass
)
*
NbAttributesPerParticle
)
*
allocatedParticles
;
FReal
*
newData
=
reinterpret_cast
<
FReal
*>
(
FAlignedMemory
::
AllocateBytes
<
MemoryAlignement
>
(
allocatedBytes
));
FReal
*
const
oldData
=
(
leaf
.
getWPositions
()[
0
]);
std
::
copy
(
oldData
,
oldData
+
allocatedBytes
,
newData
)
;
// Fill the structure
FAlignedMemory
::
DeallocBytes
(
positions
[
0
]);
for
(
int
idx
=
0
;
idx
<
3
;
++
idx
){
positions
[
idx
]
=
newData
+
(
allocatedParticles
*
idx
);
}
AttributeClass
*
startAddress
=
reinterpret_cast
<
AttributeClass
*>
(
positions
[
2
]
+
allocatedParticles
);
for
(
unsigned
idx
=
0
;
idx
<
NbAttributesPerParticle
;
++
idx
){
attributes
[
idx
]
=
startAddress
+
(
idx
*
allocatedParticles
);
}
}
FBasicParticleContainer
&
operator
=
(
const
FBasicParticleContainer
&
)
=
delete
;
/////////////////////////////////////////////////////
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment