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
Add ReferenceCell::volume() and ::barycenter(). #13678
Conversation
So updated. |
tests/grid/reference_cell_type_02.cc
Outdated
std::unique_ptr<FiniteElement<dim>> fe; | ||
if (reference_cell == ReferenceCells::Line) | ||
fe = std::make_unique<FE_Q<dim>>(1); | ||
else if (reference_cell == ReferenceCells::Triangle) | ||
fe = std::make_unique<FE_SimplexP<dim>>(1); | ||
else if (reference_cell == ReferenceCells::Quadrilateral) | ||
fe = std::make_unique<FE_Q<dim>>(1); | ||
else if (reference_cell == ReferenceCells::Tetrahedron) | ||
fe = std::make_unique<FE_SimplexP<dim>>(1); | ||
else if (reference_cell == ReferenceCells::Wedge) | ||
fe = std::make_unique<FE_WedgeP<dim>>(1); | ||
else if (reference_cell == ReferenceCells::Pyramid) | ||
fe = std::make_unique<FE_PyramidP<dim>>(1); | ||
else if (reference_cell == ReferenceCells::Hexahedron) | ||
fe = std::make_unique<FE_Q<dim>>(1); | ||
|
||
// Set up the objects to compute an integral on the reference cell | ||
FEValues<dim> fe_values(*fe, *q, update_JxW_values); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for nit-picking, but shouldn't this work:
std::unique_ptr<FiniteElement<dim>> fe; | |
if (reference_cell == ReferenceCells::Line) | |
fe = std::make_unique<FE_Q<dim>>(1); | |
else if (reference_cell == ReferenceCells::Triangle) | |
fe = std::make_unique<FE_SimplexP<dim>>(1); | |
else if (reference_cell == ReferenceCells::Quadrilateral) | |
fe = std::make_unique<FE_Q<dim>>(1); | |
else if (reference_cell == ReferenceCells::Tetrahedron) | |
fe = std::make_unique<FE_SimplexP<dim>>(1); | |
else if (reference_cell == ReferenceCells::Wedge) | |
fe = std::make_unique<FE_WedgeP<dim>>(1); | |
else if (reference_cell == ReferenceCells::Pyramid) | |
fe = std::make_unique<FE_PyramidP<dim>>(1); | |
else if (reference_cell == ReferenceCells::Hexahedron) | |
fe = std::make_unique<FE_Q<dim>>(1); | |
// Set up the objects to compute an integral on the reference cell | |
FEValues<dim> fe_values(*fe, *q, update_JxW_values); | |
FE_Nothing<dim> fe; | |
// Set up the objects to compute an integral on the reference cell | |
FEValues<dim> fe_values(fe, *q, update_JxW_values); |
Since you never evaluate any of the shape functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would hope this does not work ;) But there is a FE_Nothing
version that takes a reference cell!
tests/grid/reference_cell_type_03.cc
Outdated
std::unique_ptr<FiniteElement<dim>> fe; | ||
if (reference_cell == ReferenceCells::Line) | ||
fe = std::make_unique<FE_Q<dim>>(1); | ||
else if (reference_cell == ReferenceCells::Triangle) | ||
fe = std::make_unique<FE_SimplexP<dim>>(1); | ||
else if (reference_cell == ReferenceCells::Quadrilateral) | ||
fe = std::make_unique<FE_Q<dim>>(1); | ||
else if (reference_cell == ReferenceCells::Tetrahedron) | ||
fe = std::make_unique<FE_SimplexP<dim>>(1); | ||
else if (reference_cell == ReferenceCells::Wedge) | ||
fe = std::make_unique<FE_WedgeP<dim>>(1); | ||
else if (reference_cell == ReferenceCells::Pyramid) | ||
fe = std::make_unique<FE_PyramidP<dim>>(1); | ||
else if (reference_cell == ReferenceCells::Hexahedron) | ||
fe = std::make_unique<FE_Q<dim>>(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
std::unique_ptr<FiniteElement<dim>> fe; | |
if (reference_cell == ReferenceCells::Line) | |
fe = std::make_unique<FE_Q<dim>>(1); | |
else if (reference_cell == ReferenceCells::Triangle) | |
fe = std::make_unique<FE_SimplexP<dim>>(1); | |
else if (reference_cell == ReferenceCells::Quadrilateral) | |
fe = std::make_unique<FE_Q<dim>>(1); | |
else if (reference_cell == ReferenceCells::Tetrahedron) | |
fe = std::make_unique<FE_SimplexP<dim>>(1); | |
else if (reference_cell == ReferenceCells::Wedge) | |
fe = std::make_unique<FE_WedgeP<dim>>(1); | |
else if (reference_cell == ReferenceCells::Pyramid) | |
fe = std::make_unique<FE_PyramidP<dim>>(1); | |
else if (reference_cell == ReferenceCells::Hexahedron) | |
fe = std::make_unique<FE_Q<dim>>(1); | |
FE_Nothing<dim> fe; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK apart from the comments regarding the test.
I had assumed that So fixed now! |
else if (reference_cell == ReferenceCells::Pyramid) | ||
q = std::make_unique<QGaussPyramid<dim>>(2); | ||
else if (reference_cell == ReferenceCells::Hexahedron) | ||
q = std::make_unique<QGauss<dim>>(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also picky, but we could use ReferenceCell::get_gauss_type_quadrature(2))
here for improved genericity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you allow me to do this as a follow-up for cloned tests? I think there is value in testing the equivalence of the output since what constitutes a "Gauss" formula is not unique for anything other than tensor-product formulas (and the function you propose may or may not return the formulas I use above).
else if (reference_cell == ReferenceCells::Pyramid) | ||
q = std::make_unique<QGaussPyramid<dim>>(2); | ||
else if (reference_cell == ReferenceCells::Hexahedron) | ||
q = std::make_unique<QGauss<dim>>(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
I've needed something like a midpoint quadrature in ASPECT, and that turned out to be surprisingly difficult to generate for general cell shapes. Knowing the volume and barycenter is a good first step.
/rebuild