24 #ifndef _Integrator_H_
25 #define _Integrator_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>
34 #include <base/function.h>
57 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
68 Integrator(INTEGRATORDATACONT& idc1, INTEGRATORDATACONT& idc2);
95 template<
typename PROBLEM>
98 bool apply_boundary_values =
true);
117 template<
typename PROBLEM>
120 bool apply_boundary_values =
true);
139 template<
typename PROBLEM>
142 bool apply_boundary_values =
true);
156 template<
typename PROBLEM,
typename MATRIX>
172 template<
typename PROBLEM>
189 template<
typename PROBLEM>
204 template<
typename PROBLEM>
219 template<
typename PROBLEM>
236 template<
typename PROBLEM>
253 template<
typename PROBLEM>
270 template<
typename PROBLEM>
286 template<
typename PROBLEM>
305 template<
typename PROBLEM>
321 template<
typename PROBLEM>
340 template<
typename PROBLEM,
typename MATRIX>
381 AddParamData(std::string name,
const dealii::Vector<SCALAR>* new_data);
inline void
410 template<
typename PROBLEM,
class STH,
class EDC,
class FDC>
425 template<
typename PROBLEM>
430 inline INTEGRATORDATACONT&
433 inline INTEGRATORDATACONT&
442 inline const std::map<std::string, const VECTOR*>&
449 inline const std::map<std::string, const dealii::Vector<SCALAR>*>&
453 template<
template<
int,
int>
class DH>
455 InterpolateBoundaryValues(
458 const unsigned int color,
const dealii::Function<dim>&
function,
459 std::map<unsigned int, SCALAR>& boundary_values,
460 const std::vector<bool>& comp_mask)
const;
472 template<
typename ELEMENTITERATOR>
474 AtInterface(ELEMENTITERATOR& element,
unsigned int face)
476 if (element[0]->neighbor_index(face) != -1)
477 if (element[0]->material_id()
478 != element[0]->neighbor(face)->material_id())
483 INTEGRATORDATACONT & _idc1;
484 INTEGRATORDATACONT & _idc2;
486 std::map<std::string, const VECTOR*> _domain_data;
487 std::map<std::string, const dealii::Vector<SCALAR>*> _param_data;
492 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
495 INTEGRATORDATACONT& idc)
496 : _idc1(idc), _idc2(idc)
500 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
503 INTEGRATORDATACONT& idc1, INTEGRATORDATACONT& idc2)
504 : _idc1(idc1), _idc2(idc2)
510 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
519 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
529 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
531 template<
typename PROBLEM>
534 PROBLEM& pde, VECTOR &residual,
bool apply_boundary_values)
538 unsigned int dofs_per_element;
539 dealii::Vector<SCALAR> local_vector;
540 std::vector<unsigned int> local_dof_indices;
542 const bool need_point_rhs = pde.HasPoints();
544 const auto& dof_handler =
545 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
547 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
549 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
552 GetIntegratorDataContainer().InitializeEDC(pde.GetUpdateFlags(),
553 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
554 this->GetParamData(), this->GetDomainData());
555 auto& edc = GetIntegratorDataContainer().GetElementDataContainer();
557 bool need_faces = pde.HasFaces();
558 bool need_interfaces = pde.HasInterfaces();
559 std::vector<unsigned int> boundary_equation_colors = pde.GetBoundaryEquationColors();
560 bool need_boundary_integrals = (boundary_equation_colors.size() > 0);
561 GetIntegratorDataContainer().InitializeFDC(pde.GetFaceUpdateFlags(),
562 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
564 this->GetParamData(),
565 this->GetDomainData(),
567 auto & fdc = GetIntegratorDataContainer().GetFaceDataContainer();
569 for (; element[0] != endc[0]; element[0]++)
571 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
573 if (element[dh] == endc[dh])
576 "Elementnumbers in DoFHandlers are not matching!",
577 "Integrator::ComputeNonlinearResidual");
583 dofs_per_element = element[0]->get_fe().dofs_per_cell;
585 local_vector.reinit(dofs_per_element);
588 local_dof_indices.resize(0);
589 local_dof_indices.resize(dofs_per_element, 0);
593 pde.ElementEquation(edc, local_vector, 1., 1.);
594 pde.ElementRhs(edc, local_vector, -1.);
596 if(need_boundary_integrals && element[0]->at_boundary())
598 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
600 if (element[0]->face(face)->at_boundary()
602 (find(boundary_equation_colors.begin(),boundary_equation_colors.end(),
603 element[0]->face(face)->boundary_indicator()) != boundary_equation_colors.end()))
606 pde.BoundaryEquation(fdc,local_vector, 1., 1.);
607 pde.BoundaryRhs(fdc,local_vector,-1.);
613 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
615 if (element[0]->neighbor_index(face) != -1)
618 pde.FaceEquation(fdc, local_vector, 1., 1.);
619 pde.FaceRhs(fdc, local_vector,-1.);
626 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
631 if(AtInterface(element, face))
638 if (element[0]->neighbor(face)->has_children())
642 for (
unsigned int subface_no=0;
643 subface_no < element[0]->face(face)->n_children();
648 fdc.ReInit(face, subface_no);
651 pde.InterfaceEquation(fdc, local_vector, 1., 1.);
662 pde.InterfaceEquation(fdc, local_vector, 1., 1.);
669 element[0]->get_dof_indices(local_dof_indices);
670 for (
unsigned int i = 0; i < dofs_per_element; ++i)
672 residual(local_dof_indices[i]) += local_vector(i);
675 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
685 pde.PointRhs(this->GetParamData(), this->GetDomainData(), point_rhs,
687 residual += point_rhs;
690 if (apply_boundary_values)
692 ApplyNewtonBoundaryValues(pde, residual);
698 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
700 template<
typename PROBLEM>
703 PROBLEM& pde, VECTOR &residual,
bool apply_boundary_values)
709 unsigned int dofs_per_element;
711 dealii::Vector<SCALAR> local_vector;
713 std::vector<unsigned int> local_dof_indices;
715 const auto& dof_handler =
716 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
718 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
720 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
723 GetIntegratorDataContainer().InitializeEDC(pde.GetUpdateFlags(),
724 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
725 this->GetParamData(), this->GetDomainData());
726 auto& edc = GetIntegratorDataContainer().GetElementDataContainer();
728 bool need_faces = pde.HasFaces();
729 bool need_interfaces = pde.HasInterfaces();
730 std::vector<unsigned int> boundary_equation_colors = pde.GetBoundaryEquationColors();
731 bool need_boundary_integrals = (boundary_equation_colors.size() > 0);
733 GetIntegratorDataContainer().InitializeFDC(pde.GetFaceUpdateFlags(),
734 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
736 this->GetParamData(),
737 this->GetDomainData(),
739 auto & fdc = GetIntegratorDataContainer().GetFaceDataContainer();
741 for (; element[0] != endc[0]; element[0]++)
743 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
745 if (element[dh] == endc[dh])
748 "Elementnumbers in DoFHandlers are not matching!",
749 "mIntegrator::ComputeNonlinearLhs");
754 dofs_per_element = element[0]->get_fe().dofs_per_cell;
756 local_vector.reinit(dofs_per_element);
759 local_dof_indices.resize(0);
760 local_dof_indices.resize(dofs_per_element, 0);
764 pde.ElementEquation(edc, local_vector, 1., 1.);
766 if(need_boundary_integrals)
768 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
770 if (element[0]->face(face)->at_boundary()
772 (find(boundary_equation_colors.begin(),boundary_equation_colors.end(),
773 element[0]->face(face)->boundary_indicator()) != boundary_equation_colors.end()))
776 pde.BoundaryEquation(fdc,local_vector, 1., 1.);
782 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
784 if (element[0]->neighbor_index(face) != -1)
787 pde.FaceEquation(fdc, local_vector, 1., 1.);
795 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
800 if(AtInterface(element, face))
807 if (element[0]->neighbor(face)->has_children())
811 for (
unsigned int subface_no=0;
812 subface_no < element[0]->face(face)->n_children();
817 fdc.ReInit(face, subface_no);
820 pde.InterfaceEquation(fdc, local_vector, 1., 1.);
831 pde.InterfaceEquation(fdc, local_vector, 1., 1.);
837 element[0]->get_dof_indices(local_dof_indices);
838 for (
unsigned int i = 0; i < dofs_per_element; ++i)
840 residual(local_dof_indices[i]) += local_vector(i);
843 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
849 if (apply_boundary_values)
851 ApplyNewtonBoundaryValues(pde, residual);
858 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
860 template<
typename PROBLEM>
863 PROBLEM& pde, VECTOR &residual,
bool apply_boundary_values)
867 unsigned int dofs_per_element;
868 dealii::Vector<SCALAR> local_vector;
869 std::vector<unsigned int> local_dof_indices;
871 const bool need_point_rhs = pde.HasPoints();
873 const auto& dof_handler =
874 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
876 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
878 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
881 GetIntegratorDataContainer().InitializeEDC(pde.GetUpdateFlags(),
882 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
883 this->GetParamData(), this->GetDomainData());
884 auto& edc = GetIntegratorDataContainer().GetElementDataContainer();
886 bool need_interfaces = pde.HasInterfaces();
889 throw DOpEException(
" Faces on multiple meshes not implemented yet!",
890 "IntegratorMultiMesh::ComputeNonlinearRhs_Recursive");
892 bool need_faces = pde.HasFaces();
893 std::vector<unsigned int> boundary_equation_colors = pde.GetBoundaryEquationColors();
894 bool need_boundary_integrals = (boundary_equation_colors.size() > 0);
896 GetIntegratorDataContainer().InitializeFDC(pde.GetFaceUpdateFlags(),
897 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
899 this->GetParamData(),
900 this->GetDomainData());
901 auto & fdc = GetIntegratorDataContainer().GetFaceDataContainer();
903 for (; element[0] != endc[0]; element[0]++)
905 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
907 if (element[dh] == endc[dh])
910 "Elementnumbers in DoFHandlers are not matching!",
911 "Integrator::ComputeNonlinearRhs");
916 dofs_per_element = element[0]->get_fe().dofs_per_cell;
918 local_vector.reinit(dofs_per_element);
921 local_dof_indices.resize(0);
922 local_dof_indices.resize(dofs_per_element, 0);
923 pde.ElementRhs(edc, local_vector, 1.);
925 if(need_boundary_integrals)
927 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
929 if (element[0]->face(face)->at_boundary()
931 (find(boundary_equation_colors.begin(),boundary_equation_colors.end(),
932 element[0]->face(face)->boundary_indicator()) != boundary_equation_colors.end()))
935 pde.BoundaryRhs(fdc,local_vector,1.);
941 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
943 if (element[0]->neighbor_index(face) != -1)
946 pde.FaceRhs(fdc, local_vector);
951 element[0]->get_dof_indices(local_dof_indices);
952 for (
unsigned int i = 0; i < dofs_per_element; ++i)
954 residual(local_dof_indices[i]) += local_vector(i);
957 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
967 pde.PointRhs(this->GetParamData(), this->GetDomainData(), point_rhs,
969 residual += point_rhs;
972 if (apply_boundary_values)
974 ApplyNewtonBoundaryValues(pde, residual);
980 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
982 template<
typename PROBLEM,
typename MATRIX>
985 PROBLEM& pde, MATRIX &matrix)
989 unsigned int dofs_per_element;
990 std::vector<unsigned int> local_dof_indices;
992 const auto& dof_handler =
993 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
995 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
997 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
999 GetIntegratorDataContainer().InitializeEDC(pde.GetUpdateFlags(),
1000 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
1001 this->GetParamData(), this->GetDomainData());
1002 auto& edc = GetIntegratorDataContainer().GetElementDataContainer();
1005 unsigned int nbr_dofs_per_element;
1006 std::vector<unsigned int> nbr_local_dof_indices;
1008 bool need_faces = pde.HasFaces();
1009 bool need_interfaces = pde.HasInterfaces();
1010 std::vector<unsigned int> boundary_equation_colors = pde.GetBoundaryEquationColors();
1011 bool need_boundary_integrals = (boundary_equation_colors.size() > 0);
1013 GetIntegratorDataContainer().InitializeFDC(pde.GetFaceUpdateFlags(),
1014 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
1016 this->GetParamData(),
1017 this->GetDomainData(),
1019 auto & fdc = GetIntegratorDataContainer().GetFaceDataContainer();
1021 for (; element[0] != endc[0]; element[0]++)
1023 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1025 if (element[dh] == endc[dh])
1028 "Elementnumbers in DoFHandlers are not matching!",
1029 "Integrator::ComputeMatrix");
1033 dofs_per_element = element[0]->get_fe().dofs_per_cell;
1035 dealii::FullMatrix<SCALAR> local_matrix(dofs_per_element,
1039 local_dof_indices.resize(0);
1040 local_dof_indices.resize(dofs_per_element, 0);
1041 pde.ElementMatrix(edc, local_matrix);
1043 if(need_boundary_integrals)
1045 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1047 if (element[0]->face(face)->at_boundary()
1049 (find(boundary_equation_colors.begin(),boundary_equation_colors.end(),
1050 element[0]->face(face)->boundary_indicator()) != boundary_equation_colors.end()))
1053 pde.BoundaryMatrix(fdc, local_matrix);
1059 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1061 if (element[0]->neighbor_index(face) != -1)
1064 pde.FaceMatrix(fdc, local_matrix);
1069 if( need_interfaces)
1071 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1076 if(AtInterface(element, face))
1083 if (element[0]->neighbor(face)->has_children())
1087 for (
unsigned int subface_no=0;
1088 subface_no < element[0]->face(face)->n_children();
1093 fdc.ReInit(face, subface_no);
1097 nbr_dofs_per_element = fdc.GetNbrNDoFsPerElement();
1098 nbr_local_dof_indices.resize(0);
1099 nbr_local_dof_indices.resize(nbr_dofs_per_element, 0);
1100 dealii::FullMatrix<SCALAR> local_interface_matrix(dofs_per_element,nbr_dofs_per_element );
1101 local_interface_matrix = 0;
1103 pde.InterfaceMatrix(fdc, local_interface_matrix);
1105 element[0]->get_dof_indices(local_dof_indices);
1106 element[0]->neighbor(face)->get_dof_indices(nbr_local_dof_indices);
1108 for (
unsigned int i = 0; i < dofs_per_element; ++i)
1110 for (
unsigned int j = 0; j < nbr_dofs_per_element; ++j)
1112 matrix.add(local_dof_indices[i], nbr_local_dof_indices[j],
1113 local_interface_matrix(i, j));
1126 nbr_dofs_per_element = fdc.GetNbrNDoFsPerElement();
1127 nbr_local_dof_indices.resize(0);
1128 nbr_local_dof_indices.resize(nbr_dofs_per_element, 0);
1129 dealii::FullMatrix<SCALAR> local_interface_matrix(dofs_per_element,nbr_dofs_per_element );
1130 local_interface_matrix = 0;
1132 pde.InterfaceMatrix(fdc, local_interface_matrix);
1134 element[0]->get_dof_indices(local_dof_indices);
1135 element[0]->neighbor(face)->get_dof_indices(nbr_local_dof_indices);
1137 for (
unsigned int i = 0; i < dofs_per_element; ++i)
1139 for (
unsigned int j = 0; j < nbr_dofs_per_element; ++j)
1141 matrix.add(local_dof_indices[i], nbr_local_dof_indices[j],
1142 local_interface_matrix(i, j));
1152 element[0]->get_dof_indices(local_dof_indices);
1153 for (
unsigned int i = 0; i < dofs_per_element; ++i)
1155 for (
unsigned int j = 0; j < dofs_per_element; ++j)
1157 matrix.add(local_dof_indices[i], local_dof_indices[j],
1158 local_matrix(i, j));
1162 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1169 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1171 template<
typename PROBLEM>
1179 const auto& dof_handler =
1180 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
1182 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1184 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
1185 GetIntegratorDataContainerFunc().InitializeEDC(pde.GetUpdateFlags(),
1186 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
1187 this->GetParamData(), this->GetDomainData());
1188 auto& edc = GetIntegratorDataContainerFunc().GetElementDataContainer();
1190 bool need_faces = pde.HasFaces();
1192 for (; element[0] != endc[0]; element[0]++)
1194 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1196 if (element[dh] == endc[dh])
1199 "Elementnumbers in DoFHandlers are not matching!",
1200 "Integrator::ComputeDomainScalar");
1205 ret += pde.ElementFunctional(edc);
1210 "Integrator::ComputeDomainScalar");
1213 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1223 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1225 template<
typename PROBLEM>
1233 ret += pde.PointFunctional(this->GetParamData(),
1234 this->GetDomainData());
1241 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1243 template<
typename PROBLEM>
1252 const auto& dof_handler =
1253 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
1254 auto element = pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1255 auto endc = pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
1257 GetIntegratorDataContainerFunc().InitializeFDC(pde.GetFaceUpdateFlags(),
1258 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
1260 this->GetParamData(),
1261 this->GetDomainData());
1262 auto & fdc = GetIntegratorDataContainerFunc().GetFaceDataContainer();
1264 std::vector<unsigned int> boundary_functional_colors = pde.GetBoundaryFunctionalColors();
1265 bool need_boundary_integrals = (boundary_functional_colors.size() > 0);
1266 if(!need_boundary_integrals)
1268 throw DOpEException(
"No boundary colors given!",
"Integrator::ComputeBoundaryScalar");
1271 for (;element[0]!=endc[0]; element[0]++)
1273 for(
unsigned int dh=1; dh<dof_handler.size(); dh++)
1275 if( element[dh] == endc[dh])
1277 throw DOpEException(
"Elementnumbers in DoFHandlers are not matching!",
"Integrator::ComputeBoundaryScalar");
1281 if(need_boundary_integrals)
1283 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1285 if (element[0]->face(face)->at_boundary()
1287 (find(boundary_functional_colors.begin(),boundary_functional_colors.end(),
1288 element[0]->face(face)->boundary_indicator()) != boundary_functional_colors.end()))
1291 ret += pde.BoundaryFunctional(fdc);
1295 for(
unsigned int dh=1; dh<dof_handler.size(); dh++)
1307 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1309 template<
typename PROBLEM>
1319 const auto& dof_handler =
1320 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
1321 auto element = pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1322 auto endc = pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
1324 GetIntegratorDataContainerFunc().InitializeFDC(pde.GetFaceUpdateFlags(),
1325 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
1327 this->GetParamData(),
1328 this->GetDomainData());
1329 auto & fdc = GetIntegratorDataContainerFunc().GetFaceDataContainer();
1331 bool need_faces = pde.HasFaces();
1334 throw DOpEException(
"No faces required!",
"Integrator::ComputeFaceScalar");
1337 for (;element[0]!=endc[0]; element[0]++)
1339 for(
unsigned int dh=1; dh<dof_handler.size(); dh++)
1341 if( element[dh] == endc[dh])
1343 throw DOpEException(
"Elementnumbers in DoFHandlers are not matching!",
"Integrator::ComputeFaceScalar");
1349 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1351 if (element[0]->neighbor_index(face) != -1)
1354 ret +=pde.FaceFunctional(fdc);
1358 for(
unsigned int dh=1; dh<dof_handler.size(); dh++)
1368 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1370 template<
typename PROBLEM>
1378 ret = pde.AlgebraicFunctional(this->GetParamData(),
1379 this->GetDomainData());
1386 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1388 template<
typename PROBLEM>
1391 PROBLEM& pde, VECTOR &residual)
1394 pde.AlgebraicResidual(residual, this->GetParamData(),
1395 this->GetDomainData());
1400 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1402 template<
typename PROBLEM>
1405 PROBLEM& pde, VECTOR &constraints)
1408 pde.ComputeLocalControlConstraints(constraints, this->GetParamData(),
1409 this->GetDomainData());
1414 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1416 template<
typename PROBLEM>
1419 PROBLEM& , VECTOR &)
1426 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1428 template<
typename PROBLEM>
1431 PROBLEM& pde, VECTOR &u)
1438 std::vector<unsigned int> dirichlet_colors = pde.GetDirichletColors();
1439 for (
unsigned int i = 0; i < dirichlet_colors.size(); i++)
1441 unsigned int color = dirichlet_colors[i];
1442 std::vector<bool> comp_mask = pde.GetDirichletCompMask(color);
1443 std::map<unsigned int, SCALAR> boundary_values;
1445 InterpolateBoundaryValues( pde.GetBaseProblem().GetSpaceTimeHandler()->GetMapping(),
1446 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler()[0],
1448 pde.GetDirichletValues(color, this->GetParamData(),
1449 this->GetDomainData()), boundary_values, comp_mask);
1451 for (
typename std::map<unsigned int, SCALAR>::const_iterator p =
1452 boundary_values.begin(); p != boundary_values.end(); p++)
1454 u(p->first) = p->second;
1461 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1463 template<
typename PROBLEM>
1466 PROBLEM& pde, VECTOR &u)
1471 pde.GetDoFConstraints().condense(u);
1472 std::vector<unsigned int> dirichlet_colors = pde.GetDirichletColors();
1473 for (
unsigned int i = 0; i < dirichlet_colors.size(); i++)
1475 unsigned int color = dirichlet_colors[i];
1476 std::vector<bool> comp_mask = pde.GetDirichletCompMask(color);
1477 std::map<unsigned int, SCALAR> boundary_values;
1479 InterpolateBoundaryValues( pde.GetBaseProblem().GetSpaceTimeHandler()->GetMapping(),
1480 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler()[0],
1481 color, dealii::ZeroFunction<dim>(comp_mask.size()),
1482 boundary_values, comp_mask);
1484 for (
typename std::map<unsigned int, SCALAR>::const_iterator p =
1485 boundary_values.begin(); p != boundary_values.end(); p++)
1487 u(p->first) = p->second;
1493 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1495 template<
typename PROBLEM,
typename MATRIX>
1498 PROBLEM& pde, MATRIX& matrix, VECTOR &rhs, VECTOR &sol)
1502 pde.GetDoFConstraints().condense(rhs);
1503 pde.GetDoFConstraints().condense(matrix);
1504 std::vector<unsigned int> dirichlet_colors = pde.GetDirichletColors();
1505 for (
unsigned int i = 0; i < dirichlet_colors.size(); i++)
1507 unsigned int color = dirichlet_colors[i];
1508 std::vector<bool> comp_mask = pde.GetDirichletCompMask(color);
1509 std::map<unsigned int, SCALAR> boundary_values;
1511 InterpolateBoundaryValues( pde.GetBaseProblem().GetSpaceTimeHandler()->GetMapping(),
1512 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler()[0],
1513 color, dealii::ZeroFunction<dim>(comp_mask.size()),
1514 boundary_values, comp_mask);
1516 dealii::MatrixTools::apply_boundary_values(boundary_values, matrix,
1523 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1527 std::string name,
const VECTOR* new_data)
1529 if (_domain_data.find(name) != _domain_data.end())
1532 "Adding multiple Data with name " + name +
" is prohibited!",
1533 "Integrator::AddDomainData");
1535 _domain_data.insert(
1536 std::pair<std::string, const VECTOR*>(name, new_data));
1541 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1547 typename std::map<std::string, const VECTOR *>::iterator it =
1548 _domain_data.find(name);
1549 if (it == _domain_data.end())
1552 "Deleting Data " + name +
" is impossible! Data not found",
1553 "Integrator::DeleteDomainData");
1555 _domain_data.erase(it);
1560 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1562 const std::map<std::string, const VECTOR*>&
1565 return _domain_data;
1570 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1574 std::string name,
const dealii::Vector<SCALAR>* new_data)
1576 if (_param_data.find(name) != _param_data.end())
1579 "Adding multiple Data with name " + name +
" is prohibited!",
1580 "Integrator::AddParamData");
1583 std::pair<std::string,
const dealii::Vector<SCALAR>*>(name,
1589 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1595 typename std::map<std::string, const dealii::Vector<SCALAR>*>::iterator it =
1596 _param_data.find(name);
1597 if (it == _param_data.end())
1600 "Deleting Data " + name +
" is impossible! Data not found",
1601 "Integrator::DeleteParamData");
1603 _param_data.erase(it);
1608 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1610 const std::map<std::string, const dealii::Vector<SCALAR>*>&
1618 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1620 template<
typename PROBLEM,
class STH,
class EDC,
class FDC>
1628 std::vector<double> element_sum(n_error_comps, 0);
1629 element_sum.resize(n_error_comps, 0);
1632 const auto& dof_handler =
1633 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
1635 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1637 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
1639 const auto& dof_handler_weight = dwrc.
GetWeightSTH().GetDoFHandler();
1640 auto element_weight = dwrc.
GetWeightSTH().GetDoFHandlerBeginActive();
1641 auto endc_high = dwrc.
GetWeightSTH().GetDoFHandlerEnd();
1645 GetIntegratorDataContainer().InitializeEDC(
1647 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
1648 this->GetParamData(), this->GetDomainData());
1649 auto& edc = GetIntegratorDataContainer().GetElementDataContainer();
1651 dwrc.
GetWeightIDC().InitializeEDC(pde.GetUpdateFlags(),
1652 dwrc.
GetWeightSTH(), element_weight, this->GetParamData(),
1659 typename std::map<typename dealii::Triangulation<dim>::face_iterator,std::vector<double> >
1664 auto element_it = element[0];
1665 std::vector<double> face_init(n_error_comps,-1e20);
1666 for (; element_it != endc[0]; element_it++)
1668 for (
unsigned int face_no=0;face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
1670 face_integrals[element_it->face(face_no)] = face_init;
1679 GetIntegratorDataContainer().InitializeFDC(dwrc.
GetWeightIDC().GetFaceQuad(),
1680 pde.GetFaceUpdateFlags(),
1681 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
1683 this->GetParamData(),
1684 this->GetDomainData(),
1686 auto & fdc = GetIntegratorDataContainer().GetFaceDataContainer();
1688 dwrc.
GetWeightIDC().InitializeFDC(pde.GetFaceUpdateFlags(),
1691 this->GetParamData(),
1695 for (
unsigned int element_index = 0; element[0] != endc[0];
1696 element[0]++, element_index++)
1698 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1700 if (element[dh] == endc[dh])
1703 "Elementnumbers in DoFHandlers are not matching!",
1704 "Integrator::ComputeRefinementIndicators");
1707 for (
unsigned int dh = 0; dh < dof_handler_weight.size(); dh++)
1709 if (element_weight[dh] == endc_high[dh])
1712 "Elementnumbers in DoFHandlers are not matching!",
1713 "Integrator::ComputeRefinementIndicators");
1716 element_sum.clear();
1717 element_sum.resize(n_error_comps, 0);
1720 edc_weight.ReInit();
1723 pde.ElementErrorContribution(edc, dwrc, element_sum, 1.);
1724 for(
unsigned int l =0; l < n_error_comps; l ++)
1730 element_sum.clear();
1731 element_sum.resize(n_error_comps, 0);
1737 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1739 auto face_it = element[0]->face(face);
1742 if(face_it->at_boundary())
1746 pde.BoundaryErrorContribution(fdc, dwrc, element_sum, 1.);
1748 Assert (face_integrals.find (element[0]->face(face)) != face_integrals.end(),
1749 ExcInternalError());
1750 Assert (face_integrals[element[0]->face(face)] == face_init,
1751 ExcInternalError());
1753 face_integrals[element[0]->face(face)] = element_sum;
1754 element_sum.clear();
1755 element_sum.resize(n_error_comps,0.);
1763 if (element[0]->neighbor(face)->has_children())
1766 std::vector<double> sum(n_error_comps,0.);
1767 for (
unsigned int subface_no=0;
1768 subface_no < element[0]->face(face)->n_children();
1773 fdc.ReInit(face, subface_no);
1777 pde.FaceErrorContribution(fdc, dwrc, element_sum, 1.);
1778 for(
unsigned int l =0; l < n_error_comps; l ++)
1780 sum[l] += element_sum[l];
1782 face_integrals[element[0]->neighbor_child_on_subface(face, subface_no)
1783 ->face(element[0]->neighbor_of_neighbor(face))] = element_sum;
1784 element_sum.clear();
1785 element_sum.resize(n_error_comps,0);
1788 Assert (face_integrals.find (element[0]->face(face)) != face_integrals.end(),
1789 ExcInternalError());
1790 Assert (face_integrals[element[0]->face(face)] == face_init,
1791 ExcInternalError());
1793 face_integrals[element[0]->face(face)] = sum;
1794 element_sum.clear();
1795 element_sum.resize(n_error_comps,0);
1801 Assert(element[0]->neighbor(face)->level() <= element[0]->level(),ExcInternalError());
1804 if(element[0]->level() == element[0]->neighbor(face)->level()
1805 && element[0]->index() < element[0]->neighbor(face)->index())
1811 pde.FaceErrorContribution(fdc, dwrc, element_sum, 1.);
1812 Assert (face_integrals.find (element[0]->face(face)) != face_integrals.end(),
1813 ExcInternalError());
1814 Assert (face_integrals[element[0]->face(face)] == face_init,
1815 ExcInternalError());
1817 face_integrals[element[0]->face(face)] = element_sum;
1818 element_sum.clear();
1819 element_sum.resize(n_error_comps,0);
1824 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1828 for (
unsigned int dh = 0; dh < dof_handler_weight.size(); dh++)
1830 element_weight[dh]++;
1835 unsigned int present_element = 0;
1837 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1839 element[0] !=endc[0]; element[0]++, ++present_element)
1841 for (
unsigned int face_no = 0;
1842 face_no < GeometryInfo<dim>::faces_per_cell; ++face_no)
1845 face_integrals.find(element[0]->face(face_no)) != face_integrals.end(),
1846 ExcInternalError());
1847 if(element[0]->face(face_no)->at_boundary())
1849 for(
unsigned int l =0; l < n_error_comps; l ++)
1852 face_integrals[element[0]->face(face_no)][l];
1861 for(
unsigned int l =0; l < n_error_comps; l ++)
1864 0.5*face_integrals[element[0]->face(face_no)][l];
1877 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1879 template<
typename PROBLEM>
1886 std::vector<double> element_sum(2, 0);
1887 element_sum.resize(2, 0);
1889 const auto& dof_handler =
1890 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
1892 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1894 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
1900 for (; wd != wend; wd++)
1902 AddDomainData(wd->first, wd->second);
1908 GetIntegratorDataContainer().InitializeEDC(pde.GetUpdateFlags(),
1909 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
1910 this->GetParamData(), this->GetDomainData());
1911 auto& edc = GetIntegratorDataContainer().GetElementDataContainer();
1914 typename std::map<typename dealii::Triangulation<dim>::face_iterator,std::vector<double> >
1917 auto element_it = element[0];
1918 std::vector<double> face_init(2,-1e20);
1919 for (; element_it != endc[0]; element_it++)
1921 for (
unsigned int face_no=0;face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
1923 face_integrals[element_it->face(face_no)] = face_init;
1932 GetIntegratorDataContainer().InitializeFDC(
1933 pde.GetFaceUpdateFlags(),
1934 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
1936 this->GetParamData(),
1937 this->GetDomainData(),
1939 auto & fdc = GetIntegratorDataContainer().GetFaceDataContainer();
1941 for (
unsigned int element_index = 0; element[0] != endc[0];
1942 element[0]++, element_index++)
1944 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1946 if (element[dh] == endc[dh])
1949 "Elementnumbers in DoFHandlers are not matching!",
1950 "Integrator::ComputeRefinementIndicators");
1954 element_sum.clear();
1955 element_sum.resize(2, 0);
1960 pde.ElementErrorContribution(edc, dwrc, element_sum, 1.);
1963 element_sum.clear();
1964 element_sum.resize(2, 0);
1969 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1971 auto face_it = element[0]->face(face);
1974 if(face_it->at_boundary())
1977 #if deal_II_dimension > 1
1978 dwrc.
InitFace(element[0]->face(face)->diameter());
1980 dwrc.
InitFace(element[0]->diameter());
1982 pde.BoundaryErrorContribution(fdc, dwrc, element_sum, 1.);
1984 Assert (face_integrals.find (element[0]->face(face)) != face_integrals.end(),
1985 ExcInternalError());
1986 Assert (face_integrals[element[0]->face(face)] == face_init,
1987 ExcInternalError());
1988 face_integrals[element[0]->face(face)] = element_sum;
1989 element_sum.clear();
1990 element_sum.resize(2,0.);
1998 if (element[0]->neighbor(face)->has_children())
2001 std::vector<double> sum(2,0.);
2002 for (
unsigned int subface_no=0;
2003 subface_no < element[0]->face(face)->n_children();
2008 fdc.ReInit(face, subface_no);
2010 #if deal_II_dimension > 1
2011 dwrc.
InitFace(element[0]->face(face)->diameter());
2013 dwrc.
InitFace(element[0]->diameter());
2016 pde.FaceErrorContribution(fdc, dwrc, element_sum, 1.);
2017 sum[0]= element_sum[0];
2018 sum[1]= element_sum[1];
2019 element_sum.clear();
2020 element_sum.resize(2,0);
2021 face_integrals[element[0]->neighbor_child_on_subface(face, subface_no)
2022 ->face(element[0]->neighbor_of_neighbor(face))] = element_sum;
2023 element_sum.clear();
2024 element_sum.resize(2,0.);
2027 Assert (face_integrals.find (element[0]->face(face)) != face_integrals.end(),
2028 ExcInternalError());
2029 Assert (face_integrals[element[0]->face(face)] == face_init,
2030 ExcInternalError());
2032 face_integrals[element[0]->face(face)] = sum;
2039 Assert(element[0]->neighbor(face)->level() <= element[0]->level(),ExcInternalError());
2042 if(element[0]->level() == element[0]->neighbor(face)->level()
2043 && element[0]->index() < element[0]->neighbor(face)->index())
2047 #if deal_II_dimension > 1
2048 dwrc.
InitFace(element[0]->face(face)->diameter());
2050 dwrc.
InitFace(element[0]->diameter());
2053 pde.FaceErrorContribution(fdc, dwrc, element_sum, 1.);
2054 Assert (face_integrals.find (element[0]->face(face)) != face_integrals.end(),
2055 ExcInternalError());
2056 Assert (face_integrals[element[0]->face(face)] == face_init,
2057 ExcInternalError());
2059 face_integrals[element[0]->face(face)] = element_sum;
2060 element_sum.clear();
2061 element_sum.resize(2,0);
2068 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
2075 unsigned int present_element = 0;
2077 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
2079 element[0] !=endc[0]; element[0]++, ++present_element)
2080 for (
unsigned int face_no = 0;
2081 face_no < GeometryInfo<dim>::faces_per_cell; ++face_no)
2084 face_integrals.find(element[0]->face(face_no)) != face_integrals.end(),
2085 ExcInternalError());
2087 0.5 * face_integrals[element[0]->face(face_no)][0];
2089 0.5 * face_integrals[element[0]->face(face_no)][1];
2095 for (; wd != wend; wd++)
2097 DeleteDomainData(wd->first);
2104 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
2114 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
2124 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
2126 template<
template<
int,
int>
class DH>
2131 const unsigned int color,
const dealii::Function<dim>&
function,
2132 std::map<unsigned int, SCALAR>& boundary_values,
2133 const std::vector<bool>& comp_mask)
const
2137 dealii::VectorTools::interpolate_boundary_values(mapping[0],
2139 boundary_values, comp_mask);
SCALAR ComputeDomainScalar(PROBLEM &pde)
Definition: integrator.h:1173
Definition: mapping_wrapper.h:48
const std::map< std::string, const VECTOR * > & GetWeightData() const
Definition: dwrdatacontainer.h:398
SCALAR ComputeBoundaryScalar(PROBLEM &pde)
Definition: integrator.h:1245
void AddParamData(std::string name, const dealii::Vector< SCALAR > *new_data)
Definition: integrator.h:1573
void ComputeNonlinearLhs(PROBLEM &pde, VECTOR &residual, bool apply_boundary_values=true)
Definition: integrator.h:702
virtual EDC & GetElementWeight() const =0
~Integrator()
Definition: integrator.h:512
SCALAR ComputePointScalar(PROBLEM &pde)
Definition: integrator.h:1227
Definition: integrator.h:59
void ApplyInitialBoundaryValues(PROBLEM &pde, VECTOR &u)
Definition: integrator.h:1430
Vector< double > & GetPrimalErrorIndicators()
Definition: dwrdatacontainer.h:233
void ComputeLocalControlConstraints(PROBLEM &pde, VECTOR &constraints)
Definition: integrator.h:1404
void ComputeMatrix(PROBLEM &pde, MATRIX &matrix)
Definition: integrator.h:984
const DOFHANDLER< dim, dim > & GetDEALDoFHandler() const
Definition: dofhandler_wrapper.h:69
void ComputeRefinementIndicators(PROBLEM &pde, DWRDataContainer< STH, INTEGRATORDATACONT, EDC, FDC, VECTOR > &dwrc)
Definition: integrator.h:1622
const Vector< double > & GetErrorIndicators() const
Definition: dwrdatacontainer.h:213
const std::map< std::string, const dealii::Vector< SCALAR > * > & GetParamData() const
Definition: integrator.h:1611
INTEGRATORDATACONT & GetIntegratorDataContainerFunc() const
Definition: integrator.h:2117
Vector< double > & GetDualErrorIndicators()
Definition: dwrdatacontainer.h:251
virtual STH & GetWeightSTH()=0
SCALAR ComputeFaceScalar(PROBLEM &pde)
Definition: integrator.h:1311
void DeleteParamData(std::string name)
Definition: integrator.h:1592
void DeleteDomainData(std::string name)
Definition: integrator.h:1544
Integrator(INTEGRATORDATACONT &idc1)
Definition: integrator.h:494
Definition: residualestimator.h:38
SCALAR ComputeAlgebraicScalar(PROBLEM &pde)
Definition: integrator.h:1372
void AddDomainData(std::string name, const VECTOR *new_data)
Definition: integrator.h:1526
void ApplyTransposedInitialBoundaryValues(PROBLEM &pde, VECTOR &u)
Definition: integrator.h:1418
virtual FDC & GetFaceWeight() const =0
INTEGRATORDATACONT & GetIntegratorDataContainer() const
Definition: integrator.h:2107
unsigned int GetNErrorComps() const
Definition: dwrdatacontainer.h:317
virtual void InitFace(double)=0
void ReInit()
Definition: integrator.h:522
virtual IDC & GetWeightIDC()=0
Definition: dopeexception.h:35
void ApplyNewtonBoundaryValues(PROBLEM &pde, VECTOR &u)
Definition: integrator.h:1465
void ComputeNonlinearAlgebraicResidual(PROBLEM &pde, VECTOR &residual)
Definition: integrator.h:1390
Definition: dwrdatacontainer.h:545
void ComputeNonlinearRhs(PROBLEM &pde, VECTOR &residual, bool apply_boundary_values=true)
Definition: integrator.h:862
virtual void InitElement(double)=0
void ComputeNonlinearResidual(PROBLEM &pde, VECTOR &residual, bool apply_boundary_values=true)
Definition: integrator.h:533
const std::map< std::string, const VECTOR * > & GetDomainData() const
Definition: integrator.h:1563