Changes between Version 10 and Version 11 of addfield


Ignore:
Timestamp:
11/19/14 16:45:48 (10 years ago)
Author:
Mathieu Morlighem
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • addfield

    v10 v11  
    1 Let's use an example to illustrate how to add a field in the model. I want to add a melting rate field to the calving parameters. This melting rate is given by the user so we add the field to the GUI interface.
     1Let's use an example to illustrate how to add a field in the model. I want to add a field `melting_rate`  to the class `calving` (I want to have `md.calving.melting_rate`) that is defined by the user.
    22
    3 == Modify the GUI ==
     3== Modify the User Interface ==
    44
    5 Go to `src/m/classes` and modify all the classes concerned by the new field, here `calving.m` and`calvinglevermann.m` and their associated Python versions. Declare the new field, add default values (if desired), add consistency checks, display descriptions and marshall instructions.
     5Go to `src/m/classes` and modify `calving.m` and its python equivalent.
     6
     7 1. Declare the new field in `properties`
     8{{{
     9#!m
     10   melting_rate = NaN;
     11}}}
     12in ISSM, we use `NaN` for vectors and `0` for scalars. The default value is added with some explanation in the `setdefaultparameters` function of the class.
     13
     14 2. Add a default value in  `setdefaultparameters` (Optionals, for scalars only, Literature reference is encouraged)
     15 3. Add a consistency check
     16#!m
     17md = checkfield(md,'fieldname','calving.meltingrate','NaN',1,'size',[md.mesh.numberofvertices 1],'>=',0);
     18}}}
     19which means that we want no `NaN`, the vecteur should be of size `numberofvertices` with positive values only.
     20 4. Add description in `disp`
     21 5. Add field to `marshall`
    622
    723== Add new Enums ==
     
    1228== Implement the new field in the model ==
    1329
    14 First, load the input:
    15 
    1630{{{
    1731#!c
    1832Input* meltingrate_input  = NULL;
    19 meltingrate_input = basalelement->GetInput(CalvinglevermannMeltingrateEnum);     _assert_(meltingrate_input);
    2033}}}
    21 
    22 Then, start  looping on the number of gaussian points and fetch the input value at these points:
    23 
    24 {{{
    25 #!c
    26 meltingrate_input->GetInputValue(&meltingrate,gauss);
    27 }}}
    28 
    29 Ater that, you can do your computations using `meltingrate` for this gaussian point.
    30