How to set inhomogeneous material properties

I’m testing GetFEM by porting over a biomechanical experiment. I have a list of elastic moduli per-element that were determined from a microCT of a specimen of bone. I can’t seem to find an example in GetFEM about setting elastic moduli that vary by element. Can somebody point me to any documentation or explain how to do it?

1 Like

Model data can be specified either as a data of a fixed size (e.g. a scalar as in most of the examples) or on the degrees of freedom of a finite element method using getfem::model::add_initialized_fem_data.

You can find the options in the documentation here: The model object — GetFEM

you can use a mesh_fem of zero order (elementwise constant) to describe your E modulus.

mfE = gf.MeshFem(m)
mfE.set_classical_fem(0) # this is equivalent to mfE.set_classical_discontinuous_fem(0)

then you can define the E modulus as a field in the model
md.add_initialized_fem_data("E", mfE, numpy_vector_with_values_from_scan)

if you want to change this field later, you can do it with
md.set_variable("E", numpy_vector_with_values_from_scan)

The only difficulty is that the order of the values inside numpy_vector_with_values_from_scan needs to follow the dof numbering inside the mfE object, which is controlled by GetFEM

You can see how GetFEM has numbered your element dofs with
print(mfE.basic_dof_nodes())
It will show the location of each dof in the order from dof=1 to dof=mfE.nbdof()

I have some snippets that do this kind of reordering from your own ordering to GetFEM ordering, so please ask again if you do not figure it out faster on your own.

Thank you @jab2443 and @Konstantinos.Poulios. I will study this and follow up either with what works for me or further questions.