from data_class import *

# Tolerance for serching for points in tecplot file
tolerance = 2.0e-6


# Make an instance of unstructured data
b = unstruct_data(3)


#ACTUAL

##################
#     STEP 1     #
##################
#################################
#    LOADING STL SURFACE FILE   #
#################################

####OPTION 1####
## If STL/SURFACE grid changed##
#b.read_stl('stl/surface_A.stl') # Takes ~ 40 minutes
#b.write_tec('tec/from_stl_wing_surface.tec')

####OPTION 2####
## If stl is the same ###
b.read_tec('tec/from_stl_wing_surface.tec')


##################
#     STEP 2     #
##################
###########################################
#    LOADING TECPLOT FILE FROM NTS CODE   #
###########################################

####OPTION 1####
## No interfaces calculated yet (New grid, New solution) ##
# !!!!!! WILL OVERWRITE EXISTING INTERFACES !!!!!!!!!
# !!!!!!        NEED TO BACK THEM UP        !!!!!!!!!
#b.add_solution_data('tec/tenaca_t-00000001.tec', tolerance) # Takes ~ 1 hour
#b.add_solution_data('tec/tenaca_t-00000002.tec', tolerance) # Takes ~ 1 hour
## Write unstructured teclot file with field variables data
#b.write_tec('tec/tec_with_data.tec')
########

####OPTION 2####
## Interfaces already calculated (New Solution, Same grid) ##
b.add_solution_data('tec/tenaca_t-00000001.tec', tolerance, 'int/tenaca_t-00000001.int')
b.add_solution_data('tec/tenaca_t-00000002.tec', tolerance, 'int/tenaca_t-00000002.int')
## Write unstructured teclot file with field variables data
#b.write_tec('tec/tec_with_data.tec')
########

####OPTION 3####
## Just read previously written tec file
#b.read_tec('tec/tec_with_data.tec')
########


##################
#     STEP 3     #
##################
#####################
#    CALCULATIONS   #
#####################

## Calculate pressure force components

pres      = True
presIndex = 0
F_f = []
F_p, area  = b.calculate_pressure_forces(pressure_ind = presIndex, isPressure = pres)
F_f.append(b.calculate_shear_forces(1))
F_f.append(b.calculate_shear_forces(2))
F_f.append(b.calculate_shear_forces(3))

#area = 1.0
Vel0 = 2.95e+02
#R0   = 1.045e-1
#Vel0 = 1.0
R0   = 1.0

#scale = area * R0 * Vel0**2 / 2
scale = 1.0
scale_f = Vel0

Cd_p = [F_p[i] / scale for i in range(3)]
Cd_f = [F_f[i] / scale_f for i in range(3)]

print(' F_x = {p[0]},  F_y = {p[1]},  F_z = {p[2]}'.format(p =  F_p))
print('Cp_x = {p[0]}, Cp_y = {p[1]}, Cp_z = {p[2]}'.format(p = Cd_p))

print(' F_fx = {p[0]},  F_fy = {p[1]},  F_fz = {p[2]}'.format(p =  F_f))
print('Cpf_x = {p[0]}, Cpf_y = {p[1]}, Cpf_z = {p[2]}'.format(p = Cd_f))





#TESTS


#b.read_stl('test.stl')
#b.write_tec_data('from_stl_test.tec')
#b.write_element_data('test_elem_data.tec')
#b.read_element_data('test_elem_data.tec')
#b.write_element_data('test_elem_data1.tec')

d8b3211f746eeb05ade3eeea715a7b03d67fce76
<mask token>

<mask token>
b.read_tec('tec/from_stl_wing_surface.tec')
b.add_solution_data('tec/tenaca_t-00000001.tec', tolerance,
    'int/tenaca_t-00000001.int')
b.add_solution_data('tec/tenaca_t-00000002.tec', tolerance,
    'int/tenaca_t-00000002.int')
<mask token>
F_f.append(b.calculate_shear_forces(1))
F_f.append(b.calculate_shear_forces(2))
F_f.append(b.calculate_shear_forces(3))
<mask token>
print(' F_x = {p[0]},  F_y = {p[1]},  F_z = {p[2]}'.format(p=F_p))
print('Cp_x = {p[0]}, Cp_y = {p[1]}, Cp_z = {p[2]}'.format(p=Cd_p))
print(' F_fx = {p[0]},  F_fy = {p[1]},  F_fz = {p[2]}'.format(p=F_f))
print('Cpf_x = {p[0]}, Cpf_y = {p[1]}, Cpf_z = {p[2]}'.format(p=Cd_f))

<mask token>
tolerance = 2e-06
b = unstruct_data(3)
b.read_tec('tec/from_stl_wing_surface.tec')
b.add_solution_data('tec/tenaca_t-00000001.tec', tolerance,
    'int/tenaca_t-00000001.int')
b.add_solution_data('tec/tenaca_t-00000002.tec', tolerance,
    'int/tenaca_t-00000002.int')
pres = True
presIndex = 0
F_f = []
F_p, area = b.calculate_pressure_forces(pressure_ind=presIndex, isPressure=pres
    )
F_f.append(b.calculate_shear_forces(1))
F_f.append(b.calculate_shear_forces(2))
F_f.append(b.calculate_shear_forces(3))
Vel0 = 295.0
R0 = 1.0
scale = 1.0
scale_f = Vel0
Cd_p = [(F_p[i] / scale) for i in range(3)]
Cd_f = [(F_f[i] / scale_f) for i in range(3)]
print(' F_x = {p[0]},  F_y = {p[1]},  F_z = {p[2]}'.format(p=F_p))
print('Cp_x = {p[0]}, Cp_y = {p[1]}, Cp_z = {p[2]}'.format(p=Cd_p))
print(' F_fx = {p[0]},  F_fy = {p[1]},  F_fz = {p[2]}'.format(p=F_f))
print('Cpf_x = {p[0]}, Cpf_y = {p[1]}, Cpf_z = {p[2]}'.format(p=Cd_f))

from data_class import *
tolerance = 2e-06
b = unstruct_data(3)
b.read_tec('tec/from_stl_wing_surface.tec')
b.add_solution_data('tec/tenaca_t-00000001.tec', tolerance,
    'int/tenaca_t-00000001.int')
b.add_solution_data('tec/tenaca_t-00000002.tec', tolerance,
    'int/tenaca_t-00000002.int')
pres = True
presIndex = 0
F_f = []
F_p, area = b.calculate_pressure_forces(pressure_ind=presIndex, isPressure=pres
    )
F_f.append(b.calculate_shear_forces(1))
F_f.append(b.calculate_shear_forces(2))
F_f.append(b.calculate_shear_forces(3))
Vel0 = 295.0
R0 = 1.0
scale = 1.0
scale_f = Vel0
Cd_p = [(F_p[i] / scale) for i in range(3)]
Cd_f = [(F_f[i] / scale_f) for i in range(3)]
print(' F_x = {p[0]},  F_y = {p[1]},  F_z = {p[2]}'.format(p=F_p))
print('Cp_x = {p[0]}, Cp_y = {p[1]}, Cp_z = {p[2]}'.format(p=Cd_p))
print(' F_fx = {p[0]},  F_fy = {p[1]},  F_fz = {p[2]}'.format(p=F_f))
print('Cpf_x = {p[0]}, Cpf_y = {p[1]}, Cpf_z = {p[2]}'.format(p=Cd_f))

from data_class import *

# Tolerance for serching for points in tecplot file
tolerance = 2.0e-6


# Make an instance of unstructured data
b = unstruct_data(3)


#ACTUAL

##################
#     STEP 1     #
##################
#################################
#    LOADING STL SURFACE FILE   #
#################################

####OPTION 1####
## If STL/SURFACE grid changed##
#b.read_stl('stl/surface_A.stl') # Takes ~ 40 minutes
#b.write_tec('tec/from_stl_wing_surface.tec')

####OPTION 2####
## If stl is the same ###
b.read_tec('tec/from_stl_wing_surface.tec')


##################
#     STEP 2     #
##################
###########################################
#    LOADING TECPLOT FILE FROM NTS CODE   #
###########################################

####OPTION 1####
## No interfaces calculated yet (New grid, New solution) ##
# !!!!!! WILL OVERWRITE EXISTING INTERFACES !!!!!!!!!
# !!!!!!        NEED TO BACK THEM UP        !!!!!!!!!
#b.add_solution_data('tec/tenaca_t-00000001.tec', tolerance) # Takes ~ 1 hour
#b.add_solution_data('tec/tenaca_t-00000002.tec', tolerance) # Takes ~ 1 hour
## Write unstructured teclot file with field variables data
#b.write_tec('tec/tec_with_data.tec')
########

####OPTION 2####
## Interfaces already calculated (New Solution, Same grid) ##
b.add_solution_data('tec/tenaca_t-00000001.tec', tolerance, 'int/tenaca_t-00000001.int')
b.add_solution_data('tec/tenaca_t-00000002.tec', tolerance, 'int/tenaca_t-00000002.int')
## Write unstructured teclot file with field variables data
#b.write_tec('tec/tec_with_data.tec')
########

####OPTION 3####
## Just read previously written tec file
#b.read_tec('tec/tec_with_data.tec')
########


##################
#     STEP 3     #
##################
#####################
#    CALCULATIONS   #
#####################

## Calculate pressure force components

pres      = True
presIndex = 0
F_f = []
F_p, area  = b.calculate_pressure_forces(pressure_ind = presIndex, isPressure = pres)
F_f.append(b.calculate_shear_forces(1))
F_f.append(b.calculate_shear_forces(2))
F_f.append(b.calculate_shear_forces(3))

#area = 1.0
Vel0 = 2.95e+02
#R0   = 1.045e-1
#Vel0 = 1.0
R0   = 1.0

#scale = area * R0 * Vel0**2 / 2
scale = 1.0
scale_f = Vel0

Cd_p = [F_p[i] / scale for i in range(3)]
Cd_f = [F_f[i] / scale_f for i in range(3)]

print(' F_x = {p[0]},  F_y = {p[1]},  F_z = {p[2]}'.format(p =  F_p))
print('Cp_x = {p[0]}, Cp_y = {p[1]}, Cp_z = {p[2]}'.format(p = Cd_p))

print(' F_fx = {p[0]},  F_fy = {p[1]},  F_fz = {p[2]}'.format(p =  F_f))
print('Cpf_x = {p[0]}, Cpf_y = {p[1]}, Cpf_z = {p[2]}'.format(p = Cd_f))





#TESTS


#b.read_stl('test.stl')
#b.write_tec_data('from_stl_test.tec')
#b.write_element_data('test_elem_data.tec')
#b.read_element_data('test_elem_data.tec')
#b.write_element_data('test_elem_data1.tec')
