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