Peano
Loading...
Searching...
No Matches
ModelToDataRepository.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
6
8 def __init__(self,model):
9 self.model = model
10 self.d = {}
11
12
14 """
15
16 To create a data repository, I run over all the faces, vertices, cells of the
17 project and befill the dictionary. There's multiple reasons for this:
18
19 - I want to ensure that we include the headers in the repository such that
20 all data types are well-defined.
21 - I create a stack map for each and every data entity.
22 - I ensure all datatypes are created if this record requires a user-defined MPI
23 datatype.
24
25
26 i is of type peano4.datamodel.DoF.
27
28 """
29 self.d[ "DATA_CONTAINER_INCLUDES" ] += i.generator.get_header_file_include()
30 self.d[ "DATA_CONTAINER_INCLUDES" ] += "\n"
31
32 self.d[ "DATA_CONTAINER_DECLARATION" ] += "static peano4::maps::HierarchicalStackMap< " + i.generator.get_stack_container() + "> _" + i.get_logical_type_name() + "Stack;\n"
33 self.d[ "DATA_CONTAINER_INSTANTIATION" ] += "peano4::maps::HierarchicalStackMap< " + i.generator.get_stack_container() + "> " + self.d[ "FULL_QUALIFIED_CLASS_NAME" ] + "::_" + i.get_logical_type_name() + "Stack;\n"
34 #self.d[ "DATA_CONTAINER_DECLARATION" ] += "static peano4::maps::STDStackMap< " + i.generator.get_stack_container() + "> _" + i.get_logical_type_name() + "Stack;\n"
35 #self.d[ "DATA_CONTAINER_INSTANTIATION" ] += "peano4::maps::STDStackMap< " + i.generator.get_stack_container() + "> " + self.d[ "FULL_QUALIFIED_CLASS_NAME" ] + "::_" + i.get_logical_type_name() + "Stack;\n"
36 self.d[ "DATA_CONTAINER_CLEARS" ] += "_" + i.get_logical_type_name() + "Stack.clear();\n"
37
38 self.d[ "MPI_DATAYPE_INITIALISATION" ] += i.get_full_qualified_type() + "::initDatatype();\n"
39 self.d[ "MPI_DATAYPE_SHUTDOWN" ] += i.get_full_qualified_type() + "::shutdownDatatype();\n"
40
41
43 subdirectory = self.model.subdirectories[n]
44 self.d[ "DATA_CONTAINER_TYPE_DEFS" ] = ""
45 self.d[ "DATA_CONTAINER_INCLUDES" ] = ""
46 self.d[ "DATA_CONTAINER_DECLARATION" ] = ""
47 self.d[ "DATA_CONTAINER_INSTANTIATION" ] = ""
48 self.d[ "MPI_DATAYPE_INITIALISATION" ] = ""
49 self.d[ "MPI_DATAYPE_SHUTDOWN" ] = ""
50 self.d[ "DATA_CONTAINER_CLEARS" ] = ""
51
52 self.d[ "FULL_QUALIFIED_CLASS_NAME" ] = ""
53 for i in self.__get_full_namespace(n):
54 self.d[ "FULL_QUALIFIED_CLASS_NAME" ] += i
55 self.d[ "FULL_QUALIFIED_CLASS_NAME" ] += "::"
56 self.d[ "FULL_QUALIFIED_CLASS_NAME" ] += self.__get_class_name()
57
58 for i in self.model.cell_data:
59 if i.subdirectory == subdirectory:
61
62 for i in self.model.face_data:
63 if i.subdirectory == subdirectory:
65
66 for i in self.model.vertex_data:
67 if i.subdirectory == subdirectory:
69
71 return self.model.namespaces[i] + [ "repositories" ]
72
74 return "DataRepository"
75
76
77 def construct_output(self,output):
78 for i in range(len(self.model.namespaces)):
80
81 namespace = self.__get_full_namespace(i)
82 # print("model.subdirectory[", i, "]", " = ", self.model.subdirectories[i])
83 # print("model.namespace[", i, "]", " = ", namespace)
84 class_name = self.__get_class_name()
85 output.makefile.add_cpp_file( self.model.subdirectories[i] + namespace[-1] + "/" + class_name + ".cpp", generated=True )
86 templatefile_prefix = os.path.realpath(__file__).replace( ".pyc", "" ).replace( ".py", "" )
87 local_d = self.d.copy()
89 templatefile_prefix+".template.h",
90 templatefile_prefix+".template.cpp",
91 class_name,
92 namespace,
93 self.model.subdirectories[i] + namespace[-1],
94 local_d,
95 True)
96 output.add(generated_files)
97 pass
__build_up_dictionary_for_one_data_set(self, i)
To create a data repository, I run over all the faces, vertices, cells of the project and befill the ...