Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gmsh2D does not respect background mesh #326

Closed
guyer opened this issue Sep 19, 2014 · 8 comments
Closed

Gmsh2D does not respect background mesh #326

guyer opened this issue Sep 19, 2014 · 8 comments
Labels

Comments

@guyer
Copy link
Member

guyer commented Sep 19, 2014

>>> from fipy import *
>>> geo = *
... // A mesh consisting of a square
...                        
... // define the basic dimensions of the mesh
...                        
... cellSize = 1;
... side = 1;
...                        
... // define the corners of the square
... 
... Point(1) = {side/2, side/2, 0, cellSize};
... Point(2) = {-side/2, side/2, 0, cellSize};
... Point(3) = {-side/2, -side/2, 0, cellSize};
... Point(4) = {side/2, -side/2, 0, cellSize};
... 
... // define the square
... 
... Line(1) = {1, 2};
... Line(2) = {2, 3};
... Line(3) = {3, 4};
... Line(4) = {4, 1};
... 
... // define the boundary
... 
... Line Loop(1) = {1, 2, 3, 4};
... 
... // define the domain
... 
... Plane Surface(1) = {1};
... *
>>> square = Gmsh2D(geo)
>>> x, y = square.cellCenters
>>> var = CellVariable(mesh=square, value=abs(x) + 0.1)
>>> vw = Viewer(vars=var)

>>> square2 = Gmsh2D(geo, background=var)
>>> x2, y2 = square2.cellCenters
>>> var2 = CellVariable(mesh=square2, value=abs(x2) + 0.1)
>>> vw2 = Viewer(vars=var2)

The same mesh is generated in both cases.

This turns out to be a problem with the writing of the POSFile for the background

>>> f = openPOSFile("test.pos", "w")
>>> f.write(var)
>>> f.close()
>>> f = open("test.pos", "r")
>>> print "".join(f.readlines())
$PostFormat
1.4 0 8
$EndPostFormat
$View
 1
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0 0
0
$EndView
>>> f.close()

There are a couple of problems with this.

It turns out that some other 2D meshes don't even get this far

>>> trisquare = Tri2D(nx=1, ny=1) + [[-0.5], [-0.5]]
>>> x3, y3 = trisquare.cellCenters
>>> var3 = CellVariable(mesh=trisquare, value=abs(x3) + 0.1)
>>> square3 = Gmsh2D(geo, background=var3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "fipy/meshes/gmshImport.py", line 1559, in __init__
background=background)
  File "fipy/meshes/gmshImport.py", line 209, in openMSHFile
f.write(background)
  File "fipy/meshes/gmshImport.py", line 342, in write
self._writeValues(var=obj, dimensions=dimensions, time=time, timeindex=timeindex)
  File "fipy/meshes/gmshImport.py", line 438, in _writeValues
value=value[..., i])
  File "fipy/meshes/gmshImport.py", line 549, in _writeNodesAndValues
nodes = nodes[!= -1](nodes)
IndexError: invalid index to scalar variable.

This turns out to be due to nodes[~nodes.mask] in [trunk/fipy/meshes/gmshImport.py@5233#L352 POSFile._writeValue()]

Imported from trac ticket #448, created by guyer on 06-29-2012 at 09:02, last modified: 09-30-2013 at 21:44

@guyer
Copy link
Member Author

guyer commented Sep 19, 2014

In the course of diagnosing and fixing this, I found that

  • there's really no documentation of background
  • the GmshGrid2D class takes a background= argument, but it doesn't make any sense since Gmsh ignores the background for extruded meshes

Trac comment by guyer on 06-29-2012 at 14:41

@guyer
Copy link
Member Author

guyer commented Sep 19, 2014

Fixed with r5253

Trac comment by guyer on 06-29-2012 at 16:22

@fipymigrate
Copy link

In 557e653:

#CommitTicketReference repository="fipy" revision="557e6538b5587eb08404d2a148be9fd7872fea7a"
tests re issue #326


git-svn-id: svn+ssh://code.matforge.org/fipy/branches/ticket448@5249 d80e17d7-ff13-0410-a124-85740d801063

Trac comment by Jonathan E. Guyer guyer@nist.gov on 06-12-2013 at 14:14

@fipymigrate
Copy link

In 1acb86c:

#CommitTicketReference repository="fipy" revision="1acb86c106afdcb53d1697048ee7e04db24fa37d"
Addresses issue #326
 * Introduce 2D cell topologies
 * Introduce default `view-name` for `POSFile`
 * More robust extraction of unmasked values


git-svn-id: svn+ssh://code.matforge.org/fipy/branches/ticket448@5250 d80e17d7-ff13-0410-a124-85740d801063

Trac comment by Jonathan E. Guyer guyer@nist.gov on 06-12-2013 at 14:14

@fipymigrate
Copy link

In 9b616ba:

#CommitTicketReference repository="fipy" revision="9b616bacf2b03b8f363dd6ef6d1f9bcc0189c998"
Remove `background=` argument from `GmshGrid2D`. Addresses issue #326.


git-svn-id: svn+ssh://code.matforge.org/fipy/branches/ticket448@5251 d80e17d7-ff13-0410-a124-85740d801063

Trac comment by Jonathan E. Guyer guyer@nist.gov on 06-12-2013 at 14:14

@fipymigrate
Copy link

In 2861b2a:

#CommitTicketReference repository="fipy" revision="2861b2a520d70673a54b58c9ec3f3a4b51c6dd59"
Documentation for `background=`. Addresses issue #326.


git-svn-id: svn+ssh://code.matforge.org/fipy/branches/ticket448@5252 d80e17d7-ff13-0410-a124-85740d801063

Trac comment by Jonathan E. Guyer guyer@nist.gov on 06-12-2013 at 14:14

@fipymigrate
Copy link

In 56ebe4d:

#CommitTicketReference repository="fipy" revision="56ebe4d0977babc6918fc50f44213859795ca1e8"
merged [ticket448](../tree/ticket448)@5252 to [trunk](../tree/master/trunk)@5252. Fixes issue #326.

git-svn-id: svn+ssh://code.matforge.org/fipy/trunk@5253 d80e17d7-ff13-0410-a124-85740d801063

Trac comment by Jonathan E. Guyer guyer@nist.gov on 06-12-2013 at 14:14

@guyer
Copy link
Member Author

guyer commented Sep 19, 2014

Marking milestone

Trac comment by guyer on 09-30-2013 at 21:44

@guyer guyer closed this as completed Sep 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants