[cig-commits] r6003 - in long/3D/Gale/trunk: .
src/Underworld/plugins/Output/DumpSwarm
walter at geodynamics.org
walter at geodynamics.org
Sun Feb 11 00:50:51 PST 2007
Author: walter
Date: 2007-02-11 00:50:51 -0800 (Sun, 11 Feb 2007)
New Revision: 6003
Modified:
long/3D/Gale/trunk/
long/3D/Gale/trunk/src/Underworld/plugins/Output/DumpSwarm/DumpSwarm.c
Log:
r1544 at earth: boo | 2007-02-09 13:46:02 -0800
Remove vtk output from DumpSwarm
Property changes on: long/3D/Gale/trunk
___________________________________________________________________
Name: svk:merge
- 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1543
+ 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1544
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-11 08:50:46 UTC (rev 6002)
+++ long/3D/Gale/trunk/src/Underworld/plugins/Output/DumpSwarm/DumpSwarm.c 2007-02-11 08:50:51 UTC (rev 6003)
@@ -78,18 +78,20 @@
return PluginsManager_Submit( pluginsManager, Underworld_DumpSwarm_Type, "0", _Underworld_DumpSwarm_DefaultNew );
}
+void string_hash(char *p, unsigned int *result)
+{
+ unsigned int MULT=31;
+ unsigned int NHASH=29989;
+ for(;*p;++p)
+ *result=MULT*(*result)+*p;
+ (*result)%=NHASH;
+}
+
void DumpSwarm( void* _context ) {
UnderworldContext* context = (UnderworldContext*)_context;
- FeVariable* currFeVar;
- Name currFeVarName;
Dictionary* dictionary = context->dictionary;
- Dictionary_Entry_Value* feVarList=NULL;
- Dictionary_Entry_Value* currFvParam=NULL;
- Index feVar_I=0;
- Index numFeVarsToPrint=0;
- Swarm* swarm=context->gaussSwarm;
IntegrationPointsSwarm* picswarm=context->picIntegrationPoints;
Particle_Index num_particles = picswarm->particleLocalCount;
@@ -110,7 +112,7 @@
double *coord;
char *format;
- int stepping, iteration, num_iterations=1;
+ int stepping;
char separator[2];
separator[0]='\0';
@@ -120,6 +122,7 @@
format=Dictionary_GetString_WithDefault(dictionary,"outputFormat","txt");
stepping=Dictionary_GetInt_WithDefault(dictionary,"particleStepping",1);
+
if(!strcmp(format,"csv"))
strcpy(separator,",");
@@ -128,110 +131,66 @@
context->timeStep, format );
Stream_RedirectFile( stream, filename );
- /* Write a header for vtk */
- if(!strcmp(format,"vtk"))
- {
- 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);
- }
+ /* Loop over all of the particles */
+ for ( lParticle_I = 0 ; lParticle_I < num_particles ;
+ ++lParticle_I ){
+ double yielding, viscosity;
+ int rheology_hash;
+
+ 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 );
+
+ coord = materialparticle->coord;
+ yielding=0;
+ viscosity=0;
+ rheology_hash=0;
- /* 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 < num_particles ;
- ++lParticle_I ){
- double yielding, viscosity;
-
- 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 );
-
- 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++ ) {
- rheology = (YieldRheology*)Rheology_Register_GetByIndex( rheology_register, rheology_I );
+ /* 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"))
- {
- 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;
- }
+ string_hash(rheology->name,&rheology_hash);
+ /* Get yielding info */
+ if(!strcmp(rheology->name,"yielding"))
+ {
+ yielding=StrainWeakening_CalcRatio(rheology->strainWeakening,
+ materialparticle);
}
-
- /* 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"))
+ /* Get viscosity info */
+ else if(!strcmp(rheology->name,"storeViscosity"))
{
- switch(iteration)
- {
- 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");
- }
+ StoreVisc* self = (StoreVisc*) rheology;
+ StoreVisc_ParticleExt* particleExt;
+ particleExt=
+ ExtensionManager_Get( materialSwarm->particleExtensionMgr, materialparticle, self->particleExtHandle );
+ viscosity=particleExt->effVisc;
}
}
+
+ /* Print out a hash of the rheology names. */
+
+ Journal_Printf(stream,"%d%s ",rheology_hash,separator);
+
+ /* First print out only the coordinates. */
+ 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);
+ }
+ /* Then print out the data */
+ Journal_Printf(stream,"%lf%s %lf\n",yielding,separator,viscosity);
+ }
Stream_CloseFile( stream );
Memory_Free( filename );
}
More information about the cig-commits
mailing list