void DictionarySuite_TestCreateValues( DictionarySuiteData* data ) {
   Dictionary_Entry_Value*   dev;

   /* Don't use the pre-created test values. Want to do a very fundamental test here */
   dev = Dictionary_Entry_Value_FromString( "hello" );
   pcu_check_true( Dictionary_Entry_Value_Type_String == dev->type );
   pcu_check_streq( "hello", dev->as.typeString );
   Dictionary_Entry_Value_Delete( dev );
   dev = Dictionary_Entry_Value_FromDouble( 45.567 );
   pcu_check_true( Dictionary_Entry_Value_Type_Double == dev->type );
   pcu_check_true( 45.567 == dev->as.typeDouble );
   Dictionary_Entry_Value_Delete( dev );
   dev = Dictionary_Entry_Value_FromUnsignedInt( 5 );
   pcu_check_true( Dictionary_Entry_Value_Type_UnsignedInt == dev->type );
   pcu_check_true( 5 == dev->as.typeUnsignedInt );
   Dictionary_Entry_Value_Delete( dev );
   dev = Dictionary_Entry_Value_FromInt( -5 );
   pcu_check_true( Dictionary_Entry_Value_Type_Int == dev->type );
   pcu_check_true( -5 == dev->as.typeInt );
   Dictionary_Entry_Value_Delete( dev );
   dev = Dictionary_Entry_Value_FromUnsignedLong( 52342423 );
   pcu_check_true( Dictionary_Entry_Value_Type_UnsignedLong == dev->type );
   pcu_check_true( 52342423 == dev->as.typeUnsignedLong );
   Dictionary_Entry_Value_Delete( dev );
   dev = Dictionary_Entry_Value_FromBool( True );
   pcu_check_true( Dictionary_Entry_Value_Type_Bool == dev->type );
   pcu_check_true( True == dev->as.typeBool );
   Dictionary_Entry_Value_Delete( dev );

   /* Since we know the DEV Struct is basically a Dictionary, won't test that one
    *  until after we've tested Dictionary_Add works */   
}
Пример #2
0
Bool Dictionary_GetBool_WithDefault(
   Dictionary*          dictionary,
   Dictionary_Entry_Key key,
   const Bool           defaultVal )
{
   return Dictionary_Entry_Value_AsBool( 
      Dictionary_GetDefault(
         dictionary, key, Dictionary_Entry_Value_FromBool( defaultVal ) ) );
}
Пример #3
0
void Dictionary_Entry_Value_AddElementWithSource( Dictionary_Entry_Value* self, Dictionary_Entry_Value* element,
							Dictionary_Entry_Source source )
{
	/* check type - convert to a list if not so... */
	if (Dictionary_Entry_Value_Type_List != self->type) {
		Dictionary_Entry_Value* copy;
		
		switch (self->type) {
			case Dictionary_Entry_Value_Type_String:
				copy = Dictionary_Entry_Value_FromString( self->as.typeString );
				break;
			case Dictionary_Entry_Value_Type_Double:
				copy = Dictionary_Entry_Value_FromDouble( self->as.typeDouble );
				break;
			case Dictionary_Entry_Value_Type_UnsignedInt:
				copy = Dictionary_Entry_Value_FromUnsignedInt( self->as.typeUnsignedInt );
				break;
			case Dictionary_Entry_Value_Type_Int:
				copy = Dictionary_Entry_Value_FromInt( self->as.typeInt );
				break;
			case Dictionary_Entry_Value_Type_UnsignedLong:
				copy = Dictionary_Entry_Value_FromUnsignedLong( self->as.typeUnsignedLong );
				break;
			case Dictionary_Entry_Value_Type_Bool:
				copy = Dictionary_Entry_Value_FromBool( self->as.typeBool );
				break;
			case Dictionary_Entry_Value_Type_Struct:
				copy = Dictionary_Entry_Value_NewStruct();
				copy->as.typeStruct = self->as.typeStruct;
				break;
			default: {
				Stream* errorStream = Journal_Register( Error_Type, "Dictionary_Entry_Value" );
				Journal_Firewall( False, errorStream, "In func %s: self->type '%d' is invalid.\n", __func__, self->type );
			}
		}
		
		Dictionary_Entry_Value_SetNewList( self );	
		Dictionary_Entry_Value_AddElementWithSource( self, copy, source );
	}
	
	if (!self->as.typeList->first) {
		self->as.typeList->first = element;
	} else {
		self->as.typeList->last->next = element;
	}
	self->as.typeList->last = element;
	self->as.typeList->count++;
}
Пример #4
0
int main(int argc, char *argv[])
{
	MPI_Comm		CommWorld;
	int			rank;
	int			procCount;
	int			procToWatch;
	Dictionary*		dictionary;
	Topology*		nTopology;
	ElementLayout*		eLayout;
	NodeLayout*		nLayout;
	HexaMD*			decompCorner;
	HexaMD*			decompBody;
	Stream*                 stream;
	Index			decompDims;
	XML_IO_Handler*         ioHandler;
	Dimension_Index         dim_I;
	
	/* Initialise MPI, get world info */
	MPI_Init(&argc, &argv);
	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
	MPI_Comm_size(CommWorld, &procCount);
	MPI_Comm_rank(CommWorld, &rank);

	Base_Init( &argc, &argv );
	
	DiscretisationGeometry_Init( &argc, &argv );
	DiscretisationShape_Init( &argc, &argv );
	DiscretisationMesh_Init( &argc, &argv );
	MPI_Barrier( CommWorld ); /* Ensures copyright info always come first in output */
	
	procToWatch = argc >= 2 ? atoi(argv[1]) : 0;

	Journal_Enable_TypedStream( DebugStream_Type, False );
	stream = Journal_Register( DebugStream_Type, HexaMD_Type );
	Stream_EnableBranch( stream, True );
	Stream_SetLevelBranch( stream, 3 );
	
	dictionary = Dictionary_New();

	Dictionary_Add( dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( rank ) );
	Dictionary_Add( dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( procCount ) );
	Dictionary_Add( dictionary, "meshSizeI", Dictionary_Entry_Value_FromUnsignedInt( 5 ) );
	Dictionary_Add( dictionary, "meshSizeJ", Dictionary_Entry_Value_FromUnsignedInt( 5 ) );
	Dictionary_Add( dictionary, "meshSizeK", Dictionary_Entry_Value_FromUnsignedInt( 5 ) );
	Dictionary_Add( dictionary, "allowUnusedCPUs", Dictionary_Entry_Value_FromBool( True ) );
	Dictionary_Add( dictionary, "allowPartitionOnElement", Dictionary_Entry_Value_FromBool( False ) );
	Dictionary_Add( dictionary, "allowPartitionOnNode", Dictionary_Entry_Value_FromBool( True ) );
	Dictionary_Add( dictionary, "allowUnbalancing", Dictionary_Entry_Value_FromBool( False ) );
	Dictionary_Add( dictionary, "shadowDepth", Dictionary_Entry_Value_FromUnsignedInt( 1 ) );

	/* Moved afterwards to allow command line to over-ride */
	ioHandler = XML_IO_Handler_New();
	IO_Handler_ReadAllFromCommandLine( ioHandler, argc, argv, dictionary );

	decompDims = Dictionary_GetUnsignedInt_WithDefault( dictionary, "decompDims", 1 );
	
	nTopology = (Topology*)IJK6Topology_New( "IJK6Topology", dictionary );
	eLayout = (ElementLayout*)ParallelPipedHexaEL_New( "PPHexaEL", 3, dictionary );
	nLayout = (NodeLayout*)CornerNL_New( "CornerNL", dictionary, eLayout, nTopology );
	decompCorner = HexaMD_New_All( "HexaMD", dictionary, MPI_COMM_WORLD, eLayout, nLayout, decompDims );

	if( rank == procToWatch ) {
		printf( "Corner Node Layout\n" );
		PrintDecompInfoOfHexaMD( decompCorner, rank );
		printf( "\n" );
	}

	/* Do a run with body nodes */
	Stg_Class_Delete( nLayout );
	/* TODO: the following is a bit of a hack because of the weird way mesh size is defined by default in
	the dictionary (assumes a corner mesh ) */
	for ( dim_I = 0; dim_I < 3; dim_I++ ) {
		if ( ((IJKTopology*)nTopology)->size[dim_I] > 1 ) {
			((IJKTopology*)nTopology)->size[dim_I]--;
		}
	}	
	nLayout = (NodeLayout*)BodyNL_New( "BodyNL", dictionary, eLayout, nTopology );
	decompBody = HexaMD_New_All( "HexaMD", dictionary, MPI_COMM_WORLD, eLayout, nLayout, decompDims );
	if( rank == procToWatch ) {
		Bool    result;

		printf( "Body Node Layout\n" );
		//PrintDecompInfoOfHexaMD( decompBody, rank );
		printf( "Checking body node decomp has same element decomp as corner node decomp:\n" );
		result = CheckDecompItemsAreDecomposedIdentically( decompCorner, ELEMENT_ITEM_TYPE, 
			decompBody, ELEMENT_ITEM_TYPE, rank );
		if ( result == True ) printf( "\tPassed.\n" );
		else printf( "\tFailed.\n" );

		printf( "Checking body node decomp has same node decomp as it's element decomp:\n" );
		result = CheckDecompItemsAreDecomposedIdentically( decompBody, ELEMENT_ITEM_TYPE, 
			decompBody, NODE_ITEM_TYPE, rank );
		if ( result == True ) printf( "\tPassed.\n" );
		else printf( "\tFailed.\n" );
	}

	Stg_Class_Delete( decompBody );
	Stg_Class_Delete( decompCorner );
	Stg_Class_Delete( nLayout );
	Stg_Class_Delete( eLayout );
	Stg_Class_Delete( nTopology );
	Stg_Class_Delete( dictionary );
	
	DiscretisationMesh_Finalise();
	DiscretisationShape_Finalise();
	DiscretisationGeometry_Finalise();
	
	Base_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();
	
	return EXIT_SUCCESS;
}
Пример #5
0
int main(int argc, char **argv)
{
	MPI_Comm		CommWorld;
	XML_IO_Handler 		*io_handler = XML_IO_Handler_New();
	int			rank, procCount, procToWatch;
	Dictionary		*dictionary;
	EmbeddedSurface		*surface;
	MeshTopology		*rmt, *imt;
	MeshGeometry		*rmg, *img;
	MeshDecomp		*rmd, *imd;
	MeshLayout		*rml, *isl;
	ExtensionManager_Register	*extensionMgr_Register;
	Mesh			*mesh;
	Element_GlobalIndex	intersectCnt, *intersect;
	Index			i;
	
	/* Initialise MPI, get world info */
	MPI_Init( &argc, &argv );
	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
	MPI_Comm_size( CommWorld, &procCount );
	MPI_Comm_rank( CommWorld, &rank );
	
	Base_Init( &argc, &argv );
	
	DiscretisationGeometry_Init( &argc, &argv );
	DiscretisationShape_Init( &argc, &argv );
	DiscretisationMesh_Init( &argc, &argv );
	DiscretisationUtils_Init( &argc, &argv );
	MPI_Barrier( CommWorld ); /* Ensures copyright info always come first in output */
	
	if( argc >= 2 )
		procToWatch = atoi( argv[1] );
	else
		procToWatch = 0;
	if( rank == procToWatch ) printf( "Watching rank: %i\n", rank );
	
	dictionary = Dictionary_New();
	Dictionary_Add( dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( rank ) );
	Dictionary_Add( dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( procCount ) );
	Dictionary_Add( dictionary, "meshSizeI", Dictionary_Entry_Value_FromUnsignedInt( 2 ) );
	Dictionary_Add( dictionary, "meshSizeJ", Dictionary_Entry_Value_FromUnsignedInt( 2 ) );
	Dictionary_Add( dictionary, "meshSizeK", Dictionary_Entry_Value_FromUnsignedInt( 4 ) );
	Dictionary_Add( dictionary, "allowUnusedCPUs", Dictionary_Entry_Value_FromBool( True ) );
	Dictionary_Add( dictionary, "allowPartitionOnElement", Dictionary_Entry_Value_FromBool( True ) );
	Dictionary_Add( dictionary, "allowPartitionOnNode", Dictionary_Entry_Value_FromBool( True ) );
	Dictionary_Add( dictionary, "shadowDepth", Dictionary_Entry_Value_FromUnsignedInt( 0 ) );
	IO_Handler_ReadAllFromFile(io_handler, "data/surface.xml", dictionary);
	
	rmt = (MeshTopology *)HexaMeshTopology_New(dictionary);
	rmg = (MeshGeometry *)HexaMeshGeometry_New(dictionary);
	rmd = (MeshDecomp *)HexaMeshDecomp_New(dictionary, MPI_COMM_WORLD, (HexaMeshTopology *)rmt);
	rml = MeshLayout_New(dictionary, rmt, rmg, rmd);
	
	imt = (MeshTopology *)TriSurfTopology_New(dictionary, "imElements");
	img = (MeshGeometry *)TriSurfGeometry_New(dictionary, "imNodes");
	imd = (MeshDecomp *)IrregularMeshDecomp_New1(dictionary, MPI_COMM_WORLD, imt, img, rml);
	isl = MeshLayout_New(dictionary, imt, img, imd);
	
	extensionMgr_Register = ExtensionManager_Register_New( );
	mesh = Mesh_New( isl, sizeof(Node), sizeof(Element), extensionMgr_Register, dictionary );
	Mesh_Build( mesh );
	Mesh_Initialise(mesh);
	
	surface = EmbeddedSurface_New(mesh);
	
	if (procToWatch == rank)
	{
		intersect = Memory_Alloc_Array( Element_GlobalIndex, isl->decomp->elementGlobalCount(isl->decomp), "intersect" );
		intersectCnt = EmbeddedSurface_BuildIntersection(surface, intersect);
	
		printf("Intersects: %u\n", intersectCnt);
		for (i = 0; i < intersectCnt; i++)
			printf("\tinstersect[%u]: %u\n", i, intersect[i]);
		printf("\n");
	
		if (intersect) Memory_Free(intersect);
	
		for (i = 0; i < isl->decomp->nodeGlobalCount(isl->decomp); i++)
		{
			Coord point;
		
			point[0] = ((TriSurfGeometry *)img)->node[i][0] + 1.0;
			point[1] = ((TriSurfGeometry *)img)->node[i][1];
			point[2] = ((TriSurfGeometry *)img)->node[i][2];

			printf("Distance to point {%.3f, %.3f, %.3f}: ", point[0], point[1], point[2]);
			printf("%.3f\n", EmbeddedSurface_DistanceToPoint(surface, point));
		}
	}
	
	Stg_Class_Delete(surface);
	Stg_Class_Delete(isl);
	Stg_Class_Delete(imd);
	Stg_Class_Delete(img);
	Stg_Class_Delete(imt);
	Stg_Class_Delete(rml);
	Stg_Class_Delete(rmd);
	Stg_Class_Delete(rmg);
	Stg_Class_Delete(rmt);
	
	DiscretisationUtils_Finalise();
	DiscretisationMesh_Finalise();
	DiscretisationShape_Finalise();
	DiscretisationGeometry_Finalise();
	
	Base_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();
	
	return 0;
}
Пример #6
0
int main(int argc, char *argv[])
{
	MPI_Comm		CommWorld;
	int			rank;
	int			procCount;
	int			procToWatch;
	Dictionary*		dictionary;
	ExtensionManager_Register*	extensionMgr_Register;
	Topology*		nTopology;
	ElementLayout*		eLayout;
	NodeLayout*		nLayout;
	MeshDecomp*		decomp;
	MeshLayout*		ml;
	Mesh*			mesh;
	Stream*			stream;

	
	/* Initialise MPI, get world info */
	MPI_Init(&argc, &argv);
	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
	MPI_Comm_size(CommWorld, &procCount);
	MPI_Comm_rank(CommWorld, &rank);

	Base_Init( &argc, &argv );
	
	DiscretisationGeometry_Init( &argc, &argv );
	DiscretisationShape_Init( &argc, &argv );
	DiscretisationMesh_Init( &argc, &argv );

	stream = Journal_Register (Info_Type, "myStream");
	procToWatch = argc >= 2 ? atoi(argv[1]) : 0;
	
	dictionary = Dictionary_New();
	Dictionary_Add( dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( rank ) );
	Dictionary_Add( dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( procCount ) );
	Dictionary_Add( dictionary, "meshSizeI", Dictionary_Entry_Value_FromUnsignedInt( 7 ) );
	Dictionary_Add( dictionary, "meshSizeJ", Dictionary_Entry_Value_FromUnsignedInt( 7 ) );
	Dictionary_Add( dictionary, "meshSizeK", Dictionary_Entry_Value_FromUnsignedInt( 7 ) );
	Dictionary_Add( dictionary, "allowUnusedCPUs", Dictionary_Entry_Value_FromBool( False ) );
	Dictionary_Add( dictionary, "allowPartitionOnNode", Dictionary_Entry_Value_FromBool( True ) );
	Dictionary_Add( dictionary, "allowUnbalancing", Dictionary_Entry_Value_FromBool( False ) );
	Dictionary_Add( dictionary, "shadowDepth", Dictionary_Entry_Value_FromUnsignedInt( 1 ) );
	
	nTopology = (Topology*)IJK6Topology_New( "IJK6Topology", dictionary );
	eLayout = (ElementLayout*)ParallelPipedHexaEL_New( "PPHexaEL", 3, dictionary );
	nLayout = (NodeLayout*)CornerNL_New( "CornerNL", dictionary, eLayout, nTopology );
	decomp = (MeshDecomp*)HexaMD_New( "HexaMD", dictionary, MPI_COMM_WORLD, eLayout, nLayout );
	ml = MeshLayout_New( "MeshLayout", eLayout, nLayout, decomp );
	
	extensionMgr_Register = ExtensionManager_Register_New();
	mesh = Mesh_New( "Mesh", ml, sizeof(Node), sizeof(Element), extensionMgr_Register, dictionary );
	
	mesh->buildNodeLocalToGlobalMap = True;
	mesh->buildNodeDomainToGlobalMap = True;
	mesh->buildNodeGlobalToLocalMap = True;
	mesh->buildNodeGlobalToDomainMap = True;
	mesh->buildNodeNeighbourTbl = True;
	mesh->buildNodeElementTbl = True;
	mesh->buildElementLocalToGlobalMap = True;
	mesh->buildElementDomainToGlobalMap = True;
	mesh->buildElementGlobalToDomainMap = True;
	mesh->buildElementGlobalToLocalMap = True;
	mesh->buildElementNeighbourTbl = True;
	mesh->buildElementNodeTbl = True;
	
	Build( mesh, 0, False );
	Initialise(mesh, 0, False );
	

	
	if (rank == procToWatch)
	{
		Node_Index				currElementNodesCount=0;	
		Node_Index*         	currElementNodes = NULL;
		Element_Index          	element_dI = 0;
		Node_Index             	refNode_eI = 0;
		Node_Index				node_Diagonal = 0;
		Node_Index				node_Diagonal_gI = 0;
		
		// only use this while setting up the test
		//Print(mesh, stream);
				
		// Some tests involving RegularMeshUtils_GetDiagOppositeAcrossElementNodeIndex()
		
		
		for (element_dI=0; element_dI < mesh->elementDomainCount; element_dI++) {
			
			currElementNodes = mesh->elementNodeTbl[element_dI];
			currElementNodesCount = mesh->elementNodeCountTbl[element_dI];
			
			for (refNode_eI = 0; refNode_eI < currElementNodesCount; refNode_eI++ ) {
				
				node_Diagonal = RegularMeshUtils_GetDiagOppositeAcrossElementNodeIndex(mesh, element_dI, 
					currElementNodes[refNode_eI]) ;
				node_Diagonal_gI = Mesh_NodeMapDomainToGlobal( mesh, node_Diagonal );
				//print message stating: Element #, curr node #, diag opp node #
				printf("Element #: %d, Current Node #: %d, Diagonal Node #: %d, (%d) \n",
					element_dI, currElementNodes[refNode_eI], node_Diagonal, node_Diagonal_gI);
				
			}
		}	
	}
	
	Stg_Class_Delete(mesh);
	Stg_Class_Delete(ml);
	Stg_Class_Delete(decomp);
	Stg_Class_Delete(nLayout);
	Stg_Class_Delete(eLayout);
	Stg_Class_Delete( nTopology );
	Stg_Class_Delete(dictionary);
	
	DiscretisationMesh_Finalise();
	DiscretisationShape_Finalise();
	DiscretisationGeometry_Finalise();
	
	Base_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();
	
	return 0; /* success */
}
Пример #7
0
int main(int argc, char *argv[])
{
	int		rank;
	int		procCount;
	int		procToWatch;
	Dictionary*	dictionary;
	MeshTopology*	mt;
	MeshGeometry*	mg;
	MeshDecomp*	md;
	MeshLayout*	ml;
	Coord		point[8] = {{0.25, 0.25, 0.25}, {0.75, 0.25, 0.25}, {0.25, 0.75, 0.25}, {0.75, 0.75, 0.25}, 
				{0.25, 0.25, 0.75}, {0.75, 0.25, 0.75}, {0.25, 0.75, 0.75}, {0.75, 0.75, 0.75}};
	
	/* Initialise MPI, get world info */
	MPI_Init(&argc, &argv);
	MPI_Comm_size(MPI_COMM_WORLD, &procCount);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);

	Base_Init( &argc, &argv );
	
	DiscretisationGeometry_Init( &argc, &argv );
	DiscretisationShape_Init( &argc, &argv );
	DiscretisationMesh_Init( &argc, &argv );
	MPI_Barrier( CommWorld ); /* Ensures copyright info always come first in output */
	
	procToWatch = argc >= 2 ? atoi(argv[1]) : 0;
	
	dictionary = Dictionary_New();
	Dictionary_Add( dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( rank ) );
	Dictionary_Add( dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( procCount ) );
	Dictionary_Add( dictionary, "meshSizeI", Dictionary_Entry_Value_FromUnsignedInt( 3 ) );
	Dictionary_Add( dictionary, "meshSizeJ", Dictionary_Entry_Value_FromUnsignedInt( 3 ) );
	Dictionary_Add( dictionary, "meshSizeK", Dictionary_Entry_Value_FromUnsignedInt( 3 ) );
	Dictionary_Add( dictionary, "allowUnusedCPUs", Dictionary_Entry_Value_FromBool( True ) );
	Dictionary_Add( dictionary, "allowPartitionOnElement", Dictionary_Entry_Value_FromBool( True ) );
	Dictionary_Add( dictionary, "allowPartitionOnNode", Dictionary_Entry_Value_FromBool( True ) );
	Dictionary_Add( dictionary, "allowUnbalancing", Dictionary_Entry_Value_FromBool( False ) );
	Dictionary_Add( dictionary, "shadowDepth", Dictionary_Entry_Value_FromUnsignedInt( 0 ) );
	
	mt = (MeshTopology*)HexaMeshTopology_New(dictionary);
	mg = (MeshGeometry*)HexaMeshGeometry_New(dictionary);
	md = (MeshDecomp*)RegularMeshDecomp_New(dictionary, MPI_COMM_WORLD, mt);
	ml = MeshLayout_New(mt, mg, md);
	
	if (rank == procToWatch)
	{
		Element_GlobalIndex	elt;
		Index			i;
		
		Print(ml);
		
		for (i = 0; i < 8; i++)
		{
			elt = MeshLayout_ElementWithPoint(ml, point[i]);
			printf("Point: {%g, %g, %g} - element: ", point[i][0], point[i][1], point[i][2]);
			if (elt < ml->decomp->nodeGlobalCount)
				printf("%u\n", elt);
			else
				printf("X\n");
		}
	}
	
	Stg_Class_Delete(ml);
	Stg_Class_Delete(md);
	Stg_Class_Delete(mg);
	Stg_Class_Delete(mt);
	Stg_Class_Delete(dictionary);
	
	DiscretisationMesh_Finalise();
	DiscretisationShape_Finalise();
	DiscretisationGeometry_Finalise();
	
	Base_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();
	
	return 0; /* success */
}
void DictionarySuite_TestMerge( DictionarySuiteData* data ) {
   Dictionary_Entry_Value*    testStruct2=NULL;
   Dictionary_Entry_Value*    testGeomStruct2=NULL;
   Dictionary_Entry_Value*    mergedStruct=NULL;
   Dictionary_Entry_Value*    expectedMergedStruct=NULL;

   testStruct2 = Dictionary_Entry_Value_NewStruct( );
   Dictionary_Entry_Value_AddMember( testStruct2, (Dictionary_Entry_Key)"height", Dictionary_Entry_Value_FromDouble( data->testDD->testStruct->height )  );
   Dictionary_Entry_Value_AddMember( testStruct2, (Dictionary_Entry_Key)"anisotropic", Dictionary_Entry_Value_FromBool( False )  );
   Dictionary_Entry_Value_AddMember( testStruct2, (Dictionary_Entry_Key)"new_person", Dictionary_Entry_Value_FromString( "Luke" ) );
   testGeomStruct2 = Dictionary_Entry_Value_NewStruct( );
   Dictionary_Entry_Value_AddMember( testStruct2, (Dictionary_Entry_Key)"geom", testGeomStruct2  );
   Dictionary_Entry_Value_AddMember( testGeomStruct2, (Dictionary_Entry_Key)"startx", Dictionary_Entry_Value_FromUnsignedInt( data->testDD->testStruct->geom.startx )  );
   Dictionary_Entry_Value_AddMember( testGeomStruct2, (Dictionary_Entry_Key)"startz", Dictionary_Entry_Value_FromUnsignedInt( 222 )  );

   /* Testing Merge_Append */
   DictionarySuite_PopulateDictWithTestValues( data->dict, data->testDD );
   /* Do a copy of the DEV during merge, since we don't want it being deleted */
   Dictionary_AddMerge( data->dict, "test_struct", Dictionary_Entry_Value_Copy( testStruct2, True ), Dictionary_MergeType_Append );
   /* OK: since this was an append, we expect _two_ entries called "test_struct",
    * one preceding the other, one with the orig data, one with new data */    
   pcu_check_true( (data->testDD->testEntriesCount+1) == data->dict->count );
   pcu_check_true( Dictionary_Entry_Value_Compare( data->testDD->testValues[8], Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_struct" ) )  );
   pcu_check_true( Dictionary_Entry_Value_Compare( testStruct2, data->dict->entryPtr[9]->value ) );
   Dictionary_Empty( data->dict );

   /* Testing Merge_Merge */
   DictionarySuite_PopulateDictWithTestValues( data->dict, data->testDD );

   /* The nicest way for this test I think is to manually build a merged struct
    *  to compare against */
   expectedMergedStruct = Dictionary_Entry_Value_Copy( data->testDD->testValues[8], True );
   Dictionary_Set( expectedMergedStruct->as.typeStruct, (Dictionary_Entry_Key)"anisotropic", Dictionary_Entry_Value_FromBool( False )  );
   Dictionary_Add( expectedMergedStruct->as.typeStruct, (Dictionary_Entry_Key)"new_person", Dictionary_Entry_Value_FromString( "Luke" )  );
   Dictionary_Set( (Dictionary_Get( expectedMergedStruct->as.typeStruct, (Dictionary_Entry_Key)"geom" ) )->as.typeStruct, "startz", Dictionary_Entry_Value_FromUnsignedInt( 222 ) );

   Dictionary_AddMerge( data->dict, "test_struct", Dictionary_Entry_Value_Copy( testStruct2, True ), Dictionary_MergeType_Merge );
   /* This time, the new struct should be merged into the existing one */
   pcu_check_true( data->testDD->testEntriesCount == data->dict->count );
   mergedStruct = Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_struct"  );
   pcu_check_true( Dictionary_Entry_Value_Compare( mergedStruct, expectedMergedStruct ) );
   Dictionary_Empty( data->dict );
   Dictionary_Entry_Value_Delete( expectedMergedStruct );

   /* Testing Merge_Replace */
   DictionarySuite_PopulateDictWithTestValues( data->dict, data->testDD );
   Dictionary_AddMerge( data->dict, "test_struct", Dictionary_Entry_Value_Copy( testStruct2, True ), Dictionary_MergeType_Replace );
   pcu_check_true( data->testDD->testEntriesCount == data->dict->count );
   pcu_check_true( Dictionary_Entry_Value_Compare( testStruct2, Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_struct" ) ) );
   Dictionary_Empty( data->dict );

   Dictionary_Entry_Value_Delete( testStruct2 );
}
void DictionarySuite_SetupTestDictData( DictionarySuite_TestDictData* testDD ) {
   Index                   ii=0;
   Index                   iter=0;
   Dictionary_Entry_Value* testStruct; 
   Dictionary_Entry_Value* testStruct2; 
   Dictionary_Entry_Value* testList; 

   testDD->testEntriesCount = 9;
   testDD->testKeys = Memory_Alloc_Array_Unnamed( char*, testDD->testEntriesCount );
   testDD->testValues = Memory_Alloc_Array_Unnamed( Dictionary_Entry_Value*,
      testDD->testEntriesCount );

   for ( ii=0; ii< testDD->testEntriesCount; ii++ ) {
      testDD->testKeys[ii] = NULL;
      testDD->testValues[ii] = NULL;
   }

   Stg_asprintf( &testDD->testString, "hello" );
   Stg_asprintf( &testDD->testPlaceHolder, "test_double" );
   testDD->testDouble=45.567;
   testDD->testUint = 5;
   testDD->testInt = -5;
   testDD->testUnsignedlong = 52342423;
   testDD->testBool = True;
   iter = 0;
   Stg_asprintf( &testDD->testKeys[iter], "test_cstring" );
   testDD->testValues[iter] = Dictionary_Entry_Value_FromString( testDD->testString );
   Stg_asprintf( &testDD->testKeys[++iter], "test_double" );
   testDD->testValues[iter] = Dictionary_Entry_Value_FromDouble( testDD->testDouble );
   Stg_asprintf( &testDD->testKeys[++iter], "test_uint" );
   testDD->testValues[iter] = Dictionary_Entry_Value_FromUnsignedInt( testDD->testUint );
   Stg_asprintf( &testDD->testKeys[++iter], "test_int" );
   testDD->testValues[iter] = Dictionary_Entry_Value_FromInt( testDD->testInt );
   Stg_asprintf( &testDD->testKeys[++iter], "test_unsignedlong" );
   testDD->testValues[iter] = Dictionary_Entry_Value_FromUnsignedLong( testDD->testUnsignedlong );
   Stg_asprintf( &testDD->testKeys[++iter], "test_bool" );
   testDD->testValues[iter] = Dictionary_Entry_Value_FromUnsignedInt( testDD->testBool );
   Stg_asprintf( &testDD->testKeys[++iter], "test_placeholder" );
   testDD->testValues[iter] = Dictionary_Entry_Value_FromString( testDD->testPlaceHolder );

   /* adding a list */
   testDD->testListCount = 5;
   testDD->testList = Memory_Alloc_Array_Unnamed( double, testDD->testListCount );
   for (ii=0; ii<testDD->testListCount; ii++ ) {
      testDD->testList[ii] = 10.0 * ii;
   }

   testList = Dictionary_Entry_Value_NewList();
   Stg_asprintf( &testDD->testKeys[++iter], "test_list" );
   testDD->testValues[iter] = testList;
   for (ii=0; ii < testDD->testListCount; ii++ ) {
      Dictionary_Entry_Value_AddElement( testList, Dictionary_Entry_Value_FromDouble(testDD->testList[ii]) );
   }

   /* Adding members to a struct */
   testDD->testStruct = Memory_Alloc_Unnamed( TestStruct );
   testDD->testStruct->height = 37;
   testDD->testStruct->anisotropic = True;
   Stg_asprintf( &testDD->testStruct->person, "Patrick" );
   testDD->testStruct->geom.startx = 45;
   testDD->testStruct->geom.starty = 60;
   testDD->testStruct->geom.startz = 70;

   testStruct = Dictionary_Entry_Value_NewStruct();
   Stg_asprintf( &testDD->testKeys[++iter], "test_struct" );
   testDD->testValues[iter] = testStruct;
   Dictionary_Entry_Value_AddMember( testStruct, (Dictionary_Entry_Key)"height", Dictionary_Entry_Value_FromDouble( testDD->testStruct->height )  );
   Dictionary_Entry_Value_AddMember( testStruct, (Dictionary_Entry_Key)"anisotropic", Dictionary_Entry_Value_FromBool( testDD->testStruct->anisotropic )  );
   Dictionary_Entry_Value_AddMember( testStruct, (Dictionary_Entry_Key)"person", Dictionary_Entry_Value_FromString( testDD->testStruct->person ) );

   /* Adding a 2nd struct within the first struct */
   testStruct2 = Dictionary_Entry_Value_NewStruct( );
   Dictionary_Entry_Value_AddMember( testStruct, (Dictionary_Entry_Key)"geom", testStruct2  );
   Dictionary_Entry_Value_AddMember( testStruct2, (Dictionary_Entry_Key)"startx", Dictionary_Entry_Value_FromUnsignedInt( testDD->testStruct->geom.startx )  );
   Dictionary_Entry_Value_AddMember( testStruct2, (Dictionary_Entry_Key)"starty", Dictionary_Entry_Value_FromUnsignedInt( testDD->testStruct->geom.starty )  );
   Dictionary_Entry_Value_AddMember( testStruct2, (Dictionary_Entry_Key)"startz", Dictionary_Entry_Value_FromUnsignedInt( testDD->testStruct->geom.startz ) );
}
Пример #10
0
Bool Stg_ComponentFactory_PluginGetBool( void* cf, void *codelet, Dictionary_Entry_Key key, Bool defaultVal ) {
        return Dictionary_Entry_Value_AsBool( 
                _Stg_ComponentFactory_PluginGetDictionaryValue( cf, codelet, key,
                                                                Dictionary_Entry_Value_FromBool( defaultVal ) ) );
}
Пример #11
0
Bool _Stg_ComponentFactory_GetBool( void* cf, Name componentName, Dictionary_Entry_Key key, Bool defaultVal ) {
   return Dictionary_Entry_Value_AsBool( 
         _Stg_ComponentFactory_GetDictionaryValue( cf, componentName, key, 
            Dictionary_Entry_Value_FromBool( defaultVal ) ) );
}   
Пример #12
0
void stgGenerateFlattenedXML( Dictionary* dictionary, Dictionary* sources, char* timeStamp ) {
   XML_IO_Handler* ioHandler;
   char*           outputPath;
   char*           flatFilename;
   char*           flatFilenameStamped;
   char*           slimFilename;
   Stream*         s;
   Bool            isEnabled;
   Bool            ret;
   Bool            outputSlim;

   s = Journal_Register( Info_Type, (Name)XML_IO_Handler_Type );

   /* Avoid confusing messages from XML_IO_Handler. Turn it off temporarily. */
   isEnabled = Stream_IsEnable( s );
   Stream_EnableSelfOnly( s, False );

   ioHandler = XML_IO_Handler_New();
   if( sources == NULL )
      ioHandler->writeSources = False;
   outputPath = StG_Strdup( Dictionary_Entry_Value_AsString( Dictionary_GetDefault( dictionary,
      (Dictionary_Entry_Key)"outputPath", Dictionary_Entry_Value_FromString( "./" ) ) ) );
   outputSlim = Dictionary_Entry_Value_AsBool( Dictionary_GetDefault( dictionary,
      (Dictionary_Entry_Key)"outputSlimmedXML", Dictionary_Entry_Value_FromBool( True ) ) );

   if( ! Stg_DirectoryExists( outputPath ) ) {
      if( Stg_FileExists( outputPath ) )
         Journal_Firewall( 0, s, "outputPath '%s' is a file an not a directory! Exiting...\n", outputPath );

      Journal_Printf( s, "outputPath '%s' does not exist, attempting to create...\n", outputPath );
      ret = Stg_CreateDirectory( outputPath );
      Journal_Firewall( ret, s, "Unable to create non-existing outputPath to '%s'\n", outputPath );
      Journal_Printf( s, "outputPath '%s' successfully created!\n", outputPath );
   }

   /* Set file names. */
   Stg_asprintf( &flatFilename, "%s/%s", outputPath, "input.xml" );

   IO_Handler_WriteAllToFile( ioHandler, flatFilename, dictionary, sources );

   /* Format; path/input-YYYY.MM.DD-HH.MM.SS.xml. */
   if (timeStamp) {
      Stg_asprintf( &flatFilenameStamped, "%s/%s-%s.%s",
                   outputPath, "input", timeStamp, "xml" );
      IO_Handler_WriteAllToFile( ioHandler, flatFilenameStamped, dictionary, sources );
      Memory_Free( flatFilenameStamped );
   }

   
   if( outputSlim && timeStamp ) {
      ioHandler->writeSources = False;
      Stg_asprintf( &slimFilename, "%s/%s-%s.%s",
         outputPath, "input-basic", timeStamp, "xml" );
      IO_Handler_WriteAllToFile( ioHandler, slimFilename, dictionary, NULL);
   }

   Stream_EnableSelfOnly( s, isEnabled );
   Stg_Class_Delete( ioHandler );

   Memory_Free( flatFilename );
}
void _UnderworldContext_Init( UnderworldContext* self ) {
	self->isConstructed = True;

	/* always generate XDMF files when we generate HDF5 checkpoints */
#ifdef WRITE_HDF5
	if( Dictionary_Entry_Value_AsBool( Dictionary_GetDefault( self->dictionary, "generateXDMF", Dictionary_Entry_Value_FromBool( True ) ) ) ){
		ContextEP_Append( self, AbstractContext_EP_Save, XDMFGenerator_GenerateAll );
		ContextEP_Append( self, AbstractContext_EP_DataSave, XDMFGenerator_GenerateAll );

      if( Dictionary_Entry_Value_AsInt( Dictionary_GetDefault( self->dictionary, "checkpointEvery"    , Dictionary_Entry_Value_FromInt( 0 ) ) )  ||
          Dictionary_Entry_Value_AsInt( Dictionary_GetDefault( self->dictionary, "saveDataEvery"      , Dictionary_Entry_Value_FromInt( 0 ) ) )	 ||
          Dictionary_Entry_Value_AsInt( Dictionary_GetDefault( self->dictionary, "checkpointAtTimeInc", Dictionary_Entry_Value_FromInt( 0 ) ) )
            ){
            ContextEP_Append( self, AbstractContext_EP_Build, XDMFGenerator_GenerateTemporalTopLevel );
      }
	}
#endif
   
}
Dictionary_Entry_Value* Dictionary_Entry_Value_Copy(
		Dictionary_Entry_Value*  self,
		Bool deep )
{
	Dictionary_Entry_Value* copy = NULL;
	
	switch (self->type) {
		case Dictionary_Entry_Value_Type_String:
			copy = Dictionary_Entry_Value_FromString( self->as.typeString );
			break;
		case Dictionary_Entry_Value_Type_Double:
			copy = Dictionary_Entry_Value_FromDouble( self->as.typeDouble );
			break;
		case Dictionary_Entry_Value_Type_UnsignedInt:
			copy = Dictionary_Entry_Value_FromUnsignedInt( self->as.typeUnsignedInt );
			break;
		case Dictionary_Entry_Value_Type_Int:
			copy = Dictionary_Entry_Value_FromInt( self->as.typeInt );
			break;
		case Dictionary_Entry_Value_Type_UnsignedLong:
			copy = Dictionary_Entry_Value_FromUnsignedLong( self->as.typeUnsignedLong );
			break;
		case Dictionary_Entry_Value_Type_Bool:
			copy = Dictionary_Entry_Value_FromBool( self->as.typeBool );
			break;
		case Dictionary_Entry_Value_Type_List:
			if ( False == deep ) {
				Stream* errorStream = Journal_Register( Error_Type, "Dictionary_Entry_Value" );
				Journal_Firewall( False, errorStream, "In func %s: Shallow copy operation of list DEV not supported.\n", __func__ );
			}
			else {
				Dictionary_Entry_Value* cur = self->as.typeList->first;
				Dictionary_Entry_Value* copiedEntry = NULL;

				copy = Dictionary_Entry_Value_NewList();
				while ( cur ) {
					copiedEntry = Dictionary_Entry_Value_Copy( cur, True );
					Dictionary_Entry_Value_AddElement( copy, copiedEntry );
					cur = cur->next;
				}	
			}
			break;
		case Dictionary_Entry_Value_Type_Struct:
			if ( False == deep ) {
				copy = Dictionary_Entry_Value_FromStruct( self->as.typeStruct );
			}
			else {
				Dictionary* copiedDict;
				copiedDict = (Dictionary*)Stg_Class_Copy( self->as.typeStruct,
					NULL, True, NULL, NULL );
				copy = Dictionary_Entry_Value_FromStruct( copiedDict );
			}
			break;
		default: {
			Stream* errorStream = Journal_Register( Error_Type, "Dictionary_Entry_Value" );
			Journal_Firewall( False, errorStream, "In func %s: self->type '%d' is invalid.\n", __func__, self->type );
		}
	}

	return copy;
}
Пример #15
0
int main(int argc, char *argv[])
{
	MPI_Comm		CommWorld;
	int		rank;
	int		procCount;
	int		procToWatch;
	Stream*		stream;
	
	Dictionary*		dictionary;
	XML_IO_Handler*		io_handler;
	
	Topology*       nTopology;
	ElementLayout*	eLayout;
	NodeLayout*	nLayout;
	MeshDecomp*	decomp;
	MeshLayout*	layout;
	Mesh*		mesh;
	
	Variable*			var[7];
	Variable_Register*		variable_Register;
	WallVC*				vc;
	ConditionFunction*		quadCF;
	ConditionFunction*		expCF;
	ConditionFunction_Register*	conFunc_Register;

	ExtensionManager_Register*		extensionMgr_Register;
	
	double*		array[7];
	char*		vcKey[] = {"WallVC_Front", "WallVC_Back", "WallVC_Left", "WallVC_Right",
				"WallVC_Top", "WallVC_Bottom"};
	char*		vcKeyName[] = {"WallVC_FrontName", "WallVC_BackName", "WallVC_LeftName", "WallVC_RightName",
				"WallVC_TopName", "WallVC_BottomName"};
	char*		varName[] = {"x", "y", "z", "vx", "vy", "vz", "temp"};
	
	Index	i;

	
	/* Initialise MPI, get world info */
	MPI_Init(&argc, &argv);
	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
	MPI_Comm_size(CommWorld, &procCount);
	MPI_Comm_rank(CommWorld, &rank);
	
	Base_Init( &argc, &argv );
	
	DiscretisationGeometry_Init( &argc, &argv );
	DiscretisationShape_Init( &argc, &argv );
	DiscretisationMesh_Init( &argc, &argv );
	DiscretisationUtils_Init( &argc, &argv );
	MPI_Barrier( CommWorld ); /* Ensures copyright info always come first in output */

	io_handler = XML_IO_Handler_New();

	stream = Journal_Register (Info_Type, "myStream");
	
	procToWatch = argc >= 2 ? atoi(argv[1]) : 0;
	
	dictionary = Dictionary_New();
	IO_Handler_ReadAllFromFile(io_handler, "data/wallVC.xml", dictionary);
	fflush(stdout);
	MPI_Barrier(MPI_COMM_WORLD);
	Dictionary_Add(dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt(rank));
	Dictionary_Add(dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt(procCount));
	Dictionary_Add(dictionary, "meshSizeI", Dictionary_Entry_Value_FromUnsignedInt(4));
	Dictionary_Add(dictionary, "meshSizeJ", Dictionary_Entry_Value_FromUnsignedInt(4));
	Dictionary_Add(dictionary, "meshSizeK", Dictionary_Entry_Value_FromUnsignedInt(4));
	Dictionary_Add(dictionary, "allowUnbalancing", Dictionary_Entry_Value_FromBool(True));

	extensionMgr_Register = ExtensionManager_Register_New();	
	
	nTopology = (Topology*)IJK6Topology_New( "IJK6Topology", dictionary );
	eLayout = (ElementLayout*)ParallelPipedHexaEL_New( "PPHexaEL", 3, dictionary );
	nLayout = (NodeLayout*)CornerNL_New( "CornerNL", dictionary, eLayout, nTopology );
	decomp = (MeshDecomp*)HexaMD_New( "HexaMD", dictionary, MPI_COMM_WORLD, eLayout, nLayout );
	layout = MeshLayout_New( "MeshLayout", eLayout, nLayout, decomp );
	mesh = Mesh_New( "Mesh", layout, 0, 0, extensionMgr_Register, dictionary );
	
	/* Create CF stuff */
	quadCF = ConditionFunction_New(quadratic, "quadratic");
	expCF = ConditionFunction_New(exponential, "exponential");
	conFunc_Register = ConditionFunction_Register_New();
	ConditionFunction_Register_Add(conFunc_Register, quadCF);
	ConditionFunction_Register_Add(conFunc_Register, expCF);
	
	/* Create variable register */
	variable_Register = Variable_Register_New();
	
	/* Create variables */
	for (i = 0; i < 6; i++) {
		array[i] = Memory_Alloc_Array( double, decomp->nodeLocalCount, "array[i]" );
		var[i] = Variable_NewScalar( varName[i], Variable_DataType_Double, &decomp->nodeLocalCount, (void**)&array[i], 0 ); 
		Variable_Register_Add(variable_Register, var[i]);
	}
	array[6] = Memory_Alloc_Array( double, decomp->nodeLocalCount * 5, "array[6]" );
	var[6] = Variable_NewVector( varName[6], Variable_DataType_Double, 5, &decomp->nodeLocalCount, (void**)&array[6], 0 );
	Variable_Register_Add(variable_Register, var[6]);
	Variable_Register_BuildAll(variable_Register);
	
	/* Create WallVC */
	for (i = 0; i < 6; i++)
	{
		Index	j, k;
		
		vc = WallVC_New( vcKeyName[i], vcKey[i], variable_Register, conFunc_Register, dictionary, mesh );
		Build( vc, 0, False );
		
		for (j = 0; j < 6; j++)
			memset(array[j], 0, sizeof(double)* decomp->nodeLocalCount );
		memset(array[6], 0, sizeof(double)* decomp->nodeLocalCount * 5);
		VariableCondition_Apply(vc, NULL);
	
		if (rank == procToWatch)
		{
			printf("Testing for %s\n", vcKey[i]);
			Print(vc, stream);
			printf("\n");
			for (j = 0; j < 6; j++)
			{
				printf("\nvar[%u]: %.2lf", j, array[j][0]);
				for (k = 1; k < decomp->nodeLocalCount; k++)
					printf(", %.2lf", array[j][k]);
			}
			printf("\nvar[6]: %.2lf", array[6][0]);
			for (j = 1; j < decomp->nodeLocalCount*5; j++)
				printf(", %.2lf", array[6][j]);
			printf("\n\n");
			
			for (j = 0; j < 7; j++)
			{
				for (k = 0; k < decomp->nodeLocalCount; k++)
					printf("%s ", VariableCondition_IsCondition(vc, k, j) ? "True " : "False");
				printf("\n");
			}
			printf("\n");
			
			for (j = 0; j < 7; j++)
			{
				for (k = 0; k < decomp->nodeLocalCount; k++)
				{
					VariableCondition_ValueIndex	valIndex;
					
					valIndex = VariableCondition_GetValueIndex(vc, k, j);
					if (valIndex != (unsigned)-1)
						printf("%03u ", valIndex);
					else
						printf("XXX ");
				}
				printf("\n");
			}
			printf("\n");
		}
		
		Stg_Class_Delete(vc);
	}
		
	Stg_Class_Delete(variable_Register);
	for (i = 0; i < 7; i++)
	{
		Stg_Class_Delete(var[i]);
		if (array[i]) Memory_Free(array[i]);
	}
	Stg_Class_Delete(conFunc_Register);
	Stg_Class_Delete(quadCF);
	Stg_Class_Delete(expCF);
	Stg_Class_Delete(layout);
	Stg_Class_Delete(decomp);
	Stg_Class_Delete(nLayout);
	Stg_Class_Delete(eLayout);
	Stg_Class_Delete( nTopology );
	Stg_Class_Delete(dictionary);
	
	DiscretisationUtils_Finalise();
	DiscretisationMesh_Finalise();
	DiscretisationShape_Finalise();
	DiscretisationGeometry_Finalise();
	
	Base_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();
	
	return 0; /* success */
}
Пример #16
0
int main( int argc, char* argv[] ) {
	MPI_Comm		CommWorld;
	int			rank;
	int			procCount;
	Dictionary*		dictionary;
	Geometry*		geometry;
	ElementLayout*		eLayout;
	Topology*		nTopology;
	NodeLayout*		nLayout;
	HexaMD*			meshDecomp;
	Index			i;
	Processor_Index		procToWatch;
	
	/* Initialise MPI, get world info */
	MPI_Init(&argc, &argv);
	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
	MPI_Comm_size(CommWorld, &procCount);
	MPI_Comm_rank(CommWorld, &rank);

	Base_Init( &argc, &argv );
	
	DiscretisationGeometry_Init( &argc, &argv );
	DiscretisationShape_Init( &argc, &argv );
	DiscretisationMesh_Init( &argc, &argv );
	MPI_Barrier( CommWorld ); /* Ensures copyright info always come first in output */
	
	procToWatch = argc >= 2 ? atoi(argv[1]) : 0;
	
	dictionary = Dictionary_New();
	Dictionary_Add( dictionary, "meshSizeI", Dictionary_Entry_Value_FromUnsignedInt( 13 ) );
	Dictionary_Add( dictionary, "meshSizeJ", Dictionary_Entry_Value_FromUnsignedInt( 4 ) );
	Dictionary_Add( dictionary, "meshSizeK", Dictionary_Entry_Value_FromUnsignedInt( 4 ) );
	Dictionary_Add( dictionary, "maxX", Dictionary_Entry_Value_FromUnsignedInt( 6 ) );
	Dictionary_Add( dictionary, "allowUnbalancing", Dictionary_Entry_Value_FromBool( True ) );
	Dictionary_Add( dictionary, "shadowDepth", Dictionary_Entry_Value_FromUnsignedInt( 1 ) );
	Dictionary_Add( dictionary, "isPeriodicI", Dictionary_Entry_Value_FromBool( True ) );

	
	eLayout = (ElementLayout*)ParallelPipedHexaEL_New( "PPHexaEL", 3, dictionary );
	nTopology = (Topology*)IJK6Topology_New( "IJK6Topology", dictionary );
	nLayout = (NodeLayout*)CornerNL_New( "CornerNL", dictionary, eLayout, nTopology );
	meshDecomp = HexaMD_New( "HexaMD", dictionary, MPI_COMM_WORLD, eLayout, nLayout );
	
	ElementLayout_Build( eLayout, meshDecomp );
	
	if (rank == procToWatch) {
		printf( "Element with point:\n" );
	}
	geometry = eLayout->geometry;
	for( i = 0; i < geometry->pointCount; i++ ) {
		Coord point;
		int excEl, incEl;
		
		geometry->pointAt( geometry, i, point );

		if (rank == procToWatch) {
			printf( "\tNode %u (%0.2f,%0.2f,%0.2f):\n", i, point[0], point[1], point[2] );
			excEl = eLayout->elementWithPoint( eLayout, meshDecomp, point, NULL, 
							   EXCLUSIVE_UPPER_BOUNDARY, 0, NULL );
			incEl = eLayout->elementWithPoint( eLayout, meshDecomp, point, NULL, 
							   INCLUSIVE_UPPER_BOUNDARY, 0, NULL );
			printf( "\t\tIncl %4u, Excl %4u\n", incEl, excEl );		
		}

		point[0] += 0.1;
		point[1] += 0.1;
		point[2] += 0.1;
		
		if (rank == procToWatch) {
			printf( "\tTest point %u (%0.2f,%0.2f,%0.2f):\n", i, point[0], point[1], point[2] );
			excEl = eLayout->elementWithPoint( eLayout, meshDecomp, point, NULL, 
							   EXCLUSIVE_UPPER_BOUNDARY, 0, NULL );
			incEl = eLayout->elementWithPoint( eLayout, meshDecomp, point, NULL, 
							   INCLUSIVE_UPPER_BOUNDARY, 0, NULL );
			printf( "\t\tIncl %4u, Excl %4u\n", incEl, excEl );		
		}
	}
	if (rank == procToWatch) {
		printf( "\n" );
	}	
	
	Stg_Class_Delete( dictionary );
	Stg_Class_Delete( meshDecomp );
	Stg_Class_Delete( nLayout );
	Stg_Class_Delete( nTopology );
	Stg_Class_Delete( eLayout );
	
	DiscretisationMesh_Finalise();
	DiscretisationShape_Finalise();
	DiscretisationGeometry_Finalise();
	
	Base_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();
	
	return 0;
}