[cig-commits] commit:

Mercurial hg at geodynamics.org
Mon Nov 24 11:59:27 PST 2008


changeset:   141:70f99741dd90
user:        LukeHodkinson
date:        Tue Aug 26 17:12:55 2008 +0000
files:       Utils/src/MeshBoundaryShape.c Utils/src/MeshBoundaryShape.h Utils/src/RegularRemesher.c Utils/src/RegularRemesher.def
description:
Adding code to remesh with care to
maintain bunched up nodes on the boundary.

Also fixed the mesh boundary shape, makes
life a lot easier when using frictional boundary
layers.


diff -r e6bfd8ab9c35 -r 70f99741dd90 Utils/src/MeshBoundaryShape.c
--- a/Utils/src/MeshBoundaryShape.c	Tue Aug 26 17:11:50 2008 +0000
+++ b/Utils/src/MeshBoundaryShape.c	Tue Aug 26 17:12:55 2008 +0000
@@ -60,8 +60,8 @@ MeshBoundaryShape* MeshBoundaryShape_New
       _Stg_Shape_Copy,
       (void*(*)(Name))MeshBoundaryShape_New,
       _MeshBoundaryShape_Construct,
-      _Stg_Shape_Build,
-      _Stg_Shape_Initialise,
+      _MeshBoundaryShape_Build,
+      _MeshBoundaryShape_Initialise,
       _Stg_Shape_Execute,
       _Stg_Shape_Destroy,
       _MeshBoundaryShape_IsCoordInside,
@@ -105,9 +105,10 @@ void _MeshBoundaryShape_Construct( void*
    int ii;
 
    _Stg_Shape_Construct( self, cf, data );
-
+   _MeshBoundaryShape_Init( self );
+
+   /* Need a mesh with a cartesian generator. */
    self->mesh = Stg_ComponentFactory_ConstructByKey( cf, self->name, "mesh", Mesh, True, data );
-   self->depth = Stg_ComponentFactory_GetInt( cf, self->name, "depth", 1 );
 
    /* Read in the walls to have friction applied. */
    wallList = _Stg_ComponentFactory_GetDictionaryValue( cf, self->name, "walls", NULL );
@@ -161,6 +162,9 @@ void _MeshBoundaryShape_Build( void* _se
 
    _Stg_Shape_Build( self, data );
    Stg_Component_Build( self->mesh, data, False );
+   if( !self->mesh->generator || strcmp( self->mesh->generator->type, CartesianGenerator_Type ) )
+      abort();
+   self->gen = (CartesianGenerator*)self->mesh->generator;
 }
 
 void _MeshBoundaryShape_Initialise( void* _self, void* data ) {
@@ -173,15 +177,26 @@ Bool _MeshBoundaryShape_IsCoordInside( v
 Bool _MeshBoundaryShape_IsCoordInside( void* _self, Coord coord ) {
    MeshBoundaryShape* self = (MeshBoundaryShape*)_self;
    Coord newCoord;
+#if 0
    Grid* grid;
    int inds[3], element, nDims, wallInd;
+#endif
    int ii;
-
-   assert( self->depth > 0 );
 
    /* Transform coordinate into canonical reference frame */
    Stg_Shape_TransformCoord( self, coord, newCoord );
 
+   /* Easy, just check if the coord is in the boundary region. */
+   for( ii = 0; ii < Mesh_GetDimSize( self->mesh ); ii++ ) {
+      if( (self->walls[2 * ii] && coord[ii] < self->gen->crdMin[ii] + self->gen->contactGeom[ii]) ||
+          (self->walls[2 * ii + 1] && coord[ii] > self->gen->crdMax[ii] - self->gen->contactGeom[ii]) )
+      {
+         return True;
+      }
+   }
+   return False;
+
+#if 0
    /* Get the element grid from the mesh. */
    grid = *(Grid**)Mesh_GetExtension( self->mesh, Grid**, "elementGrid" );
    assert( grid );
@@ -203,11 +218,13 @@ Bool _MeshBoundaryShape_IsCoordInside( v
       if( (self->walls[wallInd] && inds[ii] < self->depth) ||
           (self->walls[wallInd + 1] && inds[ii] > (grid->sizes[ii] - self->depth - 1)) )
       {
+         if( coords[
          return True;
       }
    }
 
    return False;
+#endif
 }
 
 double _MeshBoundaryShape_CalculateVolume( void* _self ) {
diff -r e6bfd8ab9c35 -r 70f99741dd90 Utils/src/MeshBoundaryShape.h
--- a/Utils/src/MeshBoundaryShape.h	Tue Aug 26 17:11:50 2008 +0000
+++ b/Utils/src/MeshBoundaryShape.h	Tue Aug 26 17:12:55 2008 +0000
@@ -47,6 +47,7 @@ extern const Type MeshBoundaryShape_Type
 #define __MeshBoundaryShape                     \
    __Stg_Shape                                  \
    Mesh* mesh;                                  \
+   CartesianGenerator* gen;                     \
    int depth;                                   \
    Bool walls[6];
 
diff -r e6bfd8ab9c35 -r 70f99741dd90 Utils/src/RegularRemesher.c
--- a/Utils/src/RegularRemesher.c	Tue Aug 26 17:11:50 2008 +0000
+++ b/Utils/src/RegularRemesher.c	Tue Aug 26 17:12:55 2008 +0000
@@ -58,8 +58,6 @@ void _RegularRemesher_Init( void* _self 
    self->nWallVerts = NULL;
    self->wallVerts = NULL;
    self->wallCrds = NULL;
-   self->contactDepth = 0;
-   self->contactSize = 0.0;
 }
 
 void _RegularRemesher_Copy( void* _self, const void* _op ) {
@@ -115,6 +113,7 @@ void _RegularRemesher_Remesh( void* _sel
    int nDims, nVerts;
    int center, ind, *inds;
    double leftCrd, rightCrd;
+   CartesianGenerator* gen;
    int d_i, v_i, w_i;
 
    assert( self->mesh );
@@ -139,10 +138,14 @@ void _RegularRemesher_Remesh( void* _sel
 
    /* If we have a contact depth set we'll need to manipulate the boundaries
       a little. */
-   if( self->contactDepth ) {
+   gen = self->mesh->generator;
+   if( strcmp( gen->type, CartesianGenerator_Type ) )
+      gen = NULL;
+   if( gen ) {
       int curInd;
       int ii, d_j;
 
+#if 0
       /* Reset static depths. */
       curInd = 0;
       for( ii = 0; ii < nVerts; ii++ ) {
@@ -150,6 +153,7 @@ void _RegularRemesher_Remesh( void* _sel
          if( inds[1] != self->contactDepth ) continue;
          Mesh_GetVertex( mesh, ii )[1] = self->contactVerts[curInd++];
       }
+#endif
 
       /* Also handle contact element boundaries. */
       for( d_i = 0; d_i < nDims; d_i++ ) {
@@ -164,24 +168,19 @@ void _RegularRemesher_Remesh( void* _sel
                   sure the side coordinates are aligned. */
 	       if( d_i == 0 ) {
 		  d_j = 1;
-		  depth = self->contactDepth;
 	       }
                else if( d_i == 1 ) {
 		  d_j = 0;
-		  depth = self->contactDepth;
 	       }
                else if( d_i == 2 ) {
 		  d_j = 1;
 		  // TODO
 		  abort();
 	       }
-               if( inds[d_j] < depth )
-                  inds[d_j] = depth;
-               else if( inds[d_j] > vGrid->sizes[d_j] - depth - 1 && 
-                        d_i == 1 )
-               {
-                  inds[d_j] = vGrid->sizes[d_j] - depth - 1;
-               }
+               if( inds[d_j] < gen->contactDepth[d_j][0] )
+                  inds[d_j] = gen->contactDepth[d_j][0];
+               else if( inds[d_j] > vGrid->sizes[d_j] - gen->contactDepth[d_j][1] - 1 )
+                  inds[d_j] = vGrid->sizes[d_j] - gen->contactDepth[d_j][1] - 1;
                Mesh_GetVertex( mesh, v_i )[d_i] =
                   Mesh_GetVertex( mesh, Grid_Project( vGrid, inds ) )[d_i];
             }
@@ -221,6 +220,42 @@ void _RegularRemesher_Remesh( void* _sel
 	 else
 	    rightCrd = Mesh_GetVertex( mesh, ind)[d_i];
 
+         /* Do interpolation. */
+         if( gen ) {
+            if( center <= gen->contactDepth[d_i][0] ) {
+               mesh->verts[v_i][d_i] = leftCrd;
+               if( gen->contactDepth[d_i][0] ) {
+                  mesh->verts[v_i][d_i] +=
+                     ((double)center / (double)gen->contactDepth[d_i][0]) *
+                     gen->contactGeom[d_i];
+               }
+            }
+            else if( center >= vGrid->sizes[d_i] - gen->contactDepth[d_i][1] - 1 ) {
+               mesh->verts[v_i][d_i] = rightCrd;
+               if( gen->contactDepth[d_i][1] ) {
+                  mesh->verts[v_i][d_i] -=
+                     ((double)(vGrid->sizes[d_i] - 1 - center) /
+                      (double)gen->contactDepth[d_i][1]) *
+                     gen->contactGeom[d_i];
+               }
+            }
+            else {
+               mesh->verts[v_i][d_i] = leftCrd + gen->contactGeom[d_i] +
+                  ((double)(center - gen->contactDepth[d_i][0]) / 
+                   (double)(vGrid->sizes[d_i] - (gen->contactDepth[d_i][0] + gen->contactDepth[d_i][1]) - 1)) *
+                  ((rightCrd - leftCrd) - 2.0 * gen->contactGeom[d_i]);
+            }
+         }
+         else {
+
+               /* Blend coordinate. */
+               mesh->verts[v_i][d_i] = leftCrd + 
+                  (double)center * (rightCrd - leftCrd) / 
+                  (double)(vGrid->sizes[d_i] - 1);
+
+         }
+
+#if 0
          /* Account for contact depth. */
          if( d_i == 1 ) {
             if( center > self->contactDepth ) {
@@ -257,6 +292,7 @@ void _RegularRemesher_Remesh( void* _sel
                   (double)(vGrid->sizes[d_i] - 1);
 
          }
+#endif
       }
    }
 
@@ -379,7 +415,8 @@ void RegularRemesher_Build( void* _self 
 
    NewClass_Delete( wallSet );
 
-   /* If we have some contact depth, copy the relevant vertices. */
+#if 0
+   /* If we have some contact depth, copy the relevant vertex offsets. */
    if( self->contactDepth > 0 ) {
       int curInd;
       Grid* grid;
@@ -409,6 +446,7 @@ void RegularRemesher_Build( void* _self 
       }
 
    }
+#endif
 
    Class_Free( self, inds );
 }
diff -r e6bfd8ab9c35 -r 70f99741dd90 Utils/src/RegularRemesher.def
--- a/Utils/src/RegularRemesher.def	Tue Aug 26 17:11:50 2008 +0000
+++ b/Utils/src/RegularRemesher.def	Tue Aug 26 17:12:55 2008 +0000
@@ -38,9 +38,7 @@ MEMBER( int**, nWallVerts )
 MEMBER( int**, nWallVerts )
 MEMBER( int***, wallVerts )
 MEMBER( double***, wallCrds )
-MEMBER( int, contactDepth )
 MEMBER( double*, contactVerts )
-MEMBER( double, contactSize )
 
 
 /*



More information about the CIG-COMMITS mailing list