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

Matrixfree evaluation with FE_RaviartThomasNodal #13591

Merged
merged 1 commit into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
mkdir build
mkdir c:/project
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=c:/project -DDEAL_II_WITH_ZLIB=off -DDEAL_II_CXX_FLAGS="-WX" -T host=x64 -A x64 ..
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=c:/project -DDEAL_II_WITH_ZLIB=off -DDEAL_II_CXX_FLAGS="-WX /D FE_EVAL_FACTORY_DEGREE_MAX=2" -T host=x64 -A x64 ..
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it so simple to define a C macro? It it wouldn't work just override manually the value of

... and we find a solution after we have seen what the benefits are!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. It worked (now I see that you are directly modify the CXX flags)! I'll take another look at the code later today!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was Martin, just to be clear! I shouldn't take credit here :)

I'll prepare the PR of the Piola for the affine case right away.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, it's still a temporary solution since there will be a point where we will hit this with something else, but for all those build tests building a rather minimal degree should be more than enough, no need to waste disk space and compile time on it. We should probably choose something similar for the MacOS and Linux builds that are done through github's infrastructure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kronbichler Why aren't we do it like this in ExaDG? We also have somewhere the possibility if fast evaluation is enabled or not...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could do that as well - the reason why I opted against it up to now was that deal.II compiles considerably more code than ExaDG does, as it repeats the instantiations also for narrower SIMD (ExaDG picks only the widest version), and that makes deal.II libraries considerably fatter. The other question is whether ExaDG really needs all instantiations up to 15 with the fast path, or whether 7 or 8 would suffice and then use the slower path afterwards.

- name: archive logs
uses: actions/upload-artifact@v1
with:
Expand Down
8 changes: 8 additions & 0 deletions include/deal.II/fe/fe_raviart_thomas.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,14 @@ class FE_RaviartThomas : public FE_PolyTensor<dim>
* FiniteElementData<dim>::degree is higher by one than the constructor
* argument!
*/

namespace internal
{
template <int dim>
std::vector<unsigned int>
get_lexicographic_numbering_rt_nodal(const unsigned int degree);
} // namespace internal

template <int dim>
class FE_RaviartThomasNodal : public FE_PolyTensor<dim>
{
Expand Down
1,332 changes: 1,312 additions & 20 deletions include/deal.II/matrix_free/evaluation_kernels.h

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// ---------------------------------------------------------------------
//
// Copyright (C) 2022 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE.md at
// the top level directory of deal.II.
//
// ---------------------------------------------------------------------


#ifndef dealii_matrix_free_evaluation_template_factory_templates_h
#define dealii_matrix_free_evaluation_template_factory_templates_h


#include <deal.II/base/config.h>

#include <deal.II/matrix_free/evaluation_kernels.h>
#include <deal.II/matrix_free/evaluation_selector.h>
#include <deal.II/matrix_free/evaluation_template_factory.h>
#include <deal.II/matrix_free/evaluation_template_factory_internal.h>

DEAL_II_NAMESPACE_OPEN

namespace internal
{
template <int dim, typename Number>
void
FEFaceEvaluationFactory<dim, Number>::evaluate(
const unsigned int n_components,
const EvaluationFlags::EvaluationFlags evaluation_flag,
const Number * values_dofs,
FEEvaluationData<dim, Number, true> & fe_eval)
{
instantiation_helper_run<1,
FEFaceEvaluationImplEvaluateSelector<dim, Number>>(
fe_eval.get_shape_info().data[0].fe_degree,
fe_eval.get_shape_info().data[0].n_q_points_1d,
n_components,
evaluation_flag,
values_dofs,
fe_eval);
}



template <int dim, typename Number>
void
FEFaceEvaluationFactory<dim, Number>::integrate(
const unsigned int n_components,
const EvaluationFlags::EvaluationFlags integration_flag,
Number * values_dofs,
FEEvaluationData<dim, Number, true> & fe_eval)
{
instantiation_helper_run<
1,
FEFaceEvaluationImplIntegrateSelector<dim, Number>>(
fe_eval.get_shape_info().data[0].fe_degree,
fe_eval.get_shape_info().data[0].n_q_points_1d,
n_components,
integration_flag,
values_dofs,
fe_eval);
}



template <int dim, typename Number, typename VectorizedArrayType>
void
FEFaceEvaluationGatherFactory<dim, Number, VectorizedArrayType>::evaluate(
const unsigned int n_components,
const EvaluationFlags::EvaluationFlags evaluation_flag,
const Number * src_ptr,
const std::vector<ArrayView<const Number>> * sm_ptr,
FEEvaluationData<dim, VectorizedArrayType, true> &fe_eval)
{
instantiation_helper_run<
1,
FEFaceEvaluationImplGatherEvaluateSelector<dim,
Number,
VectorizedArrayType>>(
fe_eval.get_shape_info().data[0].fe_degree,
fe_eval.get_shape_info().data[0].n_q_points_1d,
n_components,
evaluation_flag,
src_ptr,
sm_ptr,
fe_eval);
}



template <int dim, typename Number, typename VectorizedArrayType>
void
FEFaceEvaluationGatherFactory<dim, Number, VectorizedArrayType>::integrate(
const unsigned int n_components,
const EvaluationFlags::EvaluationFlags integration_flag,
Number * dst_ptr,
const std::vector<ArrayView<const Number>> * sm_ptr,
FEEvaluationData<dim, VectorizedArrayType, true> &fe_eval)
{
instantiation_helper_run<
1,
FEFaceEvaluationImplIntegrateScatterSelector<dim,
Number,
VectorizedArrayType>>(
fe_eval.get_shape_info().data[0].fe_degree,
fe_eval.get_shape_info().data[0].n_q_points_1d,
n_components,
integration_flag,
dst_ptr,
sm_ptr,
fe_eval);
}

} // end of namespace internal

DEAL_II_NAMESPACE_CLOSE

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -93,97 +93,6 @@ namespace internal



template <int dim, typename Number>
void
FEFaceEvaluationFactory<dim, Number>::evaluate(
const unsigned int n_components,
const EvaluationFlags::EvaluationFlags evaluation_flag,
const Number * values_dofs,
FEEvaluationData<dim, Number, true> & fe_eval)
{
instantiation_helper_run<1,
FEFaceEvaluationImplEvaluateSelector<dim, Number>>(
fe_eval.get_shape_info().data[0].fe_degree,
fe_eval.get_shape_info().data[0].n_q_points_1d,
n_components,
evaluation_flag,
values_dofs,
fe_eval);
}



template <int dim, typename Number>
void
FEFaceEvaluationFactory<dim, Number>::integrate(
const unsigned int n_components,
const EvaluationFlags::EvaluationFlags integration_flag,
Number * values_dofs,
FEEvaluationData<dim, Number, true> & fe_eval)
{
instantiation_helper_run<
1,
FEFaceEvaluationImplIntegrateSelector<dim, Number>>(
fe_eval.get_shape_info().data[0].fe_degree,
fe_eval.get_shape_info().data[0].n_q_points_1d,
n_components,
integration_flag,
values_dofs,
fe_eval);
}



template <int dim, typename Number, typename VectorizedArrayType>
void
FEFaceEvaluationGatherFactory<dim, Number, VectorizedArrayType>::evaluate(
const unsigned int n_components,
const EvaluationFlags::EvaluationFlags evaluation_flag,
const Number * src_ptr,
const std::vector<ArrayView<const Number>> * sm_ptr,
FEEvaluationData<dim, VectorizedArrayType, true> &fe_eval)
{
instantiation_helper_run<
1,
FEFaceEvaluationImplGatherEvaluateSelector<dim,
Number,
VectorizedArrayType>>(
fe_eval.get_shape_info().data[0].fe_degree,
fe_eval.get_shape_info().data[0].n_q_points_1d,
n_components,
evaluation_flag,
src_ptr,
sm_ptr,
fe_eval);
}



template <int dim, typename Number, typename VectorizedArrayType>
void
FEFaceEvaluationGatherFactory<dim, Number, VectorizedArrayType>::integrate(
const unsigned int n_components,
const EvaluationFlags::EvaluationFlags integration_flag,
Number * dst_ptr,
const std::vector<ArrayView<const Number>> * sm_ptr,
FEEvaluationData<dim, VectorizedArrayType, true> &fe_eval)
{
instantiation_helper_run<
1,
FEFaceEvaluationImplIntegrateScatterSelector<dim,
Number,
VectorizedArrayType>>(
fe_eval.get_shape_info().data[0].fe_degree,
fe_eval.get_shape_info().data[0].n_q_points_1d,
n_components,
integration_flag,
dst_ptr,
sm_ptr,
fe_eval);
}



template <int dim, typename Number>
void
CellwiseInverseMassFactory<dim, Number>::apply(
Expand Down
15 changes: 10 additions & 5 deletions include/deal.II/matrix_free/matrix_free.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -1160,16 +1160,21 @@ namespace internal
dof_info[no].fe_index_conversion[fe_index].clear();
for (unsigned int c = 0; c < dof_info[no].n_base_elements; ++c)
{
dof_info[no].n_components[c] = fe.element_multiplicity(c);
dof_info[no].n_components[c] =
fe.element_multiplicity(c) *
fe.base_element(c).n_components();
for (unsigned int l = 0; l < dof_info[no].n_components[c]; ++l)
{
dof_info[no].component_to_base_index.push_back(c);
dof_info[no]
.component_dof_indices_offset[fe_index]
.push_back(dof_info[no]
.component_dof_indices_offset[fe_index]
.back() +
fe.base_element(c).n_dofs_per_cell());
.push_back(
dof_info[no]
.component_dof_indices_offset[fe_index]
.back() +
shape_infos(dof_info[no].global_base_element_offset + c,
fe_index)
.dofs_per_component_on_cell);
dof_info[no].fe_index_conversion[fe_index].push_back(
fe.base_element(c).degree);
}
Expand Down
13 changes: 11 additions & 2 deletions include/deal.II/matrix_free/shape_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,18 @@ namespace internal
tensor_symmetric_plus_dg0 = 5,

/**
* Shape functions without an tensor product properties.
* Special case of the FE_RaviartThomasNodal element with anisotropic
* tensor product shape functions, i.e degree (k + 1) in normal direction,
* and k in tangential direction.
*/
tensor_none = 6
tensor_raviart_thomas = 6,

/**
* Shape functions without a tensor product properties.
*/
tensor_none = 7


};


Expand Down