/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/sedflux/run_bioturbation.c

Go to the documentation of this file.
00001 //---
00002 //
00003 // This file is part of sedflux.
00004 //
00005 // sedflux is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // sedflux is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with sedflux; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //
00019 //---
00020 
00021 #define SED_BIOTURBATION_PROC_NAME "bioturbation"
00022 #define EH_LOG_DOMAIN SED_BIOTURBATION_PROC_NAME
00023 
00024 #include <stdio.h>
00025 #include <sed/sed_sedflux.h>
00026 #include "my_processes.h"
00027 #include <bio.h>
00028 
00029 Sed_process_info
00030 run_bioturbation( Sed_process proc , Sed_cube p )
00031 {
00032    Bioturbation_t*  data = sed_process_user_data(proc);
00033    Sed_process_info info = SED_EMPTY_INFO;
00034 
00035    {
00036       gint   i;
00037       gint   len   = sed_cube_size                ( p );
00038       double dt    = sed_cube_time_step_in_seconds( p );
00039       double time  = sed_cube_age_in_years        ( p );
00040       double depth = eh_input_val_eval( data->depth , time );
00041       double k     = eh_input_val_eval( data->k     , time );
00042 
00043       for ( i=0 ; i<len ; i++ ) sed_column_bioturbate( sed_cube_col(p,i) , depth , k , dt );
00044    }
00045 
00046    return info;
00047 }
00048 
00049 #define BIO_KEY_DEPTH   "depth of bioturbation"
00050 #define BIO_KEY_K       "bioturbation diffusion coefficient"
00051 
00052 static gchar* bio_req_labels[] =
00053 {
00054    BIO_KEY_DEPTH ,
00055    BIO_KEY_K     ,
00056    NULL
00057 };
00058 
00059 gboolean
00060 init_bioturbation( Sed_process p , Eh_symbol_table t , GError** error )
00061 {
00062    Bioturbation_t* data    = sed_process_new_user_data( p , Bioturbation_t );
00063    GError*         tmp_err = NULL;
00064    gboolean        is_ok   = TRUE;
00065 
00066    eh_return_val_if_fail( error==NULL || *error==NULL , FALSE );
00067    eh_require( t );
00068    eh_require( p );
00069 
00070    if ( eh_symbol_table_require_labels( t , bio_req_labels , &tmp_err ) )
00071    {
00072       data->k     = eh_symbol_table_input_value( t , BIO_KEY_K     , &tmp_err );
00073       data->depth = eh_symbol_table_input_value( t , BIO_KEY_DEPTH , &tmp_err );
00074    }
00075 
00076    if ( tmp_err )
00077    {
00078       g_propagate_error( error , tmp_err );
00079       is_ok = FALSE;
00080    }
00081 
00082    return is_ok;
00083 }
00084 
00085 gboolean
00086 destroy_bioturbation( Sed_process p )
00087 {
00088    if ( p )
00089    {
00090       Bioturbation_t* data = sed_process_user_data( p );
00091 
00092       if ( data )
00093       {
00094          eh_input_val_destroy( data->k     );
00095          eh_input_val_destroy( data->depth );
00096          eh_free             ( data        );
00097       }
00098    }
00099    return TRUE;
00100 }
00101 

Generated on Fri Jan 4 18:04:15 2008 for sedflux by  doxygen 1.5.2