/*
 * 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 <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, removedParticles;

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

    int pointer;

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

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

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