forked from hannorein/rebound
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboundaries_periodic.c
80 lines (74 loc) · 2.01 KB
/
boundaries_periodic.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* @file boundaries.c
* @brief Implementation of periodic boundary conditions.
* @author Hanno Rein <[email protected]>
*
* @details The code supports different boundary conditions.
* This file implements simple periodic boundary conditions.
*
*
* @section LICENSE
* Copyright (c) 2011 Hanno Rein, Shangfei Liu
*
* This file is part of rebound.
*
* rebound is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* rebound is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rebound. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <time.h>
#include "particle.h"
#include "integrator.h"
#include "main.h"
#include "boundaries.h"
#include "tree.h"
int nghostx = 1;
int nghosty = 1;
int nghostz = 1;
void boundaries_check(){
#pragma omp parallel for schedule(guided)
for (int i=0;i<N;i++){
while(particles[i].x>boxsize_x/2.){
particles[i].x -= boxsize_x;
}
while(particles[i].x<-boxsize_x/2.){
particles[i].x += boxsize_x;
}
while(particles[i].y>boxsize_y/2.){
particles[i].y -= boxsize_y;
}
while(particles[i].y<-boxsize_y/2.){
particles[i].y += boxsize_y;
}
while(particles[i].z>boxsize_z/2.){
particles[i].z -= boxsize_z;
}
while(particles[i].z<-boxsize_z/2.){
particles[i].z += boxsize_z;
}
}
}
struct ghostbox boundaries_get_ghostbox(int i, int j, int k){
struct ghostbox gb;
gb.shiftx = boxsize_x*(double)i;
gb.shifty = boxsize_y*(double)j;
gb.shiftz = boxsize_z*(double)k;
gb.shiftvx = 0;
gb.shiftvy = 0;
gb.shiftvz = 0;
return gb;
}