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

Added test 5, and pseudocode for FESystem. #107

Open
wants to merge 1 commit into
base: non-local-dofs-inside-fe
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions include/deal.II/fe/fe_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,46 @@ class FESystem : public FiniteElement<dim, spacedim>
virtual std::size_t
memory_consumption() const override;

/**
* @name Non local dofs support
* @{
*/
/**
* Return the non local dof indices associated to the current cell, for
* active cell accessors. The implementation for FESystem combines the answers
* from all base elements.
*/
virtual std::vector<types::global_dof_index>
get_non_local_dof_indices(
const DoFCellAccessor<dim, spacedim, false> &accessor) const override;

/**
* Return the non local dof indices associated to the current cell, for
* level cell accessors. The implementation for FESystem combines the answers
* from all base elements.
*/
virtual std::vector<types::global_dof_index>
get_non_local_dof_indices(
const DoFCellAccessor<dim, spacedim, true> &accessor) const override;

/**
* Return the global number of non local dof indices that are required in
* addition to the local ones. The implementation for FESystem returns the sum
* of the result from each base element.
*/
virtual types::global_dof_index
n_global_non_local_dofs() const override;

/**
* Return an identification string that uniquely identifies the non local
* behaviour of the finite element space.
*
* Returns a combination of each base non local id, with their multiplicity.
*/
virtual std::string
get_non_local_id() const override;
//@}

protected:
virtual std::unique_ptr<
typename FiniteElement<dim, spacedim>::InternalDataBase>
Expand Down
78 changes: 78 additions & 0 deletions source/fe/fe_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,84 @@ FESystem<dim, spacedim>::convert_generalized_support_point_values_to_dof_values(



namespace
{
template <int dim, int spacedim, class AccessorType>
std::vector<types::global_dof_index>
get_non_local_dof_indices(const FiniteElement<dim, spacedim> &fe,
const AccessorType & accessor)
{
// We always number non local dofs component-wise.
Assert(fe == accessor.get_fe(),
ExcInternalError(
"I was expecting the same FE that is stored in the accessor."));
std::vector<types::global_dof_index> non_local_dofs(
fe.n_non_local_dofs_per_cell());

std::vector<types::global_dof_index> non_local_dofs_start(
fe.n_non_local_dofs_per_cell());


std::vector<std::vector<types::global_dof_index>> base_non_local_dofs;
for (unsigned int i = 0; i < fe.n_base_elements(); ++i)
base_non_local_dofs.emplace_back(
fe.base_element(i).get_non_local_dof_indices(accessor));

unsigned int i = fe.n_dofs_per_cell() - fe.n_non_local_dofs_per_cell();
for (unsigned int j = 0; j < fe.n_non_local_dofs_per_cell(); ++j, ++i)
{
// const auto comp_i = fe.system_to_base_index
// FIXME[ZL+LH+AmB]
}
std::cout << "FIXME!" << std::endl;
}
} // namespace


template <int dim, int spacedim>
std::vector<types::global_dof_index>
FESystem<dim, spacedim>::get_non_local_dof_indices(
const DoFCellAccessor<dim, spacedim, false> &accessor) const
{}



template <int dim, int spacedim>
std::vector<types::global_dof_index>
FESystem<dim, spacedim>::get_non_local_dof_indices(
const DoFCellAccessor<dim, spacedim, true> &accessor) const
{}



template <int dim, int spacedim>
types::global_dof_index
FESystem<dim, spacedim>::n_global_non_local_dofs() const
{
types::global_dof_index global_dofs = 0;
for (unsigned int i = 0; i < this->n_base_elements(); ++i)
global_dofs += this->element_multiplicity(i) *
this->base_element(i).n_global_non_local_dofs();
return global_dofs;
}



template <int dim, int spacedim>
std::string
FESystem<dim, spacedim>::get_non_local_id() const
{
std::string id = "";
for (unsigned int i = 0; i < this->n_base_elements(); ++i)
{
id += (i == 0 ? "" : ", ") + this->base_element(i).get_non_local_id() +
" (" + std::to_string(this->element_multiplicity(i)) + ")";
}
return id;
}



template <int dim, int spacedim>
std::size_t
FESystem<dim, spacedim>::memory_consumption() const
Expand Down
71 changes: 71 additions & 0 deletions tests/non_local/fe_q1_nonlocal_05.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// ---------------------------------------------------------------------
//
// Copyright (C) 1998 - 2018 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.
//
// ---------------------------------------------------------------------

// build an FE_Q1_Nonlocal finite element, distribute dofs on a simple
// Triangulation, and interpolate a scalar function.

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

#include <deal.II/dofs/dof_handler.h>

#include <deal.II/fe/fe_system.h>

#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/tria.h>

#include <deal.II/numerics/vector_tools.h>

#include <iostream>

#include "../tests.h"

#include "../non_local/fe_q1_nonlocal.h"

template <int dim>
void
test()
{
Triangulation<dim> tria;
GridGenerator::hyper_cube(tria);
FE_Q<dim> fe1(1);
FE_Q1_Nonlocal<dim> fe2(tria);

FE_System<dim> fe(fe1, 1, fe2, 1);

tria.refine_global(1);
DoFHandler<dim> dh(tria);

dh.distribute_dofs(fe);

Tensor<1, dim> ones;
for (unsigned int d = 0; d < dim; ++d)
ones[d] = 1;

Vector<double> solution(dh.n_dofs());

VectorTools::interpolate(dh, Functions::Monomial<dim>(ones, 2), solution);

deallog << solution << std::endl;
}

int
main()
{
initlog();

test<1>();
test<2>();
test<3>();
}
Empty file.