Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/MSTK_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/par/MESH_Get_Partitioning.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
48 changes: 48 additions & 0 deletions src/par/MESH_PartitionWithColoringFile.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>
#include <stdlib.h>

#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
3 changes: 2 additions & 1 deletion utils/meshconvert/src/meshconvert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down