[cig-commits] commit: Fixed bug in PCDVCSuite.c

Mercurial hg at geodynamics.org
Tue Mar 23 10:34:24 PDT 2010


changeset:   396:6e39a0ce6024
branch:      1.4.x
parent:      390:652b314deeb1
user:        MirkoVelic
date:        Tue Feb 02 16:33:48 2010 +1100
files:       Utils/src/PCDVC.c Utils/tests/PCDVCSuite.c Utils/tests/expected/testPCDVC_CircleInterface.expected Utils/tests/expected/testPCDVC_ExponentialInterface.expected Utils/tests/expected/testPCDVC_PolynomialFunction.expected Utils/tests/input/testPCDVC.xml
description:
Fixed bug in PCDVCSuite.c
If you call
   _IntegrationPointsSwarm_UpdateHook( NULL, integrationSwarm );
Then you shouldn't be calling
   WeightsCalculator_CalculateCell( weights, integrationSwarm, lElement_I );
straight after this because the former function already indirectly calls
the latter.
Calling the latter function is equivalent to iterating on the positions
and weights in the Voronoi cell.

Also turned off population control for this test. We are not testing that here.
This test, as it is, should be part of the DVCWeights test suite. We should have different tests for PCDVC.


diff -r 652b314deeb1 -r 6e39a0ce6024 Utils/src/PCDVC.c
--- a/Utils/src/PCDVC.c	Tue Jan 19 15:07:09 2010 +1100
+++ b/Utils/src/PCDVC.c	Tue Feb 02 16:33:48 2010 +1100
@@ -1268,7 +1268,10 @@ void _PCDVC_Calculate2D( void* pcdvc, vo
     }
     _DVCWeights_CreateVoronoi2D( &bchain, &pList, &cells, dx, dy, nump, numx, numy, BBXMIN, BBXMAX, BBYMIN, BBYMAX);
     _DVCWeights_GetCentroids2D( cells, pList,numy,numx,nump,da);
-
+/*     for(k=0;k<nump;k++){ */
+/* 	  printf("In %s O(%10.7lf %10.7lf) C(%10.7lf %10.7lf) W(%.4lf)\n", __func__, pList[k].x, pList[k].y, pList[k].cx, pList[k].cy, pList[k].w); */
+/*     } */
+      
     /************************************/
     /************************************/
     /*    Start 2D Population Control   */
@@ -1560,6 +1563,9 @@ void _PCDVC_Calculate2D( void* pcdvc, vo
         particle[i]->weight = pList[i].w;
 
     }	
+    /* for(k=0;k<nump;k++){ */
+/* 	  printf("::In %s O(%10.7lf %10.7lf) C(%10.7lf %10.7lf) W(%.4lf)\n", __func__, pList[k].x, pList[k].y, pList[k].cx, pList[k].cy, pList[k].w); */
+/*     } */
     for(k=0;k<nump;k++){
         free(bchain[k].new_claimed_cells);
         free(bchain[k].new_bound_cells);
diff -r 652b314deeb1 -r 6e39a0ce6024 Utils/tests/PCDVCSuite.c
--- a/Utils/tests/PCDVCSuite.c	Tue Jan 19 15:07:09 2010 +1100
+++ b/Utils/tests/PCDVCSuite.c	Tue Feb 02 16:33:48 2010 +1100
@@ -135,7 +135,8 @@ void testElementIntegral_CircleInterface
 	Index						loop_I;
 	Index						count            = Dictionary_GetUnsignedInt_WithDefault( context->dictionary, "SampleSize", 5000 );
 	void*						data;
-
+		      IntegrationPoint* intParticle;
+		      MaterialPoint*  materialPoint;
 	/* Create FeVariable */
 	feVariable = FeVariable_New_Full(
 		"feVariable",
@@ -164,14 +165,27 @@ void testElementIntegral_CircleInterface
 		_Swarm_InitialiseParticles( materialSwarm, data );
 
 		_IntegrationPointsSwarm_UpdateHook( NULL, integrationSwarm );
+		/* The following function should not be called here as it is already called ultimately via the above function */
+		/* calling this function again causes a first iteration in Lloyd's algorithm for the Voronoi cells which we don't want here */
+		//WeightsCalculator_CalculateCell( weights, integrationSwarm, lElement_I );
+		if(loop_I%10 == 0){
+		      int i;
+
+		      for(i=0;i<integrationSwarm->cellParticleCountTbl[0];i++){
+			    intParticle  =  (IntegrationPoint*)Swarm_ParticleInCellAt( integrationSwarm, 0, i );
+			    materialPoint = (MaterialPoint*)Swarm_ParticleInCellAt( materialSwarm, 0, i );
+			    //printf("In %s M(%10.7lf %10.7lf) I(%10.7lf %10.7lf) W(%.4lf) particle layout type %s: point %d in cell %d\n",__func__,materialPoint->coord[0], materialPoint->coord[1],
+			//	   intParticle->xi[0], intParticle->xi[1], intParticle->weight, materialSwarm->particleLayout->type, i, 0);
 		
-		WeightsCalculator_CalculateCell( weights, integrationSwarm, lElement_I );
+			    //printf("%lf %lf\n",intParticle->xi[0],intParticle->xi[1]);
+		      }
+                }
 
 		/* Evaluate Integral */
 		integral = FeVariable_IntegrateElement( feVariable, integrationSwarm, lElement_I );
 
 		/* Calculate Error */
-		error = fabs( integral - analyticValue )/fabs( analyticValue );
+		error = fabs( ( integral - analyticValue )/( analyticValue ) );
 		errorSum += error;
 		errorSquaredSum += error*error;
 	}
@@ -179,7 +193,7 @@ void testElementIntegral_CircleInterface
 	/* Calculate Mean and Standard Deviation */
 	*mean = errorSum / (double) count;
 	*standardDeviation = sqrt( errorSquaredSum / (double) count - *mean * *mean );
-
+	printf("In %s: Mean %lf SD %lf Sol %lf Count = %d\n", __func__, *mean, *standardDeviation, analyticValue,   count);
 	Stg_Component_Destroy( feVariable, NULL, True );
 }
 
@@ -227,8 +241,9 @@ void testElementIntegral_PolynomialFunct
 		_Swarm_InitialiseParticles( materialSwarm, data );
 
 		_IntegrationPointsSwarm_UpdateHook( NULL, integrationSwarm );
-		
-		WeightsCalculator_CalculateCell( weights, integrationSwarm, lElement_I );
+		/* The following function should not be called here as it is already called ultimately via the above function */
+		/* calling this function again causes a first iteration in Lloyd's algorithm for the Voronoi cells which we don't want here */
+		//WeightsCalculator_CalculateCell( weights, integrationSwarm, lElement_I );
 
 		/* Evaluate Integral */
 		integral = FeVariable_IntegrateElement( feVariable, integrationSwarm, lElement_I );
@@ -242,7 +257,7 @@ void testElementIntegral_PolynomialFunct
 	/* Calculate Mean and Standard Deviation */
 	*mean = errorSum / (double) count;
 	*standardDeviation = sqrt( errorSquaredSum / (double) count - *mean * *mean );
-
+	printf("In %s: Mean %lf SD %lf Sol %lf\n", __func__, *mean, *standardDeviation, analyticValue);
 	Stg_Component_Destroy( feVariable, NULL, True );
 }
 
@@ -290,8 +305,9 @@ void testElementIntegral_ExponentialInte
 		_Swarm_InitialiseParticles( materialSwarm, data );
 
 		_IntegrationPointsSwarm_UpdateHook( NULL, integrationSwarm );
-		
-		WeightsCalculator_CalculateCell( weights, integrationSwarm, lElement_I );
+		/* The following function should not be called here as it is already called ultimately via the above function */
+		/* calling this function again causes a first iteration in Lloyd's algorithm for the Voronoi cells which we don't want here */
+		//WeightsCalculator_CalculateCell( weights, integrationSwarm, lElement_I );
 
 		/* Evaluate Integral */
 		integral = FeVariable_IntegrateElement( feVariable, integrationSwarm, lElement_I );
@@ -305,7 +321,7 @@ void testElementIntegral_ExponentialInte
 	/* Calculate Mean and Standard Deviation */
 	*mean = errorSum / (double) count;
 	*standardDeviation = sqrt( errorSquaredSum / (double) count - *mean * *mean );
-
+	printf("In %s: Mean %lf SD %lf Sol %lf\n", __func__, *mean, *standardDeviation, analyticValue);
 	Stg_Component_Destroy( feVariable, NULL, True );
 }
 
diff -r 652b314deeb1 -r 6e39a0ce6024 Utils/tests/expected/testPCDVC_CircleInterface.expected
--- a/Utils/tests/expected/testPCDVC_CircleInterface.expected	Tue Jan 19 15:07:09 2010 +1100
+++ b/Utils/tests/expected/testPCDVC_CircleInterface.expected	Tue Feb 02 16:33:48 2010 +1100
@@ -1,2 +1,2 @@ 0.005000 0.162000
-0.005000 0.162000
-0.001000 0.063000
+0.05 0.104
+0.01 0.06
diff -r 652b314deeb1 -r 6e39a0ce6024 Utils/tests/expected/testPCDVC_ExponentialInterface.expected
--- a/Utils/tests/expected/testPCDVC_ExponentialInterface.expected	Tue Jan 19 15:07:09 2010 +1100
+++ b/Utils/tests/expected/testPCDVC_ExponentialInterface.expected	Tue Feb 02 16:33:48 2010 +1100
@@ -1,2 +1,2 @@ 0.002000 0.070000
-0.002000 0.070000
-0.002000 0.050000
+0.04 0.055
+0.01 0.042
diff -r 652b314deeb1 -r 6e39a0ce6024 Utils/tests/expected/testPCDVC_PolynomialFunction.expected
--- a/Utils/tests/expected/testPCDVC_PolynomialFunction.expected	Tue Jan 19 15:07:09 2010 +1100
+++ b/Utils/tests/expected/testPCDVC_PolynomialFunction.expected	Tue Feb 02 16:33:48 2010 +1100
@@ -1,2 +1,8 @@ 0.001000 0.012000
-0.001000 0.012000
-0.001000 0.002000
+0.001000 0.0092
+0.001000 0.0022
+#the above numbers are
+#first line
+# mean tolerance for the relative mean and the relative mean itself
+#second line
+# mean std dev tolerance and the expected std dev
+
diff -r 652b314deeb1 -r 6e39a0ce6024 Utils/tests/input/testPCDVC.xml
--- a/Utils/tests/input/testPCDVC.xml	Tue Jan 19 15:07:09 2010 +1100
+++ b/Utils/tests/input/testPCDVC.xml	Tue Feb 02 16:33:48 2010 +1100
@@ -16,8 +16,8 @@
 			<param name="resolutionZ">10</param>
 			<param name="lowerT">0.6</param>
 			<param name="upperT">25</param>
-			<param name="maxDeletions">3</param>
-			<param name="maxSplits">3</param>
+			<param name="maxDeletions">0</param>
+			<param name="maxSplits">0</param>
 			<param name="MaterialPointsSwarm">materialPoints</param>
 		</struct>
 	</struct>



More information about the CIG-COMMITS mailing list