thelfer / MFrontGenericInterfaceSupport

This project aims at providing support for MFront generic behaviours. This project can be embedded in open-source and propriary sofware
37 stars 35 forks source link

[mgis.fenics] Implementing MFrontNonlinearProblem in DOLFINx #135

Closed VaishnavBhaskaran closed 2 months ago

VaishnavBhaskaran commented 2 months ago

Hello @thelfer, @bleyerj,

I am trying to implement one of your demos (tutorial1) involving MFront and mgis.fenics libraries using DOLFINx. This is a much compact version of tutorial2

V = fem.functionspace(msh, element) # msh is imported from gmsh using gmshio.model_to_mesh() function
u = fem.function.Function(V, name = "displacement")
material = mf.MFrontNonlinearMaterial("./src/libBehaviour.so", "ChabocheViscoplasticity",
                                      material_properties = mat_prop,
                                      hypothesis = hypothesis)
problem = mf.MFrontNonlinearProblem(u, material, quadrature_degree = 2, bcs = bcs)

I get the following error from MFrontNonlinearProblem

TypeError                                 Traceback (most recent call last)
Cell In[29], line 1
----> 1 problem = mf.MFrontNonlinearProblem(u, material, quadrature_degree = 2, bcs = bcs)

File ~/codes/mgis/master/install-f9c21b07e6ecb858ca4ec7c199f7c65cc60e7337/lib/python3.10/site-packages/mgis/fenics/nonlinear_problem.py:655, in MFrontNonlinearProblem.__init__(self, u, material, quadrature_degree, bcs)
    642 """
    643 Parameters
    644 ----------
   (...)
    652     Dirichlet boundary conditions associated with the problem. The default is None.
    653 """
    654 NonlinearProblem.__init__(self)
--> 655 AbstractNonlinearProblem.__init__(self,
    656                                   u,
    657                                   material,
    658                                   quadrature_degree=quadrature_degree,
    659                                   bcs=bcs)
    660 self.solver = NewtonSolver()

File ~/codes/mgis/master/install-f9c21b07e6ecb858ca4ec7c199f7c65cc60e7337/lib/python3.10/site-packages/mgis/fenics/nonlinear_problem.py:60, in AbstractNonlinearProblem.__init__(self, u, material, quadrature_degree, bcs)
     58 def __init__(self, u, material, quadrature_degree=2, bcs=None):
     59     self.u = u
---> 60     self.V = self.u.function_space()
     61     self.u_ = TestFunction(self.V)
     62     self.du = TrialFunction(self.V)

TypeError: 'FunctionSpace' object is not callable

Based on bleyerj's comment, I understand mgis.fenics is only meant for legacy FEniCS. I am working with ChabocheViscoplasticity from MFront and this is currently not available in dolfinx_materials.

Is there another way to implement MFrontNonlinearProblem in DOLFINx or follow tutorial2?

thelfer commented 2 months ago

I am working with ChabocheViscoplasticity from MFront and this is currently not available in dolfinx_materials.

@VaishnavBhaskaran, as far as I can tell, dolfinx_materials works with all MFront behaviours, just like mgis.fenics, so I can't get your point

VaishnavBhaskaran commented 2 months ago

Hello @thelfer, The library works well with all MFront behaviours as you said. I misunderstood the library on seeing the below image. I apologize for my mistake.

image