/*
eyee.c

E on Yee E point
*/

#include "oth.h"
#include "complex.h"
#include "oth_prototype.h"

d_complex_t exyee(int f, int i, int j, int k, int exclude)
{
	assert((f >= 0) && (f < NFrequency));
	assert((i >= 0) && (i < Nx) && (j >= 0) && (j <= Ny) && (k >= 0) && (k <= Nz));

	d_complex_t ex = d_cast(Ex[f][i][j][k]);

	if (IPlanewave) {
		d_complex_t exi = planewave(0, Xc[i], Yn[j], Zn[k], f);
		if      (exclude == 0) {  // Es + Ei
			ex = d_add(ex, exi);
		}
		else if (exclude == 1) {  // Es
			;
		}
		else if (exclude == 2) {  // Ei
			ex = exi;
		}
	}

	return ex;
}

d_complex_t eyyee(int f, int i, int j, int k, int exclude)
{
	assert((f >= 0) && (f < NFrequency));
	assert((j >= 0) && (j < Ny) && (k >= 0) && (k <= Nz) && (i >= 0) && (i <= Nx));

	d_complex_t ey = d_cast(Ey[f][i][j][k]);

	if (IPlanewave) {
		d_complex_t eyi = planewave(1, Xn[i], Yc[j], Zn[k], f);
		if      (exclude == 0) {  // Es + Ei
			ey = d_add(ey, eyi);
		}
		else if (exclude == 1) {  // Es
			;
		}
		else if (exclude == 2) {  // Ei
			ey = eyi;
		}
	}

	return ey;
}

d_complex_t ezyee(int f, int i, int j, int k, int exclude)
{
	assert((f >= 0) && (f < NFrequency));
	assert((k >= 0) && (k < Nz) && (i >= 0) && (i <= Nx) && (j >= 0) && (j <= Ny));

	d_complex_t ez = d_cast(Ez[f][i][j][k]);

	if (IPlanewave) {
		d_complex_t ezi = planewave(2, Xn[i], Yn[j], Zc[k], f);
		if      (exclude == 0) {  // Es + Ei
			ez = d_add(ez, ezi);
		}
		else if (exclude == 1) {  // Es
			;
		}
		else if (exclude == 2) {  // Ei
			ez = ezi;
		}
	}

	return ez;
}
