/*
 * Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
 * All rights reserved. This file is part of nusif-solver.
 * Use of this source code is governed by a MIT style
 * license that can be found in the LICENSE file.
 */
#ifndef __PARTICLETRACING_H_
#define __PARTICLETRACING_H_
#include "allocate.h"
#include "parameter.h"
#include "solver.h"
#include "particletracing.h"
#include <stdbool.h>

typedef enum COORD { X = 0, Y, NCOORD } COORD;
typedef struct
{
    double x, y, z;
    bool flag;
} Particle;

typedef struct {
    int numberOfParticles, totalParticles;
    double startTime, injectTimePeriod, writeTimePeriod, lastInjectTime, lastUpdateTime, lastWriteTime;

    int estimatedNumParticles, activeParticles;

    double dx, dy, dz, dt;
    Particle* linSpaceLine;
    Particle* particlePool;

    int pointer;
    
    double imax, jmax, kmax, xlength, ylength, zlength;

    double x1, y1, x2, y2, z1, z2;
} ParticleTracer;

void initParticleTracer(ParticleTracer*, Parameter*);
void injectParticles(ParticleTracer*);
void advanceParticles(ParticleTracer*, double* , double*, double*, double);
void freeParticles(ParticleTracer*);
void writeParticles(ParticleTracer*);
void printParticleTracerParameters(ParticleTracer*);
void printParticles(ParticleTracer*);
void compress(ParticleTracer*);
void trace(ParticleTracer*, double* , double* , double* , double);
#endif