Exemplo n.º 1
0
void IGraph_SetRemoteElements( void* _self, int dim, int nEls, const int* globals ) {
    IGraph* self = (IGraph*)_self;
    int nDoms;
    int d_i, e_i;

    assert( self );
    assert( dim < self->nTDims );
    assert( !nEls || globals );
    for( d_i = 0; d_i < self->nTDims; d_i++ ) {
        if( self->nIncEls[dim][d_i] ) {
            for( e_i = Decomp_GetNumLocals( self->locals[dim] ); e_i < Sync_GetNumDomains( self->remotes[dim] ); e_i++ ) {
                FreeArray( self->incEls[dim][d_i][e_i] );
            }
        }
    }

    Sync_SetRemotes( self->remotes[dim], nEls, globals );

    for( d_i = 0; d_i < self->nTDims; d_i++ ) {
        if( self->nIncEls[dim][d_i] ) {
            nDoms = Sync_GetNumDomains( self->remotes[dim] );
            self->nIncEls[dim][d_i] = ReallocArray( self->incEls[dim][d_i], int, nDoms );
            self->incEls[dim][d_i] = ReallocArray( self->incEls[dim][d_i], int*, nDoms );

            for( e_i = Decomp_GetNumLocals( self->locals[dim] ); e_i < nDoms; e_i++ ) {
                self->nIncEls[dim][d_i][e_i] = 0;
                self->incEls[dim][d_i][e_i] = NULL;
            }
        }
    }
Exemplo n.º 2
0
unsigned Mesh_GetDomainSize( void* mesh, MeshTopology_Dim topodim ) {
	Mesh*	self = (Mesh*)mesh;

	assert( self );
	assert( self->topo );

        return Sync_GetNumDomains( IGraph_GetDomain( self->topo, topodim ) );
}
void RSGenerator_CalcCurvilinearGeom( void* _self, Mesh* mesh, Sync* sync, Grid* grid, unsigned* inds, double* steps )
{
   /* function for creating a curvilinear mesh */
   RSGenerator* self = (RSGenerator*)_self;

   unsigned		n_i, d_i;
   double*         	vert;
   unsigned        	gNode;

   double dimRes[3];
   double theta;

   /*
    * grid->sizes[] ... an array containing the number of nodes in a direction
    * gNode         ... global node id
    * inds          ... an ijk index to the node
    * steps         ... an array containing the physics length in each dim
    */
   for( d_i = 0 ; d_i < mesh->topo->nDims ; d_i++ )
   {
      dimRes[d_i] = steps[d_i]/(double)(grid->sizes[d_i]-1);
   }
   memcpy( self->sph_res, dimRes, 3*sizeof(double) );

   double phi;
   double X,Y,r,d;

   /* Loop over domain nodes. */
   for( n_i = 0; n_i < Sync_GetNumDomains( sync ); n_i++ )
   {
      vert = Mesh_GetVertex( mesh, n_i );

      gNode = Sync_DomainToGlobal( sync, n_i );
      Grid_Lift( grid, gNode, inds );

      r = self->crdMin[0] + dimRes[0]*(double)inds[0];
      theta = (M_PI/180.0) * (self->crdMin[1]+dimRes[1]*(double)inds[1]); // longitude position discretization
      phi =   (M_PI/180.0) * (self->crdMin[2]+dimRes[2]*(double)inds[2]); // latitude position discretization

      X = tan(theta);
      Y = tan(phi);
      d = sqrt(1 + X*X + Y*Y);

      vert[0] = r/d * X;
      vert[1] = r/d * Y;
      vert[2] = r/d * 1;
   }
}
Exemplo n.º 4
0
void IGraph_SetLocalElements( void* _self, int dim, int nEls, const int* globals ) {
    IGraph* self = (IGraph*)_self;
    int d_i, e_i;

    assert( self );
    assert( dim < self->nTDims );
    assert( !nEls || globals );
    for( d_i = 0; d_i < self->nTDims; d_i++ ) {
        for( e_i = 0; e_i < Sync_GetNumDomains( self->remotes[dim] ); d_i++ )
            FreeArray( self->incEls[dim][d_i][e_i] );
        FreeArray( self->incEls[dim][d_i] );
        FreeArray( self->nIncEls[dim][d_i] );
        self->incEls[dim][d_i] = NULL;
        self->nIncEls[dim][d_i] = NULL;
    }
    Decomp_SetLocals( self->locals[dim], nEls, globals );
    Sync_SetDecomp( self->remotes[dim], self->locals[dim] );
}
/*--------------------------------------------------------------------------------------------
** Public Functions
*/
void LinearSpaceAdaptor_Generate( void* _self, void* _mesh, void* data ) {
  LinearSpaceAdaptor* self = (LinearSpaceAdaptor*)_self;
  Mesh* mesh = (Mesh*)_mesh;
  const Sync* sync;
  double	x;
  Index  n_i;

  /* Build base mesh (assumed to be cartesian) */
  MeshGenerator_Generate( self->generator, mesh, data );

  if( self->loadFromCheckPoint )
    return;

  /* Loop over domain nodes. */
  sync = IGraph_GetDomain( mesh->topo, MT_VERTEX );
  
  if( self->nSegmentsx > 0 ) {
    for( n_i = 0; n_i < Sync_GetNumDomains( sync ); n_i++ ) {
      /* get the x coord */
      x = Mesh_GetVertex( mesh, n_i )[I_AXIS];

      if( x != self->minX && x != self->maxX ) {	      
		  /* normalize the x coord*/
		  x = (x - self->minX) / (self->maxX - self->minX);
		  /* map the normalized point */
		  x = LinearSpaceAdaptor_MapPoint( self->tablex, self->nSegmentsx, x  );
		  /* denormalize mapped point */
		  x = (self->maxX - self->minX)*x + self->minX;
		  /* move the node */
		  Mesh_GetVertex( mesh, n_i )[I_AXIS] = x;
      }
    }
  }

  if( self->nSegmentsy > 0 ) {
    for( n_i = 0; n_i < Sync_GetNumDomains( sync ); n_i++ ) {
      /* get the y coord */
      x = Mesh_GetVertex( mesh, n_i )[J_AXIS];

      if( x != self->minY && x != self->maxY ) {
		  /* normalize the y coord*/
		  x = (x - self->minY) / (self->maxY - self->minY);
		  /* map the normalized point */
		  x = LinearSpaceAdaptor_MapPoint( self->tabley, self->nSegmentsy, x  );
		  /* denormalize mapped point */
		  x = (self->maxY - self->minY)*x + self->minY;
		  /* move the node */
		  Mesh_GetVertex( mesh, n_i )[J_AXIS] = x;
      }
    }
  }  

  if( self->nSegmentsz > 0 ) {
    for( n_i = 0; n_i < Sync_GetNumDomains( sync ); n_i++ ) {
      /* get the x coord */
      x = Mesh_GetVertex( mesh, n_i )[K_AXIS];

      if( x != self->minZ && x != self->maxZ ) {	      
		  /* normalize the z coord*/
		  x = (x - self->minZ) / (self->maxZ - self->minZ);
		  /* map the normalized point */
		  x = LinearSpaceAdaptor_MapPoint( self->tablez, self->nSegmentsz, x  );
		  /* denormalize mapped point */
		  x = (self->maxZ - self->minZ)*x + self->minZ;
		  /* move the node */
		  Mesh_GetVertex( mesh, n_i )[K_AXIS] = x;
      }
    }
  }
}