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;
338 ComputeSparsityPattern(SPARSITYPATTERN & sparsity)
const;
343 ComputeMGSparsityPattern(dealii::MGLevelObject<dealii::BlockSparsityPattern> & mg_sparsity_patterns,
344 unsigned int n_levels)
const;
347 ComputeMGSparsityPattern(dealii::MGLevelObject<dealii::SparsityPattern> & mg_sparsity_patterns,
348 unsigned int n_levels)
const;
354 inline const std::vector<unsigned int>&
355 GetDirichletColors()
const;
360 inline const std::vector<bool>&
361 GetDirichletCompMask(
unsigned int color)
const;
366 inline const Function<dim>
370 const std::map<std::string,
const dealii::Vector<double>*> ¶m_values,
371 const std::map<std::string, const VECTOR*> &domain_values)
const;
376 inline const std::vector<unsigned int>&
377 GetBoundaryEquationColors()
const;
382 inline const dealii::ConstraintMatrix&
383 GetDoFConstraints()
const;
388 const dealii::Function<dim>&
389 GetInitialValues()
const;
394 return opt_problem_.GetOutputHandler();
405 OPTPROBLEM& opt_problem_;
407 std::vector<unsigned int> dirichlet_colors_;
408 std::vector<std::vector<bool> > dirichlet_comps_;
409 std::vector<PrimalDirichletData<DD, VECTOR, dim>*>
410 primal_dirichlet_values_;
411 std::vector<unsigned int> state_boundary_equation_colors_;
412 double interval_length_;
419 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
420 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
421 template<
typename EDC>
423 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
424 dim>::ElementEquation(
const EDC& edc,
425 dealii::Vector<double> &local_vector,
double scale,
428 pde_.ElementEquation(edc, local_vector, scale*interval_length_, scale_ico*interval_length_);
433 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
434 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
435 template<
typename EDC>
437 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
438 dim>::ElementTimeEquation(
const EDC& edc,
439 dealii::Vector<double> &local_vector,
double scale)
446 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
447 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
448 template<
typename EDC>
450 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
451 dim>::ElementTimeEquationExplicit(
const EDC& edc,
452 dealii::Vector<double> &local_vector,
double scale)
459 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
460 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
461 template<
typename FDC>
463 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
464 dim>::FaceEquation(
const FDC& fdc,
465 dealii::Vector<double> &local_vector,
double scale,
double scale_ico)
467 pde_.
FaceEquation(fdc, local_vector, scale*interval_length_, scale_ico*interval_length_);
472 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
473 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
474 template<
typename FDC>
476 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
477 dim>::InterfaceEquation(
const FDC& fdc,
478 dealii::Vector<double> &local_vector,
double scale,
double scale_ico)
480 pde_.
InterfaceEquation(fdc, local_vector, scale*interval_length_, scale_ico*interval_length_);
484 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
485 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
486 template<
typename FDC>
488 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
489 dim>::BoundaryEquation(
const FDC& fdc,
490 dealii::Vector<double> &local_vector,
double scale,
double scale_ico)
492 pde_.
BoundaryEquation(fdc, local_vector, scale*interval_length_, scale_ico*interval_length_);
497 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
498 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
499 template<
typename EDC>
501 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
502 dim>::ElementRhs(
const EDC& edc,
503 dealii::Vector<double> &local_vector,
double scale)
505 pde_.ElementRightHandSide(edc, local_vector, scale*interval_length_);
510 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
511 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
514 const std::map<std::string,
const dealii::Vector<double>*> &,
515 const std::map<std::string, const VECTOR*> &,
523 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
524 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
525 template<
typename FDC>
527 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
528 dim>::FaceRhs(
const FDC& fdc,
529 dealii::Vector<double> &local_vector,
double scale)
531 pde_.FaceRightHandSide(fdc, local_vector, scale*interval_length_);
536 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
537 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
538 template<
typename FDC>
540 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
541 dim>::BoundaryRhs(
const FDC& fdc,
542 dealii::Vector<double> &local_vector,
double scale)
544 pde_.BoundaryRightHandSide(fdc, local_vector, scale*interval_length_);
549 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
550 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
551 template<
typename EDC>
553 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
554 dim>::ElementMatrix(
const EDC& edc,
555 dealii::FullMatrix<double> &local_entry_matrix,
double scale,
558 pde_.
ElementMatrix(edc, local_entry_matrix, scale*interval_length_, scale_ico*interval_length_);
563 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
564 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
565 template<
typename EDC>
567 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
568 dim>::ElementTimeMatrix(
const EDC& edc,
569 FullMatrix<double> &local_entry_matrix)
576 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
577 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
578 template<
typename EDC>
580 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
581 dim>::ElementTimeMatrixExplicit(
const EDC& edc,
582 dealii::FullMatrix<double> &local_entry_matrix)
589 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
590 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
591 template<
typename FDC>
593 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
594 dim>::FaceMatrix(
const FDC& fdc,
595 FullMatrix<double> &local_entry_matrix,
double scale,
598 pde_.
FaceMatrix(fdc, local_entry_matrix, scale*interval_length_, scale_ico*interval_length_);
603 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
604 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
605 template<
typename FDC>
607 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
608 dim>::InterfaceMatrix(
const FDC& fdc,
609 FullMatrix<double> &local_entry_matrix,
double scale,
612 pde_.
InterfaceMatrix(fdc, local_entry_matrix, scale*interval_length_, scale_ico*interval_length_);
617 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
618 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
619 template<
typename FDC>
621 StateProblem<OPTPROBLEM, PDE, DD, SPARSITYPATTERN, VECTOR,
622 dim>::BoundaryMatrix(
const FDC& fdc,
623 FullMatrix<double> &local_matrix,
double scale,
626 pde_.
BoundaryMatrix(fdc, local_matrix, scale*interval_length_, scale_ico*interval_length_);
631 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
632 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
641 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
642 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
643 const SmartPointer<const dealii::FESystem<dim> >
646 return opt_problem_.GetSpaceTimeHandler()->
GetFESystem(
"state");
650 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
651 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
652 const SmartPointer<const dealii::hp::FECollection<dim> >
660 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
661 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
667 return r | update_JxW_values;
672 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
673 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
679 return r | update_JxW_values;
684 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
685 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
690 opt_problem_.
SetTime(time, interval, initial);
691 interval_length_ = opt_problem_.GetSpaceTimeHandler()->GetStepSize();
696 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
697 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
700 SPARSITYPATTERN & sparsity)
const
702 opt_problem_.GetSpaceTimeHandler()->ComputeStateSparsityPattern(sparsity);
707 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
708 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
711 dealii::MGLevelObject<dealii::BlockSparsityPattern> & mg_sparsity_patterns,
712 unsigned int n_levels)
const
714 opt_problem_.GetSpaceTimeHandler()->ComputeMGStateSparsityPattern(mg_sparsity_patterns, n_levels);
719 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
720 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
723 dealii::MGLevelObject<dealii::SparsityPattern> & mg_sparsity_patterns,
724 unsigned int n_levels)
const
726 opt_problem_.GetSpaceTimeHandler()->ComputeMGStateSparsityPattern(mg_sparsity_patterns, n_levels);
733 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
734 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
743 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
744 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
754 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
755 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
764 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
765 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
766 const std::vector<unsigned int>&
769 return dirichlet_colors_;
774 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
775 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
776 const std::vector<bool>&
778 unsigned int color)
const
780 unsigned int comp = dirichlet_colors_.size();
781 for (
unsigned int i = 0; i < dirichlet_colors_.size(); ++i)
783 if (dirichlet_colors_[i] == color)
789 if (comp == dirichlet_colors_.size())
792 s <<
"DirichletColor" << color <<
" has not been found !";
793 throw DOpEException(s.str(),
"OptProblem::GetDirichletCompMask");
795 return dirichlet_comps_[comp];
800 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
801 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
805 const std::map<std::string,
const dealii::Vector<double>*> ¶m_values,
806 const std::map<std::string, const VECTOR*> &domain_values)
const
808 unsigned int col = dirichlet_colors_.size();
809 for (
unsigned int i = 0; i < dirichlet_colors_.size(); ++i)
811 if (dirichlet_colors_[i] == color)
817 if (col == dirichlet_colors_.size())
820 s <<
"DirichletColor" << color <<
" has not been found !";
821 throw DOpEException(s.str(),
"OptProblem::GetDirichletValues");
823 primal_dirichlet_values_[col]->ReInit(param_values, domain_values, color);
824 return *(primal_dirichlet_values_[col]);
829 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
830 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
831 const std::vector<unsigned int>&
834 return state_boundary_equation_colors_;
839 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
840 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
841 const dealii::ConstraintMatrix&
844 return opt_problem_.GetSpaceTimeHandler()->GetStateDoFConstraints();
846 template<
typename OPTPROBLEM,
typename PDE,
typename DD,
847 typename SPARSITYPATTERN,
typename VECTOR,
int dim>
const dealii::Function<dim>&
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:477
dealii::UpdateFlags GetFaceUpdateFlags() const
Definition: stateproblem.h:675
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:397
void ElementTimeEquationExplicit(const EDC &edc, dealii::Vector< double > &local_vector, double scale=1.)
Definition: stateproblem.h:451
Definition: dopetypes.h:106
void BoundaryEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale=1., double scale_ico=1.)
Definition: stateproblem.h:489
StateProblem(OPTPROBLEM &OP, PDE &pde)
Definition: stateproblem.h:51
const dealii::SmartPointer< const dealii::FESystem< dim > > GetFESystem() const
Definition: stateproblem.h:644
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:653
void FaceEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale=1., double scale_ico=1.)
Definition: stateproblem.h:464
DOpEOutputHandler< VECTOR > * GetOutputHandler()
Definition: stateproblem.h:392
Definition: timeiterator.h:63
void ElementMatrix(const EDC &edc, dealii::FullMatrix< double > &local_entry_matrix, double scale=1., double scale_ico=1.)
Definition: stateproblem.h:554
bool HasInterfaces() const
Definition: stateproblem.h:757
void ElementTimeEquation(const EDC &edc, dealii::Vector< double > &local_vector, double scale=1.)
Definition: stateproblem.h:438
void SetTime(double time, const TimeIterator &interval, bool initial=false)
Definition: stateproblem.h:687
dealii::UpdateFlags GetUpdateFlags() const
Definition: stateproblem.h:663
void Init_ElementRhs(const EDC &edc, dealii::Vector< double > &local_vector, double scale)
Definition: stateproblem.h:93
bool HasFaces() const
Definition: stateproblem.h:736
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:581
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:848
Definition: dopeexception.h:35