00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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