Peano
Loading...
Searching...
No Matches
ShrinkPatches.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
7 """
8 Extract the fine grid information
9
10 This is a very expensive filter if it is applied on large patch
11 sets, as it has to compare each patch with each other patch.
12 If you want to use it in an economically sensible way, I
13 recommend that you first apply other, cheaper filters to bring
14 the patch count down.
15
16 Even though the overlap operation is idempotent - if a patch
17 is not a fine grid patch within a small local dataset written
18 by one tree, then it can't be part of the fine grid in the
19 overall data set - I found that it is usually faster to
20 concatenate all data and then to apply the filter.
21 """
22
23 def __init__(self, scaling, verbose=False):
24 super(ShrinkPatches, self).__init__(
25 run_on_individual_pieces_of_data=True,
26 run_on_concatenated_data=False,
27 verbose=verbose,
28 )
29 self.scaling = scaling
30 pass
31
32 def render(
33 self,
34 cell_data,
35 dof,
36 dimensions,
37 unknowns,
38 is_data_associated_to_cell,
39 description,
40 mapping,
41 ):
42 for i in cell_data:
43 if dimensions == 3:
44 i.offset = (
45 i.offset[0] + i.size[0] * (1.0 - self.scaling) / 2.0,
46 i.offset[1] + i.size[1] * (1.0 - self.scaling) / 2.0,
47 i.offset[2] + i.size[2] * (1.0 - self.scaling) / 2.0,
48 )
49 i.size = (
50 i.size[0] * self.scaling,
51 i.size[1] * self.scaling,
52 i.size[2] * self.scaling,
53 )
54 else:
55 i.offset = (
56 i.offset[0] + i.size[0] * (1.0 - self.scaling) / 2.0,
57 i.offset[1] + i.size[1] * (1.0 - self.scaling) / 2.0,
58 )
59 i.size = (i.size[0] * self.scaling, i.size[1] * self.scaling)
60
61 return (
62 cell_data,
63 dof,
64 dimensions,
65 unknowns,
66 is_data_associated_to_cell,
67 description,
68 mapping,
69 )
An abstract filter class.
Definition Filter.py:5
__init__(self, scaling, verbose=False)
exploit_idempotent: boolean Exploit the fact that the filter is idempotent, i.e.