# -*- coding: utf-8 -*-

'''
Created on 2012-5-25

@author: epsilon
'''
from simpmeshfree_gui import jvm_utils as ju
from jpype import *
from matplotlib.patches import Circle
import matplotlib.pyplot as plt
import numpy as np
if __name__ == '__main__':
    ju.start_jvm(debug_port=8998)
    center=ju.Node(12.45,-20.8)
    rad=9.0
    theta=np.pi*2.1/3
    distances=[rad,rad-1,rad+1]
    colors=['red','green','black']
    lines=[np.array(ju.BoundaryUtilsTestUtils.genLine2DPerpendicularTo(center,theta,d,-rad,-rad/2)) for d in distances]
    fig=plt.figure()
    ax=fig.add_subplot(111)
    idx=0
    for line in lines:
        ax.plot((line[0],line[2]),(line[1],line[3]),color=colors[idx])
        idx+=1
    ax.add_patch(Circle((center.x,center.y),radius=rad))
    fig.canvas.draw()
    ax.set_aspect('equal')
    ax.autoscale()
    fig.show()
from simpmeshfree_gui.tools import JDArr_List_2_np,JTDList_List_2_np
import numpy as np
import math
import matplotlib.pyplot as plt
import sys
from simpmeshfree_gui.demo.PostProcessor_demo_tool import *
        
if __name__=='__main__':
    ben_debug=False
    for arg in sys.argv:
        if arg.find('no_debug')>-1:
            ben_debug=True
    debug_port=8998
    if(ben_debug):
        debug_port=None
    ju.start_jvm(debug_port=debug_port)
    
    iterativeSolver=False
    isSimpAsm=False
    core_num=1;
    monitors=java.util.ArrayList()
    monitors.add(ju.WeakformProcessorMonitors.recorder())
    monitors.add(ju.WeakformProcessorMonitors.simpLogger())
    monitor=ju.WeakformProcessorMonitors.compact(monitors)
    
    (processor,pipe)=run_processor(iterativeSolver=iterativeSolver,isSimpAsm=isSimpAsm,core_num=core_num,monitor=monitor)

    qp=ju.QuadraturePoint()
    conLaw=ju.CommonUtils.toDenseMatrix64F(pipe.conLaw)   
    workPb=pipe.workProblem
    tBeam=workPb.tBeam 
# coding: utf-8
from simpmeshfree_gui.jvm_utils import start_jvm

from jpype import JClass
from simpmeshfree_gui.plot2d import GeomUtilsPainter, gen_net_path
import matplotlib.pyplot as plt
from matplotlib.patches import PathPatch

if __name__ == "__main__":
    start_jvm(debug_port=8998)
    RectangleModel = JClass('net.epsilony.simpmeshfree.model2d.RectangleModel')
    r_m = RectangleModel(100.0, 20.0, 5.0, 10.0)
    GeomUtils = JClass('net.epsilony.simpmeshfree.model.GeomUtils')
    gu = GeomUtils(r_m.boundaries(), r_m.spaceNodes(), 2)
    
    fig = plt.figure()
    ax = fig.add_subplot(111, aspect='equal')
    gu_p = GeomUtilsPainter(ax, gu)
    gu_p.plot()
    quads = r_m.quadrangles()
    pth = gen_net_path(quads)
    ax.add_patch(PathPatch(pth, color='red', fill=False, alpha=0.3))
    pth = gen_net_path(r_m.triangles())
    ax.add_patch(PathPatch(pth, color='red', fill=False, alpha=0.9, lw=2))
    ax.autoscale()
    gu_p.draw()
    
    fig.show()

from simpmeshfree_gui import jvm_utils as ju
import numpy as np
from mpl_toolkits.mplot3d.axes3d import Axes3D
import matplotlib.pyplot as plt

if __name__=="__main__":
    ju.start_jvm(8998)
    coord=ju.Coordinate()
    sample=ju.SampleC1LSF()
    
    sample_ext_margin=0
    s_x0=sample.x0-sample_ext_margin
    s_y0=sample.y0-sample_ext_margin
    s_w=sample.w+sample_ext_margin*2
    s_h=sample.h+sample_ext_margin*2
    
    n_w=300
    n_h=500
    
    (X,Y)=np.meshgrid(np.linspace(s_x0, s_x0+s_w,n_w), np.linspace(s_y0,s_y0+s_h,n_h))
    
    
    Z=np.zeros_like(X,dtype=np.double)
    Z_x=np.zeros_like(X,dtype=np.double)
    Z_y=np.zeros_like(X,dtype=np.double)
    
    sample.setDiffOrder(1)
    for i in xrange(X.shape[0]):
        for j in xrange(X.shape[1]):
            coord.x=X[i,j]
            coord.y=Y[i,j]