← Back to team overview

syfi team mailing list archive

Re: Question about SyFi

 

>>> 2007/7/5, fhima@xxxxxxxxxxxxxxxxx <fhima@xxxxxxxxxxxxxxxxx>:
>>>> > 2007/7/5, fhima@xxxxxxxxxxxxxxxxx <fhima@xxxxxxxxxxxxxxxxx>:
>>>> >> > 2007/7/5, fhima@xxxxxxxxxxxxxxxxx <fhima@xxxxxxxxxxxxxxxxx>:
>>>> >> >> Hello Matrin,
>>>> >> >>
>>>> >> >> Can you say me please how i can
>>>> >> >>        *derivate fe.N(i) rwt x (first composant)
>>>> >> >>        *integrate on surface domaine
>>>> >> >>
>>>> >> >> Think you!
>>>> >> >
>>>> >> >
>>>> >> > diff( fe.N(i), x )
>>>> >> >
>>>> >> > ReferenceTetrahedron tet;
>>>> >> > Triangle polygon = tet.triangle(0);
>>>> >> > ex itg = polygon.integrate( fe.N(i) );
>>>> >> >
>>>> >> > There should be examples of this in the SyFi manual, and see also
>>>> the
>>>> >> > ginac manual for more about diff etc.
>>>> >> >
>>>> >> > Please send further questions to syfi-dev@xxxxxxxxxx
>>>> >> >
>>>> >>
>>>> >>
>>>> >> > --
>>>> >> > ---
>>>> >> > Martin Sandve Alnæs
>>>> >> > PhD student, Cardiac Computations
>>>> >> > Simula Research Laboratory, Norway
>>>> >> >
>>>> >>
>>>> >> Matrin,
>>>> >>
>>>> >> There are a problem because fe.N(i) is not an expression of x.
>>>> >> And i have not an expression of this fuction
>>>> >
>>>> > Try this code:
>>>> > ex x1 = symbol("x");
>>>> > ex x2 = symbol("x");
>>>> > ex f = x1-x2;
>>>> > cout << f;
>>>> >
>>>> > As you can see, a symbol in ginac is not identified by its name,
>>>> each
>>>> > object is a distinct symbol. You must use the global variables x, y,
>>>> z
>>>> > from SyFi, not create your own. Look up get_symbol in the manual.
>>>> >
>>>> > I strongly recommend going to www.ginac.de and reading the
>>>> > documentation, at least the basics.
>>>> >
>>>> > --
>>>> > ---
>>>> > Martin Sandve Alnæs
>>>> > PhD student, Cardiac Computations
>>>> > Simula Research Laboratory, Norway
>>>> >
>>>>
>>>> Matrin,
>>>>
>>>> I see the manull of ginac
>>>> my problem is that i want to diffenrentiate fe.N(i) but it is
>>>> impossible
>>>> because i have not the expression of fe.N(i)
>>>>
>>>> If you have am idea to the expression of fe.N(i) then it is good for
>>>> me
>>>>
>>>> Bye
>>>> Think you
>>>
>>>
>>> I don't understand your problem, fe.N(i) returns the expression you
>>> want. If you stil have problems you must show us the code you've tried
>>> to write.
>>>
>>> --
>>> ---
>>> Martin Sandve Alnæs
>>> PhD student, Cardiac Computations
>>> Simula Research Laboratory, Norway
>>> _______________________________________________
>>> SyFi-dev mailing list
>>> SyFi-dev@xxxxxxxxxx
>>> http://fenics.org/mailman/listinfo/syfi-dev
>>>
>>
>> Isn't this what you want:
>>
>>
>> #include <ginac/ginac.h>
>> #include <iostream>
>> #include <SyFi/SyFi.h>
>>
>> using namespace GiNaC;
>> using namespace SyFi;
>>
>> int main () {
>>
>>   initSyFi(3);
>>   ReferenceTetrahedron t;
>>   Lagrange fe(t,1);
>>
>>   for (int i=0; i<fe.nbf(); i++) {
>>     ex dN = diff(fe.N(i), x);
>>     std::cout << "dNi(0)/dx "<<dN<<std::endl;
>>     ex surface_integral =  t.triangle(0).integrate(fe.N(i));
>>     std::cout << "surface_integral "<<surface_integral<<std::endl;
>>   }
>> }
>>
>>
>> Kent
>>
>>
>>
>>
>>
>>
>>
>
>
> Hello Kent,
>
> Is this work:
>
> int main () {
>
>    initSyFi(3);
>    ReferenceTetrahedron t;
>    Lagrange fe(t,1);
>
>    for (int i=0; i<fe.nbf(); i++) {
>     ex dN = diff(fe.N(i), x);
>      std::cout << "dNi(0)/dx "<<dN<<std::endl;
>      ex surface_integral =  t.triangle(0).integrate(fe.N(i));
>      std::cout << "surface_integral "<<surface_integral<<std::endl;
>    }
>  }
>
>  implemented in C++ can be do with python. In deed in python we can not to
> obtaine the derivate fe.N(i) wrt x (first composant for example). This is
> my big problem in Python.
>

In Python you would do:


from swiginac import *
from SyFi import *

initSyFi(3)
x = cvar.x; y = cvar.y; z = cvar.z
t = ReferenceTetrahedron()
fe = Lagrange(t)
for i in range(0, fe.nbf()):
    dN = diff(fe.N(i), x)
    print "dN ", dN
    surface_integral = t.triangle(0).integrate(fe.N(i))
    print "surface_integral ", surface_integral




References