← Back to team overview

dolfin team mailing list archive

Re: using grad() inside a C++ program

 

phil marinier wrote:
sry about the subject line.

I understand how to use grad() in my .ufl file that I then compile to
get a .h file. What I don't understand is how to use grad() inside my
actual code.

In .ufl file you describe forms, then it is compiled to .h, then in C++ you define VariationalProblem using forms from .h, and finally you have to solve it.

Fenics is all about linear forms. You need to understand this concept to use this software efficiently.


I am iterating my boundary condition depending on the gradient normal
to the surface. To do this, I need to be able to find the gradient
from inside my program. Maybe I'm just missing something, but the way
I understand it is that I cannot use grad() directly in my C++
program, only in my .ufl file, but if I were to use python, I would
be able to use grad() directly in my program. I am unable to test
this out due to unrelated problems with my compiler that I'm slowly
working through.

In python you have just simple interface to create forms, but it doesn't mean that you can directly calculate gradient without solving variational problem.

What I want to end up with is a C++ function that takes in a dolfin
Function and outputs a C++ vector of the gradients normal to the
boundary at each node.

I'm not sure how to describe your problem in UFL language. Definition of vector normal to the boundary at vertex will be troublesome.

cheers,
BArtek


Thanks for your help

Phil





Date: Wed, 8 Jul 2009 14:25:23 -0600 From: sawickib@xxxxxxxxxxxxx To: lonewolf_13p@xxxxxxxxxxx CC: dolfin-dev@xxxxxxxxxx Subject: Re:
[DOLFIN-dev] (no subject)

Phil, could you please give subject to your emails. Subject is very
 important part of a message, it help readers to classify it.

Python dolfin module is just an interface to the C++ library, so
every functionality available in python is in C++ too. Remember
that to use grad() in C++ you need to define UFL form.

cheers,




phil marinier wrote:
I need to find the gradient perpendicular to the boundary. I know
I can find the gradient in python using the grad(v) command, but
I don't think I can do the same in C++. Is it possible? and if it
is possible is it worth the trouble or would it be easier to
rewrite in python? Thanks for your help



------------------------------------------------------------------------



_______________________________________________ DOLFIN-dev
mailing list DOLFIN-dev@xxxxxxxxxx http://www.fenics.org/mailman/listinfo/dolfin-dev




Follow ups

References