← Back to team overview

dolfin team mailing list archive

subfunctions

 

My aim is to use subfunctions in order to have a vector-valued function to be saved to a file, while being able to manipulate and use its single components using vector().  I have defined the following (mostly dummy, just to extract its space) Embedding.form file:

  element = VectorElement("Lagrange", "triangle", 1, 3)
  v = TestFunction(element) 
  u = TrialFunction(element) 
  f = Function(element)
  a = dot(u,v)*dx 
  L = dot(f,v)*dx

and then I wrote the following code inside main.cpp (where Poisson is the usual Poisson form in the demo):

  // Create spaces
  EmbeddingFunctionSpace R3(mesh);
  PoissonFunctionSpace C0(mesh);

  // Create embedding
  Function xyz(R3);
  Function x(C0),y(C0),z(C0);
  x = xyz[0];
  y = xyz[1];
  z = xyz[2];

but I get the following error message from y = xyz[1]:

terminate called after throwing an instance of 'std::runtime_error'
  what():  *** Error: Unable to extract sub function, missing coefficients (user-defined function).
[pc194:00801] *** Process received signal ***
[pc194:00801] Signal: Abort trap (6)
[pc194:00801] Signal code:  (0)
[ 1] (ATLU_DestroyThreadMemory + 0x2380962) [0xbfffef28, 0x924f4e32] 
[ 2] (ATLU_DestroyThreadMemory + 0x23f2dd6) [0xbfffef48, 0x925672a6] 
[ 3] (ATLU_DestroyThreadMemory + 0x23ff1f5) [0xbfffef78, 0x925736c5] 
[ 4] (_ZN9__gnu_cxx27__verbose_terminate_handlerEv + 0x1bd) [0xbfffefc8, 0x9004c005] 
[ 5] (__gxx_personality_v0 + 0x454) [0xbfffefe8, 0x9004a10c] 
[ 6] (_ZSt9terminatev + 0x1d) [0xbffff008, 0x9004a14b] 
[ 7] (__cxa_throw + 0x65) [0xbffff028, 0x9004a261] 
[ 8] (_ZNK6dolfin6Logger5errorESs + 0xa5) [0xbffff078, 0x005052f5] 
[ 9] (_ZN6dolfin5errorESsz + 0x66) [0xbffff0b8, 0x00504c26] 
[10] (_ZN6dolfin8FunctionixEj + 0x91) [0xbffff108, 0x004af2b1] 
[11] (main + 0x1ba) [0xbffff648, 0x00002e7a] 
[12] (start + 0x36) [0xbffff664, 0x00002856] 
[13] [0x00000000, 0x00000001] (FP-)
[pc194:00801] *** End of error message ***
Abort trap

am I using something in the wrong way?

Thank you,
Alessio