# Path: discretize/tests.py
# def setup_mesh(mesh_type, nC, nDim):
#         def function(cell):
#     def setupMesh(self, nC):
#     def getError(self):
#     def orderTest(self):
# def rosenbrock(x, return_g=True, return_H=True):
# def check_derivative(
#     fctn,
#     x0,
#     num=7,
#     plotIt=True,
#     dx=None,
#     expectedOrder=2,
#     tolerance=0.85,
#     eps=1e-10,
#     ax=None,
# ):
#     def l2norm(x):
#     def plot_it(ax):
# def get_quadratic(A, b, c=0):
#     def Quadratic(x, return_g=True, return_H=True):
#             X, Y = example_curvilinear_grid([nC, nC], kwrd)
#             X, Y, Z = example_curvilinear_grid([nC, nC, nC], kwrd)
#     H = sp.csr_matrix(
#         np.array(
#             [[-400 * x[1] + 1200 * x[0] ** 2 + 2, -400 * x[0]], [-400 * x[0], 200]]
#         )
#     )
#     E0 = np.ones(h.shape)
#     E1 = np.ones(h.shape)
#             H = A
# class OrderTest(unittest.TestCase):


import unittest
import numpy as np
import sympy
import discretize
from sympy.abc import r, t, z
from discretize import tests
    meshTypes = MESHTYPES
    meshDimension = 3
    meshSizes = [8, 16, 32, 64]

    def getError(self):

        funR = lambda r, t, z: np.sin(2.0 * np.pi * r)
        funT = lambda r, t, z: r * np.exp(-r) * np.sin(t)  # * np.sin(2.*np.pi*r)
        funZ = lambda r, t, z: np.sin(2.0 * np.pi * z)

        sol = lambda r, t, z: (
            (2 * np.pi * r * np.cos(2 * np.pi * r) + np.sin(2 * np.pi * r)) / r
            + np.exp(-r) * np.cos(t)
            + 2 * np.pi * np.cos(2 * np.pi * z)
        )

        Fc = cylF3(self.M, funR, funT, funZ)
        # Fc = np.c_[Fc[:, 0], np.zeros(self.M.nF), Fc[:, 1]]
        F = self.M.projectFaceVector(Fc)

        divF = self.M.faceDiv.dot(F)
        divF_ana = call3(sol, self.M.gridCC)

        err = np.linalg.norm((divF - divF_ana), np.inf)
        return err

    def test_order(self):
        self.orderTest()



# Path: discretize/tests.py
# def setup_mesh(mesh_type, nC, nDim):
#         def function(cell):
#     def setupMesh(self, nC):
#     def getError(self):
#     def orderTest(self):
# def rosenbrock(x, return_g=True, return_H=True):
# def check_derivative(
#     fctn,
#     x0,
#     num=7,
#     plotIt=True,
#     dx=None,
#     expectedOrder=2,
#     tolerance=0.85,
#     eps=1e-10,
#     ax=None,
# ):
#     def l2norm(x):
#     def plot_it(ax):
# def get_quadratic(A, b, c=0):
#     def Quadratic(x, return_g=True, return_H=True):
#             X, Y = example_curvilinear_grid([nC, nC], kwrd)
#             X, Y, Z = example_curvilinear_grid([nC, nC, nC], kwrd)
#     H = sp.csr_matrix(
#         np.array(
#             [[-400 * x[1] + 1200 * x[0] ** 2 + 2, -400 * x[0]], [-400 * x[0], 200]]
#         )
#     )
#     E0 = np.ones(h.shape)
#     E1 = np.ones(h.shape)
#             H = A
# class OrderTest(unittest.TestCase):


# Path: tests/cyl/test_cylOperators.py
import unittest
import numpy as np
import sympy
import discretize
from sympy.abc import r, t, z
from discretize import tests

    meshTypes = MESHTYPES
    meshDimension = 3
    meshSizes = [8, 16, 32, 64]

    def getError(self):

        funR = lambda r, t, z: np.sin(2.0 * np.pi * r)
        funT = lambda r, t, z: r * np.exp(-r) * np.sin(t)  # * np.sin(2.*np.pi*r)
        funZ = lambda r, t, z: np.sin(2.0 * np.pi * z)

        sol = lambda r, t, z: (
            (2 * np.pi * r * np.cos(2 * np.pi * r) + np.sin(2 * np.pi * r)) / r
            + np.exp(-r) * np.cos(t)
            + 2 * np.pi * np.cos(2 * np.pi * z)
        )

        Fc = cylF3(self.M, funR, funT, funZ)
        # Fc = np.c_[Fc[:, 0], np.zeros(self.M.nF), Fc[:, 1]]
        F = self.M.projectFaceVector(Fc)

        divF = self.M.faceDiv.dot(F)
        divF_ana = call3(sol, self.M.gridCC)

        err = np.linalg.norm((divF - divF_ana), np.inf)
        return err

    def test_order(self):
        self.orderTest()



class TestEdgeCurl3D(tests.OrderTest):