@@ -947,9 +947,7 @@ def post_processing(self):
947947 "Advection terms are not currently accounted for in the "
948948 "evaluation of surface flux values"
949949 )
950- export .compute (
951- self .ds ,
952- )
950+ export .compute (export .field .solution , self .ds )
953951 else :
954952 export .compute ()
955953 # update export data
@@ -960,7 +958,7 @@ def post_processing(self):
960958 export .write (t = float (self .t ))
961959 elif isinstance (export , exports .VolumeQuantity ):
962960 if isinstance (export , exports .TotalVolume | exports .AverageVolume ):
963- export .compute (self .dx )
961+ export .compute (u = export . field . solution , dx = self .dx )
964962 else :
965963 export .compute ()
966964 # update export data
@@ -1064,6 +1062,21 @@ def initialise(self):
10641062
10651063 for subdomain in self .volume_subdomains :
10661064 self .define_function_spaces (subdomain )
1065+ # create global DG function spaces of degree 0 and 1
1066+ element_DG0 = basix .ufl .element (
1067+ "DG" ,
1068+ self .mesh .mesh .basix_cell (),
1069+ 0 ,
1070+ basix .LagrangeVariant .equispaced ,
1071+ )
1072+ element_DG1 = basix .ufl .element (
1073+ "DG" ,
1074+ self .mesh .mesh .basix_cell (),
1075+ 1 ,
1076+ basix .LagrangeVariant .equispaced ,
1077+ )
1078+ self .V_DG_0 = fem .functionspace (self .mesh .mesh , element_DG0 )
1079+ self .V_DG_1 = fem .functionspace (self .mesh .mesh , element_DG1 )
10671080
10681081 self .define_temperature ()
10691082 self .convert_source_input_values_to_fenics_objects ()
@@ -1503,8 +1516,32 @@ def initialise_exports(self):
15031516 f"Export type { type (export )} not implemented for "
15041517 f"mixed-domain approach"
15051518 )
1506- else :
1507- raise NotImplementedError (f"Export type { type (export )} not implemented" )
1519+
1520+ # compute diffusivity function for surface fluxes
1521+
1522+ spe_to_D_global = {} # links species to global D function
1523+ spe_to_D_global_expr = {} # links species to D expression
1524+
1525+ for export in self .exports :
1526+ if isinstance (export , exports .SurfaceQuantity ):
1527+ if export .field in spe_to_D_global :
1528+ # if already computed then use the same D
1529+ D = spe_to_D_global [export .field ]
1530+ D_expr = spe_to_D_global_expr [export .field ]
1531+ else :
1532+ # compute D and add it to the dict
1533+ D , D_expr = self .define_D_global (export .field )
1534+ spe_to_D_global [export .field ] = D
1535+ spe_to_D_global_expr [export .field ] = D_expr
1536+
1537+ # add the global D to the export
1538+ export .D = D
1539+ export .D_expr = D_expr
1540+
1541+ # reset the data and time for SurfaceQuantity and VolumeQuantity
1542+ if isinstance (export , exports .SurfaceQuantity | exports .VolumeQuantity ):
1543+ export .t = []
1544+ export .data = []
15081545
15091546 def post_processing (self ):
15101547 # update post-processing solutions (for each species in each subdomain)
@@ -1536,6 +1573,56 @@ def post_processing(self):
15361573 if export .is_it_time_to_export (float (self .t )):
15371574 export .writer .write (float (self .t ))
15381575
1576+ # handle derived quantities
1577+ if isinstance (export , exports .SurfaceQuantity ):
1578+ if isinstance (
1579+ export ,
1580+ exports .SurfaceFlux | exports .TotalSurface | exports .AverageSurface ,
1581+ ):
1582+ if len (self .advection_terms ) > 0 :
1583+ warnings .warn (
1584+ "Advection terms are not currently accounted for in the "
1585+ "evaluation of surface flux values"
1586+ )
1587+ export_surf = export .surface
1588+ export_vol = self .surface_to_volume [export_surf ]
1589+ submesh_function = (
1590+ export .field .subdomain_to_post_processing_solution [export_vol ]
1591+ )
1592+ export .compute (
1593+ u = submesh_function ,
1594+ ds = self .ds ,
1595+ entity_maps = {
1596+ sd .submesh : sd .parent_to_submesh
1597+ for sd in self .volume_subdomains
1598+ },
1599+ )
1600+ else :
1601+ export .compute ()
1602+
1603+ elif isinstance (export , exports .VolumeQuantity ):
1604+ if isinstance (export , exports .TotalVolume | exports .AverageVolume ):
1605+ export .compute (
1606+ u = export .field .subdomain_to_post_processing_solution [
1607+ export_vol
1608+ ],
1609+ dx = self .dx ,
1610+ entity_maps = {
1611+ sd .submesh : sd .parent_to_submesh
1612+ for sd in self .volume_subdomains
1613+ },
1614+ )
1615+ else :
1616+ export .compute ()
1617+
1618+ if isinstance (export , exports .SurfaceQuantity | exports .VolumeQuantity ):
1619+ # update export data
1620+ export .t .append (float (self .t ))
1621+
1622+ # if filename given write export data to file
1623+ if export .filename is not None :
1624+ export .write (t = float (self .t ))
1625+
15391626 def iterate (self ):
15401627 """Iterates the model for a given time step"""
15411628 if self .show_progress_bar :
0 commit comments