Hi,
I have finally started to work on term refactoring, see [1] (branch new_terms). So far, I have only the diffusion term (scalar unknowns), but it seems promising, as the term implementation is now just:
class NewDiffusionTerm(NewTerm): name = 'dw_new_diffusion' arg_types = (('material', 'virtual', 'state'), ('material', 'parameter_1', 'parameter_2')) modes = ('weak', 'eval')
def __call__(self, mat, virtual, state, **kwargs):
val = dot(virtual.grad(), dot(mat, state.grad()), 'ATB')
return val
- it would be quite easy (IMHO) to add new terms even for "ordinary" users, if things go well.
I am attaching a test script to try the new term - it is currently very slow, pure Python implementation relying on numpy dot() function called in sfepy.linalg.dot_sequences(), so I would like to know how slow it is on your computers, when compared with the original C implementation of the diffusion term (just replace dw_new_diffusion with dw_diffusion in the test script) on various sfepy installations. Both versions should give the same result.
The script can be run as
./simple.py test_new_terms.py
If things work out even for terms with vector and other variables, there should be a big potential to get the speed back using Cython (big IMHO).
I plan to merge the branch soon to master, and the new terms will co-exist with the old ones for some time.
So, comments/help/advice welcome! r.
Update: two prototype terms with vector variables work now, so the approach seems viable after all - I was not sure until this started to work. It is still terribly slow though. Anyway, I will merge the code soon, as it can live peacefully sideways with the old-style terms.
Get it using (*) and see examples/miscellaneous/compare_scalar_terms.py, examples/miscellaneous/compare_vector_terms.py and sfepy/terms/terms_new.py if you want to get an idea.
Cheers, r.
(*) git clone https://github.com/rc/sfepy.git cd sfepy git co origin/new_terms git co -b new_terms make ./simple.py examples/miscellaneous/compare_scalar_terms.py ./simple.py examples/miscellaneous/compare_vector_terms.py
On 05/11/11 18:06, Robert Cimrman wrote:
Hi,
I have finally started to work on term refactoring, see [1] (branch new_terms). So far, I have only the diffusion term (scalar unknowns), but it seems promising, as the term implementation is now just:
class NewDiffusionTerm(NewTerm): name = 'dw_new_diffusion' arg_types = (('material', 'virtual', 'state'), ('material', 'parameter_1', 'parameter_2')) modes = ('weak', 'eval')
def __call__(self, mat, virtual, state, **kwargs):
val = dot(virtual.grad(), dot(mat, state.grad()), 'ATB')
return val
- it would be quite easy (IMHO) to add new terms even for "ordinary" users, if things go well.
I am attaching a test script to try the new term - it is currently very slow, pure Python implementation relying on numpy dot() function called in sfepy.linalg.dot_sequences(), so I would like to know how slow it is on your computers, when compared with the original C implementation of the diffusion term (just replace dw_new_diffusion with dw_diffusion in the test script) on various sfepy installations. Both versions should give the same result.
The script can be run as
./simple.py test_new_terms.py
If things work out even for terms with vector and other variables, there should be a big potential to get the speed back using Cython (big IMHO).
I plan to merge the branch soon to master, and the new terms will co-exist with the old ones for some time.
So, comments/help/advice welcome! r.
participants (1)
-
Robert Cimrman