Merge lp:~fluidity-core/fluidity/buoyancy_adjustment_diagnostic into lp:fluidity

Proposed by Adam Candy
Status: Merged
Merged at revision: 4061
Proposed branch: lp:~fluidity-core/fluidity/buoyancy_adjustment_diagnostic
Merge into: lp:fluidity
Diff against target: 164 lines (+69/-6)
3 files modified
assemble/Advection_Diffusion_DG.F90 (+37/-6)
schemas/fluidity_options.rnc (+14/-0)
schemas/fluidity_options.rng (+18/-0)
To merge this branch: bzr merge lp:~fluidity-core/fluidity/buoyancy_adjustment_diagnostic
Reviewer Review Type Date Requested Status
Alexandros Avdis Approve
Review via email: mp+124780@code.launchpad.net

Commit message

Introduces a diagnostic for the buoyancy adjustment by vertical mixing scheme.
Logging for the scheme has been leashed and generally improved.

Description of the change

Introduces a diagnostic for the buoyancy adjustment by vertical mixing scheme.
Logging for the scheme has been leashed and generally improved.

To post a comment you must log in.
4054. By Adam Candy

Tidied up commented-out code.

Revision history for this message
Alexandros Avdis (alexandros-avdis) wrote :

Looks good, it helps with some of my work too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'assemble/Advection_Diffusion_DG.F90'
2--- assemble/Advection_Diffusion_DG.F90 2012-09-17 19:22:44 +0000
3+++ assemble/Advection_Diffusion_DG.F90 2012-09-18 16:34:19 +0000
4@@ -143,6 +143,7 @@
5 logical :: on_sphere
6 ! Vertical diffusion by mixing option
7 logical :: have_buoyancy_adjustment_by_vertical_diffusion
8+ logical :: have_buoyancy_adjustment_diffusivity
9
10 contains
11
12@@ -751,6 +752,9 @@
13 logical :: cache_valid
14 integer :: num_threads
15
16+ !! Diffusivity to add due to the buoyancy adjustment by vertical mixing scheme
17+ type(scalar_field) :: buoyancy_adjustment_diffusivity
18+
19 ewrite(1,*) "Writing advection-diffusion equation for "&
20 &//trim(field_name)
21
22@@ -945,6 +949,7 @@
23 if (present(diffusion_m)) call zero(diffusion_m)
24 if (present(diffusion_RHS)) call zero(diffusion_RHS)
25 if (have_buoyancy_adjustment_by_vertical_diffusion) then
26+ ewrite(3,*) "Buoyancy adjustment by vertical mixing: enabled"
27 if (have_option(trim(T%option_path)//"/prognostic/buoyancy_adjustment"//&
28 &"/by_vertical_diffusion/project_buoyancy_to_continuous_space")) then
29 buoyancy_from_state = extract_scalar_field(state, "VelocityBuoyancyDensity", stat)
30@@ -956,7 +961,9 @@
31 ! Grab an extra reference to cause the deallocate below to be safe.
32 ! Check this is OK
33 call lumped_mass_galerkin_projection_scalar(state, buoyancy, buoyancy_from_state)
34+ ewrite(3,*) "Buoyancy adjustment by vertical mixing: projecting to continuous space"
35 else
36+ ewrite(3,*) "Buoyancy adjustment by vertical mixing: no projection"
37 buoyancy = extract_scalar_field(state, "VelocityBuoyancyDensity", stat)
38 if (stat/=0) FLAbort('Error extracting buoyancy field.')
39 call incref(buoyancy)
40@@ -976,6 +983,16 @@
41 end if
42 ! Set direction of mixing diffusion, default is in the y- and z-direction for 2- and 3-d spaces respectively
43 ! TODO: Align this direction with gravity local to an element
44+
45+ ! Check if the diagnostic associated with the buoyancy adjustment by vertical mixing scheme is required
46+ buoyancy_adjustment_diffusivity = extract_scalar_field(state, "BuoyancyAdjustmentDiffusivity", stat)
47+ if (stat==0) then
48+ have_buoyancy_adjustment_diffusivity = .true.
49+ ewrite(3,*) "Buoynacy adjustment by vertical mixing: Updating BuoyancyAdjustmentDiffusivity field."
50+ else
51+ have_buoyancy_adjustment_diffusivity = .false.
52+ end if
53+
54 end if
55
56 if (include_diffusion) then
57@@ -1011,6 +1028,7 @@
58 & rhs_diff, X, X_old, X_new, T, U_nl, U_mesh, Source, &
59 & Absorption, Diffusivity, bc_value, bc_type, q_mesh, mass, &
60 & buoyancy, gravity, gravity_magnitude, mixing_diffusion_amplitude, &
61+ & buoyancy_adjustment_diffusivity, &
62 & add_src_directly_to_rhs, porosity_theta)
63
64 end do element_loop
65@@ -1127,6 +1145,7 @@
66 & X, X_old, X_new, T, U_nl, U_mesh, Source, Absorption, Diffusivity,&
67 & bc_value, bc_type, &
68 & q_mesh, mass, buoyancy, gravity, gravity_magnitude, mixing_diffusion_amplitude, &
69+ & buoyancy_adjustment_diffusivity, &
70 & add_src_directly_to_rhs, porosity_theta)
71 !!< Construct the advection_diffusion equation for discontinuous elements in
72 !!< acceleration form.
73@@ -1154,6 +1173,9 @@
74 type(scalar_field), intent(in) :: T, Source, Absorption
75 !! Diffusivity
76 type(tensor_field), intent(in) :: Diffusivity
77+
78+ !! Diffusivity to add due to the buoyancy adjustment by vertical mixing scheme
79+ type(scalar_field), intent(inout) :: buoyancy_adjustment_diffusivity
80
81 !! If adding Source directly to rhs then
82 !! do nothing with it here
83@@ -1423,12 +1445,21 @@
84 &* gravity_magnitude * dr**2 * gravity_at_node(i) * drho_dz(:)
85 end do
86 end if
87-
88- !ewrite(3,*) "mixing_density_values", buoyancysample
89- ewrite(3,*) "mixing_grad_rho", minval(grad_rho(:,:)), maxval(grad_rho(:,:))
90- ewrite(3,*) "mixing_drho_dz", minval(drho_dz(:)), maxval(drho_dz(:))
91- ewrite(3,*) "mixing_coeffs amp dt g dr", mixing_diffusion_amplitude, dt, gravity_magnitude, dr**2
92- ewrite(3,*) "mixing_diffusion", minval(mixing_diffusion(2,2,:)), maxval(mixing_diffusion(2,2,:))
93+
94+ if(have_buoyancy_adjustment_diffusivity) then
95+ ewrite (-1,*) 'asc nodes', T_ele
96+ do i = 1,size(T_ele)
97+ call set(buoyancy_adjustment_diffusivity, T_ele(i), mixing_diffusion_amplitude * dt&
98+ &* gravity_magnitude * dr**2 * maxval(drho_dz(:)))
99+ end do
100+ ewrite(4,*) "Buoynacy adjustment diffusivity, ele:", ele, "diffusivity:", mixing_diffusion_amplitude * dt * gravity_magnitude * dr**2 * maxval(drho_dz(:))
101+ end if
102+
103+ !! Buoyancy adjustment by vertical mixing scheme debugging statements
104+ ewrite(4,*) "mixing_grad_rho", minval(grad_rho(:,:)), maxval(grad_rho(:,:))
105+ ewrite(4,*) "mixing_drho_dz", minval(drho_dz(:)), maxval(drho_dz(:))
106+ ewrite(4,*) "mixing_coeffs amp dt g dr", mixing_diffusion_amplitude, dt, gravity_magnitude, dr**2
107+ ewrite(4,*) "mixing_diffusion", minval(mixing_diffusion(2,2,:)), maxval(mixing_diffusion(2,2,:))
108
109 mixing_diffusion_rhs=shape_tensor_rhs(T%mesh%shape, mixing_diffusion, detwei_rho)
110 t_mass=shape_shape(T%mesh%shape, T%mesh%shape, detwei_rho)
111
112=== modified file 'schemas/fluidity_options.rnc'
113--- schemas/fluidity_options.rnc 2012-09-03 09:42:37 +0000
114+++ schemas/fluidity_options.rnc 2012-09-18 16:34:19 +0000
115@@ -4185,6 +4185,20 @@
116 }
117 )
118 }|
119+ element scalar_field {
120+ attribute rank { "0" },
121+ attribute name { "BuoyancyAdjustmentDiffusivity" },
122+ (
123+ element diagnostic {
124+ internal_algorithm,
125+ velocity_mesh_choice,
126+ diagnostic_scalar_field
127+ }|
128+ element aliased {
129+ generic_aliased_field
130+ }
131+ )
132+ }|
133 ## The equilibrium pressure perturbation
134 ##
135 ## Further details to be added
136
137=== modified file 'schemas/fluidity_options.rng'
138--- schemas/fluidity_options.rng 2012-09-03 09:42:37 +0000
139+++ schemas/fluidity_options.rng 2012-09-18 16:34:19 +0000
140@@ -5368,6 +5368,24 @@
141 </choice>
142 </element>
143 <element name="scalar_field">
144+ <attribute name="rank">
145+ <value>0</value>
146+ </attribute>
147+ <attribute name="name">
148+ <value>BuoyancyAdjustmentDiffusivity</value>
149+ </attribute>
150+ <choice>
151+ <element name="diagnostic">
152+ <ref name="internal_algorithm"/>
153+ <ref name="velocity_mesh_choice"/>
154+ <ref name="diagnostic_scalar_field"/>
155+ </element>
156+ <element name="aliased">
157+ <ref name="generic_aliased_field"/>
158+ </element>
159+ </choice>
160+ </element>
161+ <element name="scalar_field">
162 <a:documentation>The equilibrium pressure perturbation
163
164 Further details to be added