CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

How to conert cgns in to node array for Metis?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 12, 2006, 23:53
Default How to conert cgns in to node array for Metis?
  #1
John
Guest
 
Posts: n/a
Hi does anybody know how to use MeTis? Actually in my case i am using my own code which takes only cgns file for solver. I have to partition the domain, so i am using metis.But, in Metis it takes graph as input and does partition. For making graph it takes node array as input. so my problem is how to convert cgns file into node array? pls let me know Thank you to all.

John
  Reply With Quote

Old   November 13, 2006, 06:16
Default Re: How to conert cgns in to node array for Metis?
  #2
Renato.
Guest
 
Posts: n/a
Metis does not takes graphs only. It also provides routines which works directly in mesh data (METIS_PartMeshDual for example). These routines will convert, internally, your data into graphs. You can also use the METIS_MeshToDual routine to convert your data before calling graph partitioning routines. It's up to you. These routines and data format are nicely described in the Metis users guide.

Cheers

Renato.
  Reply With Quote

Old   November 13, 2006, 06:44
Default Re: How to conert cgns in to node array for Metis?
  #3
John
Guest
 
Posts: n/a
Thanu Renato, u are right, but before making partition i have to convert mesh file into graph file. I have confusion abt this mesh file. (i.e. how to convert my cgns file in mesh file?) bcoz i have cgns as mesh file format, and in mesh file you should have element array, so how to conevert my cgns file into mesh file? Again thank you.
  Reply With Quote

Old   November 13, 2006, 07:05
Default Re: How to conert cgns in to node array for Metis?
  #4
Renato.
Guest
 
Posts: n/a
You're, surely, making some confusion...

1st). You only need the graph IF (and only IF) you're working with hybrid mesh (mixing different kinds of elements in the same mesh, e.g., tets+hexas). NOTE: Only Metis (serial version) need the graph to partition hybrid mesh. ParMetis is able to operate directly on hybrid mesh data.

2nd). Metis *only* need the conectivity information because it's able to convert this data internally.

Here goes an example of the METIS_PartMeshDual routine (I should remember that it's fully explained in the users guide):

call METIS_PartMeshDual( nel, nnos, ien, etype, idx, nprocs, ncutedg, epart, npart )

INPUT DATA nel: number of elements nnos: number of nodes ien: element conectivity etype: element type (2= tetrahedra for example) idx: 1 = Fortran style array numbering, 0 = C style array numbering nprocs: Number of partitions

OUTPUT DATA ncutedg: Number of edge cuts (only for your information) epart: element partitions npart: nodal partitions

thus, where is the graph in the above statement?

Note that it has nothing to do with your CGNS reader. If you're actually reading an unstructured mesh with CGNS I'm sure that you'll have the conectivity information.

Regards

Renato.

  Reply With Quote

Old   November 13, 2006, 07:33
Default Re: How to conert cgns in to node array for Metis?
  #5
Renato.
Guest
 
Posts: n/a
just for completeness

You only need the graph IF (and only IF) you're working with hybrid mesh *OR* you have a mesh with elements not supported by Metis (tria, tet, hex, quad).
  Reply With Quote

Old   November 13, 2006, 07:38
Default ERRATA
  #6
Renato.
Guest
 
Posts: n/a
I think the last message worth some explanation:

tria3, tet4, hex8 and quad4 are, of course, the standard elements supported by Metis.

Examples of elements not support are: prisms, wedges, etc...

NOTE: ParMetis employs a different mesh data layout. In ParMetis the data format is more flexible to support different elements, with different configurations.

  Reply With Quote

Old   November 13, 2006, 08:45
Default Re: ERRATA
  #7
John
Guest
 
Posts: n/a
Hi Renato thanku very much for valuable suggestion. Infact i hav not installed Parmetis, now i have download it. Now i only want to know (after partitioning have done ) how can i again convert output file into cgns file ? The problem is that i havenot source code of cfd i have only executable of one of cfd code. (not commercial code ).so i am unable to make chnages . thats why i am taking help of adfviewer which is free, so is there anyway to make output partition file into cgns file. Thanks again.
  Reply With Quote

Old   November 13, 2006, 09:12
Default Re: ERRATA
  #8
Renato.
Guest
 
Posts: n/a
I don't know regarding CGNS since I've never used this format. I only could say that after partitioning your mesh you'll have independent meshes that could be treated separately, for instance, as independent mesh files. Something like:

mesh.cgns --> Metis --> mesh_00.cgns, mesh_01.cgns, ..., mesh_nn.cgns.

If you're only interested in see the partitions created you could use PMVIS ( http://www-users.cs.umn.edu/~oztekin/pmvis/ ). It's free and very easy to use.

BTW, What are you trying to do exactly?! Are you implementing a solver, modifying a program or just learning how to use Metis?!

NOTE: Particularly, I think Metis (serial) easier to learn and use than ParMetis (parallel) but it's up to you ;o)

  Reply With Quote

Old   November 13, 2006, 10:51
Default Re: ERRATA
  #9
John
Guest
 
Posts: n/a
Yeah Renato i am just implementing solver. I have to add partition functon in solver. I wanted to see that how metis works. We have nt any mesh format but are using cgns . Thanks for your valuable co operation.
  Reply With Quote

Old   November 13, 2006, 11:17
Default Re: How to conert cgns in to node array for Metis?
  #10
rt
Guest
 
Posts: n/a
hi john,

as i understand u have implementation problem, i think that with deep look at Metis examples your problem is resolved but i simply pase a part of my code related to this, probably it help u, if u are fem man u easily understand this code (partitioning tet mesh with metis)

#include "header.h"

// this is prototype of modified metis function for our purpose

void METIS_PartMeshNodal_(int *ne, int *nn,

idxtype *elmnts,

int *etype, int *numflag,

int *nparts, int *edgecut,

idxtype *epart, idxtype *npart,

idxtype *xadj,idxtype *adjncy);

/*::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::*/ /* Partitioning Mesh with Metis /*::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::*/

void metis(INPUT input, PAR_DATA *par_data, int numprocs) {

INT i, ii, j, k, l, fl, ne, me, nt, nn,

etype, numflag=0, edgecut, *lable;

char etypestr[4][5] = {"TRI", "TET", "HEX", "QUAD"};

idxtype *pwgts, *perm, *iperm;

int options[10], pnumflag=0, wgtflag=0;

int nnbrs, nbrind[200], nbrwgt[200], maxpwgt;

int esize, esizes[] = {-1, 3, 4, 8, 4};

INT *Tetra;

options[0] = 0;

etype=2; // for tetraheder element

esize = 4;

nn=input.npoin;

ne=input.ntets;

nt=input.ntris;

par_data->numprocs = numprocs;

par_data->part_tets = (INT *)calloc(ne, sizeof(INT));

par_data->part_nodes = (INT *)calloc(nn, sizeof(INT));

par_data->part_tris = (INT *)calloc(nt, sizeof(INT));

// making adjacency graph of mesh

par_data->xadj = idxmalloc(nn+1, "METIS_MESHPARTNODAL: xadj");

par_data->adjncy = idxmalloc(20*(nn), "METIS_MESHPARTNODAL: adjncy");

Tetra = (INT *)calloc(4*ne, sizeof(INT));

FOR(0,i,ne) FOR(0,j,4) Tetra[4*i+j]=input.tets[i].node[j];

METIS_MeshToNodal(&ne, &nn, Tetra, &etype,

&pnumflag, par_data->xadj, par_data->adjncy);

par_data->adjncy = realloc(par_data->adjncy,

par_data->xadj[nn]*sizeof(idxtype));

METIS_PartMeshNodal_(&ne, &nn, Tetra, &etype,

&numflag, &numprocs, &edgecut,

par_data->part_tets, par_data->part_nodes,

par_data->xadj, par_data->adjncy);

FOR(0,i,input.npoin)

++par_data->npoin[par_data->part_nodes[i]];

free(Tetra);

free(par_data->part_nodes);

free(par_data->xadj);

free(par_data->adjncy); } /*::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::*/ /*::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::*/

// Modified Metis Function /************************************************** *********************** * This function partitions a finite element mesh by partitioning its nodal * graph using KMETIS and then assigning elements in a load balanced fashion. ************************************************** ************************/ void METIS_PartMeshNodal_(int *ne, int *nn, idxtype *elmnts,

int *etype, int *numflag,

int *nparts, int *edgecut,

idxtype *epart, idxtype *npart,

idxtype *xadj,idxtype *adjncy) { int i, j, k, me; idxtype *pwgts; int options[10], pnumflag=0, wgtflag=0; int nnbrs, nbrind[200], nbrwgt[200], maxpwgt; int esize, esizes[] = {-1, 3, 4, 8, 4};

esize = 4;

options[0] = 0; METIS_PartGraphKway(nn, xadj, adjncy, NULL, NULL,

&wgtflag, &pnumflag, nparts, options, edgecut, npart);

/* OK, now compute an element partition based on the nodal partition npart */ idxset(*ne, -1, epart); pwgts = idxsmalloc(*nparts, 0, "METIS_MESHPARTNODAL: pwgts"); for (i=0; i<*ne; i++) {

me = npart[elmnts[i*esize]];

for (j=1; j<esize; j++) {

if (npart[elmnts[i*esize+j]] != me)

break;

}

if (j == esize) {

epart[i] = me;

pwgts[me]++;

} }

maxpwgt = 1.03*(*ne)/(*nparts); for (i=0; i<*ne; i++) {

if (epart[i] == -1) { /* Assign the boundary element */

nnbrs = 0;

for (j=0; j<esize; j++) {

me = npart[elmnts[i*esize+j]];

for (k=0; k<nnbrs; k++) {

if (nbrind[k] == me) {

nbrwgt[k]++;

break;

}

}

if (k == nnbrs) {

nbrind[nnbrs] = me;

nbrwgt[nnbrs++] = 1;

}

}

/* Try to assign it first to the domain with most things in common */

j = iamax(nnbrs, nbrwgt);

if (pwgts[nbrind[j]] < maxpwgt) {

epart[i] = nbrind[j];

}

else {

/* If that fails, assign it to a light domain */

for (j=0; j<nnbrs; j++) {

if (pwgts[nbrind[j]] < maxpwgt) {

epart[i] = nbrind[j];

break;

}

}

if (j == nnbrs)

epart[i] = nbrind[iamax(nnbrs, nbrwgt)];

}

pwgts[epart[i]]++;

} }

free(pwgts);

} /*::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::*/ /*::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::*/

  Reply With Quote

Old   November 14, 2006, 04:52
Default Re: How to conert cgns in to node array for Metis?
  #11
Michael
Guest
 
Posts: n/a
Hi Reanato, i have one doubt. When we are have partitioned using partdmesh then it gives no of parts in graph format. Can you tell me how to convert those graph into mesh file? Thanks
  Reply With Quote

Old   November 14, 2006, 05:43
Default Re: How to conert cgns in to node array for Metis?
  #12
Renato.
Guest
 
Posts: n/a
The output of the partdmesh program is not a graph. The partdmesh program do exactly the same thing the routine METIS PartMeshDual. It takes a MESH file, performs a dual graph partitioning (internally) and gives you the element and nodal parts.

By the way, do you know what a graph is?

Regards

Renato.
  Reply With Quote

Old   November 14, 2006, 06:56
Default Re: How to conert cgns in to node array for Metis?
  #13
Michael
Guest
 
Posts: n/a
no sir, pls explain me . i will be very thanjful of you.
  Reply With Quote

Old   November 14, 2006, 07:56
Default Re: How to conert cgns in to node array for Metis?
  #14
Renato.
Guest
 
Posts: n/a
It would be easier to draw than writing an explanation.

imagine the following 6 nodes:

1: 0. 0. 2: 1. 0. 3: 2. 0. 4: 0. 1. 5: 1. 1. 6: 2. 1.

with them we could build the following triangles:

1: 1-5-4 2: 1-2-5 3: 2-3-5 4: 3-6-5

The information written above is known as connectivity between the nodes (what you've been calling as mesh info). It's widely know for people working with unstructured grids (finite element and finite volume for example)

The corresponding dual graph for the triangles outlined above would be:

1-2-3-4

what does it mean? It means that the triangle 1 is neighbor of the triangle 2, which is neighbor of the triangle 3, which is neighbor of the triangle 4. Thus, the DUAL GRAPH gives the neighborhood information between elements as well as the NODAL GRAPH gives you the same information related to nodes. Note that in this case (the simplest) we're only concerned with the relationship information, there are more advanced ways of embedding more information in a graph.

I hope it helps you

p.s.: Once again, this information is nicely explained in the Metis users guide and Karypis papers freely available in his website.
  Reply With Quote

Old   November 14, 2006, 08:44
Default Re: How to conert cgns in to node array for Metis?
  #15
Michael
Guest
 
Posts: n/a
i have also used metis in fluent. but now frm your discussion i have just installed it. I have make one mesh file named tet.mesh , which contained information of conncevtivity of domain. I have used partdmesh for partitioning in 2 parts. It has given me 2 parts, but having named tet.mesh.npart.2 and tet.mesh.epart.2. What do these files contain ? How can i convert these files in mesh files? pls help me.
  Reply With Quote

Old   November 14, 2006, 09:33
Default Re: How to conert cgns in to node array for Metis?
  #16
Renato.
Guest
 
Posts: n/a
Michael, do you know what Metis is? If so, I'm sure you'll figure out what Metis returned you. Those files contain the element (epart) e nodal (npart) partitions. Of course, you must know what's the purpose of such partitions, otherwise you wouldn't be interested in using Metis.

p.s.: Sorry but it's my last contribution since these informations are very well explained in Metis's users guide.

  Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Master node in parallel computing only distirubtion syadgar FLUENT 1 September 8, 2009 17:41
CGNS - convert BC from node to face Charles Main CFD Forum 1 November 1, 2008 09:50
How to convert cgns file in node array? John Siemens 0 November 12, 2006 23:55
How to convert cgns filr in node array? John FLUENT 0 November 12, 2006 23:54
How to conevrt cgns file in node array for metis? John CFX 0 November 12, 2006 23:54


All times are GMT -4. The time now is 07:04.