# Path: sucemfem/Consts.py
# Z0 = mu0*c0                              


import numpy as np
import dolfin
import sucemfem.PostProcessing.ntff_expressions as ntff_expressions
from dolfin import curl, cross, dx, ds, Constant, dot
from sucemfem.Consts import Z0, c0


class SurfaceNTFFForms(object):
    def __init__(self, function_space):
        self.function_space = V = function_space
        self.n = V.cell().n
        # \vec{r'}, i.e. rprime is simply the position vector
        self.rprime = V.cell().x
        self.E_r = dolfin.Function(V)
        self.E_i = dolfin.Function(V)
        self.r_hat = ntff_expressions.get_r_hat()
        self.k0 = ntff_expressions.get_k0()
        self.theta_hat = ntff_expressions.get_theta_hat()
        self.phi_hat = ntff_expressions.get_phi_hat()
        # phase term to be used in sin/cos
        self.phase = ntff_expressions.get_phase(self.k0, self.rprime, self.r_hat)

    def set_dofs(self, dofs):
        x_r = np.real(dofs).copy()
        x_i = np.imag(dofs).copy()
        self.E_r.vector()[:] = x_r
        self.E_i.vector()[:] = x_i

    def get_N_form(self):
        try:
            return self.N_form
        except AttributeError:
            pass
        # Set up magnetic field and equivalent electric current forms
        H_r = -curl(self.E_i)/(self.k0*Z0)

# Path: sucemfem/Consts.py
# Z0 = mu0*c0                              


# Path: sucemfem/PostProcessing/surface_ntff.py
import numpy as np
import dolfin
import sucemfem.PostProcessing.ntff_expressions as ntff_expressions
from dolfin import curl, cross, dx, ds, Constant, dot
from sucemfem.Consts import Z0, c0



class SurfaceNTFFForms(object):
    def __init__(self, function_space):
        self.function_space = V = function_space
        self.n = V.cell().n
        # \vec{r'}, i.e. rprime is simply the position vector
        self.rprime = V.cell().x
        self.E_r = dolfin.Function(V)
        self.E_i = dolfin.Function(V)
        self.r_hat = ntff_expressions.get_r_hat()
        self.k0 = ntff_expressions.get_k0()
        self.theta_hat = ntff_expressions.get_theta_hat()
        self.phi_hat = ntff_expressions.get_phi_hat()
        # phase term to be used in sin/cos
        self.phase = ntff_expressions.get_phase(self.k0, self.rprime, self.r_hat)

    def set_dofs(self, dofs):
        x_r = np.real(dofs).copy()
        x_i = np.imag(dofs).copy()
        self.E_r.vector()[:] = x_r
        self.E_i.vector()[:] = x_i

    def get_N_form(self):
        try:
            return self.N_form
        except AttributeError:
            pass
        # Set up magnetic field and equivalent electric current forms
        H_r = -curl(self.E_i)/(self.k0*Z0)

        H_i = curl(self.E_r)/(self.k0*Z0)