# Path: sucemfem/Testing/Paths.py
# def get_module_path(modfile):
# def get_module_path_filename(filename, __file__):
# def get_module_path_file(filename, __file__, mode='r'):
# 
# Path: sucemfem/Utilities/MeshGenerators.py
# def get_centred_cube(domain_size, max_edge_len, centred_element_coordinate=None):
#     """ Generate a cube mesh centred arount [0,0,0]
# 
#     optionally translates mesh slightly such that
#     centred_element_coordinate is at the centre of an element.
#     """
#     domain_subdivisions = N.array(N.ceil(N.sqrt(2)*domain_size/max_edge_len), N.uint)
#     mesh = dolfin.UnitCube(*domain_subdivisions)
#     # Transform mesh to correct dimensions
#     mesh.coordinates()[:] *= domain_size
#     mesh.coordinates()[:] -= domain_size/2
#     if centred_element_coordinate is not None:
#         ## Translate mesh slightly so that source coordinate lies at
#         ## centroid of an element
#         centred_element_point = dolfin.Point(*centred_element_coordinate)
# #        source_elnos = mesh.all_intersected_entities(centred_element_point)
#         source_elnos = mesh.intersected_cells(centred_element_point)
#         closest_elno = source_elnos[(N.argmin(
#             [centred_element_point.distance(dolfin.Cell(mesh, i).midpoint())
#              for i in source_elnos]))]
#         centre_pt = dolfin.Cell(mesh, closest_elno).midpoint()
#         centre_coord = N.array([centre_pt.x(), centre_pt.y(), centre_pt.z()])
#         # The mesh intersect operator caches certain data
#         # structures. We need to clear them if the mesh coordinates
#         # are changed after calling any mesh intersection methods.
#         mesh.intersection_operator().clear()
#         mesh.coordinates()[:] -= centre_coord
#     return mesh
# 
# Path: sucemfem/PostProcessing/surface_ntff.py
# class SurfaceNTFFForms(object):
# class NTFF(object):
#     def __init__(self, function_space):
#     def set_dofs(self, dofs):
#     def get_N_form(self):
#     def get_L_form(self):
#     def assemble_N(self):
#     def assemble_L(self):
#     def set_parms(self, theta, phi, k0):
#     def __init__(self, function_space):
#     def set_dofs(self, dofs):
#     def set_frequency(self, frequency):
#     def calc_pt(self, theta_deg, phi_deg):
#         N = self.get_N_form()
#         L = self.get_L_form()
# 
# Path: sucemfem/PostProcessing/variational_ntff.py
# class TransformTestingExpression(object):
# class NTFF(object):
#     def __init__(self):
#     def set_parms(self, rhat, ahat, k0):
#     def _set_expr_parms(self, expr, rhat, k0, constfac):
#     def get_expression(self):
#     def __init__(self, function_space, testing_space=None):
#     def set_k0(self, k0):
#     def set_frequency(self, frequency):
#     def set_dofs(self, dofs):
#     def calc_pt(self, theta_deg, phi_deg):
#     def calc_pt_E_H(self, theta_deg, phi_deg):
#     def calc_ff_func(self, rhat, ahat):


import unittest
import pickle
import numpy as N
import dolfin
from sucemfem.Testing import Paths
from sucemfem.Utilities.MeshGenerators import get_centred_cube
from sucemfem.PostProcessing import surface_ntff
from sucemfem.PostProcessing import variational_ntff
## (at your option) any later version.
##
## SUCEM is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with SUCEM. If not, see <http://www.gnu.org/licenses/>. 
##
## Contact: cemagga@gmail.com 
# Authors:
# Neilen Marais <nmarais@gmail.com>
from __future__ import division


# Module under test:

class test_interpolant(unittest.TestCase):
    test_data_file = 'data/interpolant_test_data.pickle'
    rtol=1e-10
    atol=1e-7

    def setUp(self):
        desired_file = Paths.get_module_path_file(self.test_data_file, __file__)
        self.desired_data = pickle.load(desired_file)
            
class test_interpolant_expression(test_interpolant):
    def setUp(self):
        super(test_interpolant_expression, self).setUp()

# Path: sucemfem/Testing/Paths.py
# def get_module_path(modfile):
# def get_module_path_filename(filename, __file__):
# def get_module_path_file(filename, __file__, mode='r'):
# 
# Path: sucemfem/Utilities/MeshGenerators.py
# def get_centred_cube(domain_size, max_edge_len, centred_element_coordinate=None):
#     """ Generate a cube mesh centred arount [0,0,0]
# 
#     optionally translates mesh slightly such that
#     centred_element_coordinate is at the centre of an element.
#     """
#     domain_subdivisions = N.array(N.ceil(N.sqrt(2)*domain_size/max_edge_len), N.uint)
#     mesh = dolfin.UnitCube(*domain_subdivisions)
#     # Transform mesh to correct dimensions
#     mesh.coordinates()[:] *= domain_size
#     mesh.coordinates()[:] -= domain_size/2
#     if centred_element_coordinate is not None:
#         ## Translate mesh slightly so that source coordinate lies at
#         ## centroid of an element
#         centred_element_point = dolfin.Point(*centred_element_coordinate)
# #        source_elnos = mesh.all_intersected_entities(centred_element_point)
#         source_elnos = mesh.intersected_cells(centred_element_point)
#         closest_elno = source_elnos[(N.argmin(
#             [centred_element_point.distance(dolfin.Cell(mesh, i).midpoint())
#              for i in source_elnos]))]
#         centre_pt = dolfin.Cell(mesh, closest_elno).midpoint()
#         centre_coord = N.array([centre_pt.x(), centre_pt.y(), centre_pt.z()])
#         # The mesh intersect operator caches certain data
#         # structures. We need to clear them if the mesh coordinates
#         # are changed after calling any mesh intersection methods.
#         mesh.intersection_operator().clear()
#         mesh.coordinates()[:] -= centre_coord
#     return mesh
# 
# Path: sucemfem/PostProcessing/surface_ntff.py
# class SurfaceNTFFForms(object):
# class NTFF(object):
#     def __init__(self, function_space):
#     def set_dofs(self, dofs):
#     def get_N_form(self):
#     def get_L_form(self):
#     def assemble_N(self):
#     def assemble_L(self):
#     def set_parms(self, theta, phi, k0):
#     def __init__(self, function_space):
#     def set_dofs(self, dofs):
#     def set_frequency(self, frequency):
#     def calc_pt(self, theta_deg, phi_deg):
#         N = self.get_N_form()
#         L = self.get_L_form()
# 
# Path: sucemfem/PostProcessing/variational_ntff.py
# class TransformTestingExpression(object):
# class NTFF(object):
#     def __init__(self):
#     def set_parms(self, rhat, ahat, k0):
#     def _set_expr_parms(self, expr, rhat, k0, constfac):
#     def get_expression(self):
#     def __init__(self, function_space, testing_space=None):
#     def set_k0(self, k0):
#     def set_frequency(self, frequency):
#     def set_dofs(self, dofs):
#     def calc_pt(self, theta_deg, phi_deg):
#     def calc_pt_E_H(self, theta_deg, phi_deg):
#     def calc_ff_func(self, rhat, ahat):


# Path: sucemfem/PostProcessing/tests/test_ntff.py
import unittest
import pickle
import numpy as N
import dolfin
from sucemfem.Testing import Paths
from sucemfem.Utilities.MeshGenerators import get_centred_cube
from sucemfem.PostProcessing import surface_ntff
from sucemfem.PostProcessing import variational_ntff

## (at your option) any later version.
##
## SUCEM is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with SUCEM. If not, see <http://www.gnu.org/licenses/>. 
##
## Contact: cemagga@gmail.com 
# Authors:
# Neilen Marais <nmarais@gmail.com>
from __future__ import division


# Module under test:

class test_interpolant(unittest.TestCase):
    test_data_file = 'data/interpolant_test_data.pickle'
    rtol=1e-10
    atol=1e-7

    def setUp(self):
        desired_file = Paths.get_module_path_file(self.test_data_file, __file__)
        self.desired_data = pickle.load(desired_file)
            
class test_interpolant_expression(test_interpolant):
    def setUp(self):
        super(test_interpolant_expression, self).setUp()

        self.DUT = variational_ntff.TransformTestingExpression()