Merge lp:~s-parkinson11/fluidity/sinking_velocity_schema_fix into lp:fluidity
- sinking_velocity_schema_fix
- Merge into dev-trunk
Status: | Merged |
---|---|
Merged at revision: | 4133 |
Proposed branch: | lp:~s-parkinson11/fluidity/sinking_velocity_schema_fix |
Merge into: | lp:fluidity |
Diff against target: |
406 lines (+160/-9) 14 files modified
assemble/Advection_Diffusion_CG.F90 (+15/-2) assemble/Advection_Diffusion_DG.F90 (+82/-1) assemble/Advection_Diffusion_FV.F90 (+15/-2) assemble/Field_Equations_CV.F90 (+19/-2) schemas/fluidity_options.rnc (+3/-0) schemas/fluidity_options.rng (+4/-1) schemas/prognostic_field_options.rnc (+6/-0) schemas/prognostic_field_options.rng (+7/-1) tests/biology_6_component_parallel/biology_conservation.flml (+1/-0) tests/biology_6_component_parallel/biology_conservation_parallel.flml (+1/-0) tests/biology_conservation_adapt/biology_conservation.flml (+1/-0) tests/mms_sediment/MMS_X.flml (+4/-0) tests/sinking_velocity/sinking_velocity.flml (+1/-0) tests/sinking_velocity_cv/sinking_velocity.flml (+1/-0) |
To merge this branch: | bzr merge lp:~s-parkinson11/fluidity/sinking_velocity_schema_fix |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jon Hill | Approve | ||
Review via email: mp+125730@code.launchpad.net |
Commit message
Description of the change
Edited the schema to allow specification of the mesh used for sinking velocity fields. This is needed when the velocity field is on a different mesh to the scalar field with the sinking velocity or when using P1DGP2 with a DG field and projecting velocity to continuous.
Samuel Parkinson (s-parkinson11) wrote : | # |
- 4068. By Samuel Parkinson
-
changes to schema so that sinking velocity can have any mesh
Jon Hill (jon-hill) wrote : | # |
Add some documentation to the schema to say that this should be the velocity mesh?
Also, an options check somewhere wouldn't go amiss to make sure this is the case.
- 4069. By Samuel Parkinson
-
Added SinkingVelocity mesh checking to check_options routines of:
Advection_Diffusion_ CG.F90
Advection_Diffusion_ FV.F90
Field_Equations_CV.F90 Added check_options routine in Advection_
Diffusion_ DG.F90 with check for SinkingVelocity mesh. not tested yet.
- 4070. By Samuel Parkinson
-
merge with trunk
- 4071. By Samuel Parkinson
-
fixed bugs in options checking routines - these now work as planned
- 4072. By Samuel Parkinson
-
updated test flml files
Samuel Parkinson (s-parkinson11) wrote : | # |
Thanks Jon,
I have made some changes following your review. Do you think these meet the requirements?
I did notice that all prognostic field advection-diffusion discretisation options checking only happens on scalar fields that are in the root node of a material phase in the schema file. This could do with fixing at some point.
Cheers,
Sam
- 4073. By Samuel Parkinson
-
fixed bug that made all runs with scalar fields, but no sinking velocity, fail
- 4074. By Samuel Parkinson
-
merge with broken branch
- 4075. By Samuel Parkinson
-
merge with trunk
Preview Diff
1 | === modified file 'assemble/Advection_Diffusion_CG.F90' |
2 | --- assemble/Advection_Diffusion_CG.F90 2012-08-12 22:16:26 +0000 |
3 | +++ assemble/Advection_Diffusion_CG.F90 2012-11-27 18:25:25 +0000 |
4 | @@ -1431,7 +1431,7 @@ |
5 | subroutine advection_diffusion_cg_check_options |
6 | !!< Check CG advection-diffusion specific options |
7 | |
8 | - character(len = FIELD_NAME_LEN) :: field_name, state_name |
9 | + character(len = FIELD_NAME_LEN) :: field_name, state_name, mesh_0, mesh_1 |
10 | character(len = OPTION_PATH_LEN) :: path |
11 | integer :: i, j, stat |
12 | real :: beta, l_theta |
13 | @@ -1504,7 +1504,20 @@ |
14 | call field_error(state_name, field_name, & |
15 | & "Weak Dirichlet boundary conditions with diffusivity are not supported by CG advection-diffusion") |
16 | end if |
17 | - |
18 | + |
19 | + if (have_option(trim(path) // "/scalar_field::SinkingVelocity")) then |
20 | + call get_option(trim(complete_field_path(trim(path) // & |
21 | + "/scalar_field::SinkingVelocity"))//"/mesh[0]/name", & |
22 | + mesh_0, stat) |
23 | + if(stat == SPUD_NO_ERROR) then |
24 | + call get_option(trim(complete_field_path("/material_phase[" // int2str(i) // & |
25 | + "]/vector_field::Velocity")) // "/mesh[0]/name", mesh_1) |
26 | + if(trim(mesh_0) /= trim(mesh_1)) then |
27 | + call field_warning(state_name, field_name, & |
28 | + & "SinkingVelocity is on a different mesh to the Velocity field. This could cause problems") |
29 | + end if |
30 | + end if |
31 | + end if |
32 | if(have_option(trim(path) // "/spatial_discretisation/continuous_galerkin/advection_terms/exclude_advection_terms")) then |
33 | if(have_option(trim(path) // "/scalar_field::SinkingVelocity")) then |
34 | call field_warning(state_name, field_name, & |
35 | |
36 | === modified file 'assemble/Advection_Diffusion_DG.F90' |
37 | --- assemble/Advection_Diffusion_DG.F90 2012-10-11 17:52:01 +0000 |
38 | +++ assemble/Advection_Diffusion_DG.F90 2012-11-27 18:25:25 +0000 |
39 | @@ -45,6 +45,7 @@ |
40 | use petsc_solve_state_module |
41 | use boundary_conditions |
42 | use boundary_conditions_from_options |
43 | + use field_options |
44 | use spud |
45 | use upwind_stabilisation |
46 | use slope_limiters_dg |
47 | @@ -67,7 +68,8 @@ |
48 | character(len=255), private :: message |
49 | |
50 | private |
51 | - public solve_advection_diffusion_dg, construct_advection_diffusion_dg |
52 | + public solve_advection_diffusion_dg, construct_advection_diffusion_dg, & |
53 | + advection_diffusion_dg_check_options |
54 | |
55 | ! Local private control parameters. These are module-global parameters |
56 | ! because it would be expensive and/or inconvenient to re-evaluate them |
57 | @@ -3120,5 +3122,84 @@ |
58 | end subroutine initialise_aijxy |
59 | |
60 | end function masslumped_rt0_aij |
61 | + |
62 | + subroutine advection_diffusion_dg_check_options |
63 | + !!< Check DG advection-diffusion specific options |
64 | + |
65 | + character(len = FIELD_NAME_LEN) :: field_name, mesh_0, mesh_1, state_name |
66 | + character(len = OPTION_PATH_LEN) :: path |
67 | + integer :: i, j, stat |
68 | + real :: beta, l_theta |
69 | + |
70 | + if(option_count("/material_phase/scalar_field/prognostic/spatial_discretisation/discontinuous_galerkin") == 0) then |
71 | + ! Nothing to check |
72 | + return |
73 | + end if |
74 | + |
75 | + ewrite(2, *) "Checking DG advection-diffusion options" |
76 | + |
77 | + do i = 0, option_count("/material_phase") - 1 |
78 | + path = "/material_phase[" // int2str(i) // "]" |
79 | + call get_option(trim(path) // "/name", state_name) |
80 | + |
81 | + do j = 0, option_count(trim(path) // "/scalar_field") - 1 |
82 | + path = "/material_phase[" // int2str(i) // "]/scalar_field[" // int2str(j) // "]" |
83 | + call get_option(trim(path) // "/name", field_name) |
84 | + |
85 | + if(field_name /= "Pressure") then |
86 | + |
87 | + path = trim(path) // "/prognostic" |
88 | + |
89 | + if(have_option(trim(path) // "/spatial_discretisation/discontinuous_galerkin").and.& |
90 | + have_option(trim(path) // "/equation[0]")) then |
91 | + |
92 | + if (have_option(trim(path) // "/scalar_field::SinkingVelocity")) then |
93 | + call get_option(trim(complete_field_path(trim(path) // & |
94 | + "/scalar_field::SinkingVelocity"))//"/mesh[0]/name", & |
95 | + mesh_0, stat) |
96 | + if(stat == SPUD_NO_ERROR) then |
97 | + call get_option(trim(complete_field_path("/material_phase[" // int2str(i) // & |
98 | + "]/vector_field::Velocity")) // "/mesh[0]/name", mesh_1) |
99 | + if(trim(mesh_0) /= trim(mesh_1)) then |
100 | + call field_warning(state_name, field_name, & |
101 | + "SinkingVelocity is on a different mesh to the Velocity field this could "//& |
102 | + "cause problems. If using advection_scheme/project_velocity_to_continuous "//& |
103 | + "and a discontinuous Velocity field, then SinkingVelocity must be on a "//& |
104 | + "continuous mesh and hence should not be on the same mesh as the Velocity") |
105 | + end if |
106 | + end if |
107 | + end if |
108 | + |
109 | + end if |
110 | + |
111 | + end if |
112 | + end do |
113 | + end do |
114 | + |
115 | + ewrite(2, *) "Finished checking CG advection-diffusion options" |
116 | + |
117 | + contains |
118 | + |
119 | + subroutine field_warning(state_name, field_name, msg) |
120 | + character(len = *), intent(in) :: state_name |
121 | + character(len = *), intent(in) :: field_name |
122 | + character(len = *), intent(in) :: msg |
123 | + |
124 | + ewrite(0, *) "Warning: For field " // trim(field_name) // " in state " // trim(state_name) |
125 | + ewrite(0, *) trim(msg) |
126 | + |
127 | + end subroutine field_warning |
128 | + |
129 | + subroutine field_error(state_name, field_name, msg) |
130 | + character(len = *), intent(in) :: state_name |
131 | + character(len = *), intent(in) :: field_name |
132 | + character(len = *), intent(in) :: msg |
133 | + |
134 | + ewrite(-1, *) "For field " // trim(field_name) // " in state " // trim(state_name) |
135 | + FLExit(trim(msg)) |
136 | + |
137 | + end subroutine field_error |
138 | + |
139 | + end subroutine advection_diffusion_dg_check_options |
140 | |
141 | end module advection_diffusion_DG |
142 | |
143 | === modified file 'assemble/Advection_Diffusion_FV.F90' |
144 | --- assemble/Advection_Diffusion_FV.F90 2012-08-09 12:50:11 +0000 |
145 | +++ assemble/Advection_Diffusion_FV.F90 2012-11-27 18:25:25 +0000 |
146 | @@ -598,7 +598,7 @@ |
147 | |
148 | subroutine advection_diffusion_fv_check_options |
149 | |
150 | - character(len = FIELD_NAME_LEN) :: field_name, state_name |
151 | + character(len = FIELD_NAME_LEN) :: field_name, mesh_0, mesh_1, state_name |
152 | character(len = OPTION_PATH_LEN) :: path |
153 | integer :: i, j, stat |
154 | real :: beta, l_theta |
155 | @@ -652,7 +652,20 @@ |
156 | call field_warning(state_name, field_name, & |
157 | & "Implicitness factor (theta) should = 1.0 when excluding mass") |
158 | end if |
159 | - |
160 | + |
161 | + if (have_option(trim(path) // "/scalar_field::SinkingVelocity")) then |
162 | + call get_option(trim(complete_field_path(trim(path) // & |
163 | + "/scalar_field::SinkingVelocity"))//"/mesh[0]/name", & |
164 | + mesh_0, stat) |
165 | + if(stat == SPUD_NO_ERROR) then |
166 | + call get_option(trim(complete_field_path("/material_phase[" // int2str(i) // & |
167 | + "]/vector_field::Velocity")) // "/mesh[0]/name", mesh_1) |
168 | + if(trim(mesh_0) /= trim(mesh_1)) then |
169 | + call field_warning(state_name, field_name, & |
170 | + & "SinkingVelocity is on a different mesh to the Velocity field this could cause problems") |
171 | + end if |
172 | + end if |
173 | + end if |
174 | if(have_option(trim(path) // "/spatial_discretisation/finite_volume/advection_terms/exclude_advection_terms")) then |
175 | if(have_option(trim(path) // "/scalar_field::SinkingVelocity")) then |
176 | call field_warning(state_name, field_name, & |
177 | |
178 | === modified file 'assemble/Field_Equations_CV.F90' |
179 | --- assemble/Field_Equations_CV.F90 2012-08-18 21:34:37 +0000 |
180 | +++ assemble/Field_Equations_CV.F90 2012-11-27 18:25:25 +0000 |
181 | @@ -3544,8 +3544,8 @@ |
182 | !************************************************************************ |
183 | ! control volume options checking |
184 | subroutine field_equations_cv_check_options |
185 | - integer :: nmat, nfield, m, f |
186 | - character(len=OPTION_PATH_LEN) :: mat_name, field_name, diff_scheme |
187 | + integer :: nmat, nfield, m, f, stat |
188 | + character(len=OPTION_PATH_LEN) :: mat_name, field_name, mesh_0, mesh_1, diff_scheme |
189 | integer :: weakdirichlet_count |
190 | logical :: cv_disc, mmat_cv_disc, diff, conv_file, subcycle, cv_temp_disc, tolerance, explicit |
191 | real :: theta, p_theta |
192 | @@ -3675,6 +3675,23 @@ |
193 | FLExit("Only pure control volume or coupled_cv discretisations can solve explicitly") |
194 | end if |
195 | end if |
196 | + |
197 | + if(mmat_cv_disc .or. cv_disc) then |
198 | + if (have_option("/material_phase["//int2str(m)//"]/scalar_field["//int2str(f)//& |
199 | + "]/prognostic/scalar_field::SinkingVelocity")) then |
200 | + call get_option(trim(complete_field_path("/material_phase["//& |
201 | + int2str(m)//"]/scalar_field["//int2str(f)//& |
202 | + "]/prognostic/scalar_field::SinkingVelocity"))//"/mesh[0]/name", mesh_0, stat) |
203 | + if(stat == 0) then |
204 | + call get_option(trim(complete_field_path("/material_phase[" // int2str(m) // & |
205 | + "]/vector_field::Velocity")) // "/mesh[0]/name", mesh_1) |
206 | + if(trim(mesh_0) /= trim(mesh_1)) then |
207 | + ewrite(0, *) "SinkingVelocity for "//trim(field_name)//& |
208 | + " is on a different mesh to the Velocity field this could cause problems" |
209 | + end if |
210 | + end if |
211 | + end if |
212 | + end if |
213 | |
214 | end do |
215 | end do |
216 | |
217 | === modified file 'schemas/fluidity_options.rnc' |
218 | --- schemas/fluidity_options.rnc 2012-10-04 16:29:40 +0000 |
219 | +++ schemas/fluidity_options.rnc 2012-11-27 18:25:25 +0000 |
220 | @@ -1904,10 +1904,13 @@ |
221 | ## |
222 | ## As with the sinking velocity, this velocity is in the direction of gravity so if the substance |
223 | ## floats upwards, this field should be negative. |
224 | + ## |
225 | + ## This should be on the same mesh as the associated SinkingVelocity field. |
226 | element scalar_field { |
227 | attribute name { "UnhinderedSinkingVelocity" }, |
228 | attribute rank { "0" }, |
229 | element prescribed { |
230 | + velocity_mesh_choice, |
231 | prescribed_scalar_field |
232 | } |
233 | }?, |
234 | |
235 | === modified file 'schemas/fluidity_options.rng' |
236 | --- schemas/fluidity_options.rng 2012-11-05 14:25:55 +0000 |
237 | +++ schemas/fluidity_options.rng 2012-11-27 18:25:25 +0000 |
238 | @@ -2662,7 +2662,9 @@ |
239 | If the 'SinkingVelocity' is not set to diagnostic, this field will not be used. |
240 | |
241 | As with the sinking velocity, this velocity is in the direction of gravity so if the substance |
242 | -floats upwards, this field should be negative.</a:documentation> |
243 | +floats upwards, this field should be negative. |
244 | + |
245 | +This should be on the same mesh as the associated SinkingVelocity field.</a:documentation> |
246 | <attribute name="name"> |
247 | <value>UnhinderedSinkingVelocity</value> |
248 | </attribute> |
249 | @@ -2670,6 +2672,7 @@ |
250 | <value>0</value> |
251 | </attribute> |
252 | <element name="prescribed"> |
253 | + <ref name="velocity_mesh_choice"/> |
254 | <ref name="prescribed_scalar_field"/> |
255 | </element> |
256 | </element> |
257 | |
258 | === modified file 'schemas/prognostic_field_options.rnc' |
259 | --- schemas/prognostic_field_options.rnc 2012-09-29 11:32:16 +0000 |
260 | +++ schemas/prognostic_field_options.rnc 2012-11-27 18:25:25 +0000 |
261 | @@ -295,14 +295,20 @@ |
262 | ## |
263 | ## This velocity is in the direction of gravity so if the substance |
264 | ## floats or swims upwards, this field should be negative. |
265 | + ## |
266 | + ## This should be on the same mesh as the velocity field unless you are |
267 | + ## using a DG discretisation and projecting the velocity to contiuous, in |
268 | + ## which case it should be on a continuous mesh. |
269 | element scalar_field { |
270 | attribute name { "SinkingVelocity" }, |
271 | attribute rank { "0" }, |
272 | ( |
273 | element prescribed { |
274 | + velocity_mesh_choice, |
275 | prescribed_scalar_field_no_adapt |
276 | }| |
277 | element diagnostic { |
278 | + velocity_mesh_choice, |
279 | ( |
280 | scalar_python_diagnostic_algorithm | |
281 | internal_algorithm |
282 | |
283 | === modified file 'schemas/prognostic_field_options.rng' |
284 | --- schemas/prognostic_field_options.rng 2012-09-29 11:32:16 +0000 |
285 | +++ schemas/prognostic_field_options.rng 2012-11-27 18:25:25 +0000 |
286 | @@ -381,7 +381,11 @@ |
287 | <a:documentation>Velocity at which this substance sinks through the water column. |
288 | |
289 | This velocity is in the direction of gravity so if the substance |
290 | -floats or swims upwards, this field should be negative.</a:documentation> |
291 | +floats or swims upwards, this field should be negative. |
292 | + |
293 | +This should be on the same mesh as the velocity field unless you are |
294 | +using a DG discretisation and projecting the velocity to contiuous, in |
295 | +which case it should be on a continuous mesh.</a:documentation> |
296 | <attribute name="name"> |
297 | <value>SinkingVelocity</value> |
298 | </attribute> |
299 | @@ -390,9 +394,11 @@ |
300 | </attribute> |
301 | <choice> |
302 | <element name="prescribed"> |
303 | + <ref name="velocity_mesh_choice"/> |
304 | <ref name="prescribed_scalar_field_no_adapt"/> |
305 | </element> |
306 | <element name="diagnostic"> |
307 | + <ref name="velocity_mesh_choice"/> |
308 | <choice> |
309 | <ref name="scalar_python_diagnostic_algorithm"/> |
310 | <ref name="internal_algorithm"/> |
311 | |
312 | === modified file 'tests/biology_6_component_parallel/biology_conservation.flml' |
313 | --- tests/biology_6_component_parallel/biology_conservation.flml 2012-03-11 02:25:56 +0000 |
314 | +++ tests/biology_6_component_parallel/biology_conservation.flml 2012-11-27 18:25:25 +0000 |
315 | @@ -517,6 +517,7 @@ |
316 | </scalar_field> |
317 | <scalar_field name="SinkingVelocity" rank="0"> |
318 | <prescribed> |
319 | + <mesh name="VelocityMesh"/> |
320 | <value name="WholeMesh"> |
321 | <python> |
322 | <string_value lines="20" type="code" language="python">def val(X,t): |
323 | |
324 | === modified file 'tests/biology_6_component_parallel/biology_conservation_parallel.flml' |
325 | --- tests/biology_6_component_parallel/biology_conservation_parallel.flml 2012-03-11 02:25:56 +0000 |
326 | +++ tests/biology_6_component_parallel/biology_conservation_parallel.flml 2012-11-27 18:25:25 +0000 |
327 | @@ -517,6 +517,7 @@ |
328 | </scalar_field> |
329 | <scalar_field name="SinkingVelocity" rank="0"> |
330 | <prescribed> |
331 | + <mesh name="VelocityMesh"/> |
332 | <value name="WholeMesh"> |
333 | <python> |
334 | <string_value lines="20" type="code" language="python">def val(X,t): |
335 | |
336 | === modified file 'tests/biology_conservation_adapt/biology_conservation.flml' |
337 | --- tests/biology_conservation_adapt/biology_conservation.flml 2012-03-11 02:25:56 +0000 |
338 | +++ tests/biology_conservation_adapt/biology_conservation.flml 2012-11-27 18:25:25 +0000 |
339 | @@ -558,6 +558,7 @@ |
340 | </scalar_field> |
341 | <scalar_field name="SinkingVelocity" rank="0"> |
342 | <prescribed> |
343 | + <mesh name="VelocityMesh"/> |
344 | <value name="WholeMesh"> |
345 | <python> |
346 | <string_value lines="20" type="code" language="python">def val(X,t): |
347 | |
348 | === modified file 'tests/mms_sediment/MMS_X.flml' |
349 | --- tests/mms_sediment/MMS_X.flml 2012-10-05 13:00:44 +0000 |
350 | +++ tests/mms_sediment/MMS_X.flml 2012-11-27 18:25:25 +0000 |
351 | @@ -1194,6 +1194,7 @@ |
352 | </scalar_field> |
353 | <scalar_field name="SinkingVelocity" rank="0"> |
354 | <diagnostic> |
355 | + <mesh name="VelocityMesh"/> |
356 | <algorithm name="Internal" material_phase_support="multiple"/> |
357 | <output/> |
358 | <stat/> |
359 | @@ -1327,6 +1328,7 @@ |
360 | </scalar_field> |
361 | <scalar_field name="UnhinderedSinkingVelocity" rank="0"> |
362 | <prescribed> |
363 | + <mesh name="VelocityMesh"/> |
364 | <value name="WholeMesh"> |
365 | <constant> |
366 | <real_value rank="0">0.33</real_value> |
367 | @@ -1450,6 +1452,7 @@ |
368 | </scalar_field> |
369 | <scalar_field name="SinkingVelocity" rank="0"> |
370 | <diagnostic> |
371 | + <mesh name="VelocityMesh"/> |
372 | <algorithm name="Internal" material_phase_support="multiple"/> |
373 | <output/> |
374 | <stat/> |
375 | @@ -1583,6 +1586,7 @@ |
376 | </scalar_field> |
377 | <scalar_field name="UnhinderedSinkingVelocity" rank="0"> |
378 | <prescribed> |
379 | + <mesh name="VelocityMesh"/> |
380 | <value name="WholeMesh"> |
381 | <constant> |
382 | <real_value rank="0">0.66</real_value> |
383 | |
384 | === modified file 'tests/sinking_velocity/sinking_velocity.flml' |
385 | --- tests/sinking_velocity/sinking_velocity.flml 2012-03-11 02:25:56 +0000 |
386 | +++ tests/sinking_velocity/sinking_velocity.flml 2012-11-27 18:25:25 +0000 |
387 | @@ -176,6 +176,7 @@ |
388 | </boundary_conditions> |
389 | <scalar_field name="SinkingVelocity" rank="0"> |
390 | <prescribed> |
391 | + <mesh name="VelocityMesh"/> |
392 | <value name="WholeMesh"> |
393 | <python> |
394 | <string_value lines="20" type="code" language="python">def val(X,t): |
395 | |
396 | === modified file 'tests/sinking_velocity_cv/sinking_velocity.flml' |
397 | --- tests/sinking_velocity_cv/sinking_velocity.flml 2012-03-11 02:25:56 +0000 |
398 | +++ tests/sinking_velocity_cv/sinking_velocity.flml 2012-11-27 18:25:25 +0000 |
399 | @@ -178,6 +178,7 @@ |
400 | </boundary_conditions> |
401 | <scalar_field name="SinkingVelocity" rank="0"> |
402 | <prescribed> |
403 | + <mesh name="VelocityMesh"/> |
404 | <value name="WholeMesh"> |
405 | <python> |
406 | <string_value lines="20" type="code" language="python">def val(X,t): |
I realised I hadn't actually pushed the changes to this branch before requesting a review. I have now :)