Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90748267
simu_gol.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Nov 4, 10:04
Size
1 KB
Mime Type
text/x-c++
Expires
Wed, Nov 6, 10:04 (2 d)
Engine
blob
Format
Raw Data
Handle
22128818
Attached To
rSCMINICLUSTER SCITAS Mini Cluster
simu_gol.hh
View Options
#ifndef SIMU_GOL_HH
#define SIMU_GOL_HH
#include "simu.hh"
/* -------------------------------------------------------------------------- */
class
GOL
:
public
Simu
{
public
:
GOL
(
long
int
dims
[
2
],
int
ghost
,
bool
periodic
,
MPI_Comm
global_comm
,
const
std
::
string
&
server
,
int
port
=
4321
)
:
Simu
(
dims
,
ghost
,
periodic
,
global_comm
,
server
,
port
)
{}
GOL
(
long
int
dims
[
2
],
int
ghost
,
bool
periodic
=
true
,
MPI_Comm
global_comm
=
MPI_COMM_WORLD
)
:
Simu
(
dims
,
ghost
,
periodic
,
global_comm
)
{}
void
determineCell
(
long
int
i
,
long
int
j
,
int
tid
)
{
long
int
_i
=
i
;
long
int
_j
=
j
;
char
neighbours
=
-
((
*
_old_grid
)(
_i
,
_j
)
&
0x0F
);
for
(
char
v
=
-
1
;
v
<
2
;
++
v
)
for
(
char
w
=
-
1
;
w
<
2
;
++
w
)
neighbours
+=
((
*
_old_grid
)(
_i
+
v
,
_j
+
w
)
&
0x0F
);
char
res
=
0
;
if
(
neighbours
==
2
)
{
res
=
(
*
_old_grid
)(
i
,
j
)
&
0x0F
;
}
else
if
(
neighbours
==
3
)
{
res
=
1
;
}
(
*
_grid
)(
_i
,
_j
)
=
res
+
(
tid
<<
4
);
}
void
initialState
(
bool
random
)
{
if
(
random
)
{
_old_grid
->
randomize
();
}
else
{
_old_grid
->
clear
();
}
}
};
#endif
/* SIMU_GOL_HH */
Event Timeline
Log In to Comment