Thnak you so much for your quick reply.

I understand your answer, but I am still confused how many ' or " I should
put for the proper syntax.

cmd=" ''' Point(1) = {0, 0, 0, 0.05};    Point(2) = {-1, 0, 0, 0.05};
Point(3) = {0, 1, 0, 0.05};    Point(4) = {1, 0, 0, 0.05};    Point(5) = {0,
-1, 0, 0.05};    Circle(6) = {2, 1, 3};    Circle(7) = {3, 1, 4};
Circle(8) = {4, 1, 5};    Circle(9) = {5, 1, 2};    Line Loop(10) = {6, 7,
8, 9};    Plane Surface(11) = {10}; ''' "

mesh = GmshImporter2D(cmd)

doesn t seem to work


and
cmd= ''' Point(1) = {0, 0, 0, 0.05};    Point(2) = {-1, 0, 0, 0.05};
Point(3) = {0, 1, 0, 0.05};    Point(4) = {1, 0, 0, 0.05};    Point(5) = {0,
-1, 0, 0.05};    Circle(6) = {2, 1, 3};    Circle(7) = {3, 1, 4};
Circle(8) = {4, 1, 5};    Circle(9) = {5, 1, 2};    Line Loop(10) = {6, 7,
8, 9};    Plane Surface(11) = {10}; '''

mesh = GmshImporter2D(cmd)


neither
I tried many different combinations , only two '

do you know  what is the proper syntax ?


Julien


On Wed, Feb 2, 2011 at 7:32 PM, Jonath
an Guyer <[email protected]> wrote:

>
>
> On Feb 2, 2011, at 1:00 PM, Daniel Wheeler wrote:
>
> >
> > Hi Julien, I believe it is set up to work in this manner. What's the
> > error exactly?
>
> The problem is that Julien is quoting too much.
>
> This is Python code:
>
> '''cellSize = %(cellSize)g; radius = %(radius)g; rbis =
> %(rbis)g; Point(1) = {0, 0, 0, cellSize}; Point(2) = {-radius, 0, 0,
> cellSize}; Point(3) = {0, radius, 0, cellSize};Point(4) = {radius, 0, 0,
> cellSize}; Point(5) = {0, -radius, 0, cellSize}; Circle(6) = {2, 1, 3};
> Circle(7) = {3, 1, 4};Circle(8) = {4, 1, 5}; Circle(9) = {5, 1, 2}; Line
> Loop(10) = {6, 7, 8, 9};Plane Surface(12) = {10}; ''' % locals()
>
> so your current definition of cmdbase results in passing Python code to
> Gmsh, which it doesn't understand.
>
> This part is the Gmsh code:
>
> cellSize = %(cellSize)g; radius = %(radius)g; rbis =
> %(rbis)g; Point(1) = {0, 0, 0, cellSize}; Point(2) = {-radius, 0, 0,
> cellSize}; Point(3) = {0, radius, 0, cellSize};Point(4) = {radius, 0, 0,
> cellSize}; Point(5) = {0, -radius, 0, cellSize}; Circle(6) = {2, 1, 3};
> Circle(7) = {3, 1, 4};Circle(8) = {4, 1, 5}; Circle(9) = {5, 1, 2}; Line
> Loop(10) = {6, 7, 8, 9};Plane Surface(12) = {10};
>
> except that it is taking the values of cellSize, radius, and rbis from your
> Python script, by substituting the corresponding local variables (" %
> locals()").
>
>
> So, if you wish, you can do something like
>
> cmdbase = '''cellSize = %(cellSize)g; radius = %(radius)g; rbis =
> %(rbis)g; Point(1) = {0, 0, 0, cellSize}; Point(2) = {-radius, 0, 0,
> cellSize}; Point(3) = {0, radius, 0, cellSize};Point(4) = {radius, 0, 0,
> cellSize}; Point(5) = {0, -radius, 0, cellSize}; Circle(6) = {2, 1, 3};
> Circle(7) = {3, 1, 4};Circle(8) = {4, 1, 5}; Circle(9) = {5, 1, 2}; Line
> Loop(10) = {6, 7, 8, 9};Plane Surface(12) = {10};'''
>
> mesh = GmshImporter2D(cmdbase % locals())
>
> or you can skip the substitution altogether ["%(cellSize)g", "%(radius)g",
> and so on] and just build cmdbase to contain whatever Gmsh script you want
> and then you would just write:
>
> mesh = GmshImporter2D(cmdbase)
>
>
>
>

Reply via email to