Skip to content
Snippets Groups Projects
Commit 5f47072d authored by René Heß's avatar René Heß
Browse files

[skip ci] Stokes is working

parent a517e118
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,6 @@ from dune.codegen.pdelab.spaces import (lfs_iname,
name_leaf_lfs,
name_lfs,
name_lfs_bound,
type_gfs,
type_leaf_gfs,
initialize_function_spaces,
)
......
......@@ -188,6 +188,7 @@ def type_composite_constriants_parameters(element, gfs_tuple):
gfs_tuple = (gfs_tuple,)
name = "CompositeConstraintsParameters_{}".format('_'.join(c for c in gfs_tuple))
if len(element.sub_elements()) == len(gfs_tuple):
# If this is not equal the childs have already been typedefed
typedef_composite_constraints_parameters(name, element, gfs_tuple)
return name
......
......@@ -38,14 +38,44 @@ def name_test_fail_variable():
return name
def name_exact_solution_gridfunction(treepath):
@preamble(section="error", kernel="main")
def main_typedef_exact_solution_grid_function(name, treepath):
# palpo TODO
solution_type = main_type_boundary_grid_function()
# solution_type = "BoundaryGridFunction"
if len(treepath) > 0:
solution_type = "Dune::TypeTree::Child<{}, {}>;".format(solution_type, ", ".join(str(t) for t in treepath))
return "using {} = {};".format(name, solution_type)
def main_type_exact_solution_grid_function(treepath):
name = "ExactSolution"
if len(treepath) > 0:
name = "{}_{}".format(name, "_".join(str(t) for t in treepath))
main_typedef_exact_solution_grid_function(name, treepath)
return name
@preamble(section="error", kernel="main")
def main_define_exact_solution_grid_function(name, treepath):
element = get_trial_element()
func = preprocess_leaf_data(element, "exact_solution")
# if isinstance(element, MixedElement):
# index = treepath_to_index(element, treepath)
# func = (func[index],)
# element = element.extract_component(index)[1]
return main_name_boundary_grid_function(element, func)
# palpo TODO
# boundary_gf = "boundaryGridFunction"
boundary_gf = main_name_boundary_grid_function(element, func)
if len(treepath) == 0:
return "auto {} = *{};".format(name, boundary_gf)
else:
indices = ["Dune::Indices::_{}".format(str(t)) for t in treepath]
return "auto {} = child(*{}, {});".format(name, boundary_gf, ", ".join(i for i in indices))
def main_name_exact_solution_grid_function(treepath):
name = "exactSolution"
if len(treepath) > 0:
name = "{}_{}".format(name, "_".join(str(t) for t in treepath))
main_define_exact_solution_grid_function(name, treepath)
return name
def type_discrete_grid_function(treepath):
......@@ -79,17 +109,21 @@ def name_discrete_grid_function(gfs, vector_name, treepath):
@preamble(section="error", kernel="main")
def typedef_difference_squared_adapter(name, treepath):
element = get_trial_element()
func = preprocess_leaf_data(element, "exact_solution")
if isinstance(element, MixedElement):
index = treepath_to_index(element, treepath)
func = (func[index],)
element = element.extract_component(index)[1]
bgf_type = main_type_subgfs(treepath)
vector = main_name_vector(get_form_ident())
# Grid function representing exact solution
# element = get_trial_element()
# func = preprocess_leaf_data(element, "exact_solution")
# if isinstance(element, MixedElement):
# index = treepath_to_index(element, treepath)
# func = (func[index],)
# element = element.extract_component(index)[1]
bgf_type = main_type_exact_solution_grid_function(treepath)
# Discrete grid function (numerical solution)
gfs = main_name_trial_subgfs(treepath)
vector = main_name_vector(get_form_ident())
dgf = name_discrete_grid_function(gfs, vector, treepath)
dgf_type = type_discrete_grid_function(treepath)
return 'using {} = Dune::PDELab::DifferenceSquaredAdapter<{}, {}>;'.format(name, bgf_type, dgf_type)
......@@ -102,12 +136,12 @@ def type_difference_squared_adapter(treepath):
@preamble(section="error", kernel="main")
def define_difference_squared_adapter(name, treepath):
t = type_difference_squared_adapter(treepath)
sol = name_exact_solution_gridfunction(treepath)
sol = main_name_exact_solution_grid_function(treepath)
vector = main_name_vector(get_form_ident())
gfs = main_name_trial_subgfs(treepath)
dgf = name_discrete_grid_function(gfs, vector, treepath)
return '{} {}(*{}, {});'.format(t, name, sol, dgf)
return '{} {}({}, {});'.format(t, name, sol, dgf)
def name_difference_squared_adapter(treepath):
......
......@@ -224,40 +224,45 @@ def name_boundary_function(func, local):
return name
@preamble(section="postprocessing", kernel="main")
def main_typedef_boundary_grid_function(name):
driver_block_type = type_driver_block()
# palpo TODO
local = True
# bgf_type = type_boundary_grid_function(local, True)
bgf_type = "BoundaryGridFunction"
print("palpo name: {}".format(name))
return "using {} = {}::{};".format(name, driver_block_type, bgf_type)
def main_type_boundary_grid_function():
name = "BoundaryGridFunction"
main_typedef_boundary_grid_function(name)
return name
@class_member(classtag="driver_block")
def driver_block_get_boundarygridfunction(element, func, name=None):
if not name:
name = name_boundary_grid_function(element, func)
# bgf_type = type_boundary_grid_function(True, True)
bgf_type = "BoundaryGridFunction"
return ["std::shared_ptr<{}> getBoundaryGridFunction(){{".format(bgf_type),
" return {};".format(name),
"}"]
@preamble(section="postprocessing", kernel="main")
def main_typedef_boundary_grid_function(name, func):
driver_block_type = type_driver_block()
local = _is_local(func)
bgf_type = type_boundary_grid_function(local, True)
return "using {} = {}::{};".format(name, driver_block_type, bgf_type)
def main_type_boundary_grid_function(func):
name = "BoundaryGridFunction"
main_typedef_boundary_grid_function(name, func)
return name
@preamble(section="postprocessing", kernel="main")
def main_define_boundary_grid_function(name, element, func):
driver_block_name = name_driver_block()
print("palpo 2 element: {}".format(element))
# palpo TODO
# driver_block_get_boundarygridfunction(element, func)
return "auto {} = {}.getBoundaryGridFunction();".format(name, driver_block_name)
@cached
def main_name_boundary_grid_function(element, func):
# palpo TODO func rauswerfen?
assert isinstance(func, tuple)
name = "boundaryGridFunction"
main_define_boundary_grid_function(name, element, func)
......
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