[cig-commits] r5993 - in long/3D/Gale/trunk: . src/Underworld/plugins/Output/DumpSwarm

walter at geodynamics.org walter at geodynamics.org
Fri Feb 9 09:13:16 PST 2007


Author: walter
Date: 2007-02-09 09:13:16 -0800 (Fri, 09 Feb 2007)
New Revision: 5993

Modified:
   long/3D/Gale/trunk/
   long/3D/Gale/trunk/src/Underworld/plugins/Output/DumpSwarm/DumpSwarm.c
Log:
 r1540 at earth:  boo | 2007-02-09 09:11:01 -0800
 Output viscosity and yielding info for all particles into 'particles' file



Property changes on: long/3D/Gale/trunk
___________________________________________________________________
Name: svk:merge
   - 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1535
   + 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1540

Modified: long/3D/Gale/trunk/src/Underworld/plugins/Output/DumpSwarm/DumpSwarm.c
===================================================================
--- long/3D/Gale/trunk/src/Underworld/plugins/Output/DumpSwarm/DumpSwarm.c	2007-02-09 15:50:47 UTC (rev 5992)
+++ long/3D/Gale/trunk/src/Underworld/plugins/Output/DumpSwarm/DumpSwarm.c	2007-02-09 17:13:16 UTC (rev 5993)
@@ -52,9 +52,9 @@
 const Type Underworld_DumpSwarm_Type = "Underworld_DumpSwarm";
 
 void _Underworld_DumpSwarm_Construct( void* component, Stg_ComponentFactory* cf, void *data ) {
-	FiniteElementContext* context;
+	UnderworldContext* context;
 
-	context = (FiniteElementContext*)Stg_ComponentFactory_ConstructByName( cf, "context", FiniteElementContext, True, data );
+	context = (UnderworldContext*)Stg_ComponentFactory_ConstructByName( cf, "context", UnderworldContext, True, data );
 	
 	ContextEP_Append( context, AbstractContext_EP_Dump,
                           DumpSwarm );
@@ -92,7 +92,7 @@
         Swarm*                  swarm=context->gaussSwarm;
         IntegrationPointsSwarm*  picswarm=context->picIntegrationPoints;
 
-	Particle_Index          particleLocalCount = picswarm->particleLocalCount;
+	Particle_Index          num_particles = picswarm->particleLocalCount;
 	Particle_Index          lParticle_I;
 
 	RheologyMaterial*       material;
@@ -111,7 +111,6 @@
         double *coord;
         char *format;
         int stepping, iteration, num_iterations=1;
-        int num_particles=0;
         char separator[2];
         separator[0]='\0';
 
@@ -125,45 +124,25 @@
           strcpy(separator,",");
 
         stream = Journal_Register( MPIStream_Type, Swarm_Type );
-        Stg_asprintf( &filename, "%s/yielding.%05d.%s", context->outputPath,
+        Stg_asprintf( &filename, "%s/particles.%05d.%s", context->outputPath,
                       context->timeStep, format );
         Stream_RedirectFile( stream, filename );
         
+        /* Write a header for vtk */
         if(!strcmp(format,"vtk"))
           {
-            num_iterations=2;
-            
-            for ( lParticle_I = 0 ; lParticle_I < particleLocalCount ;
-                  ++lParticle_I ){
-              
-              IntegrationPoint* integrationparticle = (IntegrationPoint*)Swarm_ParticleAt( picswarm, lParticle_I );
-              
-              material = (RheologyMaterial*) IntegrationPointsSwarm_GetMaterialOn( picswarm, integrationparticle );
-              materialparticle = OneToOneMapper_GetMaterialPoint( picswarm->mapper, integrationparticle, &materialSwarm );
-              
-              rheology_register=(Rheology_Register*)material->rheology_Register;
-              
-              rheologyCount = Rheology_Register_GetCount( rheology_register ); 
-              
-              /* Loop over all of the rheologies for a particle. */
-              
-              for( rheology_I = 0; rheology_I < rheologyCount ; rheology_I++ ) { 
-                rheology = (YieldRheology*)Rheology_Register_GetByIndex( rheology_register, rheology_I ); 
-                
-                /* We are only interested in whether a particle has
-                   yielded, so we only look at yielding rheologies */
-                if(!strcmp(rheology->name,"yielding"))
-                  ++num_particles;
-              }
-            }
-              Journal_Printf(stream,"# vtk DataFile Version 2.0\nGale\nASCII\nDATASET UNSTRUCTURED_GRID\nPOINTS %d float\n",(num_particles-1)/stepping+1);
+            num_iterations=3;
+            Journal_Printf(stream,"# vtk DataFile Version 2.0\nGale\nASCII\nDATASET UNSTRUCTURED_GRID\nPOINTS %d float\n",(num_particles-1)/stepping+1);
           }
 
+        /* We need three iterations for vtk files, because the values
+           are written separately from the coordinates. */
         for(iteration=0; iteration<num_iterations; ++iteration)
           {
             /* Loop over all of the particles */
-            for ( lParticle_I = 0 ; lParticle_I < particleLocalCount ;
+            for ( lParticle_I = 0 ; lParticle_I < num_particles ;
                   ++lParticle_I ){
+              double yielding, viscosity;
               
               IntegrationPoint* integrationparticle = (IntegrationPoint*)Swarm_ParticleAt( picswarm, lParticle_I );
               
@@ -174,6 +153,10 @@
               
               rheologyCount = Rheology_Register_GetCount( rheology_register ); 
               
+              coord = materialparticle->coord;
+              yielding=0;
+              viscosity=0;
+
               /* Loop over all of the rheologies for a particle. */
               
               for( rheology_I = 0; rheology_I < rheologyCount ; rheology_I++ ) { 
@@ -183,55 +166,70 @@
                    yielded, so we only look at yielding rheologies */
                 if(!strcmp(rheology->name,"yielding"))
                   {
-                    if(strcmp(format,"vtk"))
-                      Journal_Printf(stream,"%d%s ",rheology_I,separator);
-                    
-                    coord = materialparticle->coord;
-                    
-                    if(iteration==0)
-                      {
-                        if (context->dim == 2) {
-                          Journal_Printf(stream,"%lf%s %lf%s 0.0%s ",(double)coord[0],
-                                         separator,(double)coord[1],separator,separator);
-                        } else {
-                          Journal_Printf(stream,"%lf%s %lf%s %lf%s ",
-                                         (double)coord[0],separator,
-                                         (double)coord[1],separator,
-                                         (double)coord[2],separator);
-                        }
-                      }
-                    if(iteration==1 || strcmp(format,"vtk"))
-                      {
-                        char sep='\n';
-                        if(iteration==1)
-                          sep=' ';
-                        
-                        if ( (rheology)->hasYieldedParticleExtHandle == (ExtensionInfo_Index) -1 )
-                          {
-                            Journal_Printf(stream,"No particle yield extension\n");
-                          }
-                        else
-                          {
-                            Journal_Printf
-                              (stream,"%lf%c",
-                               StrainWeakening_CalcRatio(rheology->strainWeakening,
-                                                         materialparticle),sep);
-                          }
-                      }
-                    else
-                      Journal_Printf(stream,"\n");
+                    yielding=StrainWeakening_CalcRatio(rheology->strainWeakening,
+                                                       materialparticle);
                   }
+                else if(!strcmp(rheology->name,"storeViscosity"))
+                  {
+                    StoreVisc* self = (StoreVisc*) rheology;
+                    StoreVisc_ParticleExt* particleExt;
+                    particleExt=
+                      ExtensionManager_Get( materialSwarm->particleExtensionMgr, materialparticle, self->particleExtHandle );
+                    viscosity=particleExt->effVisc;
+                  }
               }
+
+              /* If we are not creating a vtk file, then print out the
+                 rheology number. */
+              
+              if(strcmp(format,"vtk"))
+                Journal_Printf(stream,"%d%s ",rheology_I,separator);
+              
+              
+              /* First print out only the coordinates. */
+              if(iteration==0)
+                {
+                  if (context->dim == 2) {
+                    Journal_Printf(stream,"%lf%s %lf%s 0.0%s ",(double)coord[0],
+                                   separator,(double)coord[1],separator,separator);
+                  } else {
+                    Journal_Printf(stream,"%lf%s %lf%s %lf%s ",
+                                   (double)coord[0],separator,
+                                   (double)coord[1],separator,
+                                   (double)coord[2],separator);
+                  }
+                }
+              
+              /* If using vtk, then we print out viscosity and
+                 yielding during the second and third iterations. */
+              if(iteration>0 || strcmp(format,"vtk"))
+                {
+                  char sep='\n';
+                  if(iteration>0)
+                    sep=' ';
+                  
+                  if(iteration!=2)
+                    Journal_Printf(stream,"%lf%c",viscosity,' ');
+                  if(iteration!=1)
+                    Journal_Printf(stream,"%lf%c",yielding,sep);
+                }
+              else
+                Journal_Printf(stream,"\n");
             }
             if(!strcmp(format,"vtk"))
               {
-                if(iteration==0)
+                switch(iteration)
                   {
-                    Journal_Printf(stream,"POINT_DATA %d\nSCALARS Temperature_Scalars float 1\nLOOKUP_TABLE default\n",
+                  case 0:
+                    Journal_Printf(stream,"POINT_DATA %d\nSCALARS Viscosity float 1\nLOOKUP_TABLE default\n",
                                    (num_particles-1)/stepping+1);
+                    break;
+                  case 1:
+                    Journal_Printf(stream,"\nSCALARS Yielding_fraction float 1\nLOOKUP_TABLE default\n");
+                    break;
+                  case 2:
+                    Journal_Printf(stream,"\n");
                   }
-                else
-                  Journal_Printf(stream,"\n");
               }
           }
         Stream_CloseFile( stream );



More information about the cig-commits mailing list