SimVascular / svFSIplus

This repository contains a line-by-line conversion of the Fortran svFSI solver to C++.
Other
6 stars 19 forks source link

Fixed-sized tensor classes #177

Open mrp089 opened 4 months ago

mrp089 commented 4 months ago

Use Case

Most solid material models require tensor operations to compute stress $\mathbf{S}$ and tangent matrix $\mathrm{C}$. The tensors are usually 2nd- and 4th-order fixed-size, nsd x nsd and nsd x nsd x nsd x nsd, with the number of spatial dimensions nsd.

Problem

Previously, we used the variable-size array classes Vector, Array, and Tensor. In #85, this was replaced by C-arrays, which yielded a large speedup. However, we still require tensor operations (between tensors of different orders and on the tensors themselves). This will enable more "complicated" material models (specifically G&R) and replace many (if not all) the for-loops in current solid materials.

Solution

Add classes for fixed-sized tensors (templated on spatial dimension) that support various tensor operations. @ktbolt mentioned it might be great for performance to use a package where tensor operations are templated so they are computed at compile time. (Also, this way, you notice if your tensor operations make sense at compile time.)

Alternatives considered

I know of three examples that have tensor classes. I only have experience with FEBio but we might be able to find developers in or outside the lab that have experience with the other two.

FEBio provides the most comprehensive functionality (but maybe not computational performance). The full list of implemented classes is here, starting with tens*, vec*, and mat*. See an example here of how these classes are used in a material model.

deal.ii offers a tensor class that I know are used in other FEM codes. This could be interesting as we are interested in using deal.ii for a linear solver interface (#30) or finite element technology in the future. So trying its tensors for solid materials could be a nice first step.

Eigen also has tensor classes that I don't know much about, but @ktbolt might.

Additional context

No response

Code of Conduct

ktbolt commented 4 months ago

I would first have a look at Eigen, it uses expression templates and it is already integrated into svFSIplus.

I've not looked at the Eigen Tensor class. It is labeled as an unsupported module but it seems that it use used by Google in Tensor Flow.

mrp089 commented 2 months ago

For matrices, it would be nice to perform all tensor operations on the actual tensors and include a function to export to Voigt notation so we never have to deal with Voigt notation in the materials or elsewhere.