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>*>&
468 template<
template<
int,
int>
class DH>
470 InterpolateBoundaryValues(
473 const unsigned int color,
const dealii::Function<dim>&
function,
474 std::map<unsigned int, SCALAR>& boundary_values,
475 const std::vector<bool>& comp_mask)
const;
487 template<
typename ELEMENTITERATOR>
489 AtInterface(ELEMENTITERATOR& element,
unsigned int face)
491 if (element[0]->neighbor_index(face) != -1)
492 if (element[0]->material_id()
493 != element[0]->neighbor(face)->material_id())
498 INTEGRATORDATACONT & idc1_;
499 INTEGRATORDATACONT & idc2_;
501 std::map<std::string, const VECTOR*> domain_data_;
502 std::map<std::string, const dealii::Vector<SCALAR>*> param_data_;
507 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
510 INTEGRATORDATACONT& idc)
511 : idc1_(idc), idc2_(idc)
515 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
518 INTEGRATORDATACONT& idc1, INTEGRATORDATACONT& idc2)
519 : idc1_(idc1), idc2_(idc2)
525 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
534 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
544 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
546 template<
typename PROBLEM>
549 PROBLEM& pde, VECTOR &residual,
bool apply_boundary_values)
553 unsigned int dofs_per_element;
554 dealii::Vector<SCALAR> local_vector;
555 std::vector<unsigned int> local_dof_indices;
557 const bool need_point_rhs = pde.HasPoints();
559 const auto& dof_handler =
560 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
562 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
564 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
567 GetIntegratorDataContainer().InitializeEDC(pde.GetUpdateFlags(),
568 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
569 this->GetParamData(), this->GetDomainData());
570 auto& edc = GetIntegratorDataContainer().GetElementDataContainer();
572 bool need_faces = pde.HasFaces();
573 bool need_interfaces = pde.HasInterfaces();
574 std::vector<unsigned int> boundary_equation_colors = pde.GetBoundaryEquationColors();
575 bool need_boundary_integrals = (boundary_equation_colors.size() > 0);
576 GetIntegratorDataContainer().InitializeFDC(pde.GetFaceUpdateFlags(),
577 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
579 this->GetParamData(),
580 this->GetDomainData(),
582 auto & fdc = GetIntegratorDataContainer().GetFaceDataContainer();
584 for (; element[0] != endc[0]; element[0]++)
586 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
588 if (element[dh] == endc[dh])
591 "Elementnumbers in DoFHandlers are not matching!",
592 "Integrator::ComputeNonlinearResidual");
598 dofs_per_element = element[0]->get_fe().dofs_per_cell;
600 local_vector.reinit(dofs_per_element);
603 local_dof_indices.resize(0);
604 local_dof_indices.resize(dofs_per_element, 0);
608 pde.ElementEquation(edc, local_vector, 1., 1.);
609 pde.ElementRhs(edc, local_vector, -1.);
611 if(need_boundary_integrals && element[0]->at_boundary())
613 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
615 if (element[0]->face(face)->at_boundary()
617 (find(boundary_equation_colors.begin(),boundary_equation_colors.end(),
618 element[0]->face(face)->boundary_indicator()) != boundary_equation_colors.end()))
621 pde.BoundaryEquation(fdc,local_vector, 1., 1.);
622 pde.BoundaryRhs(fdc,local_vector,-1.);
628 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
630 if (element[0]->neighbor_index(face) != -1)
633 pde.FaceEquation(fdc, local_vector, 1., 1.);
634 pde.FaceRhs(fdc, local_vector,-1.);
641 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
646 if(AtInterface(element, face))
653 if (element[0]->neighbor(face)->has_children())
657 for (
unsigned int subface_no=0;
658 subface_no < element[0]->face(face)->n_children();
663 fdc.ReInit(face, subface_no);
666 pde.InterfaceEquation(fdc, local_vector, 1., 1.);
677 pde.InterfaceEquation(fdc, local_vector, 1., 1.);
684 element[0]->get_dof_indices(local_dof_indices);
685 for (
unsigned int i = 0; i < dofs_per_element; ++i)
687 residual(local_dof_indices[i]) += local_vector(i);
690 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
700 pde.PointRhs(this->GetParamData(), this->GetDomainData(), point_rhs,
702 residual += point_rhs;
705 AddPresetRightHandSide(-1.,residual);
707 if (apply_boundary_values)
709 ApplyNewtonBoundaryValues(pde, residual);
715 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
717 template<
typename PROBLEM>
720 PROBLEM& pde, VECTOR &residual,
bool apply_boundary_values)
726 unsigned int dofs_per_element;
728 dealii::Vector<SCALAR> local_vector;
730 std::vector<unsigned int> local_dof_indices;
732 const auto& dof_handler =
733 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
735 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
737 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
740 GetIntegratorDataContainer().InitializeEDC(pde.GetUpdateFlags(),
741 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
742 this->GetParamData(), this->GetDomainData());
743 auto& edc = GetIntegratorDataContainer().GetElementDataContainer();
745 bool need_faces = pde.HasFaces();
746 bool need_interfaces = pde.HasInterfaces();
747 std::vector<unsigned int> boundary_equation_colors = pde.GetBoundaryEquationColors();
748 bool need_boundary_integrals = (boundary_equation_colors.size() > 0);
750 GetIntegratorDataContainer().InitializeFDC(pde.GetFaceUpdateFlags(),
751 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
753 this->GetParamData(),
754 this->GetDomainData(),
756 auto & fdc = GetIntegratorDataContainer().GetFaceDataContainer();
758 for (; element[0] != endc[0]; element[0]++)
760 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
762 if (element[dh] == endc[dh])
765 "Elementnumbers in DoFHandlers are not matching!",
766 "mIntegrator::ComputeNonlinearLhs");
771 dofs_per_element = element[0]->get_fe().dofs_per_cell;
773 local_vector.reinit(dofs_per_element);
776 local_dof_indices.resize(0);
777 local_dof_indices.resize(dofs_per_element, 0);
781 pde.ElementEquation(edc, local_vector, 1., 1.);
783 if(need_boundary_integrals)
785 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
787 if (element[0]->face(face)->at_boundary()
789 (find(boundary_equation_colors.begin(),boundary_equation_colors.end(),
790 element[0]->face(face)->boundary_indicator()) != boundary_equation_colors.end()))
793 pde.BoundaryEquation(fdc,local_vector, 1., 1.);
799 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
801 if (element[0]->neighbor_index(face) != -1)
804 pde.FaceEquation(fdc, local_vector, 1., 1.);
812 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
817 if(AtInterface(element, face))
824 if (element[0]->neighbor(face)->has_children())
828 for (
unsigned int subface_no=0;
829 subface_no < element[0]->face(face)->n_children();
834 fdc.ReInit(face, subface_no);
837 pde.InterfaceEquation(fdc, local_vector, 1., 1.);
848 pde.InterfaceEquation(fdc, local_vector, 1., 1.);
854 element[0]->get_dof_indices(local_dof_indices);
855 for (
unsigned int i = 0; i < dofs_per_element; ++i)
857 residual(local_dof_indices[i]) += local_vector(i);
860 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
866 if (apply_boundary_values)
868 ApplyNewtonBoundaryValues(pde, residual);
875 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
877 template<
typename PROBLEM>
880 PROBLEM& pde, VECTOR &residual,
bool apply_boundary_values)
884 unsigned int dofs_per_element;
885 dealii::Vector<SCALAR> local_vector;
886 std::vector<unsigned int> local_dof_indices;
888 const bool need_point_rhs = pde.HasPoints();
890 const auto& dof_handler =
891 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
893 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
895 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
898 GetIntegratorDataContainer().InitializeEDC(pde.GetUpdateFlags(),
899 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
900 this->GetParamData(), this->GetDomainData());
901 auto& edc = GetIntegratorDataContainer().GetElementDataContainer();
903 bool need_interfaces = pde.HasInterfaces();
906 throw DOpEException(
" Faces on multiple meshes not implemented yet!",
907 "IntegratorMultiMesh::ComputeNonlinearRhs_Recursive");
909 bool need_faces = pde.HasFaces();
910 std::vector<unsigned int> boundary_equation_colors = pde.GetBoundaryEquationColors();
911 bool need_boundary_integrals = (boundary_equation_colors.size() > 0);
913 GetIntegratorDataContainer().InitializeFDC(pde.GetFaceUpdateFlags(),
914 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
916 this->GetParamData(),
917 this->GetDomainData());
918 auto & fdc = GetIntegratorDataContainer().GetFaceDataContainer();
920 for (; element[0] != endc[0]; element[0]++)
922 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
924 if (element[dh] == endc[dh])
927 "Elementnumbers in DoFHandlers are not matching!",
928 "Integrator::ComputeNonlinearRhs");
933 dofs_per_element = element[0]->get_fe().dofs_per_cell;
935 local_vector.reinit(dofs_per_element);
938 local_dof_indices.resize(0);
939 local_dof_indices.resize(dofs_per_element, 0);
940 pde.ElementRhs(edc, local_vector, 1.);
942 if(need_boundary_integrals)
944 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
946 if (element[0]->face(face)->at_boundary()
948 (find(boundary_equation_colors.begin(),boundary_equation_colors.end(),
949 element[0]->face(face)->boundary_indicator()) != boundary_equation_colors.end()))
952 pde.BoundaryRhs(fdc,local_vector,1.);
958 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
960 if (element[0]->neighbor_index(face) != -1)
963 pde.FaceRhs(fdc, local_vector);
968 element[0]->get_dof_indices(local_dof_indices);
969 for (
unsigned int i = 0; i < dofs_per_element; ++i)
971 residual(local_dof_indices[i]) += local_vector(i);
974 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
984 pde.PointRhs(this->GetParamData(), this->GetDomainData(), point_rhs,
986 residual += point_rhs;
989 AddPresetRightHandSide(1.,residual);
991 if (apply_boundary_values)
993 ApplyNewtonBoundaryValues(pde, residual);
999 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1001 template<
typename PROBLEM,
typename MATRIX>
1004 PROBLEM& pde, MATRIX &matrix)
1008 unsigned int dofs_per_element;
1009 std::vector<unsigned int> local_dof_indices;
1011 const auto& dof_handler =
1012 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
1014 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1016 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
1018 GetIntegratorDataContainer().InitializeEDC(pde.GetUpdateFlags(),
1019 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
1020 this->GetParamData(), this->GetDomainData());
1021 auto& edc = GetIntegratorDataContainer().GetElementDataContainer();
1024 unsigned int nbr_dofs_per_element;
1025 std::vector<unsigned int> nbr_local_dof_indices;
1027 bool need_faces = pde.HasFaces();
1028 bool need_interfaces = pde.HasInterfaces();
1029 std::vector<unsigned int> boundary_equation_colors = pde.GetBoundaryEquationColors();
1030 bool need_boundary_integrals = (boundary_equation_colors.size() > 0);
1032 GetIntegratorDataContainer().InitializeFDC(pde.GetFaceUpdateFlags(),
1033 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
1035 this->GetParamData(),
1036 this->GetDomainData(),
1038 auto & fdc = GetIntegratorDataContainer().GetFaceDataContainer();
1040 for (; element[0] != endc[0]; element[0]++)
1042 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1044 if (element[dh] == endc[dh])
1047 "Elementnumbers in DoFHandlers are not matching!",
1048 "Integrator::ComputeMatrix");
1052 dofs_per_element = element[0]->get_fe().dofs_per_cell;
1054 dealii::FullMatrix<SCALAR> local_matrix(dofs_per_element,
1058 local_dof_indices.resize(0);
1059 local_dof_indices.resize(dofs_per_element, 0);
1060 pde.ElementMatrix(edc, local_matrix);
1062 if(need_boundary_integrals)
1064 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1066 if (element[0]->face(face)->at_boundary()
1068 (find(boundary_equation_colors.begin(),boundary_equation_colors.end(),
1069 element[0]->face(face)->boundary_indicator()) != boundary_equation_colors.end()))
1072 pde.BoundaryMatrix(fdc, local_matrix);
1078 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1080 if (element[0]->neighbor_index(face) != -1)
1083 pde.FaceMatrix(fdc, local_matrix);
1088 if( need_interfaces)
1090 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1095 if(AtInterface(element, face))
1102 if (element[0]->neighbor(face)->has_children())
1106 for (
unsigned int subface_no=0;
1107 subface_no < element[0]->face(face)->n_children();
1112 fdc.ReInit(face, subface_no);
1116 nbr_dofs_per_element = fdc.GetNbrNDoFsPerElement();
1117 nbr_local_dof_indices.resize(0);
1118 nbr_local_dof_indices.resize(nbr_dofs_per_element, 0);
1119 dealii::FullMatrix<SCALAR> local_interface_matrix(dofs_per_element,nbr_dofs_per_element );
1120 local_interface_matrix = 0;
1122 pde.InterfaceMatrix(fdc, local_interface_matrix);
1124 element[0]->get_dof_indices(local_dof_indices);
1125 element[0]->neighbor(face)->get_dof_indices(nbr_local_dof_indices);
1127 for (
unsigned int i = 0; i < dofs_per_element; ++i)
1129 for (
unsigned int j = 0; j < nbr_dofs_per_element; ++j)
1131 matrix.add(local_dof_indices[i], nbr_local_dof_indices[j],
1132 local_interface_matrix(i, j));
1145 nbr_dofs_per_element = fdc.GetNbrNDoFsPerElement();
1146 nbr_local_dof_indices.resize(0);
1147 nbr_local_dof_indices.resize(nbr_dofs_per_element, 0);
1148 dealii::FullMatrix<SCALAR> local_interface_matrix(dofs_per_element,nbr_dofs_per_element );
1149 local_interface_matrix = 0;
1151 pde.InterfaceMatrix(fdc, local_interface_matrix);
1153 element[0]->get_dof_indices(local_dof_indices);
1154 element[0]->neighbor(face)->get_dof_indices(nbr_local_dof_indices);
1156 for (
unsigned int i = 0; i < dofs_per_element; ++i)
1158 for (
unsigned int j = 0; j < nbr_dofs_per_element; ++j)
1160 matrix.add(local_dof_indices[i], nbr_local_dof_indices[j],
1161 local_interface_matrix(i, j));
1171 element[0]->get_dof_indices(local_dof_indices);
1172 for (
unsigned int i = 0; i < dofs_per_element; ++i)
1174 for (
unsigned int j = 0; j < dofs_per_element; ++j)
1176 matrix.add(local_dof_indices[i], local_dof_indices[j],
1177 local_matrix(i, j));
1181 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1188 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1190 template<
typename PROBLEM>
1198 const auto& dof_handler =
1199 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
1201 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1203 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
1204 GetIntegratorDataContainerFunc().InitializeEDC(pde.GetUpdateFlags(),
1205 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
1206 this->GetParamData(), this->GetDomainData());
1207 auto& edc = GetIntegratorDataContainerFunc().GetElementDataContainer();
1209 for (; element[0] != endc[0]; element[0]++)
1211 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1213 if (element[dh] == endc[dh])
1216 "Elementnumbers in DoFHandlers are not matching!",
1217 "Integrator::ComputeDomainScalar");
1222 ret += pde.ElementFunctional(edc);
1224 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1234 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1236 template<
typename PROBLEM>
1244 ret += pde.PointFunctional(this->GetParamData(),
1245 this->GetDomainData());
1252 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1254 template<
typename PROBLEM>
1263 const auto& dof_handler =
1264 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
1265 auto element = pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1266 auto endc = pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
1268 GetIntegratorDataContainerFunc().InitializeFDC(pde.GetFaceUpdateFlags(),
1269 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
1271 this->GetParamData(),
1272 this->GetDomainData());
1273 auto & fdc = GetIntegratorDataContainerFunc().GetFaceDataContainer();
1275 std::vector<unsigned int> boundary_functional_colors = pde.GetBoundaryFunctionalColors();
1276 bool need_boundary_integrals = (boundary_functional_colors.size() > 0);
1277 if(!need_boundary_integrals)
1279 throw DOpEException(
"No boundary colors given!",
"Integrator::ComputeBoundaryScalar");
1282 for (;element[0]!=endc[0]; element[0]++)
1284 for(
unsigned int dh=1; dh<dof_handler.size(); dh++)
1286 if( element[dh] == endc[dh])
1288 throw DOpEException(
"Elementnumbers in DoFHandlers are not matching!",
"Integrator::ComputeBoundaryScalar");
1292 if(need_boundary_integrals)
1294 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1296 if (element[0]->face(face)->at_boundary()
1298 (find(boundary_functional_colors.begin(),boundary_functional_colors.end(),
1299 element[0]->face(face)->boundary_indicator()) != boundary_functional_colors.end()))
1302 ret += pde.BoundaryFunctional(fdc);
1306 for(
unsigned int dh=1; dh<dof_handler.size(); dh++)
1318 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1320 template<
typename PROBLEM>
1330 const auto& dof_handler =
1331 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
1332 auto element = pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1333 auto endc = pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
1335 GetIntegratorDataContainerFunc().InitializeFDC(pde.GetFaceUpdateFlags(),
1336 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
1338 this->GetParamData(),
1339 this->GetDomainData());
1340 auto & fdc = GetIntegratorDataContainerFunc().GetFaceDataContainer();
1342 bool need_faces = pde.HasFaces();
1345 throw DOpEException(
"No faces required!",
"Integrator::ComputeFaceScalar");
1348 for (;element[0]!=endc[0]; element[0]++)
1350 for(
unsigned int dh=1; dh<dof_handler.size(); dh++)
1352 if( element[dh] == endc[dh])
1354 throw DOpEException(
"Elementnumbers in DoFHandlers are not matching!",
"Integrator::ComputeFaceScalar");
1360 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1362 if (element[0]->neighbor_index(face) != -1)
1365 ret +=pde.FaceFunctional(fdc);
1369 for(
unsigned int dh=1; dh<dof_handler.size(); dh++)
1379 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1381 template<
typename PROBLEM>
1389 ret = pde.AlgebraicFunctional(this->GetParamData(),
1390 this->GetDomainData());
1397 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1399 template<
typename PROBLEM>
1402 PROBLEM& pde, VECTOR &residual)
1405 pde.AlgebraicResidual(residual, this->GetParamData(),
1406 this->GetDomainData());
1408 AddPresetRightHandSide(-1.,residual);
1413 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1415 template<
typename PROBLEM>
1418 PROBLEM& pde, VECTOR &constraints)
1421 pde.ComputeLocalControlConstraints(constraints, this->GetParamData(),
1422 this->GetDomainData());
1427 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1429 template<
typename PROBLEM>
1432 PROBLEM& , VECTOR &)
1439 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1441 template<
typename PROBLEM>
1444 PROBLEM& pde, VECTOR &u)
1451 std::vector<unsigned int> dirichlet_colors = pde.GetDirichletColors();
1452 for (
unsigned int i = 0; i < dirichlet_colors.size(); i++)
1454 unsigned int color = dirichlet_colors[i];
1455 std::vector<bool> comp_mask = pde.GetDirichletCompMask(color);
1456 std::map<unsigned int, SCALAR> boundary_values;
1458 InterpolateBoundaryValues( pde.GetBaseProblem().GetSpaceTimeHandler()->GetMapping(),
1459 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler()[0],
1461 pde.GetDirichletValues(color, this->GetParamData(),
1462 this->GetDomainData()), boundary_values, comp_mask);
1464 for (
typename std::map<unsigned int, SCALAR>::const_iterator p =
1465 boundary_values.begin(); p != boundary_values.end(); p++)
1467 u(p->first) = p->second;
1474 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1476 template<
typename PROBLEM>
1479 PROBLEM& pde, VECTOR &u)
1484 pde.GetDoFConstraints().condense(u);
1485 std::vector<unsigned int> dirichlet_colors = pde.GetDirichletColors();
1486 for (
unsigned int i = 0; i < dirichlet_colors.size(); i++)
1488 unsigned int color = dirichlet_colors[i];
1489 std::vector<bool> comp_mask = pde.GetDirichletCompMask(color);
1490 std::map<unsigned int, SCALAR> boundary_values;
1492 InterpolateBoundaryValues( pde.GetBaseProblem().GetSpaceTimeHandler()->GetMapping(),
1493 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler()[0],
1494 color, dealii::ZeroFunction<dim>(comp_mask.size()),
1495 boundary_values, comp_mask);
1497 for (
typename std::map<unsigned int, SCALAR>::const_iterator p =
1498 boundary_values.begin(); p != boundary_values.end(); p++)
1500 u(p->first) = p->second;
1506 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1508 template<
typename PROBLEM,
typename MATRIX>
1511 PROBLEM& pde, MATRIX& matrix, VECTOR &rhs, VECTOR &sol)
1515 pde.GetDoFConstraints().condense(rhs);
1516 pde.GetDoFConstraints().condense(matrix);
1517 std::vector<unsigned int> dirichlet_colors = pde.GetDirichletColors();
1518 for (
unsigned int i = 0; i < dirichlet_colors.size(); i++)
1520 unsigned int color = dirichlet_colors[i];
1521 std::vector<bool> comp_mask = pde.GetDirichletCompMask(color);
1522 std::map<unsigned int, SCALAR> boundary_values;
1524 InterpolateBoundaryValues( pde.GetBaseProblem().GetSpaceTimeHandler()->GetMapping(),
1525 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler()[0],
1526 color, dealii::ZeroFunction<dim>(comp_mask.size()),
1527 boundary_values, comp_mask);
1529 dealii::MatrixTools::apply_boundary_values(boundary_values, matrix,
1536 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1540 std::string name,
const VECTOR* new_data)
1542 if (domain_data_.find(name) != domain_data_.end())
1545 "Adding multiple Data with name " + name +
" is prohibited!",
1546 "Integrator::AddDomainData");
1548 domain_data_.insert(
1549 std::pair<std::string, const VECTOR*>(name, new_data));
1554 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1560 typename std::map<std::string, const VECTOR *>::iterator it =
1561 domain_data_.find(name);
1562 if (it == domain_data_.end())
1565 "Deleting Data " + name +
" is impossible! Data not found",
1566 "Integrator::DeleteDomainData");
1568 domain_data_.erase(it);
1573 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1575 const std::map<std::string, const VECTOR*>&
1578 return domain_data_;
1583 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1587 std::string name,
const dealii::Vector<SCALAR>* new_data)
1589 if (param_data_.find(name) != param_data_.end())
1592 "Adding multiple Data with name " + name +
" is prohibited!",
1593 "Integrator::AddParamData");
1596 std::pair<std::string,
const dealii::Vector<SCALAR>*>(name,
1602 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1608 typename std::map<std::string, const dealii::Vector<SCALAR>*>::iterator it =
1609 param_data_.find(name);
1610 if (it == param_data_.end())
1613 "Deleting Data " + name +
" is impossible! Data not found",
1614 "Integrator::DeleteParamData");
1616 param_data_.erase(it);
1621 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1623 const std::map<std::string, const dealii::Vector<SCALAR>*>&
1631 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1633 template<
typename PROBLEM,
class STH,
class EDC,
class FDC>
1641 std::vector<double> element_sum(n_error_comps, 0);
1642 element_sum.resize(n_error_comps, 0);
1645 const auto& dof_handler =
1646 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
1648 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1650 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
1652 const auto& dof_handler_weight = dwrc.
GetWeightSTH().GetDoFHandler();
1653 auto element_weight = dwrc.
GetWeightSTH().GetDoFHandlerBeginActive();
1654 auto endc_high = dwrc.
GetWeightSTH().GetDoFHandlerEnd();
1658 GetIntegratorDataContainer().InitializeEDC(
1660 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
1661 this->GetParamData(), this->GetDomainData());
1662 auto& edc = GetIntegratorDataContainer().GetElementDataContainer();
1664 dwrc.
GetWeightIDC().InitializeEDC(pde.GetUpdateFlags(),
1665 dwrc.
GetWeightSTH(), element_weight, this->GetParamData(),
1672 typename std::map<typename dealii::Triangulation<dim>::face_iterator,std::vector<double> >
1677 auto element_it = element[0];
1678 std::vector<double> face_init(n_error_comps,-1e20);
1679 for (; element_it != endc[0]; element_it++)
1681 for (
unsigned int face_no=0;face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
1683 face_integrals[element_it->face(face_no)] = face_init;
1692 GetIntegratorDataContainer().InitializeFDC(dwrc.
GetWeightIDC().GetFaceQuad(),
1693 pde.GetFaceUpdateFlags(),
1694 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
1696 this->GetParamData(),
1697 this->GetDomainData(),
1699 auto & fdc = GetIntegratorDataContainer().GetFaceDataContainer();
1701 dwrc.
GetWeightIDC().InitializeFDC(pde.GetFaceUpdateFlags(),
1704 this->GetParamData(),
1708 for (
unsigned int element_index = 0; element[0] != endc[0];
1709 element[0]++, element_index++)
1711 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1713 if (element[dh] == endc[dh])
1716 "Elementnumbers in DoFHandlers are not matching!",
1717 "Integrator::ComputeRefinementIndicators");
1720 for (
unsigned int dh = 0; dh < dof_handler_weight.size(); dh++)
1722 if (element_weight[dh] == endc_high[dh])
1725 "Elementnumbers in DoFHandlers are not matching!",
1726 "Integrator::ComputeRefinementIndicators");
1729 element_sum.clear();
1730 element_sum.resize(n_error_comps, 0);
1733 edc_weight.ReInit();
1736 pde.ElementErrorContribution(edc, dwrc, element_sum, 1.);
1737 for(
unsigned int l =0; l < n_error_comps; l ++)
1743 element_sum.clear();
1744 element_sum.resize(n_error_comps, 0);
1750 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1752 auto face_it = element[0]->face(face);
1755 if(face_it->at_boundary())
1759 pde.BoundaryErrorContribution(fdc, dwrc, element_sum, 1.);
1761 Assert (face_integrals.find (element[0]->face(face)) != face_integrals.end(),
1762 ExcInternalError());
1763 Assert (face_integrals[element[0]->face(face)] == face_init,
1764 ExcInternalError());
1766 face_integrals[element[0]->face(face)] = element_sum;
1767 element_sum.clear();
1768 element_sum.resize(n_error_comps,0.);
1776 if (element[0]->neighbor(face)->has_children())
1779 std::vector<double> sum(n_error_comps,0.);
1780 for (
unsigned int subface_no=0;
1781 subface_no < element[0]->face(face)->n_children();
1786 fdc.ReInit(face, subface_no);
1790 pde.FaceErrorContribution(fdc, dwrc, element_sum, 1.);
1791 for(
unsigned int l =0; l < n_error_comps; l ++)
1793 sum[l] += element_sum[l];
1795 face_integrals[element[0]->neighbor_child_on_subface(face, subface_no)
1796 ->face(element[0]->neighbor_of_neighbor(face))] = element_sum;
1797 element_sum.clear();
1798 element_sum.resize(n_error_comps,0);
1801 Assert (face_integrals.find (element[0]->face(face)) != face_integrals.end(),
1802 ExcInternalError());
1803 Assert (face_integrals[element[0]->face(face)] == face_init,
1804 ExcInternalError());
1806 face_integrals[element[0]->face(face)] = sum;
1807 element_sum.clear();
1808 element_sum.resize(n_error_comps,0);
1814 Assert(element[0]->neighbor(face)->level() <= element[0]->level(),ExcInternalError());
1817 if(element[0]->level() == element[0]->neighbor(face)->level()
1818 && element[0]->index() < element[0]->neighbor(face)->index())
1824 pde.FaceErrorContribution(fdc, dwrc, element_sum, 1.);
1825 Assert (face_integrals.find (element[0]->face(face)) != face_integrals.end(),
1826 ExcInternalError());
1827 Assert (face_integrals[element[0]->face(face)] == face_init,
1828 ExcInternalError());
1830 face_integrals[element[0]->face(face)] = element_sum;
1831 element_sum.clear();
1832 element_sum.resize(n_error_comps,0);
1837 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1841 for (
unsigned int dh = 0; dh < dof_handler_weight.size(); dh++)
1843 element_weight[dh]++;
1848 unsigned int present_element = 0;
1850 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1852 element[0] !=endc[0]; element[0]++, ++present_element)
1854 for (
unsigned int face_no = 0;
1855 face_no < GeometryInfo<dim>::faces_per_cell; ++face_no)
1858 face_integrals.find(element[0]->face(face_no)) != face_integrals.end(),
1859 ExcInternalError());
1860 if(element[0]->face(face_no)->at_boundary())
1862 for(
unsigned int l =0; l < n_error_comps; l ++)
1865 face_integrals[element[0]->face(face_no)][l];
1874 for(
unsigned int l =0; l < n_error_comps; l ++)
1877 0.5*face_integrals[element[0]->face(face_no)][l];
1890 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
1892 template<
typename PROBLEM>
1899 std::vector<double> element_sum(2, 0);
1900 element_sum.resize(2, 0);
1902 const auto& dof_handler =
1903 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandler();
1905 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
1907 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerEnd();
1913 for (; wd != wend; wd++)
1915 AddDomainData(wd->first, wd->second);
1921 GetIntegratorDataContainer().InitializeEDC(pde.GetUpdateFlags(),
1922 *(pde.GetBaseProblem().GetSpaceTimeHandler()), element,
1923 this->GetParamData(), this->GetDomainData());
1924 auto& edc = GetIntegratorDataContainer().GetElementDataContainer();
1927 typename std::map<typename dealii::Triangulation<dim>::face_iterator,std::vector<double> >
1930 auto element_it = element[0];
1931 std::vector<double> face_init(2,-1e20);
1932 for (; element_it != endc[0]; element_it++)
1934 for (
unsigned int face_no=0;face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
1936 face_integrals[element_it->face(face_no)] = face_init;
1945 GetIntegratorDataContainer().InitializeFDC(
1946 pde.GetFaceUpdateFlags(),
1947 *(pde.GetBaseProblem().GetSpaceTimeHandler()),
1949 this->GetParamData(),
1950 this->GetDomainData(),
1952 auto & fdc = GetIntegratorDataContainer().GetFaceDataContainer();
1954 for (
unsigned int element_index = 0; element[0] != endc[0];
1955 element[0]++, element_index++)
1957 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
1959 if (element[dh] == endc[dh])
1962 "Elementnumbers in DoFHandlers are not matching!",
1963 "Integrator::ComputeRefinementIndicators");
1967 element_sum.clear();
1968 element_sum.resize(2, 0);
1973 pde.ElementErrorContribution(edc, dwrc, element_sum, 1.);
1976 element_sum.clear();
1977 element_sum.resize(2, 0);
1982 for (
unsigned int face=0; face < dealii::GeometryInfo<dim>::faces_per_cell; ++face)
1984 auto face_it = element[0]->face(face);
1987 if(face_it->at_boundary())
1990 #if deal_II_dimension > 1
1991 dwrc.
InitFace(element[0]->face(face)->diameter());
1993 dwrc.
InitFace(element[0]->diameter());
1995 pde.BoundaryErrorContribution(fdc, dwrc, element_sum, 1.);
1997 Assert (face_integrals.find (element[0]->face(face)) != face_integrals.end(),
1998 ExcInternalError());
1999 Assert (face_integrals[element[0]->face(face)] == face_init,
2000 ExcInternalError());
2001 face_integrals[element[0]->face(face)] = element_sum;
2002 element_sum.clear();
2003 element_sum.resize(2,0.);
2011 if (element[0]->neighbor(face)->has_children())
2014 std::vector<double> sum(2,0.);
2015 for (
unsigned int subface_no=0;
2016 subface_no < element[0]->face(face)->n_children();
2021 fdc.ReInit(face, subface_no);
2023 #if deal_II_dimension > 1
2024 dwrc.
InitFace(element[0]->face(face)->diameter());
2026 dwrc.
InitFace(element[0]->diameter());
2029 pde.FaceErrorContribution(fdc, dwrc, element_sum, 1.);
2030 sum[0]= element_sum[0];
2031 sum[1]= element_sum[1];
2032 element_sum.clear();
2033 element_sum.resize(2,0);
2034 face_integrals[element[0]->neighbor_child_on_subface(face, subface_no)
2035 ->face(element[0]->neighbor_of_neighbor(face))] = element_sum;
2036 element_sum.clear();
2037 element_sum.resize(2,0.);
2040 Assert (face_integrals.find (element[0]->face(face)) != face_integrals.end(),
2041 ExcInternalError());
2042 Assert (face_integrals[element[0]->face(face)] == face_init,
2043 ExcInternalError());
2045 face_integrals[element[0]->face(face)] = sum;
2052 Assert(element[0]->neighbor(face)->level() <= element[0]->level(),ExcInternalError());
2055 if(element[0]->level() == element[0]->neighbor(face)->level()
2056 && element[0]->index() < element[0]->neighbor(face)->index())
2060 #if deal_II_dimension > 1
2061 dwrc.
InitFace(element[0]->face(face)->diameter());
2063 dwrc.
InitFace(element[0]->diameter());
2066 pde.FaceErrorContribution(fdc, dwrc, element_sum, 1.);
2067 Assert (face_integrals.find (element[0]->face(face)) != face_integrals.end(),
2068 ExcInternalError());
2069 Assert (face_integrals[element[0]->face(face)] == face_init,
2070 ExcInternalError());
2072 face_integrals[element[0]->face(face)] = element_sum;
2073 element_sum.clear();
2074 element_sum.resize(2,0);
2081 for (
unsigned int dh = 1; dh < dof_handler.size(); dh++)
2088 unsigned int present_element = 0;
2090 pde.GetBaseProblem().GetSpaceTimeHandler()->GetDoFHandlerBeginActive();
2092 element[0] !=endc[0]; element[0]++, ++present_element)
2093 for (
unsigned int face_no = 0;
2094 face_no < GeometryInfo<dim>::faces_per_cell; ++face_no)
2097 face_integrals.find(element[0]->face(face_no)) != face_integrals.end(),
2098 ExcInternalError());
2100 0.5 * face_integrals[element[0]->face(face_no)][0];
2102 0.5 * face_integrals[element[0]->face(face_no)][1];
2108 for (; wd != wend; wd++)
2110 DeleteDomainData(wd->first);
2117 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
2127 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
2137 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
2139 template<
template<
int,
int>
class DH>
2144 const unsigned int color,
const dealii::Function<dim>&
function,
2145 std::map<unsigned int, SCALAR>& boundary_values,
2146 const std::vector<bool>& comp_mask)
const
2150 dealii::VectorTools::interpolate_boundary_values(mapping[0],
2152 boundary_values, comp_mask);
2156 template<
typename INTEGRATORDATACONT,
typename VECTOR,
typename SCALAR,
2160 VECTOR &residual)
const
2162 typename std::map<std::string, const VECTOR *>::const_iterator it =
2163 domain_data_.find(
"fixed_rhs");
2164 if (it != domain_data_.end())
2166 assert(residual.size() == it->second->size());
2167 residual.add(s,*(it->second));
SCALAR ComputeDomainScalar(PROBLEM &pde)
Definition: integrator.h:1192
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:1256
void AddParamData(std::string name, const dealii::Vector< SCALAR > *new_data)
Definition: integrator.h:1586
void ComputeNonlinearLhs(PROBLEM &pde, VECTOR &residual, bool apply_boundary_values=true)
Definition: integrator.h:719
virtual EDC & GetElementWeight() const =0
~Integrator()
Definition: integrator.h:527
SCALAR ComputePointScalar(PROBLEM &pde)
Definition: integrator.h:1238
Definition: integrator.h:59
void ApplyInitialBoundaryValues(PROBLEM &pde, VECTOR &u)
Definition: integrator.h:1443
Vector< double > & GetPrimalErrorIndicators()
Definition: dwrdatacontainer.h:233
void ComputeLocalControlConstraints(PROBLEM &pde, VECTOR &constraints)
Definition: integrator.h:1417
void ComputeMatrix(PROBLEM &pde, MATRIX &matrix)
Definition: integrator.h:1003
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:1635
const Vector< double > & GetErrorIndicators() const
Definition: dwrdatacontainer.h:213
const std::map< std::string, const dealii::Vector< SCALAR > * > & GetParamData() const
Definition: integrator.h:1624
INTEGRATORDATACONT & GetIntegratorDataContainerFunc() const
Definition: integrator.h:2130
Vector< double > & GetDualErrorIndicators()
Definition: dwrdatacontainer.h:251
virtual STH & GetWeightSTH()=0
SCALAR ComputeFaceScalar(PROBLEM &pde)
Definition: integrator.h:1322
void AddPresetRightHandSide(double s, VECTOR &residual) const
Definition: integrator.h:2159
void DeleteParamData(std::string name)
Definition: integrator.h:1605
void DeleteDomainData(std::string name)
Definition: integrator.h:1557
Integrator(INTEGRATORDATACONT &idc1)
Definition: integrator.h:509
Definition: residualestimator.h:38
SCALAR ComputeAlgebraicScalar(PROBLEM &pde)
Definition: integrator.h:1383
void AddDomainData(std::string name, const VECTOR *new_data)
Definition: integrator.h:1539
void ApplyTransposedInitialBoundaryValues(PROBLEM &pde, VECTOR &u)
Definition: integrator.h:1431
virtual FDC & GetFaceWeight() const =0
INTEGRATORDATACONT & GetIntegratorDataContainer() const
Definition: integrator.h:2120
unsigned int GetNErrorComps() const
Definition: dwrdatacontainer.h:317
virtual void InitFace(double)=0
void ReInit()
Definition: integrator.h:537
virtual IDC & GetWeightIDC()=0
Definition: dopeexception.h:35
void ApplyNewtonBoundaryValues(PROBLEM &pde, VECTOR &u)
Definition: integrator.h:1478
void ComputeNonlinearAlgebraicResidual(PROBLEM &pde, VECTOR &residual)
Definition: integrator.h:1401
Definition: dwrdatacontainer.h:545
void ComputeNonlinearRhs(PROBLEM &pde, VECTOR &residual, bool apply_boundary_values=true)
Definition: integrator.h:879
virtual void InitElement(double)=0
void ComputeNonlinearResidual(PROBLEM &pde, VECTOR &residual, bool apply_boundary_values=true)
Definition: integrator.h:548
const std::map< std::string, const VECTOR * > & GetDomainData() const
Definition: integrator.h:1576