24 #ifndef STATE_PROBLEM_H_
25 #define STATE_PROBLEM_H_
29 using namespace dealii;
46 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
47 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
52 pde_(pde), opt_problem_(OP)
54 dirichlet_colors_ = opt_problem_.dirichlet_colors_;
55 dirichlet_comps_ = opt_problem_.dirichlet_comps_;
56 primal_dirichlet_values_ = opt_problem_.primal_dirichlet_values_;
57 state_boundary_equation_colors_
58 = opt_problem_.state_boundary_equation_colors_;
59 interval_length_ = 1.;
65 return "StateProblem";
79 template<
typename EDC>
81 dealii::Vector<double> &local_vector,
double scale,
84 pde_.Init_ElementEquation(edc, local_vector, scale, scale_ico);
91 template<
typename EDC>
94 dealii::Vector<double> &local_vector,
double scale)
96 pde_.Init_ElementRhs(& GetInitialValues(), edc, local_vector, scale);
105 const std::map<std::string,
const dealii::Vector<double>*> &,
106 const std::map<std::string, const VECTOR*> &,
117 template<
typename EDC>
119 dealii::FullMatrix<double> &local_entry_matrix,
double scale,
122 pde_.Init_ElementMatrix(edc, local_entry_matrix, scale, scale_ico);
131 template<
typename EDC>
133 ElementEquation(
const EDC& edc,
134 dealii::Vector<double> &local_vector,
double scale,
141 template<
typename EDC>
143 ElementTimeEquation(
const EDC& edc,
144 dealii::Vector<double> &local_vector,
double scale = 1.);
150 template<
typename EDC>
152 ElementTimeEquationExplicit(
const EDC& edc,
153 dealii::Vector<double> &local_vector,
double scale = 1.);
159 template<
typename EDC>
161 ElementRhs(
const EDC& edc,
162 dealii::Vector<double> &local_vector,
double scale = 1.);
170 const std::map<std::string,
const dealii::Vector<double>*> ¶m_values,
171 const std::map<std::string, const VECTOR*> &domain_values,
172 VECTOR& rhs_vector,
double scale);
178 template<
typename EDC>
180 ElementMatrix(
const EDC& edc,
181 dealii::FullMatrix<double> &local_entry_matrix,
double scale = 1.,
182 double scale_ico = 1.);
188 template<
typename EDC>
190 ElementTimeMatrix(
const EDC& edc,
191 dealii::FullMatrix<double> &local_entry_matrix);
197 template<
typename EDC>
199 ElementTimeMatrixExplicit(
const EDC& edc,
200 dealii::FullMatrix<double> &local_entry_matrix);
206 template<
typename FDC>
208 FaceEquation(
const FDC& fdc,
209 dealii::Vector<double> &local_vector,
double scale = 1.,
double scale_ico = 1.);
215 template<
typename FDC>
217 InterfaceEquation(
const FDC& fdc,
218 dealii::Vector<double> &local_vector,
double scale = 1.,
double scale_ico = 1.);
224 template<
typename FDC>
226 FaceRhs(
const FDC& fdc,
227 dealii::Vector<double> &local_vector,
double scale = 1.);
233 template<
typename FDC>
235 FaceMatrix(
const FDC& fdc,
236 dealii::FullMatrix<double> &local_entry_matrix,
double scale = 1.,
double scale_ico = 1.);
238 template<
typename FDC>
240 InterfaceMatrix(
const FDC& fdc,
241 dealii::FullMatrix<double> &local_entry_matrix,
double scale = 1.,
double scale_ico = 1.);
247 template<
typename FDC>
249 BoundaryEquation(
const FDC& fdc,
250 dealii::Vector<double> &local_vector,
double scale = 1.,
double scale_ico = 1.);
256 template<
typename FDC>
258 BoundaryRhs(
const FDC& fdc,
259 dealii::Vector<double> &local_vector,
double scale = 1.);
265 template<
typename FDC>
267 BoundaryMatrix(
const FDC& fdc,
268 dealii::FullMatrix<double> &local_matrix,
double scale = 1.,
double scale_ico = 1.);
274 inline const dealii::SmartPointer<const dealii::FESystem<dim> >
281 inline const dealii::SmartPointer<
282 const dealii::hp::FECollection<dim> >
283 GetFECollection()
const;
309 HasInterfaces()
const;
315 inline dealii::UpdateFlags
316 GetUpdateFlags()
const;
322 inline dealii::UpdateFlags
323 GetFaceUpdateFlags()
const;
332 unsigned int time_dof_number,
340 ComputeSparsityPattern(SPARSITYPATTERN & sparsity)
const;
345 ComputeMGSparsityPattern(dealii::MGLevelObject<dealii::BlockSparsityPattern> & mg_sparsity_patterns,
346 unsigned int n_levels)
const;
349 ComputeMGSparsityPattern(dealii::MGLevelObject<dealii::SparsityPattern> & mg_sparsity_patterns,
350 unsigned int n_levels)
const;
356 inline const std::vector<unsigned int>&
357 GetDirichletColors()
const;
362 inline const std::vector<bool>&
363 GetDirichletCompMask(
unsigned int color)
const;
368 inline const Function<dim>
372 const std::map<std::string,
const dealii::Vector<double>*> ¶m_values,
373 const std::map<std::string, const VECTOR*> &domain_values)
const;
378 inline const std::vector<unsigned int>&
379 GetBoundaryEquationColors()
const;
384 inline const dealii::ConstraintMatrix&
385 GetDoFConstraints()
const;
390 const dealii::Function<dim>&
391 GetInitialValues()
const;
396 return opt_problem_.GetOutputHandler();
404 template<
typename ELEMENTITERATOR>
405 bool AtInterface(ELEMENTITERATOR& element,
unsigned int face)
const;
411 OPTPROBLEM& opt_problem_;
413 std::vector<unsigned int> dirichlet_colors_;
414 std::vector<std::vector<bool> > dirichlet_comps_;
415 std::vector<PrimalDirichletData<DD, VECTOR, dim>*>
416 primal_dirichlet_values_;
417 std::vector<unsigned int> state_boundary_equation_colors_;
418 double interval_length_;
425 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
426 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
427 template<
typename EDC>
429 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
430 dim>::ElementEquation(
const EDC& edc,
431 dealii::Vector<double> &local_vector,
double scale,
434 pde_.ElementEquation(edc, local_vector, scale*interval_length_, scale_ico*interval_length_);
439 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
440 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
441 template<
typename EDC>
443 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
444 dim>::ElementTimeEquation(
const EDC& edc,
445 dealii::Vector<double> &local_vector,
double scale)
452 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
453 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
454 template<
typename EDC>
456 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
457 dim>::ElementTimeEquationExplicit(
const EDC& edc,
458 dealii::Vector<double> &local_vector,
double scale)
465 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
466 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
467 template<
typename FDC>
469 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
470 dim>::FaceEquation(
const FDC& fdc,
471 dealii::Vector<double> &local_vector,
double scale,
double scale_ico)
473 pde_.
FaceEquation(fdc, local_vector, scale*interval_length_, scale_ico*interval_length_);
478 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
479 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
480 template<
typename FDC>
482 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
483 dim>::InterfaceEquation(
const FDC& fdc,
484 dealii::Vector<double> &local_vector,
double scale,
double scale_ico)
486 pde_.
InterfaceEquation(fdc, local_vector, scale*interval_length_, scale_ico*interval_length_);
490 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
491 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
492 template<
typename FDC>
494 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
495 dim>::BoundaryEquation(
const FDC& fdc,
496 dealii::Vector<double> &local_vector,
double scale,
double scale_ico)
498 pde_.
BoundaryEquation(fdc, local_vector, scale*interval_length_, scale_ico*interval_length_);
503 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
504 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
505 template<
typename EDC>
507 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
508 dim>::ElementRhs(
const EDC& edc,
509 dealii::Vector<double> &local_vector,
double scale)
511 pde_.ElementRightHandSide(edc, local_vector, scale*interval_length_);
516 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
517 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
520 const std::map<std::string,
const dealii::Vector<double>*> &,
521 const std::map<std::string, const VECTOR*> &,
529 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
530 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
531 template<
typename FDC>
533 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
534 dim>::FaceRhs(
const FDC& fdc,
535 dealii::Vector<double> &local_vector,
double scale)
537 pde_.FaceRightHandSide(fdc, local_vector, scale*interval_length_);
542 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
543 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
544 template<
typename FDC>
546 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
547 dim>::BoundaryRhs(
const FDC& fdc,
548 dealii::Vector<double> &local_vector,
double scale)
550 pde_.BoundaryRightHandSide(fdc, local_vector, scale*interval_length_);
555 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
556 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
557 template<
typename EDC>
559 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
560 dim>::ElementMatrix(
const EDC& edc,
561 dealii::FullMatrix<double> &local_entry_matrix,
double scale,
564 pde_.
ElementMatrix(edc, local_entry_matrix, scale*interval_length_, scale_ico*interval_length_);
569 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
570 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
571 template<
typename EDC>
573 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
574 dim>::ElementTimeMatrix(
const EDC& edc,
575 FullMatrix<double> &local_entry_matrix)
582 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
583 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
584 template<
typename EDC>
586 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
587 dim>::ElementTimeMatrixExplicit(
const EDC& edc,
588 dealii::FullMatrix<double> &local_entry_matrix)
595 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
596 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
597 template<
typename FDC>
599 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
600 dim>::FaceMatrix(
const FDC& fdc,
601 FullMatrix<double> &local_entry_matrix,
double scale,
604 pde_.
FaceMatrix(fdc, local_entry_matrix, scale*interval_length_, scale_ico*interval_length_);
609 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
610 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
611 template<
typename FDC>
613 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
614 dim>::InterfaceMatrix(
const FDC& fdc,
615 FullMatrix<double> &local_entry_matrix,
double scale,
618 pde_.
InterfaceMatrix(fdc, local_entry_matrix, scale*interval_length_, scale_ico*interval_length_);
623 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
624 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
625 template<
typename FDC>
627 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
628 dim>::BoundaryMatrix(
const FDC& fdc,
629 FullMatrix<double> &local_matrix,
double scale,
632 pde_.
BoundaryMatrix(fdc, local_matrix, scale*interval_length_, scale_ico*interval_length_);
637 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
638 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
647 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
648 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
649 const SmartPointer<const dealii::FESystem<dim> >
652 return opt_problem_.GetSpaceTimeHandler()->
GetFESystem(
"state");
656 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
657 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
658 const SmartPointer<const dealii::hp::FECollection<dim> >
666 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
667 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
673 return r | update_JxW_values;
678 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
679 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
685 return r | update_JxW_values;
690 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
691 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
697 opt_problem_.
SetTime(time, time_dof_number, interval, initial);
698 interval_length_ = opt_problem_.GetSpaceTimeHandler()->GetStepSize();
703 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
704 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
707 SPARSITYPATTERN & sparsity)
const
709 opt_problem_.GetSpaceTimeHandler()->ComputeStateSparsityPattern(sparsity);
714 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
715 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
718 dealii::MGLevelObject<dealii::BlockSparsityPattern> & mg_sparsity_patterns,
719 unsigned int n_levels)
const
721 opt_problem_.GetSpaceTimeHandler()->ComputeMGStateSparsityPattern(mg_sparsity_patterns, n_levels);
726 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
727 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
730 dealii::MGLevelObject<dealii::SparsityPattern> & mg_sparsity_patterns,
731 unsigned int n_levels)
const
733 opt_problem_.GetSpaceTimeHandler()->ComputeMGStateSparsityPattern(mg_sparsity_patterns, n_levels);
740 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
741 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
750 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
751 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
761 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
762 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
771 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
772 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
773 const std::vector<unsigned int>&
776 return dirichlet_colors_;
781 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
782 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
783 const std::vector<bool>&
785 unsigned int color)
const
787 unsigned int comp = dirichlet_colors_.size();
788 for (
unsigned int i = 0; i < dirichlet_colors_.size(); ++i)
790 if (dirichlet_colors_[i] == color)
796 if (comp == dirichlet_colors_.size())
799 s <<
"DirichletColor" << color <<
" has not been found !";
800 throw DOpEException(s.str(),
"OptProblem::GetDirichletCompMask");
802 return dirichlet_comps_[comp];
807 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
808 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
812 const std::map<std::string,
const dealii::Vector<double>*> ¶m_values,
813 const std::map<std::string, const VECTOR*> &domain_values)
const
815 unsigned int col = dirichlet_colors_.size();
816 for (
unsigned int i = 0; i < dirichlet_colors_.size(); ++i)
818 if (dirichlet_colors_[i] == color)
824 if (col == dirichlet_colors_.size())
827 s <<
"DirichletColor" << color <<
" has not been found !";
828 throw DOpEException(s.str(),
"OptProblem::GetDirichletValues");
830 primal_dirichlet_values_[col]->ReInit(param_values, domain_values, color);
831 return *(primal_dirichlet_values_[col]);
836 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
837 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
838 const std::vector<unsigned int>&
841 return state_boundary_equation_colors_;
846 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
847 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
848 const dealii::ConstraintMatrix&
851 return opt_problem_.GetSpaceTimeHandler()->GetStateDoFConstraints();
856 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
857 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
const dealii::Function<dim>&
865 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
866 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
867 template<
typename ELEMENTITERATOR>
Definition: stateproblem.h:48
void FaceMatrix(const FDC &fdc, dealii::FullMatrix< double > &local_entry_matrix, double scale=1., double scale_ico=1.)
void InterfaceEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale=1., double scale_ico=1.)
Definition: stateproblem.h:483
dealii::UpdateFlags GetFaceUpdateFlags() const
Definition: stateproblem.h:681
void Init_ElementEquation(const EDC &edc, dealii::Vector< double > &local_vector, double scale, double scale_ico)
Definition: stateproblem.h:80
OPTPROBLEM & GetBaseProblem()
Definition: stateproblem.h:399
void ElementTimeEquationExplicit(const EDC &edc, dealii::Vector< double > &local_vector, double scale=1.)
Definition: stateproblem.h:457
Definition: dopetypes.h:106
void BoundaryEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale=1., double scale_ico=1.)
Definition: stateproblem.h:495
StateProblem(OPTPROBLEM &OP, PDE &pde)
Definition: stateproblem.h:51
const dealii::SmartPointer< const dealii::FESystem< dim > > GetFESystem() const
Definition: stateproblem.h:650
void SetTime(double time, unsigned int time_dof_number, const TimeIterator &interval, bool initial=false)
Definition: stateproblem.h:693
Definition: optproblemcontainer.h:70
void Init_PointRhs(const std::map< std::string, const dealii::Vector< double > * > &, const std::map< std::string, const VECTOR * > &, VECTOR &, double)
Definition: stateproblem.h:104
std::string GetName() const
Definition: stateproblem.h:63
const dealii::SmartPointer< const dealii::hp::FECollection< dim > > GetFECollection() const
Definition: stateproblem.h:659
void FaceEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale=1., double scale_ico=1.)
Definition: stateproblem.h:470
DOpEOutputHandler< VECTOR > * GetOutputHandler()
Definition: stateproblem.h:394
Definition: timeiterator.h:62
void ElementMatrix(const EDC &edc, dealii::FullMatrix< double > &local_entry_matrix, double scale=1., double scale_ico=1.)
Definition: stateproblem.h:560
bool HasInterfaces() const
Definition: stateproblem.h:764
void ElementTimeEquation(const EDC &edc, dealii::Vector< double > &local_vector, double scale=1.)
Definition: stateproblem.h:444
dealii::UpdateFlags GetUpdateFlags() const
Definition: stateproblem.h:669
void Init_ElementRhs(const EDC &edc, dealii::Vector< double > &local_vector, double scale)
Definition: stateproblem.h:93
bool HasFaces() const
Definition: stateproblem.h:743
void InterfaceMatrix(const FDC &fdc, dealii::FullMatrix< double > &local_entry_matrix, double scale=1., double scale_ico=1.)
void BoundaryMatrix(const FDC &fdc, dealii::FullMatrix< double > &local_matrix, double scale=1., double scale_ico=1.)
std::string GetType() const
Definition: stateproblem.h:68
void ElementTimeMatrixExplicit(const EDC &edc, dealii::FullMatrix< double > &local_entry_matrix)
Definition: stateproblem.h:587
void Init_ElementMatrix(const EDC &edc, dealii::FullMatrix< double > &local_entry_matrix, double scale, double scale_ico)
Definition: stateproblem.h:118
void ElementTimeMatrix(const EDC &edc, dealii::FullMatrix< double > &local_entry_matrix)
const dealii::Function< dim > & GetInitialValues() const
Definition: stateproblem.h:858
Definition: dopeexception.h:35
bool AtInterface(ELEMENTITERATOR &element, unsigned int face) const
Definition: stateproblem.h:869