drop default arguments in Q1 grid test

parent a76680f7
......@@ -37,6 +37,10 @@ base_config = {
'mu': 1,
}
make_Q1_pou = lambda dd: ContinuousLagrangePartitionOfUnity(dd)
Q1_pou_id = 'Q1PoU'
def assert_results(results, expected_results):
errors = {}
......@@ -87,11 +91,11 @@ def compute_on_single_refinement(cfg, make_pou, pou_id):
return num_subdomains, num_DoFs, error, estimate
def run_fixed_H_refined_h(
num_h_refs=3,
num_macro_elements=[3, 3],
make_pou=lambda dd: ContinuousLagrangePartitionOfUnity(dd),
pou_id='Q1PoU',
def run_fixed_H_refined_h( # see the bottom for suitable defaults
num_h_refs,
num_macro_elements,
make_pou,
pou_id,
DATASET_ID=FILENAME + '.fixed_H_refined_h'):
config = dict(base_config)
config['num_macro_elements'] = num_macro_elements
......@@ -112,12 +116,12 @@ def run_fixed_H_refined_h(
return results
def run_fixed_h_refined_H(
global_grid_refines=3,
num_H_refs_less=0,
initial_macro_grid=[1, 1],
make_pou=lambda dd: ContinuousLagrangePartitionOfUnity(dd),
pou_id='Q1PoU',
def run_fixed_h_refined_H( # see the bottom for suitable defaults
global_grid_refines,
num_H_refs_less,
initial_macro_grid,
make_pou,
pou_id,
DATASET_ID=FILENAME + '.fixed_h_refined_H'):
config = dict(base_config)
macro_grid = list(initial_macro_grid)
......@@ -143,7 +147,7 @@ def run_fixed_h_refined_H(
return results
def expected_results_fixed_H_refined_h(num_h_refs, num_macro_elements):
def expected_results_fixed_H_refined_h(num_h_refs, num_macro_elements, **kwargs):
if num_h_refs == 3 and num_macro_elements == [1, 1]:
return {'num_subdomains': [1, 1, 1, 1],
'num_DoFs': [4, 9, 25, 81],
......@@ -158,7 +162,7 @@ def expected_results_fixed_H_refined_h(num_h_refs, num_macro_elements):
assert False, f'missing expected results for num_h_refs={num_h_refs}, num_macro_elements={num_macro_elements}'
def expected_results_fixed_h_refined_H(global_grid_refines, num_H_refs_less, initial_macro_grid):
def expected_results_fixed_h_refined_H(global_grid_refines, num_H_refs_less, initial_macro_grid, **kwargs):
if global_grid_refines == 3 and num_H_refs_less == 0 and initial_macro_grid == [1, 1]:
return {'num_subdomains': [1, 4, 16, 64],
'num_DoFs': [81, 100, 144, 256],
......@@ -170,27 +174,27 @@ num_H_refs_less={num_H_refs_less}, initial_macro_grid={initial_macro_grid}"""
def test_fixed_H_refined_h_single_subdomain():
kwargs = {'num_h_refs': 3, 'num_macro_elements': [1, 1]}
kwargs = {'num_h_refs': 3, 'num_macro_elements': [1, 1], 'make_pou': make_Q1_pou, 'pou_id': Q1_pou_id}
assert_results(run_fixed_H_refined_h(**kwargs), expected_results_fixed_H_refined_h(**kwargs))
def test_fixed_H_refined_h_truely_inner_subdomain():
kwargs = {'num_h_refs': 3, 'num_macro_elements': [3, 3]}
def test_fixed_H_refined_h_truly_inner_subdomain():
kwargs = {'num_h_refs': 3, 'num_macro_elements': [3, 3], 'make_pou': make_Q1_pou, 'pou_id': Q1_pou_id}
assert_results(run_fixed_H_refined_h(**kwargs), expected_results_fixed_H_refined_h(**kwargs))
def test_fixed_h_refined_H():
kwargs = {'global_grid_refines': 3, 'num_H_refs_less': 0, 'initial_macro_grid': [1, 1]}
kwargs = {'global_grid_refines': 3, 'num_H_refs_less': 0, 'initial_macro_grid': [1, 1], 'make_pou': make_Q1_pou, 'pou_id': Q1_pou_id}
assert_results(run_fixed_h_refined_H(**kwargs), expected_results_fixed_h_refined_H(**kwargs))
def run_fixed_h_refined_H_with_fine_PoU_in_basis(
global_grid_refines=3,
num_H_refs_less=0,
initial_macro_grid=[1, 1],
make_pou=lambda dd: ContinuousLagrangePartitionOfUnity(dd),
pou_id='Q1PoU',
DATASET_ID=FILENAME + '.run_fixed_h_refined_H_with_fine_PoU_in_basis'):
def run_fixed_h_refined_H_with_fine_PoU_in_basis( # see the bottom for suitable defaults
global_grid_refines,
num_H_refs_less,
initial_macro_grid,
make_pou,
pou_id,
DATASET_ID=FILENAME + '.fixed_h_refined_H_with_fine_PoU_in_basis'):
config = dict(base_config)
config['local_space_type'] = 'dg_p1'
macro_grid = list(initial_macro_grid)
......@@ -266,8 +270,9 @@ def run_fixed_h_refined_H_with_fine_PoU_in_basis(
return results
def expected_results_fixed_h_refined_H_with_fine_PoU_in_basis(global_grid_refines, num_H_refs_less, initial_macro_grid):
if global_grid_refines == 3 and num_H_refs_less == 1 and initial_macro_grid == [2, 2]:
def expected_results_fixed_h_refined_H_with_fine_PoU_in_basis(global_grid_refines, num_H_refs_less, initial_macro_grid,
**kwargs):
if global_grid_refines == 3 and num_H_refs_less == 1 and initial_macro_grid == [1, 1]:
return {'num_subdomains': [1, 4, 16],
'num_DoFs': [256, 256, 256],
'error': [0.04924311575284581, 0.0492431157528458, 0.049243115752845845],
......@@ -278,24 +283,24 @@ def expected_results_fixed_h_refined_H_with_fine_PoU_in_basis(global_grid_refine
def test_fixed_h_refined_H_with_fine_PoU_in_basis():
kwargs = {'global_grid_refines': 3, 'num_H_refs_less': 1, 'initial_macro_grid': [1, 1]}
kwargs = {'global_grid_refines': 3, 'num_H_refs_less': 1, 'initial_macro_grid': [1, 1], 'make_pou': make_Q1_pou, 'pou_id': Q1_pou_id}
assert_results(run_fixed_h_refined_H_with_fine_PoU_in_basis(**kwargs),
expected_results_fixed_h_refined_H_with_fine_PoU_in_basis(**kwargs))
if __name__ == '__main__':
r = run_fixed_H_refined_h()
r = run_fixed_H_refined_h(3, [3, 3], make_Q1_pou, Q1_pou_id)
for kk, vv in r.items():
print(kk, vv)
print('')
print('')
r = run_fixed_h_refined_H()
r = run_fixed_h_refined_H(3, 0, [1, 1], make_Q1_pou, Q1_pou_id)
for kk, vv in r.items():
print(kk, vv)
print('')
print('')
r = run_fixed_h_refined_H_with_fine_PoU_in_basis()
r = run_fixed_h_refined_H_with_fine_PoU_in_basis(3, 0, [1, 1], make_Q1_pou, Q1_pou_id)
for kk, vv in r.items():
print(kk, vv)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment