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


import sys
import numpy as N
import os
import dolfin as dol
import scipy.sparse
import point_source
from dolfin import dot, cross, curl, inner, dx, ds
from sucemfem.Consts import eps0, mu0, c0
from scipy.sparse import csr_matrix
from pyamg import smoothed_aggregation_solver
from numpy import intc
# Define basis and bilinear form
k_0 = 2*N.pi*freq/c0

u = dol.TrialFunction(V)
v = dol.TestFunction(V)

m = eps_r*inner(v, u)*dx                  # Mass form
s = (1/mu_r)*dot(curl(v), curl(u))*dx            # Stiffness form

n = V.cell().n
s_0 = inner ( cross ( n, v), cross ( n, u ) )*ds

def boundary(x, on_boundary):
    return on_boundary

# Assemble forms
M = dol.uBLASSparseMatrix()
S = dol.uBLASSparseMatrix()
S_0 = dol.uBLASSparseMatrix()

dol.assemble(m, tensor=M, mesh=mesh)
dol.assemble(s, tensor=S, mesh=mesh)
dol.assemble(s_0, tensor=S_0, mesh=mesh)


def to_scipy_csr(mat, dtype=None, imagify=False):
    (row,col,data) = mat.data()   # get sparse data
    col = intc(col)
    row = intc(row)
    n = mat.size(0)

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


# Path: sandbox/ABC/abc_test.py
import sys
import numpy as N
import os
import dolfin as dol
import scipy.sparse
import point_source
from dolfin import dot, cross, curl, inner, dx, ds
from sucemfem.Consts import eps0, mu0, c0
from scipy.sparse import csr_matrix
from pyamg import smoothed_aggregation_solver
from numpy import intc

# Define basis and bilinear form
k_0 = 2*N.pi*freq/c0

u = dol.TrialFunction(V)
v = dol.TestFunction(V)

m = eps_r*inner(v, u)*dx                  # Mass form
s = (1/mu_r)*dot(curl(v), curl(u))*dx            # Stiffness form

n = V.cell().n
s_0 = inner ( cross ( n, v), cross ( n, u ) )*ds

def boundary(x, on_boundary):
    return on_boundary

# Assemble forms
M = dol.uBLASSparseMatrix()
S = dol.uBLASSparseMatrix()
S_0 = dol.uBLASSparseMatrix()

dol.assemble(m, tensor=M, mesh=mesh)
dol.assemble(s, tensor=S, mesh=mesh)
dol.assemble(s_0, tensor=S_0, mesh=mesh)


def to_scipy_csr(mat, dtype=None, imagify=False):
    (row,col,data) = mat.data()   # get sparse data
    col = intc(col)
    row = intc(row)
    n = mat.size(0)

    if imagify: data = data*1j