44from itertools import chain
55from finat .physically_mapped import DirectlyDefinedElement , PhysicallyMappedElement
66
7- from numpy import asarray
8-
97import ufl
108from ufl .algorithms import extract_arguments , extract_coefficients
119from ufl .algorithms .analysis import has_type
1210from ufl .classes import Form , GeometricQuantity
1311from ufl .log import GREEN
14- from ufl .utils .sequences import max_degree
1512
1613import gem
1714import gem .impero_utils as impero_utils
1815
19- from FIAT .reference_element import TensorProductCell
20-
2116import finat
22- from finat .quadrature import AbstractQuadratureRule , make_quadrature
2317
2418from tsfc import fem , ufl_utils
25- from tsfc .finatinterface import as_fiat_cell
2619from tsfc .logging import logger
2720from tsfc .parameters import default_parameters , is_complex
2821from tsfc .ufl_utils import apply_mapping
@@ -96,7 +89,6 @@ def compile_integral(integral_data, form_data, prefix, parameters, interface, co
9689 :returns: a kernel constructed by the kernel interface
9790 """
9891 parameters = preprocess_parameters (parameters )
99-
10092 if interface is None :
10193 if coffee :
10294 import tsfc .kernel_interface .firedrake as firedrake_interface_coffee
@@ -112,7 +104,6 @@ def compile_integral(integral_data, form_data, prefix, parameters, interface, co
112104 kernel_name = "%s_%s_integral_%s" % (prefix , integral_type , integral_data .subdomain_id )
113105 # Handle negative subdomain_id
114106 kernel_name = kernel_name .replace ("-" , "_" )
115-
116107 # Dict mapping domains to index in original_form.ufl_domains()
117108 domain_numbering = form_data .original_form .domain_numbering ()
118109 domain_number = domain_numbering [integral_data .domain ]
@@ -134,22 +125,17 @@ def compile_integral(integral_data, form_data, prefix, parameters, interface, co
134125 builder = interface (integral_data_info ,
135126 scalar_type ,
136127 diagonal = diagonal )
137-
138128 builder .set_coordinates (mesh )
139129 builder .set_cell_sizes (mesh )
140-
141130 builder .set_coefficients (integral_data , form_data )
142-
143131 ctx = builder .create_context ()
144132 for integral in integral_data .integrals :
145133 params = parameters .copy ()
146134 params .update (integral .metadata ()) # integral metadata overrides
147-
148135 integrand = ufl .replace (integral .integrand (), form_data .function_replace_map )
149136 integrand_exprs = builder .compile_integrand (integrand , params , ctx )
150137 integral_exprs = builder .construct_integrals (integrand_exprs , params )
151138 builder .stash_integrals (integral_exprs , params , ctx )
152-
153139 return builder .construct_kernel (kernel_name , ctx )
154140
155141
@@ -331,107 +317,3 @@ def __call__(self, ps):
331317 assert set (gem_expr .free_indices ) <= set (chain (ps .indices , * argument_multiindices ))
332318
333319 return gem_expr
334-
335-
336- def set_quad_rule (params , cell , integral_type , functions ):
337- # Check if the integral has a quad degree attached, otherwise use
338- # the estimated polynomial degree attached by compute_form_data
339- try :
340- quadrature_degree = params ["quadrature_degree" ]
341- except KeyError :
342- quadrature_degree = params ["estimated_polynomial_degree" ]
343- function_degrees = [f .ufl_function_space ().ufl_element ().degree () for f in functions ]
344- if all ((asarray (quadrature_degree ) > 10 * asarray (degree )).all ()
345- for degree in function_degrees ):
346- logger .warning ("Estimated quadrature degree %s more "
347- "than tenfold greater than any "
348- "argument/coefficient degree (max %s)" ,
349- quadrature_degree , max_degree (function_degrees ))
350- if params .get ("quadrature_rule" ) == "default" :
351- del params ["quadrature_rule" ]
352- try :
353- quad_rule = params ["quadrature_rule" ]
354- except KeyError :
355- fiat_cell = as_fiat_cell (cell )
356- integration_dim , _ = lower_integral_type (fiat_cell , integral_type )
357- integration_cell = fiat_cell .construct_subelement (integration_dim )
358- quad_rule = make_quadrature (integration_cell , quadrature_degree )
359- params ["quadrature_rule" ] = quad_rule
360-
361- if not isinstance (quad_rule , AbstractQuadratureRule ):
362- raise ValueError ("Expected to find a QuadratureRule object, not a %s" %
363- type (quad_rule ))
364-
365-
366- def get_index_ordering (quadrature_indices , return_variables ):
367- split_argument_indices = tuple (chain (* [var .index_ordering ()
368- for var in return_variables ]))
369- return tuple (quadrature_indices ) + split_argument_indices
370-
371-
372- def lower_integral_type (fiat_cell , integral_type ):
373- """Lower integral type into the dimension of the integration
374- subentity and a list of entity numbers for that dimension.
375-
376- :arg fiat_cell: FIAT reference cell
377- :arg integral_type: integral type (string)
378- """
379- vert_facet_types = ['exterior_facet_vert' , 'interior_facet_vert' ]
380- horiz_facet_types = ['exterior_facet_bottom' , 'exterior_facet_top' , 'interior_facet_horiz' ]
381-
382- dim = fiat_cell .get_dimension ()
383- if integral_type == 'cell' :
384- integration_dim = dim
385- elif integral_type in ['exterior_facet' , 'interior_facet' ]:
386- if isinstance (fiat_cell , TensorProductCell ):
387- raise ValueError ("{} integral cannot be used with a TensorProductCell; need to distinguish between vertical and horizontal contributions." .format (integral_type ))
388- integration_dim = dim - 1
389- elif integral_type == 'vertex' :
390- integration_dim = 0
391- elif integral_type in vert_facet_types + horiz_facet_types :
392- # Extrusion case
393- if not isinstance (fiat_cell , TensorProductCell ):
394- raise ValueError ("{} integral requires a TensorProductCell." .format (integral_type ))
395- basedim , extrdim = dim
396- assert extrdim == 1
397-
398- if integral_type in vert_facet_types :
399- integration_dim = (basedim - 1 , 1 )
400- elif integral_type in horiz_facet_types :
401- integration_dim = (basedim , 0 )
402- else :
403- raise NotImplementedError ("integral type %s not supported" % integral_type )
404-
405- if integral_type == 'exterior_facet_bottom' :
406- entity_ids = [0 ]
407- elif integral_type == 'exterior_facet_top' :
408- entity_ids = [1 ]
409- else :
410- entity_ids = list (range (len (fiat_cell .get_topology ()[integration_dim ])))
411-
412- return integration_dim , entity_ids
413-
414-
415- def pick_mode (mode ):
416- "Return one of the specialized optimisation modules from a mode string."
417- try :
418- from firedrake_citations import Citations
419- cites = {"vanilla" : ("Homolya2017" , ),
420- "coffee" : ("Luporini2016" , "Homolya2017" , ),
421- "spectral" : ("Luporini2016" , "Homolya2017" , "Homolya2017a" ),
422- "tensor" : ("Kirby2006" , "Homolya2017" , )}
423- for c in cites [mode ]:
424- Citations ().register (c )
425- except ImportError :
426- pass
427- if mode == "vanilla" :
428- import tsfc .vanilla as m
429- elif mode == "coffee" :
430- import tsfc .coffee_mode as m
431- elif mode == "spectral" :
432- import tsfc .spectral as m
433- elif mode == "tensor" :
434- import tsfc .tensor as m
435- else :
436- raise ValueError ("Unknown mode: {}" .format (mode ))
437- return m
0 commit comments