r"""
Sfepy parametrisation file
Solve the conduction equation with a Fourier Boundary condition
"""
import os
import numpy as np
import sys
from os import path
from interpolationToolbox import interpolate
from thermalSolver import ThermalSolver

filename_mesh =path.abspath('')+'/'+ 'bladeStructure.mesh'

materials = {
    'coef' : ({'c' : 1.0},),
    'heat_Coeff' : 'get_heat_Coeff',
    'exchange_var' : 'get_exchange',
}

regions = {
    'Omega' : 'all',
    'Gamma' : ('vertices of surface', 'facet'),
}

fields = {
    'temperature' : ('real', 1, 'Omega', 1),
}

variables = {
    't' : ('unknown field', 'temperature', 0),
    's' : ('test field', 'temperature', 't'),
}

ebcs = {
}

def get_heat_Coeff(ts, coors, mode=None, **kwargs):
    if mode == 'qp':
        val=interpolate(inputCoords='airfoil.dat',outputCoords=coors,inputVarFile='heat_Coeff.dat')
        val.shape = (coors.shape[0], 1,  1)
        print val
        return {'h' : val}
    
def get_exchange(ts, coors, mode=None, **kwargs):
    if mode == 'qp':
        val=interpolate(inputCoords='airfoil.dat',outputCoords=coors,inputVarFile='exchange.dat')
        val.shape = (coors.shape[0], 1,  1)
        
        return {'g' : val}

functions = {
    'get_heat_Coeff' : (get_heat_Coeff,),
    'get_exchange' : (get_exchange,),
}

integrals = {
    'i' : 2,
}

equations = {
    'Temperature' : 
    """dw_laplace.i.Omega( coef.c, s, t ) 
    + dw_surface_dot.i.Gamma( heat_Coeff.h , s, t )
    = dw_surface_integrate.i.Gamma( exchange_var.g, s )"""
}

solvers = {
    'ls' : ('ls.scipy_direct', {}),
    'newton' : ('nls.newton',
                {'i_max'      : 1,
                 'eps_a'      : 1e-10,
    }),
}

options = {
    'nls' : 'newton',
    'ls' : 'ls',
}