[scripts] make visualize_pou importable

parent ffb11638
......@@ -6,19 +6,18 @@ from dune.gdt.usercode import (
ContinuousFlatTopPartitionOfUnity,
)
local_space_type = 'cg_p1'
def visualize(dd, pou, filename):
def visualize(dd, pou, filename, local_space_type):
zeros = [None for ss in np.arange(dd.num_subdomains)]
for ss in np.arange(dd.num_subdomains):
v = pou.on_subdomain(ss)[0]
v = pou.on_subdomain(ss, local_space_type)[0]
v *= 0
zeros[ss] = v
for II in np.arange(pou.size):
for ss in np.arange(dd.num_subdomains):
if ss in pou.patch(II):
ii = pou.local_index(II, ss)
v = pou.on_subdomain(ss)[ii]
v = pou.on_subdomain(ss, local_space_type)[ii]
else:
v = zeros[ss]
dd.add_local_visualization(ss, v, local_space_type, 'basis_{}'.format(II))
......@@ -27,21 +26,23 @@ def visualize(dd, pou, filename):
for ss in np.arange(dd.num_subdomains):
if ss in pou.patch(II):
ii = pou.local_index(II, ss)
v = pou.jacobians_on_subdomain(ss)[ii][jj]
v = pou.jacobians_on_subdomain(ss, local_space_type)[ii][jj]
else:
v = zeros[ss]
dd.add_local_visualization(ss, v, local_space_type, 'basis_{}_jacobian{}'.format(II, jj))
dd.write_visualization(filename)
num_local_refinements = 4
num_subdomains_per_dim = 3
num_elements_per_subdomain_and_dim = 2**num_local_refinements
dd = DomainDecomposition([num_subdomains_per_dim, num_subdomains_per_dim], num_local_refinements, [0, 0], [1, 1])
if __name__ == '__main__':
local_space_type = 'cg_p1'
num_local_refinements = 4
num_subdomains_per_dim = 3
num_elements_per_subdomain_and_dim = 2**num_local_refinements
dd = DomainDecomposition([num_subdomains_per_dim, num_subdomains_per_dim], num_local_refinements, [0, 0], [1, 1])
cg_PoU = ContinuousLagrangePartitionOfUnity(dd)
visualize(dd, cg_PoU, 'cg_PoU')
cg_PoU = ContinuousLagrangePartitionOfUnity(dd)
visualize(dd, cg_PoU, 'cg_PoU', local_space_type)
ft_PoU = ContinuousFlatTopPartitionOfUnity(dd, overlap=0.5)
visualize(dd, ft_PoU, 'ft_PoU')
ft_PoU = ContinuousFlatTopPartitionOfUnity(dd, overlap=0.5)
visualize(dd, ft_PoU, 'ft_PoU', local_space_type)
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