[cig-commits] r14295 - long/3D/SNAC/trunk/Snac/plugins/remesher
echoi at geodynamics.org
echoi at geodynamics.org
Wed Mar 11 12:09:36 PDT 2009
Author: echoi
Date: 2009-03-11 12:09:36 -0700 (Wed, 11 Mar 2009)
New Revision: 14295
Modified:
long/3D/SNAC/trunk/Snac/plugins/remesher/Remesh.c
long/3D/SNAC/trunk/Snac/plugins/remesher/Remesh.h
long/3D/SNAC/trunk/Snac/plugins/remesher/RemeshElements.c
long/3D/SNAC/trunk/Snac/plugins/remesher/Utils.c
long/3D/SNAC/trunk/Snac/plugins/remesher/Utils.h
Log:
* Element attributes are now explicitly updated, not copied from the old mesh.
- A new function _SnacRemesher_UpdateElements() created for that purpose.
* A new function, findClosestNodeInElement() has been created to find the cloasest node of the old mesh's corresponding element to a given tet's barycenter in the new mesh.
* In RemeshElements, the existing array defined in libSnac/src/TetrahedraTables.c is now used for the mapping between a tet's local numbering of apexes and the element's node numbering. Previously, a local array was created and used, which was redundant.
Modified: long/3D/SNAC/trunk/Snac/plugins/remesher/Remesh.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher/Remesh.c 2009-03-11 15:46:02 UTC (rev 14294)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher/Remesh.c 2009-03-11 19:09:36 UTC (rev 14295)
@@ -144,9 +144,6 @@
/* Interpolate current elemental values onto new coordinates. */
meshExt->newElements = (Snac_Element*)ExtensionManager_Malloc( mesh->elementExtensionMgr, mesh->elementLocalCount );
- /* Store element-level variables. This is temporary. They sould be updated after the nearest neighbor transfer is done on the tet level. */
- memcpy( meshExt->newElements, mesh->element, mesh->elementExtensionMgr->finalSize * mesh->elementLocalCount );
-
/* Do the nearest neighbor transfer between tets. */
_SnacRemesher_InterpolateElements( context );
@@ -156,6 +153,9 @@
memcpy( mesh->node, meshExt->newNodes, mesh->nodeExtensionMgr->finalSize * mesh->nodeLocalCount );
memcpy( mesh->element, meshExt->newElements, mesh->elementExtensionMgr->finalSize * mesh->elementLocalCount );
+ /* Update element attributes based on the new coordinates and the transferred variables. */
+ _SnacRemesher_UpdateElements( context );
+
/* Free some space, as it won't be needed until the next remesh. */
ExtensionManager_Free( mesh->nodeExtensionMgr, meshExt->newNodes );
ExtensionManager_Free( mesh->elementExtensionMgr, meshExt->newElements );
Modified: long/3D/SNAC/trunk/Snac/plugins/remesher/Remesh.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher/Remesh.h 2009-03-11 15:46:02 UTC (rev 14294)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher/Remesh.h 2009-03-11 19:09:36 UTC (rev 14295)
@@ -52,6 +52,7 @@
Snac_Node* dstNodes );
void _SnacRemesher_InterpolateElements( void* context );
+ void _SnacRemesher_UpdateElements( void* context );
void _SnacRemesher_InterpolateElement(
void* _context,
Element_LocalIndex dstEltInd,
Modified: long/3D/SNAC/trunk/Snac/plugins/remesher/RemeshElements.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher/RemeshElements.c 2009-03-11 15:46:02 UTC (rev 14294)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher/RemeshElements.c 2009-03-11 19:09:36 UTC (rev 14295)
@@ -62,18 +62,6 @@
IndexSet* extElements;
Element_LocalIndex newElt_i;
- const unsigned nTets = 10;
- const unsigned nSub[] = { 0, 2, 3, 7,
- 0, 1, 2, 5,
- 4, 7, 5, 0,
- 5, 7, 6, 2,
- 5, 7, 2, 0,
- 3, 7, 4, 6,
- 4, 0, 3, 1,
- 6, 2, 1, 3,
- 1, 5, 6, 4,
- 1, 6, 3, 4 };
-
void Tet_Barycenter( Coord tetCrds[4], Coord center );
void interpolateElement( void* _context,
Element_LocalIndex newEltInd,
@@ -128,7 +116,7 @@
}
}
- for( tet_i = 0; tet_i < nTets; tet_i++ ) {
+ for( tet_i = 0; tet_i < Tetrahedra_Count; tet_i++ ) {
Coord tetCrds[4];
Coord bc;
Node_DomainIndex dNodeInd;
@@ -139,17 +127,17 @@
unsigned minTetInd, minEltInd;
/* Extract the tetrahedron's coordinates. */
- Vector_Set( tetCrds[0], meshExt->newNodeCoords[eltNodes[nSub[tet_i * 4 + 0]]] );
- Vector_Set( tetCrds[1], meshExt->newNodeCoords[eltNodes[nSub[tet_i * 4 + 1]]] );
- Vector_Set( tetCrds[2], meshExt->newNodeCoords[eltNodes[nSub[tet_i * 4 + 2]]] );
- Vector_Set( tetCrds[3], meshExt->newNodeCoords[eltNodes[nSub[tet_i * 4 + 3]]] );
+ Vector_Set( tetCrds[0], meshExt->newNodeCoords[eltNodes[TetraToNode[tet_i][0]]] );
+ Vector_Set( tetCrds[1], meshExt->newNodeCoords[eltNodes[TetraToNode[tet_i][1]]] );
+ Vector_Set( tetCrds[2], meshExt->newNodeCoords[eltNodes[TetraToNode[tet_i][2]]] );
+ Vector_Set( tetCrds[3], meshExt->newNodeCoords[eltNodes[TetraToNode[tet_i][3]]] );
/* Calculate the barycenter of this tetrahedron. */
Tet_Barycenter( tetCrds, bc );
/* Locate the closest node to the barycenter. We use index zero of the tethrahedra coordinates
as a reference. */
- dNodeInd = findClosestNode( context, bc, eltNodes[nSub[tet_i * 4]] );
+ dNodeInd = findClosestNodeInElement( context, bc, nEltNodes, eltNodes );
/* Grab incident elements. */
{
@@ -239,7 +227,27 @@
Stg_Class_Delete( extElements );
}
+void _SnacRemesher_UpdateElements( void* _context ) {
+ Snac_Context* context = (Snac_Context*)_context;
+ Element_LocalIndex element_lI;
+
+ /* Update all the elements, and in the process work out this processor's minLengthScale */
+ for( element_lI = 0; element_lI < context->mesh->elementLocalCount; element_lI++ ) {
+ double elementMinLengthScale;
+
+ KeyCall( context, context->updateElementK, Snac_UpdateElementMomentum_CallCast* )
+ ( KeyHandle(context,context->updateElementK),
+ context,
+ element_lI,
+ &elementMinLengthScale );
+ if( elementMinLengthScale < context->minLengthScale ) {
+ context->minLengthScale = elementMinLengthScale;
+ }
+ }
+}
+
+
/*
** Locate the tetrahedra the barycenter falls in and interpolate from there.
*/
@@ -264,21 +272,8 @@
Node_DomainIndex* eltNodes;
unsigned tet_i;
- const unsigned nTets = 10;
- const unsigned nSub[] = { 0, 2, 3, 7,
- 0, 1, 2, 5,
- 4, 7, 5, 0,
- 5, 7, 6, 2,
- 5, 7, 2, 0,
- 3, 7, 4, 6,
- 4, 0, 3, 1,
- 6, 2, 1, 3,
- 1, 5, 6, 4,
- 1, 6, 3, 4 };
-
void Tet_Barycenter( Coord tetCrds[4], Coord center );
-
/* Extract the element's node indices. Note that there should always be eight of these. */
{
Element_GlobalIndex gEltInd;
@@ -300,16 +295,16 @@
/* Loop over 10 sub tets in a brick element, calculate the distance from its barycenter to the supplied one. */
{
- for( tet_i = 0; tet_i < nTets; tet_i++ ) {
+ for( tet_i = 0; tet_i < Tetrahedra_Count; tet_i++ ) {
Coord tCrds[4];
Coord bc;
double dist;
/* Extract the tetrahedron's coordinates. */
- Vector_Set( tCrds[0], mesh->nodeCoord[eltNodes[nSub[tet_i * 4 + 0]]] );
- Vector_Set( tCrds[1], mesh->nodeCoord[eltNodes[nSub[tet_i * 4 + 1]]] );
- Vector_Set( tCrds[2], mesh->nodeCoord[eltNodes[nSub[tet_i * 4 + 2]]] );
- Vector_Set( tCrds[3], mesh->nodeCoord[eltNodes[nSub[tet_i * 4 + 3]]] );
+ Vector_Set( tCrds[0], mesh->nodeCoord[eltNodes[TetraToNode[tet_i][0]]] );
+ Vector_Set( tCrds[1], mesh->nodeCoord[eltNodes[TetraToNode[tet_i][1]]] );
+ Vector_Set( tCrds[2], mesh->nodeCoord[eltNodes[TetraToNode[tet_i][2]]] );
+ Vector_Set( tCrds[3], mesh->nodeCoord[eltNodes[TetraToNode[tet_i][3]]] );
/* Calc the barycenter. */
Tet_Barycenter( tCrds, bc );
@@ -359,21 +354,8 @@
unsigned minTetInd;
unsigned tet_i;
- const unsigned nTets = 10;
- const unsigned nSub[] = { 0, 2, 3, 7,
- 0, 1, 2, 5,
- 4, 7, 5, 0,
- 5, 7, 6, 2,
- 5, 7, 2, 0,
- 3, 7, 4, 6,
- 4, 0, 3, 1,
- 6, 2, 1, 3,
- 1, 5, 6, 4,
- 1, 6, 3, 4 };
-
void Tet_Barycenter( Coord tetCrds[4], Coord center );
-
/* Extract the element's node indices. Note that there should always be eight of these. */
{
Element_GlobalIndex gEltInd;
@@ -397,16 +379,16 @@
{
double minDist;
- for( tet_i = 0; tet_i < nTets; tet_i++ ) {
+ for( tet_i = 0; tet_i < Tetrahedra_Count; tet_i++ ) {
Coord tCrds[4];
Coord bc;
double dist;
/* Extract the tetrahedron's coordinates. */
- Vector_Set( tCrds[0], mesh->nodeCoord[eltNodes[nSub[tet_i * 4 + 0]]] );
- Vector_Set( tCrds[1], mesh->nodeCoord[eltNodes[nSub[tet_i * 4 + 1]]] );
- Vector_Set( tCrds[2], mesh->nodeCoord[eltNodes[nSub[tet_i * 4 + 2]]] );
- Vector_Set( tCrds[3], mesh->nodeCoord[eltNodes[nSub[tet_i * 4 + 3]]] );
+ Vector_Set( tCrds[0], mesh->nodeCoord[eltNodes[TetraToNode[tet_i][0]]] );
+ Vector_Set( tCrds[1], mesh->nodeCoord[eltNodes[TetraToNode[tet_i][0]]] );
+ Vector_Set( tCrds[2], mesh->nodeCoord[eltNodes[TetraToNode[tet_i][0]]] );
+ Vector_Set( tCrds[3], mesh->nodeCoord[eltNodes[TetraToNode[tet_i][0]]] );
/* Calc the barycenter. */
Tet_Barycenter( tCrds, bc );
Modified: long/3D/SNAC/trunk/Snac/plugins/remesher/Utils.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher/Utils.c 2009-03-11 15:46:02 UTC (rev 14294)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher/Utils.c 2009-03-11 19:09:36 UTC (rev 14295)
@@ -129,6 +129,35 @@
}
+Node_DomainIndex findClosestNodeInElement( void* _context, Coord point, unsigned nEltNodes, Node_DomainIndex *eltNodes ) {
+ Snac_Context* context = (Snac_Context*)_context;
+ Mesh* mesh = context->mesh;
+ Bool done = False;
+ unsigned eltNode_i;
+ Coord tmp;
+ double minDist = 1.0e+32;
+ Node_DomainIndex minNode = 0;
+
+ /*
+ ** Search through the mesh's old coordinates to find the closest node to the new node 'newNode'.
+ */
+
+ /* Get the distance from the current new node to the element nodes in the old mesh. */
+ for( eltNode_i = 0; eltNode_i < nEltNodes; eltNode_i++ ) {
+ double dist=0.0;
+
+ Vector_Sub( tmp, point, mesh->nodeCoord[eltNodes[eltNode_i]] );
+ dist = Vector_Mag( tmp );
+
+ if( dist < minDist ) {
+ minDist = dist;
+ minNode = eltNodes[eltNode_i];
+ }
+ }
+
+ return minNode;
+}
+
/*
** Determine if 'point' is inside the element corresponding to 'dElementInd'.
*/
Modified: long/3D/SNAC/trunk/Snac/plugins/remesher/Utils.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/remesher/Utils.h 2009-03-11 15:46:02 UTC (rev 14294)
+++ long/3D/SNAC/trunk/Snac/plugins/remesher/Utils.h 2009-03-11 19:09:36 UTC (rev 14295)
@@ -49,6 +49,8 @@
Node_DomainIndex findClosestNode( void* _context, Coord point, Node_LocalIndex refNodeInd );
+
+ Node_DomainIndex findClosestNodeInElement( void* _context, Coord point, unsigned nEltNodes, Node_DomainIndex *eltNodes );
Bool pointInElement( void* _context, Coord point, Element_DomainIndex dElementInd );
More information about the CIG-COMMITS
mailing list