
I'm updating the Primer tut: https://github.com/sfepy/sfepy/wiki/Primer
This is the first of probably many questions:
I'm stuck on the last line in the tut as shown. Previously I was able to save the force vector f, as in pb.save_state(file,f) now it fails. f is no longer a State variable?
-- Andre

On 12/10/10 17:00, Andre Smit wrote:
I'm updating the Primer tut: https://github.com/sfepy/sfepy/wiki/Primer
This is the first of probably many questions:
I'm stuck on the last line in the tut as shown. Previously I was able to save the force vector f, as in pb.save_state(file,f) now it fails. f is no longer a State variable?
I have introduced recently the State class to hold both a bunch of variables and the related DOF coefficient vector, so that the DOF coefficient vector is consistent with the values of variables. Prior to this change, one could have had a state vector with some values and variables holding internally different values, which was quite error-prone.
So to save a vector of DOF values, that has the correct shape, as is your case, you can use (listing several possibilities):
# create a state and set its DOF vector to f. 1.
from sfepy.fem state import State
variables = pb.get_variables() state = State(variables, vec=f)
state = pb.create_state() state.set_full(f)
# save it 1.
pb.save_state(file, state)
out = state.create_output_dict()
pb.save_state(file, out=out)
Does this help?
r.

On 12/10/10 17:24, Robert Cimrman wrote:
On 12/10/10 17:00, Andre Smit wrote:
I'm updating the Primer tut: https://github.com/sfepy/sfepy/wiki/Primer
This is the first of probably many questions:
I'm stuck on the last line in the tut as shown. Previously I was able to save the force vector f, as in pb.save_state(file,f) now it fails. f is no longer a State variable?
I have introduced recently the State class to hold both a bunch of variables and the related DOF coefficient vector, so that the DOF coefficient vector is consistent with the values of variables. Prior to this change, one could have had a state vector with some values and variables holding internally different values, which was quite error-prone.
So to save a vector of DOF values, that has the correct shape, as is your case, you can use (listing several possibilities):
# create a state and set its DOF vector to f. 1.
from sfepy.fem state import State
variables = pb.get_variables() state = State(variables, vec=f)
state = pb.create_state() state.set_full(f)
# save it 1.
pb.save_state(file, state)
out = state.create_output_dict()
pb.save_state(file, out=out)
Does this help?
FYI: http://docs.sfepy.org/doc-devel/src/sfepy/fem/state.html
r.

Thanks I'll check it out. I noticed that vec.get_reduced() is failing:
In [87]: vec.get_reduced()
IndexError Traceback (most recent call last)
/home/grassy/sfepy/sfepy/interactive/__init__.pyc in <module>() ----> 1 2 3 4 5
/home/grassy/sfepy/sfepy/fem/state.pyc in get_reduced(self) 106 107 else: --> 108 r_vec = self.variables.strip_state_vector(self.vec) 109 110 return r_vec
/home/grassy/sfepy/sfepy/fem/variables.pyc in strip_state_vector(self, vec, follow_epbc) 361 svec[aindx] = vec[ii] 362 --> 363 if follow_epbc: 364 """ In [10]: a 365 Out[10]: array([0, 1, 2, 3, 4])
IndexError: index (55) out of range (0<=index<54) in dimension 0
Not sure if this is an error. Also what do you think about introducing a function in problemDef.py that removes boundary conditions as in:
pb.time_update(ebcs={},epbcs={},lcbcs={})
def rem_bcs(self): """ Remove boundary conditions
""" self.time_update(ebcs={},epbcs={},lcbcs={})
On Fri, Dec 10, 2010 at 10:28 AM, Robert Cimrman <cimr...@ntc.zcu.cz>wrote:
On 12/10/10 17:24, Robert Cimrman wrote:
On 12/10/10 17:00, Andre Smit wrote:
I'm updating the Primer tut: https://github.com/sfepy/sfepy/wiki/Primer
This is the first of probably many questions:
I'm stuck on the last line in the tut as shown. Previously I was able to save the force vector f, as in pb.save_state(file,f) now it fails. f is no longer a State variable?
I have introduced recently the State class to hold both a bunch of variables and the related DOF coefficient vector, so that the DOF coefficient vector is consistent with the values of variables. Prior to this change, one could have had a state vector with some values and variables holding internally different values, which was quite error-prone.
So to save a vector of DOF values, that has the correct shape, as is your case, you can use (listing several possibilities):
# create a state and set its DOF vector to f. 1.
from sfepy.fem state import State
variables = pb.get_variables() state = State(variables, vec=f)
state = pb.create_state() state.set_full(f)
# save it 1.
pb.save_state(file, state)
out = state.create_output_dict()
pb.save_state(file, out=out)
Does this help?
FYI: http://docs.sfepy.org/doc-devel/src/sfepy/fem/state.html
r.
-- 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

On 12/10/10 17:38, Andre Smit wrote:
Thanks I'll check it out. I noticed that vec.get_reduced() is failing:
In [87]: vec.get_reduced()
IndexError Traceback (most recent call last)
/home/grassy/sfepy/sfepy/interactive/__init__.pyc in<module>() ----> 1 2 3 4 5
/home/grassy/sfepy/sfepy/fem/state.pyc in get_reduced(self) 106 107 else: --> 108 r_vec = self.variables.strip_state_vector(self.vec) 109 110 return r_vec
/home/grassy/sfepy/sfepy/fem/variables.pyc in strip_state_vector(self, vec, follow_epbc) 361 svec[aindx] = vec[ii] 362 --> 363 if follow_epbc: 364 """ In [10]: a 365 Out[10]: array([0, 1, 2, 3, 4])
IndexError: index (55) out of range (0<=index<54) in dimension 0
I am not sure either - can you post a small script showing how you arrived to that state?
Not sure if this is an error. Also what do you think about introducing a function in problemDef.py that removes boundary conditions as in:
pb.time_update(ebcs={},epbcs={},lcbcs={})
def rem_bcs(self): """ Remove boundary conditions
"""
self.time_update(ebcs={},epbcs={},lcbcs={})
You mean making a convenience function that has a name suggesting what it really does? Why not. I would call it remove_bcs() though...
r.

Not sure why vec.get_reduced() was failing. I haven't been able to replicate
- please ignore.
What repo should I use for patches?
On Fri, Dec 10, 2010 at 10:46 AM, Robert Cimrman <cimr...@ntc.zcu.cz>wrote:
On 12/10/10 17:38, Andre Smit wrote:
Thanks I'll check it out. I noticed that vec.get_reduced() is failing:
In [87]: vec.get_reduced()
IndexError Traceback (most recent call last)
/home/grassy/sfepy/sfepy/interactive/__init__.pyc in<module>() ----> 1 2 3 4 5
/home/grassy/sfepy/sfepy/fem/state.pyc in get_reduced(self) 106 107 else: --> 108 r_vec = self.variables.strip_state_vector(self.vec) 109 110 return r_vec
/home/grassy/sfepy/sfepy/fem/variables.pyc in strip_state_vector(self, vec, follow_epbc) 361 svec[aindx] = vec[ii] 362 --> 363 if follow_epbc: 364 """ In [10]: a 365 Out[10]: array([0, 1, 2, 3, 4])
IndexError: index (55) out of range (0<=index<54) in dimension 0
I am not sure either - can you post a small script showing how you arrived to that state?
Not sure if this is an error. Also what do you think about introducing a
function in problemDef.py that removes boundary conditions as in:
pb.time_update(ebcs={},epbcs={},lcbcs={})
def rem_bcs(self): """ Remove boundary conditions
""" self.time_update(ebcs={},epbcs={},lcbcs={})
You mean making a convenience function that has a name suggesting what it really does? Why not. I would call it remove_bcs() though...
r.
-- 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

On 12/10/10 18:46, Andre Smit wrote:
Not sure why vec.get_reduced() was failing. I haven't been able to replicate
- please ignore.
Easy :)
What repo should I use for patches?
The best would be to follow [1], i.e. clone/update from the master repo, make a branch, make changes there, ask for code review, and I will merge it.
Or just send the patch here.
Thanks! r.
[1] http://docs.sfepy.org/doc-devel/dev/gitwash/git_development.html
On Fri, Dec 10, 2010 at 10:46 AM, Robert Cimrman<cimr...@ntc.zcu.cz>wrote:
On 12/10/10 17:38, Andre Smit wrote:
Thanks I'll check it out. I noticed that vec.get_reduced() is failing:
In [87]: vec.get_reduced()
IndexError Traceback (most recent call last)
/home/grassy/sfepy/sfepy/interactive/__init__.pyc in<module>() ----> 1 2 3 4 5
/home/grassy/sfepy/sfepy/fem/state.pyc in get_reduced(self) 106 107 else: --> 108 r_vec = self.variables.strip_state_vector(self.vec) 109 110 return r_vec
/home/grassy/sfepy/sfepy/fem/variables.pyc in strip_state_vector(self, vec, follow_epbc) 361 svec[aindx] = vec[ii] 362 --> 363 if follow_epbc: 364 """ In [10]: a 365 Out[10]: array([0, 1, 2, 3, 4])
IndexError: index (55) out of range (0<=index<54) in dimension 0
I am not sure either - can you post a small script showing how you arrived to that state?
Not sure if this is an error. Also what do you think about introducing a
function in problemDef.py that removes boundary conditions as in:
pb.time_update(ebcs={},epbcs={},lcbcs={})
def rem_bcs(self): """ Remove boundary conditions
"""
self.time_update(ebcs={},epbcs={},lcbcs={})
You mean making a convenience function that has a name suggesting what it really does? Why not. I would call it remove_bcs() though...
r.
-- 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.
participants (2)
-
Andre Smit
-
Robert Cimrman