Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/ein16/synth/d2/obj_field.py
ViewVC logotype

Diff of /branches/ein16/synth/d2/obj_field.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4458, Sat Aug 27 19:52:38 2016 UTC revision 4459, Mon Aug 29 15:57:31 2016 UTC
# Line 9  Line 9 
9  import sys  import sys
10  import re  import re
11  import os  import os
12    from constants import *
13  from obj_ty import *  from obj_ty import *
14  from obj_coeff import mk_exp  from obj_coeff import mk_exp
15    
16    class kernel:
17        def __init__(self, name, str, continuity, order):
18            self.name = name
19            self.str = str
20            self.continuity = continuity
21            self.order = order
22    
23    #kernel(name, str, continuity, order)
24    krn_hex = kernel("c4hexic", "c4hexic", 3, 3)
25    krn_bs3 = kernel("bspln3","bspln3", 2, 2)
26    krn_tent = kernel("tent", "tent", 0, 1)
27    
28    # transform kernel from input global to kernel variable
29    def transform_krn(krn, id):
30        if(krn == h_bs3):
31            return krn_bs3
32        elif(krn == h_hex):
33            return krn_hex
34        elif(krn == h_tent):
35            return krn_tent
36        elif(krn == h_mixcbc):
37            if(id == 0):
38                return krn_hex
39            elif(id == 1):
40                return krn_bs3
41            elif(id == 2):
42                return krn_hex
43        elif(krn == h_mixcbt):
44            if(id == 0):
45                return krn_hex
46            elif(id == 1):
47                return krn_bs3
48            elif(id == 2):
49                return krn_tent
50    
51        else:
52            raise Exception ("unsupported kernel type:", krn)
53    
54    # transform kernel from input global to kernel variable
55    def krn_to_k(krn):
56        return krn.continuity
57    def set_k(g_krn, id, ty1):
58        c_krn = transform_krn(g_krn, id)
59        c_k = c_krn.continuity
60        ty1.k = c_k
61        return
62    def set_ks(g_krn, ishapes):
63        id = 0
64        for i in ishapes:
65            set_k(g_krn, id, i)
66            id+=1
67        return
68    
69    
70  #returns expression created with coefficients  #returns expression created with coefficients
71  class field:  class field:
72      def __init__(self, isField, name, fldty, krn, data, inputfile):      def __init__(self, isField, name, fldty, krn, data, inputfile):
# Line 63  Line 118 
118          shape = ty0.fldty.shape          shape = ty0.fldty.shape
119          return  (len(shape)==3)          return  (len(shape)==3)
120    
121  def mk_Field(index, tys, k, inputfile, dim, coeff_style, ucoeff, krn):  #  i_fty: field type
122      #print "inside mk_fields: "+str(index)  def mk_Field(index, i_fty, k, inputfile, dim, coeff_style, ucoeff, krn):
123        #print "inside mk fields: "+str(index)
124      tag="_"+str(index)      tag="_"+str(index)
125      id="F"+tag      id="F"+tag
126      #print "index:", index," dim:",dim      # field type
127        finfo1 = fty.convertTy(i_fty, k)
     finfo1 = fty.convertTy(tys[index], k)  
128      # translate coefficients to expression      # translate coefficients to expression
   
   
129      # name of input file      # name of input file
130      input1 = inputfile+tag      input1 = inputfile+tag
131      def get_vec(n):      def get_vec(n):
# Line 156  Line 209 
209          if(fty.is_Scalar(finfo1)):          if(fty.is_Scalar(finfo1)):
210              (coeff1, exp1)= mk_exp(dim, coeff_style, ucoeff)              (coeff1, exp1)= mk_exp(dim, coeff_style, ucoeff)
211              (coeffs, exps) = (coeff1, exp1)              (coeffs, exps) = (coeff1, exp1)
212              F = field(false, id, tys[index],"", exps, "")              F = field(false, id, i_fty,"", exps, "")
213              #print ("Ften", field.toStr(F))              #print ("Ften", field.toStr(F))
214              return (F, finfo1, coeff1)              return (F, finfo1, coeff1)
215          elif(fty.is_Vector(finfo1)):          elif(fty.is_Vector(finfo1)):
216              n= fty.get_vecLength(finfo1)              n= fty.get_vecLength(finfo1)
217              (coeff1, exp1)= mk_exp(dim, coeff_style, ucoeff)              (coeff1, exp1)= mk_exp(dim, coeff_style, ucoeff)
218              (coeffs, exps) = get_vec(n)              (coeffs, exps) = get_vec(n)
219              F = field(false, id, tys[index],"", exps, "")              F = field(false, id, i_fty,"", exps, "")
220              #print ("Ften", field.toStr(F))              #print ("Ften", field.toStr(F))
221              return (F, finfo1, coeff1)              return (F, finfo1, coeff1)
222          elif(fty.is_Matrix(finfo1)):          elif(fty.is_Matrix(finfo1)):
223              [shape0, shape1] = fty.get_shape(finfo1)              [shape0, shape1] = fty.get_shape(finfo1)
224              (coeffs, exps) =  get_mat(shape0, shape1)              (coeffs, exps) =  get_mat(shape0, shape1)
225              F = field(false, id, tys[index],"", exps, "")              F = field(false, id, i_fty,"", exps, "")
226              #print ("Ften", field.toStr(F))              #print ("Ften", field.toStr(F))
227              return (F, finfo1, coeffs)              return (F, finfo1, coeffs)
228          elif(fty.is_Ten3(finfo1)):          elif(fty.is_Ten3(finfo1)):
229              [shape0, shape1, shape2] = fty.get_shape(finfo1)              [shape0, shape1, shape2] = fty.get_shape(finfo1)
230              (coeffs, exps) = get_ten3(shape0, shape1, shape2)              (coeffs, exps) = get_ten3(shape0, shape1, shape2)
231              F = field(false, id, tys[index],"", exps, "")              F = field(false, id, i_fty,"", exps, "")
232              #print ("Ften", field.toStr(F))              #print ("Ften", field.toStr(F))
233              return (F, finfo1, coeffs)              return (F, finfo1, coeffs)
234          else:          else:

Legend:
Removed from v.4458  
changed lines
  Added in v.4459

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0