SyFi  0.3
sfc_callbacks::callback_forms Namespace Reference

Functions

def constant_scalar
def L2_scalar
def H1_semi_scalar
def H1_scalar
def constant_vector
def constant_source_vector
def source_vector
def load_vector
def constant_matrix
def mass_matrix
def mass_with_c_matrix
def stiffness_matrix
def stiffness_with_M_matrix
def mass_boundary_matrix
def check
def form_name

Variables

list scalar_forms = [constant_scalar, L2_scalar, H1_semi_scalar, H1_scalar]
list vector_forms = [constant_vector, constant_source_vector, source_vector]
list matrix_forms = [constant_matrix, mass_matrix, mass_with_c_matrix, stiffness_matrix, stiffness_with_M_matrix]
tuple args = set(sys.argv[1:])
string print_forms = "p"
string generate = "g"
string compile = "c"
int quad_order = 3
int formcount = 0
dictionary polygon = { 2: "triangle", 3: "tetrahedron" }
tuple fe0 = FiniteElement("P0", polygon, 0)
tuple fe1 = FiniteElement("Lagrange", polygon, 1)
tuple fe2 = FiniteElement("Lagrange", polygon, 2)
list scalar_elements = [fe0, fe1, fe2]
tuple vfe0 = VectorElement("P0", polygon, 0)
tuple vfe1 = VectorElement("Lagrange", polygon, 1)
tuple vfe2 = VectorElement("Lagrange", polygon, 2)
list vector_elements = [vfe0, vfe1, vfe2]
tuple tfe0 = TensorElement("P0", polygon, 0)
tuple tfe1 = TensorElement("Lagrange", polygon, 1)
tuple tfe2 = TensorElement("Lagrange", polygon, 2)
list tensor_elements = [tfe0, tfe1, tfe2]
 all_elements = scalar_elements+vector_elements+tensor_elements
dictionary options = { "symbolic": symbolic, "quad_order": quad_order }
 callback = L2_scalar
list basisfunctions = []
list coefficients = [Function(fe)]
tuple form = Form(name=form_name(callback), basisfunctions=basisfunctions, coefficients=coefficients, cell_integrands=[callback], options=options)

Function Documentation

Definition at line 116 of file callback_forms.py.

00116 
00117     def check(form):
00118         form.sanity_check()
00119         if print_forms:
00120             print form
00121         if generate or compile:
00122             if compile:
00123                 compiled_form = compile_form(form)
00124                 print "Successfully compiled form:"
00125                 print compiled_form
00126                 print dir(compiled_form)
00127             else:
00128                 res = write_ufc_code(form)
00129                 print "Successfully generated form code:"
00130                 print res

def sfc_callbacks.callback_forms.constant_matrix (   v,
  u,
  itg 
)
a(v, u; ) = \int 1 dx

Definition at line 64 of file callback_forms.py.

00064 
00065 def constant_matrix(v, u, itg):
00066     """a(v, u; ) = \int 1 dx"""
00067     return numeric(1)

a(;) = \int 1 dx

Definition at line 12 of file callback_forms.py.

00012 
00013 def constant_scalar(itg):
00014     """a(;) = \int 1 dx"""
00015     return numeric(1)

a(v;) = \int v dx

Definition at line 42 of file callback_forms.py.

00042 
00043 def constant_source_vector(v, itg):
00044     """a(v;) = \int v dx"""
00045     return v

a(v;) = \int 1 dx

Definition at line 38 of file callback_forms.py.

00038 
00039 def constant_vector(v, itg):
00040     """a(v;) = \int 1 dx"""
00041     return numeric(1)

Definition at line 134 of file callback_forms.py.

00134 
00135     def form_name(callback):
00136         global formcount
00137         name = "form_%s_%d" % (get_callable_name(callback), formcount)
00138         formcount += 1
00139         return name

a(;w) = \int w^2 + grad(w)^2 dx

Definition at line 26 of file callback_forms.py.

References SyFi.grad(), and SyFi.inner().

00026 
00027 def H1_scalar(w, itg):
00028     """a(;w) = \int w^2 + grad(w)^2 dx"""
00029     GinvT = itg.GinvT()
00030     Dw = grad(w, GinvT)
00031     return inner(w, w) + inner(Dw, Dw)

a(;w) = \int grad(w)^2 dx

Definition at line 20 of file callback_forms.py.

References SyFi.grad(), and SyFi.inner().

00020 
00021 def H1_semi_scalar(w, itg):
00022     """a(;w) = \int grad(w)^2 dx"""
00023     GinvT = itg.GinvT()
00024     Dw = grad(w, GinvT)
00025     return inner(Dw, Dw)

a(;w) = \int w^2 dx

Definition at line 16 of file callback_forms.py.

References SyFi.inner().

00016 
00017 def L2_scalar(w, itg):
00018     """a(;w) = \int w^2 dx"""
00019     return inner(w, w)

def sfc_callbacks.callback_forms.load_vector (   v,
  t,
  itg 
)
a(v; t) = \int t . v dx

Definition at line 57 of file callback_forms.py.

References SyFi.inner().

00057 
00058 def load_vector(v, t, itg):
00059     """a(v; t) = \int t . v dx"""
00060     return inner(t, v)
00061 
00062 
00063 # ----------------------------------------------- Matrix forms:

a(v, u; ) = \int u . v ds

Definition at line 94 of file callback_forms.py.

References SyFi.inner().

00094 
00095 def mass_boundary_matrix(v, u, itg):
00096     """a(v, u; ) = \int u . v ds"""
00097     return inner(v, u)
00098 
00099 
00100 
00101 # ----------------------------------------------- Testing:
00102 

def sfc_callbacks.callback_forms.mass_matrix (   v,
  u,
  itg 
)
a(v, u; ) = \int u . v dx

Definition at line 68 of file callback_forms.py.

References SyFi.inner().

00068 
00069 def mass_matrix(v, u, itg):
00070     """a(v, u; ) = \int u . v dx"""
00071     return inner(v, u)

def sfc_callbacks.callback_forms.mass_with_c_matrix (   v,
  u,
  c,
  itg 
)
a(v, u; c) = \int c (u . v) dx

Definition at line 72 of file callback_forms.py.

References SyFi.inner().

00072 
00073 def mass_with_c_matrix(v, u, c, itg):
00074     """a(v, u; c) = \int c (u . v) dx"""
00075     return c * inner(v, u)

def sfc_callbacks.callback_forms.source_vector (   v,
  f,
  itg 
)
a(v; f) = \int f . v dx

Definition at line 46 of file callback_forms.py.

References SyFi.inner().

00046 
00047 def source_vector(v, f, itg):
00048     """a(v; f) = \int f . v dx"""
00049     return inner(f, v)
00050 

def sfc_callbacks.callback_forms.stiffness_matrix (   v,
  u,
  itg 
)

Definition at line 76 of file callback_forms.py.

References SyFi.grad(), and SyFi.inner().

00076 
00077 def stiffness_matrix(v, u, itg):
00078     GinvT = itg.GinvT()
00079     Du = grad(u, GinvT)
00080     Dv = grad(v, GinvT)
00081     return inner(Du, Dv)

def sfc_callbacks.callback_forms.stiffness_with_M_matrix (   v,
  u,
  M,
  itg 
)

Definition at line 82 of file callback_forms.py.

References SyFi.grad(), and SyFi.inner().

00082 
00083 def stiffness_with_M_matrix(v, u, M, itg):
00084     GinvT = itg.GinvT()
00085     Du = grad(u, GinvT)
00086     Dv = grad(v, GinvT)
00087     return inner(M * Du, Dv)


Variable Documentation

tuple sfc_callbacks::callback_forms::args = set(sys.argv[1:])

Definition at line 110 of file callback_forms.py.

Definition at line 180 of file callback_forms.py.

Definition at line 114 of file callback_forms.py.

tuple sfc_callbacks::callback_forms::fe0 = FiniteElement("P0", polygon, 0)

Definition at line 144 of file callback_forms.py.

tuple sfc_callbacks::callback_forms::fe1 = FiniteElement("Lagrange", polygon, 1)

Definition at line 145 of file callback_forms.py.

tuple sfc_callbacks::callback_forms::fe2 = FiniteElement("Lagrange", polygon, 2)

Definition at line 146 of file callback_forms.py.

Referenced by check_CrouzeixRaviart(), and main().

Definition at line 133 of file callback_forms.py.

Definition at line 113 of file callback_forms.py.

dictionary sfc_callbacks::callback_forms::options = { "symbolic": symbolic, "quad_order": quad_order }

Definition at line 170 of file callback_forms.py.

dictionary sfc_callbacks::callback_forms::polygon = { 2: "triangle", 3: "tetrahedron" }

Definition at line 141 of file callback_forms.py.

Definition at line 112 of file callback_forms.py.

tuple sfc_callbacks::callback_forms::tfe0 = TensorElement("P0", polygon, 0)

Definition at line 154 of file callback_forms.py.

tuple sfc_callbacks::callback_forms::tfe1 = TensorElement("Lagrange", polygon, 1)

Definition at line 155 of file callback_forms.py.

tuple sfc_callbacks::callback_forms::tfe2 = TensorElement("Lagrange", polygon, 2)

Definition at line 156 of file callback_forms.py.

tuple sfc_callbacks::callback_forms::vfe0 = VectorElement("P0", polygon, 0)

Definition at line 149 of file callback_forms.py.

tuple sfc_callbacks::callback_forms::vfe1 = VectorElement("Lagrange", polygon, 1)

Definition at line 150 of file callback_forms.py.

tuple sfc_callbacks::callback_forms::vfe2 = VectorElement("Lagrange", polygon, 2)

Definition at line 151 of file callback_forms.py.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines