@@ -1974,16 +1974,15 @@ subroutine assemble_advectiondiffusion_m_cv(A_m, rhs, D_m, diff_rhs, &
1974
1974
if (include_advection) then
1975
1975
1976
1976
! u.n
1977
+ divudotn = dot_product (u_bdy_f(:,ggi), normal_bdy(:,ggi))
1977
1978
if (move_mesh) then
1978
- divudotn = dot_product (u_bdy_f(:,ggi), normal_bdy(:,ggi))
1979
1979
if ((tfield_bc_type(sele)==BC_TYPE_ZEROFLUX .or. tfield_bc_type(sele)==BC_TYPE_FLUX)) then
1980
1980
! If we have zero flux, or a flux BC, set u.n = 0
1981
1981
udotn = 0.0
1982
1982
else
1983
1983
udotn = dot_product ((u_bdy_f(:,ggi)- ug_bdy_f(:,ggi)), normal_bdy(:,ggi))
1984
1984
end if
1985
1985
else
1986
- divudotn = dot_product (u_bdy_f(:,ggi), normal_bdy(:,ggi))
1987
1986
if ((tfield_bc_type(sele)==BC_TYPE_ZEROFLUX .or. tfield_bc_type(sele)==BC_TYPE_FLUX)) then
1988
1987
udotn = 0.0
1989
1988
else
@@ -2642,7 +2641,6 @@ subroutine solve_coupled_cv(field_name, nfields, state, global_it)
2642
2641
2643
2642
move_mesh = have_option(" /mesh_adaptivity/mesh_movement" )
2644
2643
if (move_mesh) then
2645
- FLExit(" Moving meshes not fully set-up with coupled cv." )
2646
2644
if (.not. include_advection) then
2647
2645
FLExit(" Moving the mesh but not including advection is not possible yet." )
2648
2646
end if
@@ -2769,12 +2767,11 @@ subroutine solve_coupled_cv(field_name, nfields, state, global_it)
2769
2767
tdensity, oldtdensity, tdensity_options, &
2770
2768
cvfaces, x_cvshape, x_cvbdyshape, &
2771
2769
u_cvshape, u_cvbdyshape, t_cvshape, &
2772
- state, advu, x, x_tfield, cfl_no, &
2770
+ ug_cvshape, ug_cvbdyshape, &
2771
+ state, advu, ug, x, x_tfield, cfl_no, &
2773
2772
getmat, sub_dt, &
2774
2773
mesh_sparsity_x)
2775
2774
2776
-
2777
-
2778
2775
do f = 1 , nfields
2779
2776
2780
2777
! assemble it all into a coherent equation
@@ -2866,7 +2863,8 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
2866
2863
tdensity , oldtdensity , tdensity_options , &
2867
2864
cvfaces , x_cvshape , x_cvbdyshape , &
2868
2865
u_cvshape , u_cvbdyshape , t_cvshape , &
2869
- state , advu , x , x_tfield , cfl_no , getmat , dt , &
2866
+ ug_cvshape , ug_cvbdyshape , &
2867
+ state , advu , ug , x , x_tfield , cfl_no , getmat , dt , &
2870
2868
mesh_sparsity )
2871
2869
2872
2870
! !< This subroutine assembles the advection matrix and rhs for
@@ -2898,11 +2896,13 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
2898
2896
! shape functions for region and surface
2899
2897
type (element_type), intent (in ) :: x_cvshape, x_cvbdyshape
2900
2898
type (element_type), intent (in ) :: u_cvshape, u_cvbdyshape
2899
+ type (element_type), intent (in ) :: ug_cvshape, ug_cvbdyshape
2901
2900
type (element_type), intent (in ) :: t_cvshape
2902
2901
! bucket full of fields
2903
2902
type (state_type), dimension (:), intent (inout ) :: state
2904
2903
! the advection velocity
2905
2904
type (vector_field), intent (in ) :: advu
2905
+ type (vector_field), pointer :: ug
2906
2906
! the coordinates
2907
2907
type (vector_field), intent (inout ) :: x, x_tfield
2908
2908
! the cfl number
@@ -2921,6 +2921,7 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
2921
2921
! and the cfl number at the gauss pts and nodes
2922
2922
real , dimension (:,:), allocatable :: x_ele, x_ele_bdy
2923
2923
real , dimension (:,:), allocatable :: x_f, u_f, u_bdy_f
2924
+ real , dimension (:,:), allocatable :: ug_f, ug_bdy_f
2924
2925
real , dimension (:,:), allocatable :: normal, normal_bdy
2925
2926
real , dimension (:), allocatable :: detwei, detwei_bdy
2926
2927
real , dimension (:), allocatable :: normgi
@@ -2954,7 +2955,7 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
2954
2955
oldtfield_upwind, tdensity_upwind, oldtdensity_upwind
2955
2956
2956
2957
! incoming or outgoing flow
2957
- real :: udotn, income, udotn_bdy
2958
+ real :: udotn, divudotn, income, udotn_bdy
2958
2959
logical :: inflow
2959
2960
! time and face discretisation
2960
2961
real , dimension (size (tfield)) :: ptheta, beta
@@ -2979,6 +2980,7 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
2979
2980
allocate (x_ele(x% dim,ele_loc(x,1 )), &
2980
2981
x_f(x% dim, x_cvshape% ngi), &
2981
2982
u_f(advu% dim, u_cvshape% ngi), &
2983
+ ug_f(advu% dim, ug_cvshape% ngi), &
2982
2984
detwei(x_cvshape% ngi), &
2983
2985
normal(x% dim, x_cvshape% ngi), &
2984
2986
normgi(x% dim))
@@ -3053,6 +3055,7 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
3053
3055
u_f= ele_val_at_quad(advu, ele, u_cvshape)
3054
3056
nodes= >ele_nodes(tfield(1 )% ptr, ele)
3055
3057
x_nodes= >ele_nodes(x_tfield, ele)
3058
+ if (move_mesh) ug_f= ele_val_at_quad(ug, ele, ug_cvshape)
3056
3059
if ((tfield_options(1 )% upwind_scheme== CV_UPWINDVALUE_PROJECT_POINT).or. &
3057
3060
(tfield_options(1 )% upwind_scheme== CV_UPWINDVALUE_PROJECT_GRAD)) then
3058
3061
upwind_nodes= >x_nodes
@@ -3107,7 +3110,13 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
3107
3110
normgi= orientate_cvsurf_normgi(node_val(x_tfield, x_nodes(iloc)),x_f(:,ggi),normal(:,ggi))
3108
3111
3109
3112
! calculate u.n
3110
- udotn= dot_product (u_f(:,ggi), normgi(:))
3113
+ if (move_mesh) then
3114
+ udotn= dot_product ((u_f(:,ggi)- ug_f(:,ggi)), normgi(:))
3115
+ divudotn= dot_product (u_f(:,ggi), normgi(:))
3116
+ else
3117
+ udotn= dot_product (u_f(:,ggi), normgi(:))
3118
+ divudotn= udotn
3119
+ end if
3111
3120
3112
3121
inflow = (udotn<= 0.0 )
3113
3122
@@ -3188,22 +3197,22 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
3188
3197
3189
3198
call addto_diag(A_m(f), nodes(iloc), &
3190
3199
ptheta(f)* detwei(ggi)* udotn* (1.0 - income)* tdensity_theta_val &
3191
- - ftheta* (1 .- beta(f))* detwei(ggi)* udotn * tdensity_theta_val)
3200
+ - ftheta* (1 .- beta(f))* detwei(ggi)* divudotn * tdensity_theta_val)
3192
3201
call addto_diag(A_m(f), nodes(oloc), &
3193
3202
ptheta(f)* detwei(ggi)* (- udotn)* income* tdensity_theta_val &
3194
- - ftheta* (1 .- beta(f))* detwei(ggi)* (- udotn )* tdensity_theta_val) ! notvisited
3203
+ - ftheta* (1 .- beta(f))* detwei(ggi)* (- divudotn )* tdensity_theta_val) ! notvisited
3195
3204
3196
3205
end if
3197
3206
3198
3207
! assemble the rhs
3199
3208
call addto(rhs(f), nodes(iloc), &
3200
3209
ptheta(f)* udotn* detwei(ggi)* tdensity_theta_val* tfield_pivot_val &
3201
3210
- udotn* detwei(ggi)* tfield_theta_val* tdensity_theta_val &
3202
- + (1 .- ftheta)* (1 .- beta(f))* detwei(ggi)* udotn * tdensity_theta_val* oldtfield_ele(f,iloc))
3211
+ + (1 .- ftheta)* (1 .- beta(f))* detwei(ggi)* divudotn * tdensity_theta_val* oldtfield_ele(f,iloc))
3203
3212
call addto(rhs(f), nodes(oloc), &
3204
3213
ptheta(f)* (- udotn)* detwei(ggi)* tdensity_theta_val* tfield_pivot_val &
3205
3214
- (- udotn)* detwei(ggi)* tfield_theta_val* tdensity_theta_val &
3206
- + (1 .- ftheta)* (1 .- beta(f))* detwei(ggi)* (- udotn )* tdensity_theta_val* oldtfield_ele(f,oloc)) ! notvisited
3215
+ + (1 .- ftheta)* (1 .- beta(f))* detwei(ggi)* (- divudotn )* tdensity_theta_val* oldtfield_ele(f,oloc)) ! notvisited
3207
3216
else
3208
3217
! if we need the matrix then assemble it now
3209
3218
if (getmat(f)) then
@@ -3214,22 +3223,22 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
3214
3223
3215
3224
call addto_diag(A_m(f), nodes(iloc), &
3216
3225
ptheta(f)* detwei(ggi)* udotn* (1.0 - income)* tdensity_theta_val &
3217
- - ftheta* (1 .- beta(f))* detwei(ggi)* udotn )
3226
+ - ftheta* (1 .- beta(f))* detwei(ggi)* divudotn )
3218
3227
call addto_diag(A_m(f), nodes(oloc), &
3219
3228
ptheta(f)* detwei(ggi)* (- udotn)* income* tdensity_theta_val &
3220
- - ftheta* (1 .- beta(f))* detwei(ggi)* (- udotn )) ! notvisited
3229
+ - ftheta* (1 .- beta(f))* detwei(ggi)* (- divudotn )) ! notvisited
3221
3230
3222
3231
end if
3223
3232
3224
3233
! assemble the rhs
3225
3234
call addto(rhs(f), nodes(iloc), &
3226
3235
ptheta(f)* udotn* detwei(ggi)* tfield_pivot_val &
3227
3236
- udotn* detwei(ggi)* tfield_theta_val &
3228
- + (1 .- ftheta)* (1 .- beta(f))* detwei(ggi)* udotn * oldtfield_ele(f,iloc))
3237
+ + (1 .- ftheta)* (1 .- beta(f))* detwei(ggi)* divudotn * oldtfield_ele(f,iloc))
3229
3238
call addto(rhs(f), nodes(oloc), &
3230
3239
ptheta(f)* (- udotn)* detwei(ggi)* tfield_pivot_val &
3231
3240
- (- udotn)* detwei(ggi)* tfield_theta_val &
3232
- + (1 .- ftheta)* (1 .- beta(f))* detwei(ggi)* (- udotn )* oldtfield_ele(f,oloc)) ! notvisited
3241
+ + (1 .- ftheta)* (1 .- beta(f))* detwei(ggi)* (- divudotn )* oldtfield_ele(f,oloc)) ! notvisited
3233
3242
3234
3243
end if
3235
3244
@@ -3247,6 +3256,7 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
3247
3256
detwei_bdy(x_cvbdyshape% ngi), &
3248
3257
normal_bdy(x% dim, x_cvbdyshape% ngi), &
3249
3258
u_bdy_f(advu% dim, u_cvbdyshape% ngi), &
3259
+ ug_bdy_f(advu% dim, ug_cvbdyshape% ngi), &
3250
3260
tdensity_ele_bdy(nfields,face_loc(tdensity(1 )% ptr,1 )), &
3251
3261
oldtdensity_ele_bdy(nfields,face_loc(oldtdensity(1 )% ptr,1 )), &
3252
3262
tfield_ele_bdy(nfields,face_loc(tfield(1 )% ptr,1 )), &
@@ -3283,6 +3293,7 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
3283
3293
x_cvbdyshape, normal_bdy, detwei_bdy)
3284
3294
3285
3295
u_bdy_f= face_val_at_quad(advu, sele, u_cvbdyshape)
3296
+ if (move_mesh) ug_bdy_f= face_val_at_quad(ug, sele, ug_cvbdyshape)
3286
3297
3287
3298
do f = 1 , nfields
3288
3299
! deal with bcs for tfield
@@ -3335,8 +3346,13 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
3335
3346
ggi = (face-1 )* cvfaces% shape% ngi + gi
3336
3347
3337
3348
! u.n
3338
- udotn_bdy= dot_product (u_bdy_f(:,ggi), normal_bdy(:,ggi))
3339
-
3349
+ divudotn = dot_product (u_bdy_f(:,ggi), normal_bdy(:,ggi))
3350
+ if (move_mesh) then
3351
+ udotn_bdy = dot_product ((u_bdy_f(:,ggi)- ug_bdy_f(:,ggi)), normal_bdy(:,ggi))
3352
+ else
3353
+ udotn_bdy = divudotn
3354
+ end if
3355
+
3340
3356
if (udotn_bdy> 0 ) then
3341
3357
income= 0.0 ! flow leaving the domain
3342
3358
else
@@ -3372,27 +3388,27 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
3372
3388
if (getmat(f)) then
3373
3389
call addto_diag(A_m(f), nodes_bdy(iloc), &
3374
3390
ptheta(f)* detwei_bdy(ggi)* udotn* (1 .- income)* tdensity_theta_val & ! if iloc is the donor we can do this implicitly
3375
- - ptheta(f)* (1 .- beta(f))* detwei_bdy(ggi)* udotn_bdy * tdensity_theta_val)
3391
+ - ptheta(f)* (1 .- beta(f))* detwei_bdy(ggi)* divudotn * tdensity_theta_val)
3376
3392
end if
3377
3393
3378
3394
! assemble rhs
3379
3395
call addto(rhs(f), nodes_bdy(iloc), &
3380
3396
- ptheta(f)* udotn* detwei_bdy(ggi)* income* tdensity_theta_val* ghost_tfield_ele_bdy(f,iloc) & ! but we can't if it's the downwind
3381
3397
- (1 .- ptheta(f))* udotn* detwei_bdy(ggi)* tdensity_theta_val* oldtfield_face_val(f) &
3382
- + (1 .- ptheta(f))* (1 .- beta(f))* udotn_bdy * detwei_bdy(ggi)* tdensity_theta_val* oldtfield_ele_bdy(f,iloc))
3398
+ + (1 .- ptheta(f))* (1 .- beta(f))* divudotn * detwei_bdy(ggi)* tdensity_theta_val* oldtfield_ele_bdy(f,iloc))
3383
3399
else
3384
3400
! assemble matrix
3385
3401
if (getmat(f)) then
3386
3402
call addto_diag(A_m(f), nodes_bdy(iloc), &
3387
3403
ptheta(f)* detwei_bdy(ggi)* udotn* (1 .- income) & ! if iloc is the donor we can do this implicitly
3388
- - ptheta(f)* (1 .- beta(f))* detwei_bdy(ggi)* udotn_bdy )
3404
+ - ptheta(f)* (1 .- beta(f))* detwei_bdy(ggi)* divudotn )
3389
3405
end if
3390
3406
3391
3407
! assemble rhs
3392
3408
call addto(rhs(f), nodes_bdy(iloc), &
3393
3409
- ptheta(f)* udotn* detwei_bdy(ggi)* income* ghost_tfield_ele_bdy(f,iloc) & ! but we can't if it's the downwind
3394
3410
- (1 .- ptheta(f))* udotn* detwei_bdy(ggi)* oldtfield_face_val(f) &
3395
- + (1 .- ptheta(f))* (1 .- beta(f))* udotn_bdy * detwei_bdy(ggi)* oldtfield_ele_bdy(f,iloc))
3411
+ + (1 .- ptheta(f))* (1 .- beta(f))* divudotn * detwei_bdy(ggi)* oldtfield_ele_bdy(f,iloc))
3396
3412
end if
3397
3413
3398
3414
end do surface_field_loop
@@ -3407,7 +3423,7 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
3407
3423
3408
3424
end do surface_element_loop
3409
3425
3410
- deallocate (x_ele_bdy, detwei_bdy, normal_bdy, u_bdy_f)
3426
+ deallocate (x_ele_bdy, detwei_bdy, normal_bdy, u_bdy_f, ug_bdy_f )
3411
3427
deallocate (nodes_bdy)
3412
3428
deallocate (tdensity_ele_bdy, oldtdensity_ele_bdy, tfield_ele_bdy, oldtfield_ele_bdy)
3413
3429
deallocate (ghost_tdensity_ele_bdy, ghost_oldtdensity_ele_bdy, &
@@ -3427,7 +3443,7 @@ subroutine assemble_coupled_advection_m_cv(A_m, rhs, &
3427
3443
call deallocate (oldtfield_upwind(f))
3428
3444
end do
3429
3445
3430
- deallocate (x_ele, x_f, detwei, normal, normgi, u_f)
3446
+ deallocate (x_ele, x_f, detwei, normal, normgi, u_f, ug_f )
3431
3447
deallocate (cfl_ele, tfield_ele, oldtfield_ele, tdensity_ele, oldtdensity_ele)
3432
3448
deallocate (notvisited)
3433
3449
0 commit comments