/*
 * 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;
    bool flag;
} Particle;

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

    int estimatedNumParticles;

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

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

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

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