[Gmsh] RE Create .geo file using C++..??

jean pierre aubry jeanpierre at lamachine.fr
Tue Oct 25 15:26:34 CEST 2011


Hi, Rakesh!

>>Is there a way to generate .geo file pro grammatically..?? i.e. using
>>C++.??

Maybe, I don't really understand your question... but what is the
problem?

int main()
{
  std::ofstream geo("test.geo");
  geo << "Point(1) = {0, 0, 0};\n";
  // and so on
  geo.close();
  return 0;
}

Cheers
Mikhail Artemiev

hello

writing a script in Gmsh language is a very close sibbling to writing
a C program
below is an abstract
with the resulting mesh in pic, once calculated in Code_aster and Post
processed with Gmsh

jean pierre aubry

Function splitLine
pi1[]=Point{i1};
pi2[]=Point{i2};
lx=pi2[0]-pi1[0];
// If (lx==0)
// 	lx=0.00001;
// EndIf
ly=pi2[1]-pi1[1];
lz=pi2[2]-pi1[2];
Point(i1+10+fact) =
{pi1[0]+ksplit*lx,pi1[1]+ksplit*ly,pi1[2]+ksplit*lz, el1};
Point(i1+20+fact) =
{pi1[0]+(1-ksplit)*lx,pi1[1]+(1-ksplit)*ly,pi1[2]+(1-ksplit)*lz, el1};
Line(nl1+10) = {i1, i1+10+fact}; Line(nl1)={i1+10+fact, i1+20+fact};
Line(nl1+20) = {i1+20+fact, i2}; a[]=(nl1+10);
barends[]+=a[];
a[]=(nl1+20);
barends[]+=a[];
// a[]=(i1);
// epi[]+=a[];
// a[]=(i2);
// epi[]+=a[];
Return


Point(100000)={0, 0, 0, el1};
Point(123101)={0, 0, ro, el1};
a[]=(123101);
epi[]+=a[];


//k numero du secteur
k=1;
//n numero du row + 10
n=22;
//i numero du point + 100

For k In {1:5}
  ak=(k-1)*2*Pi/5;
  cak=Cos((k-1)*2*Pi/5);
  sak=Sin((k-1)*2*Pi/5);
  n=22;
//  b=Pi/2-Pi/2/12;
  b=Pi/2-bA;
  cb=Cos(b);
  sb=Sin(b);
  sub=1;
  For i In {1:sub+1}
	a=-Pi/5+(i-1)*2*Pi/5/sub;
	ca=Cos(a);
	sa=Sin(a);
	xo=ro*cb*ca;
	yo=ro*cb*sa;
	zo=ro*sb;
	xi=ri*cb*ca;
	yi=ri*cb*sa;
	zi=ri*sb;
	Point(100000*k+1000*n+100+i)={xo*cak-yo*sak, xo*sak+yo*cak, zo,
el1}; // 	Point(100000*k+1000*n+200+i)={xi*cak-yi*sak,
xi*sak+yi*cak, zi, el1}; //
Line(100000*k+1000*n+200+i)={100000*k+1000*n+100+i,
100000*k+1000*n+200+i}; a[]=(100000*k+1000*n+100+i); epi[]+=a[];
  EndFor
  For i In {1:sub}
//	Line(100000*k+1000*n+100+i)={100000*k+1000*n+100+i,
100000*k+1000*n+100+i+1}; i1=100000*k+1000*n+100+i;
	i2=100000*k+1000*n+100+i+1;
	fact=0;
	nl1=100000*k+1000*n+100+i;
	Call splitLine;
	a[]=(100000*k+1000*n+100+i);
	bar12[]+=a[];
  EndFor
  i=1;
//  Line(100000*k+1000*n+300+i)={100000*k+1000*n+100+i, 123101};
  i1=100000*k+1000*n+100+i;
  i2=123101;
  nl1=100000*k+1000*n+300+i;
  fact=20;
  Call splitLine;
  a[]=(100000*k+1000*n+300+i);
  bar12[]+=a[];
  a[]=(100000*k+1000*n+100+1);
  accro1[]+=a[];
  a[]=(100000*k+1000*n+100+sub+1);
  accro1[]+=a[];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dome1.png
Type: image/png
Size: 123826 bytes
Desc: not available
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20111025/27223b5a/attachment.png>