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

'MixedFunctionSpace' object has no attribute 'inside'

0 votes

Hi,

I want to solve an eigenvalue problem in linear elasticity which contains periodic boundary condition and complex weak formulation. I defined a mixed function space to handle the complex problem. My code is like this:

    a=5.e-2; #cube size
# Sub domain for Periodic boundary condition
class PeriodicBoundary(SubDomain):

    # Left boundary is "target domain" G
    def inside(self, x, on_boundary):
        # return True if on left or bottom boundary AND NOT on one of the two slave edges
        return bool(( near(x[0], -a/2.) or near(x[1], -a/2.) or near(x[2], -a/2.)) and 
            (not ((near(x[0], a/2.) and near(x[2], -a/2.)) or 
                  (near(x[0], -a/2.) and near(x[2], a/2.)) or
                  (near(x[1], a/2.) and near(x[2], -a/2.))or
                  (near(x[1], -a/2.) and near(x[2], a/2.)))) and on_boundary)

    # Map right boundary (H) to left boundary (G)
    def map(self, x, y):

        if near(x[0], a/2.) and near(x[2], a/2.):
            y[0] = x[0] - a/2
            y[1] = x[1] 
            y[2] = x[2] - a/2
        elif near(x[1], a/2.) and near(x[2], a/2.):
            y[0] = x[0] 
            y[1] = x[1] - a/2
            y[2] = x[2] - a/2
        elif near(x[0], a/2):
            y[0] = x[0] - a/2
            y[1] = x[1]
            y[2] = x[2]
        elif near(x[1], a/2):
            y[0] = x[0]
            y[1] = x[1] - a/2
            y[2] = x[2] 
        elif near(x[2], a/2):
            y[0] = x[0]
            y[1] = x[1]
            y[2] = x[2] - a/2



mesh = BoxMesh(-a/2, -a/2, -a/2, a/2, a/2, a/2,36,36,36)

V = VectorFunctionSpace(mesh, "CG", 1, constrained_domain=PeriodicBoundary())
Vcomplex = V*V

uR, uI = TrialFunctions(Vcomplex)
wR, wI = TestFunctions(Vcomplex)

when I run the code, it gives the following error:

File "Alessandro.py", line 61, in <module>
    Vcomplex = V*V
  File "/share/apps/fenics/lib/python2.7/site-packages/dolfin/functions/functionspace.py", line 126, in __mul__
    return MixedFunctionSpace((self, other))
  File "/share/apps/fenics/lib/python2.7/site-packages/dolfin/functions/functionspace.py", line 505, in __init__
    FunctionSpaceBase.__init__(self, spaces[0].mesh(), element, constrained_domain=spaces[0].dofmap().constrained_domain)
  File "/share/apps/fenics/lib/python2.7/site-packages/dolfin/functions/functionspace.py", line 93, in __init__
    dolfin_dofmap  = cpp.DofMap(ufc_dofmap, mesh, constrained_domain)
  File "/share/apps/fenics/lib/python2.7/site-packages/dolfin/cpp/fem.py", line 654, in __init__
    _fem.DofMap_swiginit(self,_fem.new_DofMap(*args))
AttributeError: 'MixedFunctionSpace' object has no attribute 'inside'

So due to :AttributeError: 'MixedFunctionSpace' object has no attribute 'inside'
How should I define the periodic boundary condition for the mixed function space?

Thanks

asked May 11, 2017 by Ashkan FEniCS Novice (300 points)

1 Answer

0 votes
 
Best answer

Hi, if you update your FEniCS version to (at least) 2016.2.0 or later then the construction is possible with

V = VectorElement("Lagrange", mesh.ufl_cell(), 1)
W = MixedElement([V, V])
Vcomplex = FunctionSpace(mesh, W, constrained_domain=PeriodicBoundary())

print Vcomplex.dim(), FunctionSpace(mesh, W).dim() 
answered May 12, 2017 by MiroK FEniCS Expert (80,920 points)
selected May 24, 2017 by johannr

Thanks a lot. Do you know what are the new features of the newest version of fenics (May 12)?
Does it support complex numbers directly?

No, there is no support for complex numbers. For new features consult the ChangeLog.

...