24 #ifndef _IntegratorMultiMesh_H_
25 #define _IntegratorMultiMesh_H_
27 #include <lac/vector.h>
28 #include <lac/block_sparsity_pattern.h>
29 #include <lac/block_sparse_matrix.h>
31 #include <numerics/matrix_tools.h>
32 #include <numerics/vector_tools.h>
33 #include <deal.II/grid/grid_tools.h>
34 #include <base/function.h>
60 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
72 template<
typename PROBLEM>
75 bool apply_boundary_values =
true);
76 template<
typename PROBLEM>
79 bool apply_boundary_values =
true);
80 template<
typename PROBLEM>
83 bool apply_boundary_values =
true);
84 template<
typename PROBLEM,
typename MATRIX>
88 template<
typename PROBLEM>
90 template<
typename PROBLEM>
93 template<
typename PROBLEM>
96 template<
typename PROBLEM>
99 template<
typename PROBLEM>
102 template<
typename PROBLEM>
105 template<
typename PROBLEM>
109 template<
typename PROBLEM>
112 template<
typename PROBLEM>
115 template<
typename PROBLEM,
typename MATRIX>
124 inline const std::map<std::string, const VECTOR*>&
128 AddParamData(std::string name,
const dealii::Vector<SCALAR>* new_data);
131 inline const std::map<std::string, const dealii::Vector<SCALAR>*>&
134 inline INTEGRATORDATACONT&
138 template<
template<
int,
int>
class DH>
140 InterpolateBoundaryValues(
142 const unsigned int color,
const dealii::Function<dim>&
function,
143 std::map<unsigned int, SCALAR>& boundary_values,
144 const std::vector<bool>& comp_mask)
const;
150 template<
typename PROBLEM,
template<
int,
int>
class DH>
151 inline void ComputeNonlinearResidual_Recursive(
154 typename std::vector<
typename DH<dim, dim>::cell_iterator>& element_iter,
155 typename std::vector<
typename dealii::Triangulation<dim>::cell_iterator>& tria_element_iter,
156 const FullMatrix<SCALAR>& prolong_matrix,
unsigned int coarse_index,
unsigned int fine_index,
164 template<
typename PROBLEM,
template<
int,
int>
class DH>
165 inline void ComputeNonlinearRhs_Recursive(
168 typename std::vector<
typename DH<dim, dim>::cell_iterator>& element_iter,
169 typename std::vector<
typename dealii::Triangulation<dim>::cell_iterator>& tria_element_iter,
170 const FullMatrix<SCALAR>& prolong_matrix,
unsigned int coarse_index,
unsigned int fine_index,
178 template<
typename PROBLEM,
typename MATRIX,
template<
int,
int>
class DH>
179 inline void ComputeMatrix_Recursive(
182 typename std::vector<
typename DH<dim, dim>::cell_iterator>& element_iter,
183 typename std::vector<
typename dealii::Triangulation<dim>::cell_iterator>& tria_element_iter,
184 const FullMatrix<SCALAR>& prolong_matrix,
unsigned int coarse_index,
unsigned int fine_index,
192 template<
typename PROBLEM,
template<
int,
int>
class DH>
193 inline SCALAR ComputeDomainScalar_Recursive(
195 typename std::vector<
typename DH<dim, dim>::cell_iterator>& element_iter,
196 typename std::vector<
typename dealii::Triangulation<dim>::cell_iterator>& tria_element_iter,
197 const FullMatrix<SCALAR>& prolong_matrix,
unsigned int coarse_index,
unsigned int fine_index,
204 template<
typename PROBLEM,
template<
int,
int>
class DH>
205 inline SCALAR ComputeBoundaryScalar_Recursive(
207 typename std::vector<
typename DH<dim, dim>::cell_iterator>& element_iter,
208 typename std::vector<
typename dealii::Triangulation<dim>::cell_iterator>& tria_element_iter,
209 const FullMatrix<SCALAR>& prolong_matrix,
unsigned int coarse_index,
unsigned int fine_index,
212 INTEGRATORDATACONT & _idc;
214 std::map<std::string, const VECTOR*> _domain_data;
215 std::map<std::string, const dealii::Vector<SCALAR>*> _param_data;
220 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
223 INTEGRATORDATACONT& idc) :
230 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
239 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
249 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
251 template<
typename PROBLEM>
254 PROBLEM& pde, VECTOR &residual,
bool apply_boundary_values)
258 const auto& dof_handler =
259 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
261 assert(dof_handler.size() == 2);
263 const auto tria_element_list = GridTools::get_finest_common_cells (dof_handler[0]->GetDEALDoFHandler().get_tria(),
264 dof_handler[1]->GetDEALDoFHandler().get_tria());
265 const auto element_list = GridTools::get_finest_common_cells (dof_handler[0]->GetDEALDoFHandler(),
266 dof_handler[1]->GetDEALDoFHandler());
268 auto element_iter = element_list.begin();
269 auto tria_element_iter = tria_element_list.begin();
271 std::vector<decltype(tria_element_iter->first)> tria_element(2);
272 tria_element[0] = tria_element_iter->first;
273 tria_element[1] = tria_element_iter->second;
275 std::vector<decltype(element_iter->first)> element(2);
276 element[0] = element_iter->first;
277 element[1] = element_iter->second;
278 int coarse_index = 0;
282 _idc.InitializeMMEDC(pde.GetUpdateFlags(),
283 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element, tria_element,
284 this->GetParamData(), this->GetDomainData());
285 auto& edc = _idc.GetMultimeshElementDataContainer();
287 bool need_interfaces = pde.HasInterfaces();
288 _idc.InitializeMMFDC(pde.GetFaceUpdateFlags(),
289 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
292 this->GetParamData(),
293 this->GetDomainData(),
295 auto& fdc = _idc.GetMultimeshFaceDataContainer();
297 for(; element_iter != element_list.end(); element_iter++)
299 element[0] = element_iter->first;
300 element[1] = element_iter->second;
301 tria_element[0] = tria_element_iter->first;
302 tria_element[1] = tria_element_iter->second;
303 FullMatrix<SCALAR> prolong_matrix;
305 if(element[0]->has_children())
307 prolong_matrix = IdentityMatrix(element[1]->get_fe().dofs_per_cell);
313 if(element[1]->has_children())
315 prolong_matrix = IdentityMatrix(element[0]->get_fe().dofs_per_cell);
321 assert(element.size() ==2);
322 coarse_index = fine_index = 2;
325 ComputeNonlinearResidual_Recursive(pde,residual,element,tria_element,prolong_matrix,coarse_index,fine_index,edc,fdc);
329 if (apply_boundary_values)
331 ApplyNewtonBoundaryValues(pde, residual);
337 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
339 template<
typename PROBLEM>
342 PROBLEM& pde, VECTOR &residual,
bool apply_boundary_values)
345 throw DOpEException(
"This function needs to be implemented!",
"IntegratorMultiMesh::ComputeNonlinearLhs");
351 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
353 template<
typename PROBLEM>
356 PROBLEM& pde, VECTOR &residual,
bool apply_boundary_values)
360 const auto& dof_handler =
361 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
363 assert(dof_handler.size() == 2);
365 const auto tria_element_list = GridTools::get_finest_common_cells (dof_handler[0]->GetDEALDoFHandler().get_tria(),
366 dof_handler[1]->GetDEALDoFHandler().get_tria());
367 const auto element_list = GridTools::get_finest_common_cells (dof_handler[0]->GetDEALDoFHandler(),
368 dof_handler[1]->GetDEALDoFHandler());
370 auto element_iter = element_list.begin();
371 auto tria_element_iter = tria_element_list.begin();
373 std::vector<decltype(tria_element_iter->first)> tria_element(2);
374 tria_element[0] = tria_element_iter->first;
375 tria_element[1] = tria_element_iter->second;
377 std::vector<decltype(element_iter->first)> element(2);
378 element[0] = element_iter->first;
379 element[1] = element_iter->second;
380 int coarse_index = 0;
384 _idc.InitializeMMEDC(pde.GetUpdateFlags(),
385 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element, tria_element,
386 this->GetParamData(), this->GetDomainData());
387 auto& edc = _idc.GetMultimeshElementDataContainer();
389 _idc.InitializeMMFDC(pde.GetFaceUpdateFlags(),
390 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
393 this->GetParamData(),
394 this->GetDomainData());
395 auto& fdc = _idc.GetMultimeshFaceDataContainer();
397 for(; element_iter != element_list.end(); element_iter++)
399 element[0] = element_iter->first;
400 element[1] = element_iter->second;
401 tria_element[0] = tria_element_iter->first;
402 tria_element[1] = tria_element_iter->second;
403 FullMatrix<SCALAR> prolong_matrix;
405 if(element[0]->has_children())
407 prolong_matrix = IdentityMatrix(element[1]->get_fe().dofs_per_cell);
413 if(element[1]->has_children())
415 prolong_matrix = IdentityMatrix(element[0]->get_fe().dofs_per_cell);
421 assert(element.size() ==2);
422 coarse_index = fine_index = 2;
425 ComputeNonlinearRhs_Recursive(pde,residual,element,tria_element,prolong_matrix,coarse_index,fine_index,edc,fdc);
429 if (apply_boundary_values)
431 ApplyNewtonBoundaryValues(pde, residual);
437 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
439 template<
typename PROBLEM,
typename MATRIX>
442 PROBLEM& pde, MATRIX &matrix)
446 const auto& dof_handler =
447 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
449 assert(dof_handler.size() == 2);
451 const auto tria_element_list = GridTools::get_finest_common_cells (dof_handler[0]->GetDEALDoFHandler().get_tria(),
452 dof_handler[1]->GetDEALDoFHandler().get_tria());
453 const auto element_list = GridTools::get_finest_common_cells (dof_handler[0]->GetDEALDoFHandler(),
454 dof_handler[1]->GetDEALDoFHandler());
456 auto element_iter = element_list.begin();
457 auto tria_element_iter = tria_element_list.begin();
459 std::vector<decltype(tria_element_iter->first)> tria_element(2);
460 tria_element[0] = tria_element_iter->first;
461 tria_element[1] = tria_element_iter->second;
463 std::vector<decltype(element_iter->first)> element(2);
464 element[0] = element_iter->first;
465 element[1] = element_iter->second;
466 int coarse_index = 0;
470 _idc.InitializeMMEDC(pde.GetUpdateFlags(),
471 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element, tria_element,
472 this->GetParamData(), this->GetDomainData());
473 auto& edc = _idc.GetMultimeshElementDataContainer();
475 bool need_interfaces = pde.HasInterfaces();
476 _idc.InitializeMMFDC(pde.GetFaceUpdateFlags(),
477 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
480 this->GetParamData(),
481 this->GetDomainData(),
483 auto & fdc = _idc.GetMultimeshFaceDataContainer();
485 for(; element_iter != element_list.end(); element_iter++)
487 element[0] = element_iter->first;
488 element[1] = element_iter->second;
489 tria_element[0] = tria_element_iter->first;
490 tria_element[1] = tria_element_iter->second;
491 FullMatrix<SCALAR> prolong_matrix;
493 if(element[0]->has_children())
495 prolong_matrix = IdentityMatrix(element[1]->get_fe().dofs_per_cell);
501 if(element[1]->has_children())
503 prolong_matrix = IdentityMatrix(element[0]->get_fe().dofs_per_cell);
509 assert(element.size() ==2);
510 coarse_index = fine_index = 2;
513 ComputeMatrix_Recursive(pde,matrix,element,tria_element,prolong_matrix,coarse_index,fine_index,edc,fdc);
518 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
520 template<
typename PROBLEM>
527 const auto& dof_handler =
528 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
530 assert(dof_handler.size() == 2);
532 const auto tria_element_list = GridTools::get_finest_common_cells (dof_handler[0]->GetDEALDoFHandler().get_tria(),
533 dof_handler[1]->GetDEALDoFHandler().get_tria());
534 const auto element_list = GridTools::get_finest_common_cells (dof_handler[0]->GetDEALDoFHandler(),
535 dof_handler[1]->GetDEALDoFHandler());
537 auto element_iter = element_list.begin();
538 auto tria_element_iter = tria_element_list.begin();
540 std::vector<decltype(tria_element_iter->first)> tria_element(2);
541 tria_element[0] = tria_element_iter->first;
542 tria_element[1] = tria_element_iter->second;
544 std::vector<decltype(element_iter->first)> element(2);
545 element[0] = element_iter->first;
546 element[1] = element_iter->second;
547 int coarse_index = 0;
552 throw DOpEException(
"This function should not be called when faces are needed!",
553 "IntegratorMultiMesh::ComputeDomainScalar");
557 _idc.InitializeMMEDC(pde.GetUpdateFlags(),
558 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element, tria_element,
559 this->GetParamData(), this->GetDomainData());
560 auto& edc = _idc.GetMultimeshElementDataContainer();
562 for(; element_iter != element_list.end(); element_iter++)
564 element[0] = element_iter->first;
565 element[1] = element_iter->second;
566 tria_element[0] = tria_element_iter->first;
567 tria_element[1] = tria_element_iter->second;
568 FullMatrix<SCALAR> prolong_matrix;
570 if(element[0]->has_children())
572 prolong_matrix = IdentityMatrix(element[1]->get_fe().dofs_per_cell);
578 if(element[1]->has_children())
580 prolong_matrix = IdentityMatrix(element[0]->get_fe().dofs_per_cell);
586 assert(element.size() ==2);
587 coarse_index = fine_index = 2;
590 ret += ComputeDomainScalar_Recursive(pde,element,tria_element,prolong_matrix,coarse_index,fine_index,edc);
599 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
601 template<
typename PROBLEM>
609 ret += pde.PointFunctional(this->GetParamData(),
610 this->GetDomainData());
617 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
619 template<
typename PROBLEM>
627 const auto& dof_handler =
628 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
630 const auto tria_element_list = GridTools::get_finest_common_cells (dof_handler[0]->GetDEALDoFHandler().get_tria(),
631 dof_handler[1]->GetDEALDoFHandler().get_tria());
632 const auto element_list = GridTools::get_finest_common_cells (dof_handler[0]->GetDEALDoFHandler(),
633 dof_handler[1]->GetDEALDoFHandler());
635 auto element_iter = element_list.begin();
636 auto tria_element_iter = tria_element_list.begin();
638 std::vector<decltype(tria_element_iter->first)> tria_element(2);
639 tria_element[0] = tria_element_iter->first;
640 tria_element[1] = tria_element_iter->second;
642 std::vector<decltype(element_iter->first)> element(2);
643 element[0] = element_iter->first;
644 element[1] = element_iter->second;
645 int coarse_index = 0;
649 _idc.InitializeMMFDC(pde.GetFaceUpdateFlags(),
650 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
651 element, tria_element,
652 this->GetParamData(),
653 this->GetDomainData());
654 auto & fdc = _idc.GetMultimeshFaceDataContainer();
656 std::vector<unsigned int> boundary_functional_colors = pde.GetBoundaryFunctionalColors();
657 bool need_boundary_integrals = (boundary_functional_colors.size() > 0);
658 if(!need_boundary_integrals)
660 throw DOpEException(
"No boundary colors given!",
"IntegratorMultiMesh::ComputeBoundaryScalar");
663 for(; element_iter != element_list.end(); element_iter++)
665 element[0] = element_iter->first;
666 element[1] = element_iter->second;
667 tria_element[0] = tria_element_iter->first;
668 tria_element[1] = tria_element_iter->second;
669 FullMatrix<SCALAR> prolong_matrix;
671 if(element[0]->has_children())
673 prolong_matrix = IdentityMatrix(element[1]->get_fe().dofs_per_cell);
679 if(element[1]->has_children())
681 prolong_matrix = IdentityMatrix(element[0]->get_fe().dofs_per_cell);
687 assert(element.size() ==2);
688 coarse_index = fine_index = 2;
691 ret += ComputeBoundaryScalar_Recursive(pde,element,tria_element,prolong_matrix,coarse_index,fine_index,fdc);
699 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
701 template<
typename PROBLEM>
707 throw DOpEException(
"This function needs to be implemented!",
"IntegratorMultiMesh::ComputeFaceScalar");
765 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
767 template<
typename PROBLEM>
775 ret = pde.AlgebraicFunctional(this->GetParamData(),
776 this->GetDomainData());
783 template <
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
int dim>
784 template<
typename PROBLEM>
789 pde.AlgebraicResidual(residual,this->GetParamData(),this->GetDomainData());
794 template <
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
int dim>
795 template<
typename PROBLEM>
800 pde.ComputeLocalControlConstraints(constraints,this->GetParamData(),this->GetDomainData());
805 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
807 template<
typename PROBLEM>
810 PROBLEM& pde, VECTOR &u)
817 std::vector<unsigned int> dirichlet_colors = pde.GetDirichletColors();
818 for (
unsigned int i = 0; i < dirichlet_colors.size(); i++)
820 unsigned int color = dirichlet_colors[i];
821 std::vector<bool> comp_mask = pde.GetDirichletCompMask(color);
822 std::map<unsigned int, SCALAR> boundary_values;
824 InterpolateBoundaryValues(pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler()[0], color, pde.GetDirichletValues(color, this->GetParamData(),
825 this->GetDomainData()), boundary_values, comp_mask );
827 for (
typename std::map<unsigned int, SCALAR>::const_iterator p =
828 boundary_values.begin(); p != boundary_values.end(); p++)
830 u(p->first) = p->second;
837 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
839 template<
typename PROBLEM>
842 PROBLEM& pde, VECTOR &u)
847 pde.GetDoFConstraints().condense(u);
848 std::vector<unsigned int> dirichlet_colors = pde.GetDirichletColors();
849 for (
unsigned int i = 0; i < dirichlet_colors.size(); i++)
851 unsigned int color = dirichlet_colors[i];
852 std::vector<bool> comp_mask = pde.GetDirichletCompMask(color);
853 std::map<unsigned int, SCALAR> boundary_values;
856 InterpolateBoundaryValues(
857 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler()[0],
858 color, dealii::ZeroFunction<dim>(comp_mask.size()),
859 boundary_values, comp_mask);
861 for (
typename std::map<unsigned int, SCALAR>::const_iterator p =
862 boundary_values.begin(); p != boundary_values.end(); p++)
864 u(p->first) = p->second;
870 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
872 template<
typename PROBLEM,
typename MATRIX>
875 PROBLEM& pde, MATRIX& matrix, VECTOR &rhs, VECTOR &sol)
879 pde.GetDoFConstraints().condense(rhs);
880 pde.GetDoFConstraints().condense(matrix);
881 std::vector<unsigned int> dirichlet_colors = pde.GetDirichletColors();
882 for (
unsigned int i = 0; i < dirichlet_colors.size(); i++)
884 unsigned int color = dirichlet_colors[i];
885 std::vector<bool> comp_mask = pde.GetDirichletCompMask(color);
886 std::map<unsigned int, SCALAR> boundary_values;
888 InterpolateBoundaryValues(
889 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler()[0],
890 color, dealii::ZeroFunction<dim>(comp_mask.size()),
891 boundary_values, comp_mask);
893 dealii::MatrixTools::apply_boundary_values(boundary_values, matrix,
900 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
904 std::string name,
const VECTOR* new_data)
906 if (_domain_data.find(name) != _domain_data.end())
909 "Adding multiple Data with name " + name +
" is prohibited!",
910 "IntegratorMultiMesh::AddDomainData");
912 _domain_data.insert(std::pair<std::string, const VECTOR*>(name, new_data));
917 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
923 typename std::map<std::string, const VECTOR *>::iterator it =
924 _domain_data.find(name);
925 if (it == _domain_data.end())
928 "Deleting Data " + name +
" is impossible! Data not found",
929 "IntegratorMultiMesh::DeleteDomainData");
931 _domain_data.erase(it);
936 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
938 const std::map<std::string, const VECTOR*>&
946 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
950 std::string name,
const dealii::Vector<SCALAR>* new_data)
952 if (_param_data.find(name) != _param_data.end())
955 "Adding multiple Data with name " + name +
" is prohibited!",
956 "IntegratorMultiMesh::AddParamData");
959 std::pair<std::string,
const dealii::Vector<SCALAR>*>(name, new_data));
964 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
970 typename std::map<std::string, const dealii::Vector<SCALAR>*>::iterator
971 it = _param_data.find(name);
972 if (it == _param_data.end())
975 "Deleting Data " + name +
" is impossible! Data not found",
976 "IntegratorMultiMesh::DeleteParamData");
978 _param_data.erase(it);
983 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
985 const std::map<std::string, const dealii::Vector<SCALAR>*>&
993 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1004 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1006 template<
template<
int,
int>
class DH>
1010 const unsigned int color,
const dealii::Function<dim>&
function,
1011 std::map<unsigned int, SCALAR>& boundary_values,
1012 const std::vector<bool>& comp_mask)
const
1014 dealii::VectorTools::interpolate_boundary_values(
1016 boundary_values, comp_mask);
1021 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
int dim>
1022 template<
typename PROBLEM,
template<
int,
int>
class DH>
1023 void IntegratorMultiMesh<INTEGRATORDATACONT, VECTOR, SCALAR, dim>::ComputeNonlinearResidual_Recursive(
1026 typename std::vector<
typename DH<dim, dim>::cell_iterator> &element,
1027 typename std::vector<
typename dealii::Triangulation<dim>::cell_iterator> &tria_element,
1028 const FullMatrix<SCALAR>& prolong_matrix,
unsigned int coarse_index,
unsigned int fine_index,
1029 Multimesh_ElementDataContainer<DH, VECTOR, dim>& edc,Multimesh_FaceDataContainer<DH, VECTOR, dim>& fdc)
1031 if(!element[0]->has_children() && ! element[1]->has_children())
1033 unsigned int dofs_per_element;
1034 dealii::Vector<SCALAR> local_vector;
1035 std::vector<unsigned int> local_dof_indices;
1037 bool need_faces = pde.HasFaces();
1038 std::vector<unsigned int> boundary_equation_colors = pde.GetBoundaryEquationColors();
1039 bool need_boundary_integrals = (boundary_equation_colors.size() > 0);
1040 bool need_interfaces = pde.HasInterfaces();
1042 edc.
ReInit(coarse_index,fine_index,prolong_matrix);
1044 dofs_per_element = element[0]->get_fe().dofs_per_cell;
1046 local_vector.reinit(dofs_per_element);
1049 local_dof_indices.resize(0);
1050 local_dof_indices.resize(dofs_per_element, 0);
1054 pde.ElementEquation(edc, local_vector, 1., 1.);
1055 pde.ElementRhs(edc, local_vector, -1.);
1058 if(need_faces || need_interfaces)
1060 throw DOpEException(
" Faces on multiple meshes not implemented yet!",
1061 "IntegratorMultiMesh::ComputeNonlinearResidual_Recursive");
1063 unsigned int b_index = fine_index%2;
1066 if(need_boundary_integrals && element[b_index]->at_boundary())
1068 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1070 if (element[b_index]->face(face)->at_boundary()
1072 (find(boundary_equation_colors.begin(),boundary_equation_colors.end(),
1073 element[b_index]->face(face)->boundary_indicator()) != boundary_equation_colors.end()))
1075 fdc.ReInit(coarse_index,fine_index,prolong_matrix,face);
1076 pde.BoundaryEquation(fdc,local_vector, 1., 1.);
1077 pde.BoundaryRhs(fdc,local_vector,-1.);
1107 if(coarse_index == 0)
1109 dealii::Vector<SCALAR> tmp(dofs_per_element);
1110 prolong_matrix.Tvmult(tmp,local_vector);
1113 element[0]->get_dof_indices(local_dof_indices);
1114 for (
unsigned int i = 0; i < dofs_per_element; ++i)
1116 residual(local_dof_indices[i]) += tmp(i);
1122 element[0]->get_dof_indices(local_dof_indices);
1123 for (
unsigned int i = 0; i < dofs_per_element; ++i)
1125 residual(local_dof_indices[i]) += local_vector(i);
1132 assert(fine_index != coarse_index);
1133 assert(element[fine_index]->has_children());
1134 assert(!element[coarse_index]->has_children());
1135 assert(tria_element[fine_index]->has_children());
1136 assert(!tria_element[coarse_index]->has_children());
1138 unsigned int local_n_dofs = element[coarse_index]->get_fe().dofs_per_cell;
1140 typename DH<dim, dim>::cell_iterator dofh_fine = element[fine_index];
1141 typename dealii::Triangulation<dim>::cell_iterator tria_fine = tria_element[fine_index];
1143 for (
unsigned int child=0; child<GeometryInfo<dim>::max_children_per_cell;++child)
1145 FullMatrix<SCALAR> new_matrix(local_n_dofs);
1146 element[coarse_index]->get_fe().get_prolongation_matrix(child).mmult (new_matrix,
1148 element[fine_index] = dofh_fine->child(child);
1149 tria_element[fine_index] = tria_fine->child(child);
1151 ComputeNonlinearResidual_Recursive(pde,residual,element,tria_element,new_matrix, coarse_index, fine_index, edc, fdc);
1157 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
int dim>
1158 template<
typename PROBLEM,
template<
int,
int>
class DH>
1159 void IntegratorMultiMesh<INTEGRATORDATACONT, VECTOR, SCALAR, dim>::ComputeNonlinearRhs_Recursive(
1162 typename std::vector<
typename DH<dim, dim>::cell_iterator> &element,
1163 typename std::vector<
typename dealii::Triangulation<dim>::cell_iterator> &tria_element,
1164 const FullMatrix<SCALAR>& prolong_matrix,
unsigned int coarse_index,
unsigned int fine_index,
1165 Multimesh_ElementDataContainer<DH, VECTOR, dim>& edc,Multimesh_FaceDataContainer<DH, VECTOR, dim>& fdc)
1167 if(!element[0]->has_children() && ! element[1]->has_children())
1169 unsigned int dofs_per_element;
1170 dealii::Vector<SCALAR> local_vector;
1171 std::vector<unsigned int> local_dof_indices;
1173 bool need_faces = pde.HasFaces();
1174 std::vector<unsigned int> boundary_equation_colors = pde.GetBoundaryEquationColors();
1175 bool need_boundary_integrals = (boundary_equation_colors.size() > 0);
1176 bool need_interfaces = pde.HasInterfaces();
1178 edc.ReInit(coarse_index,fine_index,prolong_matrix);
1180 dofs_per_element = element[0]->get_fe().dofs_per_cell;
1182 local_vector.reinit(dofs_per_element);
1185 local_dof_indices.resize(0);
1186 local_dof_indices.resize(dofs_per_element, 0);
1190 pde.ElementRhs(edc, local_vector, 1.);
1195 throw DOpEException(
" Faces on multiple meshes not implemented yet!",
1196 "IntegratorMultiMesh::ComputeNonlinearRhs_Recursive");
1198 if(need_interfaces )
1200 throw DOpEException(
" Faces on multiple meshes not implemented yet!",
1201 "IntegratorMultiMesh::ComputeNonlinearRhs_Recursive");
1203 unsigned int b_index = fine_index%2;
1206 if(need_boundary_integrals && element[b_index]->at_boundary())
1208 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1210 if (element[b_index]->face(face)->at_boundary()
1212 (find(boundary_equation_colors.begin(),boundary_equation_colors.end(),
1213 element[b_index]->face(face)->boundary_indicator()) != boundary_equation_colors.end()))
1215 fdc.ReInit(coarse_index,fine_index,prolong_matrix,face);
1216 pde.BoundaryRhs(fdc,local_vector,1.);
1231 if(coarse_index == 0)
1233 dealii::Vector<SCALAR> tmp(dofs_per_element);
1234 prolong_matrix.Tvmult(tmp,local_vector);
1237 element[0]->get_dof_indices(local_dof_indices);
1238 for (
unsigned int i = 0; i < dofs_per_element; ++i)
1240 residual(local_dof_indices[i]) += tmp(i);
1246 element[0]->get_dof_indices(local_dof_indices);
1247 for (
unsigned int i = 0; i < dofs_per_element; ++i)
1249 residual(local_dof_indices[i]) += local_vector(i);
1256 assert(fine_index != coarse_index);
1257 assert(element[fine_index]->has_children());
1258 assert(!element[coarse_index]->has_children());
1259 assert(tria_element[fine_index]->has_children());
1260 assert(!tria_element[coarse_index]->has_children());
1262 unsigned int local_n_dofs = element[coarse_index]->get_fe().dofs_per_cell;
1264 typename DH<dim, dim>::cell_iterator dofh_fine = element[fine_index];
1265 typename dealii::Triangulation<dim>::cell_iterator tria_fine = tria_element[fine_index];
1267 for (
unsigned int child=0; child<GeometryInfo<dim>::max_children_per_cell;++child)
1269 FullMatrix<SCALAR> new_matrix(local_n_dofs);
1270 element[coarse_index]->get_fe().get_prolongation_matrix(child).mmult (new_matrix,
1272 element[fine_index] = dofh_fine->child(child);
1273 tria_element[fine_index] = tria_fine->child(child);
1275 ComputeNonlinearRhs_Recursive(pde,residual,element,tria_element,new_matrix, coarse_index, fine_index, edc, fdc);
1282 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1284 template<
typename PROBLEM,
typename MATRIX,
template<
int,
int>
class DH>
1286 IntegratorMultiMesh<INTEGRATORDATACONT, VECTOR, SCALAR, dim>::ComputeMatrix_Recursive(
1287 PROBLEM& pde, MATRIX &matrix,
typename std::vector<
typename DH<dim, dim>::cell_iterator>& element,
1288 typename std::vector<
typename dealii::Triangulation<dim>::cell_iterator>& tria_element,
1289 const FullMatrix<SCALAR>& prolong_matrix,
unsigned int coarse_index,
unsigned int fine_index,
1290 Multimesh_ElementDataContainer<DH, VECTOR, dim>& edc,
1291 Multimesh_FaceDataContainer<DH, VECTOR, dim>& fdc)
1294 if(!element[0]->has_children() && ! element[1]->has_children())
1296 unsigned int dofs_per_element;
1297 std::vector<unsigned int> local_dof_indices;
1299 bool need_faces = pde.HasFaces();
1300 bool need_interfaces = pde.HasInterfaces();
1301 std::vector<unsigned int> boundary_equation_colors = pde.GetBoundaryEquationColors();
1302 bool need_boundary_integrals = (boundary_equation_colors.size() > 0);
1304 edc.ReInit(coarse_index,fine_index,prolong_matrix);
1305 dofs_per_element = element[0]->get_fe().dofs_per_cell;
1307 dealii::FullMatrix<SCALAR> local_matrix(dofs_per_element,
1311 local_dof_indices.resize(0);
1312 local_dof_indices.resize(dofs_per_element, 0);
1313 pde.ElementMatrix(edc, local_matrix);
1316 if(need_faces || need_interfaces)
1318 throw DOpEException(
" Faces on multiple meshes not implemented yet!",
1319 "IntegratorMultiMesh::ComputeMatrix_Recursive");
1321 unsigned int b_index = fine_index%2;
1323 if(need_boundary_integrals && element[b_index]->at_boundary())
1326 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1328 if (element[b_index]->face(face)->at_boundary()
1330 (find(boundary_equation_colors.begin(),boundary_equation_colors.end(),
1331 element[b_index]->face(face)->boundary_indicator()) != boundary_equation_colors.end()))
1333 fdc.ReInit(coarse_index,fine_index,prolong_matrix,face);
1334 pde.BoundaryMatrix(fdc, local_matrix);
1382 if(coarse_index == 0)
1384 dealii::FullMatrix<SCALAR> tmp(dofs_per_element);
1386 prolong_matrix.Tmmult(tmp,local_matrix);
1388 tmp.mmult(local_matrix,prolong_matrix);
1391 element[0]->get_dof_indices(local_dof_indices);
1392 for (
unsigned int i = 0; i < dofs_per_element; ++i)
1394 for (
unsigned int j = 0; j < dofs_per_element; ++j)
1396 matrix.add(local_dof_indices[i], local_dof_indices[j],
1397 local_matrix(i, j));
1404 element[0]->get_dof_indices(local_dof_indices);
1405 for (
unsigned int i = 0; i < dofs_per_element; ++i)
1407 for (
unsigned int j = 0; j < dofs_per_element; ++j)
1409 matrix.add(local_dof_indices[i], local_dof_indices[j],
1410 local_matrix(i, j));
1418 assert(fine_index != coarse_index);
1419 assert(element[fine_index]->has_children());
1420 assert(!element[coarse_index]->has_children());
1421 assert(tria_element[fine_index]->has_children());
1422 assert(!tria_element[coarse_index]->has_children());
1424 unsigned int local_n_dofs = element[coarse_index]->get_fe().dofs_per_cell;
1426 typename DH<dim, dim>::cell_iterator dofh_fine = element[fine_index];
1427 typename dealii::Triangulation<dim>::cell_iterator tria_fine = tria_element[fine_index];
1429 for (
unsigned int child=0; child<GeometryInfo<dim>::max_children_per_cell;++child)
1431 FullMatrix<SCALAR> new_matrix(local_n_dofs);
1432 element[coarse_index]->get_fe().get_prolongation_matrix(child).mmult (new_matrix,
1434 element[fine_index] = dofh_fine->child(child);
1435 tria_element[fine_index] = tria_fine->child(child);
1437 ComputeMatrix_Recursive(pde,matrix,element,tria_element,new_matrix, coarse_index, fine_index, edc, fdc);
1444 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
int dim>
1445 template<
typename PROBLEM,
template<
int,
int>
class DH>
1446 SCALAR IntegratorMultiMesh<INTEGRATORDATACONT, VECTOR, SCALAR, dim>::ComputeDomainScalar_Recursive(
1448 typename std::vector<
typename DH<dim, dim>::cell_iterator> &element,
1449 typename std::vector<
typename dealii::Triangulation<dim>::cell_iterator> &tria_element,
1450 const FullMatrix<SCALAR>& prolong_matrix,
unsigned int coarse_index,
unsigned int fine_index,
1451 Multimesh_ElementDataContainer<DH, VECTOR, dim>& edc)
1453 if(!element[0]->has_children() && ! element[1]->has_children())
1456 edc.ReInit(coarse_index,fine_index,prolong_matrix);
1457 ret += pde.ElementFunctional(edc);
1462 assert(fine_index != coarse_index);
1463 assert(element[fine_index]->has_children());
1464 assert(!element[coarse_index]->has_children());
1465 assert(tria_element[fine_index]->has_children());
1466 assert(!tria_element[coarse_index]->has_children());
1468 unsigned int local_n_dofs = element[coarse_index]->get_fe().dofs_per_cell;
1470 typename DH<dim, dim>::cell_iterator dofh_fine = element[fine_index];
1471 typename dealii::Triangulation<dim>::cell_iterator tria_fine = tria_element[fine_index];
1473 for (
unsigned int child=0; child<GeometryInfo<dim>::max_children_per_cell;++child)
1475 FullMatrix<SCALAR> new_matrix(local_n_dofs);
1476 element[coarse_index]->get_fe().get_prolongation_matrix(child).mmult (new_matrix,
1478 element[fine_index] = dofh_fine->child(child);
1479 tria_element[fine_index] = tria_fine->child(child);
1481 ret += ComputeDomainScalar_Recursive(pde,element,tria_element,new_matrix, coarse_index, fine_index, edc);
1488 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
int dim>
1489 template<
typename PROBLEM,
template<
int,
int>
class DH>
1490 SCALAR IntegratorMultiMesh<INTEGRATORDATACONT, VECTOR, SCALAR, dim>::ComputeBoundaryScalar_Recursive(
1492 typename std::vector<
typename DH<dim, dim>::cell_iterator> &element,
1493 typename std::vector<
typename dealii::Triangulation<dim>::cell_iterator> &tria_element,
1494 const FullMatrix<SCALAR>& prolong_matrix,
unsigned int coarse_index,
unsigned int fine_index,
1495 Multimesh_FaceDataContainer<DH, VECTOR, dim>& fdc)
1497 if(!element[0]->has_children() && ! element[1]->has_children())
1500 std::vector<unsigned int> boundary_functional_colors = pde.GetBoundaryFunctionalColors();
1501 unsigned int b_index = fine_index%2;
1503 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1505 if (element[b_index]->face(face)->at_boundary()
1507 (find(boundary_functional_colors.begin(),boundary_functional_colors.end(),
1508 element[b_index]->face(face)->boundary_indicator()) != boundary_functional_colors.end()))
1510 fdc.ReInit(coarse_index,fine_index,prolong_matrix,face);
1511 ret += pde.BoundaryFunctional(fdc);
1518 assert(fine_index != coarse_index);
1519 assert(element[fine_index]->has_children());
1520 assert(!element[coarse_index]->has_children());
1521 assert(tria_element[fine_index]->has_children());
1522 assert(!tria_element[coarse_index]->has_children());
1524 unsigned int local_n_dofs = element[coarse_index]->get_fe().dofs_per_cell;
1526 typename DH<dim, dim>::cell_iterator dofh_fine = element[fine_index];
1527 typename dealii::Triangulation<dim>::cell_iterator tria_fine = tria_element[fine_index];
1529 for (
unsigned int child=0; child<GeometryInfo<dim>::max_children_per_cell;++child)
1531 FullMatrix<SCALAR> new_matrix(local_n_dofs);
1532 element[coarse_index]->get_fe().get_prolongation_matrix(child).mmult (new_matrix,
1534 element[fine_index] = dofh_fine->child(child);
1535 tria_element[fine_index] = tria_fine->child(child);
1537 ret += ComputeBoundaryScalar_Recursive(pde,element,tria_element,new_matrix, coarse_index, fine_index, fdc);
const std::map< std::string, const VECTOR * > & GetDomainData() const
Definition: integrator_multimesh.h:939
void ComputeLocalControlConstraints(PROBLEM &pde, VECTOR &constraints)
Definition: integrator_multimesh.h:797
SCALAR ComputeBoundaryScalar(PROBLEM &pde)
Definition: integrator_multimesh.h:621
Definition: integrator_multimesh.h:62
SCALAR ComputeFaceScalar(PROBLEM &pde)
Definition: integrator_multimesh.h:703
SCALAR ComputeDomainScalar(PROBLEM &pde)
Definition: integrator_multimesh.h:522
void ComputeNonlinearLhs(PROBLEM &pde, VECTOR &residual, bool apply_boundary_values=true)
Definition: integrator_multimesh.h:341
Definition: multimesh_elementdatacontainer.h:55
void ComputeNonlinearRhs(PROBLEM &pde, VECTOR &residual, bool apply_boundary_values=true)
Definition: integrator_multimesh.h:355
void ComputeNonlinearResidual(PROBLEM &pde, VECTOR &residual, bool apply_boundary_values=true)
Definition: integrator_multimesh.h:253
SCALAR ComputeAlgebraicScalar(PROBLEM &pde)
Definition: integrator_multimesh.h:769
void AddParamData(std::string name, const dealii::Vector< SCALAR > *new_data)
Definition: integrator_multimesh.h:949
const DOFHANDLER< dim, dim > & GetDEALDoFHandler() const
Definition: dofhandler_wrapper.h:69
SCALAR ComputePointScalar(PROBLEM &pde)
Definition: integrator_multimesh.h:603
void ApplyNewtonBoundaryValues(PROBLEM &pde, VECTOR &u)
Definition: integrator_multimesh.h:841
void ComputeMatrix(PROBLEM &pde, MATRIX &matrix)
Definition: integrator_multimesh.h:441
~IntegratorMultiMesh()
Definition: integrator_multimesh.h:232
void DeleteParamData(std::string name)
Definition: integrator_multimesh.h:967
void ReInit()
Definition: integrator_multimesh.h:242
void DeleteDomainData(std::string name)
Definition: integrator_multimesh.h:920
void ApplyInitialBoundaryValues(PROBLEM &pde, VECTOR &u)
Definition: integrator_multimesh.h:809
IntegratorMultiMesh(INTEGRATORDATACONT &idc)
Definition: integrator_multimesh.h:222
void AddDomainData(std::string name, const VECTOR *new_data)
Definition: integrator_multimesh.h:903
void ComputeNonlinearAlgebraicResidual(PROBLEM &pde, VECTOR &residual)
Definition: integrator_multimesh.h:786
Definition: multimesh_facedatacontainer.h:53
INTEGRATORDATACONT & GetIntegratorDataContainer() const
Definition: integrator_multimesh.h:996
Definition: dopeexception.h:35
const std::map< std::string, const dealii::Vector< SCALAR > * > & GetParamData() const
Definition: integrator_multimesh.h:986