-
Notifications
You must be signed in to change notification settings - Fork 3
Fe br #8
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
base: master
Are you sure you want to change the base?
Fe br #8
Changes from 8 commits
c3ca881
4873bf9
d83be4b
4dcecfd
1f53354
19cb379
d180b1a
760b276
1a9ba9f
c14d37f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,9 +207,12 @@ class FE_PolyTensor : public FiniteElement<dim, spacedim> | |
| protected: | ||
| /** | ||
| * The mapping type to be used to map shape functions from the reference | ||
| * cell to the mesh cell. | ||
| * cell to the mesh cell. If this vector is length one, the same mapping | ||
| * will be applied to all shape functions. If the vector size is equal to | ||
| * the finite element dofs per cell, then each shape function will be mapped | ||
| * according to the corresponding entry in the vector. | ||
| */ | ||
| MappingType mapping_type; | ||
| std::vector<MappingType> mapping_type; | ||
|
|
||
|
|
||
| /* NOTE: The following function has its definition inlined into the class | ||
|
|
@@ -245,11 +248,33 @@ class FE_PolyTensor : public FiniteElement<dim, spacedim> | |
| // initialize fields only if really | ||
| // necessary. otherwise, don't | ||
| // allocate memory | ||
|
|
||
| bool update_transformed_shape_values = false; | ||
| bool update_transformed_shape_grads = false; | ||
| bool update_transformed_shape_hessian_tensors = false; | ||
|
|
||
| for (unsigned int i = 0; i < this->mapping_type.size(); ++i) | ||
| { | ||
| MappingType mapping_type = this->mapping_type[i]; | ||
|
|
||
| if (mapping_type != mapping_none) | ||
| update_transformed_shape_values = true; | ||
|
|
||
| if ((mapping_type == mapping_raviart_thomas) || | ||
| (mapping_type == mapping_piola) || | ||
| (mapping_type == mapping_nedelec) || | ||
| (mapping_type == mapping_contravariant)) | ||
| update_transformed_shape_grads = true; | ||
|
||
|
|
||
| if (mapping_type != mapping_none) | ||
| update_transformed_shape_hessian_tensors = true; | ||
|
||
| } | ||
|
|
||
| if (update_flags & update_values) | ||
| { | ||
| values.resize(this->dofs_per_cell); | ||
| data->shape_values.reinit(this->dofs_per_cell, n_q_points); | ||
| if (mapping_type != mapping_none) | ||
| if (update_transformed_shape_values) | ||
| data->transformed_shape_values.resize(n_q_points); | ||
| } | ||
|
|
||
|
|
@@ -259,10 +284,7 @@ class FE_PolyTensor : public FiniteElement<dim, spacedim> | |
| data->shape_grads.reinit(this->dofs_per_cell, n_q_points); | ||
| data->transformed_shape_grads.resize(n_q_points); | ||
|
|
||
| if ((mapping_type == mapping_raviart_thomas) || | ||
| (mapping_type == mapping_piola) || | ||
| (mapping_type == mapping_nedelec) || | ||
| (mapping_type == mapping_contravariant)) | ||
| if (update_transformed_shape_grads) | ||
| data->untransformed_shape_grads.resize(n_q_points); | ||
| } | ||
|
|
||
|
|
@@ -271,7 +293,7 @@ class FE_PolyTensor : public FiniteElement<dim, spacedim> | |
| grad_grads.resize(this->dofs_per_cell); | ||
| data->shape_grad_grads.reinit(this->dofs_per_cell, n_q_points); | ||
| data->transformed_shape_hessians.resize(n_q_points); | ||
| if (mapping_type != mapping_none) | ||
| if (update_transformed_shape_hessian_tensors) | ||
| data->untransformed_shape_hessian_tensors.resize(n_q_points); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,25 @@ FE_BernardiRaugel<dim>::FE_BernardiRaugel(const unsigned int p) | |
|
|
||
| // const unsigned int n_dofs = this->dofs_per_cell; | ||
|
|
||
| this->mapping_type = mapping_none; | ||
| if(dim==2) | ||
| this->mapping_type = {mapping_none, mapping_none, | ||
| mapping_none, mapping_none, | ||
| mapping_none, mapping_none, | ||
| mapping_none, mapping_none, | ||
| mapping_piola, mapping_piola, | ||
| mapping_piola, mapping_piola}; | ||
|
||
| else if(dim==3) | ||
| this->mapping_type = {mapping_none, mapping_none, mapping_none, | ||
| mapping_none, mapping_none, mapping_none, | ||
| mapping_none, mapping_none, mapping_none, | ||
| mapping_none, mapping_none, mapping_none, | ||
| mapping_none, mapping_none, mapping_none, | ||
| mapping_none, mapping_none, mapping_none, | ||
| mapping_none, mapping_none, mapping_none, | ||
| mapping_none, mapping_none, mapping_none, | ||
| mapping_piola, mapping_piola, | ||
| mapping_piola, mapping_piola, | ||
| mapping_piola, mapping_piola}; | ||
|
||
| // These must be done first, since | ||
| // they change the evaluation of | ||
| // basis functions | ||
|
|
@@ -178,6 +196,34 @@ FE_BernardiRaugel<dim>::initialize_support_points() | |
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
| template <int dim> | ||
| void | ||
| FE_BernardiRaugel<dim>::fill_fe_values( | ||
| const typename Triangulation<dim, dim>::cell_iterator &cell, | ||
| const CellSimilarity::Similarity cell_similarity, | ||
| const Quadrature<dim> & quadrature, | ||
| const Mapping<dim, dim> & mapping, | ||
| const typename Mapping<dim, dim>::InternalDataBase &mapping_internal, | ||
| const dealii::internal::FEValuesImplementation::MappingRelatedData<dim, | ||
| dim> | ||
| & mapping_data, | ||
| const typename FiniteElement<dim, dim>::InternalDataBase &fe_internal, | ||
| dealii::internal::FEValuesImplementation::FiniteElementRelatedData<dim, | ||
| dim> | ||
| &output_data) const | ||
| { | ||
| FE_PolyTensor<PolynomialsBernardiRaugel<dim>, dim, dim>::fill_fe_values(cell, | ||
| cell_similarity, | ||
| quadrature, | ||
| mapping, | ||
| mapping_internal, | ||
| mapping_data, | ||
| fe_internal, | ||
| output_data); | ||
| } | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's what I had in mind. Now you'll just have to overwrite what this function has computed for the four last shape functions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I like that idea. I stopped here because I need to read what kind of data or structure is sitting in |
||
|
|
||
| template class FE_BernardiRaugel<1>; | ||
| template class FE_BernardiRaugel<2>; | ||
| template class FE_BernardiRaugel<3>; | ||
|
|
||
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.
In essence, what you're doing here is determine whether any of the elements of the vector are different from
mapping_none. (And similarly in the next few lines.) You can write this more concisely in the following way (see https://en.cppreference.com/w/cpp/algorithm/find):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.
This command is a mouthful. Let me see... so this command locates any entry between begin or end satisfies the inline function (what's the C++ word for that?) that returns true if the mapping type is not mapping_none. I assume the default return is
.end()if nothing is found?Should that be
.end()on the second line? Also, if we usereturn t != mapping_none, shouldn't we use find_if instead of find_if_not?And if I were to do this for transformed_shape_grads, would it look like this?
If so, then I think I understand how this works and I can implement it.
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.
Oh is that called a "lambda expression"? This is something I haven't explored much of before.
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.
Yes:
.end()in the second line.find_ifcan't find an entry that satisfies the lambda function, then it returns.end().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.
https://en.wikipedia.org/wiki/Anonymous_function#C%2B%2B_%28since_C%2B%2B11%29