[cig-commits] r20537 - long/3D/SNAC/trunk/Snac/plugins/remesher_BI

echoi at geodynamics.org echoi at geodynamics.org
Tue Jul 24 12:41:37 PDT 2012


Author: echoi
Date: 2012-07-24 12:41:37 -0700 (Tue, 24 Jul 2012)
New Revision: 20537

Modified:
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/ConstructExtensions.c
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Context.c
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Context.h
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/DeleteExtensions.c
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/EntryPoint.c
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/EntryPoint.h
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Makefile.def
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Mesh.h
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Output.c
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Register.c
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Register.h
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Remesh.c
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Remesh.h
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/RemeshElements.c
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/RemeshNodes.c
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Remesher.h
   long/3D/SNAC/trunk/Snac/plugins/remesher_BI/types.h
Log:
A new entry point has been created, where the mapped element varialbes are copied from temporary arrays to the original ones.


Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/ConstructExtensions.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/ConstructExtensions.c	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/ConstructExtensions.c	2012-07-24 19:41:37 UTC (rev 20537)
@@ -191,8 +191,8 @@
 	contextExt->bottomRestore = 0;
 	if( !strcmp( Dictionary_Entry_Value_AsString( Dictionary_GetDefault( context->dictionary, "bottomRestore", Dictionary_Entry_Value_FromString( OFF_STR ) ) ), ON_STR) )
 		contextExt->bottomRestore = 1;
+	fprintf(stderr,"bottomRestore=%d\n",contextExt->bottomRestore);
 	
-	
 	/* Register these functions for use in VCs */
 	ConditionFunction_Register_Add(
 		context->condFunc_Register,
@@ -215,6 +215,9 @@
 	contextExt->interpolateElementK = EntryPoint_Register_GetHandle( 
 		context->entryPoint_Register, 
 		SnacRemesher_EP_InterpolateElement );
+	contextExt->copyElementK = EntryPoint_Register_GetHandle( 
+		context->entryPoint_Register, 
+		SnacRemesher_EP_CopyElement );
 
 	/* Prepare the dump file */
 	if( context->rank == 0) {

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Context.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Context.c	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Context.c	2012-07-24 19:41:37 UTC (rev 20537)
@@ -53,6 +53,7 @@
 	
 	printf( "\tinterpolateNodeK: %u\n", self->interpolateNodeK );
 	printf( "\tinterpolateElementK: %u\n", self->interpolateElementK );
+	printf( "\tcopyElementK: %u\n", self->copyElementK );
 }
 
 void SnacRemesher_InterpolateNodeFunction( void* _context, SnacRemesher_Context* self, 
@@ -69,22 +70,31 @@
 }
 
 void SnacRemesher_InterpolateElementFunction( 
-		void*			_context, 
+		void*					_context, 
 		SnacRemesher_Context*	self, 
-		Element_LocalIndex	dstEltInd, 
-		Tetrahedra_Index	dstTetInd, 
-		Snac_Element*		dstEltArray, 
-		Element_DomainIndex	srcEltInd, 
-		Tetrahedra_Index	srcTetInd )
+		Element_LocalIndex		dstEltInd, 
+		Tetrahedra_Index		dstTetInd, 
+		SnacRemesher_Element*	dstEltArray, 
+		Element_DomainIndex		srcEltInd, 
+		Tetrahedra_Index		srcTetInd )
 {
 	Snac_Context*			context = (Snac_Context*)_context;
 		
 	SnacRemesher_InterpolateElementMacro( 
-		context,
-		self,
-		dstEltInd, 
-		dstTetInd, 
-		dstEltArray, 
-		srcEltInd, 
-		srcTetInd );
+						context, self,
+						dstEltInd, dstTetInd, dstEltArray,
+						srcEltInd, srcTetInd );
 }
+
+
+void SnacRemesher_CopyElementFunction( 
+		void*					_context, 
+		SnacRemesher_Context*	self, 
+		Element_LocalIndex		eltInd,  
+		Tetrahedra_Index		tetInd, 
+		SnacRemesher_Element*	eltArray )
+{
+	Snac_Context*			context = (Snac_Context*)_context;
+		
+	SnacRemesher_CopyElementMacro( context, self, eltInd, tetInd, eltArray ); 
+}

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Context.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Context.h	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Context.h	2012-07-24 19:41:37 UTC (rev 20537)
@@ -45,8 +45,8 @@
 		SnacRemesher_Off, 
 		SnacRemesher_OnTimeStep, 
 		SnacRemesher_OnMinLengthScale, 
-		SnacRemesher_OnBothTimeStepLength, 
-		SnacRemesher_ConditionMax
+		SnacRemesher_OnBothTimeStepLength
+		/* SnacRemesher_ConditionMax */
 	} SnacRemesher_Condition;
 	
 
@@ -59,6 +59,7 @@
 		
 		EntryPoint_Index		interpolateNodeK;	/* Key to node interpolation entry point (for speed) */
 		EntryPoint_Index		interpolateElementK;	/* Key to element interpolation entry point (for speed) */
+		EntryPoint_Index		copyElementK;	/* Key to copy element values (for speed) */
 
 		Stream*				debugIC;
 		Stream*				debugCoords;
@@ -114,7 +115,7 @@
 						      SnacRemesher_Context*	self, 
 						      Element_LocalIndex	dstEltInd, 
 						      Tetrahedra_Index		dstTetInd, 
-						      Snac_Element*		dstEltArray, 
+						      SnacRemesher_Element*	dstEltArray, 
 						      Element_DomainIndex	srcEltInd, 
 						      Tetrahedra_Index		srcTetInd );
 
@@ -124,4 +125,27 @@
 		#define SnacRemesher_InterpolateElement SnacRemesher_InterpolateElementMacro
 	#endif
 
+
+	/* Run the copy element entry point */
+	#define SnacRemesher_CopyElementMacro( context, self, \
+										   elementInd, tetInd,	\
+										   elementArray )	\
+		( KeyCall( context, self->copyElementK, SnacRemesher_CopyElement_CallCast* ) ( \
+			KeyHandle( context, self->copyElementK ), \
+			context, \
+			elementInd, \
+			tetInd, \
+			elementArray ) )
+	void SnacRemesher_CopyElementFunction( void*					_context, 
+										   SnacRemesher_Context*	self, 
+										   Element_LocalIndex		eltInd, 
+										   Tetrahedra_Index			tetInd, 
+										   SnacRemesher_Element*	eltArray );
+
+	#ifdef MACRO_AS_FUNC
+		#define SnacRemesher_CopyElement SnacRemesher_CopyElementFunction
+	#else
+		#define SnacRemesher_CopyElement SnacRemesher_CopyElementMacro
+	#endif
+
 #endif /* __SnacRemesher_Context_h__ */

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/DeleteExtensions.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/DeleteExtensions.c	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/DeleteExtensions.c	2012-07-24 19:41:37 UTC (rev 20537)
@@ -59,9 +59,11 @@
 		ExtensionManager_Free( mesh->nodeExtensionMgr, meshExt->newNodes );
 	}
 	
+#if 0
 	if( meshExt->newElements ) {
 		ExtensionManager_Free( mesh->nodeExtensionMgr, meshExt->newElements );
 	}
+#endif
 	
 	
 	/*

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/EntryPoint.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/EntryPoint.c	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/EntryPoint.c	2012-07-24 19:41:37 UTC (rev 20537)
@@ -127,9 +127,13 @@
 	switch( self->castType ) {
 		case SnacRemesher_InterpolateNode_CastType:
 			return _SnacRemesher_EntryPoint_Run_InterpolateNode;
-		
+
 		case SnacRemesher_InterpolateElement_CastType:
 			return _SnacRemesher_EntryPoint_Run_InterpolateElement;
+
+		case SnacRemesher_CopyElement_CastType:
+			return _SnacRemesher_EntryPoint_Run_CopyElement;
+
 		default:
 			return _Snac_EntryPoint_GetRun( self );
 	}
@@ -165,7 +169,7 @@
 
 void _SnacRemesher_EntryPoint_Run_InterpolateElement( void* entryPoint, void* context, 
 						      unsigned dstElementInd, unsigned dstTetInd, 
-						      Snac_Element* elementArray, 
+						      SnacRemesher_Element* elementArray, 
 						      unsigned srcElementInd, unsigned srcTetInd )
 {
 	SnacRemesher_EntryPoint* self = (SnacRemesher_EntryPoint*)entryPoint;
@@ -190,3 +194,27 @@
 	#endif
 }
 
+void _SnacRemesher_EntryPoint_Run_CopyElement( void* entryPoint, void* context, 
+											   unsigned elementInd, unsigned tetInd, 
+											   SnacRemesher_Element* elementArray )
+{
+	SnacRemesher_EntryPoint* self = (SnacRemesher_EntryPoint*)entryPoint;
+	Hook_Index hookIndex;
+	
+	#ifdef USE_PROFILE
+		Stg_CallGraph_Push( stgCallGraph, _SnacRemesher_EntryPoint_Run_CopyElement, self->name );
+	#endif
+
+	for( hookIndex = 0; hookIndex < self->hooks->count; hookIndex++ ) {
+		void*	funcPtr;
+
+		funcPtr = ((Hook*)self->hooks->data[hookIndex])->funcPtr;
+		(*(SnacRemesher_CopyElement_Cast*)funcPtr)( context, 
+													elementInd, tetInd, 
+													elementArray ); 
+	}
+
+	#ifdef USE_PROFILE
+		Stg_CallGraph_Pop( stgCallGraph );
+	#endif
+}

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/EntryPoint.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/EntryPoint.h	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/EntryPoint.h	2012-07-24 19:41:37 UTC (rev 20537)
@@ -40,9 +40,13 @@
 
 	typedef void (SnacRemesher_InterpolateElement_Cast)( void* context, 
 							     unsigned dstElementInd, unsigned dstTetInd, 
-							     Snac_Element* elementArray, 
+							     SnacRemesher_Element* elementArray, 
 							     unsigned srcElementInd, unsigned srcTetInd );
 
+	typedef void (SnacRemesher_CopyElement_Cast)( void* context, 
+												  unsigned elementInd, unsigned tetInd, 
+												  SnacRemesher_Element* elementArray );
+
 	typedef void (SnacRemesher_InterpolateNode_CallCast)( void* entryPoint, void* context, 
 							      unsigned nodeInd, unsigned elementInd, unsigned tetInd, 
 							      unsigned* tetNodeInds, double* weights, 
@@ -50,12 +54,17 @@
 
 	typedef void (SnacRemesher_InterpolateElement_CallCast)( void* entryPoint, void* context, 
 								 unsigned dstElementInd, unsigned dstTetInd, 
-								 Snac_Element* elementArray, 
+								 SnacRemesher_Element* elementArray, 
 								 unsigned srcElementInd, unsigned srcTetInd );
 
+	typedef void (SnacRemesher_CopyElement_CallCast)( void* entryPoint, void* context, 
+													  unsigned elementInd, unsigned tetInd, 
+													  SnacRemesher_Element* elementArray );
+
 	#define SnacRemesher_InterpolateNode_CastType		(Snac_CastType_MAX + 1)
 	#define SnacRemesher_InterpolateElement_CastType	(SnacRemesher_InterpolateNode_CastType + 1)
-	#define SnacRemesher_CastType_MAX			(SnacRemesher_InterpolateElement_CastType + 1)
+	#define SnacRemesher_CopyElement_CastType			(SnacRemesher_InterpolateElement_CastType + 1)
+	#define SnacRemesher_CastType_MAX					(SnacRemesher_CopyElement_CastType + 1)
 
 	/** Textual name of this class */
 	extern const Type SnacRemesher_EntryPoint_Type;
@@ -103,7 +112,12 @@
 	/* Snac remesher entry point run... for interpolating an element */
 	void _SnacRemesher_EntryPoint_Run_InterpolateElement( void* entryPoint, void* context, 
 							      unsigned dstElementInd, unsigned dstTetInd, 
-							      Snac_Element* elementArray, 
+							      SnacRemesher_Element* elementArray, 
 							      unsigned srcElementInd, unsigned srcTetInd );
 
+	/* Snac remesher entry point run... for copying interpolated values to an element */
+	void _SnacRemesher_EntryPoint_Run_CopyElement( void* entryPoint, void* context, 
+									unsigned ElementInd, unsigned TetInd, 
+									SnacRemesher_Element* elementArray );
+
 #endif /* __SnacRemesher_EntryPoint_h__ */

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Makefile.def
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Makefile.def	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Makefile.def	2012-07-24 19:41:37 UTC (rev 20537)
@@ -64,5 +64,6 @@
 	TestCondFunc.h \
 	Remesh.h \
 	DeleteExtensions.h \
+	RemesherElement.h \
 	Remesher.h
 

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Mesh.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Mesh.h	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Mesh.h	2012-07-24 19:41:37 UTC (rev 20537)
@@ -75,7 +75,8 @@
 		unsigned 	local_range_min[3];	
 		unsigned 	local_range_max[3];	
 
-		Snac_Element*	newElements;
+		SnacRemesher_Element*   newElements;
+		//Snac_Element*	newElements;
 		Element_DomainIndex*	orderedToDomain;
 		
 		/* If during the remesh nodes are found outside the old mesh they will be stored here. */

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Output.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Output.c	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Output.c	2012-07-24 19:41:37 UTC (rev 20537)
@@ -65,7 +65,7 @@
 		break;
 	}
 
-	fprintf( contextExt->remesherOut, "%6u: %s %6d %6u %12g %12g %12g %12g\n",
+	fprintf( contextExt->remesherOut, "%6lu: %s %6d %6lu %12g %12g %12g %12g\n",
 			 (long unsigned int)contextExt->remeshingCount,
 			 cr,
 			 context->timeStep,

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Register.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Register.c	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Register.c	2012-07-24 19:41:37 UTC (rev 20537)
@@ -51,8 +51,9 @@
 ExtensionInfo_Index SnacRemesher_ContextHandle;
 ExtensionInfo_Index SnacRemesher_MeshHandle;
 
-const Name SnacRemesher_EP_InterpolateNode =		"SnacRemesher_EP_InterpolateNode";
-const Name SnacRemesher_EP_InterpolateElement =		"SnacRemesher_EP_InterpolateElement";
+const Name SnacRemesher_EP_InterpolateNode =	"SnacRemesher_EP_InterpolateNode";
+const Name SnacRemesher_EP_InterpolateElement =	"SnacRemesher_EP_InterpolateElement";
+const Name SnacRemesher_EP_CopyElement =		"SnacRemesher_EP_CopyElement";
 
 
 Index _SnacRemesher_Register( PluginsManager* pluginsMgr ) {
@@ -107,6 +108,9 @@
 	Context_AddEntryPoint(
 		context,
 		SnacRemesher_EntryPoint_New( SnacRemesher_EP_InterpolateElement, SnacRemesher_InterpolateElement_CastType ) );
+	Context_AddEntryPoint(
+		context,
+		SnacRemesher_EntryPoint_New( SnacRemesher_EP_CopyElement, SnacRemesher_CopyElement_CastType ) );
 
 	/* Add extensions to the entry points */
 	EntryPoint_Append(
@@ -135,6 +139,11 @@
 		_SnacRemesher_InterpolateElement,
 		SnacRemesher_Type );
 	EntryPoint_Append(
+		Context_GetEntryPoint( context, SnacRemesher_EP_CopyElement ),
+		SnacRemesher_Type,
+		_SnacRemesher_CopyElement,
+		SnacRemesher_Type );
+	EntryPoint_Append(
 		Context_GetEntryPoint( context, AbstractContext_EP_DestroyExtensions ),
 		SnacRemesher_Type,
 		_SnacRemesher_DeleteExtensions,

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Register.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Register.h	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Register.h	2012-07-24 19:41:37 UTC (rev 20537)
@@ -50,6 +50,7 @@
 	/* Names to new entry points */
 	extern const Name SnacRemesher_EP_InterpolateNode;
 	extern const Name SnacRemesher_EP_InterpolateElement;
+	extern const Name SnacRemesher_EP_CopyElement;
 
 	Index _SnacRemesher_Register( PluginsManager* pluginsMgr );
 

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Remesh.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Remesh.c	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Remesh.c	2012-07-24 19:41:37 UTC (rev 20537)
@@ -42,6 +42,7 @@
 #include "Register.h"
 #include "Utils.h"
 #include "Output.h"
+#include "RemesherElement.h"
 
 #include <string.h>
 #include <assert.h>
@@ -93,6 +94,7 @@
 								mesh,
 								SnacRemesher_MeshHandle );
 		Node_LocalIndex		newNode_i;
+		/* Element_LocalIndex		newElement_i; */
 
 		Journal_Printf( context->snacInfo, "Remeshing!\n" );
 		
@@ -101,7 +103,6 @@
 		** then we'll need to convert the current mesh's cartesian coordinates 
 		** to spherical coordinates first.
 		*/
-		
 		if( meshExt->meshType == SnacRemesher_Spherical ) {
 			Node_LocalIndex	lNode_i;
 			
@@ -144,26 +145,36 @@
 		
 		/* Interpolate current elemental values onto new coordinates. */
 		/* Barycentric coordinates of the old domain hex element set. */
-		meshExt->oldBarycenters = Memory_Alloc_Array( Coord, mesh->elementDomainCount, "SnacRemesher" );
+		meshExt->oldBarycenters = Memory_Alloc_Array( Coord, mesh->elementDomainCount, "OldBarycenters" );
 		/* Barycentric coordinates of the new local hex element set. */
-		meshExt->newBarycenters = Memory_Alloc_Array( Coord, mesh->elementLocalCount, "SnacRemesher" );
+		meshExt->newBarycenters = Memory_Alloc_Array( Coord, mesh->elementLocalCount, "NewBarycenters" );
 		/* Coefficients for evaluating interpolation weight - function of old barycenters only. */
-		meshExt->barcoef =  Memory_Alloc_Array( SnacRemesher_ElementBarcoef, mesh->elementDomainCount, "SnacRemesher" );
-		meshExt->barcord =  Memory_Alloc_Array( SnacRemesher_ElementBarcord, mesh->elementLocalCount, "SnacRemesher" );
+		meshExt->barcoef =  Memory_Alloc_Array( SnacRemesher_ElementBarcoef, mesh->elementDomainCount, "BarCoef" );
+		meshExt->barcord =  Memory_Alloc_Array( SnacRemesher_ElementBarcord, mesh->elementLocalCount, "BarCord" );
 		/* Since ghost elements are numbered after local elements, 
 		   a mapping from domain id to an ordered id listis constructed for straightforward interpolation:
 		   i.e. orderedToDomain: ordered ID -> domainID. */
-		meshExt->orderedToDomain =  Memory_Alloc_Array( Element_DomainIndex, mesh->elementDomainCount, "SnacRemesher" );
-		meshExt->newElements = (Snac_Element*)ExtensionManager_Malloc( mesh->elementExtensionMgr, mesh->elementLocalCount );
+		meshExt->orderedToDomain =  Memory_Alloc_Array( Element_DomainIndex, mesh->elementDomainCount, "OrderedToDomain" );
+		meshExt->newElements = Memory_Alloc_Array( SnacRemesher_Element, mesh->elementLocalCount, "NewElements" );
+		//memcpy( meshExt->newElements, mesh->element, mesh->elementExtensionMgr->finalSize * mesh->elementDomainCount );
 
-
 		/* Do the linear interpolation between grids of barycenters. */
 		_SnacRemesher_InterpolateElements( context );
 
 		/* Copy accross the new coord, node & element information to the current arrays. */
 		memcpy( mesh->nodeCoord, meshExt->newNodeCoords, mesh->nodeLocalCount * sizeof(Coord) );
 		memcpy( mesh->node, meshExt->newNodes, mesh->nodeExtensionMgr->finalSize * mesh->nodeLocalCount );
-		memcpy( mesh->element, meshExt->newElements, mesh->elementExtensionMgr->finalSize * mesh->elementLocalCount );
+		/* don't need to copy here because it's now donw in _SnacRemesher_InterpolateElements. */
+		//memcpy( mesh->element, meshExt->newElements, mesh->elementExtensionMgr->finalSize * mesh->elementLocalCount );
+		/* for( newElement_i = 0; newElement_i < mesh->elementLocalCount; newElement_i++ ) { */
+		/* 	Snac_Element* srcElement =  */
+		/* 		(Snac_Element*)ExtensionManager_At( context->mesh->elementExtensionMgr, */
+		/* 											meshExt->newElements, */
+		/* 											newElement_i ); */
+			
+		/* 	Snac_Element* dstElement = Snac_Element_At( context, newElement_i );  */
+		/* 	memcpy( dstElement, srcElement, sizeof(Snac_Element)/2 ); */
+		/* } */
 		
 		/* Update element attributes based on the new coordinates and the transferred variables. */
 		_SnacRemesher_UpdateElements( context );
@@ -173,10 +184,13 @@
 		Memory_Free( meshExt->newBarycenters ); 
 		Memory_Free( meshExt->barcoef );
 		Memory_Free( meshExt->barcord );
+		Memory_Free( meshExt->orderedToDomain ); 
+		Memory_Free( meshExt->newElements );
+
 		ExtensionManager_Free( mesh->nodeExtensionMgr, meshExt->newNodes );
-		ExtensionManager_Free( mesh->elementExtensionMgr, meshExt->newElements );
+		//ExtensionManager_Free( mesh->elementExtensionMgr, meshExt->newElements );
 		meshExt->newNodes = NULL;
-		meshExt->newElements = NULL;
+		//meshExt->newElements = NULL;
 		
 		/*
 		** If in spherical mode, convert back to cartesian coordinates.

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Remesh.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Remesh.h	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Remesh.h	2012-07-24 19:41:37 UTC (rev 20537)
@@ -54,12 +54,17 @@
 	void _SnacRemesher_InterpolateElements( void* context );
 	void _SnacRemesher_UpdateElements( void* context );
 	void _SnacRemesher_InterpolateElement(
-		void*			_context,
-		Element_LocalIndex	dstEltInd, 
-		Tetrahedra_Index	dstTetInd, 
-		Snac_Element*		dstEltArray, 
-		Element_DomainIndex	srcEltInd, 
-		Tetrahedra_Index	srcTetInd );
+		void*					_context,
+		Element_LocalIndex		dstEltInd, 
+		Tetrahedra_Index		dstTetInd, 
+		SnacRemesher_Element*	dstEltArray, 
+		Element_DomainIndex		srcEltInd, 
+		Tetrahedra_Index		srcTetInd );
+	void _SnacRemesher_CopyElement(
+		void*					_context,
+		Element_LocalIndex		eltInd, 
+		Tetrahedra_Index		tetInd, 
+		SnacRemesher_Element*	eltArray );
 
 	struct dist_id_pair { double dist; unsigned int id; };
 

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/RemeshElements.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/RemeshElements.c	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/RemeshElements.c	2012-07-24 19:41:37 UTC (rev 20537)
@@ -38,6 +38,7 @@
 #include "types.h"
 #include "EntryPoint.h"
 #include "Mesh.h"
+#include "RemesherElement.h"
 #include "Context.h"
 #include "Remesh.h"
 #include "Register.h"
@@ -79,12 +80,12 @@
 	rankPartition[1] = (context->rank-rankPartition[2]*decomp->partition3DCounts[0]*decomp->partition3DCounts[1]) / decomp->partition3DCounts[0];
 	rankPartition[0] = context->rank-rankPartition[2]*decomp->partition3DCounts[0]*decomp->partition3DCounts[1] - rankPartition[1] * decomp->partition3DCounts[0];
 	
-	have_xneg_shadow = (rankPartition[0]>0?1:0);
-	have_xpos_shadow = (rankPartition[0]<(decomp->partition3DCounts[0]-1)?1:0);
-	have_yneg_shadow = (rankPartition[1]>0?1:0);
-	have_ypos_shadow = (rankPartition[1]<(decomp->partition3DCounts[1]-1)?1:0);
-	have_zneg_shadow = (rankPartition[2]>0?1:0);
-	have_zpos_shadow = (rankPartition[2]<(decomp->partition3DCounts[2]-1)?1:0);
+	have_xneg_shadow = (((decomp->partition3DCounts[0]>1)&&(rankPartition[0]>0))?1:0);
+	have_xpos_shadow = (((decomp->partition3DCounts[0]>1)&&(rankPartition[0]<(decomp->partition3DCounts[0]-1)))?1:0);
+	have_yneg_shadow = (((decomp->partition3DCounts[1]>1)&&(rankPartition[1]>0))?1:0);
+	have_ypos_shadow = (((decomp->partition3DCounts[1]>1)&&(rankPartition[1]<(decomp->partition3DCounts[1]-1)))?1:0);
+	have_zneg_shadow = (((decomp->partition3DCounts[2]>1)&&(rankPartition[2]>0))?1:0);
+	have_zpos_shadow = (((decomp->partition3DCounts[2]>1)&&(rankPartition[2]<(decomp->partition3DCounts[2]-1)))?1:0);
 
 	meshExt->local_range_min[0] = (have_xneg_shadow?decomp->shadowDepth:0);
 	meshExt->local_range_max[0] = (have_xpos_shadow?(neldI-1-decomp->shadowDepth):(neldI-1));
@@ -112,11 +113,20 @@
 	for( element_lI = 0; element_lI < mesh->elementLocalCount; element_lI++ )
 		for(tet_I=0;tet_I<Tetrahedra_Count;tet_I++) 
 			SnacRemesher_InterpolateElement( context, contextExt,
-											 element_lI, tet_I,
-											 meshExt->newElements,
-											 meshExt->barcord[element_lI].elnum,
-											 meshExt->barcord[element_lI].tetnum );
+							element_lI, tet_I,
+							meshExt->newElements,
+							meshExt->barcord[element_lI].elnum,
+							meshExt->barcord[element_lI].tetnum );
 	
+	/* Copy interpolated element variables stored in newElements
+	   to the origianl element array. */
+	for( element_lI = 0; element_lI < mesh->elementLocalCount; element_lI++ )
+		for(tet_I=0;tet_I<Tetrahedra_Count;tet_I++) 
+			SnacRemesher_CopyElement( context, contextExt, element_lI, tet_I, 
+									  meshExt->newElements ); 
+			/* _SnacRemesher_CopyElement( context, element_lI, tet_I, */
+			/* 						  meshExt->newElements ); */
+
 }
 
  
@@ -145,32 +155,30 @@
   Interpolate an element's tetrahedra.
   Note that srcEltInd and srcTetInd are those of the old barycenter grid.
 */
-void _SnacRemesher_InterpolateElement( void*				_context, 
-									   Element_LocalIndex	dstEltInd, 
-									   Tetrahedra_Index		tetInd, 
-									   Snac_Element*		dstEltArray, 
-									   Element_DomainIndex	srcEltInd, 
-									   Tetrahedra_Index		srcTetInd )
+void _SnacRemesher_InterpolateElement( void* _context, 
+					Element_LocalIndex	dstEltInd, 
+					Tetrahedra_Index	tetInd, 
+					SnacRemesher_Element*	dstEltArray, 
+					Element_DomainIndex	srcEltInd, 
+					Tetrahedra_Index	srcTetInd )
 {
 
 	Snac_Context*		context = (Snac_Context*)_context;
-	Mesh*				mesh = context->mesh;
+	Mesh*			mesh = context->mesh;
 	SnacRemesher_Mesh*	meshExt = ExtensionManager_Get( context->meshExtensionMgr,
-														mesh, 
-														SnacRemesher_MeshHandle );
-	HexaMD*				decomp = (HexaMD*)mesh->layout->decomp;
-	Snac_Element*		dstElt = (Snac_Element*)ExtensionManager_At( context->mesh->elementExtensionMgr, 
-																	 dstEltArray, 
-																	 dstEltInd );
-	Element_DomainIndex eltdI[8],eldI,eldJ,eldK;
-	double 				dblMaterial_I;
-	Index 				coef_I;
+								mesh, 
+								SnacRemesher_MeshHandle );
+	HexaMD*			decomp = (HexaMD*)mesh->layout->decomp;
+	SnacRemesher_Element* 	dstElt = &dstEltArray[dstEltInd];
+	Element_DomainIndex 	eltdI[8],eldI,eldJ,eldK;
+	double 			dblMaterial_I;
+	Index 			coef_I;
 
 	Element_DomainIndex	neldI =  decomp->elementDomain3DCounts[0];
 	Element_DomainIndex	neldJ =  decomp->elementDomain3DCounts[1];
 	Element_DomainIndex	neldK =  decomp->elementDomain3DCounts[2];
 
-	enum					{ threeD, xy, undefined } geomType;
+	enum			{ threeD, xy, undefined } geomType;
 	
 	geomType = undefined;
 	if( neldI>1 && neldJ>1 && neldK>1 ) geomType = threeD;
@@ -194,18 +202,15 @@
 		eltdI[5] = (eldI+1) + eldJ*neldI     + (eldK+1)*neldI*neldJ;
 		eltdI[6] = (eldI+1) + (eldJ+1)*neldI + (eldK+1)*neldI*neldJ;
 		eltdI[7] = eldI     + (eldJ+1)*neldI + (eldK+1)*neldI*neldJ;
-		/* if(context->rank==13 && (dstEltInd==0 || dstEltInd==26)) fprintf(stderr,"%d %d src:%d (%d %d %d) (%d %d %d %d %d %d %d %d) srcTet:%d\n", */
-		/* 							  dstEltInd,tetInd,srcEltInd,eldI,eldJ,eldK, */
-		/* 							  eltdI[0],eltdI[1],eltdI[2],eltdI[3], */
-		/* 							  eltdI[4],eltdI[5],eltdI[6],eltdI[7],srcTetInd); */
-		
-		memset( dstElt->tetra[tetInd].strain, 0, sizeof(double)*3*3 );
-		memset( dstElt->tetra[tetInd].stress, 0, sizeof(double)*3*3 );
+
+		memset( dstElt->tetra[tetInd].strain, 0, sizeof(StrainTensor) );
+		memset( dstElt->tetra[tetInd].stress, 0, sizeof(StressTensor) );
 		dblMaterial_I = 0.0;
 		dstElt->tetra[tetInd].density = 0.0;
 
 		for(coef_I=0;coef_I<4;coef_I++) {
 			/* The actual src elements are the apexes of the tet in the old barycenter grid. */
+			/* fprintf(stderr,"dstEl=%d dstTet=%d from src: %d %d\n",dstEltInd,tetInd,eltdI[TetraToNode[srcTetInd][coef_I]],meshExt->orderedToDomain[eltdI[TetraToNode[srcTetInd][coef_I]]]); */
 			Snac_Element* srcElt = Snac_Element_At( context, meshExt->orderedToDomain[eltdI[TetraToNode[srcTetInd][coef_I]]] );
 
 			dstElt->tetra[tetInd].strain[0][0] += meshExt->barcord[dstEltInd].L[coef_I]*srcElt->tetra[tetInd].strain[0][0];
@@ -225,6 +230,12 @@
 			dblMaterial_I += meshExt->barcord[dstEltInd].L[coef_I]*srcElt->tetra[tetInd].material_I;
 			dstElt->tetra[tetInd].density += meshExt->barcord[dstEltInd].L[coef_I]*srcElt->tetra[tetInd].density;
 		}
+		dstElt->tetra[tetInd].strain[1][0] = dstElt->tetra[tetInd].strain[0][1];
+		dstElt->tetra[tetInd].strain[2][0] = dstElt->tetra[tetInd].strain[0][2];
+		dstElt->tetra[tetInd].strain[2][1] = dstElt->tetra[tetInd].strain[1][2];
+		dstElt->tetra[tetInd].stress[1][0] = dstElt->tetra[tetInd].stress[0][1];
+		dstElt->tetra[tetInd].stress[2][0] = dstElt->tetra[tetInd].stress[0][2];
+		dstElt->tetra[tetInd].stress[2][1] = dstElt->tetra[tetInd].stress[1][2];
 		dstElt->tetra[tetInd].material_I = (Material_Index)dblMaterial_I;
 		break;
 	case xy:
@@ -238,8 +249,8 @@
 		eltdI[2] = (eldI+1) + (eldJ+1)*neldI;
 		eltdI[3] = eldI     + (eldJ+1)*neldI;
 		
-		memset( dstElt->tetra[tetInd].strain, 0, sizeof(double)*3*3 );
-		memset( dstElt->tetra[tetInd].stress, 0, sizeof(double)*3*3 );
+		memset( dstElt->tetra[tetInd].strain, 0, sizeof(StrainTensor) );
+		memset( dstElt->tetra[tetInd].stress, 0, sizeof(StressTensor) );
 		dblMaterial_I = 0.0;
 		dstElt->tetra[tetInd].density = 0.0;
 
@@ -264,13 +275,47 @@
 			dblMaterial_I += meshExt->barcord[dstEltInd].L[coef_I]*srcElt->tetra[tetInd].material_I;
 			dstElt->tetra[tetInd].density += meshExt->barcord[dstEltInd].L[coef_I]*srcElt->tetra[tetInd].density;
 		}
+		dstElt->tetra[tetInd].strain[1][0] = dstElt->tetra[tetInd].strain[0][1];
+		dstElt->tetra[tetInd].strain[2][0] = dstElt->tetra[tetInd].strain[0][2];
+		dstElt->tetra[tetInd].strain[2][1] = dstElt->tetra[tetInd].strain[1][2];
+		dstElt->tetra[tetInd].stress[1][0] = dstElt->tetra[tetInd].stress[0][1];
+		dstElt->tetra[tetInd].stress[2][0] = dstElt->tetra[tetInd].stress[0][2];
+		dstElt->tetra[tetInd].stress[2][1] = dstElt->tetra[tetInd].stress[1][2];
 		dstElt->tetra[tetInd].material_I = (Material_Index)dblMaterial_I;
 		break;
 	}
 
 }
 
+/*
+  Copy interpolated values stored in newElement array 
+  back to the original element array. 
+*/
+void _SnacRemesher_CopyElement( void*					_context, 
+								Element_LocalIndex		EltInd, 
+								Tetrahedra_Index		tetInd, 
+								SnacRemesher_Element*	elementArray )
+{
 
+	Snac_Context*		context = (Snac_Context*)_context;
+	SnacRemesher_Element* srcElt;
+	Snac_Element* dstElt;
+
+	Index i,j;
+
+	srcElt = &elementArray[EltInd];
+	dstElt = Snac_Element_At( context, EltInd );
+	for( i=0; i<3; i++ )
+		for( j=0; j<3; j++ ) {
+			dstElt->tetra[tetInd].strain[i][j] = srcElt->tetra[tetInd].strain[i][j]; 
+			dstElt->tetra[tetInd].stress[i][j] = srcElt->tetra[tetInd].stress[i][j]; 
+		}
+	dstElt->tetra[tetInd].density = srcElt->tetra[tetInd].density;
+	dstElt->tetra[tetInd].material_I = srcElt->tetra[tetInd].material_I;
+
+}
+
+
 void createBarycenterGrids( void* _context )
 {
 	Snac_Context*			context = (Snac_Context*)_context;
@@ -336,7 +381,7 @@
 			nLayout->buildElementNodes( nLayout, gEltInd, eltNodes );
 		}
 		
-		/* Convert global node indices to local. */
+		/* Convert global node indices to domain. */
 		{
 			unsigned	eltNode_i;
 			tempBC[element_dI][0] = 0.0;
@@ -350,7 +395,7 @@
 			}
 		}
 	}
-	/* Sort the tempBC arry for a structured BC grid. */
+	/* Sort the tempBC array for a structured BC grid. */
 	{
 		Element_LocalIndex  nLElI = decomp->elementLocal3DCounts[context->rank][0];
 		Element_LocalIndex  nLElJ = decomp->elementLocal3DCounts[context->rank][1];
@@ -438,22 +483,10 @@
 				element_dI = eldI+eldJ*neldI;
 					
 				/* Four-node element defined. */
-				/* if(context->rank==13) */
-				/* 	fprintf(stderr,"element_dI=%d (%d %d) (%d %d) (%d %d %d %d)\n",element_dI, */
-				/* 			neldI,neldJ,nellI,nellJ */
-				/* 			eldI     + eldJ*neldI     */
-				/* 			(eldI+1) + eldJ*neldI     */
-				/* 			(eldI+1) + (eldJ+1)*neldI */
-				/* 			eldI     + (eldJ+1)*neldI */
 				Vector_Set( hexCrds[0], meshExt->oldBarycenters[eldI     + eldJ*neldI    ] );
 				Vector_Set( hexCrds[1], meshExt->oldBarycenters[(eldI+1) + eldJ*neldI    ] );
 				Vector_Set( hexCrds[2], meshExt->oldBarycenters[(eldI+1) + (eldJ+1)*neldI] );
 				Vector_Set( hexCrds[3], meshExt->oldBarycenters[eldI     + (eldJ+1)*neldI] );
-				/* fprintf(stderr,"(%.2e,%.2e,%.2e) (%.2e,%.2e,%.2e) (%.2e,%.2e,%.2e) (%.2e,%.2e,%.2e)\n", */
-				/* 		hexCrds[0][0],hexCrds[0][1],hexCrds[0][2], */
-				/* 		hexCrds[1][0],hexCrds[1][1],hexCrds[1][2], */
-				/* 		hexCrds[2][0],hexCrds[2][1],hexCrds[2][2], */
-				/* 		hexCrds[3][0],hexCrds[3][1],hexCrds[3][2] ); */
 				
 				for(tri_I=0;tri_I<2;tri_I++) {
 					/*
@@ -490,13 +523,6 @@
 						meshExt->barcoef[element_dI].coef[tri_I][0][2] -= meshExt->barcoef[element_dI].coef[tri_I][0][coef_i]*hexCrds[TriToNode[tri_I][2]][coef_i];
 						meshExt->barcoef[element_dI].coef[tri_I][1][2] -= meshExt->barcoef[element_dI].coef[tri_I][1][coef_i]*hexCrds[TriToNode[tri_I][2]][coef_i];
 					}
-					/* fprintf(stderr,"element_dI=%d (%e %e %e) (%e %e %e)\n",element_dI, */
-					/* 		meshExt->barcoef[element_dI].coef[tet_I][0][0], */
-					/* 		meshExt->barcoef[element_dI].coef[tet_I][0][1], */
-					/* 		meshExt->barcoef[element_dI].coef[tet_I][0][2], */
-					/* 		meshExt->barcoef[element_dI].coef[tet_I][1][0], */
-					/* 		meshExt->barcoef[element_dI].coef[tet_I][1][1], */
-					/* 		meshExt->barcoef[element_dI].coef[tet_I][1][2], */
 				}
 			}
 		break;
@@ -504,25 +530,14 @@
 		for( eldK = 0; eldK < neldK-1; eldK++ ) 
 			for( eldJ = 0; eldJ < neldJ-1; eldJ++ ) 
 				for( eldI = 0; eldI < neldI-1; eldI++ ) {
-					Coord				hexCrds[8];
+					Coord			hexCrds[8];
 					Tetrahedra_Index	tet_I;
-					Index				coef_i;
+					Index			coef_i;
 					
 					/* Old domain grid is constructed: i.e., ghost elements are included in this grid. */
 					element_dI = eldI+eldJ*neldI+eldK*neldI*neldJ;
 					
 					/* Eight-node hex defined. */
-					/* if(context->rank==13) */
-					/* 	fprintf(stderr,"element_dI=%d (%d %d %d) (%d %d %d) (%d %d %d %d %d %d %d %d)\n",element_dI, */
-					/* 			neldI,neldJ,neldK,nellI,nellJ,nellK, */
-					/* 			eldI     + eldJ*neldI     + eldK*neldI*neldJ, */
-					/* 			(eldI+1) + eldJ*neldI     + eldK*neldI*neldJ, */
-					/* 			(eldI+1) + (eldJ+1)*neldI + eldK*neldI*neldJ, */
-					/* 			eldI     + (eldJ+1)*neldI + eldK*neldI*neldJ, */
-					/* 			eldI     + eldJ*neldI     + (eldK+1)*neldI*neldJ, */
-					/* 			(eldI+1) + eldJ*neldI     + (eldK+1)*neldI*neldJ, */
-					/* 			(eldI+1) + (eldJ+1)*neldI + (eldK+1)*neldI*neldJ, */
-					/* 			eldI     + (eldJ+1)*neldI + (eldK+1)*neldI*neldJ); */
 					Vector_Set( hexCrds[0], meshExt->oldBarycenters[eldI     + eldJ*neldI     + eldK*neldI*neldJ    ] );
 					Vector_Set( hexCrds[1], meshExt->oldBarycenters[(eldI+1) + eldJ*neldI     + eldK*neldI*neldJ    ] );
 					Vector_Set( hexCrds[2], meshExt->oldBarycenters[(eldI+1) + (eldJ+1)*neldI + eldK*neldI*neldJ    ] );
@@ -531,16 +546,6 @@
 					Vector_Set( hexCrds[5], meshExt->oldBarycenters[(eldI+1) + eldJ*neldI     + (eldK+1)*neldI*neldJ] );
 					Vector_Set( hexCrds[6], meshExt->oldBarycenters[(eldI+1) + (eldJ+1)*neldI + (eldK+1)*neldI*neldJ] );
 					Vector_Set( hexCrds[7], meshExt->oldBarycenters[eldI     + (eldJ+1)*neldI + (eldK+1)*neldI*neldJ] );
-					/* fprintf(stderr,"(%.2e,%.2e,%.2e) (%.2e,%.2e,%.2e) (%.2e,%.2e,%.2e) (%.2e,%.2e,%.2e)\n", */
-					/* 		hexCrds[0][0],hexCrds[0][1],hexCrds[0][2], */
-					/* 		hexCrds[1][0],hexCrds[1][1],hexCrds[1][2], */
-					/* 		hexCrds[2][0],hexCrds[2][1],hexCrds[2][2], */
-					/* 		hexCrds[3][0],hexCrds[3][1],hexCrds[3][2] ); */
-					/* fprintf(stderr,"(%.2e,%.2e,%.2e) (%.2e,%.2e,%.2e) (%.2e,%.2e,%.2e) (%.2e,%.2e,%.2e)\n", */
-					/* 		hexCrds[4][0],hexCrds[4][1],hexCrds[4][2], */
-					/* 		hexCrds[5][0],hexCrds[5][1],hexCrds[5][2], */
-					/* 		hexCrds[6][0],hexCrds[6][1],hexCrds[6][2], */
-					/* 		hexCrds[7][0],hexCrds[7][1],hexCrds[7][2] ); */
 					
 					for(tet_I=0;tet_I<5;tet_I++) {
 						/*
@@ -591,19 +596,6 @@
 							meshExt->barcoef[element_dI].coef[tet_I][1][3] -= meshExt->barcoef[element_dI].coef[tet_I][1][coef_i]*hexCrds[TetraToNode[tet_I][3]][coef_i];
 							meshExt->barcoef[element_dI].coef[tet_I][2][3] -= meshExt->barcoef[element_dI].coef[tet_I][2][coef_i]*hexCrds[TetraToNode[tet_I][3]][coef_i];
 						}
-						/* fprintf(stderr,"element_dI=%d (%e %e %e %e) (%e %e %e %e) (%e %e %e %e)\n",element_dI, */
-						/* 		meshExt->barcoef[element_dI].coef[tet_I][0][0], */
-						/* 		meshExt->barcoef[element_dI].coef[tet_I][0][1], */
-						/* 		meshExt->barcoef[element_dI].coef[tet_I][0][2], */
-						/* 		meshExt->barcoef[element_dI].coef[tet_I][0][3], */
-						/* 		meshExt->barcoef[element_dI].coef[tet_I][1][0], */
-						/* 		meshExt->barcoef[element_dI].coef[tet_I][1][1], */
-						/* 		meshExt->barcoef[element_dI].coef[tet_I][1][2], */
-						/* 		meshExt->barcoef[element_dI].coef[tet_I][1][3], */
-						/* 		meshExt->barcoef[element_dI].coef[tet_I][2][0], */
-						/* 		meshExt->barcoef[element_dI].coef[tet_I][2][1], */
-						/* 		meshExt->barcoef[element_dI].coef[tet_I][2][2], */
-						/* 		meshExt->barcoef[element_dI].coef[tet_I][2][3]); */
 					}
 				}
 	break;
@@ -680,11 +672,6 @@
 					if(mindK==maxdK) maxdK++;
 					
 					found_tet = 0;
-
-					/* if(context->rank==1) { */
-					/* 	fprintf(stderr,"Looking %d (ijk:%d/%d %d/%d %d/%d)\n",element_lI,ellI,nellI-1,ellJ,nellJ-1,ellK,nellK-1); */
-					/* 	fprintf(stderr,"           %d to %d/%d %d to %d/%d %d to %d/%d)\n",mindI,maxdI,neldI-1,mindJ,maxdJ,neldJ-1,mindK,maxdK,neldK-1); */
-					/* } */
 					
 					for( eldK = mindK; eldK < maxdK; eldK++ ) {
 						for( eldJ = mindJ; eldJ < maxdJ; eldJ++ ) {
@@ -703,22 +690,6 @@
 											meshExt->barcoef[element_dI].coef[tet_I][coef_I][2] * meshExt->newBarycenters[element_lI][2] +
 											meshExt->barcoef[element_dI].coef[tet_I][coef_I][3];
 										lambda[3] -= lambda[coef_I];
-
-										/* if(context->rank==1 && element_lI==0) { */
-										/* 	fprintf(stderr,"lambda[%d]=%e lambda[3]=%e in elD %d (newBC: %e %e %e, coef: %e %e %e %e)\n", */
-										/* 			coef_I,lambda[coef_I],lambda[3],element_dI, */
-										/* 			meshExt->newBarycenters[element_lI][0], */
-										/* 			meshExt->newBarycenters[element_lI][1], */
-										/* 			meshExt->newBarycenters[element_lI][2], */
-										/* 			meshExt->barcoef[element_dI].coef[tet_I][coef_I][0], */
-										/* 			meshExt->barcoef[element_dI].coef[tet_I][coef_I][1], */
-										/* 			meshExt->barcoef[element_dI].coef[tet_I][coef_I][2], */
-										/* 			meshExt->barcoef[element_dI].coef[tet_I][coef_I][3]); */
-										/* fprintf(stderr," old BC: %e %e %e\t%e %e%e\t%e %e %e\t%e %e %e\n", */
-										/* 		hexCrds[TetraToNode[tet_I][0]][0], hexCrds[TetraToNode[tet_I][0]][1], hexCrds[TetraToNode[tet_I][0]][2], */
-										/* 		hexCrds[TetraToNode[tet_I][1]][0], hexCrds[TetraToNode[tet_I][1]][1], hexCrds[TetraToNode[tet_I][1]][2], */
-										/* 		hexCrds[TetraToNode[tet_I][2]][0], hexCrds[TetraToNode[tet_I][2]][1], hexCrds[TetraToNode[tet_I][2]][2], */
-										/* 		hexCrds[TetraToNode[tet_I][3]][0], hexCrds[TetraToNode[tet_I][3]][1], hexCrds[TetraToNode[tet_I][3]][2]); */
 									}
 
 									/* Keep track of closest element in case the current new barycenter is outside of the old grid. */
@@ -730,8 +701,6 @@
 										closest_dI = element_dI;
 										closest_tI = tet_I;
 									}
-									/* if(context->rank==0 && element_lI==0)  */
-									/* 	fprintf(stderr,"lamda_sqrd=%e min=%e (%d %d)\n",lambda_sqrd,lambda_sqrd_min,closest_dI,closest_tI); */
 									
 									/* See if the barycenter is inside this tet. */
 									if( (lambda[0] >= -tol_error && lambda[0] <= (1.0+tol_error)) &&
@@ -742,22 +711,17 @@
 										memcpy( meshExt->barcord[element_lI].L, lambda, sizeof(double)*4);
 										meshExt->barcord[element_lI].elnum = element_dI;
 										meshExt->barcord[element_lI].tetnum = tet_I;
-										/* if(context->rank==13) */
-										/* 	fprintf(stderr,"%d (ijk:%d %d %d) in %d %d: %e %e %e %e\n",element_lI,ellI,ellJ,ellK,element_dI,tet_I, */
-										/* 		meshExt->barcord[element_lI].L[0], */
-										/* 		meshExt->barcord[element_lI].L[1], */
-										/* 		meshExt->barcord[element_lI].L[2], */
-										/* 		meshExt->barcord[element_lI].L[3]); */
+
 										break; /* break tet loop */
 									}
 								} /* end of tet loop */
+								if( found_tet ) break; /* break eldI loop */
 							}
-							if( found_tet ) break; /* break eldI loop */
+							if( found_tet ) break; /* break eldJ loop */
 						}
-						if( found_tet ) break; /* break eldJ loop */
+						if( found_tet ) break; /* break eldK loop */
 					}
-					if( found_tet ) break; /* break eldK loop */
-	
+					
 					/* see if the point is outside of the old mesh.
 					   Assumed is that the current new barycenter is at least closest to "closest_dI" element. */
 					if( !found_tet ) { 
@@ -802,13 +766,6 @@
 						meshExt->barcord[element_lI].L[dist_apexes[3].id] = 0.0;
 						meshExt->barcord[element_lI].elnum = closest_dI;
 						meshExt->barcord[element_lI].tetnum = closest_tI;
-						
-						/* fprintf(stderr,"Possible Outside: rank:%d, %d (ijk:%d %d %d) closest to %d %d: %e %e %e %e\n",context->rank, */
-						/* 		element_lI,ellI,ellJ,ellK,closest_dI,closest_tI, */
-						/* 		meshExt->barcord[element_lI].L[0], */
-						/* 		meshExt->barcord[element_lI].L[1], */
-						/* 		meshExt->barcord[element_lI].L[2], */
-						/* 		meshExt->barcord[element_lI].L[3]); */
 					}
 				} /* end of local element loop */
 		break;
@@ -860,22 +817,6 @@
 									meshExt->barcoef[element_dI].coef[tri_I][coef_I][1] * meshExt->newBarycenters[element_lI][1] +
 									meshExt->barcoef[element_dI].coef[tri_I][coef_I][2];
 								lambda[2] -= lambda[coef_I];
-
-								/* if(context->rank==1 && element_lI==0) { */
-								/* 	fprintf(stderr,"lambda[%d]=%e lambda[3]=%e in elD %d (newBC: %e %e %e, coef: %e %e %e %e)\n", */
-								/* 			coef_I,lambda[coef_I],lambda[3],element_dI, */
-								/* 			meshExt->newBarycenters[element_lI][0], */
-								/* 			meshExt->newBarycenters[element_lI][1], */
-								/* 			meshExt->newBarycenters[element_lI][2], */
-								/* 			meshExt->barcoef[element_dI].coef[tet_I][coef_I][0], */
-								/* 			meshExt->barcoef[element_dI].coef[tet_I][coef_I][1], */
-								/* 			meshExt->barcoef[element_dI].coef[tet_I][coef_I][2], */
-								/* 			meshExt->barcoef[element_dI].coef[tet_I][coef_I][3]); */
-								/* fprintf(stderr," old BC: %e %e %e\t%e %e%e\t%e %e %e\t%e %e %e\n", */
-								/* 		hexCrds[TetraToNode[tet_I][0]][0], hexCrds[TetraToNode[tet_I][0]][1], hexCrds[TetraToNode[tet_I][0]][2], */
-								/* 		hexCrds[TetraToNode[tet_I][1]][0], hexCrds[TetraToNode[tet_I][1]][1], hexCrds[TetraToNode[tet_I][1]][2], */
-								/* 		hexCrds[TetraToNode[tet_I][2]][0], hexCrds[TetraToNode[tet_I][2]][1], hexCrds[TetraToNode[tet_I][2]][2], */
-								/* 		hexCrds[TetraToNode[tet_I][3]][0], hexCrds[TetraToNode[tet_I][3]][1], hexCrds[TetraToNode[tet_I][3]][2]); */
 							}
 							
 							/* Keep track of closest element in case the current new barycenter is outside of the old grid. */
@@ -887,8 +828,6 @@
 								closest_dI = element_dI;
 								closest_tI = tri_I;
 							}
-							/* if(context->rank==0 && element_lI==0)  */
-							/* 	fprintf(stderr,"lamda_sqrd=%e min=%e (%d %d)\n",lambda_sqrd,lambda_sqrd_min,closest_dI,closest_tI); */
 							
 							/* See if the barycenter is inside this tet. */
 							if( (lambda[0] >= -tol_error && lambda[0] <= (1.0+tol_error)) &&
@@ -898,12 +837,6 @@
 								memcpy( meshExt->barcord[element_lI].L, lambda, sizeof(double)*4);
 								meshExt->barcord[element_lI].elnum = element_dI;
 								meshExt->barcord[element_lI].tetnum = tri_I; /* note that this is the id of triangle in the xy case.*/
-								/* if(context->rank==13) */
-								/* 	fprintf(stderr,"%d (ijk:%d %d %d) in %d %d: %e %e %e %e\n",element_lI,ellI,ellJ,ellK,element_dI,tet_I, */
-								/* 		meshExt->barcord[element_lI].L[0], */
-								/* 		meshExt->barcord[element_lI].L[1], */
-								/* 		meshExt->barcord[element_lI].L[2], */
-								/* 		meshExt->barcord[element_lI].L[3]); */
 							}
 							if( found_tet ) break; /* break tri loop */
 						} /* end of tri loop */
@@ -952,13 +885,6 @@
 					meshExt->barcord[element_lI].L[3] = 0.0; /* dummy in the xy case. */
 					meshExt->barcord[element_lI].elnum = closest_dI;
 					meshExt->barcord[element_lI].tetnum = closest_tI; /* note that this is the id of triangle in the xy case.*/
-					
-					/* fprintf(stderr,"Possible Outside: rank:%d, %d (ijk:%d %d %d) closest to %d %d: %e %e %e %e\n",context->rank, */
-					/* 		element_lI,ellI,ellJ,ellK,closest_dI,closest_tI, */
-					/* 		meshExt->barcord[element_lI].L[0], */
-					/* 		meshExt->barcord[element_lI].L[1], */
-					/* 		meshExt->barcord[element_lI].L[2], */
-					/* 		meshExt->barcord[element_lI].L[3]); */
 				}
 			} /* end of local element loop */
 		break;
@@ -970,4 +896,3 @@
 	double v2 = ((struct dist_id_pair *)dist2)->dist;
 	return (v1<v2) ? -1 : (v1>v2) ? 1 : 0;
 };
-

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/RemeshNodes.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/RemeshNodes.c	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/RemeshNodes.c	2012-07-24 19:41:37 UTC (rev 20537)
@@ -248,6 +248,7 @@
 	dstNode->velocity[1] = 0.0;
 	dstNode->velocity[2] = 0.0;
 
+
 	/* Loop over each contributing node. */
 	for( tetNode_i = 0; tetNode_i < 4; tetNode_i++ ) {
 		Snac_Node*	srcNode;
@@ -260,5 +261,14 @@
 		dstNode->velocity[0] += srcNode->velocity[0] * weights[tetNode_i];
 		dstNode->velocity[1] += srcNode->velocity[1] * weights[tetNode_i];
 		dstNode->velocity[2] += srcNode->velocity[2] * weights[tetNode_i];
+
+		/* fprintf(stderr,"\t src vel[%d]=%e %e %e\n",tetNode_i,srcNode->velocity[0],srcNode->velocity[1],srcNode->velocity[2]); */
+		/* if(sqrt(dstNode->velocity[0]*dstNode->velocity[0]+dstNode->velocity[1]*dstNode->velocity[1]+dstNode->velocity[2]*dstNode->velocity[2])>=5e-10) { */
+		/* 	fprintf(stderr,"node=%d in element %d tet nodes: %d %d %d %d weights: %e %e %e %e\n",nodeInd,elementInd, */
+		/* 			tetNodeInds[0],tetNodeInds[1],tetNodeInds[2],tetNodeInds[3], */
+		/* 			weights[0],weights[1],weights[2],weights[3]); */
+		/* 	fprintf(stderr,"\t after vel=%e %e %e\n",dstNode->velocity[0],dstNode->velocity[1],dstNode->velocity[2]); */
+		/* } */
+
 	}
 }

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Remesher.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Remesher.h	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/Remesher.h	2012-07-24 19:41:37 UTC (rev 20537)
@@ -42,6 +42,8 @@
 	
 	#include "types.h"  
 	#include "Utils.h"
+	#include "Mesh.h"  
+	#include "RemesherElement.h"  
 	#include "Context.h"  
 	#include "Register.h"  
 	#include "ConstructExtensions.h"  

Modified: long/3D/SNAC/trunk/Snac/plugins/remesher_BI/types.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher_BI/types.h	2012-07-23 21:58:26 UTC (rev 20536)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher_BI/types.h	2012-07-24 19:41:37 UTC (rev 20537)
@@ -44,6 +44,7 @@
 	
 	/* Plastic */
 	typedef struct _SnacRemesher_Context	SnacRemesher_Context;
+	typedef struct _SnacRemesher_Element_Tetrahedra		SnacRemesher_Element_Tetrahedra;
 	typedef struct _SnacRemesher_Element	SnacRemesher_Element;
 	typedef struct _SnacRemesher_Node	SnacRemesher_Node;
 	typedef struct _SnacRemesher_Mesh	SnacRemesher_Mesh;



More information about the CIG-COMMITS mailing list