dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #16729
[Question #92245]: Gradients and SubFunctions
Question #92245 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/92245
Description changed to:
I am using gradients in my calculations. So far this hasn't posed a
problem. I've been able to do most of my manipulation using c++ arrays.
I calculated my gradients using a form file and the resulting Function
has 2, (probably 3 but I'm working in 2d) SubFunctions: Gradient[0] is
the X values, Gradient[1] is the Y, (and Gradient[2] is the Z?). I
extract the data by doing:
Function GradX;
GradX = Gradients[0];
GradX.vector().get(gradX);
where gradX is the c++ array. I have to do this because
Gradients[0].vector().get() doesn't seem to work. Anyways, so far it
hasn't been a problem. But now I need to do:
GradX.vector().set(gradX);
Gradients[0] = GradX;
That didn't work, so now I'm trying it like this:
dolfin::Function GradAvg;
GradAvgX = &GradAvg[0];
GradAvgY = &GradAvg[1];
GradAvgX and Y are function pointers defined previously. And now my
problem becomes defining a Function with 2 SubFunctions. I think this
will work I can figure out how to define the Function, which I have no
idea how to do. Since the programmers refernce is off the site, I can't
look there. So this is probably a really simple and kinda stupid
question. Sorry about that.
The second part of my question involves FunctionSapces. The only thing I am using GradAvg for is defining Neumann BCs. As I understand it, I need to define the same number of points for my Function as there are in the domain that was used to create the FunctionSpace. For example, if "mesh" has 100 nodes, if I need to define 100 values, regardless of if the subdomain I am using this Function in only has 8 nodes. All the values that I don't care about should be set to zero, or i guess it doesn't really matter, since they won't be used. At least, that's the way I've been doing when the numbering system doesn't match up with my boundary. Because when nodes 0 through 7 will be assigned the first 8 values, and if those nodes aren't on your boundary, they won't be used.
But since it's now possible to define a Function without including a FunctionSpace, how will dolfin figure it out? I have a subdomain for my neumann BC. Do I just need to define values for every point in my subdomain? or will the Function automaticly try to find a FunctionSpace to be associated with? And if it does, will I then need to define a value for every point in my domain, instead of just on my boundary subdomain? And if it automaticly finds a FunctionSpace, will there be problems if I use the same Function in two different classes with different FunctionSpaces?
I appologise again if this is a really stupid question. If so, if you
could just direct me to where i can find the information, that would be
awesome.
Thank you very much for all your help,
Phil
--
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.