Skip to content
Snippets Groups Projects
Commit fa36182a authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Leaf gfs have to be unique isntances in composite grid function spaces!

parent 5489086d
No related branches found
No related tags found
No related merge requests found
...@@ -9,13 +9,18 @@ from dune.perftool.pdelab.driver import (get_formdata, ...@@ -9,13 +9,18 @@ from dune.perftool.pdelab.driver import (get_formdata,
get_trial_element, get_trial_element,
preprocess_leaf_data, preprocess_leaf_data,
) )
from dune.perftool.pdelab.driver.gridfunctionspace import name_gfs from dune.perftool.pdelab.driver.gridfunctionspace import (name_trial_gfs,
name_trial_subgfs,
type_range,
)
from dune.perftool.pdelab.driver.interpolate import (interpolate_vector, from dune.perftool.pdelab.driver.interpolate import (interpolate_vector,
name_boundary_function, name_boundary_function,
) )
from dune.perftool.pdelab.driver.solve import (define_vector, from dune.perftool.pdelab.driver.solve import (define_vector,
dune_solve,
name_vector, name_vector,
) )
from ufl import MixedElement, TensorElement, VectorElement
@preamble @preamble
...@@ -29,43 +34,18 @@ def name_test_fail_variable(): ...@@ -29,43 +34,18 @@ def name_test_fail_variable():
return name return name
def name_exact_solution(): def name_exact_solution_gridfunction(treepath):
name = "solution"
define_vector(name, get_formdata())
interpolate_exact_solution(name)
return name
def interpolate_exact_solution(name):
element = get_trial_element() element = get_trial_element()
is_dirichlet = preprocess_leaf_data(element, "is_dirichlet") func = preprocess_leaf_data(element, "exact_solution")
gfs = name_gfs(element, is_dirichlet) if isinstance(element, MixedElement):
sol = preprocess_leaf_data(element, "exact_solution") index = treepath_to_index(element, treepath)
func = name_boundary_function(element, sol) func = (func[index],)
interpolate_vector(func, gfs, name) element = element.extract_component(index)[1]
return name_boundary_function(element, func)
@preamble
def compare_dofs():
v = name_vector(get_formdata())
solution = name_exact_solution()
fail = name_test_fail_variable()
return ["",
"// Maximum norm of difference between dof vectors of the",
"// numerical solution and the interpolation of the exact solution",
"using Dune::PDELab::Backend::native;",
"double maxerror(0.0);",
"for (std::size_t i=0; i<native({}).size(); ++i)".format(v),
" if (std::abs(native({})[i]-native({})[i]) > maxerror)".format(v, solution),
" maxerror = std::abs(native({})[i]-native({})[i]);".format(v, solution),
"std::cout << std::endl << \"Maxerror: \" << maxerror << std::endl;",
"if (maxerror>{})".format(get_option("compare_dofs")),
" {} = true;".format(fail)]
def type_discrete_grid_function(gfs): def type_discrete_grid_function(gfs):
return "DGF_{}".format(gfs.upper()) return "{}_DGF".format(gfs.upper())
@preamble @preamble
...@@ -82,53 +62,93 @@ def name_discrete_grid_function(gfs, vector_name): ...@@ -82,53 +62,93 @@ def name_discrete_grid_function(gfs, vector_name):
@preamble @preamble
def typedef_difference_squared_adapter(name): def typedef_difference_squared_adapter(name, treepath):
sol = name_exact_solution() sol = name_exact_solution_gridfunction(treepath)
vector = name_vector(get_formdata()) vector = name_vector(get_formdata())
gfs = name_trial_subgfs(treepath)
dgf = name_discrete_grid_function(gfs, vector) dgf = name_discrete_grid_function(gfs, vector)
return 'using {} = Dune::PDELab::DifferenceSquaredAdapter<decltype({}), decltype({})>;'.format(name, sol, dgf) return 'using {} = Dune::PDELab::DifferenceSquaredAdapter<decltype({}), decltype({})>;'.format(name, sol, dgf)
def type_difference_squared_adapter(): def type_difference_squared_adapter(treepath):
name = 'DifferenceSquaredAdapter' name = 'DifferenceSquaredAdapter_{}'.format("_".join(str(t) for t in treepath))
typedef_difference_squared_adapter(name) typedef_difference_squared_adapter(name, treepath)
return name return name
@preamble @preamble
def define_difference_squared_adapter(name): def define_difference_squared_adapter(name, treepath):
t = type_difference_squared_adapter() t = type_difference_squared_adapter(treepath)
sol = name_exact_solution() sol = name_exact_solution_gridfunction(treepath)
vector = name_vector(get_formdata()) vector = name_vector(get_formdata())
gfs = name_trial_subgfs(treepath)
dgf = name_discrete_grid_function(gfs, vector) dgf = name_discrete_grid_function(gfs, vector)
return '{} {}({}, {});'.format(t, name, sol, dgf) return '{} {}({}, {});'.format(t, name, sol, dgf)
def name_difference_squared_adapter(): def name_difference_squared_adapter(treepath):
name = 'differencesquared_adapter' name = 'dsa_{}'.format("_".join(str(t) for t in treepath))
define_difference_squared_adapter(name) define_difference_squared_adapter(name, treepath)
return name return name
@preamble @preamble
def accumulate_L2_squared(): def _accumulate_L2_squared(treepath):
dsa = name_difference_squared_adapter() dsa = name_difference_squared_adapter(treepath)
accum_error = name_accumulated_L2_error() accum_error = name_accumulated_L2_error()
include_file("dune/pdelab/gridfunctionspace/gridfunctionadapter.hh", filetag="driver") include_file("dune/pdelab/gridfunctionspace/gridfunctionadapter.hh", filetag="driver")
include_file("dune/pdelab/common/functionutilities.hh", filetag="driver") include_file("dune/pdelab/common/functionutilities.hh", filetag="driver")
return ["// L2 error squared of difference between numerical", strtp = ", ".join(str(t) for t in treepath)
"// solution and the interpolation of exact solution",
" Dune::PDELab::integrateGridFunction({}, {}, 10);".format(dsa, accum_error), return ["{",
" // L2 error squared of difference between numerical",
" // solution and the interpolation of exact solution",
" // for treepath ({})".format(strtp),
" typename decltype({})::Traits::RangeType err(0.0);".format(dsa),
" Dune::PDELab::integrateGridFunction({}, err, 10);".format(dsa),
" {} += err;".format(accum_error),
" std::cout << \"L2 Error for treepath {}: \" << err << std::endl;".format(strtp),
"}",
] ]
def get_treepath(element, index):
if isinstance(element, (VectorElement, TensorElement)):
return (index,)
if isinstance(element, MixedElement):
pos, rest = element.extract_subelement_component(index)
offset = sum(element.sub_elements()[i].value_size() for i in range(pos))
return (pos,) + get_treepath(element.sub_elements()[pos], index - offset)
else:
return ()
def treepath_to_index(element, treepath, offset=0):
if len(treepath) == 0:
return offset
index = treepath[0]
offset = offset + sum(element.sub_elements()[i].value_size() for i in range(index))
subel = element.sub_elements()[index]
return treepath_to_index(subel, treepath[1:], offset)
def accumulate_L2_squared():
element = get_trial_element()
if isinstance(element, MixedElement):
for i in range(element.value_size()):
_accumulate_L2_squared(get_treepath(element, i))
else:
_accumulate_L2_squared(())
@preamble @preamble
def define_accumulated_L2_error(name): def define_accumulated_L2_error(name):
return "double {}(0.0);".format(name) t = type_range()
return "{} {}(0.0);".format(t, name)
def name_accumulated_L2_error(): def name_accumulated_L2_error():
...@@ -143,8 +163,10 @@ def compare_L2_squared(): ...@@ -143,8 +163,10 @@ def compare_L2_squared():
accum_error = name_accumulated_L2_error() accum_error = name_accumulated_L2_error()
fail = name_test_fail_variable() fail = name_test_fail_variable()
return ["std::cout << \"l2errorsquared: \" << {} << std::endl;".format(accum_error), return ["using std::abs;",
"if (std::isnan({0}) or std::abs({0})>{1})".format(accum_error, get_option("compare_l2errorsquared")), "using std::isnan;",
"std::cout << \"\\nl2errorsquared: \" << {} << std::endl << std::endl;".format(accum_error),
"if (isnan({0}) or abs({0})>{1})".format(accum_error, get_option("compare_l2errorsquared")),
" {} = true;".format(fail)] " {} = true;".format(fail)]
......
...@@ -175,27 +175,30 @@ def name_test_gfs(): ...@@ -175,27 +175,30 @@ def name_test_gfs():
return name_gfs(element, is_dirichlet) return name_gfs(element, is_dirichlet)
def name_gfs(element, is_dirichlet): def name_gfs(element, is_dirichlet, treepath=()):
if isinstance(element, (VectorElement, TensorElement)): if isinstance(element, (VectorElement, TensorElement)):
subel = element.sub_element()[0] subel = element.sub_elements()[0]
subgfs = name_gfs(subel, is_dirichlet[:subel.value_size()]) subgfs = name_gfs(subel, is_dirichlet[:subel.value_size()], treepath=treepath + (0,))
name = "{}_pow{}gfs".format(subgfs, element.num_sub_elements()) name = "{}_pow{}gfs_{}".format(subgfs,
element.num_sub_elements(),
"_".join(str(t) for t in treepath))
define_power_gfs(element, is_dirichlet, name, subgfs) define_power_gfs(element, is_dirichlet, name, subgfs)
return name return name
if isinstance(element, MixedElement): if isinstance(element, MixedElement):
k = 0 k = 0
subgfs = [] subgfs = []
for subel in element.sub_elements(): for i, subel in enumerate(element.sub_elements()):
subgfs.append(name_gfs(subel, is_dirichlet[k:k + subel.value_size()])) subgfs.append(name_gfs(subel, is_dirichlet[k:k + subel.value_size()], treepath=treepath + (i,)))
k = k + subel.value_size() k = k + subel.value_size()
name = "_".join(subgfs) name = "_".join(subgfs)
define_composite_gfs(element, is_dirichlet, name, subgfs) name = "{}_{}".format(name, "_".join(str(t) for t in treepath))
define_composite_gfs(element, is_dirichlet, name, tuple(subgfs))
return name return name
else: else:
assert isinstance(element, FiniteElement) assert isinstance(element, FiniteElement)
name = "{}{}_gfs".format(FEM_name_mangling(element).lower(), name = "{}{}_gfs_{}".format(FEM_name_mangling(element).lower(),
"_dirichlet" if is_dirichlet else "", "_dirichlet" if is_dirichlet[0] else "",
) "_".join(str(t) for t in treepath))
define_gfs(element, is_dirichlet, name) define_gfs(element, is_dirichlet, name)
return name return name
...@@ -214,7 +217,7 @@ def type_trial_gfs(): ...@@ -214,7 +217,7 @@ def type_trial_gfs():
def type_gfs(element, is_dirichlet): def type_gfs(element, is_dirichlet):
if isinstance(element, (VectorElement, TensorElement)): if isinstance(element, (VectorElement, TensorElement)):
subel = element.sub_element()[0] subel = element.sub_elements()[0]
subgfs = type_gfs(subel, is_dirichlet[:subel.value_size()]) subgfs = type_gfs(subel, is_dirichlet[:subel.value_size()])
name = "{}_POW{}GFS".format(subgfs, element.num_sub_elements()) name = "{}_POW{}GFS".format(subgfs, element.num_sub_elements())
typedef_power_gfs(element, is_dirichlet, name, subgfs) typedef_power_gfs(element, is_dirichlet, name, subgfs)
...@@ -226,12 +229,12 @@ def type_gfs(element, is_dirichlet): ...@@ -226,12 +229,12 @@ def type_gfs(element, is_dirichlet):
subgfs.append(type_gfs(subel, is_dirichlet[k:k + subel.value_size()])) subgfs.append(type_gfs(subel, is_dirichlet[k:k + subel.value_size()]))
k = k + subel.value_size() k = k + subel.value_size()
name = "_".join(subgfs) name = "_".join(subgfs)
typedef_composite_gfs(element, name, subgfs) typedef_composite_gfs(element, name, tuple(subgfs))
return name return name
else: else:
assert isinstance(element, FiniteElement) assert isinstance(element, FiniteElement)
name = "{}{}_GFS".format(FEM_name_mangling(element).upper(), name = "{}{}_GFS".format(FEM_name_mangling(element).upper(),
"_dirichlet" if is_dirichlet else "", "_dirichlet" if is_dirichlet[0] else "",
) )
typedef_gfs(element, is_dirichlet, name) typedef_gfs(element, is_dirichlet, name)
return name return name
...@@ -242,13 +245,15 @@ def define_gfs(element, is_dirichlet, name): ...@@ -242,13 +245,15 @@ def define_gfs(element, is_dirichlet, name):
gfstype = type_gfs(element, is_dirichlet) gfstype = type_gfs(element, is_dirichlet)
gv = name_leafview() gv = name_leafview()
fem = name_fem(element) fem = name_fem(element)
return "{} {}({}, {});".format(gfstype, name, gv, fem) return ["{} {}({}, {});".format(gfstype, name, gv, fem),
"{}.name(\"{}\");".format(name, name)]
@preamble @preamble
def define_power_gfs(element, is_dirichlet, name, subgfs): def define_power_gfs(element, is_dirichlet, name, subgfs):
gv = name_leafview() gv = name_leafview()
fem = name_fem(element.sub_elements()[0]) fem = name_fem(element.sub_elements()[0])
gfstype = type_gfs(element, is_dirichlet)
return "{} {}({}, {});".format(gfstype, name, gv, fem) return "{} {}({}, {});".format(gfstype, name, gv, fem)
...@@ -263,7 +268,7 @@ def typedef_gfs(element, is_dirichlet, name): ...@@ -263,7 +268,7 @@ def typedef_gfs(element, is_dirichlet, name):
vb = type_vectorbackend(element) vb = type_vectorbackend(element)
gv = type_leafview() gv = type_leafview()
fem = type_fem(element) fem = type_fem(element)
cass = type_constraintsassembler(bool(is_dirichlet)) cass = type_constraintsassembler(bool(is_dirichlet[0]))
return "using {} = Dune::PDELab::GridFunctionSpace<{}, {}, {}, {}>;".format(name, gv, fem, cass, vb) return "using {} = Dune::PDELab::GridFunctionSpace<{}, {}, {}, {}>;".format(name, gv, fem, cass, vb)
...@@ -343,3 +348,30 @@ def type_constraintsassembler(is_dirichlet): ...@@ -343,3 +348,30 @@ def type_constraintsassembler(is_dirichlet):
name = "NoConstraintsAssembler" name = "NoConstraintsAssembler"
typedef_no_constraintsassembler(name) typedef_no_constraintsassembler(name)
return name return name
def name_trial_subgfs(treepath):
if len(treepath) == 0:
return name_trial_gfs()
else:
return name_subgfs(treepath)
def name_subgfs(treepath):
gfs = name_trial_gfs()
name = "{}_{}".format(gfs, "_".join(str(t) for t in treepath))
define_subgfs(name, treepath)
return name
@preamble
def define_subgfs(name, treepath):
t = type_subgfs(treepath)
gfs = name_trial_gfs()
return "{} {}({});".format(t, name, gfs)
def type_subgfs(tree_path):
include_file('dune/pdelab/gridfunctionspace/subspace.hh', filetag='driver')
gfs = type_trial_gfs()
return "Dune::PDELab::GridFunctionSubSpace<{}, Dune::TypeTree::TreePath<{}> >".format(gfs, ', '.join(str(t) for t in tree_path))
from dune.perftool.generation import preamble from dune.perftool.generation import (include_file,
preamble,
)
from dune.perftool.pdelab.driver import (get_formdata, from dune.perftool.pdelab.driver import (get_formdata,
get_mass_formdata,
get_trial_element,
is_linear, is_linear,
name_initree,
preprocess_leaf_data,
) )
from dune.perftool.pdelab.driver.gridoperator import (type_gridoperator,) from dune.perftool.pdelab.driver.gridfunctionspace import (name_trial_gfs,
type_range,
)
from dune.perftool.pdelab.driver.gridoperator import (name_gridoperator,
name_parameters,
type_gridoperator,)
from dune.perftool.pdelab.driver.constraints import (name_bctype_function,
name_constraintscontainer,
)
from dune.perftool.pdelab.driver.interpolate import (interpolate_dirichlet_data,
name_boundary_function,
)
from dune.perftool.pdelab.driver.solve import (print_matrix, from dune.perftool.pdelab.driver.solve import (print_matrix,
print_residual, print_residual,
name_stationarynonlinearproblemsolver,
name_vector,
type_stationarynonlinearproblemssolver,
type_vector,
) )
from dune.perftool.pdelab.driver.vtk import (name_vtk_sequence_writer,
visualize_initial_condition,
)
from dune.perftool.options import get_option from dune.perftool.options import get_option
...@@ -28,12 +52,6 @@ def solve_instationary(): ...@@ -28,12 +52,6 @@ def solve_instationary():
print_residual() print_residual()
print_matrix() print_matrix()
from dune.perftool.pdelab.driver.error import compare_dofs, compare_L2_squared
if get_option("exact_solution_expression"):
if get_option("compare_dofs"):
compare_dofs()
if get_option("compare_l2errorsquared"):
compare_L2_squared()
@preamble @preamble
...@@ -42,12 +60,14 @@ def time_loop(): ...@@ -42,12 +60,14 @@ def time_loop():
formdata = get_formdata() formdata = get_formdata()
params = name_parameters(formdata) params = name_parameters(formdata)
time = name_time() time = name_time()
expr = get_trial_element() element = get_trial_element()
bctype = name_bctype_function(expr) is_dirichlet = preprocess_leaf_data(element, "is_dirichlet")
gfs = name_gfs(expr) bctype = name_bctype_function(element, is_dirichlet)
cc = name_constraintscontainer(expr) gfs = name_trial_gfs()
cc = name_constraintscontainer()
vector_type = type_vector(formdata) vector_type = type_vector(formdata)
vector = name_vector(formdata) vector = name_vector(formdata)
interpolate_dirichlet_data(vector)
# Choose between explicit and implicit time stepping # Choose between explicit and implicit time stepping
explicit = get_option('explicit_time_stepping') explicit = get_option('explicit_time_stepping')
...@@ -55,7 +75,8 @@ def time_loop(): ...@@ -55,7 +75,8 @@ def time_loop():
osm = name_explicitonestepmethod() osm = name_explicitonestepmethod()
apply_call = "{}.apply(time, dt, {}, {}new);".format(osm, vector, vector) apply_call = "{}.apply(time, dt, {}, {}new);".format(osm, vector, vector)
else: else:
boundary = name_boundary_function(expr) dirichlet = preprocess_leaf_data(element, "dirichlet_expression")
boundary = name_boundary_function(element, dirichlet)
osm = name_onestepmethod() osm = name_onestepmethod()
apply_call = "{}.apply(time, dt, {}, {}, {}new);".format(osm, vector, boundary, vector) apply_call = "{}.apply(time, dt, {}, {}, {}new);".format(osm, vector, boundary, vector)
...@@ -95,7 +116,6 @@ def name_time(): ...@@ -95,7 +116,6 @@ def name_time():
return "time" return "time"
@preamble @preamble
def typedef_timesteppingmethod(name): def typedef_timesteppingmethod(name):
r_type = type_range() r_type = type_range()
...@@ -131,8 +151,8 @@ def name_timesteppingmethod(): ...@@ -131,8 +151,8 @@ def name_timesteppingmethod():
@preamble @preamble
def typedef_instationarygridoperator(name): def typedef_instationarygridoperator(name):
include_file("dune/pdelab/gridoperator/onestep.hh", filetag="driver") include_file("dune/pdelab/gridoperator/onestep.hh", filetag="driver")
go_type = type_gridoperator(_driver_data['formdata']) go_type = type_gridoperator(get_formdata())
mass_go_type = type_gridoperator(_driver_data['mass_formdata']) mass_go_type = type_gridoperator(get_mass_formdata())
explicit = get_option('explicit_time_stepping') explicit = get_option('explicit_time_stepping')
if explicit: if explicit:
return "using {} = Dune::PDELab::OneStepGridOperator<{},{},false>;".format(name, go_type, mass_go_type) return "using {} = Dune::PDELab::OneStepGridOperator<{},{},false>;".format(name, go_type, mass_go_type)
...@@ -148,8 +168,8 @@ def type_instationarygridoperator(): ...@@ -148,8 +168,8 @@ def type_instationarygridoperator():
@preamble @preamble
def define_instationarygridoperator(name): def define_instationarygridoperator(name):
igo_type = type_instationarygridoperator() igo_type = type_instationarygridoperator()
go = name_gridoperator(_driver_data['formdata']) go = name_gridoperator(get_formdata())
mass_go = name_gridoperator(_driver_data['mass_formdata']) mass_go = name_gridoperator(get_mass_formdata())
return "{} {}({}, {});".format(igo_type, name, go, mass_go) return "{} {}({}, {});".format(igo_type, name, go, mass_go)
...@@ -163,7 +183,7 @@ def typedef_onestepmethod(name): ...@@ -163,7 +183,7 @@ def typedef_onestepmethod(name):
r_type = type_range() r_type = type_range()
igo_type = type_instationarygridoperator() igo_type = type_instationarygridoperator()
snp_type = type_stationarynonlinearproblemssolver(igo_type) snp_type = type_stationarynonlinearproblemssolver(igo_type)
vector_type = type_vector(_driver_data['formdata']) vector_type = type_vector(get_formdata())
return "using {} = Dune::PDELab::OneStepMethod<{}, {}, {}, {}, {}>;".format(name, r_type, igo_type, snp_type, vector_type, vector_type) return "using {} = Dune::PDELab::OneStepMethod<{}, {}, {}, {}, {}>;".format(name, r_type, igo_type, snp_type, vector_type, vector_type)
...@@ -192,7 +212,7 @@ def typedef_explicitonestepmethod(name): ...@@ -192,7 +212,7 @@ def typedef_explicitonestepmethod(name):
r_type = type_range() r_type = type_range()
igo_type = type_instationarygridoperator() igo_type = type_instationarygridoperator()
ls_type = type_linearsolver() ls_type = type_linearsolver()
vector_type = type_vector(_driver_data['formdata']) vector_type = type_vector(get_formdata())
return "using {} = Dune::PDELab::ExplicitOneStepMethod<{}, {}, {}, {}>;".format(name, r_type, igo_type, ls_type, vector_type) return "using {} = Dune::PDELab::ExplicitOneStepMethod<{}, {}, {}, {}>;".format(name, r_type, igo_type, ls_type, vector_type)
......
...@@ -10,7 +10,7 @@ from dune.perftool.pdelab.driver import (FEM_name_mangling, ...@@ -10,7 +10,7 @@ from dune.perftool.pdelab.driver import (FEM_name_mangling,
is_stationary, is_stationary,
preprocess_leaf_data, preprocess_leaf_data,
) )
from dune.perftool.pdelab.driver.gridfunctionspace import (name_gfs, from dune.perftool.pdelab.driver.gridfunctionspace import (name_trial_gfs,
name_leafview, name_leafview,
) )
from dune.perftool.pdelab.driver.gridoperator import (name_parameters,) from dune.perftool.pdelab.driver.gridoperator import (name_parameters,)
...@@ -28,8 +28,8 @@ def _do_interpolate(dirichlet): ...@@ -28,8 +28,8 @@ def _do_interpolate(dirichlet):
def interpolate_dirichlet_data(name): def interpolate_dirichlet_data(name):
element = get_trial_element() element = get_trial_element()
is_dirichlet = preprocess_leaf_data(element, "is_dirichlet") is_dirichlet = preprocess_leaf_data(element, "is_dirichlet")
if _do_interpolate(is_dirichlet): if _do_interpolate(is_dirichlet) or not is_stationary():
gfs = name_gfs(element, is_dirichlet) gfs = name_trial_gfs()
dirichlet = preprocess_leaf_data(element, "dirichlet_expression") dirichlet = preprocess_leaf_data(element, "dirichlet_expression")
bf = name_boundary_function(element, dirichlet) bf = name_boundary_function(element, dirichlet)
interpolate_vector(bf, gfs, name) interpolate_vector(bf, gfs, name)
......
...@@ -122,7 +122,6 @@ def visualize_initial_condition(): ...@@ -122,7 +122,6 @@ def visualize_initial_condition():
include_file("dune/pdelab/gridfunctionspace/vtk.hh", filetag="driver") include_file("dune/pdelab/gridfunctionspace/vtk.hh", filetag="driver")
vtkwriter = name_vtk_sequence_writer() vtkwriter = name_vtk_sequence_writer()
element = get_trial_element() element = get_trial_element()
define_gfs_names(element)
gfs = name_trial_gfs() gfs = name_trial_gfs()
vector = name_vector(get_formdata()) vector = name_vector(get_formdata())
predicate = name_predicate() predicate = name_predicate()
...@@ -130,23 +129,3 @@ def visualize_initial_condition(): ...@@ -130,23 +129,3 @@ def visualize_initial_condition():
time = name_time() time = name_time()
return ["Dune::PDELab::addSolutionToVTKWriter({}, {}, {}, Dune::PDELab::vtk::defaultNameScheme(), {});".format(vtkwriter, gfs, vector, predicate), return ["Dune::PDELab::addSolutionToVTKWriter({}, {}, {}, Dune::PDELab::vtk::defaultNameScheme(), {});".format(vtkwriter, gfs, vector, predicate),
"{}.write({}, Dune::VTK::appendedraw);".format(vtkwriter, time)] "{}.write({}, Dune::VTK::appendedraw);".format(vtkwriter, time)]
@preamble
def _define_gfs_name(element, is_dirichlet, offset=0):
from ufl import MixedElement
if isinstance(element, MixedElement):
k = 0
for subel in element.sub_elements():
define_gfs_name(subel, is_dirichlet[k:k + subel.value_size()], offset=offset + k)
k = k + subel.value_size()
return []
else:
# This is a scalar leaf
gfs = name_gfs(element, is_dirichlet)
return "{}.name(\"data_{}\");".format(gfs, offset)
def define_gfs_names(element):
is_dirichlet = preprocess_leaf_data(element, "is_dirichlet")
return _define_gfs_name(element, is_dirichlet)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment