BAMresearch / fenics-constitutive

Complex constitutive models beyond the FEniCS UFL.
https://bamresearch.github.io/fenics-constitutive
MIT License
13 stars 2 forks source link

Removing Constraint from the interface #44

Open srosenbu opened 5 months ago

srosenbu commented 5 months ago

Maybe it would be a good idea to remove the Constraint enum from the interface to make it easier to write constitutive models in other languages. If I wanted to write a model in Rust, I would probably implement the methods evaluate and history_dim and then write a wrapper

class ModelWrapper:
    def __init__(self, rust_model):
        self.rust_model = rust_model
    def constraint():
        return Constraint.PLANE_STRAIN
    def evaluate(...):
        self.rust_model.evaluate(...)
    def history_dim(...):
        self.rust_model.history_dim()
    ...

We should still keep the stress_strain_dim geometric_dim and history_dim methods, but constraint could just return a string.

Example:

class SomeModel:
    ...
    def constraint(self) -> str:
        return "PLANE_STRAIN"

The advantage would be that with this change any constitutive model would only need to handle np.ndarray and str and maybe dict as complex data types.