Home | Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 """ 4 This module contains code generation tools for the ufc::form class. 5 """ 6 7 # Copyright (C) 2008-2009 Martin Sandve Alnes and Simula Resarch Laboratory 8 # 9 # This file is part of SyFi. 10 # 11 # SyFi is free software: you can redistribute it and/or modify 12 # it under the terms of the GNU General Public License as published by 13 # the Free Software Foundation, either version 2 of the License, or 14 # (at your option) any later version. 15 # 16 # SyFi is distributed in the hope that it will be useful, 17 # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 # GNU General Public License for more details. 20 # 21 # You should have received a copy of the GNU General Public License 22 # along with SyFi. If not, see <http://www.gnu.org/licenses/>. 23 # 24 # First added: 2008-08-13 25 # Last changed: 2009-03-05 26 27 from sfc.codegeneration.codeformatting import indent, CodeFormatter 2830 "Code generator for an ufc::form." 33 37 41149 150 if __name__ == '__main__': 151 print "form.py, no test implemented" 15243 form_vars = { 44 "classname" : self.formrep.classname, 45 "constructor" : indent(self.gen_constructor()), 46 "constructor_arguments" : indent(self.gen_constructor_arguments()), 47 "initializer_list" : indent(self.gen_initializer_list()), 48 "destructor" : indent(self.gen_destructor()), 49 "members" : indent(self.gen_members()), 50 "rank" : indent(self.gen_rank()), 51 "num_coefficients" : indent(self.gen_num_coefficients()), 52 "signature" : indent(self.gen_signature()), 53 "create_dofmap" : indent(self.gen_create_dofmap()), 54 "create_finite_element" : indent(self.gen_create_finite_element()), 55 "create_cell_integral" : indent(self.gen_create_cell_integral()), 56 "create_exterior_facet_integral" : indent(self.gen_create_exterior_facet_integral()), 57 "create_interior_facet_integral" : indent(self.gen_create_interior_facet_integral()), 58 "num_cell_domains" : indent(self.gen_num_cell_domains()), 59 "num_exterior_facet_domains" : indent(self.gen_num_exterior_facet_domains()), 60 "num_interior_facet_domains" : indent(self.gen_num_interior_facet_domains()), 61 } 62 return form_vars63 66 69 72 75 78 8183 return 'return %d;' % self.formrep.rank84 87 90 9799 return self._gen_num_domains(self.formrep.citg_names)100102 return self._gen_num_domains(self.formrep.eitg_names)103105 return self._gen_num_domains(self.formrep.iitg_names)106108 "Utility function for creating factory functions." 109 code = CodeFormatter() 110 #if options.add_debug_code: # FIXME 111 # code.begin_debug() 112 # code += 'std::cout << "Creating object in %s, index is " << i << std::endl;' % name 113 # code.end_debug() 114 if classnames: 115 if isinstance(classnames, dict): 116 assert indices is None 117 else: 118 if indices is None: 119 indices = range(len(classnames)) 120 classnames = dict((i,c) for (i,c) in zip(indices, classnames)) 121 122 code.begin_switch("i") 123 for i, c in classnames.iteritems(): 124 code.begin_case(i) 125 code += "return new %s();" % c 126 code.end_case() 127 code.end_switch() 128 129 if return_null: 130 code += 'return 0;' 131 else: 132 code += 'throw std::runtime_error("Invalid index in %s()");' % name 133 return str(code)134136 return self._gen_create_switch(self.formrep.dm_names, "create_dofmap")137139 return self._gen_create_switch(self.formrep.fe_names, "create_finite_element")140142 return self._gen_create_switch(self.formrep.citg_names, "create_cell_integral", return_null=True)143145 return self._gen_create_switch(self.formrep.eitg_names, "create_exterior_facet_integral", return_null=True)146148 return self._gen_create_switch(self.formrep.iitg_names, "create_interior_facet_integral", return_null=True)
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Jun 11 11:34:32 2012 | http://epydoc.sourceforge.net |