[cig-commits] r6223 - in mc/3D/CitcomS/trunk: CitcomS/Components lib module

tan2 at geodynamics.org tan2 at geodynamics.org
Sat Mar 10 21:27:51 PST 2007


Author: tan2
Date: 2007-03-10 21:27:50 -0800 (Sat, 10 Mar 2007)
New Revision: 6223

Modified:
   mc/3D/CitcomS/trunk/CitcomS/Components/Tracer.py
   mc/3D/CitcomS/trunk/lib/Composition_related.c
   mc/3D/CitcomS/trunk/lib/Full_tracer_advection.c
   mc/3D/CitcomS/trunk/lib/Output.c
   mc/3D/CitcomS/trunk/lib/global_defs.h
   mc/3D/CitcomS/trunk/lib/tracer_defs.h
   mc/3D/CitcomS/trunk/module/setProperties.c
Log:
A new way to compute composition.

Each tracer has a "flavor" (can only be either 0 or 1 currently). In the ratio
method, the composition of an element is determined by:
  (# of tracers of flavor i)/(# of total tracers)


Modified: mc/3D/CitcomS/trunk/CitcomS/Components/Tracer.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Components/Tracer.py	2007-03-11 05:20:43 UTC (rev 6222)
+++ mc/3D/CitcomS/trunk/CitcomS/Components/Tracer.py	2007-03-11 05:27:50 UTC (rev 6223)
@@ -71,8 +71,12 @@
         # (tracer_ic_method == 1)
         tracer_file = inv.str("tracer_file", default="tracer.dat")
 
-        # How many types of tracers, must be >= 1
-        tracer_types = inv.int("tracer_types", default=1)
+        # How many flavors of tracers
+        # If tracer_flavors > 0, each element will report the number of
+        # tracers of each flavor inside it. This information can be used
+        # later for many purposes. One of it is to compute composition,
+        # either using absolute method or ratio method.
+        tracer_flavors = inv.int("tracer_flavors", default=0)
 
 
         # Advection Scheme

Modified: mc/3D/CitcomS/trunk/lib/Composition_related.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Composition_related.c	2007-03-11 05:20:43 UTC (rev 6222)
+++ mc/3D/CitcomS/trunk/lib/Composition_related.c	2007-03-11 05:27:50 UTC (rev 6223)
@@ -91,13 +91,7 @@
 
 void composition_setup(struct All_variables *E)
 {
-    int j;
 
-    E->composition.on = 0;
-    if (E->composition.ichemical_buoyancy==1 ||
-        E->composition.icompositional_rheology)
-        E->composition.on = 1;
-
     if (E->composition.on) {
         allocate_composition_memory(E);
         init_composition(E);
@@ -117,7 +111,7 @@
         number_of_tracers = E->trace.ntracers[j];
         for (kk=1;kk<=number_of_tracers;kk++) {
             rad = E->trace.basicq[j][2][kk];
-
+            //TODO: generalize init flavors
             if (rad<=E->composition.z_interface) E->trace.extraq[j][0][kk]=1.0;
             if (rad>E->composition.z_interface) E->trace.extraq[j][0][kk]=0.0;
         }
@@ -129,6 +123,16 @@
 void write_composition_instructions(struct All_variables *E)
 {
 
+    E->composition.on = 0;
+    if (E->composition.ichemical_buoyancy==1 ||
+        E->composition.icompositional_rheology)
+        E->composition.on = 1;
+
+    if (E->composition.on && E->trace.nflavors < 1) {
+        fprintf(E->trace.fpt, "Tracer flavors must be greater than 1 to track composition\n");
+        parallel_process_termination();
+    }
+
     if (E->composition.ichemical_buoyancy==0)
             fprintf(E->trace.fpt,"Passive Tracers\n");
 
@@ -141,6 +145,8 @@
 
     fprintf(E->trace.fpt,"Buoyancy Ratio: %f\n", E->composition.buoyancy_ratio);
 
+    if (E->composition.ichemical_buoyancy==1)
+        fprintf(E->trace.fpt,"Interface Height: %f\n",E->composition.z_interface);
 
     if (E->composition.ireset_initial_composition==0)
         fprintf(E->trace.fpt,"Using old initial composition from tracer files\n");
@@ -173,7 +179,7 @@
     /* XXX: Currently, only the ratio method works here.           */
     /* Will have to come back here to include the absolute method. */
 
-    accumulate_tracers_in_element(E);
+    //count_tracers_of_flavors(E);
 
 
     /* ratio method */
@@ -219,24 +225,6 @@
         }
     }
 
-    if (E->composition.ibuoy_type==1) {
-        /* allocat memory for tracer ratio method */
-
-        for (j=1;j<=E->sphere.caps_per_proc;j++) {
-
-            if ((E->composition.ieltrac[j]=(int *)malloc((E->lmesh.nel+1)*sizeof(int)))==NULL) {
-                fprintf(E->trace.fpt,"AKM(compute_elemental_composition)-no memory 5u83a\n");
-                fflush(E->trace.fpt);
-                exit(10);
-            }
-            if ((E->composition.celtrac[j]=(double *)malloc((E->lmesh.nel+1)*sizeof(double)))==NULL) {
-                    fprintf(E->trace.fpt,"AKM(compute_elemental_composition)-no memory 58hy8\n");
-                    fflush(E->trace.fpt);
-                    exit(10);
-            }
-        }
-    }
-
     return;
 }
 
@@ -267,179 +255,109 @@
 
     FILE *fp;
 
-    for (j=1;j<=E->sphere.caps_per_proc;j++)
-        {
+    if ((E->trace.ic_method==0)||(E->trace.ic_method==1)) {
+        for (j=1;j<=E->sphere.caps_per_proc;j++) {
+            for (kk=1;kk<=E->lmesh.nel;kk++) {
 
-            if ((E->composition.oldel[j]=(double *)malloc((E->lmesh.nel+1)*sizeof(double)))==NULL)
-                {
-                    fprintf(E->trace.fpt,"ERROR(fill old composition)-no memory 324c\n");
-                    fflush(E->trace.fpt);
-                    exit(10);
-                }
-        }
+                ibottom_node=E->ien[j][kk].node[1];
+                zbottom=E->sx[j][3][ibottom_node];
 
+                if (zbottom<E->composition.z_interface) E->composition.comp_el[j][kk]=1.0;
+                if (zbottom>=E->composition.z_interface) E->composition.comp_el[j][kk]=0.0;
 
-    if ((E->trace.ic_method==0)||(E->trace.ic_method==1))
-        {
-            for (j=1;j<=E->sphere.caps_per_proc;j++)
-                {
-                    for (kk=1;kk<=E->lmesh.nel;kk++)
-                        {
+            } /* end kk */
+        } /* end j */
+    }
 
-                            ibottom_node=E->ien[j][kk].node[1];
-                            zbottom=E->sx[j][3][ibottom_node];
 
-                            if (zbottom<E->composition.z_interface) E->composition.oldel[j][kk]=1.0;
-                            if (zbottom>=E->composition.z_interface) E->composition.oldel[j][kk]=0.0;
-
-                        } /* end kk */
-                } /* end j */
-        }
-
-
     /* Else read from file */
 
 
-    else if (E->trace.ic_method==2)
-        {
+    else if (E->trace.ic_method==2) {
 
-            /* first look for backing file */
+        /* first look for backing file */
 
-            sprintf(output_file,"%s.comp_el.%d.%d",E->control.old_P_file,E->parallel.me,E->monitor.solution_cycles_init);
-            if ( (fp=fopen(output_file,"r"))==NULL)
-                {
-                    fprintf(E->trace.fpt,"AKMerror(Initialize Old Composition)-FILE NOT EXIST: %s\n", output_file);
-                    fflush(E->trace.fpt);
-                    exit(10);
-                }
+        sprintf(output_file,"%s.comp_el.%d.%d",E->control.old_P_file,E->parallel.me,E->monitor.solution_cycles_init);
+        if ( (fp=fopen(output_file,"r"))==NULL) {
+            fprintf(E->trace.fpt,"AKMerror(Initialize Old Composition)-FILE NOT EXIST: %s\n", output_file);
+            fflush(E->trace.fpt);
+            exit(10);
+        }
 
+        fgets(input_s,200,fp);
+
+        for(j=1;j<=E->sphere.caps_per_proc;j++) {
             fgets(input_s,200,fp);
+            for (kk=1;kk<=E->lmesh.nel;kk++) {
+                fgets(input_s,200,fp);
+                sscanf(input_s,"%lf",&E->composition.comp_el[j][kk]);
+            }
+        }
 
-            for(j=1;j<=E->sphere.caps_per_proc;j++)
-                {
-                    fgets(input_s,200,fp);
-                    for (kk=1;kk<=E->lmesh.nel;kk++)
-                        {
-                            fgets(input_s,200,fp);
-                            sscanf(input_s,"%lf",&E->composition.oldel[j][kk]);
-                        }
-                }
+        fclose(fp);
 
-            fclose(fp);
+    } /* endif */
 
-        } /* endif */
 
 
-
     return;
 }
 
 /*********** COMPUTE ELEMENTAL COMPOSITION RATIO METHOD ***/
 /*                                                        */
 /* This function computes the composition per element.    */
-/* Integer array ieltrac stores tracers per element.      */
-/* Double array celtrac stores the sum of tracer composition */
+/* The concentration of material i in an element is       */
+/* defined as:                                            */
+/*   (# of tracers of flavor i) / (# of all tracers)      */
 
 static void compute_elemental_composition_ratio_method(struct All_variables *E)
 {
+    int j, e, flavor, numtracers;
+    int iempty = 0;
 
-    int kk;
-    int numtracers;
-    int nelem;
-    int j;
-    int iempty=0;
 
-    double comp;
+    /* XXX: currently only two composition is supported */
+    if (E->trace.nflavors != 2) {
+        fprintf(E->trace.fpt, "Sorry - Only two flavors of tracers is supported\n");
+        fflush(E->trace.fpt);
+        parallel_process_termination();
+    }
 
-    for (j=1;j<=E->sphere.caps_per_proc;j++)
-        {
 
-            /* first zero arrays */
+    for (j=1; j<=E->sphere.caps_per_proc; j++) {
+        for (e=1; e<=E->lmesh.nel; e++) {
+            numtracers = 0;
+            for (flavor=0; flavor<E->trace.nflavors; flavor++)
+                numtracers += E->trace.ntracer_flavor[j][flavor][e];
 
-            for (kk=1;kk<=E->lmesh.nel;kk++)
-                {
-                    E->composition.ieltrac[j][kk]=0;
-                    E->composition.celtrac[j][kk]=0.0;
-                }
-
-            numtracers=E->trace.ntracers[j];
-
-            /* Fill ieltrac and celtrac */
-
-
-            for (kk=1;kk<=numtracers;kk++)
-                {
-
-                    nelem=E->trace.ielement[j][kk];
-                    E->composition.ieltrac[j][nelem]++;
-
-                    comp=E->trace.extraq[j][0][kk];
-
-                    if (comp>1.0000001)
-                        {
-                            fprintf(E->trace.fpt,"ERROR(compute elemental)-not ready for comp>1 yet (%f)(tr. %d) \n",comp,kk);
-                            fflush(E->trace.fpt);
-                            exit(10);
-                        }
-
-                    E->composition.celtrac[j][nelem]=E->composition.celtrac[j][nelem]+comp;
-
-                }
-
             /* Check for empty entries and compute ratio.  */
-            /* If no tracers are in an element, use previous composition */
+            /* If no tracers are in an element, skip this element, */
+            /* use previous composition. */
+            if (numtracers == 0) {
+                iempty++;
+                continue;
+            }
 
-            iempty=0;
+            /* XXX: generalize for more than one composition */
+            flavor = 1;
+            E->composition.comp_el[j][e] =
+                E->trace.ntracer_flavor[j][flavor][e] / (double)numtracers;
+        }
 
-            for (kk=1;kk<=E->lmesh.nel;kk++)
-                {
 
-                    if (E->composition.ieltrac[j][kk]==0)
-                        {
-                            iempty++;
-                            E->composition.comp_el[j][kk]=E->composition.oldel[j][kk];
-                        }
-                    else if (E->composition.ieltrac[j][kk]>0)
-                        {
-                            E->composition.comp_el[j][kk]=E->composition.celtrac[j][kk]/(1.0*E->composition.ieltrac[j][kk]);
-                        }
+        if (iempty) {
 
-                    if (E->composition.comp_el[j][kk]>(1.000001) || E->composition.comp_el[j][kk]<(-0.000001))
-                        {
-                            fprintf(E->trace.fpt,"ERROR(compute elemental)-noway (3u5hd)\n");
-                            fprintf(E->trace.fpt,"COMPEL: %f (%d)(%d)\n",E->composition.comp_el[j][kk],kk,E->composition.ieltrac[j][kk]);
-                            fflush(E->trace.fpt);
-                            exit(10);
-                        }
-                }
-            if (iempty>0)
-                {
+            if ((1.0*iempty/E->lmesh.nel)>0.80) {
+                fprintf(E->trace.fpt,"WARNING(compute_elemental...)-number of tracers is REALLY LOW\n");
+                fflush(E->trace.fpt);
+                if (E->trace.itracer_warnings==1) exit(10);
+            }
+        }
 
-                    /*
-                      fprintf(E->trace.fpt,"%d empty elements filled with old values (%f percent)\n",iempty, (100.0*iempty/E->lmesh.nel));
-                      fflush(E->trace.fpt);
-                    */
+    } /* end j */
 
-                    if ((1.0*iempty/E->lmesh.nel)>0.80)
-                        {
-                            fprintf(E->trace.fpt,"WARNING(compute_elemental...)-number of tracers is REALLY LOW\n");
-                            fflush(E->trace.fpt);
-                            if (E->trace.itracer_warnings==1) exit(10);
-                        }
-                }
+    E->trace.istat_iempty += iempty;
 
-            /* Fill oldel */
-
-
-            for (kk=1;kk<=E->lmesh.nel;kk++)
-                {
-                    E->composition.oldel[j][kk]=E->composition.comp_el[j][kk];
-                }
-
-        } /* end j */
-
-    E->trace.istat_iempty=E->trace.istat_iempty+iempty;
-
     return;
 }
 

Modified: mc/3D/CitcomS/trunk/lib/Full_tracer_advection.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Full_tracer_advection.c	2007-03-11 05:20:43 UTC (rev 6222)
+++ mc/3D/CitcomS/trunk/lib/Full_tracer_advection.c	2007-03-11 05:27:50 UTC (rev 6223)
@@ -33,7 +33,7 @@
 #include "parallel_related.h"
 #include "composition_related.h"
 
-void accumulate_tracers_in_element(struct All_variables *E);
+void count_tracers_of_flavors(struct All_variables *E);
 
 static void get_neighboring_caps(struct All_variables *E);
 static void pdebug(struct All_variables *E, int i);
@@ -82,8 +82,12 @@
     }
 
 
-    /* How many types of tracers, must be >= 1 */
-    input_int("tracer_types",&(E->trace.ntypes),"1,1,nomax",m);
+    /* How many flavors of tracers */
+    /* If tracer_flavors > 0, each element will report the number of
+     * tracers of each flavor inside it. This information can be used
+     * later for many purposes. One of it is to compute composition,
+     * either using absolute method or ratio method. */
+    input_int("tracer_flavors",&(E->trace.nflavors),"0,0,nomax",m);
 
 
 
@@ -191,11 +195,11 @@
     if (E->trace.itracer_advection_scheme==1) E->trace.number_of_basic_quantities=12;
     if (E->trace.itracer_advection_scheme==2) E->trace.number_of_basic_quantities=12;
 
-    /* extra_quantities - used for composition, etc.    */
+    /* extra_quantities - used for flavors, composition, etc.    */
     /* (can be increased for additional science i.e. tracing chemistry */
 
     E->trace.number_of_extra_quantities = 0;
-    if (E->composition.ichemical_buoyancy==1)
+    if (E->trace.nflavors > 0)
         E->trace.number_of_extra_quantities += 1;
 
 
@@ -205,7 +209,7 @@
 
 
     /* Fixed positions in tracer array */
-    /* Comp is always in extraq position 0  */
+    /* Flavor is always in extraq position 0  */
     /* Current coordinates are always kept in basicq positions 0-5 */
     /* Other positions may be used depending on advection scheme and/or science being done */
 
@@ -242,21 +246,32 @@
 
     write_trace_instructions(E);
 
+
+    /* Gnometric projection for velocity interpolation */
+    if (E->trace.itracer_interpolation_scheme==1) {
+        define_uv_space(E);
+        determine_shape_coefficients(E);
+    }
+
+
+    /* The bounding box of neiboring processors */
     get_neighboring_caps(E);
 
+
+    /* Fine-grained regular grid to search tracers */
+    make_regular_grid(E);
+
+
     if (E->trace.ic_method==0) {
         make_tracer_array(E);
 
         if (E->composition.ichemical_buoyancy==1)
             init_tracer_composition(E);
     }
-    else if (E->trace.ic_method==1) {
+    else if (E->trace.ic_method==1)
         read_tracer_file(E);
-
-        if (E->composition.ichemical_buoyancy==1)
-            init_tracer_composition(E);
-    }
-    else if (E->trace.ic_method==2) restart_tracers(E);
+    else if (E->trace.ic_method==2)
+        restart_tracers(E);
     else
         {
             fprintf(E->trace.fpt,"Not ready for other inputs yet\n");
@@ -264,37 +279,29 @@
             exit(10);
         }
 
-    /* flush and wait for not real reason but it can't hurt */
-    fflush(E->trace.fpt);
-    parallel_process_sync(E);
 
+    /* total number of tracers  */
 
-    if (E->trace.itracer_interpolation_scheme==1) {
-        define_uv_space(E);
-        determine_shape_coefficients(E);
-    }
+    E->trace.ilast_tracer_count = isum_tracers(E);
+    fprintf(E->trace.fpt, "Sum of Tracers: %d\n", E->trace.ilast_tracer_count);
 
 
     /* flush and wait for not real reason but it can't hurt */
     fflush(E->trace.fpt);
     parallel_process_sync(E);
 
-    make_regular_grid(E);
 
-    /* flush and wait for not real reason but it can't hurt */
-    fflush(E->trace.fpt);
-    parallel_process_sync(E);
-
-
     /* find elements */
 
     find_tracers(E);
 
-    /* total number of tracers  */
 
-    E->trace.ilast_tracer_count = isum_tracers(E);
-    fprintf(E->trace.fpt, "Sum of Tracers: %d\n", E->trace.ilast_tracer_count);
+    /* count # of tracers of each flavor */
 
+    if (E->trace.nflavors > 0)
+        count_tracers_of_flavors(E);
+
+
     if (E->trace.ianalytical_tracer_test==1) {
         //TODO: walk into this code...
         analytical_test(E);
@@ -333,8 +340,10 @@
 
     check_sum(E);
 
-    //TODO: move
-    if (E->composition.ichemical_buoyancy==1) {
+    if (E->trace.nflavors > 0)
+        count_tracers_of_flavors(E);
+
+    if (E->composition.on) {
         fill_composition(E);
     }
 
@@ -1083,6 +1092,18 @@
         }
     }
 
+    if (E->trace.nflavors > 0) {
+        E->trace.ntracer_flavor[j]=(int **)malloc(E->trace.nflavors*sizeof(int*));
+        for (kk=0;kk<E->trace.nflavors;kk++) {
+            if ((E->trace.ntracer_flavor[j][kk]=(int *)malloc(E->lmesh.nel*sizeof(int)))==NULL) {
+                fprintf(E->trace.fpt,"ERROR(initialize tracer arrays)-no memory 1c.%d\n",kk);
+                fflush(E->trace.fpt);
+                exit(10);
+            }
+        }
+    }
+
+
     fprintf(E->trace.fpt,"Physical size of tracer arrays (max_ntracers): %d\n",
             E->trace.max_ntracers[j]);
     fflush(E->trace.fpt);
@@ -3013,12 +3034,6 @@
         {
             fprintf(E->trace.fpt,"Generating New Tracer Array\n");
             fprintf(E->trace.fpt,"Tracers per element: %d\n",E->trace.itperel);
-            /* TODO: move
-            if (E->composition.ichemical_buoyancy==1)
-                {
-                    fprintf(E->trace.fpt,"Interface Height: %f\n",E->composition.z_interface);
-                }
-            */
         }
     if (E->trace.ic_method==1)
         {
@@ -3029,11 +3044,7 @@
             fprintf(E->trace.fpt,"Restarting Tracers\n");
         }
 
-    fprintf(E->trace.fpt,"Number of tracer types: %d", E->trace.ntypes);
-    if (E->trace.ntypes < 1) {
-        fprintf(E->trace.fpt, "Tracer types shouldn't be less than 1\n");
-        parallel_process_termination();
-    }
+    fprintf(E->trace.fpt,"Number of tracer flavors: %d\n", E->trace.nflavors);
 
     if (E->trace.itracer_advection_scheme==1)
         {
@@ -3347,12 +3358,12 @@
 
     char input_s[1000];
 
-    int number_of_tracers;
+    int number_of_tracers, ncolumns;
     int kk;
     int icheck;
     int iestimate;
     int icushion;
-    int j;
+    int i, j;
 
     int icheck_cap();
     int icheck_processor_shell();
@@ -3365,7 +3376,7 @@
 
     double x,y,z;
     double theta,phi,rad;
-    double rdum1,rdum2,rdum3;
+    double extra[100];
 
     FILE *fptracer;
 
@@ -3373,9 +3384,18 @@
     fprintf(E->trace.fpt,"Opening %s\n",E->trace.tracer_file);
 
     fgets(input_s,200,fptracer);
-    sscanf(input_s,"%d",&number_of_tracers);
-    fprintf(E->trace.fpt,"%d Tracers in file \n",number_of_tracers);
+    sscanf(input_s,"%d %d",&number_of_tracers,&ncolumns);
+    fprintf(E->trace.fpt,"%d Tracers, %d columns in file \n",
+            number_of_tracers, ncolumns);
 
+    /* some error control */
+    if (E->trace.number_of_extra_quantities+3 != ncolumns) {
+        fprintf(E->trace.fpt,"ERROR(read tracer file)-wrong # of columns\n");
+        fflush(E->trace.fpt);
+        exit(10);
+    }
+
+
     /* initially size tracer arrays to number of tracers divided by processors */
 
     icushion=100;
@@ -3388,11 +3408,20 @@
 
         for (kk=1;kk<=number_of_tracers;kk++) {
             fgets(input_s,200,fptracer);
-            sscanf(input_s,"%lf %lf %lf",&rdum1,&rdum2,&rdum3);
+            if (E->trace.number_of_extra_quantities==0) {
+                sscanf(input_s,"%lf %lf %lf\n",&theta,&phi,&rad);
+            }
+            else if (E->trace.number_of_extra_quantities==1) {
+                sscanf(input_s,"%lf %lf %lf %lf\n",&theta,&phi,&rad,&extra[0]);
+            }
+            /* XXX: if E->trace.number_of_extra_quantities is greater than 1 */
+            /* this part has to be changed... */
+            else {
+                fprintf(E->trace.fpt,"ERROR(restart tracers)-huh?\n");
+                fflush(E->trace.fpt);
+                exit(10);
+            }
 
-            theta=rdum1;
-            phi=rdum2;
-            rad=rdum3;
             sphere_to_cart(E,theta,phi,rad,&x,&y,&z);
 
 
@@ -3423,6 +3452,9 @@
             E->trace.basicq[j][4][E->trace.ntracers[j]]=y;
             E->trace.basicq[j][5][E->trace.ntracers[j]]=z;
 
+            for (i=0; i<E->trace.number_of_extra_quantities; i++)
+                E->trace.extraq[j][i][E->trace.ntracers[j]]=extra[i];
+
         } /* end kk, number of tracers */
 
         fprintf(E->trace.fpt,"Number of tracers in this cap is: %d\n",
@@ -5325,39 +5357,48 @@
 
 
 
-/********************************************************************/
-/* This function computes the number of tracers in each element.    */
-/* Each tracer can be of different "type", which is the 0th index   */
-/* of extraq. How to interprete "type" is left for the application. */
+/***********************************************************************/
+/* This function computes the number of tracers in each element.       */
+/* Each tracer can be of different "flavors", which is the 0th index   */
+/* of extraq. How to interprete "flavor" is left for the application.  */
 
-void accumulate_tracers_in_element(struct All_variables *E)
+void count_tracers_of_flavors(struct All_variables *E)
 {
-    /* how many types of tracers? */
-    // TODO: fix to 1, generalized it later
-    const int itypes = 1;
-    int kk;
+
+    int j, flavor, e, kk;
     int numtracers;
-    int nelem;
-    int j;
 
-    for (j=1;j<=E->sphere.caps_per_proc;j++) {
+    for (j=1; j<=E->sphere.caps_per_proc; j++) {
 
         /* first zero arrays */
-        for (kk=1;kk<=E->lmesh.nel;kk++) {
-        }
+        for (flavor=0; flavor<E->trace.nflavors; flavor++)
+            for (e=1; e<=E->lmesh.nel; e++)
+                E->trace.ntracer_flavor[j][flavor][e] = 0;
 
         numtracers=E->trace.ntracers[j];
 
         /* Fill arrays */
-        for (kk=1;kk<=numtracers;kk++) {
+        for (kk=1; kk<=numtracers; kk++) {
+            e = E->trace.ielement[j][kk];
+            flavor = E->trace.extraq[j][0][kk];
+            E->trace.ntracer_flavor[j][flavor][e]++;
+        }
+    }
 
-            nelem=E->trace.ielement[j][kk];
-
-            //E->composition.itypes[j][nelem]++;
-
-
+    /* debug */
+    /**
+    for (j=1; j<=E->sphere.caps_per_proc; j++) {
+        for (e=1; e<=E->lmesh.nel; e++) {
+            fprintf(E->trace.fpt, "element=%d ntracer_flaver =", e);
+            for (flavor=0; flavor<E->trace.nflavors; flavor++) {
+                fprintf(E->trace.fpt, " %d",
+                        E->trace.ntracer_flavor[j][flavor][e]);
+            }
+            fprintf(E->trace.fpt, "\n");
         }
     }
+    fflush(E->trace.fpt);
+    /**/
 
     return;
 }

Modified: mc/3D/CitcomS/trunk/lib/Output.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Output.c	2007-03-11 05:20:43 UTC (rev 6222)
+++ mc/3D/CitcomS/trunk/lib/Output.c	2007-03-11 05:27:50 UTC (rev 6223)
@@ -501,7 +501,7 @@
         for(j=1;j<=E->sphere.caps_per_proc;j++) {
 	    fprintf(fp1,"%3d %7d\n", j, E->lmesh.nel);
 	    for(i=1;i<=E->lmesh.nel;i++) {
-                fprintf(fp1,"%.6e\n",E->composition.oldel[j][i]);
+                fprintf(fp1,"%.6e\n",E->composition.comp_el[j][i]);
             }
 	}
 

Modified: mc/3D/CitcomS/trunk/lib/global_defs.h
===================================================================
--- mc/3D/CitcomS/trunk/lib/global_defs.h	2007-03-11 05:20:43 UTC (rev 6222)
+++ mc/3D/CitcomS/trunk/lib/global_defs.h	2007-03-11 05:27:50 UTC (rev 6223)
@@ -673,11 +673,10 @@
     double buoyancy_ratio;
     int ireset_initial_composition;
     int ibuoy_type;
-    int *ieltrac[13];
-    double *oldel[13];
-    double *celtrac[13];
+
     double *comp_el[13];
     double *comp_node[13];
+
     double initial_bulk_composition;
     double bulk_composition;
     double error_fraction;

Modified: mc/3D/CitcomS/trunk/lib/tracer_defs.h
===================================================================
--- mc/3D/CitcomS/trunk/lib/tracer_defs.h	2007-03-11 05:20:43 UTC (rev 6222)
+++ mc/3D/CitcomS/trunk/lib/tracer_defs.h	2007-03-11 05:27:50 UTC (rev 6223)
@@ -82,9 +82,9 @@
     int ilater[13];
     double *rlater[13][100];
 
-    /* tracer types */
-    int ntypes;
-    int *ntracer_in_element[13];
+    /* tracer flavors */
+    int nflavors;
+    int **ntracer_flavor[13];
 
     /* regular mesh parameters */
     int numtheta[13];

Modified: mc/3D/CitcomS/trunk/module/setProperties.c
===================================================================
--- mc/3D/CitcomS/trunk/module/setProperties.c	2007-03-11 05:20:43 UTC (rev 6222)
+++ mc/3D/CitcomS/trunk/module/setProperties.c	2007-03-11 05:27:50 UTC (rev 6223)
@@ -585,12 +585,14 @@
             getIntProperty(properties, "tracer_ic_method",
                            E->trace.ic_method, fp);
 
-            if (E->trace.ic_method==0)
+            if (E->trace.ic_method==0) {
                 getIntProperty(properties, "tracers_per_element",
                                E->trace.itperel, fp);
-            else if (E->trace.ic_method==1)
+            }
+            else if (E->trace.ic_method==1) {
                 getStringProperty(properties, "tracer_file",
                                   E->trace.tracer_file, fp);
+            }
             else if (E->trace.ic_method==2) {
             }
             else {
@@ -600,7 +602,7 @@
             }
         }
 
-        getIntProperty(properties, "tracer_types", E->trace.ntypes, fp);
+        getIntProperty(properties, "tracer_flavors", E->trace.nflavors, fp);
 
         getIntProperty(properties, "tracer_advection_scheme", E->trace.itracer_advection_scheme, fp);
         getIntProperty(properties, "tracer_interpolation_scheme", E->trace.itracer_interpolation_scheme, fp);
@@ -627,6 +629,7 @@
         if (E->composition.icompositional_rheology==1) {
             getDoubleProperty(properties, "compositional_prefactor", E->composition.compositional_rheology_prefactor, fp);
         }
+
     }
     PUTS(("\n"));
 



More information about the cig-commits mailing list