Ejemplo n.º 1
0
void _Mesh_Build( void* mesh, void* data ) {
	Mesh*			self = (Mesh*)mesh;
	unsigned		nDims;
	unsigned		d_i;

	assert( self );

    if( self->generator ) {
        Stg_Component_Build( self->generator, data, False );
        MeshGenerator_Generate( self->generator, self, data );
    }

	if( self->algorithms ) Stg_Component_Build( self->algorithms, data, False );

	nDims = Mesh_GetDimSize( self );
	if( !nDims ){
        self->isBuilt = False;
        return;
    }

	self->topoDataInfos = Memory_Alloc_Array( ExtensionManager*, nDims, "mesh::topoDataInfos" );
	self->topoDatas = Memory_Alloc_Array( void*, nDims, "mesh::topoDatas" );

	for( d_i = 0; d_i < nDims; d_i++ ) {
		char		name[20];
		unsigned	size;

		if( !UIntMap_Map( self->topoDataSizes, d_i, &size ) || !size ||
		    !Mesh_GetDomainSize( self, d_i ) )
		{
			self->topoDataInfos[d_i] = NULL;
			self->topoDatas[d_i] = NULL;
			continue;
		}

		sprintf( name, "topoData(%d)", d_i );
		self->topoDataInfos[d_i] = ExtensionManager_New_OfStruct( name, size );
		self->topoDatas[d_i] = (void*)ExtensionManager_Malloc( self->topoDataInfos[d_i], Mesh_GetDomainSize( self, d_i ) );
	}

	/*
	** Set up the geometric information.
	*/

	self->minAxialSep = Memory_Alloc_Array( double, nDims, "Mesh::minAxialSep" );
	self->minLocalCrd = Memory_Alloc_Array( double, nDims, "Mesh::minLocalCrd" );
	self->maxLocalCrd = Memory_Alloc_Array( double, nDims, "Mesh::maxLocalCrd" );
	self->minDomainCrd = Memory_Alloc_Array( double, nDims, "Mesh::minLocalCrd" );
	self->maxDomainCrd = Memory_Alloc_Array( double, nDims, "Mesh::maxLocalCrd" );
	self->minGlobalCrd = Memory_Alloc_Array( double, nDims, "Mesh::minGlobalCrd" );
	self->maxGlobalCrd = Memory_Alloc_Array( double, nDims, "Mesh::maxGlobalCrd" );

	Mesh_DeformationUpdate( self );

}
Ejemplo n.º 2
0
void _MeshGenerator_Build( void* meshGenerator, void* data ) {
	MeshGenerator*	self = (MeshGenerator*)meshGenerator;
	unsigned	m_i;

	/* Sanity check. */
	assert( self );
	assert( !self->nMeshes || self->meshes );

	/* Generate each mesh in our list. */
	for( m_i = 0; m_i < self->nMeshes; m_i++ )
		MeshGenerator_Generate( self, self->meshes[m_i] );
}
/*--------------------------------------------------------------------------------------------
** 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;
      }
    }
  }
}
Ejemplo n.º 4
0
void SurfaceAdaptor_Generate( void* adaptor, void* _mesh ) {
	SurfaceAdaptor*			self = (SurfaceAdaptor*)adaptor;
	Mesh*				mesh = (Mesh*)_mesh;
	SurfaceAdaptor_DeformFunc*	deformFunc;
	unsigned*			gSize;
	Grid*				grid;
	unsigned*			inds;
	unsigned			d_i, n_i;

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

	/* If we're not 2D or 3D, forget about it. */
	if( mesh->topo->nDims != 2 && mesh->topo->nDims != 3 )
		return;

	/* What kind of surface do we want? */
	switch( self->surfaceType ) {
	case SurfaceAdaptor_SurfaceType_Wedge:
		deformFunc = SurfaceAdaptor_Wedge;
		break;
	case SurfaceAdaptor_SurfaceType_Sine:
		deformFunc = SurfaceAdaptor_Sine;
		break;
	case SurfaceAdaptor_SurfaceType_Cosine:
		deformFunc = SurfaceAdaptor_Cosine;
		break;
	default:
		break;
	};

	/* Extract the cartesian information. */
	gSize = (unsigned*)ExtensionManager_Get( mesh->info, mesh, 
						 ExtensionManager_GetHandle( mesh->info, "cartesianGlobalSize" ) );

	/* Build grid and space for indices. */
	grid = Grid_New();
	Grid_SetNDims( grid, mesh->topo->nDims );
	for( d_i = 0; d_i < mesh->topo->nDims; d_i++ )
		gSize[d_i]++;
	Grid_SetSizes( grid, gSize );
	for( d_i = 0; d_i < mesh->topo->nDims; d_i++ )
		gSize[d_i]--;
	inds = Memory_Alloc_Array_Unnamed( unsigned, mesh->topo->nDims );

	/* Loop over domain nodes. */
	for( n_i = 0; n_i < MeshTopology_GetDomainSize( mesh->topo, MT_VERTEX ); n_i++ ) {
		unsigned	gNode;
		double		height;

		gNode = MeshTopology_DomainToGlobal( mesh->topo, MT_VERTEX, n_i );
		Grid_Lift( grid, gNode, inds );

		/* Calculate a height percentage. */
		height = (double)inds[1] / (double)(gSize[1] - 1);

		/* Deform this node. */
		mesh->nodeCoord[n_i][1] += height * deformFunc( self, mesh, gSize, n_i, inds );
	}

	/* Free resources. */
	FreeArray( inds );
	FreeObject( grid );
}