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

Proposed by Samuel Parkinson
Status: Merged
Merged at revision: 4107
Proposed branch: lp:~fluidity-core/fluidity/sediment
Merge into: lp:fluidity
Diff against target: 458 lines (+183/-78)
7 files modified
schemas/fluidity_options.rnc (+18/-9)
schemas/fluidity_options.rng (+26/-13)
schemas/prognostic_field_options.rnc (+5/-0)
schemas/prognostic_field_options.rng (+7/-0)
sediments/Sediment.F90 (+12/-19)
sediments/Sediment_Diagnostics.F90 (+11/-27)
tests/mms_sediment/MMS_X.flml (+104/-10)
To merge this branch: bzr merge lp:~fluidity-core/fluidity/sediment
Reviewer Review Type Date Requested Status
Jon Hill Approve
Review via email: mp+127255@code.launchpad.net

Description of the change

Changed bedload field to prognostic. I think it is a prognostic field really despite being trivial to solve and this way:
A) it can be checkpointed
B) we can start with an abritrary initial condition

I know you said you didn't like this solution but it seems the simplest option. What do you think?

To post a comment you must log in.
Revision history for this message
Jon Hill (jon-hill) wrote :

Approve, but grudgingly. The checkpointing *should* work, but I agree that an abritrary initial condition is required here.

There might be a better way in the long term.

An options check for a CV field would be useful though. Can this be added?

Revision history for this message
Samuel Parkinson (s-parkinson11) wrote :

Thanks again Jon. Yes I agree that perhaps this isn't the nicest way to do this. I am not totally sure what you mean by an options check for a CV field, can you elaborate at all?

Revision history for this message
Jon Hill (jon-hill) wrote :

The schema says:
No solver settings are required as the sediment model only works
 for p1 CG or DG fields where the mass matrix can be easily inverted.

So if you have a CV field this won't work. You should check which discretisation has been set and error if CV.

lp:~fluidity-core/fluidity/sediment updated
3488. By Samuel Parkinson

fixed error in schema description

Revision history for this message
Samuel Parkinson (s-parkinson11) wrote :

This was actually an error in the description. It will work for CV just not for >P1 discretisations

Revision history for this message
Jon Hill (jon-hill) wrote :

OK, merge it then.

review: Approve
lp:~fluidity-core/fluidity/sediment updated
3489. By Samuel Parkinson

changed mms test schema so that bedload is not calculated

3490. By Samuel Parkinson

merge with trunk

3491. By Samuel Parkinson

merge with trunk

3492. By Samuel Parkinson

removed some multiphase compatibility due to bug in flredecomp

3493. By Samuel Parkinson

merge with trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'schemas/fluidity_options.rnc'
2--- schemas/fluidity_options.rnc 2012-09-25 06:55:02 +0000
3+++ schemas/fluidity_options.rnc 2012-10-24 15:56:21 +0000
4@@ -1829,24 +1829,33 @@
5 ## deposited through the prescribed boundary.
6 ##
7 ## The units are in unit distances as a depth of sediment.
8+ ##
9+ ## - The equation type must be set to SedimentBedload
10+ ##
11+ ## - Spatial discretisation should be as the parent sediment class
12+ ##
13+ ## - Initial conditions can be set as normal
14+ ##
15+ ## - Most other settings are irrelevant
16+ ## - No solver settings are required as the sediment model only works
17+ ## for p1 discretisations where the mass matrix can be easily inverted.
18+ ## - The bedload is always calculated completely explicitly
19+ ## - You cannot apply Source or Absorbtion terms to the bedload
20+ ## - There is no diffusion of the bedload
21 element scalar_field {
22 attribute rank { "0" },
23 attribute name { "Bedload" },
24 ## Field type
25 (
26- element diagnostic {
27+ element prognostic {
28 ## Surface ids over which to calculate the bedload:
29 element surface_ids {
30 integer_vector
31 },
32- diagnostic_scalar_field
33- }|
34- element prescribed {
35- ## Surface ids over which to calculate the bedload deposition:
36- element surface_ids {
37- integer_vector
38- },
39- prescribed_scalar_field
40+ prognostic_scalar_field,
41+ ## Disables calculation of change to bedload due to
42+ ## erosion/deposition (generally only used for mms testing):
43+ element disable_calculation { empty }?
44 }
45 )
46 },
47
48=== modified file 'schemas/fluidity_options.rng'
49--- schemas/fluidity_options.rng 2012-09-25 06:55:02 +0000
50+++ schemas/fluidity_options.rng 2012-10-24 15:56:21 +0000
51@@ -2562,30 +2562,43 @@
52 <a:documentation>Sediment bedload diagnostic which records the sediment
53 deposited through the prescribed boundary.
54
55-The units are in unit distances as a depth of sediment.</a:documentation>
56+The units are in unit distances as a depth of sediment.
57+
58+- The equation type must be set to SedimentBedload
59+
60+- Spatial discretisation should be as the parent sediment class
61+
62+- Initial conditions can be set as normal
63+
64+- Most other settings are irrelevant
65+ - No solver settings are required as the sediment model only works
66+ for p1 CG or DG fields where the mass matrix can be easily inverted.
67+ - The bedload is always calculated completely explicitly
68+ - You cannot apply Source or Absorbtion terms to the bedload
69+ - There is no diffusion of the bedload</a:documentation>
70 <attribute name="rank">
71 <value>0</value>
72 </attribute>
73 <attribute name="name">
74 <value>Bedload</value>
75 </attribute>
76- <choice>
77+ <group>
78 <a:documentation>Field type</a:documentation>
79- <element name="diagnostic">
80+ <element name="prognostic">
81 <element name="surface_ids">
82 <a:documentation>Surface ids over which to calculate the bedload:</a:documentation>
83 <ref name="integer_vector"/>
84 </element>
85- <ref name="diagnostic_scalar_field"/>
86- </element>
87- <element name="prescribed">
88- <element name="surface_ids">
89- <a:documentation>Surface ids over which to calculate the bedload deposition:</a:documentation>
90- <ref name="integer_vector"/>
91- </element>
92- <ref name="prescribed_scalar_field"/>
93- </element>
94- </choice>
95+ <ref name="prognostic_scalar_field"/>
96+ <optional>
97+ <element name="disable_calculation">
98+ <a:documentation>Disables calculation of change to bedload due to
99+erosion/deposition (generally only used for mms testing):</a:documentation>
100+ <empty/>
101+ </element>
102+ </optional>
103+ </element>
104+ </group>
105 </element>
106 <element name="scalar_field">
107 <a:documentation>Sediment bedload diagnostic which records the sediment
108
109=== modified file 'schemas/prognostic_field_options.rnc'
110--- schemas/prognostic_field_options.rnc 2012-09-18 08:03:27 +0000
111+++ schemas/prognostic_field_options.rnc 2012-10-24 15:56:21 +0000
112@@ -2068,6 +2068,11 @@
113 ## Note: Only works for continuous galerkin or control volume discretisations.
114 element equation {
115 attribute name { "KEpsilon" }
116+ }|
117+ ## Equation type for the sediment bedload fields.
118+ ## Note: Only works for P1 discretisations.
119+ element equation {
120+ attribute name { "SedimentBedload" }
121 }
122 )
123 )
124
125=== modified file 'schemas/prognostic_field_options.rng'
126--- schemas/prognostic_field_options.rng 2012-09-18 08:03:27 +0000
127+++ schemas/prognostic_field_options.rng 2012-10-24 15:56:21 +0000
128@@ -2553,6 +2553,13 @@
129 <value>KEpsilon</value>
130 </attribute>
131 </element>
132+ <element name="equation">
133+ <a:documentation>Equation type for the sediment bedload fields.
134+Note: Only works for P1 discretisations.</a:documentation>
135+ <attribute name="name">
136+ <value>SedimentBedload</value>
137+ </attribute>
138+ </element>
139 </choice>
140 </define>
141 <define name="equation_coefficients">
142
143=== modified file 'sediments/Sediment.F90'
144--- sediments/Sediment.F90 2012-09-17 13:35:07 +0000
145+++ sediments/Sediment.F90 2012-10-24 15:56:21 +0000
146@@ -81,7 +81,8 @@
147 integer, intent(out), optional :: stat
148 character(len=FIELD_NAME_LEN) :: name
149
150- call get_option(trim(state%option_path)//'/sediment/scalar_field['//int2str(i_field -&
151+ ! had to remove trim(state%option_path)// as this didn't work with flredecomp
152+ call get_option('/material_phase[0]/sediment/scalar_field['//int2str(i_field -&
153 & 1)//']/name', name)
154 item => extract_scalar_field(state, trim(name), stat)
155
156@@ -95,7 +96,8 @@
157 character(len=FIELD_NAME_LEN), intent(out) :: item
158 integer, intent(out), optional :: stat
159
160- call get_option(trim(state%option_path)//'/sediment/scalar_field['//int2str(i_field -&
161+ ! had to remove trim(state%option_path)// as this didn't work with flredecomp
162+ call get_option('/material_phase[0]/sediment/scalar_field['//int2str(i_field -&
163 & 1)//']/name', item, stat=stat)
164
165 end subroutine get_sediment_field_name
166@@ -109,7 +111,8 @@
167 character(len=FIELD_NAME_LEN), intent(out) :: item
168 integer, intent(out), optional :: stat
169
170- call get_option(trim(state%option_path)//'/sediment/scalar_field['//int2str(i_field -&
171+ ! had to remove trim(state%option_path)// as this didn't work with flredecomp
172+ call get_option('/material_phase[0]/sediment/scalar_field['//int2str(i_field -&
173 & 1)//']/prognostic/'//option, item, stat=stat)
174
175 end subroutine get_sediment_option_string
176@@ -124,7 +127,8 @@
177 integer, intent(out), optional :: stat
178 real, intent(in), optional :: default
179
180- call get_option(trim(state%option_path)//'/sediment/scalar_field['//int2str(i_field -&
181+ ! had to remove trim(state%option_path)// as this didn't work with flredecomp
182+ call get_option('/material_phase[0]/sediment/scalar_field['//int2str(i_field -&
183 & 1)//']/prognostic/'//option, item, stat = stat, default = default)
184
185 end subroutine get_sediment_option_real
186@@ -140,7 +144,8 @@
187
188 character(len=FIELD_NAME_LEN) :: field_name
189
190- call get_option(trim(state%option_path)//'/sediment/scalar_field['//int2str(i_field -&
191+ ! had to remove trim(state%option_path)// as this didn't work with flredecomp
192+ call get_option('/material_phase[0]/sediment/scalar_field['//int2str(i_field -&
193 & 1)//']/name', field_name)
194 item => extract_scalar_field(state, trim(field_name)//option, stat)
195
196@@ -499,7 +504,6 @@
197
198 character(len=FIELD_NAME_LEN) :: field_mesh, sediment_mesh, bc_type
199 character(len=OPTION_PATH_LEN) :: field_option_path
200- character(len=10) :: type
201 integer :: i_field, i_bc, i_bc_surf, i_bedload_surf,&
202 & n_sediment_fields, nbcs
203 integer, dimension(2) :: bc_surface_id_count, bedload_surface_id_count
204@@ -536,10 +540,6 @@
205 ! Loop over boundary conditions for field
206 boundary_conditions: do i_bc=0, nbcs-1
207
208- ! get name and type of boundary condition
209- call get_option(trim(field_option_path)//'/boundary_conditions['//int2str(i_bc)//&
210- &']/type[0]/name', bc_type)
211-
212 ! check whether this is a reentrainment boundary
213 if (.not. (trim(bc_type) .eq. "sediment_reentrainment")) then
214 cycle boundary_conditions
215@@ -549,22 +549,15 @@
216 if (.not.(have_option('/material_phase[0]/vector_field::BedShearStress'))) then
217 FLExit("Reentrainment boundary condition requires a BedShearStress field")
218 end if
219-
220- ! warn if bedload field is prescribed
221- type = 'diagnostic'
222- if (have_option(trim(field_option_path)//'/scalar_field::Bedload/prescribed')) then
223- ewrite(0,*) 'WARNING: Bedload field is prescribed'
224- type = 'prescribed'
225- end if
226
227 ! check boundary id's are the same for re-entrainment and bedload
228
229 ! get bedload surface ids
230 bedload_surface_id_count=option_shape(trim(field_option_path)// &
231- '/scalar_field::Bedload/'//type//'/surface_ids')
232+ '/scalar_field::Bedload/prognostic/surface_ids')
233 allocate(bedload_surface_ids(bedload_surface_id_count(1)))
234 call get_option(trim(field_option_path)// &
235- '/scalar_field::Bedload/'//type//'/surface_ids', bedload_surface_ids)
236+ '/scalar_field::Bedload/prognostic/surface_ids', bedload_surface_ids)
237
238 ! get reentrainment surface ids
239 bc_surface_id_count=option_shape(trim(field_option_path)//'/boundary_conditions['&
240
241=== modified file 'sediments/Sediment_Diagnostics.F90'
242--- sediments/Sediment_Diagnostics.F90 2012-10-22 19:47:09 +0000
243+++ sediments/Sediment_Diagnostics.F90 2012-10-24 15:56:21 +0000
244@@ -173,19 +173,11 @@
245 end if
246
247 ! obtain surface ids over which to record deposition
248- if (have_option(trim(bedload_field%option_path)//"/diagnostic")) then
249- surface_id_count=option_shape(trim(bedload_field%option_path)//&
250- &"/diagnostic/surface_ids")
251- allocate(surface_ids(surface_id_count(1)))
252- call get_option(trim(bedload_field%option_path)//"/diagnostic/surface_ids", &
253- & surface_ids)
254- else
255- surface_id_count=option_shape(trim(bedload_field%option_path)//&
256- &"/prescribed/surface_ids")
257- allocate(surface_ids(surface_id_count(1)))
258- call get_option(trim(bedload_field%option_path)//"/prescribed/surface_ids", &
259- & surface_ids)
260- end if
261+ surface_id_count=option_shape(trim(bedload_field%option_path)//&
262+ &"/prognostic/surface_ids")
263+ allocate(surface_ids(surface_id_count(1)))
264+ call get_option(trim(bedload_field%option_path)//"/prognostic/surface_ids", &
265+ & surface_ids)
266
267 ! loop through elements in surface field
268 elements: do ele=1,element_count(deposited_sediment(i_field))
269@@ -243,7 +235,7 @@
270 call scale(diagnostic_field, 1./dt)
271 end if
272
273- if (.not. have_option(trim(bedload_field%option_path)//'/prescribed')) then
274+ if (.not. have_option(trim(bedload_field%option_path)//'/prognostic/disable_calculation')) then
275 ! Add on sediment falling in and subtract sediment coming out
276 do i_node = 1, node_count(surface_mesh(i_field))
277 ! add deposited sediment
278@@ -687,19 +679,11 @@
279 end if
280
281 ! obtain sediment bedload surface ids
282- if (have_option(trim(bedload%option_path)//"/diagnostic")) then
283- surface_id_count=option_shape(trim(bedload%option_path)//&
284- &"/diagnostic/surface_ids")
285- allocate(surface_ids(surface_id_count(1)))
286- call get_option(trim(bedload%option_path)//"/diagnostic/surface_ids", &
287- & surface_ids)
288- else
289- surface_id_count=option_shape(trim(bedload%option_path)//&
290- &"/prescribed/surface_ids")
291- allocate(surface_ids(surface_id_count(1)))
292- call get_option(trim(bedload%option_path)//"/prescribed/surface_ids", &
293- & surface_ids)
294- end if
295+ surface_id_count=option_shape(trim(bedload%option_path)//&
296+ &"/prognostic/surface_ids")
297+ allocate(surface_ids(surface_id_count(1)))
298+ call get_option(trim(bedload%option_path)//"/prognostic/surface_ids", &
299+ & surface_ids)
300
301 ! loop through elements in surface field
302 elements: do i_ele=1, element_count(volume_fraction_surface)
303
304=== modified file 'tests/mms_sediment/MMS_X.flml'
305--- tests/mms_sediment/MMS_X.flml 2012-08-30 10:34:23 +0000
306+++ tests/mms_sediment/MMS_X.flml 2012-10-24 15:56:21 +0000
307@@ -1215,23 +1215,70 @@
308 </steady_state>
309 <consistent_interpolation/>
310 <scalar_field name="Bedload" rank="0">
311- <prescribed>
312+ <prognostic>
313 <surface_ids>
314 <integer_value shape="1" rank="1">2</integer_value>
315 </surface_ids>
316- <value name="WholeMesh">
317+ <equation name="AdvectionDiffusion"/>
318+ <spatial_discretisation>
319+ <continuous_galerkin>
320+ <stabilisation>
321+ <no_stabilisation/>
322+ </stabilisation>
323+ <advection_terms/>
324+ <mass_terms/>
325+ </continuous_galerkin>
326+ <conservative_advection>
327+ <real_value rank="0">0.0</real_value>
328+ </conservative_advection>
329+ </spatial_discretisation>
330+ <temporal_discretisation>
331+ <theta>
332+ <real_value rank="0">0.5</real_value>
333+ </theta>
334+ </temporal_discretisation>
335+ <solver>
336+ <iterative_method name="gmres">
337+ <restart>
338+ <integer_value rank="0">30</integer_value>
339+ </restart>
340+ </iterative_method>
341+ <preconditioner name="sor"/>
342+ <relative_error>
343+ <real_value rank="0">1e-6</real_value>
344+ </relative_error>
345+ <absolute_error>
346+ <real_value rank="0">1e-15</real_value>
347+ </absolute_error>
348+ <max_iterations>
349+ <integer_value rank="0">1000</integer_value>
350+ </max_iterations>
351+ <never_ignore_solver_failures/>
352+ <diagnostics>
353+ <monitors/>
354+ </diagnostics>
355+ </solver>
356+ <initial_condition name="WholeMesh">
357 <python>
358 <string_value lines="20" type="code" language="python">def val(X,t):
359 import mms_sediment_tools as k
360 return k.s1_d(X)</string_value>
361 </python>
362- </value>
363+ </initial_condition>
364 <output/>
365 <stat/>
366+ <convergence>
367+ <include_in_convergence/>
368+ </convergence>
369 <detectors>
370- <exclude_from_detectors/>
371+ <include_in_detectors/>
372 </detectors>
373- </prescribed>
374+ <steady_state>
375+ <include_in_steady_state/>
376+ </steady_state>
377+ <consistent_interpolation/>
378+ <disable_calculation/>
379+ </prognostic>
380 </scalar_field>
381 <scalar_field name="BedloadVolumeFraction" rank="0">
382 <diagnostic>
383@@ -1424,23 +1471,70 @@
384 </steady_state>
385 <consistent_interpolation/>
386 <scalar_field name="Bedload" rank="0">
387- <prescribed>
388+ <prognostic>
389 <surface_ids>
390 <integer_value shape="1" rank="1">2</integer_value>
391 </surface_ids>
392- <value name="WholeMesh">
393+ <equation name="AdvectionDiffusion"/>
394+ <spatial_discretisation>
395+ <continuous_galerkin>
396+ <stabilisation>
397+ <no_stabilisation/>
398+ </stabilisation>
399+ <advection_terms/>
400+ <mass_terms/>
401+ </continuous_galerkin>
402+ <conservative_advection>
403+ <real_value rank="0">0.0</real_value>
404+ </conservative_advection>
405+ </spatial_discretisation>
406+ <temporal_discretisation>
407+ <theta>
408+ <real_value rank="0">0.5</real_value>
409+ </theta>
410+ </temporal_discretisation>
411+ <solver>
412+ <iterative_method name="gmres">
413+ <restart>
414+ <integer_value rank="0">30</integer_value>
415+ </restart>
416+ </iterative_method>
417+ <preconditioner name="sor"/>
418+ <relative_error>
419+ <real_value rank="0">1e-6</real_value>
420+ </relative_error>
421+ <absolute_error>
422+ <real_value rank="0">1e-15</real_value>
423+ </absolute_error>
424+ <max_iterations>
425+ <integer_value rank="0">1000</integer_value>
426+ </max_iterations>
427+ <never_ignore_solver_failures/>
428+ <diagnostics>
429+ <monitors/>
430+ </diagnostics>
431+ </solver>
432+ <initial_condition name="WholeMesh">
433 <python>
434 <string_value lines="20" type="code" language="python">def val(X,t):
435 import mms_sediment_tools as k
436 return k.s2_d(X)</string_value>
437 </python>
438- </value>
439+ </initial_condition>
440 <output/>
441 <stat/>
442+ <convergence>
443+ <include_in_convergence/>
444+ </convergence>
445 <detectors>
446- <exclude_from_detectors/>
447+ <include_in_detectors/>
448 </detectors>
449- </prescribed>
450+ <steady_state>
451+ <include_in_steady_state/>
452+ </steady_state>
453+ <consistent_interpolation/>
454+ <disable_calculation/>
455+ </prognostic>
456 </scalar_field>
457 <scalar_field name="BedloadVolumeFraction" rank="0">
458 <diagnostic>