With the code at [1] I was hoping to retrieve the number of elements from the mesh to use in the problem definition. I'm running into problems - seems mesh_hook isn't processed early enough to define NELS and although mesh_hook reads the mesh from file it fails with this error:
grassy@x sfepy]$ ~/sfepy/simple.py its.py sfepy: left over: ['disp', 'young', '__builtins__', 'youngpoisson_to_lame', 'mesh_file', 'poisson', '_filename', 'Eq', 'NELS', 'verbose', '__doc__', 'i', 'mesh_hook', '__package__', 'stiffness_tensor_youngpoisson', '__file__', '__name__'] sfepy: reading mesh (function:mesh_hook)... sfepy: reading mesh (/home/grassy/sfepy.wiki/msh/its2D.mesh)... sfepy: ...done in 0.01 s sfepy: ...done in 0.01 s Traceback (most recent call last): File "/home/grassy/sfepy/simple.py", line 120, in <module> main() File "/home/grassy/sfepy/simple.py", line 113, in main app = SimpleApp( conf, options, output_prefix ) File "/home/grassy/sfepy/sfepy/applications/simple_app.py", line 71, in __init__ **kwargs) File "/home/grassy/sfepy/sfepy/fem/problemDef.py", line 70, in from_conf mesh = Mesh.from_file(conf.filename_mesh, prefix_dir=conf_dir) File "/home/grassy/sfepy/sfepy/fem/mesh.py", line 323, in from_file mesh._set_shape_info() File "/home/grassy/sfepy/sfepy/fem/mesh.py", line 454, in _set_shape_info self.n_nod, self.dim = self.coors.shape AttributeError: 'Mesh' object has no attribute 'coors'
Any suggestions on a workaround?
thx
[1] http://paste.pocoo.org/show/305010/
-- Andre
hi Andre, if you want to access mesh data in the problem definition forget the mesh_hook and use:
from sfepy.fem.mesh import Mesh ... mesh = Mesh.from_file(mesh_file) NELS = mesh.n_el
regards, vladimir
On 12/15/2010 04:29 AM, Andre Smit wrote:
With the code at [1] I was hoping to retrieve the number of elements from the mesh to use in the problem definition. I'm running into problems - seems mesh_hook isn't processed early enough to define NELS and although mesh_hook reads the mesh from file it fails with this error:
grassy@x sfepy]$ ~/sfepy/simple.py its.py sfepy: left over: ['disp', 'young', '__builtins__', 'youngpoisson_to_lame', 'mesh_file', 'poisson', '_filename', 'Eq', 'NELS', 'verbose', '__doc__', 'i', 'mesh_hook', '__package__', 'stiffness_tensor_youngpoisson', '__file__', '__name__'] sfepy: reading mesh (function:mesh_hook)... sfepy: reading mesh (/home/grassy/sfepy.wiki/msh/its2D.mesh)... sfepy: ...done in 0.01 s sfepy: ...done in 0.01 s Traceback (most recent call last): File "/home/grassy/sfepy/simple.py", line 120, in <module> main() File "/home/grassy/sfepy/simple.py", line 113, in main app = SimpleApp( conf, options, output_prefix ) File "/home/grassy/sfepy/sfepy/applications/simple_app.py", line 71, in __init__ **kwargs) File "/home/grassy/sfepy/sfepy/fem/problemDef.py", line 70, in from_conf mesh = Mesh.from_file(conf.filename_mesh, prefix_dir=conf_dir) File "/home/grassy/sfepy/sfepy/fem/mesh.py", line 323, in from_file mesh._set_shape_info() File "/home/grassy/sfepy/sfepy/fem/mesh.py", line 454, in _set_shape_info self.n_nod, self.dim = self.coors.shape AttributeError: 'Mesh' object has no attribute 'coors'
Any suggestions on a workaround?
thx
[1] http://paste.pocoo.org/show/305010/
-- Andre
-- You received this message because you are subscribed to the Google Groups "sfepy-devel" group. To post to this group, send email to sfepy...@googlegroups.com. To unsubscribe from this group, send email to sfepy-devel...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sfepy-devel?hl=en.
Vladimir already replied your question, so let me just clarify the purpose of mesh_hook.
The mesh (filename_mesh keyword) can be given in three ways:
- by name of a file
- by a function - the mesh_hook - that takes an empty Mesh instance and creates its data, i.e. nodes and elements, see tests/test_meshio.py
- by a MeshIO subclass instance
So if you you a mesh_hook function, this function should populate an empty mesh
instance. The mesh
argument is an empty instance, that's why you got that
AttributeError.
To sum it up: use a mesh_hook only if you want to generate the mesh programmatically, without having any mesh file. For this, you could use e.g. functions in sfepy/fem/mesh_generators.py
r.
On 12/15/10 10:15, Vladimir Lukes wrote:
hi Andre, if you want to access mesh data in the problem definition forget the mesh_hook and use:
from sfepy.fem.mesh import Mesh ... mesh = Mesh.from_file(mesh_file) NELS = mesh.n_el
regards, vladimir
On 12/15/2010 04:29 AM, Andre Smit wrote:
With the code at [1] I was hoping to retrieve the number of elements from the mesh to use in the problem definition. I'm running into problems - seems mesh_hook isn't processed early enough to define NELS and although mesh_hook reads the mesh from file it fails with this error:
grassy@x sfepy]$ ~/sfepy/simple.py its.py sfepy: left over: ['disp', 'young', '__builtins__', 'youngpoisson_to_lame', 'mesh_file', 'poisson', '_filename', 'Eq', 'NELS', 'verbose', '__doc__', 'i', 'mesh_hook', '__package__', 'stiffness_tensor_youngpoisson', '__file__', '__name__'] sfepy: reading mesh (function:mesh_hook)... sfepy: reading mesh (/home/grassy/sfepy.wiki/msh/its2D.mesh)... sfepy: ...done in 0.01 s sfepy: ...done in 0.01 s Traceback (most recent call last): File "/home/grassy/sfepy/simple.py", line 120, in <module> main() File "/home/grassy/sfepy/simple.py", line 113, in main app = SimpleApp( conf, options, output_prefix ) File "/home/grassy/sfepy/sfepy/applications/simple_app.py", line 71, in __init__ **kwargs) File "/home/grassy/sfepy/sfepy/fem/problemDef.py", line 70, in from_conf mesh = Mesh.from_file(conf.filename_mesh, prefix_dir=conf_dir) File "/home/grassy/sfepy/sfepy/fem/mesh.py", line 323, in from_file mesh._set_shape_info() File "/home/grassy/sfepy/sfepy/fem/mesh.py", line 454, in _set_shape_info self.n_nod, self.dim = self.coors.shape AttributeError: 'Mesh' object has no attribute 'coors'
Any suggestions on a workaround?
thx
Thanks guys!
On Wed, Dec 15, 2010 at 4:12 AM, Robert Cimrman <cimr...@ntc.zcu.cz> wrote:
Vladimir already replied your question, so let me just clarify the purpose of mesh_hook.
The mesh (filename_mesh keyword) can be given in three ways:
- by name of a file
- by a function - the mesh_hook - that takes an empty Mesh instance and creates its data, i.e. nodes and elements, see tests/test_meshio.py
- by a MeshIO subclass instance
So if you you a mesh_hook function, this function should populate an empty mesh instance. The
mesh
argument is an empty instance, that's why you got that AttributeError.To sum it up: use a mesh_hook only if you want to generate the mesh programmatically, without having any mesh file. For this, you could use e.g. functions in sfepy/fem/mesh_generators.py
r.
On 12/15/10 10:15, Vladimir Lukes wrote:
hi Andre, if you want to access mesh data in the problem definition forget the mesh_hook and use:
from sfepy.fem.mesh import Mesh ... mesh = Mesh.from_file(mesh_file) NELS = mesh.n_el
regards, vladimir
On 12/15/2010 04:29 AM, Andre Smit wrote:
With the code at [1] I was hoping to retrieve the number of elements from the mesh to use in the problem definition. I'm running into problems - seems mesh_hook isn't processed early enough to define NELS and although mesh_hook reads the mesh from file it fails with this error:
grassy@x sfepy]$ ~/sfepy/simple.py its.py sfepy: left over: ['disp', 'young', '__builtins__', 'youngpoisson_to_lame', 'mesh_file', 'poisson', '_filename', 'Eq', 'NELS', 'verbose', '__doc__', 'i', 'mesh_hook', '__package__', 'stiffness_tensor_youngpoisson', '__file__', '__name__'] sfepy: reading mesh (function:mesh_hook)... sfepy: reading mesh (/home/grassy/sfepy.wiki/msh/its2D.mesh)... sfepy: ...done in 0.01 s sfepy: ...done in 0.01 s Traceback (most recent call last): File "/home/grassy/sfepy/simple.py", line 120, in <module> main() File "/home/grassy/sfepy/simple.py", line 113, in main app = SimpleApp( conf, options, output_prefix ) File "/home/grassy/sfepy/sfepy/applications/simple_app.py", line 71, in __init__ **kwargs) File "/home/grassy/sfepy/sfepy/fem/problemDef.py", line 70, in from_conf mesh = Mesh.from_file(conf.filename_mesh, prefix_dir=conf_dir) File "/home/grassy/sfepy/sfepy/fem/mesh.py", line 323, in from_file mesh._set_shape_info() File "/home/grassy/sfepy/sfepy/fem/mesh.py", line 454, in _set_shape_info self.n_nod, self.dim = self.coors.shape AttributeError: 'Mesh' object has no attribute 'coors'
Any suggestions on a workaround?
thx
-- You received this message because you are subscribed to the Google Groups "sfepy-devel" group. To post to this group, send email to sfepy...@googlegroups.com. To unsubscribe from this group, send email to sfepy-devel...@googlegroups.com<sfepy-devel%...@googlegroups.com> . For more options, visit this group at http://groups.google.com/group/sfepy-devel?hl=en.
-- Andre
participants (3)
-
Andre Smit
-
Robert Cimrman
-
Vladimir Lukes