ikarus-project / ikarus

Ikarus is a C++-based library that uses DUNE modules to solve partial differential equations with the finite element method and more.
https://ikarus-project.github.io/
Other
6 stars 3 forks source link

calculateAt() should be generalised for various gridDim #200

Closed tarun-mitruka closed 10 months ago

tarun-mitruka commented 11 months ago
typename ResultTypeMap<double>::ResultArray resultVector;
if (req.isResultRequested(ResultType::linearStress)) {
    resultVector.resize(3, 1);
    resultVector = cauchyStress;
    result.insertOrAssignResult(ResultType::linearStress, resultVector);
  } else
    DUNE_THROW(Dune::NotImplemented, "The requested result type is NOT implemented.");
}

The above code snippet in linearelastic.hh only works for 2D case. For 3D case, the resize should be of size 3x3 and for 1D it should be a scalar.

Voigt notation in 3D will not work as ResultArray is restricted with a maximum number of rows being 3 where as Voigt notation in 3D will yield a maximum number of rows as 6.

using ResultArray = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3>;

Similar fix has to be done for nonLinearElastic.hh.

henrij22 commented 11 months ago

There is actually no need to resize the resultVector, or even create it in the first place. We can just do

result.insertOrAssignResult(ResultType::linearStress, linearStress);

directly

rath3t commented 11 months ago

There is actually no need to resize the resultVector, or even create it in the first place. We can just do

result.insertOrAssignResult(ResultType::linearStress, linearStress);

directly

I wonder why this works now. I believe in an earlier Eigen version ths assignment didn't work. But if it works fine now, I'm fine with it.