Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation errors due to fixed typs in deal.II #252

Closed
jh66637 opened this issue Jul 20, 2022 · 5 comments
Closed

Compilation errors due to fixed typs in deal.II #252

jh66637 opened this issue Jul 20, 2022 · 5 comments

Comments

@jh66637
Copy link
Contributor

jh66637 commented Jul 20, 2022

Explicitly using double for interface coupling results in compilation errors after the fixture of types in deal.II dealii/dealii#14142.

The decision to use double instead of Number is related due to the design choice to keep Number out of BoundaryDescriptors.

I might find some time to work on this towards the end of the week.

@peterrum
Copy link
Member

A minimal test:

#include <deal.II/matrix_free/fe_point_evaluation.h>

using namespace dealii;

template <int n_components, int dim, int spacedim, typename Number>
void
test()
{
  std::unique_ptr<Mapping<dim, spacedim>>       mapping;
  std::unique_ptr<FiniteElement<dim, spacedim>> fe;

  FEPointEvaluation<n_components, dim, spacedim, Number> fpe(
    *mapping, *fe, UpdateFlags::update_default);

  Triangulation<dim, spacedim> tria;

  fpe.reinit(tria.begin(), ArrayView<const Point<dim>>());

  fpe.evaluate(ArrayView<const Number>(), EvaluationFlags::values);

  fpe.integrate(ArrayView<Number>(), EvaluationFlags::values);
}

int
main()
{
  test<1, 1, 1, double>();
  test<2, 1, 1, double>();

  test<1, 2, 2, double>();
  test<2, 2, 2, double>();
  test<3, 2, 2, double>();

  test<1, 3, 3, double>();
  test<2, 3, 3, double>();
  test<3, 3, 3, double>();
  test<4, 3, 3, double>();

  test<1, 1, 1, float>();
  test<2, 1, 1, float>();

  test<1, 2, 2, float>();
  //test<2, 2, 2, float>(); // not working 
  test<3, 2, 2, float>();

  test<1, 3, 3, float>();
  test<2, 3, 3, float>();
  //test<3, 3, 3, float>(); // not working
  test<4, 3, 3, float>();
}

@peterrum
Copy link
Member

This should fix it:

diff --git a/include/deal.II/base/derivative_form.h b/include/deal.II/base/derivative_form.h
index 10d6545..ba4985b 100644
--- a/include/deal.II/base/derivative_form.h
+++ b/include/deal.II/base/derivative_form.h
@@ -108,12 +108,14 @@ public:
    * Number>. In particular, if order == 1 and the derivative is the Jacobian of
    * $\mathbf F(\mathbf x)$, then Tensor[i] = $\nabla F_i(\mathbf x)$.
    */
-  operator Tensor<order + 1, dim, Number>() const;
+  template<typename Number2>
+  operator Tensor<order + 1, dim, Number2>() const;
 
   /**
    * Converts a DerivativeForm<1, dim, 1, Number> to Tensor<1, dim, Number>.
    */
-  operator Tensor<1, dim, Number>() const;
+   template<typename Number2>
+  operator Tensor<1, dim, Number2>() const;
 
   /**
    * Return the transpose of a rectangular DerivativeForm,
@@ -273,8 +275,9 @@ DerivativeForm<order, dim, spacedim, Number>::operator[](
 
 
 template <int order, int dim, int spacedim, typename Number>
+template<typename Number2>
 inline DerivativeForm<order, dim, spacedim, Number>::
-operator Tensor<1, dim, Number>() const
+operator Tensor<1, dim, Number2>() const
 {
   Assert((1 == spacedim) && (order == 1),
          ExcMessage("Only allowed for spacedim==1."));
@@ -285,8 +288,9 @@ operator Tensor<1, dim, Number>() const
 
 
 template <int order, int dim, int spacedim, typename Number>
+template<typename Number2>
 inline DerivativeForm<order, dim, spacedim, Number>::
-operator Tensor<order + 1, dim, Number>() const
+operator Tensor<order + 1, dim, Number2>() const
 {
   Assert((dim == spacedim), ExcMessage("Only allowed when dim==spacedim."));

I'll open a PR in deal.II later today.

@jh66637
Copy link
Contributor Author

jh66637 commented Jul 20, 2022

Thank you :)

@jh66637
Copy link
Contributor Author

jh66637 commented Aug 30, 2022

Merging this: #257 (comment), the pipeline is successful, and the Issue can be closed.

@nfehn
Copy link
Member

nfehn commented Aug 31, 2022

should be resolved by dealii/dealii#14159

@nfehn nfehn closed this as completed Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants