Merge lp:~fluidity-core/fluidity/fluidity-initialisation-from_netcdf into lp:fluidity

Proposed by Stephan Kramer
Status: Work in progress
Proposed branch: lp:~fluidity-core/fluidity/fluidity-initialisation-from_netcdf
Merge into: lp:fluidity
Diff against target: 2679 lines (+1141/-1170)
23 files modified
femtools/Makefile.dependencies (+1/-1)
femtools/SampleNetCDF_fortran.F90 (+35/-3)
ocean_forcing/SampleNetCDF.cpp (+44/-1)
ocean_forcing/SampleNetCDF.h (+7/-1)
preprocessor/Boundary_Conditions_From_Options.F90 (+93/-61)
preprocessor/Initialise_Fields.F90 (+31/-7)
preprocessor/Makefile.dependencies (+2/-1)
schemas/input_output.rnc (+10/-3)
schemas/input_output.rng (+11/-3)
schemas/prognostic_field_options.rnc (+2/-194)
schemas/prognostic_field_options.rng (+2/-272)
schemas/shallow_water_options.rnc (+0/-12)
schemas/shallow_water_options.rng (+15/-31)
schemas/test_advection_diffusion_options.rnc (+0/-241)
schemas/test_advection_diffusion_options.rng (+15/-339)
tests/sample_netcdf_test/Makefile (+9/-0)
tests/sample_netcdf_test/create_netcdf_test.py (+70/-0)
tests/sample_netcdf_test/sample.flml (+658/-0)
tests/sample_netcdf_test/sample_netcdf_test.xml (+24/-0)
tests/sample_netcdf_test/src/box_on_sphere.geo (+17/-0)
tests/sample_netcdf_test/src/definitions.geo (+41/-0)
tests/sample_netcdf_test/src/shorelines.geo (+8/-0)
tests/sample_netcdf_test/src/shorelines_with_boundaries.geo (+46/-0)
To merge this branch: bzr merge lp:~fluidity-core/fluidity/fluidity-initialisation-from_netcdf
Reviewer Review Type Date Requested Status
Stephan Kramer Pending
Review via email: mp+95576@code.launchpad.net

Description of the change

This merge achieves 3 things:
1) Change tidal forcing boundary condition so that the phase is no longer interpolated (this causes issues at the 360-0 line). Instead the tidal elevation is calculated as:
  A(x) cos(omega*t+alpha(x)) = A(x) cos(omega*t) cos(alpha(x)-sin(omega*t) sin(alpha(x))
                             = Re[ A(x) exp(i omega*t) exp(i alpha(x)) ]
where A(x), alpha(x) and omega are the amplitude, phase and frequency of the tidal constituent. We therefore now compute A(x)*cos(alpha(x)) and A(x)*sin(alpha(x)), the real and imaginary components of the complex tidal constituent, at the nodes of the netCDF first, before interpolating to the fluidity mesh.
2) The netCDF file is only read once at the beginning of the run instead of every timestep.
3) Prescribed fields have an option to be prescribed from a netCDF file using the same netCDF reader as used for the tidal boundary forcing, so we can actually see what data is being used. This is done by adding a new "netcdf" format (next to the existing "vtu" format under "from_file"), under which the user can specify which netCDF variable to read.

The reason these 3 things are combined in this merge is to allow testing of the tidal boundary forcing - currently no such tests exist. This merge introduces the sample_netcdf_test/ that tests
both the SampleNetCDF reader and the actual tidal boundary condition values. This is done by creating a netCDF file using Scientific python with variables set via an analytical function and checking the same values are read in fluidity.

Smaller changes:
- taking away the dirichlet/from_file/tidal option under various balance pressure fields. For these cases (other than field%name=="Pressure") the tidal forcing was never multiplied by g, so this would not have worked.
- because this was also still present under the no longer existing "prognostic free surface", this has now finally been taken out of the schema - which meant also deleting it from the shallow water and test_advection_diffussion schemes.
- fix intents of id argument of most SampleNetCDF_XXX() routines.
- add SampleNetCDF_to_field() routine that interpolate netCDF data to scalar_field on the fluidity mesh

To post a comment you must log in.
3943. By Stephan Kramer

Fix initialising prescribed fields from "netcdf" format in parallel.

Revision history for this message
Stephan Kramer (s-kramer) wrote :

I use python code for all of this now, that I'll make available soon. Therefore retracting my merge request for now.

Revision history for this message
Adam Candy (asc) wrote :

> I use python code for all of this now, that I'll make available soon.
> Therefore retracting my merge request for now.

How very gentlemanly of you!

I have a branch implementing some of the above, so we could take a look at the two and merge in a combination. The NetCDF input certainly requires an improvement - Jon's also mentioned working on this?

I think my branch with additional debugging for the NetCDf readers (a portion of them) is already in. This does give information on the location of problem reads, warns when values are recast and is accompanied by a suite of tests.

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

I have a half-competed branch for reading netcdf files and putting those
data onto a mesh. I was stuck with a unit test not compiling if I
remember correctly.

The branch is at:
bzr+ssh://bazaar.launchpad.net/~fluidity-core/fluidity/refactor-netcdf/

I was trying to create a generic reader which created a mesh using
Delauny triangulation. We can then use Fluidity's mesh interpolation to
put this on any mesh.

Michael Lange is also interested in this, including outputting stat
files and detectors to NetCDF.

Jon

On 09/05/13 12:14, Adam Candy wrote:
>> I use python code for all of this now, that I'll make available soon.
>> Therefore retracting my merge request for now.
>
> How very gentlemanly of you!
>
> I have a branch implementing some of the above, so we could take a look at the two and merge in a combination. The NetCDF input certainly requires an improvement - Jon's also mentioned working on this?
>
> I think my branch with additional debugging for the NetCDf readers (a portion of them) is already in. This does give information on the location of problem reads, warns when values are recast and is accompanied by a suite of tests.
>

--
Dr Jon Hill
Research Fellow
AMCG, Imperial College London
Mob: 07748254812

Unmerged revisions

3943. By Stephan Kramer

Fix initialising prescribed fields from "netcdf" format in parallel.

3942. By Stephan Kramer

Merging from trunk.

3941. By Stephan Kramer

Cleaning up before merge request.

3940. By Stephan Kramer

Should have committed these file for the test as well.

3939. By Stephan Kramer

Merging in from trunk.

3938. By Stephan Kramer

Actually testing the values brought up two more bugs. Now pretty confident it actually works.

3937. By Stephan Kramer

Add prescribed field initialised from netcdf, to be compared with a python diagnostic field using the same function used to create the netcdf file.
Fixed mem leak in initialsing form netcdf.

3936. By Stephan Kramer

Several bug fixes. Test now runs through and seems to give sensible answers.

3935. By Stephan Kramer

Start of a new test to test SampleNetCDF and tidal boundary conditions.
Does not yet work.
Accidentily removed tidal boundary conditions also from "Pressure" - putting back in.

3934. By Stephan Kramer

This commit address 2 issues:
* interpolating errors along the phase=360 lines of tidal forcing read netcdf files
* the tidal forcing is no longer read every timestep, but only once in populate_state - this prevents reading the entire netcdf tidal atlas on every processor every timestep.

In femtools/SampleNetCDF_fortran.F90:
- fix intents of id argument of most SampleNetCDF_XXX() routines.
- add SampleNetCDF_to_field that sets a scalar field from netcdf values.
In preprocessor/Boundary_Conditions_From_Options.F90
- add new populate_tidal_bc() routine, that initialises the tidal bc calculation by computing the real and complex components of A(x)exp(i*alpha(x)), where A(x) is amplitude and alpha(x) the phase, and store these components as surface fields under the bc.
- in set_tidal_bc_value() it now uses these to compute the free surface contributions of the different tidal components.
In schemas/:
- taking away the dirichlet/from_file/tidal option under various balance pressure fields. For these cases (other than field%name=="Pressure") the tidal forcing was never multiplied by g, so this would not have worked.
- because this was also still present under the no longer existing "prognostic free surface", this has now finally been taken out of the schema - which meant also deleting it from the shallow water and test_advection_diffussion schemes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'femtools/Makefile.dependencies'
--- femtools/Makefile.dependencies 2012-01-20 15:54:44 +0000
+++ femtools/Makefile.dependencies 2012-03-27 11:21:19 +0000
@@ -933,7 +933,7 @@
933 @true933 @true
934934
935SampleNetCDF_fortran.o ../include/samplenetcdf.mod: SampleNetCDF_fortran.F90 \935SampleNetCDF_fortran.o ../include/samplenetcdf.mod: SampleNetCDF_fortran.F90 \
936 ../include/fldebug.mod936 ../include/coordinates.mod ../include/fields.mod ../include/fldebug.mod
937937
938../include/shape_functions.mod: Shape_Functions.o938../include/shape_functions.mod: Shape_Functions.o
939 @true939 @true
940940
=== modified file 'femtools/SampleNetCDF_fortran.F90'
--- femtools/SampleNetCDF_fortran.F90 2010-11-09 14:08:19 +0000
+++ femtools/SampleNetCDF_fortran.F90 2012-03-27 11:21:19 +0000
@@ -27,6 +27,8 @@
2727
28module SampleNetCDF28module SampleNetCDF
29 use FLDebug29 use FLDebug
30 use fields
31 use coordinates
30 implicit none32 implicit none
31contains33contains
32 34
@@ -39,13 +41,25 @@
3941
40 subroutine SampleNetCDF_SetVariable(id, varname)42 subroutine SampleNetCDF_SetVariable(id, varname)
41 character(len=*), intent(in)::varname43 character(len=*), intent(in)::varname
42 integer, intent(out)::id44 integer, intent(in)::id
43 45
44 call samplenetcdf_setvariable_c(id, varname, len_trim(varname))46 call samplenetcdf_setvariable_c(id, varname, len_trim(varname))
45 end subroutine SampleNetCDF_SetVariable47 end subroutine SampleNetCDF_SetVariable
4648
49 subroutine SampleNetCDF_ApplyCos(id)
50 integer, intent(in)::id
51
52 call samplenetcdf_applycos_c(id)
53 end subroutine SampleNetCDF_ApplyCos
54
55 subroutine SampleNetCDF_ApplySin(id)
56 integer, intent(in)::id
57
58 call samplenetcdf_applysin_c(id)
59 end subroutine SampleNetCDF_ApplySin
60
47 subroutine SampleNetCDF_GetValue(id, longitude, latitude, val)61 subroutine SampleNetCDF_GetValue(id, longitude, latitude, val)
48 integer, intent(out)::id62 integer, intent(in)::id
49 real, intent(out)::longitude, latitude63 real, intent(out)::longitude, latitude
50 real, intent(out)::val64 real, intent(out)::val
5165
@@ -53,9 +67,27 @@
53 end subroutine SampleNetCDF_GetValue67 end subroutine SampleNetCDF_GetValue
5468
55 subroutine SampleNetCDF_Close(id)69 subroutine SampleNetCDF_Close(id)
56 integer, intent(out)::id70 integer, intent(in)::id
57 71
58 call samplenetcdf_close_c(id)72 call samplenetcdf_close_c(id)
59 end subroutine SampleNetCDF_Close73 end subroutine SampleNetCDF_Close
74
75 subroutine SampleNetCDF_to_field(id, field, bc_position)
76 ! set scalar field from netcdf values
77 integer, intent(in):: id
78 type(scalar_field), intent(inout):: field
79 type(vector_field), intent(in):: bc_position
80
81 integer:: i
82 real:: longitude, latitude, xyz(3), value
83
84 do i=1, node_count(bc_position)
85 xyz = node_val(bc_position, i)
86 call LongitudeLatitude(xyz, longitude, latitude)
87 call SampleNetCDF_GetValue(id, longitude, latitude, value)
88 call set(field, i, value)
89 end do
90
91 end subroutine SampleNetCDF_to_field
60 92
61end module SampleNetCDF93end module SampleNetCDF
6294
=== modified file 'ocean_forcing/SampleNetCDF.cpp'
--- ocean_forcing/SampleNetCDF.cpp 2012-02-20 17:52:19 +0000
+++ ocean_forcing/SampleNetCDF.cpp 2012-03-27 11:21:19 +0000
@@ -25,6 +25,7 @@
25#include <iostream>25#include <iostream>
26#include <map>26#include <map>
27#include <vector>27#include <vector>
28#include <algorithm>
2829
29#include <vtk.h>30#include <vtk.h>
3031
@@ -65,6 +66,7 @@
65 }66 }
6667
67 data = in.data;68 data = in.data;
69 read_data = in.read_data;
68 verbose = in.verbose;70 verbose = in.verbose;
69 71
70 reader = in.reader;72 reader = in.reader;
@@ -189,7 +191,19 @@
189 if(verbose)191 if(verbose)
190 cout<<"void SampleNetCDF::SetVariable("<<varname<<")\n";192 cout<<"void SampleNetCDF::SetVariable("<<varname<<")\n";
191193
192 reader.Read(varname, data);194 reader.Read(varname, read_data);
195 data = read_data.begin();
196}
197
198void SampleNetCDF::ApplyFunction(double f(double x)){
199 // apply transformation to read data
200 // transformed data is stored in manipulated_data, allocate it to right size (or reuse)
201 if (manipulated_data.size()!=read_data.size())
202 manipulated_data.resize(read_data.size());
203 // iterate over read_data, apply function f and store in manipulated_data
204 transform(read_data.begin(), read_data.end(), manipulated_data.begin(), f);
205 // from now on we sample the manipulated data:
206 data = manipulated_data.begin();
193}207}
194208
195void SampleNetCDF::VerboseOff(){209void SampleNetCDF::VerboseOff(){
@@ -226,6 +240,35 @@
226 240
227 netcdf_sampler[*id].SetVariable(string(varname, *len));241 netcdf_sampler[*id].SetVariable(string(varname, *len));
228 }242 }
243
244 // auxilary functions cosdeg and sindeg: cos and sin as function of degrees rather than radials
245 double const pi=4*atan(1);
246 double cosdeg(double deg){
247 return cos(pi*deg/180);
248 }
249 double sindeg(double deg){
250 return sin(pi*deg/180);
251 }
252
253#define samplenetcdf_applycos_fc F77_FUNC_(samplenetcdf_applycos_c, SAMPLENETCDF_APPLYCOS_C)
254 void samplenetcdf_applycos_fc(const int *id){
255 if(netcdf_sampler.find(*id)==netcdf_sampler.end()){
256 cerr<<"ERROR: netcdf file has not been opened\n";
257 exit(-1);
258 }
259
260 netcdf_sampler[*id].ApplyFunction(cosdeg);
261 }
262
263#define samplenetcdf_applysin_fc F77_FUNC_(samplenetcdf_applysin_c, SAMPLENETCDF_APPLYSIN_C)
264 void samplenetcdf_applysin_fc(const int *id){
265 if(netcdf_sampler.find(*id)==netcdf_sampler.end()){
266 cerr<<"ERROR: netcdf file has not been opened\n";
267 exit(-1);
268 }
269
270 netcdf_sampler[*id].ApplyFunction(sindeg);
271 }
229 272
230#define samplenetcdf_getvalue_fc F77_FUNC_(samplenetcdf_getvalue_c, SAMPLENETCDF_GETVALUE_C)273#define samplenetcdf_getvalue_fc F77_FUNC_(samplenetcdf_getvalue_c, SAMPLENETCDF_GETVALUE_C)
231 void samplenetcdf_getvalue_fc(const int *id, const double *longitude, const double *latitude, double *val){274 void samplenetcdf_getvalue_fc(const int *id, const double *longitude, const double *latitude, double *val){
232275
=== modified file 'ocean_forcing/SampleNetCDF.h'
--- ocean_forcing/SampleNetCDF.h 2009-12-16 14:11:47 +0000
+++ ocean_forcing/SampleNetCDF.h 2012-03-27 11:21:19 +0000
@@ -52,6 +52,7 @@
5252
53 void SetFile(std::string);53 void SetFile(std::string);
54 void SetVariable(std::string);54 void SetVariable(std::string);
55 void ApplyFunction(double f(double x));
55 56
56 void VerboseOff();57 void VerboseOff();
57 void VerboseOn();58 void VerboseOn();
@@ -66,7 +67,12 @@
66 double spacing[2]; // Grid spacing67 double spacing[2]; // Grid spacing
67 int dimension[2]; // Grid dimensions68 int dimension[2]; // Grid dimensions
68 69
69 std::vector<double> data;70 // random access iterator over the data being sampled
71 // (this may be iterating manipulated_data or read_data):
72 std::vector<double>::iterator data;
73
74 std::vector<double> read_data; // original data in netcdf file
75 std::vector<double> manipulated_data; // data after manipulation
70 bool verbose;76 bool verbose;
7177
72 NetCDFReader reader;78 NetCDFReader reader;
7379
=== modified file 'preprocessor/Boundary_Conditions_From_Options.F90'
--- preprocessor/Boundary_Conditions_From_Options.F90 2011-11-23 13:46:31 +0000
+++ preprocessor/Boundary_Conditions_From_Options.F90 2012-03-27 11:21:19 +0000
@@ -260,6 +260,10 @@
260 call insert_surface_field(field, i+1, surface_field)260 call insert_surface_field(field, i+1, surface_field)
261 call deallocate(surface_field)261 call deallocate(surface_field)
262262
263 if (have_option(trim(bc_path_i)//"/type::dirichlet/from_file")) then
264 call populate_tidal_bc(field, i+1, bc_position, trim(bc_path_i)//"/type::dirichlet/from_file")
265 end if
266
263 case("robin")267 case("robin")
264268
265 call allocate(surface_field, surface_mesh, name="order_zero_coefficient")269 call allocate(surface_field, surface_mesh, name="order_zero_coefficient")
@@ -767,7 +771,7 @@
767 ! Tidal: set free surface height at the boundary.771 ! Tidal: set free surface height at the boundary.
768 if (have_option(trim(bc_type_path)//"/from_file")) then772 if (have_option(trim(bc_type_path)//"/from_file")) then
769 ! Special case for tidal harmonic boundary conditions773 ! Special case for tidal harmonic boundary conditions
770 call set_tidal_bc_value(surface_field, bc_position, trim(bc_type_path), field%name)774 call set_tidal_bc_value(field, surface_field, i+1, trim(bc_type_path)//"/from_file")
771 else if (have_option(trim(bc_type_path)//"/NEMO_data")) then775 else if (have_option(trim(bc_type_path)//"/NEMO_data")) then
772 call set_nemo_bc_value(state, surface_field, bc_position, trim(bc_type_path), field%name, surface_element_list)776 call set_nemo_bc_value(state, surface_field, bc_position, trim(bc_type_path), field%name, surface_element_list)
773 else777 else
@@ -1092,71 +1096,99 @@
1092 1096
1093 end subroutine set_vector_boundary_conditions_values1097 end subroutine set_vector_boundary_conditions_values
1094 1098
1095 subroutine set_tidal_bc_value(surface_field, bc_position, bc_type_path, field_name)1099 subroutine populate_tidal_bc(field, bc_index, bc_position, bc_option_path)
1096 ! tidal_forcing - asc1100 ! tidal_forcing - asc
1097 type(scalar_field), intent(inout):: surface_field1101 type(scalar_field), intent(inout):: field
1098 type(vector_field), intent(in):: bc_position1102 integer, intent(in):: bc_index
1099 character(len=*), intent(in):: bc_type_path, field_name1103 type(vector_field), intent(inout):: bc_position
1104 ! option path pointing to tidal constituents
1105 character(len=*), intent(in):: bc_option_path
11001106
1101 real :: current_time, frequency, amplitude_factor1107 type(scalar_field):: amplitude, real_component, imag_component
1102 integer :: constituent_count, i, j, id, stat1108 integer :: constituent_count, i, j, id, stat
1103 character(len=3) :: constituent_name1109 character(len=3) :: constituent_name
1104 character(len=4096) :: file_name, variable_name_amplitude, variable_name_phase1110 character(len=4096) :: file_name, variable_name_amplitude, variable_name_phase
1105 real, dimension(:), allocatable::amplitude, phase1111
1106 real :: xyz(3), longitude, latitude1112 constituent_count = option_count(trim(bc_option_path)//"/tidal")
1107 real :: gravty1113
11081114 do i=0, constituent_count-1
1109 allocate(amplitude(node_count(surface_field)), phase(node_count(surface_field)))1115
1110 1116 ! Taken from E.W. Schwiderski - Rev. Geophys. Space Phys. Vol. 18 No. 1 pp. 243--268, 1980
1111 if(have_option(trim(bc_type_path)//"/from_file/tidal")) then1117 call get_option(trim(bc_option_path)//"/tidal["//int2str(i)//"]/name", constituent_name)
1112 call set(surface_field, 0.0)1118
1113 call get_option("/timestepping/current_time", current_time)1119 call get_option(trim(bc_option_path)//"/tidal["//int2str(i)//"]/file_name", file_name)
1114 constituent_count = option_count(trim(bc_type_path)//"/from_file/tidal")1120 call get_option(trim(bc_option_path)//"/tidal["//int2str(i)//"]/variable_name_amplitude", variable_name_amplitude)
11151121 call get_option(trim(bc_option_path)//"/tidal["//int2str(i)//"]/variable_name_phase", variable_name_phase)
1116 do i=0, constituent_count-11122
1117 amplitude = 0.01123 call SampleNetCDF_Open(trim(file_name), id)
1118 phase = 0.01124
1119 call get_option(trim(bc_type_path)//"/from_file/tidal["//int2str(i)//"/amplitude_factor", amplitude_factor, stat=stat)1125 ! sample the tidal amplitude at the boundary nodes
1120 if (stat/=0) then1126 call SampleNetCDF_SetVariable(id, trim(variable_name_amplitude))
1121 amplitude_factor = 1.01127 call allocate(amplitude, bc_position%mesh, "amplitude")
1122 end if1128 call SampleNetCDF_to_field(id, amplitude, bc_position)
1123 1129
1124 ! Taken from E.W. Schwiderski - Rev. Geophys. Space Phys. Vol. 18 No. 1 pp. 243--268, 19801130 ! we compute the real and imaginary component of the tide:
1125 call get_option(trim(bc_type_path)//"/from_file/tidal["//int2str(i)//"]/name", constituent_name, stat=stat)1131 ! A(x) * exp(i*alpha(x)) = A(x)cos(alpha(x)) + i * A(x)sin(alpha(x))
11261132 ! where A(x) is the amplitude, and alpha(x) the phase
1127 frequency = get_tidal_frequency(constituent_name)1133
11281134 ! sample cos(alpha(x)) and multiply with A(x) at the nodes
1129 call get_option(trim(bc_type_path)//"/from_file/tidal["//int2str(i)//"]/file_name", file_name, stat=stat)1135 call SampleNetCDF_SetVariable(id, trim(variable_name_phase))
1130 call get_option(trim(bc_type_path)//"/from_file/tidal["//int2str(i)//"]/variable_name_amplitude", variable_name_amplitude, stat=stat)1136 call SampleNetCDF_ApplyCos(id)
1131 call get_option(trim(bc_type_path)//"/from_file/tidal["//int2str(i)//"]/variable_name_phase", variable_name_phase, stat=stat)1137 call allocate(real_component, bc_position%mesh, trim(constituent_name)//"real")
11321138 call SampleNetCDF_to_field(id, real_component, bc_position)
1133 call SampleNetCDF_Open(trim(file_name), id)1139 call scale(real_component, amplitude)
1134 call SampleNetCDF_SetVariable(id, trim(variable_name_amplitude))1140 call insert_surface_field(field, bc_index, real_component)
1135 do j=1, node_count(bc_position)1141 call deallocate(real_component)
1136 xyz = node_val(bc_position, j)1142
1137 call LongitudeLatitude(xyz, longitude, latitude)1143 ! sample sin(alpha(x)) and multiply with A(x) at the nodes
1138 call SampleNetCDF_GetValue(id, longitude, latitude, amplitude(j))1144 call SampleNetCDF_ApplySin(id)
1139 end do1145 call allocate(imag_component, bc_position%mesh, trim(constituent_name)//"imag")
1140 call SampleNetCDF_SetVariable(id, trim(variable_name_phase))1146 call SampleNetCDF_to_field(id, imag_component, bc_position)
1141 do j=1, node_count(bc_position)1147 call scale(imag_component, amplitude)
1142 xyz = node_val(bc_position, j)1148 call insert_surface_field(field, bc_index, imag_component)
1143 call LongitudeLatitude(xyz, longitude, latitude)1149 call deallocate(imag_component)
1144 call SampleNetCDF_GetValue(id, longitude, latitude, phase(j))1150
1145 end do1151 call deallocate(amplitude)
1146 1152 call SampleNetCDF_Close(id)
1147 call get_option('/physical_parameters/gravity/magnitude', gravty)1153 end do
1148 do j=1, node_count(bc_position)1154
1149 if (field_name=="Pressure") then1155 end subroutine populate_tidal_bc
1150 call addto(surface_field, j, &1156
1151 gravty * amplitude(j) * cos( frequency * current_time - ( phase(j) * pi / 180 ) ))1157 subroutine set_tidal_bc_value(field, surface_field, bc_index, bc_option_path)
1152 else1158 ! tidal components are added into the dirichlet "value" surface_field
1153 call addto(surface_field, j, &1159 type(scalar_field), intent(inout):: field, surface_field
1154 amplitude(j) * cos( frequency * current_time - ( phase(j) * pi / 180 ) ))1160 integer, intent(in):: bc_index
1155 end if1161 ! option path pointing to tidal constituents
1156 end do1162 character(len=*), intent(in):: bc_option_path
1157 call SampleNetCDF_Close(id)1163
1158 end do1164 type(scalar_field), pointer:: real_component, imag_component
1159 end if1165 integer :: constituent_count, i
1166 character(len=3) :: constituent_name
1167 real :: g, t, omega
1168
1169 call get_option("/timestepping/current_time", t)
1170 call get_option('/physical_parameters/gravity/magnitude', g)
1171
1172 call zero(surface_field)
1173
1174 constituent_count = option_count(trim(bc_option_path)//"/tidal")
1175
1176 do i=0, constituent_count-1
1177 ! Taken from E.W. Schwiderski - Rev. Geophys. Space Phys. Vol. 18 No. 1 pp. 243--268, 1980
1178 call get_option(trim(bc_option_path)//"/tidal["//int2str(i)//"]/name", constituent_name)
1179 omega = get_tidal_frequency(constituent_name)
1180
1181 ! the free surface contribution is calculated as:
1182 ! g*A(x) cos(omega * t + alpha(x)) = g*A(x) cos(alpha(x) cos(omega *t) - g*A(x) sin(alpha(x) sin(omega *t)
1183
1184 real_component => extract_surface_field(field, bc_index, trim(constituent_name)//"real")
1185 call addto(surface_field, real_component, scale=g*cos(omega*t))
1186
1187 imag_component => extract_surface_field(field, bc_index, trim(constituent_name)//"imag")
1188 call addto(surface_field, imag_component, scale=-g*sin(omega*t))
1189
1190 end do
1191
1160 end subroutine set_tidal_bc_value1192 end subroutine set_tidal_bc_value
11611193
1162 subroutine set_nemo_bc_value(state, surface_field, bc_position, bc_type_path, field_name, surface_element_list)1194 subroutine set_nemo_bc_value(state, surface_field, bc_position, bc_type_path, field_name, surface_element_list)
11631195
=== modified file 'preprocessor/Initialise_Fields.F90'
--- preprocessor/Initialise_Fields.F90 2012-02-09 22:34:28 +0000
+++ preprocessor/Initialise_Fields.F90 2012-03-27 11:21:19 +0000
@@ -38,6 +38,8 @@
38use nemo_states_module38use nemo_states_module
39use physics_from_options39use physics_from_options
40use load_netcdf_module40use load_netcdf_module
41use tidal_module
42use SampleNetCDF
4143
42implicit none44implicit none
4345
@@ -84,9 +86,11 @@
84 character(len=PYTHON_FUNC_LEN) :: func86 character(len=PYTHON_FUNC_LEN) :: func
85 real :: current_time87 real :: current_time
86 real :: gravity_magnitude88 real :: gravity_magnitude
87 89
88 real value90 ! some variables for reading from netcdf and climatology
89 integer nid91 real, dimension(3):: xyz
92 real:: value, longitude, latitude
93 integer:: id, nid
9094
91 ! Find out whether initial condition is constant or generated by a 95 ! Find out whether initial condition is constant or generated by a
92 ! python function (or comes from something else). 96 ! python function (or comes from something else).
@@ -123,13 +127,15 @@
123 127
124 call get_option(trim(path) // "/from_file/format/name", format)128 call get_option(trim(path) // "/from_file/format/name", format)
125 call get_option(trim(path) // "/from_file/file_name", filename)129 call get_option(trim(path) // "/from_file/file_name", filename)
126 if(isparallel()) then
127 filename = parallel_filename(trim_file_extension(filename), ".vtu")
128 end if
129 ewrite(2, *) "Initialising field " // trim(field%name) // " from file " // trim(filename)
130 130
131 select case (format)131 select case (format)
132 case ("vtu")132 case ("vtu")
133
134 if(isparallel()) then
135 filename = parallel_filename(trim_file_extension(filename), ".vtu")
136 end if
137 ewrite(2, *) "Initialising field " // trim(field%name) // " from file " // trim(filename)
138
133 call get_option(trim(path) // "/from_file/format::vtu/field_name", field_name, default = field%name)139 call get_option(trim(path) // "/from_file/format::vtu/field_name", field_name, default = field%name)
134 read_field => vtk_cache_read_scalar_field(filename, field_name) 140 read_field => vtk_cache_read_scalar_field(filename, field_name)
135 141
@@ -164,7 +170,25 @@
164170
165 call set(field, read_field)171 call set(field, read_field)
166 172
173 case ("netcdf")
174
175 ewrite(2, *) "Initialising field " // trim(field%name) // " from file " // trim(filename)
167 176
177 call get_option(trim(path) // "/from_file/format::netcdf/field_name", field_name)
178 if (field%mesh==position%mesh) then
179 field_position=position
180 call incref(field_position)
181 else
182 ! otherwise the position mapped onto field%mesh
183 field_position = get_remapped_coordinates(position, field%mesh)
184 end if
185
186 call SampleNetCDF_Open(trim(filename), id)
187 call SampleNetCDF_SetVariable(id, trim(field_name))
188 call SampleNetCDF_to_field(id, field, field_position)
189 call SampleNetCDF_Close(id)
190 call deallocate(field_position)
191
168 case ("climatology (Boyer2005)")192 case ("climatology (Boyer2005)")
169 193
170 do nid=1, node_count(position)194 do nid=1, node_count(position)
171195
=== modified file 'preprocessor/Makefile.dependencies'
--- preprocessor/Makefile.dependencies 2011-10-26 19:57:55 +0000
+++ preprocessor/Makefile.dependencies 2012-03-27 11:21:19 +0000
@@ -36,7 +36,8 @@
36 ../include/fdebug.h ../include/fields.mod ../include/futils.mod \36 ../include/fdebug.h ../include/fields.mod ../include/futils.mod \
37 ../include/global_parameters.mod ../include/load_netcdf_module.mod \37 ../include/global_parameters.mod ../include/load_netcdf_module.mod \
38 ../include/nemo_states_module.mod ../include/physics_from_options.mod \38 ../include/nemo_states_module.mod ../include/physics_from_options.mod \
39 ../include/spud.mod ../include/tictoc.mod ../include/vtk_cache_module.mod39 ../include/samplenetcdf.mod ../include/spud.mod ../include/tictoc.mod \
40 ../include/tidal_module.mod ../include/vtk_cache_module.mod
4041
41../include/physics_from_options.mod: Physics_From_Options.o42../include/physics_from_options.mod: Physics_From_Options.o
42 @true43 @true
4344
=== modified file 'schemas/input_output.rnc'
--- schemas/input_output.rnc 2012-02-11 14:10:31 +0000
+++ schemas/input_output.rnc 2012-03-27 11:21:19 +0000
@@ -35,7 +35,8 @@
35 element from_file {35 element from_file {
36 attribute file_name { xsd:string },36 attribute file_name { xsd:string },
37 (37 (
38 vtu_input_format38 vtu_input_format|
39 netcdf_input_format
39 ),40 ),
40 comment41 comment
41 }|42 }|
@@ -575,9 +576,15 @@
575 576
576netcdf_input_format =577netcdf_input_format =
577 (578 (
578 ## NetCDF CF 1.4 (http://cf-pcmdi.llnl.gov/)579 ## Read from netcdf file
579 element format {580 element format {
580 attribute name { "NetCDF - CF 1.x" },581 attribute name { "netcdf" },
582 ## The field to read from the NetCDF file.
583 element field_name {
584 anystring,
585 comment
586 },
581 comment587 comment
582 }588 }
583 )589 )
590
584591
=== modified file 'schemas/input_output.rng'
--- schemas/input_output.rng 2012-02-11 14:10:31 +0000
+++ schemas/input_output.rng 2012-03-27 11:21:19 +0000
@@ -60,7 +60,10 @@
60 <attribute name="file_name">60 <attribute name="file_name">
61 <data type="string"/>61 <data type="string"/>
62 </attribute>62 </attribute>
63 <ref name="vtu_input_format"/>63 <choice>
64 <ref name="vtu_input_format"/>
65 <ref name="netcdf_input_format"/>
66 </choice>
64 <ref name="comment"/>67 <ref name="comment"/>
65 </element>68 </element>
66 <element name="NEMO_data">69 <element name="NEMO_data">
@@ -638,10 +641,15 @@
638 </define>641 </define>
639 <define name="netcdf_input_format">642 <define name="netcdf_input_format">
640 <element name="format">643 <element name="format">
641 <a:documentation>NetCDF CF 1.4 (http://cf-pcmdi.llnl.gov/)</a:documentation>644 <a:documentation>Read from netcdf file</a:documentation>
642 <attribute name="name">645 <attribute name="name">
643 <value>NetCDF - CF 1.x</value>646 <value>netcdf</value>
644 </attribute>647 </attribute>
648 <element name="field_name">
649 <a:documentation>The field to read from the NetCDF file.</a:documentation>
650 <ref name="anystring"/>
651 <ref name="comment"/>
652 </element>
645 <ref name="comment"/>653 <ref name="comment"/>
646 </element>654 </element>
647 </define>655 </define>
648656
=== modified file 'schemas/prognostic_field_options.rnc'
--- schemas/prognostic_field_options.rnc 2012-02-13 15:35:39 +0000
+++ schemas/prognostic_field_options.rnc 2012-03-27 11:21:19 +0000
@@ -1479,7 +1479,7 @@
1479 ## Type1479 ## Type
1480 element type {1480 element type {
1481 attribute name { "dirichlet" },1481 attribute name { "dirichlet" },
1482 input_choice_real_plus_boundary_forcing1482 input_choice_real_contents
1483 }1483 }
1484 }*,1484 }*,
1485 prognostic_scalar_output_options,1485 prognostic_scalar_output_options,
@@ -1511,7 +1511,7 @@
1511 ## Type1511 ## Type
1512 element type {1512 element type {
1513 attribute name { "dirichlet" },1513 attribute name { "dirichlet" },
1514 input_choice_real_plus_boundary_forcing1514 input_choice_real_contents
1515 }1515 }
1516 }+, 1516 }+,
1517 ## Disables checkpointing of this field1517 ## Disables checkpointing of this field
@@ -1681,198 +1681,6 @@
1681 interpolation_algorithm_scalar_full,1681 interpolation_algorithm_scalar_full,
1682 discrete_properties_algorithm_scalar?1682 discrete_properties_algorithm_scalar?
1683 )1683 )
1684
1685# free surface field, this is a copy of prognostic_scalar_field above
1686# removing all options that don't apply (mainly advection related)
1687prognostic_free_surface_field =
1688 (
1689 (
1690 ## Spatial discretisation options
1691 element spatial_discretisation {
1692 ## Form a full 3D system for the free surface
1693 element free_surface_3D {
1694 empty
1695 }?,
1696 element fourth_order_dissipation {
1697 empty
1698 }?,
1699 ## low order (linear) free surface
1700 element low_order_free_surface {
1701 empty
1702 }?,
1703 (
1704 ## Select free surface filter
1705 ##
1706 ## With PN-PN we need some filter to supress spurious modes.
1707 element default_free_surface_filter {
1708 empty
1709 }|
1710 ## Select free surface filter
1711 ##
1712 ## With PN-PN we need some filter to supress spurious modes.
1713 element user_specified_free_surface_filter {
1714 ## Default is to apply 0.01 and for wetting and drying cases 1.0
1715 element non_linear_filter_coefficient {
1716 real
1717 }
1718 }|
1719 ## Switch off free surface filter, this is more efficient than setting the coefficient to 0.
1720 element switch_off_free_surface_filter {
1721 empty
1722 }
1723 ),
1724 ## Apply wetting and drying routines
1725 element wetting_drying {
1726 empty
1727 }?,
1728 ## Tidal forcing options
1729 element tidal_forcing {
1730 ## M2
1731 element M2 {
1732 empty
1733 }?,
1734 ## S2
1735 element S2 {
1736 empty
1737 }?,
1738 ## N2
1739 element N2 {
1740 empty
1741 }?,
1742 ## K2
1743 element K2 {
1744 empty
1745 }?,
1746 ## K1
1747 element K1 {
1748 empty
1749 }?,
1750 ## O1
1751 element O1 {
1752 empty
1753 }?,
1754 ## P1
1755 element P1 {
1756 empty
1757 }?,
1758 ## Q1
1759 element Q1 {
1760 empty
1761 }?,
1762 ## Switch on all tidal components
1763 element all_tidal_components {
1764 empty
1765 }?,
1766 ## Switches on a Love number of 0.3
1767 element love_number {
1768 empty
1769 }?,
1770 ## Use static tidal force for testing
1771 element static_tidal_force {
1772 empty
1773 }?
1774 }?
1775 }
1776 ),
1777 # atheta, ctheta and fstheta (absorption, coriolis and free surface)
1778 # need to go in temporal discretisation
1779 # they are currently hard-coded however
1780 element temporal_discretisation {
1781 ## Implicit/explicitness for the free surface.
1782 ##
1783 ## Suggested value 1.0 (should be at least bigger than 0.5).
1784 ## =0. -- explicit
1785 ## =0.5 -- Crank-Nicolson
1786 ## =1. -- implicit
1787 element theta {
1788 real
1789 },
1790 # Maybe this should go under a proper absorption field under free surface?
1791 ## Implicit/explicitness for absorption
1792 ## =0. -- explicit (default)
1793 ## =0.5 -- Crank-Nicolson
1794 ## =1. -- implicit
1795 element absorption_theta {
1796 real
1797 }?
1798 },
1799 ## Solver
1800 element solver {
1801 linear_solver_options_sym
1802 },
1803 (
1804 ## Initial condition for WholeMesh
1805 ##
1806 ## Only specify one condition if not using mesh regions.
1807 ## Otherwise select other initial_condition option, specify region_ids
1808 ## and distinct names. Then add extra intial conditions for other regions.
1809 element initial_condition {
1810 attribute name { "WholeMesh" },
1811 input_choice_initial_condition_real
1812 }|
1813 ## Multiple initial_conditions are allowed if specifying
1814 ## different values in different
1815 ## regions of the mesh (defined by region_ids). In this case
1816 ## each initial_condition
1817 ## requires a distinct name for the options dictionary.
1818 element initial_condition {
1819 attribute name { string },
1820 region_ids?,
1821 input_choice_initial_condition_real
1822 }
1823 )+,
1824 ## Boundary conditions
1825 element boundary_conditions {
1826 attribute name { string },
1827 ## Surface id:
1828 element surface_ids {
1829 integer_vector
1830 },
1831 ## Type
1832 (
1833 element type {
1834 attribute name { "dirichlet" },
1835 (
1836 input_choice_real_contents|
1837 element from_file {
1838 element tidal {
1839 attribute file_name { string },
1840 attribute variable_name_amplitude { string },
1841 attribute variable_name_phase { string },
1842 ## See E.W. Schwiderski - Rev. Geophys. Space
1843 ## Phys. Vol. 18 No. 1 pp. 243--268, 1980
1844 ## for details of these constituent.
1845 attribute name {"M2"|"S2"|"N2"|"K2"|"K1"|"O1"|"P1"|"Q1"|"Mf"|"Mm"|"Ssa"}
1846 }+
1847 }|
1848 ## Set the boundary free-surface height from NEMO data.
1849 ## A prescribed NEMO pressure scalar field must be set to use this option.
1850 ## Set the name of the prescribed NEMO pressure scalar field below.
1851 element NEMO_data {
1852 attribute field_name { string }
1853 }
1854 )
1855 }|
1856 element type {
1857 attribute name { "neumann" },
1858 input_choice_real
1859 }|
1860 robin_bc_scalar
1861 )
1862 }*,
1863 # no Diffusivity for field
1864 # no source term
1865 # no Absorption term
1866 # no Adaptive timestepping option
1867 prognostic_scalar_output_options,
1868 prognostic_scalar_stat_options,
1869 scalar_convergence_options,
1870 prognostic_detector_options,
1871 scalar_steady_state_options,
1872 adaptivity_options_prognostic_scalar_field,
1873 interpolation_algorithm_scalar,
1874 discrete_properties_algorithm_scalar?
1875 )
18761684
1877# stream function, this is a copy of prognostic_scalar_field above1685# stream function, this is a copy of prognostic_scalar_field above
1878# removing all options that don't apply (mainly advection related)1686# removing all options that don't apply (mainly advection related)
18791687
=== modified file 'schemas/prognostic_field_options.rng'
--- schemas/prognostic_field_options.rng 2012-02-13 15:35:39 +0000
+++ schemas/prognostic_field_options.rng 2012-03-27 11:21:19 +0000
@@ -1807,7 +1807,7 @@
1807 <attribute name="name">1807 <attribute name="name">
1808 <value>dirichlet</value>1808 <value>dirichlet</value>
1809 </attribute>1809 </attribute>
1810 <ref name="input_choice_real_plus_boundary_forcing"/>1810 <ref name="input_choice_real_contents"/>
1811 </element>1811 </element>
1812 </element>1812 </element>
1813 </zeroOrMore>1813 </zeroOrMore>
@@ -1847,7 +1847,7 @@
1847 <attribute name="name">1847 <attribute name="name">
1848 <value>dirichlet</value>1848 <value>dirichlet</value>
1849 </attribute>1849 </attribute>
1850 <ref name="input_choice_real_plus_boundary_forcing"/>1850 <ref name="input_choice_real_contents"/>
1851 </element>1851 </element>
1852 </element>1852 </element>
1853 </oneOrMore>1853 </oneOrMore>
@@ -2048,276 +2048,6 @@
2048 </optional>2048 </optional>
2049 </define>2049 </define>
2050 <!--2050 <!--
2051 free surface field, this is a copy of prognostic_scalar_field above
2052 removing all options that don't apply (mainly advection related)
2053 -->
2054 <define name="prognostic_free_surface_field">
2055 <element name="spatial_discretisation">
2056 <a:documentation>Spatial discretisation options</a:documentation>
2057 <optional>
2058 <element name="free_surface_3D">
2059 <a:documentation>Form a full 3D system for the free surface</a:documentation>
2060 <empty/>
2061 </element>
2062 </optional>
2063 <optional>
2064 <element name="fourth_order_dissipation">
2065 <empty/>
2066 </element>
2067 </optional>
2068 <optional>
2069 <element name="low_order_free_surface">
2070 <a:documentation>low order (linear) free surface</a:documentation>
2071 <empty/>
2072 </element>
2073 </optional>
2074 <choice>
2075 <element name="default_free_surface_filter">
2076 <a:documentation>Select free surface filter
2077
2078With PN-PN we need some filter to supress spurious modes.</a:documentation>
2079 <empty/>
2080 </element>
2081 <element name="user_specified_free_surface_filter">
2082 <a:documentation>Select free surface filter
2083
2084With PN-PN we need some filter to supress spurious modes.</a:documentation>
2085 <element name="non_linear_filter_coefficient">
2086 <a:documentation>Default is to apply 0.01 and for wetting and drying cases 1.0</a:documentation>
2087 <ref name="real"/>
2088 </element>
2089 </element>
2090 <element name="switch_off_free_surface_filter">
2091 <a:documentation>Switch off free surface filter, this is more efficient than setting the coefficient to 0.</a:documentation>
2092 <empty/>
2093 </element>
2094 </choice>
2095 <optional>
2096 <element name="wetting_drying">
2097 <a:documentation>Apply wetting and drying routines</a:documentation>
2098 <empty/>
2099 </element>
2100 </optional>
2101 <optional>
2102 <element name="tidal_forcing">
2103 <a:documentation>Tidal forcing options </a:documentation>
2104 <optional>
2105 <element name="M2">
2106 <a:documentation>M2</a:documentation>
2107 <empty/>
2108 </element>
2109 </optional>
2110 <optional>
2111 <element name="S2">
2112 <a:documentation>S2</a:documentation>
2113 <empty/>
2114 </element>
2115 </optional>
2116 <optional>
2117 <element name="N2">
2118 <a:documentation>N2</a:documentation>
2119 <empty/>
2120 </element>
2121 </optional>
2122 <optional>
2123 <element name="K2">
2124 <a:documentation>K2</a:documentation>
2125 <empty/>
2126 </element>
2127 </optional>
2128 <optional>
2129 <element name="K1">
2130 <a:documentation>K1</a:documentation>
2131 <empty/>
2132 </element>
2133 </optional>
2134 <optional>
2135 <element name="O1">
2136 <a:documentation>O1</a:documentation>
2137 <empty/>
2138 </element>
2139 </optional>
2140 <optional>
2141 <element name="P1">
2142 <a:documentation>P1</a:documentation>
2143 <empty/>
2144 </element>
2145 </optional>
2146 <optional>
2147 <element name="Q1">
2148 <a:documentation>Q1</a:documentation>
2149 <empty/>
2150 </element>
2151 </optional>
2152 <optional>
2153 <element name="all_tidal_components">
2154 <a:documentation>Switch on all tidal components</a:documentation>
2155 <empty/>
2156 </element>
2157 </optional>
2158 <optional>
2159 <element name="love_number">
2160 <a:documentation>Switches on a Love number of 0.3</a:documentation>
2161 <empty/>
2162 </element>
2163 </optional>
2164 <optional>
2165 <element name="static_tidal_force">
2166 <a:documentation>Use static tidal force for testing</a:documentation>
2167 <empty/>
2168 </element>
2169 </optional>
2170 </element>
2171 </optional>
2172 </element>
2173 <!--
2174 atheta, ctheta and fstheta (absorption, coriolis and free surface)
2175 need to go in temporal discretisation
2176 they are currently hard-coded however
2177 -->
2178 <element name="temporal_discretisation">
2179 <element name="theta">
2180 <a:documentation>Implicit/explicitness for the free surface.
2181
2182Suggested value 1.0 (should be at least bigger than 0.5).
2183 =0. -- explicit
2184 =0.5 -- Crank-Nicolson
2185 =1. -- implicit</a:documentation>
2186 <ref name="real"/>
2187 </element>
2188 <optional>
2189 <!-- Maybe this should go under a proper absorption field under free surface? -->
2190 <element name="absorption_theta">
2191 <a:documentation>Implicit/explicitness for absorption
2192=0. -- explicit (default)
2193=0.5 -- Crank-Nicolson
2194=1. -- implicit</a:documentation>
2195 <ref name="real"/>
2196 </element>
2197 </optional>
2198 </element>
2199 <element name="solver">
2200 <a:documentation>Solver</a:documentation>
2201 <ref name="linear_solver_options_sym"/>
2202 </element>
2203 <oneOrMore>
2204 <choice>
2205 <element name="initial_condition">
2206 <a:documentation>Initial condition for WholeMesh
2207
2208Only specify one condition if not using mesh regions.
2209Otherwise select other initial_condition option, specify region_ids
2210and distinct names. Then add extra intial conditions for other regions.</a:documentation>
2211 <attribute name="name">
2212 <value>WholeMesh</value>
2213 </attribute>
2214 <ref name="input_choice_initial_condition_real"/>
2215 </element>
2216 <element name="initial_condition">
2217 <a:documentation>Multiple initial_conditions are allowed if specifying
2218different values in different
2219regions of the mesh (defined by region_ids). In this case
2220each initial_condition
2221requires a distinct name for the options dictionary.</a:documentation>
2222 <attribute name="name">
2223 <data type="string" datatypeLibrary=""/>
2224 </attribute>
2225 <optional>
2226 <ref name="region_ids"/>
2227 </optional>
2228 <ref name="input_choice_initial_condition_real"/>
2229 </element>
2230 </choice>
2231 </oneOrMore>
2232 <zeroOrMore>
2233 <element name="boundary_conditions">
2234 <a:documentation>Boundary conditions</a:documentation>
2235 <attribute name="name">
2236 <data type="string" datatypeLibrary=""/>
2237 </attribute>
2238 <element name="surface_ids">
2239 <a:documentation>Surface id:</a:documentation>
2240 <ref name="integer_vector"/>
2241 </element>
2242 <choice>
2243 <a:documentation>Type</a:documentation>
2244 <element name="type">
2245 <attribute name="name">
2246 <value>dirichlet</value>
2247 </attribute>
2248 <choice>
2249 <ref name="input_choice_real_contents"/>
2250 <element name="from_file">
2251 <oneOrMore>
2252 <element name="tidal">
2253 <attribute name="file_name">
2254 <data type="string" datatypeLibrary=""/>
2255 </attribute>
2256 <attribute name="variable_name_amplitude">
2257 <data type="string" datatypeLibrary=""/>
2258 </attribute>
2259 <attribute name="variable_name_phase">
2260 <data type="string" datatypeLibrary=""/>
2261 </attribute>
2262 <attribute name="name">
2263 <a:documentation>See E.W. Schwiderski - Rev. Geophys. Space
2264Phys. Vol. 18 No. 1 pp. 243--268, 1980
2265for details of these constituent.</a:documentation>
2266 <choice>
2267 <value>M2</value>
2268 <value>S2</value>
2269 <value>N2</value>
2270 <value>K2</value>
2271 <value>K1</value>
2272 <value>O1</value>
2273 <value>P1</value>
2274 <value>Q1</value>
2275 <value>Mf</value>
2276 <value>Mm</value>
2277 <value>Ssa</value>
2278 </choice>
2279 </attribute>
2280 </element>
2281 </oneOrMore>
2282 </element>
2283 <element name="NEMO_data">
2284 <a:documentation>Set the boundary free-surface height from NEMO data.
2285A prescribed NEMO pressure scalar field must be set to use this option.
2286Set the name of the prescribed NEMO pressure scalar field below.</a:documentation>
2287 <attribute name="field_name">
2288 <data type="string" datatypeLibrary=""/>
2289 </attribute>
2290 </element>
2291 </choice>
2292 </element>
2293 <element name="type">
2294 <attribute name="name">
2295 <value>neumann</value>
2296 </attribute>
2297 <ref name="input_choice_real"/>
2298 </element>
2299 <ref name="robin_bc_scalar"/>
2300 </choice>
2301 </element>
2302 </zeroOrMore>
2303 <!--
2304 no Diffusivity for field
2305 no source term
2306 no Absorption term
2307 no Adaptive timestepping option
2308 -->
2309 <ref name="prognostic_scalar_output_options"/>
2310 <ref name="prognostic_scalar_stat_options"/>
2311 <ref name="scalar_convergence_options"/>
2312 <ref name="prognostic_detector_options"/>
2313 <ref name="scalar_steady_state_options"/>
2314 <ref name="adaptivity_options_prognostic_scalar_field"/>
2315 <ref name="interpolation_algorithm_scalar"/>
2316 <optional>
2317 <ref name="discrete_properties_algorithm_scalar"/>
2318 </optional>
2319 </define>
2320 <!--
2321 stream function, this is a copy of prognostic_scalar_field above2051 stream function, this is a copy of prognostic_scalar_field above
2322 removing all options that don't apply (mainly advection related)2052 removing all options that don't apply (mainly advection related)
2323 -->2053 -->
23242054
=== modified file 'schemas/shallow_water_options.rnc'
--- schemas/shallow_water_options.rnc 2011-10-19 17:43:54 +0000
+++ schemas/shallow_water_options.rnc 2012-03-27 11:21:19 +0000
@@ -1909,18 +1909,6 @@
1909 attribute name { "FreeSurface" },1909 attribute name { "FreeSurface" },
1910 (1910 (
1911 ## Free Surface1911 ## Free Surface
1912 ## NOTE: the prognostic FreeSurface field only works with the
1913 ## legacy_continuous_galerkin code path
1914 element prognostic {
1915 ## Note that this is not the quadratic mesh balance pressure is
1916 ## actually calculated on, but the linear mesh it is projected back
1917 ## on for output purposes.
1918 element mesh {
1919 attribute name { "VelocityMesh" }
1920 },
1921 prognostic_free_surface_field
1922 }|
1923 ## Free Surface
1924 ## NOTE: the diagnostic FreeSurface field only works in combination1912 ## NOTE: the diagnostic FreeSurface field only works in combination
1925 ## with the free_surface boundary condition applied to the Velocity1913 ## with the free_surface boundary condition applied to the Velocity
1926 ## field. It gives you a 3D field (constant over the vertical)1914 ## field. It gives you a 3D field (constant over the vertical)
19271915
=== modified file 'schemas/shallow_water_options.rng'
--- schemas/shallow_water_options.rng 2011-10-19 17:43:54 +0000
+++ schemas/shallow_water_options.rng 2012-03-27 11:21:19 +0000
@@ -2215,42 +2215,26 @@
2215 <attribute name="name">2215 <attribute name="name">
2216 <value>FreeSurface</value>2216 <value>FreeSurface</value>
2217 </attribute>2217 </attribute>
2218 <choice>2218 <element name="diagnostic">
2219 <element name="prognostic">2219 <a:documentation>Free Surface
2220 <a:documentation>Free Surface
2221NOTE: the prognostic FreeSurface field only works with the
2222legacy_continuous_galerkin code path</a:documentation>
2223 <element name="mesh">
2224 <a:documentation>Note that this is not the quadratic mesh balance pressure is
2225actually calculated on, but the linear mesh it is projected back
2226on for output purposes.</a:documentation>
2227 <attribute name="name">
2228 <value>VelocityMesh</value>
2229 </attribute>
2230 </element>
2231 <ref name="prognostic_free_surface_field"/>
2232 </element>
2233 <element name="diagnostic">
2234 <a:documentation>Free Surface
2235NOTE: the diagnostic FreeSurface field only works in combination2220NOTE: the diagnostic FreeSurface field only works in combination
2236with the free_surface boundary condition applied to the Velocity2221with the free_surface boundary condition applied to the Velocity
2237field. It gives you a 3D field (constant over the vertical)2222field. It gives you a 3D field (constant over the vertical)
2238of the free surface elevation.</a:documentation>2223of the free surface elevation.</a:documentation>
2239 <ref name="internal_algorithm"/>2224 <ref name="internal_algorithm"/>
2240 <!--2225 <!--
2241 this is hard-coded on the PressureMesh as long as the Pressure is2226 this is hard-coded on the PressureMesh as long as the Pressure is
2242 if this is no longer true, it should be option-checked to be on the2227 if this is no longer true, it should be option-checked to be on the
2243 same mesh as Pressure2228 same mesh as Pressure
2244 -->2229 -->
2245 <element name="mesh">2230 <element name="mesh">
2246 <a:documentation>Must be on the same mesh as Pressure</a:documentation>2231 <a:documentation>Must be on the same mesh as Pressure</a:documentation>
2247 <attribute name="name">2232 <attribute name="name">
2248 <value>PressureMesh</value>2233 <value>PressureMesh</value>
2249 </attribute>2234 </attribute>
2250 </element>
2251 <ref name="diagnostic_scalar_field"/>
2252 </element>2235 </element>
2253 </choice>2236 <ref name="diagnostic_scalar_field"/>
2237 </element>
2254 </element>2238 </element>
2255 <element name="scalar_field">2239 <element name="scalar_field">
2256 <a:documentation>Second Fluid</a:documentation>2240 <a:documentation>Second Fluid</a:documentation>
22572241
=== modified file 'schemas/test_advection_diffusion_options.rnc'
--- schemas/test_advection_diffusion_options.rnc 2011-10-19 17:43:54 +0000
+++ schemas/test_advection_diffusion_options.rnc 2012-03-27 11:21:19 +0000
@@ -1755,235 +1755,6 @@
1755 discrete_properties_algorithm_scalar?1755 discrete_properties_algorithm_scalar?
1756 )1756 )
1757 1757
1758# free surface field, this is a copy of prognostic_scalar_field above
1759# removing all options that don't apply (mainly advection related)
1760prognostic_free_surface_field =
1761 (
1762 (
1763 ## Spatial discretisation options
1764 element spatial_discretisation {
1765 ## Form a full 3D system for the free surface
1766 element free_surface_3D {
1767 empty
1768 }?,
1769 element fourth_order_dissipation {
1770 empty
1771 }?,
1772 ## low order (linear) free surface
1773 element low_order_free_surface {
1774 empty
1775 }?,
1776 (
1777 ## Select free surface filter
1778 ##
1779 ## With PN-PN we need some filter to supress spurious modes.
1780 element default_free_surface_filter {
1781 empty
1782 }|
1783 ## Select free surface filter
1784 ##
1785 ## With PN-PN we need some filter to supress spurious modes.
1786 element user_specified_free_surface_filter {
1787 ## Default is to apply 0.01 and for wetting and drying cases 1.0
1788 element non_linear_filter_coefficient {
1789 real
1790 }
1791 }|
1792 ## Switch off free surface filter, this is more efficient than setting the coefficient to 0.
1793 element switch_off_free_surface_filter {
1794 empty
1795 }
1796 ),
1797 ## Apply wetting and drying routines
1798 element wetting_drying {
1799 empty
1800 }?,
1801 ## Tidal forcing options
1802 element tidal_forcing {
1803 ## M2
1804 element M2 {
1805 empty
1806 }?,
1807 ## S2
1808 element S2 {
1809 empty
1810 }?,
1811 ## N2
1812 element N2 {
1813 empty
1814 }?,
1815 ## K2
1816 element K2 {
1817 empty
1818 }?,
1819 ## K1
1820 element K1 {
1821 empty
1822 }?,
1823 ## O1
1824 element O1 {
1825 empty
1826 }?,
1827 ## P1
1828 element P1 {
1829 empty
1830 }?,
1831 ## Q1
1832 element Q1 {
1833 empty
1834 }?,
1835 ## Switch on all tidal components
1836 element all_tidal_components {
1837 empty
1838 }?,
1839 ## Switches on a Love number of 0.3
1840 element love_number {
1841 empty
1842 }?,
1843 ## Use static tidal force for testing
1844 element static_tidal_force {
1845 empty
1846 }?
1847 }?
1848 }|
1849 ## Legacy Free Surface
1850 ## Allows astronomical forcing for multiple tidal constituents.
1851 ## Integer should be sum of desired components as follows:
1852 ##
1853 ## 3D Free Surface = 1
1854 ##
1855 ## Fourth Order Dissipation = 4
1856 ##
1857 ## Low Order Free Surface = 8
1858 ##
1859 ## Implicit absorption in the free surface (good for wetting/drying) = 16
1860 ##
1861 ## Turn on all tides = 32
1862 ##
1863 ## Love Number = 64
1864 ##
1865 ## Static Tidal Force = 128
1866 ##
1867 ## M2 constituent = 2048
1868 ##
1869 ## S2 constituent = 4096
1870 ##
1871 ## N2 constituent = 8192
1872 ##
1873 ## K2 constituent = 16384
1874 ##
1875 ## K1 constituent = 32768
1876 ##
1877 ## O1 constituent = 65536
1878 ##
1879 ## P1 constituent = 131072
1880 ##
1881 ## Q1 constituent = 262144
1882 element Legacy_Free_Surface {
1883 integer
1884 }
1885 ),
1886 # atheta, ctheta and fstheta (absorption, coriolis and free surface)
1887 # need to go in temporal discretisation
1888 # they are currently hard-coded however
1889 element temporal_discretisation {
1890 ## Implicit/explicitness for the free surface.
1891 ##
1892 ## Suggested value 1.0 (should be at least bigger than 0.5).
1893 ## =0. -- explicit
1894 ## =0.5 -- Crank-Nicolson
1895 ## =1. -- implicit
1896 element theta {
1897 real
1898 },
1899 # Maybe this should go under a proper absorption field under free surface?
1900 ## Implicit/explicitness for absorption
1901 ## =0. -- explicit (default)
1902 ## =0.5 -- Crank-Nicolson
1903 ## =1. -- implicit
1904 element absorption_theta {
1905 real
1906 }?
1907 },
1908 ## Solver
1909 element solver {
1910 linear_solver_options_sym
1911 },
1912 (
1913 ## Initial condition for WholeMesh
1914 ##
1915 ## Only specify one condition if not using mesh regions.
1916 ## Otherwise select other initial_condition option, specify region_ids
1917 ## and distinct names. Then add extra intial conditions for other regions.
1918 element initial_condition {
1919 attribute name { "WholeMesh" },
1920 input_choice_initial_condition_real
1921 }|
1922 ## Multiple initial_conditions are allowed if specifying
1923 ## different values in different
1924 ## regions of the mesh (defined by region_ids). In this case
1925 ## each initial_condition
1926 ## requires a distinct name for the options dictionary.
1927 element initial_condition {
1928 attribute name { string },
1929 region_ids,
1930 input_choice_initial_condition_real
1931 }
1932 )+,
1933 ## Boundary conditions
1934 element boundary_conditions {
1935 attribute name { string },
1936 ## Surface id:
1937 element surface_ids {
1938 integer_vector
1939 },
1940 ## Type
1941 (
1942 element type {
1943 attribute name { "dirichlet" },
1944 (
1945 input_choice_real_contents|
1946 element from_file {
1947 element tidal {
1948 attribute file_name { string },
1949 attribute variable_name_amplitude { string },
1950 attribute variable_name_phase { string },
1951 ## See E.W. Schwiderski - Rev. Geophys. Space
1952 ## Phys. Vol. 18 No. 1 pp. 243--268, 1980
1953 ## for details of these constituent.
1954 attribute name {"M2"|"S2"|"N2"|"K2"|"K1"|"O1"|"P1"|"Q1"|"Mf"|"Mm"|"Ssa"}
1955 }+
1956 }
1957 )
1958 }|
1959 element type {
1960 attribute name { "neumann" },
1961 input_choice_real
1962 }|
1963 element type {
1964 attribute name { "robin" },
1965 element order_zero_coefficient {
1966 input_choice_real
1967 },
1968 element order_one_coefficient {
1969 input_choice_real
1970 }
1971 }
1972 )
1973 }*,
1974 # no Diffusivity for field
1975 # no source term
1976 # no Absorption term
1977 # no Adaptive timestepping option
1978 prognostic_scalar_output_options,
1979 prognostic_scalar_stat_options,
1980 scalar_convergence_options,
1981 prognostic_detector_options,
1982 scalar_steady_state_options,
1983 adaptivity_options_prognostic_scalar_field,
1984 interpolation_algorithm_scalar,
1985 discrete_properties_algorithm_scalar?
1986 )
19871758
1988# stream function, this is a copy of prognostic_scalar_field above1759# stream function, this is a copy of prognostic_scalar_field above
1989# removing all options that don't apply (mainly advection related)1760# removing all options that don't apply (mainly advection related)
@@ -3345,18 +3116,6 @@
3345 attribute name { "FreeSurface" },3116 attribute name { "FreeSurface" },
3346 (3117 (
3347 ## Free Surface3118 ## Free Surface
3348 ## NOTE: the prognostic FreeSurface field only works with the
3349 ## legacy_continuous_galerkin code path
3350 element prognostic {
3351 ## Note that this is not the quadratic mesh balance pressure is
3352 ## actually calculated on, but the linear mesh it is projected back
3353 ## on for output purposes.
3354 element mesh {
3355 attribute name { "VelocityMesh" }
3356 },
3357 prognostic_free_surface_field
3358 }|
3359 ## Free Surface
3360 ## NOTE: the diagnostic FreeSurface field only works in combination3119 ## NOTE: the diagnostic FreeSurface field only works in combination
3361 ## with the free_surface boundary condition applied to the Velocity3120 ## with the free_surface boundary condition applied to the Velocity
3362 ## field. It gives you a 3D field (constant over the vertical)3121 ## field. It gives you a 3D field (constant over the vertical)
33633122
=== modified file 'schemas/test_advection_diffusion_options.rng'
--- schemas/test_advection_diffusion_options.rng 2011-10-19 17:43:54 +0000
+++ schemas/test_advection_diffusion_options.rng 2012-03-27 11:21:19 +0000
@@ -2075,314 +2075,6 @@
2075 </optional>2075 </optional>
2076 </define>2076 </define>
2077 <!--2077 <!--
2078 free surface field, this is a copy of prognostic_scalar_field above
2079 removing all options that don't apply (mainly advection related)
2080 -->
2081 <define name="prognostic_free_surface_field">
2082 <choice>
2083 <element name="spatial_discretisation">
2084 <a:documentation>Spatial discretisation options</a:documentation>
2085 <optional>
2086 <element name="free_surface_3D">
2087 <a:documentation>Form a full 3D system for the free surface</a:documentation>
2088 <empty/>
2089 </element>
2090 </optional>
2091 <optional>
2092 <element name="fourth_order_dissipation">
2093 <empty/>
2094 </element>
2095 </optional>
2096 <optional>
2097 <element name="low_order_free_surface">
2098 <a:documentation>low order (linear) free surface</a:documentation>
2099 <empty/>
2100 </element>
2101 </optional>
2102 <choice>
2103 <element name="default_free_surface_filter">
2104 <a:documentation>Select free surface filter
2105
2106With PN-PN we need some filter to supress spurious modes.</a:documentation>
2107 <empty/>
2108 </element>
2109 <element name="user_specified_free_surface_filter">
2110 <a:documentation>Select free surface filter
2111
2112With PN-PN we need some filter to supress spurious modes.</a:documentation>
2113 <element name="non_linear_filter_coefficient">
2114 <a:documentation>Default is to apply 0.01 and for wetting and drying cases 1.0</a:documentation>
2115 <ref name="real"/>
2116 </element>
2117 </element>
2118 <element name="switch_off_free_surface_filter">
2119 <a:documentation>Switch off free surface filter, this is more efficient than setting the coefficient to 0.</a:documentation>
2120 <empty/>
2121 </element>
2122 </choice>
2123 <optional>
2124 <element name="wetting_drying">
2125 <a:documentation>Apply wetting and drying routines</a:documentation>
2126 <empty/>
2127 </element>
2128 </optional>
2129 <optional>
2130 <element name="tidal_forcing">
2131 <a:documentation>Tidal forcing options </a:documentation>
2132 <optional>
2133 <element name="M2">
2134 <a:documentation>M2</a:documentation>
2135 <empty/>
2136 </element>
2137 </optional>
2138 <optional>
2139 <element name="S2">
2140 <a:documentation>S2</a:documentation>
2141 <empty/>
2142 </element>
2143 </optional>
2144 <optional>
2145 <element name="N2">
2146 <a:documentation>N2</a:documentation>
2147 <empty/>
2148 </element>
2149 </optional>
2150 <optional>
2151 <element name="K2">
2152 <a:documentation>K2</a:documentation>
2153 <empty/>
2154 </element>
2155 </optional>
2156 <optional>
2157 <element name="K1">
2158 <a:documentation>K1</a:documentation>
2159 <empty/>
2160 </element>
2161 </optional>
2162 <optional>
2163 <element name="O1">
2164 <a:documentation>O1</a:documentation>
2165 <empty/>
2166 </element>
2167 </optional>
2168 <optional>
2169 <element name="P1">
2170 <a:documentation>P1</a:documentation>
2171 <empty/>
2172 </element>
2173 </optional>
2174 <optional>
2175 <element name="Q1">
2176 <a:documentation>Q1</a:documentation>
2177 <empty/>
2178 </element>
2179 </optional>
2180 <optional>
2181 <element name="all_tidal_components">
2182 <a:documentation>Switch on all tidal components</a:documentation>
2183 <empty/>
2184 </element>
2185 </optional>
2186 <optional>
2187 <element name="love_number">
2188 <a:documentation>Switches on a Love number of 0.3</a:documentation>
2189 <empty/>
2190 </element>
2191 </optional>
2192 <optional>
2193 <element name="static_tidal_force">
2194 <a:documentation>Use static tidal force for testing</a:documentation>
2195 <empty/>
2196 </element>
2197 </optional>
2198 </element>
2199 </optional>
2200 </element>
2201 <element name="Legacy_Free_Surface">
2202 <a:documentation>Legacy Free Surface
2203Allows astronomical forcing for multiple tidal constituents.
2204Integer should be sum of desired components as follows:
2205
22063D Free Surface = 1
2207
2208Fourth Order Dissipation = 4
2209
2210Low Order Free Surface = 8
2211
2212Implicit absorption in the free surface (good for wetting/drying) = 16
2213
2214Turn on all tides = 32
2215
2216Love Number = 64
2217
2218Static Tidal Force = 128
2219
2220M2 constituent = 2048
2221
2222S2 constituent = 4096
2223
2224N2 constituent = 8192
2225
2226K2 constituent = 16384
2227
2228K1 constituent = 32768
2229
2230O1 constituent = 65536
2231
2232P1 constituent = 131072
2233
2234Q1 constituent = 262144</a:documentation>
2235 <ref name="integer"/>
2236 </element>
2237 </choice>
2238 <!--
2239 atheta, ctheta and fstheta (absorption, coriolis and free surface)
2240 need to go in temporal discretisation
2241 they are currently hard-coded however
2242 -->
2243 <element name="temporal_discretisation">
2244 <element name="theta">
2245 <a:documentation>Implicit/explicitness for the free surface.
2246
2247Suggested value 1.0 (should be at least bigger than 0.5).
2248 =0. -- explicit
2249 =0.5 -- Crank-Nicolson
2250 =1. -- implicit</a:documentation>
2251 <ref name="real"/>
2252 </element>
2253 <optional>
2254 <!-- Maybe this should go under a proper absorption field under free surface? -->
2255 <element name="absorption_theta">
2256 <a:documentation>Implicit/explicitness for absorption
2257=0. -- explicit (default)
2258=0.5 -- Crank-Nicolson
2259=1. -- implicit</a:documentation>
2260 <ref name="real"/>
2261 </element>
2262 </optional>
2263 </element>
2264 <element name="solver">
2265 <a:documentation>Solver</a:documentation>
2266 <ref name="linear_solver_options_sym"/>
2267 </element>
2268 <oneOrMore>
2269 <choice>
2270 <element name="initial_condition">
2271 <a:documentation>Initial condition for WholeMesh
2272
2273Only specify one condition if not using mesh regions.
2274Otherwise select other initial_condition option, specify region_ids
2275and distinct names. Then add extra intial conditions for other regions.</a:documentation>
2276 <attribute name="name">
2277 <value>WholeMesh</value>
2278 </attribute>
2279 <ref name="input_choice_initial_condition_real"/>
2280 </element>
2281 <element name="initial_condition">
2282 <a:documentation>Multiple initial_conditions are allowed if specifying
2283different values in different
2284regions of the mesh (defined by region_ids). In this case
2285each initial_condition
2286requires a distinct name for the options dictionary.</a:documentation>
2287 <attribute name="name">
2288 <data type="string" datatypeLibrary=""/>
2289 </attribute>
2290 <ref name="region_ids"/>
2291 <ref name="input_choice_initial_condition_real"/>
2292 </element>
2293 </choice>
2294 </oneOrMore>
2295 <zeroOrMore>
2296 <element name="boundary_conditions">
2297 <a:documentation>Boundary conditions</a:documentation>
2298 <attribute name="name">
2299 <data type="string" datatypeLibrary=""/>
2300 </attribute>
2301 <element name="surface_ids">
2302 <a:documentation>Surface id:</a:documentation>
2303 <ref name="integer_vector"/>
2304 </element>
2305 <choice>
2306 <a:documentation>Type</a:documentation>
2307 <element name="type">
2308 <attribute name="name">
2309 <value>dirichlet</value>
2310 </attribute>
2311 <choice>
2312 <ref name="input_choice_real_contents"/>
2313 <element name="from_file">
2314 <oneOrMore>
2315 <element name="tidal">
2316 <attribute name="file_name">
2317 <data type="string" datatypeLibrary=""/>
2318 </attribute>
2319 <attribute name="variable_name_amplitude">
2320 <data type="string" datatypeLibrary=""/>
2321 </attribute>
2322 <attribute name="variable_name_phase">
2323 <data type="string" datatypeLibrary=""/>
2324 </attribute>
2325 <attribute name="name">
2326 <a:documentation>See E.W. Schwiderski - Rev. Geophys. Space
2327Phys. Vol. 18 No. 1 pp. 243--268, 1980
2328for details of these constituent.</a:documentation>
2329 <choice>
2330 <value>M2</value>
2331 <value>S2</value>
2332 <value>N2</value>
2333 <value>K2</value>
2334 <value>K1</value>
2335 <value>O1</value>
2336 <value>P1</value>
2337 <value>Q1</value>
2338 <value>Mf</value>
2339 <value>Mm</value>
2340 <value>Ssa</value>
2341 </choice>
2342 </attribute>
2343 </element>
2344 </oneOrMore>
2345 </element>
2346 </choice>
2347 </element>
2348 <element name="type">
2349 <attribute name="name">
2350 <value>neumann</value>
2351 </attribute>
2352 <ref name="input_choice_real"/>
2353 </element>
2354 <element name="type">
2355 <attribute name="name">
2356 <value>robin</value>
2357 </attribute>
2358 <element name="order_zero_coefficient">
2359 <ref name="input_choice_real"/>
2360 </element>
2361 <element name="order_one_coefficient">
2362 <ref name="input_choice_real"/>
2363 </element>
2364 </element>
2365 </choice>
2366 </element>
2367 </zeroOrMore>
2368 <!--
2369 no Diffusivity for field
2370 no source term
2371 no Absorption term
2372 no Adaptive timestepping option
2373 -->
2374 <ref name="prognostic_scalar_output_options"/>
2375 <ref name="prognostic_scalar_stat_options"/>
2376 <ref name="scalar_convergence_options"/>
2377 <ref name="prognostic_detector_options"/>
2378 <ref name="scalar_steady_state_options"/>
2379 <ref name="adaptivity_options_prognostic_scalar_field"/>
2380 <ref name="interpolation_algorithm_scalar"/>
2381 <optional>
2382 <ref name="discrete_properties_algorithm_scalar"/>
2383 </optional>
2384 </define>
2385 <!--
2386 stream function, this is a copy of prognostic_scalar_field above2078 stream function, this is a copy of prognostic_scalar_field above
2387 removing all options that don't apply (mainly advection related)2079 removing all options that don't apply (mainly advection related)
2388 -->2080 -->
@@ -3943,42 +3635,26 @@
3943 <attribute name="name">3635 <attribute name="name">
3944 <value>FreeSurface</value>3636 <value>FreeSurface</value>
3945 </attribute>3637 </attribute>
3946 <choice>3638 <element name="diagnostic">
3947 <element name="prognostic">3639 <a:documentation>Free Surface
3948 <a:documentation>Free Surface
3949NOTE: the prognostic FreeSurface field only works with the
3950legacy_continuous_galerkin code path</a:documentation>
3951 <element name="mesh">
3952 <a:documentation>Note that this is not the quadratic mesh balance pressure is
3953actually calculated on, but the linear mesh it is projected back
3954on for output purposes.</a:documentation>
3955 <attribute name="name">
3956 <value>VelocityMesh</value>
3957 </attribute>
3958 </element>
3959 <ref name="prognostic_free_surface_field"/>
3960 </element>
3961 <element name="diagnostic">
3962 <a:documentation>Free Surface
3963NOTE: the diagnostic FreeSurface field only works in combination3640NOTE: the diagnostic FreeSurface field only works in combination
3964with the free_surface boundary condition applied to the Velocity3641with the free_surface boundary condition applied to the Velocity
3965field. It gives you a 3D field (constant over the vertical)3642field. It gives you a 3D field (constant over the vertical)
3966of the free surface elevation.</a:documentation>3643of the free surface elevation.</a:documentation>
3967 <ref name="internal_algorithm"/>3644 <ref name="internal_algorithm"/>
3968 <!--3645 <!--
3969 this is hard-coded on the PressureMesh as long as the Pressure is3646 this is hard-coded on the PressureMesh as long as the Pressure is
3970 if this is no longer true, it should be option-checked to be on the3647 if this is no longer true, it should be option-checked to be on the
3971 same mesh as Pressure3648 same mesh as Pressure
3972 -->3649 -->
3973 <element name="mesh">3650 <element name="mesh">
3974 <a:documentation>Must be on the same mesh as Pressure</a:documentation>3651 <a:documentation>Must be on the same mesh as Pressure</a:documentation>
3975 <attribute name="name">3652 <attribute name="name">
3976 <value>PressureMesh</value>3653 <value>PressureMesh</value>
3977 </attribute>3654 </attribute>
3978 </element>
3979 <ref name="diagnostic_scalar_field"/>
3980 </element>3655 </element>
3981 </choice>3656 <ref name="diagnostic_scalar_field"/>
3657 </element>
3982 </element>3658 </element>
3983 <element name="scalar_field">3659 <element name="scalar_field">
3984 <a:documentation>Second Fluid</a:documentation>3660 <a:documentation>Second Fluid</a:documentation>
39853661
=== added directory 'tests/sample_netcdf_test'
=== added file 'tests/sample_netcdf_test/Makefile'
--- tests/sample_netcdf_test/Makefile 1970-01-01 00:00:00 +0000
+++ tests/sample_netcdf_test/Makefile 2012-03-27 11:21:19 +0000
@@ -0,0 +1,9 @@
1input: clean
2 ./create_netcdf_test.py
3 gmsh -2 src/box_on_sphere.geo -o box_on_sphere.msh
4 ../../bin/gmsh2triangle box_on_sphere.msh
5 sed -i '1s/ 3 / 2 /' box_on_sphere.node
6
7clean:
8 rm -f box_on_sphere.* fluidity.* netcdf_test.nc
9 rm -f sample*.vtu sample.stat matrixdump*
010
=== added file 'tests/sample_netcdf_test/create_netcdf_test.py'
--- tests/sample_netcdf_test/create_netcdf_test.py 1970-01-01 00:00:00 +0000
+++ tests/sample_netcdf_test/create_netcdf_test.py 2012-03-27 11:21:19 +0000
@@ -0,0 +1,70 @@
1#!/usr/bin/env python
2from math import cos, sin, pi
3
4lonl=-10.0
5lonr=0.0
6lonres=0.5
7latl=40.0
8latr=60.0
9latres=0.5
10
11
12# the following 3 functions will also be used from the fluidity run:
13# made up tidal amplitude
14def amplitude(lon, lat):
15 return cos(pi*4*lon/180)*sin(pi*4*lat/180)
16
17# made up phase (contains 360 degree line within domain)
18def phase(lon,lat):
19 ph= ((latl+latr)/2.0-lat)*10
20 if lat<(latl+latr)/2.0:
21 return ph
22 else:
23 return ph+360
24
25# auxillary function to compute lon,lat from xyz (taken from fluidity code)
26def lonlat(xyz):
27 from math import pi,atan2,sqrt,acos
28 r=sqrt(xyz[0]**2+xyz[1]**2+xyz[2]**2)
29 lon=180.0/pi*atan2(xyz[1],xyz[0])
30 lat=90.0-180.0/pi*acos(xyz[2]/r)
31 return lon,lat
32
33# add a field (variable) to the netcdf file
34def add_field(nc, name, dims, val):
35 import numpy
36 nc.createVariable(name, 'f', dims)
37 var=nc.variables[name]
38 # make sure to cast to numpy array of float type
39 val=numpy.array(val, dtype='float32')
40 var[:]=val
41 var.long_name=name
42 var.actual_range=(val.min(), val.max())
43
44def create_netcdf(filename):
45 from Scientific.IO.NetCDF import NetCDFFile
46 from numpy import arange
47 nc=NetCDFFile(filename, 'w')
48 lonrange=arange(lonl,lonr+lonres/10.,lonres,dtype='float32')
49 latrange=arange(latl,latr+latres/10.,latres,dtype='float32')
50 nc.createDimension('longitude', len(lonrange))
51 nc.createDimension('latitude', len(latrange))
52
53 # add the variables
54 add_field(nc, 'longitude', ('longitude',), lonrange)
55 add_field(nc, 'latitude', ('latitude',), latrange)
56 # note that fields have to be f(lat,lon) as this a hard-coded assumption
57 # in our NetCDF reader
58 add_field(nc, 'amplitude', ('latitude','longitude'),
59 [[amplitude(lon,lat) for lon in lonrange] for lat in latrange])
60 add_field(nc, 'phase', ('latitude','longitude'),
61 [[phase(lon,lat) for lon in lonrange] for lat in latrange])
62
63 # finally set some global attributes
64 nc.Conventions='COARDS/CF-1.0'
65 nc.history='Test netCDF file created with create_netcdf_test.py script'
66
67 nc.close()
68
69if __name__ == "__main__":
70 create_netcdf('netcdf_test.nc')
071
=== added file 'tests/sample_netcdf_test/sample.flml'
--- tests/sample_netcdf_test/sample.flml 1970-01-01 00:00:00 +0000
+++ tests/sample_netcdf_test/sample.flml 2012-03-27 11:21:19 +0000
@@ -0,0 +1,658 @@
1<?xml version='1.0' encoding='utf-8'?>
2<fluidity_options>
3 <simulation_name>
4 <string_value lines="1">sample</string_value>
5 </simulation_name>
6 <problem_type>
7 <string_value lines="1">oceans</string_value>
8 </problem_type>
9 <geometry>
10 <dimension>
11 <integer_value rank="0">3</integer_value>
12 </dimension>
13 <mesh name="CoordinateMesh">
14 <from_mesh>
15 <mesh name="InputMesh"/>
16 <extrude>
17 <regions name="WholeMesh">
18 <bottom_depth>
19 <constant>
20 <real_value rank="0">200</real_value>
21 </constant>
22 </bottom_depth>
23 <sizing_function>
24 <constant>
25 <real_value rank="0">10000</real_value>
26 </constant>
27 </sizing_function>
28 <top_surface_id>
29 <integer_value rank="0">1</integer_value>
30 </top_surface_id>
31 <bottom_surface_id>
32 <integer_value rank="0">2</integer_value>
33 </bottom_surface_id>
34 </regions>
35 </extrude>
36 <stat>
37 <exclude_from_stat/>
38 </stat>
39 </from_mesh>
40 </mesh>
41 <mesh name="VelocityMesh">
42 <from_mesh>
43 <mesh name="CoordinateMesh"/>
44 <mesh_continuity>
45 <string_value>discontinuous</string_value>
46 </mesh_continuity>
47 <stat>
48 <exclude_from_stat/>
49 </stat>
50 </from_mesh>
51 </mesh>
52 <mesh name="PressureMesh">
53 <from_mesh>
54 <mesh name="CoordinateMesh"/>
55 <mesh_shape>
56 <polynomial_degree>
57 <integer_value rank="0">2</integer_value>
58 </polynomial_degree>
59 </mesh_shape>
60 <stat>
61 <exclude_from_stat/>
62 </stat>
63 </from_mesh>
64 </mesh>
65 <mesh name="InputMesh">
66 <from_file file_name="box_on_sphere">
67 <format name="triangle"/>
68 <stat>
69 <include_in_stat/>
70 </stat>
71 </from_file>
72 </mesh>
73 <quadrature>
74 <degree>
75 <integer_value rank="0">4</integer_value>
76 </degree>
77 </quadrature>
78 <spherical_earth>
79 <linear_mapping/>
80 </spherical_earth>
81 <ocean_boundaries>
82 <top_surface_ids>
83 <integer_value shape="1" rank="1">1</integer_value>
84 </top_surface_ids>
85 <bottom_surface_ids>
86 <integer_value shape="1" rank="1">2</integer_value>
87 </bottom_surface_ids>
88 <scalar_field name="DistanceToTop" rank="0">
89 <diagnostic>
90 <algorithm name="Internal" material_phase_support="multiple"/>
91 <mesh name="CoordinateMesh"/>
92 <output/>
93 <stat/>
94 <convergence>
95 <include_in_convergence/>
96 </convergence>
97 <detectors>
98 <include_in_detectors/>
99 </detectors>
100 <steady_state>
101 <include_in_steady_state/>
102 </steady_state>
103 </diagnostic>
104 </scalar_field>
105 <scalar_field name="DistanceToBottom" rank="0">
106 <diagnostic>
107 <algorithm name="Internal" material_phase_support="multiple"/>
108 <mesh name="CoordinateMesh"/>
109 <output/>
110 <stat/>
111 <convergence>
112 <include_in_convergence/>
113 </convergence>
114 <detectors>
115 <include_in_detectors/>
116 </detectors>
117 <steady_state>
118 <include_in_steady_state/>
119 </steady_state>
120 </diagnostic>
121 </scalar_field>
122 </ocean_boundaries>
123 </geometry>
124 <io>
125 <dump_format>
126 <string_value>vtk</string_value>
127 </dump_format>
128 <dump_period_in_timesteps>
129 <constant>
130 <integer_value rank="0">1</integer_value>
131 </constant>
132 </dump_period_in_timesteps>
133 <output_mesh name="VelocityMesh"/>
134 <stat/>
135 </io>
136 <timestepping>
137 <current_time>
138 <real_value rank="0">0</real_value>
139 <time_units date="seconds since 1987-01-05 00:00.0"/>
140 </current_time>
141 <timestep>
142 <real_value rank="0">1200</real_value>
143 </timestep>
144 <finish_time>
145 <real_value rank="0">86400</real_value>
146 </finish_time>
147 <final_timestep>
148 <integer_value rank="0">10</integer_value>
149 </final_timestep>
150 <nonlinear_iterations>
151 <integer_value rank="0">2</integer_value>
152 </nonlinear_iterations>
153 </timestepping>
154 <physical_parameters>
155 <gravity>
156 <magnitude>
157 <real_value rank="0">9.81</real_value>
158 </magnitude>
159 <vector_field name="GravityDirection" rank="1">
160 <prescribed>
161 <mesh name="CoordinateMesh"/>
162 <value name="WholeMesh">
163 <python>
164 <string_value lines="20" type="python">def val(X, t):
165
166 a = X[0]
167 b = X[1]
168 c = X[2]
169
170 x_component = -(a/((a**2+b**2+c**2)**0.5))
171 y_component = -(b/((a**2+b**2+c**2)**0.5))
172 z_component = -(c/((a**2+b**2+c**2)**0.5))
173
174 return [x_component, y_component, z_component]</string_value>
175 </python>
176 </value>
177 <output/>
178 <stat>
179 <include_in_stat/>
180 </stat>
181 <detectors>
182 <exclude_from_detectors/>
183 </detectors>
184 </prescribed>
185 </vector_field>
186 </gravity>
187 <coriolis>
188 <on_sphere>
189 <omega>
190 <real_value rank="0">7.27220522e-5</real_value>
191 </omega>
192 </on_sphere>
193 </coriolis>
194 </physical_parameters>
195 <material_phase name="Ocean">
196 <equation_of_state>
197 <fluids>
198 <linear>
199 <reference_density>
200 <real_value rank="0">1</real_value>
201 </reference_density>
202 <subtract_out_hydrostatic_level/>
203 </linear>
204 </fluids>
205 </equation_of_state>
206 <scalar_field name="Pressure" rank="0">
207 <prognostic>
208 <mesh name="PressureMesh"/>
209 <spatial_discretisation>
210 <continuous_galerkin>
211 <remove_stabilisation_term/>
212 <integrate_continuity_by_parts/>
213 </continuous_galerkin>
214 </spatial_discretisation>
215 <scheme>
216 <poisson_pressure_solution>
217 <string_value lines="1">only first timestep</string_value>
218 </poisson_pressure_solution>
219 <use_projection_method/>
220 </scheme>
221 <solver>
222 <iterative_method name="cg"/>
223 <preconditioner name="mg">
224 <vertical_lumping/>
225 </preconditioner>
226 <relative_error>
227 <real_value rank="0">1.0e-7</real_value>
228 </relative_error>
229 <max_iterations>
230 <integer_value rank="0">1700</integer_value>
231 </max_iterations>
232 <never_ignore_solver_failures/>
233 <diagnostics>
234 <monitors/>
235 </diagnostics>
236 </solver>
237 <initial_condition name="WholeMesh">
238 <constant>
239 <real_value rank="0">0.0</real_value>
240 </constant>
241 </initial_condition>
242 <boundary_conditions name="BoundaryTide">
243 <surface_ids>
244 <integer_value shape="4" rank="1">1009 1010 1011 1012</integer_value>
245 </surface_ids>
246 <type name="dirichlet">
247 <from_file>
248 <tidal file_name="netcdf_test.nc" variable_name_amplitude="amplitude" name="M2" variable_name_phase="phase"/>
249 </from_file>
250 </type>
251 </boundary_conditions>
252 <output/>
253 <stat/>
254 <convergence>
255 <include_in_convergence/>
256 </convergence>
257 <detectors>
258 <exclude_from_detectors/>
259 </detectors>
260 <steady_state>
261 <include_in_steady_state/>
262 </steady_state>
263 <consistent_interpolation/>
264 </prognostic>
265 </scalar_field>
266 <vector_field name="Velocity" rank="1">
267 <prognostic>
268 <mesh name="VelocityMesh"/>
269 <equation name="Boussinesq"/>
270 <spatial_discretisation>
271 <discontinuous_galerkin>
272 <mass_terms/>
273 <viscosity_scheme>
274 <compact_discontinuous_galerkin/>
275 </viscosity_scheme>
276 <advection_scheme>
277 <upwind/>
278 <project_velocity_to_continuous>
279 <mesh name="CoordinateMesh"/>
280 </project_velocity_to_continuous>
281 <integrate_advection_by_parts>
282 <twice/>
283 </integrate_advection_by_parts>
284 </advection_scheme>
285 </discontinuous_galerkin>
286 <conservative_advection>
287 <real_value rank="0">0.0</real_value>
288 </conservative_advection>
289 </spatial_discretisation>
290 <temporal_discretisation>
291 <theta>
292 <real_value rank="0">0.5</real_value>
293 </theta>
294 <relaxation>
295 <real_value rank="0">0.5</real_value>
296 </relaxation>
297 <theta_divergence>
298 <real_value rank="0">1.0</real_value>
299 </theta_divergence>
300 <discontinuous_galerkin>
301 <maximum_courant_number_per_subcycle>
302 <real_value rank="0">0.1</real_value>
303 </maximum_courant_number_per_subcycle>
304 </discontinuous_galerkin>
305 </temporal_discretisation>
306 <solver>
307 <iterative_method name="gmres">
308 <restart>
309 <integer_value rank="0">30</integer_value>
310 </restart>
311 </iterative_method>
312 <preconditioner name="sor"/>
313 <relative_error>
314 <real_value rank="0">1.0e-7</real_value>
315 </relative_error>
316 <max_iterations>
317 <integer_value rank="0">10000</integer_value>
318 </max_iterations>
319 <never_ignore_solver_failures/>
320 <diagnostics>
321 <monitors/>
322 </diagnostics>
323 </solver>
324 <initial_condition name="WholeMesh">
325 <constant>
326 <real_value shape="3" dim1="dim" rank="1">0.0 0.0 0.0</real_value>
327 </constant>
328 </initial_condition>
329 <boundary_conditions name="drag_on_bottom_and_sides">
330 <surface_ids>
331 <integer_value shape="5" rank="1">2 1009 1010 1011 1012</integer_value>
332 </surface_ids>
333 <type name="drag">
334 <constant>
335 <real_value rank="0">0.0025</real_value>
336 </constant>
337 <quadratic_drag/>
338 </type>
339 </boundary_conditions>
340 <boundary_conditions name="FreeSurface">
341 <surface_ids>
342 <integer_value shape="1" rank="1">1</integer_value>
343 </surface_ids>
344 <type name="free_surface"/>
345 </boundary_conditions>
346 <boundary_conditions name="NoNormalFlow">
347 <surface_ids>
348 <integer_value shape="5" rank="1">2 1009 1010 1011 1012</integer_value>
349 </surface_ids>
350 <type name="no_normal_flow"/>
351 </boundary_conditions>
352 <tensor_field name="Viscosity" rank="2">
353 <prescribed>
354 <value name="WholeMesh">
355 <anisotropic_symmetric>
356 <python>
357 <string_value lines="20" type="python">def val(X, t):
358 a = X[0]
359 b = X[1]
360 c = X[2]
361 from math import sqrt, sin, cos, atan2, acos
362 r=sqrt(a**2+b**2+c**2)
363 A1=200.0
364 A2=A1
365 A3=0.1
366 phi=atan2(b,a)
367 theta=acos(c/r)
368 T11=A1*sin(phi)**2+A2*cos(theta)**2*cos(phi)**2+A3*sin(theta)**2*cos(phi)**2
369 T12=-A1*sin(phi)*cos(phi)+A2*cos(theta)**2*sin(phi)*cos(phi)+A3*sin(theta)**2*sin(phi)*cos(phi)
370 T13=-A2*sin(theta)*cos(theta)*cos(phi)+A3*sin(theta)*cos(theta)*cos(phi)
371 T21=T12
372 T22=A1*cos(phi)**2+A2*cos(theta)**2*sin(phi)**2+A3*sin(theta)**2*sin(phi)**2
373 T23=-A2*sin(theta)*cos(theta)*sin(phi)+A3*sin(theta)*cos(theta)*sin(phi)
374 T31=T13
375 T32=T23
376 T33=A2*sin(theta)**2+A3*cos(theta)**2
377
378 return [[T11, T12, T13],
379 [T21, T22, T23],
380 [T31, T32, T33]]</string_value>
381 </python>
382 </anisotropic_symmetric>
383 </value>
384 <output/>
385 </prescribed>
386 </tensor_field>
387 <output/>
388 <stat>
389 <include_in_stat/>
390 <previous_time_step>
391 <exclude_from_stat/>
392 </previous_time_step>
393 <nonlinear_field>
394 <exclude_from_stat/>
395 </nonlinear_field>
396 </stat>
397 <convergence>
398 <include_in_convergence/>
399 </convergence>
400 <detectors>
401 <include_in_detectors/>
402 </detectors>
403 <steady_state>
404 <include_in_steady_state/>
405 </steady_state>
406 <consistent_interpolation/>
407 </prognostic>
408 </vector_field>
409 <scalar_field name="DG_CourantNumber" rank="0">
410 <diagnostic>
411 <algorithm name="Internal" material_phase_support="multiple"/>
412 <mesh name="VelocityMesh"/>
413 <output/>
414 <stat/>
415 <convergence>
416 <include_in_convergence/>
417 </convergence>
418 <detectors>
419 <include_in_detectors/>
420 </detectors>
421 <steady_state>
422 <include_in_steady_state/>
423 </steady_state>
424 </diagnostic>
425 </scalar_field>
426 <scalar_field name="Amplitude" rank="0">
427 <prescribed>
428 <mesh name="VelocityMesh"/>
429 <value name="WholeMesh">
430 <from_file file_name="netcdf_test.nc">
431 <format name="netcdf">
432 <field_name>
433 <string_value lines="1">amplitude</string_value>
434 </field_name>
435 </format>
436 </from_file>
437 </value>
438 <output/>
439 <stat/>
440 <detectors>
441 <exclude_from_detectors/>
442 </detectors>
443 </prescribed>
444 </scalar_field>
445 <scalar_field name="AmplitudeFromPython" rank="0">
446 <diagnostic>
447 <algorithm name="scalar_python_diagnostic" material_phase_support="single">
448 <string_value lines="20" type="python">from create_netcdf_test import amplitude,lonlat
449x=state.vector_fields['DiagnosticCoordinate']
450for i,xyz in enumerate(x.val):
451 lon,lat=lonlat(xyz)
452 field.set(i, amplitude(lon,lat))</string_value>
453 <depends>
454 <string_value lines="1">DiagnosticCoordinate</string_value>
455 </depends>
456 </algorithm>
457 <mesh name="PressureMesh"/>
458 <output/>
459 <stat/>
460 <convergence>
461 <include_in_convergence/>
462 </convergence>
463 <detectors>
464 <include_in_detectors/>
465 </detectors>
466 <steady_state>
467 <include_in_steady_state/>
468 </steady_state>
469 </diagnostic>
470 </scalar_field>
471 <scalar_field name="AmplitudeDifference" rank="0">
472 <diagnostic>
473 <algorithm name="scalar_difference" source_field_1_name="Amplitude" source_field_2_name="AmplitudeFromPython" source_field_2_type="scalar" material_phase_support="single" source_field_1_type="scalar">
474 <absolute_difference/>
475 </algorithm>
476 <mesh name="VelocityMesh"/>
477 <output/>
478 <stat/>
479 <convergence>
480 <include_in_convergence/>
481 </convergence>
482 <detectors>
483 <include_in_detectors/>
484 </detectors>
485 <steady_state>
486 <include_in_steady_state/>
487 </steady_state>
488 </diagnostic>
489 </scalar_field>
490 <scalar_field name="TideFromPython" rank="0">
491 <diagnostic>
492 <algorithm name="scalar_python_diagnostic" material_phase_support="single">
493 <string_value type="python" lines="20">from create_netcdf_test import amplitude,lonlat,phase
494from math import cos,pi
495g=9.81 # gravity
496omega=1.40519E-04 # M2 frequency (taken from code)
497x=state.vector_fields['DiagnosticCoordinate']
498for i,xyz in enumerate(x.val):
499 lon,lat=lonlat(xyz)
500 A=amplitude(lon,lat)
501 alpha=phase(lon,lat)
502 field.set(i, g*A*cos(omega*time+pi*alpha/180.0))</string_value>
503 <depends>
504 <string_value lines="1">DiagnosticCoordinate</string_value>
505 </depends>
506 </algorithm>
507 <mesh name="PressureMesh"/>
508 <output/>
509 <stat/>
510 <convergence>
511 <include_in_convergence/>
512 </convergence>
513 <detectors>
514 <include_in_detectors/>
515 </detectors>
516 <steady_state>
517 <include_in_steady_state/>
518 </steady_state>
519 </diagnostic>
520 </scalar_field>
521 <scalar_field name="TidalDifference" rank="0">
522 <diagnostic>
523 <algorithm name="scalar_difference" source_field_1_name="Pressure" source_field_2_name="TideFromPython" source_field_2_type="scalar" material_phase_support="single" source_field_1_type="scalar">
524 <absolute_difference/>
525 </algorithm>
526 <mesh name="PressureMesh"/>
527 <output/>
528 <stat/>
529 <convergence>
530 <include_in_convergence/>
531 </convergence>
532 <detectors>
533 <include_in_detectors/>
534 </detectors>
535 <steady_state>
536 <include_in_steady_state/>
537 </steady_state>
538 </diagnostic>
539 </scalar_field>
540 <scalar_field name="BoundaryMask" rank="0">
541 <prognostic>
542 <mesh name="PressureMesh"/>
543 <equation name="AdvectionDiffusion"/>
544 <spatial_discretisation>
545 <continuous_galerkin>
546 <stabilisation>
547 <no_stabilisation/>
548 </stabilisation>
549 <advection_terms>
550 <exclude_advection_terms/>
551 </advection_terms>
552 <mass_terms/>
553 </continuous_galerkin>
554 <conservative_advection>
555 <real_value rank="0">0.0</real_value>
556 </conservative_advection>
557 </spatial_discretisation>
558 <temporal_discretisation>
559 <theta>
560 <real_value rank="0">0.0</real_value>
561 </theta>
562 </temporal_discretisation>
563 <solver>
564 <iterative_method name="gmres">
565 <restart>
566 <integer_value rank="0">30</integer_value>
567 </restart>
568 </iterative_method>
569 <preconditioner name="sor"/>
570 <relative_error>
571 <real_value rank="0">1e-7</real_value>
572 </relative_error>
573 <absolute_error>
574 <real_value rank="0">0.1</real_value>
575 </absolute_error>
576 <max_iterations>
577 <integer_value rank="0">1000</integer_value>
578 </max_iterations>
579 <never_ignore_solver_failures/>
580 <diagnostics>
581 <monitors/>
582 </diagnostics>
583 </solver>
584 <initial_condition name="WholeMesh">
585 <constant>
586 <real_value rank="0">0.0</real_value>
587 </constant>
588 </initial_condition>
589 <boundary_conditions name="AllSides">
590 <surface_ids>
591 <integer_value shape="4" rank="1">1009 1010 1011 1012</integer_value>
592 </surface_ids>
593 <type name="dirichlet">
594 <constant>
595 <real_value rank="0">1.0</real_value>
596 </constant>
597 </type>
598 </boundary_conditions>
599 <output/>
600 <stat/>
601 <convergence>
602 <include_in_convergence/>
603 </convergence>
604 <detectors>
605 <include_in_detectors/>
606 </detectors>
607 <steady_state>
608 <include_in_steady_state/>
609 </steady_state>
610 <consistent_interpolation/>
611 </prognostic>
612 </scalar_field>
613 <scalar_field name="TidalDifferenceMasked" rank="0">
614 <diagnostic>
615 <algorithm name="scalar_python_diagnostic" material_phase_support="single">
616 <string_value type="python" lines="20">diff=state.scalar_fields['TidalDifference']
617# this field is 1 on the boundary nodes, and 0 in the interior
618mask=state.scalar_fields['BoundaryMask']
619field.val[:]=diff.val*mask.val</string_value>
620 <depends>
621 <string_value lines="1">BoundaryMask,TidalDifference</string_value>
622 </depends>
623 </algorithm>
624 <mesh name="PressureMesh"/>
625 <output/>
626 <stat/>
627 <convergence>
628 <include_in_convergence/>
629 </convergence>
630 <detectors>
631 <include_in_detectors/>
632 </detectors>
633 <steady_state>
634 <include_in_steady_state/>
635 </steady_state>
636 </diagnostic>
637 </scalar_field>
638 <vector_field name="DiagnosticCoordinate" rank="1">
639 <diagnostic>
640 <algorithm name="Internal" material_phase_support="multiple"/>
641 <mesh name="PressureMesh"/>
642 <output/>
643 <stat>
644 <include_in_stat/>
645 </stat>
646 <convergence>
647 <include_in_convergence/>
648 </convergence>
649 <detectors>
650 <include_in_detectors/>
651 </detectors>
652 <steady_state>
653 <include_in_steady_state/>
654 </steady_state>
655 </diagnostic>
656 </vector_field>
657 </material_phase>
658</fluidity_options>
0659
=== added file 'tests/sample_netcdf_test/sample_netcdf_test.xml'
--- tests/sample_netcdf_test/sample_netcdf_test.xml 1970-01-01 00:00:00 +0000
+++ tests/sample_netcdf_test/sample_netcdf_test.xml 2012-03-27 11:21:19 +0000
@@ -0,0 +1,24 @@
1<?xml version='1.0' encoding='utf-8'?>
2<testproblem>
3 <name>sample_netcdf_test</name>
4 <owner userid="skramer"/>
5 <problem_definition length="short" nprocs="1">
6 <command_line>fluidity -v2 -l sample.flml</command_line>
7 </problem_definition>
8 <variables>
9 <variable name="amplitude_difference_max" language="python"> from fluidity_tools import stat_parser
10stat=stat_parser('sample.stat')
11amplitude_difference_max=stat['Ocean']['AmplitudeDifference']['max']</variable>
12 <variable name="tidal_difference_max" language="python">from fluidity_tools import stat_parser
13stat=stat_parser('sample.stat')
14tidal_difference_max=stat['Ocean']['TidalDifferenceMasked']['max']</variable>
15 </variables>
16 <pass_tests>
17 <test name="compare_amplitude_from_netCDF_with_function" language="python"># compare difference between amplitude read from netCDF
18# with values from python function used to create this netCDF file
19assert( max(amplitude_difference_max)&lt;3e-4 )</test>
20 <test name="compare_tidal_boundary_value_with_python" language="python"># compare values of tidal boundary condition on Pressure
21# with those directly computed from python functions
22assert( max(tidal_difference_max)&lt;0.01 )</test>
23 </pass_tests>
24</testproblem>
025
=== added directory 'tests/sample_netcdf_test/src'
=== added file 'tests/sample_netcdf_test/src/box_on_sphere.geo'
--- tests/sample_netcdf_test/src/box_on_sphere.geo 1970-01-01 00:00:00 +0000
+++ tests/sample_netcdf_test/src/box_on_sphere.geo 2012-03-27 11:21:19 +0000
@@ -0,0 +1,17 @@
1Include "shorelines_with_boundaries.geo";
2
3Printf("Assigning characteristic mesh sizes...");
4Field[ IFI + 1] = MathEval;
5Field[ IFI + 1].F = "50000";
6
7Background Field = IFI + 1;
8
9// Dont extent the elements sizes from the boundary inside the domain
10Mesh.CharacteristicLengthExtendFromBoundary = 0;
11
12//Set some options for better png output
13General.Color.Background = {255,255,255};
14General.Color.BackgroundGradient = {255,255,255};
15General.Color.Foreground = Black;
16Mesh.Color.Lines = {0,0,0};
17
018
=== added file 'tests/sample_netcdf_test/src/definitions.geo'
--- tests/sample_netcdf_test/src/definitions.geo 1970-01-01 00:00:00 +0000
+++ tests/sample_netcdf_test/src/definitions.geo 2012-03-27 11:21:19 +0000
@@ -0,0 +1,41 @@
1Printf("Reading function and point definitions...");
2
3Function DrawParallel
4 alpha = parallelSectionStartingY/parallelSectionStartingX;
5 parallelRadius = Sqrt(parallelSectionStartingX^2 + parallelSectionStartingY^2);
6 deltaAlpha = (parallelSectionEndingY/parallelSectionEndingX - parallelSectionStartingY/parallelSectionStartingX)/pointsOnParallel;
7 For t In {1:pointsOnParallel}
8 alpha += deltaAlpha;
9 newParallelPointX = (parallelSectionStartingX/Fabs(parallelSectionStartingX))*parallelRadius/(Sqrt(alpha^2 + 1));
10 newParallelPointY = newParallelPointX*alpha;
11 newPointOnParallel = newp; Point(newPointOnParallel) = {newParallelPointX, newParallelPointY, 0};
12 EndFor
13 BSpline(newParallelID) = {firstPointOnParallel, newPointOnParallel-(pointsOnParallel-1):newPointOnParallel, lastPointOnParallel};
14Return
15
16//The coordinates of various points on the Surface of the Earth are converted to radians
17//and stereographic coordinatesbelow.
18
19//Point A is located 2 deg 00'W, 48 deg 45'N.
20Point_A_longitude_rad = -(2 + (00/60))*(Pi/180);
21Point_A_latitude_rad = (48 + (45/60))*(Pi/180);
22Point_A_stereographic_x = -Cos(Fabs(Point_A_longitude_rad))*Cos(Fabs(Point_A_latitude_rad))/( 1 + Sin(Fabs(Point_A_latitude_rad)) );
23Point_A_stereographic_y = Cos(Fabs(Point_A_latitude_rad))*Sin(Fabs(Point_A_longitude_rad))/( 1 + Sin(Fabs(Point_A_latitude_rad)) );
24
25//Point B is located at 9 deg 46'W, 48 deg 45'N
26Point_B_longitude_rad = -(9 + (46/60))*(Pi/180);
27Point_B_latitude_rad = (48 + (45/60))*(Pi/180);
28Point_B_stereographic_x = -Cos(Fabs(Point_B_longitude_rad))*Cos(Fabs(Point_B_latitude_rad))/( 1 + Sin(Fabs(Point_B_latitude_rad)) );
29Point_B_stereographic_y = Cos(Fabs(Point_B_latitude_rad))*Sin(Fabs(Point_B_longitude_rad))/( 1 + Sin(Fabs(Point_B_latitude_rad)) );
30
31//Point C is located at 9 deg 45'W, 56 deg 45'N
32Point_C_longitude_rad = -(9 + (45/60))*(Pi/180);
33Point_C_latitude_rad = (56 + (45/60))*(Pi/180);
34Point_C_stereographic_x = -Cos(Fabs(Point_C_longitude_rad))*Cos(Fabs(Point_C_latitude_rad))/( 1 + Sin(Fabs(Point_C_latitude_rad)) );
35Point_C_stereographic_y = Cos(Fabs(Point_C_latitude_rad))*Sin(Fabs(Point_C_longitude_rad))/( 1 + Sin(Fabs(Point_C_latitude_rad)) );
36
37//Point D is located at 2 deg 00'W, 56 deg 45'N
38Point_D_longitude_rad = -(2 + (00/60))*(Pi/180);
39Point_D_latitude_rad = (56 + (45/60))*(Pi/180);
40Point_D_stereographic_x = -Cos(Fabs(Point_D_longitude_rad))*Cos(Fabs(Point_D_latitude_rad))/( 1 + Sin(Fabs(Point_D_latitude_rad)) );
41Point_D_stereographic_y = Cos(Fabs(Point_D_latitude_rad))*Sin(Fabs(Point_D_longitude_rad))/( 1 + Sin(Fabs(Point_D_latitude_rad)) );
042
=== added file 'tests/sample_netcdf_test/src/shorelines.geo'
--- tests/sample_netcdf_test/src/shorelines.geo 1970-01-01 00:00:00 +0000
+++ tests/sample_netcdf_test/src/shorelines.geo 2012-03-27 11:21:19 +0000
@@ -0,0 +1,8 @@
1IP = newp;
2IL = newl;
3ILL = newll;
4IS = news;
5IFI = newf;
6Point ( IP + 0 ) = {0, 0, 0 };
7Point ( IP + 1 ) = {0, 0,6.37101e+06};
8PolarSphere ( IS + 0 ) = {IP , IP+1};
09
=== added file 'tests/sample_netcdf_test/src/shorelines_with_boundaries.geo'
--- tests/sample_netcdf_test/src/shorelines_with_boundaries.geo 1970-01-01 00:00:00 +0000
+++ tests/sample_netcdf_test/src/shorelines_with_boundaries.geo 2012-03-27 11:21:19 +0000
@@ -0,0 +1,46 @@
1Include "definitions.geo";
2Include "shorelines.geo";
3Coherence;
4
5Printf("Creating Meridian & Parallel segments to close the domain...");
6//So far, only points on the shorelies and curves approximating shorelines have been
7//constructed. we now add points in the sea, to close the domain boundaries
8Point(IP + 60000) = {Point_A_stereographic_x, Point_A_stereographic_y, 0};
9Point(IP + 60001) = {Point_B_stereographic_x, Point_B_stereographic_y, 0};
10Point(IP + 60002) = {Point_C_stereographic_x, Point_C_stereographic_y, 0};
11Point(IP + 60003) = {Point_D_stereographic_x, Point_D_stereographic_y, 0};
12
13//Draw South-most parallel of the Domain.
14pointsOnParallel = 200; //Assign parameters to variables and then call function DrawParallel,
15parallelSectionStartingX = Point_A_stereographic_x;
16parallelSectionStartingY = Point_A_stereographic_y;
17firstPointOnParallel = IP + 60000;
18parallelSectionEndingX = Point_B_stereographic_x;
19parallelSectionEndingY = Point_B_stereographic_y;
20lastPointOnParallel = IP + 60001;
21newParallelID = IL + 1000;
22Call DrawParallel;
23
24BSpline(IL + 1001) = {IP + 60001, IP + 60002};
25BSpline(IL + 1002) = {IP + 60000, IP + 60003};
26
27////Draw North-most parallel of the Domain.
28pointsOnParallel = 200; //Assign parameters to variables and then call function DrawParallel,
29parallelSectionStartingX = Point_C_stereographic_x;
30parallelSectionStartingY = Point_C_stereographic_y;
31firstPointOnParallel = IP + 60002;
32parallelSectionEndingX = Point_D_stereographic_x;
33parallelSectionEndingY = Point_D_stereographic_y;
34lastPointOnParallel = IP + 60003;
35newParallelID = IL + 1003;
36Call DrawParallel;
37
38Printf("Declaring surface on sphere to be meshed...");
39Line Loop(1006) = {1003, -1004, -1002, -1001};
40Plane Surface(1007) = {1006};
41Physical Surface(1008) = {1007};
42
43Physical Line(1009) = {1001}; //Physical line corresponding to south-most parallel.
44Physical Line(1010) = {1002}; //Physical line corresponding to meridian segment through point A.
45Physical Line(1011) = {1003}; //Physical line corresponding to meridian segment through point B.
46Physical Line(1012) = {1004}; //Physical line corresponding to north-most parallel.