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