Skip to content

Instantly share code, notes, and snippets.

View wence-'s full-sized avatar

Lawrence Mitchell wence-

View GitHub Profile
from firedrake import *
mesh = UnitSquareMesh(1, 1)
V = FunctionSpace(mesh, 'CG', 1)
u = TrialFunction(V)
v = TestFunction(V)
f = Function(V)
problem = LinearVariationalProblem(u*v*dx, v*dx, f)
import random
from firedrake import *
# Class representing the intial conditions
class InitialConditions(Expression):
def __init__(self):
# random.seed(2 + op2.MPI.comm.rank)
super(InitialConditions, self).__init__()
def eval(self, values, x):
wence_params={'pc_type': 'fieldsplit',
'pc_fieldsplit_type': 'schur',
'ksp_type': 'gmres',
'ksp_monitor_true_residual': True,
'ksp_max_it': 100,
'ksp_gmres_restart': 50,
'pc_fieldsplit_schur_fact_type': 'FULL',
'pc_fieldsplit_schur_precondition': 'selfp',
'fieldsplit_0_ksp_type': 'richardson',
'fieldsplit_0_ksp_max_it': 2,
wence_params={'pc_type': 'fieldsplit',
'pc_fieldsplit_type': 'schur',
'ksp_type': 'gmres',
'ksp_monitor_true_residual': True,
'ksp_max_it': 100,
'ksp_gmres_restart': 50,
'pc_fieldsplit_schur_fact_type': 'FULL',
'pc_fieldsplit_schur_precondition': 'selfp',
'fieldsplit_0_ksp_type': 'richardson',
'fieldsplit_0_ksp_max_it': 5,
wence_params={'pc_type': 'fieldsplit',
'pc_fieldsplit_type': 'schur',
'ksp_type': 'gmres',
'ksp_max_it': 100,
'ksp_gmres_restart': 50,
'pc_fieldsplit_schur_fact_type': 'FULL',
'pc_fieldsplit_schur_precondition': 'selfp',
'fieldsplit_0_ksp_type': 'richardson',
'fieldsplit_0_ksp_max_it': 2,
'fieldsplit_0_pc_type': 'bjacobi',
wence_params={'pc_type': 'fieldsplit',
'pc_fieldsplit_type': 'schur',
'ksp_type': 'gmres',
'ksp_max_it': 100,
'ksp_gmres_restart': 50,
'pc_fieldsplit_schur_fact_type': 'FULL',
'pc_fieldsplit_schur_precondition': 'selfp',
'fieldsplit_0_ksp_type': 'richardson',
'fieldsplit_0_ksp_max_it': 2,
'fieldsplit_0_pc_type': 'bjacobi',
"pc_type": "fieldsplit"
"pc_fieldsplit_type": "schur"
"pc_fieldsplit_schur_fact_type": "FULL"
"pc_fieldsplit_schur_precondition": "selfp"
"fieldsplit_0_ksp_type": "preonly"
"fieldsplit_0_pc_type": "bjacobi"
"fieldsplit_0_sub_pc_type": "ilu"
"fieldsplit_1_ksp_type": "preonly"
"fieldsplit_1_pc_type": "hypre"
"fieldsplit_1_pc_hypre_type": "boomeramg"
diff --git a/firedrake/fc/driver.py b/firedrake/fc/driver.py
index 1fb0e92..93da812 100644
--- a/firedrake/fc/driver.py
+++ b/firedrake/fc/driver.py
@@ -2,6 +2,7 @@ from __future__ import absolute_import
import numpy
import time
+import collections
On quads
In [1]: print self.original_form
{ div(w_6) } * dx(<Mesh #4 with coordinates parameterized by <Q vector element of degree 1 on a quadrilateral: 2 x <CG1 on a quadrilateral>>>[everywhere], {})
In [2]: print apply_algebra_lowering(self.original_form)
{ sum_{i_{115}} (grad(w_6[i_{115}]))[i_{115}] } * dx(<Mesh #4 with coordinates parameterized by <Q vector element of degree 1 on a quadrilateral: 2 x <CG1 on a quadrilateral>>>[everywhere], {})
In [3]: print apply_derivatives(apply_algebra_lowering(self.original_form))
{ sum_{i_{116}} (grad(w_6))[i_{116}, i_{116}] } * dx(<Mesh #4 with coordinates parameterized by <Q vector element of degree 1 on a quadrilateral: 2 x <CG1 on a quadrilateral>>>[everywhere], {})
On triangles
In [1]: print self.original_form
{ div(w_2) } * dx(<Mesh #1 with coordinates parameterized by <Lagrange vector element of degree 1 on a triangle: 2 x <CG1 on a triangle>>>[everywhere], {})
In [2]: print apply_algebra_lowering(self.original_form)
{ sum_{i_{30}} (grad(w_2[i_{30}]))[i_{30}] } * dx(<Mesh #1 with coordinates parameterized by <Lagrange vector element of degree 1 on a triangle: 2 x <CG1 on a triangle>>>[everywhere], {})
In [3]: print apply_derivatives(apply_algebra_lowering(self.original_form))
{ sum_{i_{31}} (grad(w_2))[i_{31}, i_{31}] } * dx(<Mesh #1 with coordinates parameterized by <Lagrange vector element of degree 1 on a triangle: 2 x <CG1 on a triangle>>>[everywhere], {})