Subject: Re: [Syfi-dev] Question about SyFi

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Fri, 6 Jul 2007 09:53:11 +0200

2007/7/5, [email-masked] <[email-masked]>:
> > 2007/7/5, [email-masked] <[email-masked]>:
> >> > 2007/7/5, [email-masked] <[email-masked]>:
> >> >> 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 [email-masked]
> >> >
> >>
> >>
> >> > --
> >> > ---
> >> > 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

---

From: [email-masked]
Date: Fri, 6 Jul 2007 10:05:39 +0200 (CEST)

> _______________________________________________
> SyFi-dev mailing list
> [email-masked]
> 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

---

From: [email-masked]
Date: Fri, 6 Jul 2007 11:48:14 +0200 (CEST)

> Hello Kent,
> Is this work:
>  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