Swarm-NG
1.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
straight_line.cpp
Go to the documentation of this file.
1
/*************************************************************************
2
* Copyright (C) 2011 by Saleh Dindar and the Swarm-NG Development Team *
3
* *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 3 of the License. *
7
* *
8
* This program is distributed in the hope that it will be useful, *
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11
* GNU General Public License for more details. *
12
* *
13
* You should have received a copy of the GNU General Public License *
14
* along with this program; if not, write to the *
15
* Free Software Foundation, Inc., *
16
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
17
************************************************************************/
18
25
#include "
swarm/swarm.h
"
26
#include <iostream>
27
using namespace
swarm;
28
using namespace
std
;
29
30
const
int
nbod = 3;
31
const
int
nsys = 64;
32
34
int
main(
int
argc,
char
* argv[]){
35
if
(argc <= 1){
36
cout <<
"Usage: straight_line <outputfilename>"
<< endl;
37
}
38
const
string
outputfn = argv[1];
39
init
(
config
());
40
defaultEnsemble
ens =
defaultEnsemble::create
(nbod,nsys);
41
42
for
(
int
s = 0; s < nsys ; s++){
43
ens[s].id() = 0;
44
ens[s].time() = 0;
45
46
// Set all the bodies to zero
47
for
(
int
b = 0; b < nbod; b++){
48
ens[s][b].mass() = 0;
49
for
(
int
c
= 0;
c
< 3;
c
++)
50
ens[s][b][
c
].pos() = 0, ens[s][b][
c
].vel() = 0;
51
}
52
53
// the central one has to pull everything together
54
ens[s][0].mass() = 1;
55
ens[s][1][0].pos() = -10;
56
ens[s][2][0].pos() = +10;
57
58
}
59
snapshot::save_text
(ens,outputfn);
60
}
61
62
63
swarm
src
utils
straight_line.cpp
Generated on Sun Jul 21 2013 11:11:54 for Swarm-NG by
1.8.4