9 interface = &Interface;
11 Krylov = &Parameters.sublist(
"Krylov");
21 delta = Teuchos::getParameter<double>(Parameters.sublist(
"Newton"),
"delta");
22 iter_min = Teuchos::getParameter<int>(Parameters.sublist(
"Newton"),
"iterMin");
23 iter_max = Teuchos::getParameter<int>(Parameters.sublist(
"Newton"),
"iterMax");
24 nb_bis_max = Teuchos::getParameter<int>(Parameters.sublist(
"Newton"),
"nbBisMax");
25 norm_inf_tol = Teuchos::getParameter<double>(Parameters.sublist(
"Newton"),
"NormFTol");
26 norm_inf_max = Teuchos::getParameter<double>(Parameters.sublist(
"Newton"),
"NormFMax");
27 eps = Teuchos::getParameter<double>(Parameters.sublist(
"Newton"),
"eps");
28 success = Teuchos::getParameter<double>(Parameters.sublist(
"Newton"),
"success_parameter");
29 failure = Teuchos::getParameter<double>(Parameters.sublist(
"Newton"),
"failure_parameter");
30 bc_disp = Teuchos::getParameter<double>(Parameters.sublist(
"Newton"),
"bc_disp");
31 pressure_load = Teuchos::getParameter<double>(Parameters.sublist(
"Newton"),
"pressure_load");
32 tol = Teuchos::getParameter<double>(Parameters.sublist(
"Newton"),
"tol");
37 double assemble_time,displacement, norm_inf_rhs, time_init, time_max, krylov_res;
38 int FLAG1, FLAG2, FLAG3, nb_bis, iter, krylov_its;
43 std::string solver_its =
"krylov_its";
44 std::string solver_res =
"krylov_res";
46 Epetra_Time Time(*
Comm);
48 Teuchos::RCP<Epetra_FECrsMatrix> epetra_A = Teuchos::rcp(
new Epetra_FECrsMatrix(Copy,*
interface->
FEGraph));
49 Teuchos::RCP<Epetra_FEVector> epetra_rhs = Teuchos::rcp(
new Epetra_FEVector(*
interface->
StandardMap));
50 Teuchos::RCP<Epetra_Vector> epetra_lhs = Teuchos::rcp(
new Epetra_Vector(*
interface->
StandardMap));
52 Teuchos::RCP<Epetra_MultiVector> epetra_rhsv = epetra_rhs;
54 Stratimikos::DefaultLinearSolverBuilder linearSolverBuilder;
55 linearSolverBuilder.setParameterList(solverBuilderSL);
57 Teuchos::RCP<Thyra::LinearOpWithSolveFactoryBase<double> > lowsFactory =
58 linearSolverBuilder.createLinearSolveStrategy(
"");
59 Teuchos::RCP<Thyra::LinearOpWithSolveBase<double> > lows = lowsFactory->createOp();
61 Teuchos::RCP<Teuchos::FancyOStream> out = Teuchos::VerboseObjectBase::getDefaultOStream();
65 Teuchos::RCP<const Thyra::LinearOpBase<double>> thyra_A = Thyra::epetraLinearOp(epetra_A);
66 Teuchos::RCP<Thyra::VectorBase<double>> thyra_lhs = Thyra::create_Vector(epetra_lhs,thyra_A->domain());
67 Teuchos::RCP<const Thyra::MultiVectorBase<double>> thyra_rhs = Thyra::create_MultiVector(epetra_rhsv,thyra_A->range());
69 Thyra::SolveStatus<double> status;
100 if (
MyPID==0){std::cout <<
"Iteration limit exceeds.\n";}
103 Time.ResetStartTime();
105 assemble_time = Time.ElapsedTime();
116 epetra_rhs->NormInf(&norm_inf_rhs);
120 std::cout <<
"\t\t\t" << iter <<
"\t" << norm_inf_rhs <<
"\t" << krylov_res <<
"\t\t" << assemble_time <<
"\t\t\t" <<
time*pressure_load/1000.0 <<
"\n";
123 std::cout <<
"\n Time" <<
"\t" <<
"Timestep" <<
"\t" <<
"Iter" <<
"\t" <<
"NormInf" <<
"\t" << solver_res <<
"\t\t" <<
"assemble_time" <<
"\t\t" <<
"pressure_load [kPa]" <<
"\n";
124 std::cout <<
" " <<
time <<
"\t" <<
delta <<
"\t\t" << iter <<
"\t" << norm_inf_rhs <<
"\t\t" << krylov_res <<
"\t\t" << assemble_time <<
"\t\t\t" <<
time*pressure_load <<
"\n";
146 std::cout <<
"Bisecting increment: " << nb_bis <<
"\n";
151 std::cout <<
"Bisection number exceeds.\n";
162 epetra_rhsv = epetra_rhs;
163 epetra_lhs->PutScalar(0.0);
166 if (
time==time_init){
167 Thyra::initializeOp<double>(*lowsFactory, thyra_A, lows.ptr());
170 Thyra::uninitializeOp<double>(*lowsFactory, lows.ptr());
171 Thyra::initializeAndReuseOp<double>(*lowsFactory, thyra_A, lows.ptr());
173 status = Thyra::solve<double>(*lows, Thyra::NOTRANS, *thyra_rhs, thyra_lhs.ptr());
181 krylov_res = status.achievedTol;
183 x->Update(1.0,*epetra_lhs,1.0);
195 Epetra_Time Time(*
Comm);
197 Epetra_LinearProblem problem;
205 double Assemble_time;
209 double time_max = 1.0;
210 double Krylov_res = 0;
211 int FLAG1, FLAG2, FLAG3, nb_bis, iter;
216 std::string solver_its =
"GMRES_its";
217 std::string solver_res =
"GMRES_res";
251 if (
MyPID==0){std::cout <<
"Iteration limit exceeds.\n";}
255 Time.ResetStartTime();
257 Assemble_time = Time.ElapsedTime();
270 rhs.NormInf(&norm_inf_rhs);
272 if (
MyPID==0 && print){
274 std::cout <<
"\t\t\t" << iter <<
"\t" << norm_inf_rhs <<
"\t" << Krylov_its <<
"\t\t" << Krylov_res <<
"\t\t" << Assemble_time <<
"\t\t\t" << Aztec_time <<
"\t\t\t" <<
time*pressure_load <<
"\n";
277 std::cout <<
"\n Time" <<
"\t" <<
"Timestep" <<
"\t" <<
"Iter" <<
"\t" <<
"NormInf" <<
"\t\t" << solver_its <<
"\t" << solver_res <<
"\t\t" <<
"assemble_time" <<
"\t\t" <<
"aztec_time" <<
"\t\t" <<
"pressure_load [kPa]" <<
"\n";
278 std::cout <<
" " <<
time <<
"\t" <<
delta <<
"\t\t" << iter <<
"\t" << norm_inf_rhs <<
"\t" << Krylov_its <<
"\t\t" << Krylov_res <<
"\t\t" << Assemble_time <<
"\t\t\t" << Aztec_time <<
"\t\t\t" <<
time*pressure_load <<
"\n";
302 std::cout <<
"Bisecting increment: " << nb_bis <<
"\n";
307 std::cout <<
"Bisection number exceeds.\n";
319 problem.SetOperator(&stiffness);
320 problem.SetLHS(&lhs);
321 problem.SetRHS(&rhs);
322 solver.SetProblem(problem);
323 solver.SetParameters(*
Krylov);
325 Time.ResetStartTime();
326 solver.Iterate(2000,
tol);
327 Aztec_time = Time.ElapsedTime();
328 Krylov_its = solver.NumIters();
329 Krylov_res = solver.TrueResidual();
330 x->Update(1.0,lhs,1.0);
343 int NumTargetElements = 0;
347 Epetra_Map MapOnRoot(-1,NumTargetElements,0,*
Comm);
349 Epetra_MultiVector lhs_root(MapOnRoot,
true);
350 lhs_root.Export(*
x,ExportOnRoot,Insert);
352 int error = EpetraExt::MultiVectorToMatrixMarketFile(fileName.c_str(),lhs_root,0,0,
false);
int Solve_with_Aztec(bool print)
Teuchos::ParameterList * Krylov
Epetra_FECrsGraph * FEGraph
void setInitialization(Epetra_Vector &init)
nonLinearFiniteElementProblem * interface
void setParameters(Teuchos::ParameterList &Parameters)
newtonRaphson(nonLinearFiniteElementProblem &Interface, Teuchos::ParameterList &Parameters)
int print_newton_solution(std::string fileName)
virtual void apply_dirichlet_conditions(Epetra_FECrsMatrix &K, Epetra_FEVector &F, double &displacement)=0
virtual void get_matrix_and_rhs(Epetra_Vector &x, Epetra_FECrsMatrix &K, Epetra_FEVector &F)=0
int Solve_with_Stratimikos(Teuchos::RCP< Teuchos::ParameterList > solverBuilderSL)