249
251
real, dimension(u%dim) :: abs_wd_const
252
type(mesh_type) :: p0_mesh
253
type(csr_sparsity), pointer :: dependency_sparsity
254
type(scalar_field) :: node_colour
255
type(integer_set), dimension(:), allocatable :: clr_sets
256
integer :: clr, nnid, no_colours, len
257
logical :: compact_stencil
254
type(integer_set), dimension(:), pointer :: colours
255
integer :: len, clr, nnid
256
!! Is the transform_to_physical cache we prepopulated valid
257
logical :: cache_valid
258
258
integer :: num_threads
260
260
! Volume fraction fields for multi-phase flow simulation
617
617
call remap_field(wettingdrying_alpha, alpha_u_field)
620
call profiler_tic(u, "element_loop")
620
call profiler_tic(u, "element_loop-omp_overhead")
624
num_threads = omp_get_max_threads()
623
num_threads = omp_get_max_threads()
629
if(num_threads>1) then
631
!! working out the options for different schemes of different terms
632
call set_coriolis_parameters
633
compact_stencil = have_option(trim(u%option_path)//&
634
&"/prognostic/spatial_discretisation"//&
635
&"/discontinuous_galerkin/viscosity_scheme"//&
636
&"/interior_penalty") .or. &
637
&have_option(trim(u%option_path)//&
638
&"/prognostic/spatial_discretisation"//&
639
&"/discontinuous_galerkin/viscosity_scheme"//&
640
&"/compact_discontinuous_galerkin")
642
compact_stencil=.false.
643
!! generate the dual graph of the mesh
644
p0_mesh = piecewise_constant_mesh(x%mesh, trim(x%name)//"P0Mesh")
646
!! the sparse pattern of the dual graph.
647
if (have_viscosity .and. (.not. compact_stencil)) then
648
dependency_sparsity => get_csr_sparsity_secondorder(state, p0_mesh, p0_mesh)
650
dependency_sparsity =>get_csr_sparsity_compactdgdouble(state, p0_mesh)
653
dependency_sparsity => get_csr_sparsity_secondorder(state, p0_mesh, p0_mesh)
655
!! colouring dual graph according the sparsity pattern with greedy
656
!! colouring algorithm
657
!! "colours" is an array of type(integer_set)
658
call colour_sparsity(dependency_sparsity, p0_mesh, node_colour, no_colours)
660
if(.not. verify_colour_sparsity(dependency_sparsity, node_colour)) then
661
FLAbort("The neighbours are using same colours, wrong!!.")
664
allocate(clr_sets(no_colours))
665
clr_sets=colour_sets(dependency_sparsity, node_colour, no_colours)
666
PRINT *, "colouring passed"
628
if (have_viscosity) then
629
call get_mesh_colouring(state, u%mesh, COLOURING_DG2, colours)
669
allocate(clr_sets(no_colours))
670
call allocate(clr_sets)
671
do ELE=1,element_count(U)
672
call insert(clr_sets(1), ele)
676
colour_loop: do clr = 1, no_colours
677
len = key_count(clr_sets(clr))
678
!$OMP PARALLEL DO DEFAULT(SHARED) &
679
!$OMP SCHEDULE(STATIC) &
680
!$OMP PRIVATE(nnid, ele)
681
element_loop: do nnid = 1, len
682
ele = fetch(clr_sets(clr), nnid)
631
call get_mesh_colouring(state, u%mesh, COLOURING_DG0, colours)
634
cache_valid = prepopulate_transform_cache(X)
636
if (have_coriolis) then
637
call set_coriolis_parameters
640
call profiler_toc(u, "element_loop-omp_overhead")
642
call profiler_tic(u, "element_loop")
644
!$OMP PARALLEL DEFAULT(SHARED) &
645
!$OMP PRIVATE(clr, nnid, ele, len)
647
colour_loop: do clr = 1, size(colours)
648
len = key_count(colours(clr))
650
!$OMP DO SCHEDULE(STATIC)
651
element_loop: do nnid = 1, len
652
ele = fetch(colours(clr), nnid)
683
653
call construct_momentum_element_dg(ele, big_m, rhs, &
684
654
& X, U, advecting_velocity, U_mesh, X_old, X_new, &
685
655
& Source, Buoyancy, gravity, Abs, Viscosity, &
1794
1758
! Add BC into RHS
1796
rhs_addto(dim,:) = rhs_addto(dim,:) &
1797
& -matmul(Viscosity_mat(dim,:,start:finish), &
1798
& ele_val(velocity_bc,dim,face))
1760
rhs_addto(dim,:) = rhs_addto(dim,:) &
1761
& -matmul(Viscosity_mat(dim,:,start:finish), &
1762
& ele_val(velocity_bc,dim,face))
1800
1763
! Ensure it is not used again.
1801
1764
Viscosity_mat(dim,:,start:finish)=0.0