Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
NonLinearProblem_decl.hpp
1#ifndef NONLINEARPROBLEM_DECL_hpp
2#define NONLINEARPROBLEM_DECL_hpp
3
4#include "Problem.hpp"
5#include <Thyra_StateFuncModelEvaluatorBase.hpp>
6
7
16
17namespace FEDD{
18template<class SC_, class LO_, class GO_, class NO_>
19class Problem;
20template <class SC = default_sc,
21 class LO = default_lo,
22 class GO = default_go,
23 class NO = default_no>
24class NonLinearProblem : public Problem<SC,LO,GO,NO> , public Thyra::StateFuncModelEvaluatorBase<SC> {
25
26public:
27
28 typedef Problem<SC,LO,GO,NO> Problem_Type;
29 typedef typename Problem_Type::CommConstPtr_Type CommConstPtr_Type;
30 typedef typename Problem_Type::MapConstPtr_Type MapConstPtr_Type;
31 typedef typename Problem_Type::MultiVector_Type MultiVector_Type;
32 typedef typename Problem_Type::MultiVectorPtr_Type MultiVectorPtr_Type;
33 typedef typename Problem_Type::MultiVectorConstPtr_Type MultiVectorConstPtr_Type;
34 typedef typename Problem_Type::BlockMultiVector_Type BlockMultiVector_Type;
35 typedef typename Problem_Type::BlockMultiVectorPtr_Type BlockMultiVectorPtr_Type;
36
37 typedef typename Problem_Type::Matrix_Type Matrix_Type;
38 typedef typename Problem_Type::MatrixPtr_Type MatrixPtr_Type;
39
40 typedef typename Problem_Type::BlockMatrix_Type BlockMatrix_Type;
41 typedef typename Problem_Type::BlockMatrixPtr_Type BlockMatrixPtr_Type;
42
43
44 typedef Tpetra::Map<LO,GO,NO> TpetraMap_Type;
45 typedef Teuchos::RCP<TpetraMap_Type> TpetraMapPtr_Type;
46 typedef Teuchos::RCP<const TpetraMap_Type> TpetraMapConstPtr_Type;
47 typedef const TpetraMapConstPtr_Type TpetraMapConstPtrConst_Type;
48
49
50 typedef BlockMap<LO,GO,NO> BlockMap_Type;
51 typedef Teuchos::RCP<BlockMap_Type> BlockMapPtr_Type;
52 typedef Teuchos::RCP<const BlockMap_Type> BlockMapConstPtr_Type;
53 typedef Teuchos::Array<BlockMultiVectorPtr_Type> BlockMultiVectorPtrArray_Type;
54
55 typedef Thyra::VectorSpaceBase<SC> ThyraVecSpace_Type;
56 typedef Teuchos::RCP<const ThyraVecSpace_Type> ThyraVecSpaceConstPtr_Type;
57 typedef Thyra::VectorBase<SC> ThyraVec_Type;
58 typedef Tpetra::CrsMatrix<SC, LO, GO, NO> TpetraMatrix_Type;
59 typedef Thyra::LinearOpBase<SC> ThyraOp_Type;
60 typedef Tpetra::Operator<SC,LO,GO,NO> TpetraOp_Type;
61 typedef Thyra::BlockedLinearOpBase<SC> ThyraBlockOp_Type;
62
63 NonLinearProblem(CommConstPtr_Type comm);
64
65 NonLinearProblem(ParameterListPtr_Type &parameterList, CommConstPtr_Type comm);
66
67 ~NonLinearProblem();
68
69 virtual void info() = 0;
70
71 void infoNonlinProblem();
72
73 void initializeProblem(int nmbVectors=1);
74
75 virtual void assemble( std::string type = "" ) const = 0;
76
77 virtual void getValuesOfInterest( vec_dbl_Type& values ) = 0;
78
79 int solveAndUpdate( const std::string& criterion , double& criterionValue );
80
81 int solveUpdate( );
82
83// virtual void reAssemble(std::string type="FixedPoint") const = 0;
84
85 virtual void reAssemble( BlockMultiVectorPtr_Type previousSolution ) const = 0;
86
87 void reAssembleAndFill( BlockMatrixPtr_Type bMat, std::string type="FixedPoint" );
88
89 virtual void reAssembleExtrapolation(BlockMultiVectorPtrArray_Type previousSolutions) = 0;
90 //MultiVector_ptr_vec_ptr_Type allPreviousSolutions
91// virtual int ComputeDragLift(vec_dbl_ptr_Type &values) = 0;
92
93 void initializeVectorsNonLinear(int nmbVectors=1);
94
95 double calculateResidualNorm() const;
96
97 virtual void calculateNonLinResidualVec(std::string type="standard", double time=0.) const = 0; //type=standard or reverse
98
99 // if used for timeproblem
100 virtual void calculateNonLinResidualVec(SmallMatrix<double>& coeff, std::string type="standard", double time=0.); //type=standard or reverse
101
102 BlockMultiVectorPtr_Type getResidualVector() const;
103
104 BlockMultiVectorPtr_Type getPreviousSolution() const{ return previousSolution_; }
105
106 virtual Thyra::ModelEvaluatorBase::InArgs<SC> getNominalValues() const;
107
108 virtual Teuchos::RCP<const ::Thyra::VectorSpaceBase<SC> > get_x_space() const;
109
110 virtual Teuchos::RCP<const ::Thyra::VectorSpaceBase<SC> > get_f_space() const;
111
112 virtual ::Thyra::ModelEvaluatorBase::InArgs<SC> createInArgs() const;
113
114 void initNOXParameters( );
115
116 void initVectorSpaces( );
117
118 void initVectorSpacesMonolithic( );
119
120 void initVectorSpacesBlock( );
121
122 // virtual void evalModelImpl(const ::Thyra::ModelEvaluatorBase::InArgs<SC> &inArgs,
123 // const ::Thyra::ModelEvaluatorBase::OutArgs<SC> &outArgs) const = 0;
124
125 virtual ::Thyra::ModelEvaluatorBase::OutArgs<SC> createOutArgsImpl() const;
126
127 double nonLinearTolerance_;
128 BlockMultiVectorPtr_Type previousSolution_;
129 mutable BlockMultiVectorPtr_Type residualVec_;
130 SmallMatrix<double> coeff_;// coefficients for a time-dependent problem
131
132 mutable int newtonStep_;
133
134 Teuchos::RCP< Thyra::LinearOpBase<SC> > create_W_op() const;
135 Teuchos::RCP< Thyra::LinearOpBase<SC> > create_W_op_Monolithic() const;
136#ifdef FEDD_HAVE_TEKO
137 Teuchos::RCP< Thyra::LinearOpBase<SC> > create_W_op_Block() const;
138#endif
139 Teuchos::RCP<Thyra::PreconditionerBase<SC> > create_W_prec() const;
140
141
142private:
143 mutable bool precInitOnly_; //Help variable to signal that we constructed the initial preconditioner
144 // for NOX already and we do not need to compute it if fill_W_prec is
145 // called for the first time. However, the preconditioner is only correct
146 // if a linear system is solved in the first nonlinear iteration.
147
148
149 Thyra::ModelEvaluatorBase::InArgs<SC> nominalValues_;
150
151 ::Thyra::ModelEvaluatorBase::InArgs<SC> prototypeInArgs_;
152 ::Thyra::ModelEvaluatorBase::OutArgs<SC> prototypeOutArgs_;
153
154 Teuchos::RCP<const ThyraVecSpace_Type> xSpace_;
155 Teuchos::RCP<const ThyraVecSpace_Type> fSpace_;
156
157 Teuchos::RCP<ThyraVec_Type> x0_;
158
159 virtual void evalModelImpl(
160 const ::Thyra::ModelEvaluatorBase::InArgs<SC> &inArgs,
161 const ::Thyra::ModelEvaluatorBase::OutArgs<SC> &outArgs
162 ) const;
163
164 void evalModelImplMonolithic(const ::Thyra::ModelEvaluatorBase::InArgs<SC> &inArgs,
165 const ::Thyra::ModelEvaluatorBase::OutArgs<SC> &outArgs) const;
166
167#ifdef FEDD_HAVE_TEKO
168 void evalModelImplBlock(const ::Thyra::ModelEvaluatorBase::InArgs<SC> &inArgs,
169 const ::Thyra::ModelEvaluatorBase::OutArgs<SC> &outArgs) const;
170#endif
171
172
173
174};
175}
176
177#endif
Block Variant of Map class.
Definition BlockMap_decl.hpp:38
Teuchos::RCP< Thyra::LinearOpBase< SC > > create_W_op() const
Block Approach for Nonlinear Solver NOX. Input. Includes calculation of the residual vector and updat...
Definition NonLinearProblem_def.hpp:556
Definition Problem_decl.hpp:40
This class represents a templated small Matrix of type T. Primarily created for 2x2 and 3x3 matrices....
Definition SmallMatrix.hpp:22
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:33