diff --git a/include/MSTK_private.h b/include/MSTK_private.h index 4cc3b9c..dc4316a 100644 --- a/include/MSTK_private.h +++ b/include/MSTK_private.h @@ -332,6 +332,7 @@ typedef enum MDelType {MDELREGION=-40, MDELFACE=-30, MDELEDGE=-20, MDELVERTEX=-1 int MESH_PartitionWithZoltan(Mesh_ptr mesh, int nparts, int **part, int noptions, char **options, MSTK_Comm comm); + int MESH_PartitionWithColoringFile(Mesh_ptr mesh, int nparts, int **part); int FixColumnPartitions(Mesh_ptr mesh, int *part, MSTK_Comm comm); int FixColumnPartitions_IsSide(Mesh_ptr mesh, MRegion_ptr mr, MFace_ptr rf); int FixColumnPartitions_UpDown(Mesh_ptr mesh, MRegion_ptr mr, MFace_ptr* up, MFace_ptr* dn); diff --git a/src/par/MESH_Get_Partitioning.c b/src/par/MESH_Get_Partitioning.c index 446c904..68b9a2f 100644 --- a/src/par/MESH_Get_Partitioning.c +++ b/src/par/MESH_Get_Partitioning.c @@ -112,6 +112,14 @@ int MESH_Get_Partitioning(Mesh_ptr mesh, int method, int **part, MSTK_Comm comm) break; } + case 3: { + /* This reads a coloring file */ + if (rank == 0) { + ok = MESH_PartitionWithColoringFile(mesh, num, part); + } + + break; + } default: MSTK_Report("MESH_Get_Partition","Unknown partitioning method",MSTK_FATAL); } diff --git a/src/par/MESH_PartitionWithColoringFile.c b/src/par/MESH_PartitionWithColoringFile.c new file mode 100644 index 0000000..7bd9574 --- /dev/null +++ b/src/par/MESH_PartitionWithColoringFile.c @@ -0,0 +1,48 @@ +/* +Copyright 2019 Triad National Security, LLC. All rights reserved. + +This file is part of the MSTK project. Please see the license file at +the root of this repository or at +https://github.com/MeshToolkit/MSTK/blob/master/LICENSE +*/ + +#include +#include + +#include "MSTK.h" + +/* Get the partitioning of mesh by reading a coloring file - + Doesn't actually do anything to the mesh */ + +#ifdef __cplusplus +extern "C" { +#endif + + +int MESH_PartitionWithColoringFile(Mesh_ptr mesh, int nparts, int **part) { + int ncells; + FILE* fid; + size_t count; + + ncells = MESH_Num_Regions(mesh); + *part = (int *) malloc(ncells*sizeof(int)); + + fid = fopen("coloring.bin", "rb"); + if (fid == NULL) { + fprintf(stderr,"Nonexistent coloring file \"coloring.bin\"\n"); + exit(-1); + } + + count = fread(*part, sizeof(int), (size_t) ncells, fid); + fprintf(stderr,"read %zu of %i region colors from coloring.bin\n", count, ncells); + if (count != (size_t) ncells) { + fprintf(stderr,"Error reading coloring file \"coloring.bin\"\n"); + exit(-1); + } + fclose(fid); + return 1; +} + +#ifdef __cplusplus + } +#endif diff --git a/utils/meshconvert/src/meshconvert.c b/utils/meshconvert/src/meshconvert.c index eb8250e..46583dc 100644 --- a/utils/meshconvert/src/meshconvert.c +++ b/utils/meshconvert/src/meshconvert.c @@ -57,10 +57,11 @@ int main(int argc, char *argv[]) { if (argc < 3) { fprintf(stderr,"\n"); - fprintf(stderr,"usage: meshconvert <--classify=0|n|1|y|2> <--partition=y|1|n|0> <--partition-method=0|1|2> <--parallel-check=y|1|n|0> <--weave=y|1|n|0> <--num-ghost-layers=?> <--check-topo=y|1|n|0> infilename outfilename\n\n"); + fprintf(stderr,"usage: meshconvert <--classify=0|n|1|y|2> <--partition=y|1|n|0> <--partition-method=0|1|2|3> <--parallel-check=y|1|n|0> <--weave=y|1|n|0> <--num-ghost-layers=?> <--check-topo=y|1|n|0> infilename outfilename\n\n"); fprintf(stderr,"partition-method = 0, METIS\n"); fprintf(stderr," = 1, ZOLTAN with GRAPH partioning\n"); fprintf(stderr," = 2, ZOLTAN with RCB partitioning\n"); + fprintf(stderr," = 3, read partitioning from coloring.bin file\n"); fprintf(stderr,"Choose 2 if you want to avoid partitioning models\n"); fprintf(stderr,"with high aspect ratio along the short directions\n"); fprintf(stderr,"\n");