This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

No Coefficients in generated Header

+1 vote

Hi,

I just tried to solve coupled equations and set up my UFL-File like this:

cell = tetrahedron

scalar = FiniteElement("DG", cell, 1)

scalarMixed = scalar * scalar

sigmaLiquid, sigmaSolid = Coefficient(scalarMixed)
u = TrialFunction(scalarMixed)
vLiquid,vSolid = TestFunction(scalarMixed)
fLiquid, fSolid = Coefficient(scalarMixed)

uLiquid, uSolid = split(u)


aLiquid = (-sigmaLiquid*inner(grad(uLiquid), grad(vLiquid))-uLiquid*inner(grad(sigmaLiquid), grad(vLiquid)))*(dx(2)+dx(3)+dx(5))
aSolid = (-sigmaSolid*inner(grad(uSolid), grad(vSolid))-uSolid*inner(grad(sigmaSolid), grad(vSolid)))*(dx(1)+dx(2)+dx(3)+dx(4))

a = aLiquid+aSolid
L = fSolid*vSolid*(dx(2)+dx(3))+ fLiquid*vLiquid*(dx(2)+dx(3))

If I try to generate a CPP-Header with ffc -l dolfin myFile.ufl the forms in the generated header have no coefficients for sigmaLiquid, sigmaSolid, fLiquid and fSolid but if I compile it in two seperate UFL Files (one for Liquid and one for Solid) it just compiles right (except that I can't combine them to a system of coupled equations).

Does anybody know what to do to get this working?

Thanks a lot.

Justus

asked Dec 22, 2016 by Pama328 FEniCS Novice (480 points)

1 Answer

+1 vote
 
Best answer

Using a mixed space, you have to split coefficients. I don't have your C++ code to test, but consider:

cell = tetrahedron

scalar = FiniteElement("DG", cell, 1)

scalarMixed = scalar * scalar

sigma = Coefficient(scalarMixed)
u = TrialFunction(scalarMixed)
v = TestFunction(scalarMixed)
f = Coefficient(scalarMixed)

sigmaLiquid, sigmaSolid = split(sigma)
uLiquid, uSolid = split(u)
vLiquid, vSolid = split(v)
fLiquid, fSolid = split(f)

aLiquid = (-sigmaLiquid*inner(grad(uLiquid), grad(vLiquid))-uLiquid*inner(grad(sigmaLiquid), grad(vLiquid)))*(dx(2)+dx(3)+dx(5))
aSolid = (-sigmaSolid*inner(grad(uSolid), grad(vSolid))-uSolid*inner(grad(sigmaSolid), grad(vSolid)))*(dx(1)+dx(2)+dx(3)+dx(4))

a = aLiquid+aSolid
L = fSolid*vSolid*(dx(2)+dx(3))+ fLiquid*vLiquid*(dx(2)+dx(3))

On a side note, if you intend to use a DG space, you should be aware that your variational formulation is incomplete.

answered Dec 22, 2016 by nate FEniCS Expert (17,050 points)
selected Dec 22, 2016 by Pama328

thanks a lot, that worked, but know I've got another question:

actually my class for example SigmaSolid is looking like this:

class Sigma_S : public dolfin::Expression {
           private:
            void eval(dolfin::Array<double> &values,
                      const dolfin::Array<double> &) const
            {
                values[0] = 5.3e5;
            }
        };

should I define sigma as a vector-valued expression now like

class Sigma : public dolfin::Expression {
               private:
                void eval(dolfin::Array<double> &values,
                          const dolfin::Array<double> &) const
                {
                    values[0] = 42; //SigmaLiquid
                    values[1] = 5.3e5; //SigmaSolid
                }
            };

?

And why is my variational formulation incomplete?

You should address your new problem succinctly with a minimal working example in a new question. Regarding DG FEM methods, examine the dolfin DG demos, cf. for elliptic problems Arnold, Brezzi, Cockburn, Marini, 2002.

...