| T O P I C R E V I E W |
| daver |
Posted - Jun 03 2010 : 01:45:58 Has anyone used opensource gmsh to create mesh and imported that into fastcap? I don't want to purchase Patran ($$), nor do I want to use the generic file interface for relatively complex structures. gmsh seems to be a good mesh creation tool but its output file format choices are not compatible. Has anyone written the code needed to convert?
dave |
| 4 L A T E S T R E P L I E S (Newest First) |
| chromatik |
Posted - May 02 2011 : 11:02:25 quote: Originally posted by v.b.t
Hi all,
I have a meshed file in "medit" format that contains both triangular and tetrahedral meshes. I need to find a way to convert it to "igs" or "ascii" or "dxf" or similar formats.
I really appreciate if anyone has a code or a suggestion on how this can be done.
Thank you all, Cheers
Hi,
As the mesh unit in FastCap/FastHenry is rectangle, this might be quite tough. I dont know medit files, but maybe you should start with vector files, then converts these vectors to points, then segments.
Hope this helps.
Regards |
| v.b.t |
Posted - Apr 04 2011 : 03:25:02 Hi all,
I have a meshed file in "medit" format that contains both triangular and tetrahedral meshes. I need to find a way to convert it to "igs" or "ascii" or "dxf" or similar formats.
I really appreciate if anyone has a code or a suggestion on how this can be done.
Thank you all, Cheers
|
| daver |
Posted - Jul 20 2010 : 15:48:46 Eleon, Thanks for this code! Dave
dave |
| eleon |
Posted - Jul 09 2010 : 17:39:05 I find it is fairly easy to use GMSH with the MEDIT format option to create fastcap input files. When you examine an MEDIT file, "vertices" are the individual mesh points in x,y,z coordinates, "triangles" are the three vertices used in each mesh triangle. For simplicity, "tetrahedra" MEDIT mesh structures were not used.
A conversion (C/C++) program uses three arrays to re-format the MEDIT mesh file into fastcap generic file format.
// MEDIT CONVERSION - ARRAY FORMAT - MUST USE Bloodshed C/C++ Compiler!! // USE MODULO 4 VC and TI data file!! #define INPUT_FILE "top_mesh_largest.msh" // (GMSH MEDIT file) #define TITLE "top_mesh_largest.qui" // output file title .qui normally #define HEADER "0 top plate mesh largest" // 0 (Always), description #define COND_NO "3" // conductor designator #define NO_VERT 13732 // Number of Vertices #define NO_TRI 27092 // Number of Triangles #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> char header[]={HEADER}; char cond_no[]={COND_NO}; long n; long r; long j,k,t,p; double VC[3*NO_VERT]={0.0}; long TI[3*NO_TRI]={0}; double T[9*NO_TRI]={0.0}; main() { FILE *fp; char oneword[1000]; char eachword[1000]; long c; char ca; long i,l,s,vert,tri,r_m,s_m; fp = fopen(INPUT_FILE, "r"); // open test_modulo.dat for reading MEDIT file
vert = 0; // Clear "Vertices" Flag while (fgets(oneword,100,fp) != NULL) { // c = fgets(oneword,100,fp); // get one LINE from the file
if (c != NULL) { i = strcmp(oneword,"Vertices\n"); // Compare with "Vertices" j = strcmp(oneword,"Triangles\n"); // Compare with "Triangles", if (i==0) // Vertices Comparison Match { printf("%s","Vertices_Found\n"); // Confirm "Vertices" Match vert = 1; // Set "Vertices" Flag for Next Line Check } else { if (vert==1) // Next Line (# Vertices) Check { k = atoi(oneword); // convert numeric (# Vertices) string to integer printf("%d\n%",k); // print numeric conversion r = 1; r_m = 0; do { // READ EACH WORD after "Vertices" (See "Reading One Word at a Time") c = fscanf(fp,"%s",eachword); // if ( c != EOF) // Print EACH Vertice NODE AFTER "Vertices #" // printf("%s\n",eachword); // Load Vertices_coord with x,y,z array entries // VC[r-1] = atoi(eachword); if ((r%4) == 0) // skip modulo 4 entry r_m+=1; else VC[r-1-r_m] = atof(eachword); r++; } while (( c != EOF) && (r<=(4*k))); vert = 0; // Clear "Vertices" Flag } } if(j==0) // Triangles Comparison Match { printf("%s","Triangles_Found\n"); // Confirm "Vertices" Match tri = 1; // Set "Vertices" Flag for Next Line Check } else { if (tri==1) // Next Line (# Vertices) Check { l = atoi(oneword); // convert numeric (# Triangles) string to integer printf("%d\n%",l); // print numeric conversion s = 1; s_m = 0; do { // READ EACH WORD after "Triangles" (See "Reading One Word at a Time") c = fscanf(fp,"%s",eachword); // if ( c != EOF) // Print EACH Triangle NODE AFTER "Triangles #" // printf("%s\n",eachword); // TI[s-1] = atoi(eachword); if ((s%4) == 0) // skip modulo 4 entry s_m+=1; else TI[s-1-s_m] = atoi(eachword); s++; } while (( c != EOF) && (s<=(4*l))); tri = 0; // Clear "Triangles" Flag } } } } // while (c != NULL); // repeat until NULL fclose(fp); /* close the file */
// for ( ; ; ); //stall
for (j=0;j<=(NO_VERT-1);j++) { printf("V\t"); // for (i=0;i<=2;i++) printf("%3.9f\t",VC[i+j*3]); // vertices x,y,z printf("\n");
}
// for ( ; ; ); // stall
for (j=0;j<=(NO_TRI-1);j++) { printf("T\t"); // for (i=0;i<=2;i++) printf("%d\t",TI[i+j*3]); // triangles printf("\n"); }
// for ( ; ; ); // stall n=0; r=0; p=0; for (j=1;j<=NO_TRI;j++) { // # triangles for (t=1;t<=3;t++) { // one triangle for (k=1;k<=3;k++) { T[p]= VC[n+((TI[r]-1))*3]; n+=1; p+=1; } n=0; r+=1; }
} // Print Out Vertices Array // for (n=0;n<=(3*NO_VERT*NO_TRI-1);n++) // printf("%2.8f\n",T[n]); // for ( ; ; ); // stall fp=fopen(TITLE, "w"); // open file for writing fprintf(fp,"%s\n",header); // print header message for (j=0;j<=(NO_TRI-1);j++) { fprintf(fp,"T\t"); // preface each line with "T" == triangle fprintf(fp,"%s\t",cond_no); // insert conductor number for (i=0;i<=8;i++) fprintf(fp,"%3.9f\t",T[i+j*9]); // data (3 * x,y,z coordinates) fprintf(fp,"\n"); }
fclose(fp); // close file
for ( ; ; ); } |
|
|