In hindsight I could've written something simpler. Here it is: -------------------------------------------------------------------------------------------- #include <deal.II/base/tensor_function.h> #include <deal.II/numerics/vector_tools.h>
using namespace dealii; template <int dim> class Exact : public TensorFunction<1, dim> { public: Exact() : TensorFunction<1, dim>(dim) {} virtual Tensor<1, dim> value(const Point<dim> &p) const override; virtual Tensor<2, dim> gradient(const Point<dim> &p) const override; }; template <int dim> Tensor<1, dim> Exact<dim>::value(const Point<dim> &p) const { return Tensor<1, dim>(); } template <int dim> Tensor<2, dim> Exact<dim>::gradient(const Point<dim> &p) const { return Tensor<2, dim>(); } int main() { const int dim = 2; Exact<dim> exact_solution; VectorFunctionFromTensorFunction<dim> exact_solution_vector_function(exact_solution, 0, dim); Point<dim> p1; exact_solution_vector_function.value(p1); exact_solution_vector_function.gradient(p1); return 0; } -------------------------------------------------------------------------------------------- I get this error when I call the exact_solution_vector_function.gradient (p1): !ERROR Message: *An error occurred in line <135> of file </home/abbas/dealii-candi/deal-II/dealii/include/deal.II/base/function.templates.h> in function dealii::Tensor<1, dim, Number> dealii::Function<dim, RangeNumberType>::gradient(const dealii::Point<dim>&, unsigned int) const [with int dim = 2; RangeNumberType = double]The violated condition was: falseAdditional information: You (or a place in the library) are trying to call a function that is declared as a virtual function in a base class but that has not been overridden in your derived class.* Calling value works fine but not gradient even though I have overridden both functions. On Friday, July 14, 2023 at 8:55:34 PM UTC+2 Wolfgang Bangerth wrote: > On 7/14/23 09:34, Abbas Ballout wrote: > > // THis throws exception > > VectorTools::integrate_difference(dof_handler, > > solution, > > exact_solution_vector_function, > > difference_per_cell, > > quadrature_formula, > > VectorTools::H1_seminorm);; > > Well, what's the error message? A good rule of thumb is that 50% debugging > consists of carefully reading what the error message says. > > Best > W. > > -- > ------------------------------------------------------------------------ > Wolfgang Bangerth email: bang...@colostate.edu > www: http://www.math.colostate.edu/~bangerth/ > > > -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/c1157723-d4a3-4c67-96f7-8eb98aa57fd5n%40googlegroups.com.