Peano
Loading...
Searching...
No Matches
ExtractMeshResolution.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from .Filter import Filter
4
5
8 self, min_h, max_h, run_on_individual_pieces_of_data=True, verbose=False
9 ):
10 Filter.__init__(
11 self,
12 run_on_individual_pieces_of_data,
13 not run_on_individual_pieces_of_data,
14 verbose,
15 )
16 self.min_h = min_h
17 self.max_h = max_h
18 if min_h > max_h:
19 print(
20 "Extract mesh resolution filter uses smaller max_h ("
21 + str(max_h)
22 + ") than min_h ("
23 + str(min_h)
24 + "). Permuted entries, but this should be fixed"
25 )
26 self.min_h = max_h
27 self.max_h = min_h
28 pass
29
30 def render(
31 self,
32 cell_data,
33 dof,
34 dimension,
35 unknowns,
36 is_data_associated_to_cell,
37 description,
38 mapping,
39 ):
40 """
41 Overwrite this one for the particular filter.
42 """
43
44 def sort_key(patch):
45 return patch.size[0]
46
47 print("Sort input data to optimise algorithmic efficiency")
48 cell_data.sort(key=sort_key)
49
50 new_cell_data = []
51
52 ratio_for_print = 10
53
54 i = 0
55 while i < len(cell_data) and cell_data[i].size[0] < self.max_h:
56 if cell_data[i].size[0] < self.max_h and cell_data[i].size[0] >= self.min_h:
57 new_cell_data.append(cell_data[i])
58 i += 1
59
60 if i > 0.01 * ratio_for_print * len(cell_data):
61 print("... " + str(ratio_for_print) + "%")
62 ratio_for_print += 10
63
64 print(
65 "Extracted "
66 + str(len(new_cell_data))
67 + " from the "
68 + str(len(cell_data))
69 + " patch(es)"
70 )
71
72 return (
73 new_cell_data,
74 dof,
75 dimension,
76 unknowns,
77 is_data_associated_to_cell,
78 description,
79 mapping,
80 )
__init__(self, min_h, max_h, run_on_individual_pieces_of_data=True, verbose=False)
exploit_idempotent: boolean Exploit the fact that the filter is idempotent, i.e.
An abstract filter class.
Definition Filter.py:5