Hello all,
I have found an unexpected behavior in using the FEInterfaceValues object.
Namely, it seems that a line like,
fe_interface_values.get_fe_face_values(1).get_function_values(...);
returns the following error
> The violated condition was:
> cell_index == 0 || !at_boundary()
> Additional information:
> You are on a boundary, so you can only ask for the first FEFaceValues
object.
...if the cell is on a boundary, but the face is an interior face.
I've attached code for a small test case illustrating the issue. It
consists of a 2x2 2D mesh, and attempts to use FEInterfaceValues to get
field values from the cell "above".
Is this indeed a bug, or am I misunderstanding the intended usage of
FEInterfaceValues? I'm using deal.II, version 9.2.0.
Best,
Corbin
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dealii/22813e93-5959-4244-aa45-1652d3e8c7b8n%40googlegroups.com.
// empty integration test
//
#include <iostream>
#include <fstream>
// deal ii imports
#include <deal.II/grid/tria.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/tria.h>
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_refinement.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/numerics/data_out.h>
#include <deal.II/numerics/vector_tools.h>
#include <deal.II/fe/fe_dgq.h>
#include <deal.II/fe/fe_interface_values.h>
using namespace dealii;
template<int dim>
struct ScratchData
{
FEValues<dim> fe_values;
FEInterfaceValues<dim> fe_interface_values;
std::vector<std::vector<unsigned int>> fe_local_support_on_face;
ScratchData(const Mapping<dim> &mapping,
const FiniteElement<dim> &fe,
const Quadrature<dim> &cell_quadrature,
const Quadrature<dim-1> &face_quadrature,
const UpdateFlags cell_update_flags = update_values
| update_gradients
| update_quadrature_points
| update_JxW_values,
const UpdateFlags interface_update_flags = update_values
| update_quadrature_points
| update_JxW_values
| update_normal_vectors)
: fe_values(mapping, fe, cell_quadrature, cell_update_flags)
, fe_interface_values(mapping, fe, face_quadrature, interface_update_flags)
, fe_local_support_on_face(GeometryInfo<dim>::faces_per_cell)
{
for (unsigned int face_no : GeometryInfo<dim>::face_indices())
for (unsigned int i = 0; i < fe.dofs_per_cell; ++i)
{
if (fe.has_support_on_face(i, face_no))
fe_local_support_on_face[face_no].push_back(i);
}
}
};
int main()
{
const int dim = 2;
// create an [NN]^2 grid
std::vector<unsigned int> repetitions{2,2};
const Point<dim> bottom_left(0.0, 0.0);
const Point<dim> top_right(1.0, 1.0);
Triangulation<dim> volume_mesh;
GridGenerator::subdivided_hyper_rectangle(volume_mesh, repetitions, bottom_left, top_right);
// DG elements over the mesh
const unsigned int p_order = 3;
FE_DGQ<dim> fe(p_order);
DoFHandler<dim> dof_handler(volume_mesh);
dof_handler.distribute_dofs(fe);
// interior field phi = 1, to be integrated
Vector<double> field;
field.reinit(dof_handler.n_dofs());
VectorTools::interpolate(dof_handler, ConstantFunction<dim>(1.0), field);
// create FE values, interface values via scratchdata
MappingQ1<dim> mapping;
const QGauss<dim> quadrature(fe.degree + 1);
const QGauss<dim - 1> face_quadrature(fe.degree + 1);
ScratchData<dim> sd(mapping, fe, quadrature, face_quadrature);
for (const auto &cell : dof_handler.active_cell_iterators())
{
sd.fe_values.reinit(cell);
// face loop
for (const auto face_index : GeometryInfo<dim>::face_indices())
{
sd.fe_interface_values.reinit(cell, face_index);
const std::vector<Tensor<1, dim>> &nrml = sd.fe_interface_values.get_fe_face_values(0).get_normal_vectors();
// if top face (and not boundary face, just to be sure)
if (nrml[0][1] > 0 && !(cell->face(face_index)->at_boundary()))
{
std::cout << "cell " << cell << " at " << cell->center()[0] << " " << cell->center()[1] << std::endl;
const double center_x = cell->face(face_index)->center()(0);
const double center_y = cell->face(face_index)->center()(1);
std::cout << "face " << face_index << " at " << center_x << " " << center_y << std::endl;
std::vector<double> field_at_qpts(sd.fe_interface_values.n_quadrature_points);
// this line fails, with the error message:
// >>> The violated condition was: cell_index == 0 || !at_boundary()
// >>> Additional information: You are on a boundary, so you can only ask for the first FEFaceValues object.
// if I change get_face_values(1) to get_face_values(0), everything is fine
//
// it seems to be upset that we're on a cell boundary, but the interface is not a boundary interface
sd.fe_interface_values.get_fe_face_values(1).get_function_values(field, field_at_qpts);
}
}
}
return 0;
}