Question #111370 on DOLFIN changed: https://answers.launchpad.net/dolfin/+question/111370
Status: Open => Answered Patrick Riesen proposed the following answer: jhame...@illinois.edu wrote: > New question #111370 on DOLFIN: > https://answers.launchpad.net/dolfin/+question/111370 > > Hello, > > Is there a nice way to initialize a mixed element function with two of its > sub-functions. Specifically, > > element = FiniteElement("Lagrange", tetrahedron, 1) > vecElement = element + element > u = Coefficient(vecElement) > > Now, in the code, I want to do this: > > u[0] = func1 > u[1] = func2 you can extract the sub-dofmaps of u corresponding to u[0] and u[1] and then in a cell iteration loop place the values of func1 and func2 into u[0] and u[1] using subdofmap.tabulate_dofs() and func1.vector().get() / u.vector().set() i guess ... patrick > > where func1 and func2 are functions of "element". I want to do this to > initialize u in a newton solver. The above code doesnt copy the values to u's > sub-functions. Another way of framing my question could be, given two > subfunctions, how do I combine them into a mixed-function? > > I can think of some workarounds, e.g. initializing the function "u" as a > vector function using an Expression class, but thats not as clean a solution > as I would like. I would like to initialize u, given two input functions > which are scalar. > > Thanks, > -Jehanzeb > -- You received this question notification because you are a member of DOLFIN Team, which is an answer contact for DOLFIN. _______________________________________________ Mailing list: https://launchpad.net/~dolfin Post to : dolfin@lists.launchpad.net Unsubscribe : https://launchpad.net/~dolfin More help : https://help.launchpad.net/ListHelp