Peano
Loading...
Searching...
No Matches
StepToActionSets.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
4
5class StepToActionSets(object):
6 """!
7
8 Maps a step to an action set
9
10 This is a generator, i.e. it is
11 """
12
13
14 def __init__(self,step):
15 self.step = step
16
17 def construct_output(self,output,action_set):
18 """
19 Construct one action_set
20 """
21 number_of_user_action_sets = 0
22 for x in self.step.action_sets:
23 if x.user_should_modify_template():
24 number_of_user_action_sets +=1
25
26 action_set_name = ""
27 subnamespace = ""
28 if action_set.user_should_modify_template():
29 subnamespace = "actions"
30 action_set_name = action_set.get_action_set_name()
31 print( "user has to modify class " + action_set.get_action_set_name() + " in actions directory manually ")
32 else:
33 subnamespace = "observers"
34 action_set_name = self.step.get_observer_class_name() + "2" + action_set.get_action_set_name() + str( self.step.action_sets.index(action_set))
35
36 new_action_set = peano4.api.output.ActionSet(
37 action_set_name, self.step.project.namespace + [ subnamespace ], self.step.project.subdirectory + subnamespace, action_set
38 )
39
40 for i in self.step.vertex_data:
41 new_action_set.include_files.append( i.subdirectory + "vertexdata/" + i.name + ".h" )
42 for i in self.step.face_data:
43 new_action_set.include_files.append( i.subdirectory + "facedata/" + i.name + ".h" )
44 for i in self.step.cell_data:
45 new_action_set.include_files.append( i.subdirectory + "celldata/" + i.name + ".h" )
46
47 if len(self.step.vertex_data)>0:
48 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_CREATE_PERSISTENT_VERTEX, "void" ] + self.step.get_vertex_operations_signature() )
49 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_DESTROY_PERSISTENT_VERTEX, "void" ] + self.step.get_vertex_operations_signature() )
50 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_CREATE_HANGING_VERTEX, "void" ] + self.step.get_vertex_operations_signature() )
51 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_DESTROY_HANGING_VERTEX, "void" ] + self.step.get_vertex_operations_signature() )
52 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME, "void" ] + self.step.get_vertex_operations_signature() )
53 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_LAST_TIME, "void" ] + self.step.get_vertex_operations_signature() )
54
55 if len(self.step.face_data)>0:
56 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_CREATE_PERSISTENT_FACE, "void" ] + self.step.get_face_operations_signature() )
57 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_DESTROY_PERSISTENT_FACE, "void" ] + self.step.get_face_operations_signature() )
58 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_CREATE_HANGING_FACE, "void" ] + self.step.get_face_operations_signature() )
59 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_DESTROY_HANGING_FACE, "void" ] + self.step.get_face_operations_signature() )
60 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME, "void" ] + self.step.get_face_operations_signature() )
61 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_TOUCH_FACE_LAST_TIME, "void" ] + self.step.get_face_operations_signature() )
62
63 if len(self.step.cell_data)>0:
64 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_CREATE_CELL, "void" ] + self.step.get_cell_operations_signature() )
65 new_action_set.operations.append( [ peano4.api.solversteps.ActionSet.OPERATION_DESTROY_CELL, "void" ] + self.step.get_cell_operations_signature() )
66
67 new_action_set.operations.append(
68 [ peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME, "void" ] +
69 self.step.get_touch_cell_signature()
70 )
71 new_action_set.operations.append(
72 [ peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_LAST_TIME, "void" ] +
73 self.step.get_touch_cell_signature()
74 )
75
76 output.artefacts.append( new_action_set )
77 output.makefile.add_cpp_file( new_action_set.get_cpp_file_name(), generated=True )
78
79 return subnamespace + "::" + new_action_set.classname
Code generator for one action set.
Definition ActionSet.py:12
construct_output(self, output, action_set)
Construct one action_set.