16#include <dune/vtk/vtkwriter.hh>
24 struct DefaultUserFunction {};
47 template <
typename ElementType_,
typename UserFunction = Impl::DefaultUserFunction>
48 class ResultFunction :
public Dune::VTKFunction<typename ElementType_::GridView> {
52 using GridView =
typename ElementType::GridView;
53 using ctype =
typename GridView::ctype;
54 constexpr static int griddim = GridView::dimension;
55 typedef typename GridView::template Codim<0>::Entity
Entity;
68 auto index = gridView.indexSet().index(e);
69 return evaluateComponent(index, local, comp);
79 [[nodiscard]]
int ncomps()
const override {
80 if constexpr (std::is_same_v<UserFunction, Impl::DefaultUserFunction>) {
83 fes_->at(0).calculateAt(resultRequirements_, val, resultTypeMap);
84 if (resultRequirements_.getRequestedResult() != resultTypeMap.
getSingleResult().first)
85 DUNE_THROW(Dune::InvalidStateException,
"The return result should be the requested one");
89 return static_cast<int>(sigma.rows() * sigma.cols());
91 return userFunction_.ncomps();
101 [[nodiscard]]
constexpr std::string
name()
const override {
102 if constexpr (std::is_same_v<UserFunction, Impl::DefaultUserFunction>)
103 return toString(resultRequirements_.getRequestedResult());
105 return userFunction_.name();
119 : gridView{fes->at(0).localView().globalBasis().gridView()},
120 resultRequirements_{req},
122 userFunction_{userFunction} {
123 if constexpr (!std::is_same_v<UserFunction, Impl::DefaultUserFunction>) userFunction_ = userFunction;
128 if constexpr (!std::is_same_v<UserFunction, Impl::DefaultUserFunction>)
129 return userFunction_(fes_->at(eleID), resultRequirements_, local, comp);
131 fes_->at(eleID).calculateAt(resultRequirements_, local, resultTypeMap);
139 std::vector<ElementType>* fes_;
140 mutable ResultTypeMap<ctype> resultTypeMap;
141 [[no_unique_address]] std::string name_{};
142 UserFunction userFunction_;
Helper for transform between Dune linear algebra types and Eigen.
Definition of the LinearElastic class for finite element mechanics computations.
Ikarus Result Evaluators for Stress Analysis.
Definition: simpleassemblers.hh:21
constexpr std::string toString(ScalarAffordances _e)
Definition: ferequirements.hh:34
auto & getSingleResult()
Get the result array for a single result type.
Definition: ferequirements.hh:379
Definition: resultevaluators.hh:20
Wrapper to evaluate results for a vtkwriter.
Definition: resultfunction.hh:48
static constexpr int griddim
Definition: resultfunction.hh:54
typename GridView::ctype ctype
Definition: resultfunction.hh:53
int ncomps() const override
Get the number of components.
Definition: resultfunction.hh:79
typename ElementType::GridView GridView
Definition: resultfunction.hh:52
ResultFunction(std::vector< ElementType > *fes, const ResultRequirements &req, UserFunction userFunction={})
Constructor for ResultFunction.
Definition: resultfunction.hh:118
GridView::template Codim< 0 >::Entity Entity
Definition: resultfunction.hh:55
typename ElementType::ResultRequirementsType ResultRequirements
Definition: resultfunction.hh:51
double evaluate(int comp, const Entity &e, const Dune::FieldVector< ctype, griddim > &local) const override
Evaluate the component at a given entity and local coordinates.
Definition: resultfunction.hh:67
constexpr std::string name() const override
Get the name of the result type.
Definition: resultfunction.hh:101
ElementType_ ElementType
Definition: resultfunction.hh:50