forked from ALaDyn/piccante
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrent.h
83 lines (60 loc) · 2.95 KB
/
current.h
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
79
80
81
82
/* Copyright 2014 - Andrea Sgattoni, Luca Fedeli, Stefano Sinigardi */
/*******************************************************************************
This file is part of piccante.
piccante 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.
piccante 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 piccante. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
#ifndef __CURRENT_H__
#define __CURRENT_H__
#define _USE_MATH_DEFINES
#include <mpi.h>
//#include <malloc.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <string>
#include <stdint.h>
#include "commons.h"
#include "grid.h"
#include "structures.h"
class CURRENT{
public:
double *getDataPointer();
void writeN_grid(int *N_grid);
int Ncomp; // N grid point including ghost cells,N_grid[0]*N_grid[1]*N_grid[2], comp number
//double max_value[6],min_value[6]; //12 utility values
CURRENT();
~CURRENT();
void allocate(GRID *grid); //field allocation
void reallocate(); //REALLOCATION only if load balancing is introduced
void setAllValuesToZero();
CURRENT operator = (CURRENT &destro);
integer_or_halfinteger getJCoords(int c);
integer_or_halfinteger getDensityCoords();
void pbc();
void eraseDensity();
//PUBLIC INLINE FUNCTIONS
inline double & Jx(int i, int j, int k){ return val[my_indice(mygrid->getEdge(), YGrid_factor, ZGrid_factor, 0, i, j*YGrid_factor, k*ZGrid_factor, N_grid[0], N_grid[1], N_grid[2], Ncomp)]; }
inline double & Jy(int i, int j, int k){ return val[my_indice(mygrid->getEdge(), YGrid_factor, ZGrid_factor, 1, i, j*YGrid_factor, k*ZGrid_factor, N_grid[0], N_grid[1], N_grid[2], Ncomp)]; }
inline double & Jz(int i, int j, int k){ return val[my_indice(mygrid->getEdge(), YGrid_factor, ZGrid_factor, 2, i, j*YGrid_factor, k*ZGrid_factor, N_grid[0], N_grid[1], N_grid[2], Ncomp)]; }
inline double & density(int i, int j, int k){ return val[my_indice(mygrid->getEdge(), YGrid_factor, ZGrid_factor, 3, i, j*YGrid_factor, k*ZGrid_factor, N_grid[0], N_grid[1], N_grid[2], Ncomp)]; }
inline double & JJ(int c, int i, int j, int k){ return val[my_indice(mygrid->getEdge(), YGrid_factor, ZGrid_factor, c, i, j*YGrid_factor, k*ZGrid_factor, N_grid[0], N_grid[1], N_grid[2], Ncomp)]; }
private:
int N_grid[3];
uint64_t Ntot;
int ZGrid_factor, YGrid_factor;
double *val; // THE BIG poiniter
GRID *mygrid; // pointer to the GIRD object
int allocated; //flag 1-0 allocaded-not alloc
};
#endif