ok sorry about my last email, I got it adding \n between arguments, make it work! thanks a lot again for your help !!!
fipy is amazing!!!! Julien On Thu, Feb 3, 2011 at 3:21 PM, Julien Derr <[email protected]> wrote: > Hi James, > thanks a lot for your answer and the explanation about the triple ''' > > but I don't understand why there is only one vertex in this description. I > am using the ery same as in the example examples.diffusion.circle code . > isn'it ? > > Julien > > > > On Thu, Feb 3, 2011 at 2:45 PM, James O'Beirne <[email protected]>wrote: > >> On Thu, Feb 3, 2011 at 4:51 AM, Julien Derr <[email protected]>wrote: >> >>> >>> do you know what is the proper syntax ? >>> >> >> Hey, Julien. >> >> A multi-line string in Python is indicated by an opening and closing set >> of three quotes (either single- or double-quotes) [0]. For a good example of >> how to use a multi-line string to construct a GmshImporter from a Gmsh >> specification, see the examples.diffusion.circle code [1]. >> >> The problem with your above code, however, is that the Gmsh specification >> you provide only produces one vertex. FiPy can't make a cell from only one >> vertex, hence the error. I suggest using Gmsh's graphical user interface to >> check that your Gmsh code produces what you expect. >> >> Admittedly, the error you're getting is cryptic, so I'll add some code to >> make this situation clearer. >> >> Regards, >> James >> >> [0] http://docs.python.org/tutorial/introduction.html#strings >> [1] >> http://www.matforge.org/fipy/browser/tags/version-2_1_1/examples/diffusion/circle.py >> >> >>> >>> >>> Julien >>> >>> >>> >>> On Wed, Feb 2, 2011 at 7:32 PM, Jonath >>> an Guyer <guyer@nistgov <[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) >>>> >>>> >>>> >>>> >>> >> >
