40#define cross_product(av,bv) (av).cross(bv)
41#define dot_product(av,bv) (av).dot(bv)
42#define vector_length(v) (v).norm()
43#define normalize_vector(v) (v).normalized()
45int main(
int argc,
char** argv) {
47 MPI_Init(&argc, &argv);
52 parameters.
parse(
false);
54 std::cerr <<
"Parsing parameters failed, aborting." << std::endl;
55 std::cerr <<
"Did you add a --run_config=file.cfg parameter?" << std::endl;
61 char filename_buffer[256];
67 snprintf(filename_buffer,256,filename_pattern.c_str(),input_file_counter-1);
75 if(B[0].dimension[0]->cells <= 1) {
79 if(B[0].dimension[1]->cells <= 1) {
83 if(B[0].dimension[2]->cells <= 1) {
100 int maxsteps = maxtime/
dt;
105 std::cerr <<
"Pushing " << particles.size() <<
" particles for " << maxsteps <<
" steps..." << std::endl;
106 std::cerr <<
"[ ]\x0d[";
109 for(
int step=0; step<maxsteps; step++) {
115 B[0], B[1],
V, scenario->
needV, input_file_counter);
118 B[1], B[0],
V, scenario->
needV, input_file_counter);
126 scenario->
newTimestep(input_file_counter, step, step*
dt, particles, cur_E, cur_B,
V);
131 #pragma omp parallel for
132 for(
unsigned int i=0;
i< particles.size();
i++) {
142 Eval = cur_E(particles[
i].x);
143 Bval = cur_B(particles[
i].x);
151 particles[
i].push(Bval,Eval,
dt);
157 for(
auto i = particles.begin();
i != particles.end(); ) {
161 bool do_erase =
false;
178 scenario->
afterPush(step, step*
dt, particles, cur_E, cur_B,
V);
181 if((step % (maxsteps/71))==0) {
186 scenario->
finalize(particles,E[1],B[1],
V);
188 std::cerr << std::endl;
Boundary * createBoundary(int dimension)
static bool parse(const bool needsRunConfig=true, const bool allowUnknown=true)
std::vector< Particle, aligned_allocator< Particle, 32 > > ParticleContainer
bool readNextTimestep(const std::string &filename_pattern, double t, int step, Field &E0, Field &E1, Field &B0, Field &B1, Field &V, bool doV, int &input_file_counter)
void readfields(const char *filename, Field &E, Field &B, Field &V, bool doV=true)
Scenario * createScenario()
static Boundary * boundary_behaviour_x
static bool addParameters()
static Boundary * boundary_behaviour_z
static std::string input_filename_pattern
static Boundary * boundary_behaviour_y
static bool getParameters()
virtual void finalize(ParticleContainer &particles, Field &E, Field &B, Field &V)
virtual void afterPush(int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
virtual void beforePush(ParticleContainer &particles, Field &E, Field &B, Field &V)
virtual void newTimestep(int input_file_counter, int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
virtual ParticleContainer initialParticles(Field &E, Field &B, Field &V)
static ARCH_HOSTDEV VecSimple< T > min(VecSimple< T > const &l, VecSimple< T > const &r)
static ARCH_HOSTDEV VecSimple< T > max(VecSimple< T > const &l, VecSimple< T > const &r)
static ARCH_HOSTDEV VecSimple< T > floor(VecSimple< T > const &a)