forked from FluidityProject/fluidity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguring_fluidity.tex
2822 lines (2365 loc) · 170 KB
/
configuring_fluidity.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\chapter{Configuring \fluidity}\label{chap:configuration}
\section{Overview}
A \fluidity\ simulation is configured by creating a \fluidity\ options (or flml) file using
Diamond, which is the Graphical User Interface (GUI).
The left-hand pane of Diamond allows users to browse the
\emph{options tree}, while the right-hand pane provides brief documentation
about the option and is where users enter input data.
This chapter aims to provide a detailed description of all the options in
the tree. From section~\ref{sec:OptionsTree} onwards, \fluidity\ options are
described in the order in which they appear in Diamond. Prior to this are
some important general notes about the different types of options and, in
particular, how to work with fields in \fluidity.
\section{Options syntax}
\index{options!syntax}
\fluidity\ options files, or flml files, are XML files whose grammar is defined by the
fluidity options schema \verb+fluidity_options.rng+. XML files have a
tree-like structure of elements containing other elements. This structure is
reflected in the left hand pane of Diamond, the GUI which
is used to write flml files.
The flml file can also be edited with a standard editor and the options written
in text and in code using the Spud library on which the \fluidity\ options
system is based. A location in the options tree can be written as a path,
much like the path of a file on disk. So, for example, the option
controlling the physical dimension of the problem domain is written as
\option{/geometry/dimension}. This should be read as the \option{dimension}
option which is found under \option{geometry} which is in turn at the top
level of the options tree. In Diamond, and in the flml file, the absolute
top level element is always \option{fluidity\_options} but this element is
always discarded from paths. Figure \ref{fig:geometry_dimension}\ shows a
Diamond screen shot open at the \option{/geometry/dimension} option. Further
documentation of the Spud system is available in \citet{ham2009}\ and from
\href{http://amcg.ese.ic.ac.uk/spud}{the Spud website}.
\begin{figure}[ht]
\centering
\fig[width=.7\textwidth]{geometry_dimension}
\caption{A Diamond screenshot showing the \option{/geometry/dimension}
option. Note that the option path is displayed at the bottom of the
diamond window}
\label{fig:geometry_dimension}
\end{figure}
\subsection{Allowed Characters}
Only certain characters are recognised by the options dictionary, which contains the flml input once it is read into fluidity. Therefore only the following letters are allowed in any input field:
\begin{verbatim}
/_:[]1234567890qwertyuioplkjhgfdsazxcvbnmMNBVCXZASDFGHJKLPOIUYTREWQ
\end{verbatim}
Comment boxes may contain any characters.
\subsection{Named options}
\index{options!names}
Some options in the tree, such as fields and meshes, have name
attributes. The name attribute is represented in the flml file with a double colon so that,
for example, the coordinate mesh has options path\onlypdf\linebreak
\option{/geometry/mesh::CoordinateMesh}. Note that this differs from the
convention in the Diamond interface in which name attributes are given in brackets. Figure
\ref{fig:mesh_name}
\begin{figure}[ht]
\centering
\fig[width=.7\textwidth]{mesh_name}
\caption{A Diamond screenshot showing the \option{/geometry/mesh::Coordinate}
option. Note that the name is shown in brackets in the main Diamond
window but after double colons in the path in the bottom bar.}
\label{fig:mesh_name}
\end{figure}
Names of objects (fields, material phases, meshes, etc.) should be camel cased (MyOwnField) and not contain spaces or underscores. Furthermore, the characters \verb+/:[]+ are prohibited as these have special meanings in the options dictionary inside \fluidity.
\section{The options tree}\label{sec:OptionsTree}
The top level of the options tree contains the following compulsory elements:
\begin{itemize}
\item Simulation Name
\item Problem Type
\item Geometry
\item IO
\item Timestepping
\item Physical Parameters
\item Material/Phase
\end{itemize}
The first six of these are described here.
\subsection{Simulation Name}
The simulation name is the base name for all output files. For example if you set the simulation name to foo then your statistics output file will be called foo.stat
\subsection{Problem Type}
Setting problem type gives fluidity a hint as to what sort of simulation you are conducting and therefore what combinations of options are likely to be valid. If you do not know which category applies to your problem, choose "fluids".
\subsection{Geometry}
This element contains all the options required to specify the geometry of the mesh and the accuracy of the finite element discretisation.
\subsubsection{Dimension}
\index{dimension}
The dimension of the domain of your problem. This can be 1, 2 or 3.
Be careful, once you set the dimension you can't change it again!
This is necessary to ensure that all vectors and tensors are of the correct
dimension.
\subsubsection{Meshes} \label{sec:mesh_configuration}
Meshes are the finite element spaces on which your problem is solved. Meshes
are either read from file or are derived from other meshes. Mesh options are
described in detail in section~\ref{sec:Mesh}. There is only one required
mesh: the CoordinateMesh. Some settings or fields have
specific mesh requirements. These are discussed under the appropriate
options.
\subsubsection{Quadrature}
\index{quadrature!options}
\fluidity\ uses numerical quadrature to integrate the equations over each
element. There is a performance/accuracy trade off in quadrature: the more
quadrature points are employed, the more accurate the integrals are but
the more expensive the assembly operation is. Quadrature rules in \fluidity\ are categorised by the degree of the polynomial which they will integrate
exactly. The higher the degree of the quadrature rule, the more quadrature
points will be employed. As a general rule of thumb, the quadrature
degree employed should be at least $\max(2n_{\vec{u}+1},2n_p)$ where
$n_{\vec{u}}$ is the degree of the elements employed for velocity and $n_p$
is the degree of the elements employed for pressure. This means that degree
4 quadrature is sufficient for most of the fluidity configurations currently
in use.
The quadrature degree is specified by setting \option{/geometry/quadrature/degree}.
\subsubsection{Spherical Earth}
\label{sec:spherical_earth}
\index{spherical earth}
\index{mesh!superparametric}
Enabling \option{/geometry/spherical\_earth} informs \fluidity that your
simulation is being carried out in an Earth like geometry. This means that the mesh domain is assumed to approximate (a part of) an
N-sphere (sphere in three dimensions, circle in two dimensions). The domain is still described in
general $x,y,z$ coordinates (no spherical/cylindrical coordinates)
and the centre of the N-sphere must coincide with the origin. Turning on this option has a number of effects.
In combination with extrusion options (see section \ref{sec:extruded_meshes}),
specifying a \option{spherical\_earth} will extrude radially from the top surface of the
domain towards the origin. Generally, the sphere is only extruded to a certain
depth, leaving a void around the origin. The two main applications of this
option are large-scale ocean simulations on the sphere, and geodynamic simulations of the
Earth's mantle.
When using this option the gravity direction should be defined manually in the radial
direction (pointing to the origin) using python
(\option{/physical\_parameters/gravity/vector\_field::GravityDirection/prescribed/value::WholeMesh/python}). If used in conjunction with the
\option{buoyancy/radial\_gravity\_direction\_at\_gauss\_points} option underneath the \option{spatial\_discretisation} option for
Velocity then gravity will be automatically defined to be radial at the gauss points (rather than the nodes) in the buoyancy term
(ignoring whatever gravity direction you have specified manually in the buoyancy term only). Specifying the gravity direction at the
gauss points in the buoyancy term helps eliminate spurious interpolation errors and non-physical imbalance in spherical simulations (see
\ref{sec:configuring_fluidity!spatial_discretisation!buoyancy}).
For ocean simulations, the option has implications for various options and terms such as wind forcing (see section \ref{sec:wind_forcing}), the calculation of buoyancy and the `direction' of absorptions (see \ref{sec:Source}).
If this option is checked, wind forcing and \eg momentum forcing from bulk formulae (see \ref{sec:bulk_formulae}) will automatically be rotated and applied in the direction tangential to the Earth's surface. It will also result in absorption terms set through the options tree being rotated and applied in the longitudinal, latitudinal and radial directions respectively. Note however that the viscosity and diffusion operators are currently not rotated automatically and thus the user must carry such rotations out themselves. An example in which the viscosity is rotated is giving in section \ref{sec:tides_in_the_med}.
Two options, \option{spherical\_earth/superparametric\_mapping} and
\option{spherical\_earth/analytical\_mapping},
are available to improve the approximation of the spherical domain
by the mesh, in particular for coarse meshes.
The general idea is that instead of using straight, linearly
interpolated tets and triangles, the elements are bent to better fit the curved
geometry (see section \ref{sec:coordinate_mesh_and_superparametric} for the
exact formula). The mesh vertices are kept in place, but all points in the interior of
an element are moved a little in the radial direction,
such that the radial coordinate varies linearly
between the vertices. For example, in the case of a triangle with all three
points on a perfect sphere, this means the entire triangle is now curved
to be exactly on that sphere.
Using the \option{superparametric\_mapping} option
the curved elements are approximated by a higher order polynomial by using a
higher order \option{CoordinateMesh}. To use this option, you therefore need a
seperate \option{CoordinateMesh} that is derived from the usual continuous P1
mesh (typically called \option{BaseMesh}). For example, when combining this with
extrusion in 3D, one needs a 2D input mesh \option{InputMesh}, an extruded
\option{BaseMesh} with extrusion options, and a \option{CoordinateMesh} derived
from this that has set a higher order \option{mesh\_shape/polynomial\_degree}.
Other meshes (function spaces) used in the discretisation, e.g. a \PoDG or a $P2$ mesh, are
also derived from the \option{BaseMesh}.
For the \option{analytical\_mapping} option a higher order
\option{CoordinateMesh} is not necessary; the bending of the element is done
directly at the gauss points using an analytical expression. Thus the
conformance of a bended element with a perfect sphere is only limited by the
quadrature degree. Nonetheless, for calculations that are done node-wise, in
particular when setting a higher order prescribed field from a python
function, it may still make sense to combine \option{superparametric\_mapping}
and \option{analytical\_mapping}, so that the coordinates of the bended
elements are available in the nodes of the higher order mesh.
\subsubsection{Ocean Boundaries}\label{sec:ocean_boundaries}
\index{boundary conditions!ocean}
These options are required if you are running an ocean simulation with a
free surface or with various other ocean options which require the code to
know where the ocean surface and bed lie.
\option{/geometry/ocean\_boundaries/top\_surface\_ids} and
\onlypdf\linebreak\option{/geometry/ocean\_boundaries/bottom\_surface\_ids}
are lists of boundary tags from your input mesh which lie on the ocean
surface and bed respectively.
It is not usually necessary to change the settings for either of the scalar fields under this option.
\subsection{IO}
These options control the frequency and form of model outputs.
\subsubsection{Dump format}
\index{vtk}
The file format used to output fields to disk. At this stage, vtu is the
only allowed format.
\subsubsection{Dump period}
This is the interval between the state fields being output to disk. You should usually start by setting this to a rather low value (possibly as short as your timestep) for testing and then increase it for production runs once you know how your configuration works. The value can be specified as either a constant or python function.
It is possible to swap \option{/io/dump\_period} for \option{/io/dump\_period\_in\_timesteps} to specify that you wish to have a dump every fixed number of timesteps.
\subsubsection{Output mesh}
\index{mesh!output}
All fields will be interpolated onto the same mesh for output. Usually the
CoordinateMesh is the right choice. If you have fields that are of
higher order than the selected output mesh you will lose
accuracy. Interpolating all fields to a higher order mesh for output may give
very large dump files however. If any
of the fields in the output is discontinuous, the mesh in the output file
will be a discontinuous version of the mesh selected here.
\subsubsection{Disable dump at start}
A dump is normally performed at the start of the simulation. This options disables that.
\subsubsection{Disable dump at end}
A dump is normally performed at the end of the simulation. This options disables that.
\subsubsection{CPU dump period}
This outputs dumps at specified CPU times. Not recommended.
\subsubsection{Wall time dump period}
Outputs at specified walltime (real time) periods. Not recommended.
\subsubsection{Max dump file count}
Limits the number of dumps by overwriting the previous dumps after the number specified here.
\subsubsection{Convergence}
You can check certain fields for convergence during nonlinear iterations. To do this switch on \option{/timestepping/nonlinear\_iterations} and \option{/timestepping/nonlinear\_iterations/tolerance} and switch on the convergence option under the fields that you want to check for convergence.
It is possible to enable the creation of a convergence file, giving details of the convergence of each field over the global nonlinear iteration loop. The .convergence file is in the same format as the .stat file. In order to do this, switch on
\option{/io/convergence} and \option{/io/convergence/convergence\_file}. You still need the options in the above paragraph.
\subsubsection{Checkpointing}
\index{checkpointing}
\label{sec:configuring_fluidity_checkpointing}
Enables checkpointing, which saves sufficient information (including a new flml options file) to restart a simulation, i.e., to continue the simulation after it stopped. You must specify how often to checkpoint in terms of the number of dumps. There
are also options to checkpoint at the start of the simulation and at the
end. This latter is useful when running on batch systems that have a time
limit.
Up to five sets of files are created when checkpointing:
\begin{enumerate}
\item Mesh files - The from\_file meshes, in Gmsh format. Surface IDs
and (if present) region IDs are written to the mesh files, and adaptivity
is supported. In parallel a Gmsh mesh is written for each process.
\item Halo files (in parallel) - Halo information for each process.
\item Field files - A vtu is written for each mesh with prognostic fields in
each state and (in parallel) for each process.
\item Checkpointed option file - A new FLML file, with the from\_file mesh
set to read the checkpoint mesh files and the prognostic fields set
to initialise from the checkpoint field files.
\item Checkpointed detector files - Two files related to checkpointing of
detectors are created.
\end{enumerate}
The first checkpointed detector file has the extension .groups and contains
a header with the names of the groups of detectors in the order they were
read in the simulation. It also contains information about the number of
detectors in each group. This is to guarantee that when restarting from a
checkpoint, the detectors will be read in the same order and consequently
will be saved in that same order into the output detector file for
consistency. The second checkpointed detector file has the extension
.positions.dat and contains the last position of the detectors at the time
of checkpointing, in binary format.
No checkpointed detector files will be created if only static detectors are
defined in Diamond, since the position of these detectors remains always the
same. This is mainly used when Lagrangian detectors are set that are
advected by the flow and hence, their position changes as the simulation
proceeds.
At the same time as creating the two files related to checkpointing of
detectors, the detector options in the options tree or Diamond are updated
so that in the new flml file the detectors are set to initialise from the
checkpoint detectors files \\
(\option{/io/detectors/detector\_array/from\_checkpoint\_file} or \\
\option{/io/detectors/lagrangian\_detector/from\_checkpoint\_file}). For
simplicity, the static detectors are also read from the checkpoint file that
contains the position of all detectors, static and Lagrangian
(\option{/io/detectors/static\_detector/from\_checkpoint\_file}).
Checkpoint filenames all end with [dump
no.]\_checkpoint[-[process]].[extension], where the process number is added
to the mesh, halo and field files in parallel. The checkpoint detectors
filenames contain \_det after [dump no.]\_checkpoint.
A script is available at \lstinline[language = bash]+scripts/rename_checkpoint.py+
that can be used to easily rename these filenames and there contents to continue
the naming convention of the original run. For more information see section
\ref{sec:rename_checkpoint}.
\index{checkpointing!restarting}
To restart from a checkpoint, specify the checkpointed FLML file as input.
\subsubsection{Stat}
\index{stat file}
Contains additional options for handling stat files, for example outputting
a stat file at the start (timestep zero) and outputting stat data before and
after an adapt.
There are further options under individual fields, for example to exclude data from the stat file.
\subsubsection{Detectors}
\index{detectors!options}\label{detectors_options}
Detectors are set in Diamond with the \option{/io/detectors} option. The detectors can be set to be static detectors, \option{/io/detectors/static\_detector}, Lagrangian detectors \\
\option{/io/detectors/lagrangian\_detector} or an array of detectors, \\
\option{/io/detectors/detector\_array}.
When choosing to set detectors using an array, the total number of detectors
needs to be specified in
\option{/io/detectors/detector\_array/number\_of\_detectors} and the type of
detectors is indicated with the option
\option{/io/detectors/detector\_array/static} or \\
\option{/io/detectors/detector\_array/lagrangian}.
\index{Python!detector positions}
Examples \ref{examp:python_function_detectors} and
\ref{examp:python_function_detectors_1} illustrate the use of a Python
function to set an array of detectors, that can be static or Lagrangian.
\begin{example}
\begin{lstlisting}[language=Python]
def val(t):
import math
ret=[]
for i in range(100):
ret.append([-2.5,(-0.495 + i * 0.01)])
return ret
\end{lstlisting}
\caption{A Python function setting 100 detectors. This
example illustrates that it is possible to use a Python function to set an array of detectors.}
\label{examp:python_function_detectors}
\end{example}
\begin{example}
\begin{lstlisting}[language=Python]
def val(t):
import math
ret=[]
for k in range(100,2000,100):
for j in range(7000,25100,100):
for i in range(7000,25100,100):
ret.append([i,j,k])
return ret
\end{lstlisting}
\caption{A Python function setting 622459 detectors uniformly distributed
at intervals of 100 m in the three orthogonal directions. They cover 19 z planes, from z=100 to z=1900, with 32761 detectors in each plane, from
x=7000 to x=25000 and y=7000 to y=25000.}
\label{examp:python_function_detectors_1}
\end{example}
If one or more Lagrangian detectors are selected the option \option{/lagrangian\_timestepping} must be set to define detector movement.
The user can define the order of the Runge-Kutta method to be used by defining the Butcher tableau and timestepping weights under \option{/explicit\_runge\_kutta\_guided\_search}.
For convenience the first- and fourth-order Runge-Kutta method (\option{/forward\_euler\_guided\_search} and \option{/rk4\_guided\_search}) are available as pre-defined options.
See section \ref{sec:lagrangian_trajectories} for more information on Lagrangian detector advection.
The output of the detectors is an ascii file called
\option{name\_of\_simulation.detectors} where the name of the simulation has
been indicated in \option{/simulation\_name}. If binary output
\option{/io/detectors/} \option{binary\_output} option is enabled then the file containing the detector data is called
\option{name\_of\_simulation.detectors.dat} and in this case \option{name\_of\_simulation.detectors} contains only the header with the
information about the detectors (name of each detector, in which column the
position of each detector is stored, etc.).
Note that the algorithm used to determine the element containing a detector (of
any kind) assumes that the detector is known to be within the simulation domain.
The option \option{/fail\_outside\_domain} will cause Fluidity to fail if a detector
is found to be outside the domain boundaries.
This option should be the default choice when creating new simulations.
If detectors are intended to temporarily reside outside of the domain the option
\option{/write\_nan\_outside\_domain} will cause Fluidity to write "NaN" values
to the detector output in this case.
If \option{/move\_with\_mesh} is selected with any mesh movement algorithm the
detectors will move according to the mesh displacement.
That is to say that a static detector will remain static with reference to the
domain boundaries rather than its true physical coordinates.
\subsubsection{Log output}
Enables additional output to the screen or log file. Usually controlled
using the -v option when running \fluidity. However, a useful option for
logging memory diagnostics can be switched on here.
\subsection{Timestepping}
\index{time!step}
These options control the start and end time of the simulation as well as options regarding timestep size.
\subsubsection{Current time}
This is the model time at the start of the simulation. In most cases this is likely to be zero. It can be non-zero when continuing a simulation from a checkpoint.
\textbf{Time units}
If your simulation contains real data, for example when using
\option{ocean\_forcing}, \fluidity\ must know how to map simulated time onto
real time. This option allows the user to specify the ``real-world'' start
time of the simulation. The input is a string of the form:
\begin{lstlisting}[language=bash]
seconds since 1992-10-8 15:15:42.5 -6:00
\end{lstlisting}
which indicates seconds since October 8th, 1992 at 3 hours, 15 minutes and
42.5 seconds in the afternoon in the time zone which is six hours to the
west of Coordinated Universal Time (i.e. Mountain Daylight Time). The time
zone specification can also be written without a colon using one or
two-digits (indicating hours) or three or four digits (indicating hours and
minutes).
\subsubsection{Timestep}
The simulation timestep. If adaptive timestepping is not used this will
define the size of the timestep used throughout the simulation. If adaptive
timestepping is used this option defines only the size of the first
timestep.
\subsubsection{Finish time}
The model time at which the simulation should halt. Note that the simulation
may overrun slightly due to roundoff in calculating the current time or if
the timestep does not divide the simulation time exactly.
\subsubsection{Final timestep}
Rather than specify a finish time, the final timestep may be specified. This is the number of timestep after which the simulation will stop.
\subsubsection{CPU time limit}
This option will stop the simulation after the CPU time reaches this limit.
This option is useful when coupled with
\option{/io/checkpointing/checkpoint\_at\_end} enabled.
\subsubsection{Wall time limit}
This option will stop the simulation after the wall time (real time) reaches
this limit. This option is useful when coupled with
\option{/io/checkpointing/checkpoint\_at\_end} enabled.
\subsubsection{Nonlinear iterations}
Nonlinear quantities in the equations are represented by their last known
values. It may be necessary to solve the equations more than once to produce
better approximations to those last known values for reasons of accuracy or
stability. Unless there are reasons for doing this, set this value to 2.
\subsubsection{Adaptive timestep}
\label{section:config_adaptive_timestep}
This option allows the timestep, $\Delta T$, to vary throughout the run, depending on the
Courant-–Friedrichs-–Lewy (CFL) number. There are several sub-options here. The
\option{\ldots/requested\_cfl} is the desired upper limit of the CFL. A value of 5-10 is usual
here. \fluidity\ will increase the timestep if the CFL number is less than this value and decrease
it if the CFL is greater than this. The \option{\ldots/minimum\_timestep} and
\option{\ldots/maximim\_timestep} options limit the timestep. The option
\option{\ldots/increase\_tolerance} determines
the rate of growth in the timestep. A value of 1.5 indicates the timestep can grow by
at most, 50\%. There is no limit on the rate of decrease. Note that if a timestep fails
to meet the CFL limit imposed it is not re-run, but the timestep is decreased for the next
iteration. Finally, a desired $\Delta T$ can be calculated at the first time iteration by
switching on the option: \option{\ldots/at\_first\_timestep}
\subsubsection{Steady state}
It is possible to run \fluidity until it converges to a steady state; this is sometimes useful for initialising a problem. In order to do this, switch on \option{/timestepping/steady\_state} and set a tolerance.
\subsection{Physical parameters}
These options control global physical quantities.
\subsubsection{Gravity}\label{sec:Gravity}
\index{gravity}
The importance of buoyancy is discussed in section \ref{sec:buoyancy_hydrostacy}. This
requires a gravitational field to be set and involves both its magnitude
(\eg \mss[9.8]) and a vector field specifying the direction in which gravity
points. For a 3D simulation in a flat domain with gravity pointing in the
negative z direction you would set \verb+value(WholeMesh)+ for this field to
the vector (0.0, 0.0, -1.0). For a gravitational force with spatially
varying direction, e.g. on the Earth considered in Cartesian space with
gravity pointing in the negative radial direction you could use a Python
function of the form
\begin{example}
\begin{lstlisting}[language=Python]
def val(X, t):
from math import sqrt
radius=sqrt(X[0]**2+X[1]**2+X[2]**2)
rx=X[0]/radius
ry=X[1]/radius
rz=X[2]/radius
return (-rx, -ry, -rz)
\end{lstlisting}
\caption{A Python function returning a vector pointing in the negative radial direction.}
\end{example}
\subsubsection{Coriolis}
\index{Coriolis!options}
\fluidity\ supports the specification of the Coriolis term (section
\ref{sec:coriolis}) in a number of different ways. The following options
are available:
\begin{enumerate}
\item \option{f\_plane} -- a single float is prescribed which corresponds to
$f_0$ in \eqref{eq:f-plane};
\item \option{beta\_plane} -- here two floats are prescribed, $f_0$ and
$\beta$ in \eqref{eq:beta-plane};
\item \option{sine\_of\_latitude} -- here the Coriolis parameter from
\eqref{eq:coriolis_parameters} is used and $\Omega$,
$R_{\textrm{earth}}$ and $\textrm{latitude}_0$ are defined as floats with
latitude calculated via
$\phi = y/R_{earth} + \textrm{latitude}_0$;
\item \option{on\_sphere} -- here $\Omega$ the rotation vector pointing in the
inertial frame $z$ direction \eqref{eq:on_sphere_rotation} is set,
note this is the direction pointing from the centre of mass to the North
Pole on the Earth;
\item \option{python\_f\_plane} -- time dependent python input
prescribing a single float which corresponds to
$f_0$ in \eqref{eq:f-plane} - see example \ref{ex:python_f_plane}.
\end{enumerate}
Recall that there is a factor $2$ relationship between $f$ and $\Omega$
\eqref{eq:f_omega} --- make sure you don't get caught out by this.
\begin{example}
\begin{lstlisting}[language = Python]
if t < 4000.0:
omega = 3.0
elif t < 6000.0:
omega = 2.5
elif t < 8000.0:
omega = 2.0
elif t < 10000.0:
omega = 1.5
elif t < 12000.0:
omega = 1.0
elif t < 14000.0:
omega = 0.5
else:
omega = 0.0
return 2.0 * omega
\end{lstlisting}
\caption{\option{python\_f\_plane} definition, sweeping through a number of
rotation rates. Note the factor of $2$ between $f$ and $\Omega$ (see
equation \eqref{eq:f_omega}).}
\label{ex:python_f_plane}
\end{example}
\section{Meshes}\label{sec:Mesh}
A mesh defines the discrete
function space in which the values of one or more fields lie. For example, the mesh
defines what degree of polynomials are employed on each element, whether the
field is continuous or discontinuous between elements, and whether the
domain is periodic in any direction.
Meshes are defined in the flml file by \option{/geometry/mesh} options. The
mesh associated with each field is referred to by name in the
\option{\ldots/mesh} option under that field.
\subsection{Reading meshes from file}
\index{mesh!input}
There must always be one mesh which is read in from a file in
Gmsh format. This is usually the \option{CoordinateMesh}. To specify the
Gmsh file from which the coordinate mesh should be read, set the
\option{file\_name} attribute of
\option{/geometry/dimension/mesh::CoordinateMesh/from\_file} to the basename
of the Gmsh file (that is, the filename without .msh)
The coordinate mesh read in from file will always have linear elements and
the Coordinate field is always continuous between elements.
\fluidity\ also has native Gmsh support, which loads in Gmsh files directly into
\fluidity, and works with binary and ASCII Gmsh formats. To enable native
support, \fluidity\ needs to be told to expect a Gmsh file, which is achieved
by setting the \onlypdf\option{/geometry/mesh/from\_file/format}\ option
to \onlypdf\option{gmsh}. \fluidity\ will now look for a file with the extension
\lstinline[language=bash]+.msh+ when it runs.
For information on generating meshes in Gmsh format, see chapter
\ref{chap:meshes}.
\subsection{Deriving meshes from other meshes}
\index{mesh!derived}
The alternative to reading a mesh from a file is to derive it from another
mesh. This is necessary when for instance we wish to derive a mesh with
different continuity or elements than the original mesh.
For example, if we have a \option{CoordinateMesh} as our input mesh read
from file, it is possible to derive a \option{VelocityMesh} from it
by adding \option{/geometry/mesh::VelocityMesh}, selecting
\option{from\_mesh} under it and there selecting
\option{mesh::CoordinateMesh}. If nothing further is specified
under the new mesh, the derived mesh will be exactly the same as the mesh
it is derived from.
The more interesting case occurs where we wish to derive a mesh with
different continuity or elements from the original mesh. To specify a
discontinuous mesh, under \option{\ldots/from\_mesh} enable
\option{mesh\_continuity} and select \option{discontinuous}.
Similarly, to specify a mesh with higher polynomial degree elements, enable
\option{mesh\_shape} under \option{\ldots/from\_mesh} and set
\option{polynomial\_degree}.
Meshes with any name can be added. Only the name \option{CoordinateMesh}
is special, as it will be used to store the coordinates of the mesh. This
is also the only required mesh. \option{VelocityMesh} and \option{PressureMesh}
are only provided as suggested names as quite often the pressure
and velocity fields need to be on a different mesh
than the coordinate mesh, e.g. for \PoDGPt. It is however
not required that the velocity is defined on a mesh with the name
\option{VelocityMesh}, nor does the pressure field have to be on a mesh
with the name \option{PressureMesh}. If for instance the mesh needed
for pressure is the same as your \option{CoordinateMesh}, e.g.
for \Poo or \Pzero\Pone, the pressure can be defined directly on
the \option{CoordinateMesh} and no extra mesh is needed.
\subsubsection{Shape function}
This option is used to specify the degree of polynomial which should be used
for the shape functions on each element of the mesh. If not selected, the
shape functions will be the same as those on the mesh from which this mesh
is derived.
\subsubsection{Continuity}
This option can be set to discontinuous to derive a discontinuous mesh from
a continuous one. Note that it is not possible to derive a continuous mesh
from a discontinuous mesh.
\subsubsection{Periodic}\label{sec:periodic}
\index{mesh!periodic}
\index{periodic domain}
To specify a periodic domain in Diamond, add a new mesh under
\option{/geometry/mesh}. Select \onlypdf\linebreak
\option{\ldots/from\_mesh/mesh::CoordinateMesh} and then turn
on \onlypdf\\
\option{\ldots/from\_mesh/periodic\_boundary\_conditions} for each dimension
that is periodic. There are three fields that need to be completed: the
surface IDs of one side, the surface IDs of the opposite side and a python
function (\option{coordinate\_map}) which contains the necessary mapping
function.
For example, suppose that the domain is the unit square shown in figure
\ref{fig:periodic}\ which is to be periodic in the $x$ direction. We
designate surface ID 1 as the \emph{physical boundary}\ and surface ID 2 as the
\emph{aliased boundary}. We therefore enter 1 in
\option{\ldots/physical\_boundary\_ids}\ and 2 in
\option{\ldots/aliased\_boundary\_ids}. The \emph{coordinate map}\ function
takes a point on the \emph{aliased}\ boundary to the corresponding point on
the \emph{physical}\ boundary. In this case, the appropriate function is:
\begin{lstlisting}[language=Python]
def val(X,t):
result = list(X)
result[0]=result[0]-1.0
return result
\end{lstlisting}
\begin{figure}[ht]
\centering
\xfig{configuring_fluidity_images/periodic_domain}
\caption{Periodic unit square with surface IDs 1-4 shown.}
\label{fig:periodic}
\end{figure}
Meshes that are required to be periodic can now be derived from this
periodic mesh. Note that the periodic mesh must be directly derived from the
mesh which has been read \option{from\_file}. It is not possible to derive a
periodic mesh from a \option{from\_mesh}\ mesh.
\subsubsection{Extruded meshes}\label{sec:extruded}
It can be advantageous to have a mesh in which all the nodes line up in
vertical lines. To achieve this effect within \fluidity, it is possible to
read in a mesh in $n-1$ dimensions and extrude it along the $n$-th
dimension. An extruded mesh is specified using the
\option{\ldots/from\_mesh/extrude}\ option.
Under this option it is necessary to set the \option{regions/bottom\_depth}. This is
a scalar value which gives the depth, a positive value. The extent of the
domain in $n$-th dimension will be $(0,-bottom\_depth)$. This value may be
set either as a constant or as a Python function. In the latter case,
function will be a function of space and time. Note in this case that the
space argument \lstinline[language=Python]+X+ will be $n-1$-dimensional. See
section \ref{sec:setting_with_python}\ for a full explanation of the use of Python functions to
prescribe field values. In this case, the depth is essentially a scalar
field over the $n-1$ dimensional parent mesh. The time argument which
will be passed to the function is the simulation start time and the function
will \emph{not}\ be re-evaluated during the simulation.
The second option which must be set is the
\option{\ldots/sizing\_function}. This specifies the mesh spacing
along the $n$-th dimension. It may once again be a constant or a Python
function. In the latter case, it will be a function of all $n$ dimensions
which facilitates the mesh spacing varying in depth as well as in the
horizontal. Once again, the function will be evaluated only at simulation
start.
It will usually be advantageous to specify the surface ID to be associated
with the top and bottom boundaries, so that boundary conditions can be
associated with them. This is achieved using the
\option{\ldots/top\_surface\_id}\ and
\option{\ldots/bottom\_surface\_id}\ options. The lateral boundaries
of the extruded mesh will inherit the surface IDs associated with the the
boundaries of the parent (non-extruded) mesh.
It is possible to specify different options for different regions of the
mesh by adding multiple \option{\ldots/extrude/regions}\ options and changing
them to the generic rather than the \option{regions::WholeMesh}\
version. The new regions need to be named and the region IDs to which they
apply specified.
As well as extruding 2D meshes (where only the $x$ and $y$ coordinates are
specified in the Gmsh file), given a pseudo 2D mesh on a spherical
shell, \fluidity\ can perform and extrusion in the radial direction. To
perform such an extrusion simply enable the options as noted above and
additionally check the \option{/geometry/spherical\_earth option}. With this
option enabled \fluidity\ will then perform the specified extrusion towards
the centre of the sphere.
Extrusions on the sphere can be performed such that the `depth' of the extrusion
conforms to bathymetric data. To extrude according
to bathymetry \fluidity\ must be provided with a netCDF data file containing
three columns of data giving the longitude, latitude and depth
of each point respectively. The name and location of this data file must then be
entered under \option{\ldots/extrude/regions/bottom\_depth/from\_map}.
To avoid the depth at coast dropping to zero the user may also enter a minimum
depth under the \option{\ldots/from\_map/min\_depth} option. Note however, that
if a minimum depth is specified, this will be applied throughout the domain.
\subsubsection{Extruded periodic meshes}\label{sec:extrudedperiodic}
If an extruded periodic mesh is required then the periodic mesh must first
be derived from the \option{from\_file}\ mesh. The extruded mesh is then
derived from the periodic mesh. All other meshes are next derived from the
extruded mesh. A special case is the \option{CoordinateMesh}. This must be
derived from the extruded mesh by specifying
\option{periodic\_boundary\_conditions/remove\_periodicity}. At this stage it
is necessary to re-specify the \option{physical\_boundary\_ids},
\option{aliased\_boundary\_ids} and \option{coordinate\_map}. Additionally, the
\option{inverse\_coordinate\_map}\ must be given. As the name suggests, this
function must be the inverse of the original \option{coordinate\_map}.
\section{Material/Phase}
The final compulsory element in the top level of the options tree is
\option{/material\_phase}. A \option{/material\_phase} element groups all
of the fields which pertain to one phase or one material. See
section~\ref{sec:config_multimatph} for an explanation of the distinction
between a phase and material in this context.
When configuring ocean problems (or single material/single phase fluids
problems), only one \option{/material\_phase} is required. Multi-material
and multiphase problems will require one \option{/material\_phase} for each
phase or material in the problem.
Note that you must give each of your material phases a name.
% NOTE: if you add anything below the Sediments sections here, change the ref...
The following sections (\ref{config:spatial} to \ref{config:sediments}) describe the options below the
\option{/material\_phase} option.
\section{Fields}
\index{field}
\subsection{Types of field}
A field associates a value with every node in the domain. Examples of fields
in a fluids simulation include the velocity and pressure. Fields in \fluidity\
are distinguished by the rank of the data on the field and the way in which
that field is calculated.
\begin{description}
\item[Scalar fields] have a scalar value at each node. Common examples
include temperature, pressure and density.
\item[Vector fields] have a vector value, in other words a list of numbers,
at each node. The rank of a vector field is 1 and the length of the
vector is given by the dimension of the problem.
\item[Tensor fields] have a value given by a square matrix at each
node. The side length of the matrix is the problem dimension and the rank
is naturally 2. The diffusivity of a tracer is a typical example of a
tensor-valued field.
\end{description}
Fields can also be characterised by the manner in which their value is
calculated. \fluidity\ recognises three such categories:
\begin{description}
\item[Prognostic fields] are the result of solving a partial differential
equation. In a typical fluids simulation, the velocity and pressure are
prognostic and are calculated by solving some variant of the Navier-Stokes
equations. Similarly, tracers such as temperature and salinity are usually
the result of solving an advection-diffusion equation. Prognostic fields
typically have specified initial and boundary conditions and it will be
necessary to specify spatial and temporal discretisation options. If an
implicit timestepping scheme is in use (and it almost always is in
\fluidity), it is also necessary to specify solver options.
\item[Diagnostic fields] are calculated from other fields without solving a
partial differential equation. A typical example is the CFL number which
may be calculated from the timestep, the mesh spacing and the velocity
field.
\item[Prescribed fields] receive their values from sources external to
\fluidity. This might be a constant or varying function specified by the
user, or it might be interpolated from some external data set. Fields such
as diffusivity and viscosity are often prescribed as are source and
absorption terms.
\end{description}
An additional field type - aliased - is also available. This links the values in one field to those in another, using no extra computational resources during the simulation (i.e. it is not an independent field). This is useful when sharing fields between material\_phases. For example if two material\_phases share a common velocity field then only one should contain a prognostic field while the other is aliased to the other material\_phase.
\subsection{Setting field values}\label{sec:setting_field_values}
\index{field!values}
\index{initial conditions!setting}
Field values must be specified by the user in two circumstances: the initial
value of most prognostic fields and the value throughout the simulation of
all prescribed fields.
The initial value of prognostic fields is set with the
\option{\ldots/prognostic/initial\_condition} option while the value of
prescribed fields is set with the \option{\ldots/prescribed/value} option.
\subsubsection{Constant fields}
\index{field!constant}
Fields which are constant in space and (for prescribed fields) time may be
specified by simply providing a constant value in the \option{constant}
option under \option{\ldots/prognostic/initial\_condition},
\option{\ldots/prescribed/value}. For a scalar field, this is a single
floating point (real) value while for a vector field this is a list of reals
of length equal to the field dimension.
For tensor valued fields there are more options. It is possible to specify
an isotropic, or rotation invariant, value by choosing
\option{\ldots/value/isotropic/constant} and specifying a single real which
will be used for all the diagonal entries of the tensor field at all mesh
nodes. The off-diagonal entries of an isotropic tensor field are always
zero. A constant anisotropic field may be specified by choosing
\option{\ldots/value/anisotropic\_asymmetric/constant} and providing the
entire matrix. Finally, a constant symmetric anisotropic tensor field may be
specified by selecting \onlypdf\linebreak
\option{\ldots/value/anisotropic\_symmetric/constant}. In this case, the
user must specify all of the entries in the upper half of the matrix and
those in the lower half will be filled automatically by symmetry.
\subsubsection{Setting fields with a Python function}\label{sec:setting_with_python}
\index{field!Python function}
\index{Python!prescribed field values}
The value of a field which varies in space and (for prescribed fields) in
time may be specified by providing an appropriate function written in
Python. The Python function will be evaluated for each node in the mesh at
the start of the simulation to populate the field values. For time-varying
prescribed fields, the function will be evaluated again at the beginning of
every timestep to update the field value. If it is known that the value of
the field does not in fact vary in time, then the re-evaluation of the
Python function on each timestep can be inhibited by setting the
\onlypdf\linebreak \option{\ldots/prescribed/do\_not\_recalculate} option.
The Python function must be provided as the value of the
\option{\ldots/python} option which may be chosen as an alternative to the
\option{\ldots/constant} function. The option may contain any Python code
but it must define a function \lstinline[language=Python]+val(X,t)+ where
the sequence \lstinline[language=Python]+X+ is the coordinates of the point
at which the field is being evaluated and \lstinline[language=Python]+t+ is
the current time.
For a scalar field, the function must return a single floating point
value. Similarly for a vector field, a sequence of values of length equal to
the field dimension must be returned. For a tensor field, there are two
cases. For an isotropic field specified with
\option{\ldots/value/isotropic/python}, the function must return a single
float which will be used for all the diagonal entries of the tensor at that
point. The off-diagonal entries will be set to zero. For the anisotropic case,
the function must return a two-dimensional array (a sequence of
sequences). It is the user's responsibility to ensure that the tensor is
symmetric in cases where it should be.
\begin{example}
\begin{lstlisting}[language=Python]
def val(X,t):
return (-X[1],X[0])
\end{lstlisting}
\caption{A Python function returning a two-dimensional solid rotating
vector field about the origin.}
\end{example}
\subsubsection{Reading fields from a file (using the \option{from\_file} option)}
\index{field!input}
A field can be populated using saved data from a file. This is intended primarily
for picking up prescribed fields from previously run prognostic simulations
(checkpointing) and may be specified by providing the file name in
the \option{from\_file} option under \option{\ldots/prognostic/initial\_condition},
\option{\ldots/prescribed/value}.
For prescribed fields the format of the input file containing field data must be
vtu, and this will only work for those prescribed fields directly underneath
\option{\ldots/material\_phase}. For prognostic fields it is possible to select
the type of input file, under \option{\ldots/initial\_condition/from\_file/format};
the available supported formats for this include \option{vtu} and \option{NetCDF-CF 1.x}.
The file mesh must match the mesh of this field (except for piecewise constant
fields which will be remapped back from the discontinuous nodal values). In
parallel the process number is appended to the filename, e.g. if the file name
attribute is set to \option{input.vtu}, process 0 reads from \option{input-0.vtu}.
\subsubsection{Setting an initial condition from a NetCDF file}\label{sec:setting_from_netcdf}
The initial state of certain fields can be set from external data contained within a NetCDF file.
This functionality can be used by selecting the \option{\ldots/initial\_condition/from\_netcdf/format}
option.
This option will not currently work with multi-layered data files. Supported
NetCDF file conventions include the NetCDF-CF 1.x convention.
\subsubsection{Setting fields from NEMO data}\label{sec:setting_from_nemo}
\index{field!from Nemo}
Initial conditions of prognostic fields and the values of prescribed fields can also be set from an external NEMO
data file. The external data file is in the NETCDF format and data is currently available for pressure, temperature, salinity
and velocity. To set the initial condition of a prognostic field from NEMO data, choose the option
\option{\ldots/prognostic/initial\_condition/NEMO\_data} and then under \option{format} select the required data format. For scalar fields
the formats available are `Temperature', `Salinity' and `Free-surface height', for vector fields `Velocity' is the only available format.
Setting the value of prescribed fields from NEMO data works similarly. Set the option \option{\ldots/prescribed/value/NEMO\_data} and then proceed as above.
\subsubsection{Setting an initial free surface height}\label{sec:setting_free_surface_height}
\index{inital conditions!free surface height}
\index{free surface!initial condition}
The free surface height is contained within the Pressure field. To apply an initial condition on free surface height,
choose the \option{\ldots/free\_surface} under the relevant Pressure initial condition option.
With this option, it is possible to set the initial free surface elevation in a tsunami simulation, for example.
The initial condition can be applied using the approaches outlined above, in this section~\ref{sec:setting_field_values}.
It is recommended that a diagnostic FreeSurface field is included if this option is used.
If set from a NetCDF file using the option \option{\ldots/initial\_condition/from\_netcdf}, and the file provides exactly the
free surface height, it is important that the child option \option{\ldots/initial\_condition/from\_netcdf/format} is set to `raw'.
If the \option{no\_normal\_stress} option is used, to impose
boundary condition \eqref{NormalStressBC} instead of $p=\patm$, you should add a
prognostic FreeSurface (instead of a diagnostic). The initial condition is then
also set for that field.
\subsection{Region IDs}
\index{region ID}
If the input mesh defines a number of region IDs then these may be employed
to specify different field values for each region. For a prescribed field,
this is achieved by changing the \option{\ldots/value::WholeMesh} element to
the unnamed \option{\ldots/value}. The user must then specify a new name for
that value element. Next, enable the \option{\ldots/value/region\_ids}
option and set it to a list of region ids to which this value should
apply. Any number of \option{\ldots/value} elements may be added to allow
different values to be specified in different regions. For prognostic
fields, analogous behaviour for initial conditions may be achieved by
switching \option{\ldots/initial\_condition} from \option{WholeMesh} to a
user-specified name and specifying the region IDs appropriately.
See section \ref{sec:region_ids}\ for information on including region IDs
in meshes.
\subsection{Mathematical constraints on initial conditions}\label{sec:ICs}
For well-posedness, the initial condition of the velocity field must
satisfy both continuity (\ref{conty}) and the boundary conditions
imposed on the problem. If the normal component of velocity is
imposed on the entire boundary then the additional
compatibility constraint of global mass conservation must be
satisfied:
\begin{equation*}
\int_{\partial\Omega}\bmn\cdot\bmu=0.
\end{equation*}
\section{Advected quantities: momentum and tracers}
\label{config:spatial}
\subsection{Spatial discretisations}\label{sec:Spatial discretisations}
\index{advection-diffusion equation!discretisation options}
\index{momentum equation!discretisation options}
A number of underlying finite element schemes are available for tracer
fields and velocity. In each case there are restrictions on the mesh
continuity which must be employed. In addition, the \onlypdf\linebreak