Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
DAESolverInTime_def.hpp
1#ifndef DAESOLVERINTIME_DEF_hpp
2#define DAESOLVERINTIME_DEF_hpp
3#include "DAESolverInTime_decl.hpp"
4
5
14
15namespace FEDD {
16
17
18template<class SC,class LO,class GO,class NO>
19DAESolverInTime<SC,LO,GO,NO>::DAESolverInTime( CommConstPtr_Type comm ):
20comm_(comm),
21verbose_(comm->getRank()==0),
22parameterList_(),
23isTimeSteppingDefined_(false),
24problem_(),
25problemTime_(),
26timeStepDef_(),
27timeSteppingTool_(),
28exporter_vector_(),
29export_solution_vector_(),
30boolExporterSetup_(false)
31#ifdef FEDD_TIMER
32,solveProblemTimer_ (Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime - Solve Problem"))
33#endif
34#ifdef FEDD_DETAIL_TIMER
35,reassmbleAddInterfaceRHSTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Interface RHS"))
36,reassmbleUpdateMeshDisplacementTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Update Mesh Displ."))
37,reassmbleSolveGeometryTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Solve Geometry"))
38,reassmbleMoveMeshTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Move Mesh"))
39,reassmbleSolidMassAndRHSTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Assemble Solid Massmatrix and RHS"))
40,reassmbleForTimeTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Assemble Fluid Problem (steady Navier-Stokes)"))
41,reassmbleUpdateFluidInTimeTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Update Fluid Solution"))
42#endif
43{
44
45
46}
47
48template<class SC,class LO,class GO,class NO>
49DAESolverInTime<SC,LO,GO,NO>::DAESolverInTime( ParameterListPtr_Type &parameterList, CommConstPtr_Type comm):
50comm_(comm),
51verbose_(comm->getRank()==0),
52parameterList_(parameterList),
53isTimeSteppingDefined_(false),
54problem_(),
55problemTime_(),
56timeStepDef_(),
57timeSteppingTool_(),
58exporter_vector_(),
59export_solution_vector_(),
60boolExporterSetup_(false)
61#ifdef FEDD_TIMER
62,solveProblemTimer_ (Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime - Solve Problem"))
63#endif
64#ifdef FEDD_DETAIL_TIMER
65,reassmbleAddInterfaceRHSTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Interface RHS"))
66,reassmbleUpdateMeshDisplacementTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Update Mesh Displ."))
67,reassmbleSolveGeometryTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Solve Geometry"))
68,reassmbleMoveMeshTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Move Mesh"))
69,reassmbleSolidMassAndRHSTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Assemble Solid Massmatrix and RHS"))
70,reassmbleForTimeTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Assemble Fluid Problem (steady Navier-Stokes)"))
71,reassmbleUpdateFluidInTimeTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Update Fluid Solution"))
72#endif
73
74{
75
76}
77
78template<class SC,class LO,class GO,class NO>
79DAESolverInTime<SC,LO,GO,NO>::DAESolverInTime( SmallMatrix<int> &timeStepDef, ParameterListPtr_Type &parameterList, CommConstPtr_Type comm):
80comm_(comm),
81verbose_(comm->getRank()==0),
82parameterList_(parameterList),
83isTimeSteppingDefined_(false),
84problem_(),
85problemTime_(),
86timeStepDef_(),
87timeSteppingTool_(),
88exporter_vector_(),
89export_solution_vector_(),
90boolExporterSetup_(false)
91#ifdef FEDD_TIMER
92,solveProblemTimer_ (Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime - Solve Problem"))
93#endif
94#ifdef FEDD_DETAIL_TIMER
95,reassmbleAddInterfaceRHSTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Interface RHS"))
96,reassmbleUpdateMeshDisplacementTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Update Mesh Displ."))
97,reassmbleSolveGeometryTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Solve Geometry"))
98,reassmbleMoveMeshTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Move Mesh"))
99,reassmbleSolidMassAndRHSTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Assemble Solid Massmatrix and RHS"))
100,reassmbleForTimeTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Assemble Fluid Problem (steady Navier-Stokes)"))
101,reassmbleUpdateFluidInTimeTimer_(Teuchos::TimeMonitor::getNewCounter("FEDD - DAETime Detail - FSI Update Fluid Solution"))
102#endif
103
104{
105 this->defineTimeStepping(timeStepDef);
106}
107
108template<class SC,class LO,class GO,class NO>
109DAESolverInTime<SC,LO,GO,NO>::~DAESolverInTime(){
110
111}
112
113
114template<class SC,class LO,class GO,class NO>
115void DAESolverInTime<SC,LO,GO,NO>::setProblem(Problem_Type& problem){
116
117 problem_ = Teuchos::rcpFromRef(problem); /*now a NON-OWNING TEUCHOS::RCP to the object which was probably constructed in main function */
118
119}
120
121template<class SC,class LO,class GO,class NO>
122void DAESolverInTime<SC,LO,GO,NO>::defineTimeStepping(SmallMatrix<int> &timeStepDef){
123
124 timeStepDef_ = timeStepDef;
125 timeSteppingTool_.reset(new TimeSteppingTools(sublist(parameterList_,"Timestepping Parameter") , comm_));
126 isTimeSteppingDefined_ = true;
127
128
129}
130
131template<class SC,class LO,class GO,class NO>
132void DAESolverInTime<SC,LO,GO,NO>::advanceInTime(){
133
134 TEUCHOS_TEST_FOR_EXCEPTION(problemTime_.is_null(), std::logic_error, "Mass system is null.");
135
136 checkTimeSteppingDef();
137
138 if(this->parameterList_->sublist("Parameter").get("FSI",false))
139 {
140 advanceInTimeFSI();
141 }
142 else{
143 if (!parameterList_->sublist("Timestepping Parameter").get("Class","Singlestep").compare("Loadstepping")) {
144 NonLinProbPtr_Type nonLinProb = Teuchos::rcp_dynamic_cast<NonLinProb_Type>(problem_);
145 if (nonLinProb.is_null()){
146 TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "Loadstepping only available to nonlinear Problems. (It is a tool to increase Nonlinear Solver convergence.)");
147 }
148 else{
149 advanceWithLoadStepping();
150 }
151 }
152 if (!parameterList_->sublist("Timestepping Parameter").get("Class","Singlestep").compare("Singlestep")) {
153 NonLinProbPtr_Type nonLinProb = Teuchos::rcp_dynamic_cast<NonLinProb_Type>(problem_);
154 if (nonLinProb.is_null()) {
155 advanceInTimeLinear();
156 }
157 else{
158 advanceInTimeNonLinear();
159 }
160 }
161 else if(!parameterList_->sublist("Timestepping Parameter").get("Class","Singlestep").compare("Newmark"))
162 {
163 NonLinProbPtr_Type nonLinProb = Teuchos::rcp_dynamic_cast<NonLinProb_Type>(problem_);
164 if (nonLinProb.is_null()) {
165 advanceInTimeLinearNewmark();
166 }
167 else
168 {
169 advanceInTimeNonLinearNewmark();
170 }
171 }
172 else if( !parameterList_->sublist("Timestepping Parameter").get("Class","Singlestep").compare("Multistep") ){
173 NonLinProbPtr_Type nonLinProb = Teuchos::rcp_dynamic_cast<NonLinProb_Type>(problem_);
174 if (nonLinProb.is_null()) {
175 advanceInTimeLinearMultistep();
176 }
177 else{
178 advanceInTimeNonLinearMultistep();
179 }
180 }
181 else if( !parameterList_->sublist("Timestepping Parameter").get("Class","Singlestep").compare("External") ){
182 NonLinProbPtr_Type nonLinProb = Teuchos::rcp_dynamic_cast<NonLinProb_Type>(problem_);
183 if (nonLinProb.is_null()) {
184 advanceInTimeLinearExternal();
185 }
186 else{
187 advanceInTimeNonLinearExternal();
188 }
189 }
190 else{
191 TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "Unknown time discretization type.");
192 }
193 }
194
195}
196
197template<class SC,class LO,class GO,class NO>
198void DAESolverInTime<SC,LO,GO,NO>::advanceInTimeLinear(){
199
200
201 bool print = parameterList_->sublist("General").get("ParaViewExport",false);
202 if (print)
203 exportTimestep();
204 bool fullImplicitPressure = false;
205 int size = timeStepDef_.size();
206 double dt = 0.0;
207 while (timeSteppingTool_->continueTimeStepping()) {
208 problemTime_->updateTime ( timeSteppingTool_->currentTime() );
209 dt = timeSteppingTool_->get_dt();
210 problemTime_->updateSolutionPreviousStep();
211
212 Teuchos::Array<BlockMatrixPtr_Type> bMatNonLin_vec_allstages;
213 BlockMultiVectorPtrArray_Type solutionRK_stages;
214 BlockMultiVectorPtrArray_Type sourceTermRK_stages;
215
216 for (int s=0; s<timeSteppingTool_->getNmbStages(); s++) {
217 double time = timeSteppingTool_->currentTime() + dt * timeSteppingTool_->getButcherTableC(s);
218 if (verbose_)
219 std::cout << "Currently in stage " << s+1 << " of "<< timeSteppingTool_->getNmbStages() << std::endl;
220
221 problemTime_->updateRhs();/*apply (mass matrix / dt) to u_t*/
222 if ( problemTime_->hasSourceTerm() ){
223 TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "Fix source term.");
224 problemTime_->assembleSourceTerm( time );
225 }
226
227 if (s==0 && timeSteppingTool_->getButcherTableCoefficient(s , s) == 0.0) {
228 /* solution of last time step is later added to rk solution vector */
229 }
230 else if (s==0 && timeSteppingTool_->getButcherTableCoefficient(s , s) != 0.0) {
231 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Not implemented butcher table!");
232 }
233 else{
234 for (int s_prior=0; s_prior<s; s_prior++) {
235 SmallMatrix<double> coeff(size);
236 for (int i=0; i<size; i++) {
237 for (int j=0; j<size; j++) {
238 if (timeStepDef_[i][j]>0) {
239 if (i==0 && j==1 && fullImplicitPressure) {
240 coeff[i][j] = 0;
241 }
242 else{
243 coeff[i][j] = - timeSteppingTool_->getButcherTableCoefficient(s , s_prior);
244 }
245 }
246 }
247 }
248 if (problemTime_->hasSourceTerm())
249 this->addRhsDAE(coeff, sourceTermRK_stages[s_prior] );
250
251 this->addRhsDAE( coeff, problemTime_->getSystem(), solutionRK_stages[s_prior] );
252
253 }
254
255 SmallMatrix<double> massCoeff(size);
256 SmallMatrix<double> problemCoeff(size);
257 double coeffSourceTerm = 0.;
258 for (int i=0; i<size; i++) {
259 for (int j=0; j<size; j++) {
260 if (timeStepDef_[i][j]>0 && i==j) {
261 massCoeff[i][j] = 1. / dt;
262 }
263 else if (timeStepDef_[i][j]==2) /*force off-diagnonal mass matrix*/
264 massCoeff[i][j] = 1. / dt;
265 else{
266 massCoeff[i][j] = 0.;
267 }
268 }
269 }
270 for (int i=0; i<size; i++) {
271 for (int j=0; j<size; j++){
272 if (timeStepDef_[i][j]>0){
273 if (i==0 && j==1 && fullImplicitPressure) {
274 problemCoeff[i][j] = 1.;
275 coeffSourceTerm = timeSteppingTool_->getButcherTableCoefficient(s , s); // ACHTUNG FUER SOURCE TERM, DER NICHT IN DER ZEIT
276 }
277 else{
278 problemCoeff[i][j] = timeSteppingTool_->getButcherTableCoefficient(s , s);
279 coeffSourceTerm = timeSteppingTool_->getButcherTableCoefficient(s , s); // ACHTUNG FUER SOURCE TERM, DER NICHT IN DER ZEIT DISKRETISIERT WIRD!
280 }
281 }
282 else{
283 problemCoeff[i][j] = 1.;
284 }
285 }
286 }
287
288 if (problemTime_->hasSourceTerm())
289 addSourceTermToRHS(coeffSourceTerm);
290
291 problemTime_->setTimeParameters(massCoeff, problemCoeff);
292 problemTime_->combineSystems();
293 problemTime_->setBoundaries(time);
294
295 problemTime_->solve();
296
297 }
298
299 if (s+1 == timeSteppingTool_->getNmbStages()) {
300 BlockMultiVectorPtr_Type tmpSolution = Teuchos::rcp( new BlockMultiVector_Type ( problemTime_->getSolution() ) );
301 solutionRK_stages.push_back(tmpSolution);
302 BlockMultiVectorPtr_Type tmpSolutionPtr = problemTime_->getSolution();
303 BlockMatrixPtr_Type tmpMassSystem = problemTime_->getMassSystem();
304 timeSteppingTool_->calculateSolution( tmpSolutionPtr, solutionRK_stages, tmpMassSystem);
305 }
306 else{
307 solutionRK_stages.push_back( problemTime_->getSolution() );
308 if ( problemTime_->hasSourceTerm() )
309 sourceTermRK_stages.push_back( problemTime_->getSourceTerm() );
310 }
311 }
312
313 timeSteppingTool_->advanceTime(true/*output info*/);
314
315 if (print)
316 exportTimestep();
317 }
318
319 if (print) {
320 closeExporter();
321 }
322 if (parameterList_->sublist("NSParameter").get("Calculate Coefficients",false)) {
323 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "close txt exporters here.");
324 }
325
326}
327template<class SC,class LO,class GO,class NO>
328void DAESolverInTime<SC,LO,GO,NO>::getMassCoefficients(SmallMatrix<double> &massCoeff){
329 int size = timeStepDef_.size();
330 massCoeff.resize(size);
331
332 for (int i=0; i<size; i++) {
333 for (int j=0; j<size; j++) {
334 if (timeStepDef_[i][j]>0 && i==j)
335 massCoeff[i][j] = 1.;
336 else
337 massCoeff[i][j] = 0.;
338 }
339 }
340}
341
342template<class SC,class LO,class GO,class NO>
343void DAESolverInTime<SC,LO,GO,NO>::getMultiStageCoefficients(SmallMatrix<double> &problemCoeff, int stage, int stagePrior, bool forRhs){
344 int size = timeStepDef_.size();
345 problemCoeff.resize(size);
346
347 for (int i=0; i<size; i++) {
348 for (int j=0; j<size; j++) {
349 if (timeStepDef_[i][j]>0)
350 problemCoeff[i][j] = timeSteppingTool_->get_dt()* timeSteppingTool_->getButcherTableCoefficient(stage , stagePrior);
351 else{
352 if (forRhs)
353 problemCoeff[i][j] = 0.;
354 else
355 problemCoeff[i][j] = 1.;
356 }
357 }
358 }
359}
360
361template<class SC,class LO,class GO,class NO>
362void DAESolverInTime<SC,LO,GO,NO>::buildMultiStageRhs( int stage, Teuchos::Array<BlockMatrixPtr_Type>& matrixPrevStages, BlockMultiVectorPtrArray_Type& solutionPrevStages ){
363
364 int size = timeStepDef_.size();
365 SmallMatrix<double> massCoeff(size);
366 SmallMatrix<double> problemCoeff(size);
367
368 getMassCoefficients(massCoeff);
369
370 problemTime_->setTimeParameters(massCoeff, problemCoeff);//problemCoeff not needed here
371 problemTime_->updateRhs();/*apply (mass matrix / dt) to u_t*/
372
373 bool fullImplicitPressure = parameterList_->sublist("Timestepping Parameter").get("Full implicit pressure",false);
374 for (int prevStage=0; prevStage<stage; prevStage++) {
375
376 getMultiStageCoefficients(problemCoeff, stage, prevStage, true);
377 if (fullImplicitPressure && size>1 )
378 problemCoeff[0][1] = 0.;
379
380 problemCoeff.scale(-1.);
381
382 TEUCHOS_TEST_FOR_EXCEPTION(problemTime_->hasSourceTerm(), std::logic_error, "Using source term must be implemented for single-step methods.");
383// addRhsDAE(coeff,beNL_vec_allstages.at(s_prior), solutionRK_stages.at(s_prior), sourceTermRK_stages.at(s_prior));
384 addRhsDAE( problemCoeff, matrixPrevStages[prevStage], solutionPrevStages[prevStage] );
385
386 }
387}
388
389
390
391template<class SC,class LO,class GO,class NO>
392void DAESolverInTime<SC,LO,GO,NO>::advanceInTimeNonLinear(){
393
394 bool print = parameterList_->sublist("General").get("ParaViewExport",false);
395 BlockMultiVectorPtr_Type solShort;
396 if (print){
397 if (parameterList_->sublist("Timestepping Parameter").get("Print Solution Short",false)) {
398 solShort = Teuchos::rcp(new BlockMultiVector_Type (problemTime_->getSolution()) );
399 exportTimestep(solShort);
400 }
401 else{
402 exportTimestep();
403 }
404 }
405
406 // Navier-Stokes treatment of pressure
407 bool fullImplicitPressure = parameterList_->sublist("Timestepping Parameter").get("Full implicit pressure",false);
408 bool semiImplicitPressure = parameterList_->sublist("Timestepping Parameter").get("Semi implicit pressure",false);
409 bool correctPressure = parameterList_->sublist("Timestepping Parameter").get("Correct pressure",false);
410 int size = timeStepDef_.size();
411 SmallMatrix<double> massCoeff(size);
412 SmallMatrix<double> problemCoeff(size);
413 double dt = 0.0;
414 int timeit = 0;
415 while (timeSteppingTool_->continueTimeStepping()) {
416
417 dt = timeSteppingTool_->get_dt();
418 // Which values should we use for extrapolation? u_m and u_m-1 (current implementation) or should we use most recent U_i-1 of multi stages
419 if(!parameterList_->sublist("General").get("Linearization","FixedPoint").compare("Extrapolation")) {
420 if (timeSteppingTool_->currentTime()!=0.)
421 problemTime_->updateSolutionMultiPreviousStep(2); //2nd order
422 else
423 problemTime_->updateSolutionMultiPreviousStep(1);
424 }
425 else{
426 problemTime_->updateSolutionPreviousStep();
427 }
428
429
430// BlockMultiVectorPtrArray_Type sourceTermRK_stages;
431
432 TEUCHOS_TEST_FOR_EXCEPTION(timeSteppingTool_->getButcherTableCoefficient(0 , 0) != 0.0, std::logic_error, "Not implemented butchertable! First stage should have 0 diagonal value");
433 if (verbose_)
434 std::cout << "Currently in stage " << 1 << " of "<< timeSteppingTool_->getNmbStages() <<" (dummy stage)"<< std::endl;
435 // Multistage stepping, in general we use at least 2 stages (implicit Euler and Crank-Nicolson)
436 Teuchos::Array<BlockMatrixPtr_Type> matrixPrevStages;
437 BlockMultiVectorPtrArray_Type solutionPrevStages;
438
439 BlockMatrixPtr_Type blockMatrix = Teuchos::rcp( new BlockMatrix_Type( problemTime_->getSystem()->size() ) );
440 problemTime_->reAssembleAndFill( blockMatrix ); // Reassemble FixedPoint
441
442 matrixPrevStages.push_back( blockMatrix );
443
444 BlockMultiVectorPtr_Type sol =
445 Teuchos::rcp( new BlockMultiVector_Type( problemTime_->getSolution() ) );
446 solutionPrevStages.push_back( sol );
447
448 for (int stage=1; stage<timeSteppingTool_->getNmbStages(); stage++) {
449 double time = timeSteppingTool_->currentTime() + dt * timeSteppingTool_->getButcherTableC(stage);
450 problemTime_->updateTime( time );
451 if (verbose_)
452 std::cout << "Currently in stage " << stage+1 << " of "<< timeSteppingTool_->getNmbStages() << std::endl;
453
454 buildMultiStageRhs( stage, matrixPrevStages, solutionPrevStages );
455
456 TEUCHOS_TEST_FOR_EXCEPTION(problemTime_->hasSourceTerm(), std::logic_error, "Using source term must be implemented for single-step methods.");
457// problemTime_->AssembleSourceTerm(time);
458
459
460 SmallMatrix<double> massCoeff(size);
461 SmallMatrix<double> problemCoeff(size);
462
463 getMassCoefficients(massCoeff);
464 getMultiStageCoefficients(problemCoeff, stage, stage, false);
465 if (fullImplicitPressure && size>1 )
466 problemCoeff[0][1] = timeSteppingTool_->get_dt();
467
468 problemTime_->setTimeParameters(massCoeff, problemCoeff);
469
470 NonLinearSolver<SC, LO, GO, NO> nlSolver(parameterList_->sublist("General").get("Linearization","FixedPoint"));
471 nlSolver.solve(*problemTime_,time);
472
473 if (correctPressure) {
474 TEUCHOS_TEST_FOR_EXCEPTION( !fullImplicitPressure && !semiImplicitPressure, std::logic_error,"There is no pressure that can be corrected." );
475
476 MultiVectorPtr_Type sol = problemTime_->getSolution()->getBlockNonConst(1);
477 MultiVectorConstPtr_Type solLast = problemTime_->getSolutionPreviousTimestep()->getBlock(1);
478 timeSteppingTool_->correctPressure( sol, solLast );
479 if (verbose_)
480 std::cout << "Pressure corrected." << std::endl;
481 }
482
483 if (stage+1 == timeSteppingTool_->getNmbStages()) {
484 // save last solution
485 BlockMultiVectorPtr_Type tmpSolution = Teuchos::rcp( new BlockMultiVector_Type ( problemTime_->getSolution() ) );
486
487 solutionPrevStages.push_back( tmpSolution );
488 BlockMultiVectorPtr_Type tmpSolutionPtr = problemTime_->getSolution();
489 BlockMatrixPtr_Type tmpMassSystem = problemTime_->getMassSystem();
490 timeSteppingTool_->calculateSolution( tmpSolutionPtr, solutionPrevStages, tmpMassSystem, solShort);
491 }
492 else{
493 BlockMatrixPtr_Type blockMatrix = Teuchos::rcp( new BlockMatrix_Type( problemTime_->getSystem()->size() ) );
494 problemTime_->reAssembleAndFill( blockMatrix );
495 matrixPrevStages.push_back( blockMatrix );
496
497 BlockMultiVectorPtr_Type sol =
498 Teuchos::rcp( new BlockMultiVector_Type( problemTime_->getSolution() ) );
499 solutionPrevStages.push_back( sol );
500
501 TEUCHOS_TEST_FOR_EXCEPTION(problemTime_->hasSourceTerm(), std::logic_error, "Using source term must be implemented for single-step methods.");
502// sourceTermRK_stages.push_back(*problemTime_->GetSourceTerm());
503 }
504 }
505 timeSteppingTool_->advanceTime(true/*output info*/);
506 timeit++;
507 if (print) {
508 exportTimestep();
509 }
510 if (parameterList_->sublist("NSParameter").get("Calculate Coefficients",false)) {
511 vec_dbl_ptr_Type values(new vec_dbl_Type(4));
512 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Drag and Lift are not implemented.");
513// nonLinearProblem_->ComputeDragLift(values);
514 }
515 }
516
517 if (print) {
518 closeExporter();
519 }
520 if (parameterList_->sublist("NSParameter").get("Calculate Coefficients",false)) {
521 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "close txt exporters here.");
522 }
523
524}
525
526// TODO: Irgendwann einmal fuer St. Venant-Kirchoff oder so programmieren.
527// Erstmal nicht wichtig
528template<class SC,class LO,class GO,class NO>
529void DAESolverInTime<SC,LO,GO,NO>::advanceWithLoadStepping()
530{
531
532 bool print = parameterList_->sublist("General").get("ParaViewExport",false);
533 bool printExtraData = parameterList_->sublist("General").get("Export Extra Data",false);
534 bool printData = parameterList_->sublist("General").get("Export Data",false);
535 if (print)
536 {
537 exportTimestep();
538 }
539
540 vec_dbl_ptr_Type its = Teuchos::rcp(new vec_dbl_Type ( 2, 0. ) ); //0:linear iterations, 1: nonlinear iterations
541 ExporterTxtPtr_Type exporterTimeTxt;
542 ExporterTxtPtr_Type exporterIterations;
543 ExporterTxtPtr_Type exporterNewtonIterations;
544 if (printData) {
545 std::string suffix = parameterList_->sublist("General").get("Export Suffix","");
546
547 exporterTimeTxt = Teuchos::rcp(new ExporterTxt());
548 exporterTimeTxt->setup( "time" + suffix, this->comm_ );
549
550 exporterNewtonIterations = Teuchos::rcp(new ExporterTxt());
551 exporterNewtonIterations->setup( "newtonIterations" + suffix, this->comm_ );
552
553 exporterIterations = Teuchos::rcp(new ExporterTxt());
554 exporterIterations->setup( "linearIterations" + suffix, this->comm_ );
555 }
556 // Groesse des Problems, Zeitschrittweite und Newmark-Parameter
557 int size = timeStepDef_.size();
558 TEUCHOS_TEST_FOR_EXCEPTION( size>1, std::runtime_error, "Loadstepping only implemented or sensible for 1x1 Systems.");
559 double dt = timeSteppingTool_->get_dt();
560
561
562 // Koeffizienten vor der Massematrix und vor der Systemmatrix des steady-Problems
563 SmallMatrix<double> massCoeff(size);
564 SmallMatrix<double> problemCoeff(size);
565 double coeffSourceTerm = 0.0; // Koeffizient fuer den Source-Term (= rechte Seite der DGL); mit Null initialisieren
566
567 // Koeffizient vor der Massematrix
568 massCoeff[0][0] = 0.;
569 problemCoeff[0][0] = 1.0;
570 // Der Source Term ist schon nach der Assemblierung mit der Dichte \rho skaliert worden
571 coeffSourceTerm = 1.0; // ACHTUNG FUER SOURCE TERM, DER NICHT IN DER ZEIT DISKRETISIERT WIRD!
572
573 // Temporaerer Koeffizienten fuer die Skalierung der Massematrix in der rechten Seite des Systems in UpdateNewmarkRhs()
574 vec_dbl_Type coeffTemp(1);
575 coeffTemp.at(0) = 1.0;
576
577 // Uebergebe die Parameter fuer Masse- und steady-Problemmatrix an TimeProblem
578 // Wegen moeglicher Zeitschrittweitensteuerung, rufe CombineSystems()
579 // in jedem Zeitschritt auf, um LHS neu aufzustellen.
580 // Bei AdvanceInTimeNonLinear... wird das in ReAssemble() gemacht!!!
581 problemTime_->setTimeParameters(massCoeff, problemCoeff);
582 // Der Source Term ist schon nach der Assemblierung mit der Dichte \rho skaliert worden
583
584 // ######################
585 // "Time" loop
586 // ######################
587 while(timeSteppingTool_->continueTimeStepping())
588 {
589 // Stelle (massCoeff*M + problemCoeff*A) auf
590 //problemTime_->combineSystems();
591
592
593 double time = timeSteppingTool_->currentTime() + dt;
594 problemTime_->updateTime ( time );
595
596 NonLinearSolver<SC, LO, GO, NO> nlSolver(parameterList_->sublist("General").get("Linearization","Newton"));
597 nlSolver.solve( *problemTime_, time, its );
598
599 timeSteppingTool_->advanceTime(true/*output info*/);
600 if (printData) {
601 exporterTimeTxt->exportData( timeSteppingTool_->currentTime() );
602 exporterIterations->exportData( (*its)[0] );
603 exporterNewtonIterations->exportData( (*its)[1] );
604 }
605 if (print) {
606 exportTimestep();
607 }
608 this->problemTime_->assemble("UpdateTime"); // Updates to next timestep
609
610 }
611
612 comm_->barrier();
613 if (print)
614 {
615 closeExporter();
616 }
617}
618
619
620template<class SC,class LO,class GO,class NO>
621void DAESolverInTime<SC,LO,GO,NO>::advanceInTimeLinearNewmark()
622{
623 // problemCoeff vor A (= kompletes steady-System)
624 // massCoeff vor M (= Massematrix)
625 // coeffSourceTerm vor f (= rechte Seite der DGL)
626
627 bool print = parameterList_->sublist("General").get("ParaViewExport",false);
628 if (print)
629 {
630 exportTimestep();
631 }
632
633 // Groesse des Problems, Zeitschrittweite und Newmark-Parameter
634 int size = timeStepDef_.size();
635 TEUCHOS_TEST_FOR_EXCEPTION( size>1, std::runtime_error, "Newmark only implemented for systems of size 1x1.");
636 double dt = timeSteppingTool_->get_dt();
637 double beta = timeSteppingTool_->get_beta();
638 double gamma = timeSteppingTool_->get_gamma();
639
640 // Koeffizienten vor der Massematrix und vor der Systemmatrix des steady-Problems
641 SmallMatrix<double> massCoeff(size);
642 SmallMatrix<double> problemCoeff(size);
643 double coeffSourceTerm = 0.0; // Koeffizient fuer den Source-Term (= rechte Seite der DGL); mit Null initialisieren
644
645 // Koeffizient vor der Massematrix
646 massCoeff[0][0] = 1.0/(dt*dt*beta);
647 problemCoeff[0][0] = 1.0;
648 // Der Source Term ist schon nach der Assemblierung mit der Dichte \rho skaliert worden
649 coeffSourceTerm = 1.0; // ACHTUNG FUER SOURCE TERM, DER NICHT IN DER ZEIT DISKRETISIERT WIRD!
650
651 // Temporaerer Koeffizienten fuer die Skalierung der Massematrix in der rechten Seite des Systems in UpdateNewmarkRhs()
652 vec_dbl_Type coeffTemp(1);
653 coeffTemp.at(0) = 1.0;
654
655 // Uebergebe die Parameter fuer Masse- und steady-Problemmatrix an TimeProblem
656 // Wegen moeglicher Zeitschrittweitensteuerung, rufe CombineSystems()
657 // in jedem Zeitschritt auf, um LHS neu aufzustellen.
658 // Bei AdvanceInTimeNonLinear... wird das in ReAssemble() gemacht!!!
659 problemTime_->setTimeParameters(massCoeff, problemCoeff);
660
661 // ######################
662 // Time loop
663 // ######################
664 while(timeSteppingTool_->continueTimeStepping())
665 {
666 // Stelle (massCoeff*M + problemCoeff*A) auf
667 problemTime_->combineSystems();
668
669 // Update u und berechne u' und u'' mit Hilfe der Newmark-Vorschrift
670 problemTime_->updateSolutionNewmarkPreviousStep(dt, beta, gamma);
671
672 double time = timeSteppingTool_->currentTime() + dt;
673 problemTime_->updateTime ( timeSteppingTool_->currentTime() );
674 // Stelle die rechte Seite des zeitdiskretisierten Systems auf (ohne f_{n+1}).
675 // Bei Newmark lautet dies:
676 // M*[\frac{1}{dt^2*beta}*u_n + \frac{1}{dt*beta}*u'_n + \frac{0.5 - beta}{beta}*u''_n],
677 // wobei u' = v (velocity) und u'' = w (acceleration).
678 problemTime_->updateNewmarkRhs(dt, beta, gamma, coeffTemp);
679
680 // TODO: SourceTerm wird in jedem Zeitschritt neu berechnet; auch wenn konstant!!!
681 // if(time == 0){nur dann konstanten SourceTerm berechnen}
682 if ( problemTime_->hasSourceTerm() )
683 {
684// TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "Fix source term.");
685 problemTime_->assembleSourceTerm(time);
686
687 // Fuege die rechte Seite der DGL (f bzw. f_{n+1}) der rechten Seite hinzu (skaliert mit coeffSourceTerm)
688 // Die Skalierung mit der Dichte erfolgt schon in der Assemblierungsfunktion!
689 addSourceTermToRHS(coeffSourceTerm);
690 }
691
692 // Uebergabeparameter fuer BC noch hinzu nehmen!
693 problemTime_->setBoundaries(time);
694 problemTime_->solve();
695
696 timeSteppingTool_->advanceTime(true/*output info*/);
697
698 if (print) {
699 exportTimestep();
700 }
701
702 }
703
704 comm_->barrier();
705 if (print)
706 {
707 closeExporter();
708 }
709}
710
711
712// TODO: Irgendwann einmal fuer St. Venant-Kirchoff oder so programmieren.
713// Erstmal nicht wichtig
714template<class SC,class LO,class GO,class NO>
715void DAESolverInTime<SC,LO,GO,NO>::advanceInTimeNonLinearNewmark()
716{
717
718 bool print = parameterList_->sublist("General").get("ParaViewExport",false);
719 bool printExtraData = parameterList_->sublist("General").get("Export Extra Data",false);
720 bool printData = parameterList_->sublist("General").get("Export Data",false);
721 if (print)
722 {
723 exportTimestep();
724 }
725
726 vec_dbl_ptr_Type its = Teuchos::rcp(new vec_dbl_Type ( 2, 0. ) ); //0:linear iterations, 1: nonlinear iterations
727 ExporterTxtPtr_Type exporterTimeTxt;
728 ExporterTxtPtr_Type exporterIterations;
729 ExporterTxtPtr_Type exporterNewtonIterations;
730 if (printData) {
731 std::string suffix = parameterList_->sublist("General").get("Export Suffix","");
732
733 exporterTimeTxt = Teuchos::rcp(new ExporterTxt());
734 exporterTimeTxt->setup( "time" + suffix, this->comm_ );
735
736 exporterNewtonIterations = Teuchos::rcp(new ExporterTxt());
737 exporterNewtonIterations->setup( "newtonIterations" + suffix, this->comm_ );
738
739 exporterIterations = Teuchos::rcp(new ExporterTxt());
740 exporterIterations->setup( "linearIterations" + suffix, this->comm_ );
741 }
742 // Groesse des Problems, Zeitschrittweite und Newmark-Parameter
743 int size = timeStepDef_.size();
744 TEUCHOS_TEST_FOR_EXCEPTION( size>1, std::runtime_error, "Newmark only implemented for systems of size 1x1.");
745 double dt = timeSteppingTool_->get_dt();
746 double beta = timeSteppingTool_->get_beta();
747 double gamma = timeSteppingTool_->get_gamma();
748
749 // Koeffizienten vor der Massematrix und vor der Systemmatrix des steady-Problems
750 SmallMatrix<double> massCoeff(size);
751 SmallMatrix<double> problemCoeff(size);
752 double coeffSourceTerm = 0.0; // Koeffizient fuer den Source-Term (= rechte Seite der DGL); mit Null initialisieren
753
754 // Koeffizient vor der Massematrix
755 massCoeff[0][0] = 1.0/(dt*dt*beta);
756 problemCoeff[0][0] = 1.0;
757 // Der Source Term ist schon nach der Assemblierung mit der Dichte \rho skaliert worden
758 coeffSourceTerm = 1.0; // ACHTUNG FUER SOURCE TERM, DER NICHT IN DER ZEIT DISKRETISIERT WIRD!
759
760 // Temporaerer Koeffizienten fuer die Skalierung der Massematrix in der rechten Seite des Systems in UpdateNewmarkRhs()
761 vec_dbl_Type coeffTemp(1);
762 coeffTemp.at(0) = 1.0;
763
764 // Uebergebe die Parameter fuer Masse- und steady-Problemmatrix an TimeProblem
765 // Wegen moeglicher Zeitschrittweitensteuerung, rufe CombineSystems()
766 // in jedem Zeitschritt auf, um LHS neu aufzustellen.
767 problemTime_->setTimeParameters(massCoeff, problemCoeff);
768
769 // ######################
770 // Time loop
771 // ######################
772 while(timeSteppingTool_->continueTimeStepping())
773 {
774 // Stelle (massCoeff*M + problemCoeff*A) auf
775 problemTime_->combineSystems();
776
777 // Update u und berechne u' und u'' mit Hilfe der Newmark-Vorschrift
778 problemTime_->updateSolutionNewmarkPreviousStep(dt, beta, gamma);
779
780 double time = timeSteppingTool_->currentTime() + dt;
781 problemTime_->updateTime ( time );
782 // Stelle die rechte Seite des zeitdiskretisierten Systems auf (ohne f_{n+1}).
783 // Bei Newmark lautet dies:
784 // M*[\frac{1}{dt^2*beta}*u_n + \frac{1}{dt*beta}*u'_n + \frac{0.5 - beta}{beta}*u''_n],
785 // wobei u' = v (velocity) und u'' = w (acceleration).
786 problemTime_->updateNewmarkRhs(dt, beta, gamma, coeffTemp);
787
788 // TODO: SourceTerm wird in jedem Zeitschritt neu berechnet; auch wenn konstant!!!
789 // if(time == 0){nur dann konstanten SourceTerm berechnen}
790 if (problemTime_->hasSourceTerm())
791 {
792// TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "Fix source term.");
793 problemTime_->assembleSourceTerm(time);
794
795 // Fuege die rechte Seite der DGL (f bzw. f_{n+1}) der rechten Seite hinzu (skaliert mit coeffSourceTerm)
796 // Die Skalierung mit der Dichte erfolgt schon in der Assemblierungsfunktion!
797 // This is done in calculateNonLinResidualVec for this nonlinear problem
798 addSourceTermToRHS(coeffSourceTerm);
799 }
800
801 // Uebergabeparameter fuer BC noch hinzu nehmen!
802// problemTime_->setBoundaries(time);
803
804 NonLinearSolver<SC, LO, GO, NO> nlSolver(parameterList_->sublist("General").get("Linearization","Newton"));
805 nlSolver.solve( *problemTime_, time, its );
806
807 timeSteppingTool_->advanceTime(true/*output info*/);
808 if (printData) {
809 exporterTimeTxt->exportData( timeSteppingTool_->currentTime() );
810 exporterIterations->exportData( (*its)[0] );
811 exporterNewtonIterations->exportData( (*its)[1] );
812 }
813 if (print) {
814 exportTimestep();
815 }
816
817 }
818
819 comm_->barrier();
820 if (print)
821 {
822 closeExporter();
823 }
824}
825
826template<class SC,class LO,class GO,class NO>
827void DAESolverInTime<SC,LO,GO,NO>::advanceInTimeFSI()
828{
829 // problemCoeff vor A (= komplettes steady-System)
830 // massCoeff vor M (= Massematrix)
831 // coeffSourceTerm vor f (= rechte Seite der DGL)
832
833
834 FSIProblemPtr_Type fsi = Teuchos::rcp_dynamic_cast<FSIProblem_Type>( this->problemTime_->getUnderlyingProblem() );
835
836 bool print = parameterList_->sublist("General").get("ParaViewExport",false);
837 bool printData = parameterList_->sublist("General").get("Export Data",false);
838 bool printExtraData = parameterList_->sublist("General").get("Export Extra Data",false);
839
840 if (print)
841 {
842 exportTimestep();
843 }
844
845
846 vec_dbl_ptr_Type its = Teuchos::rcp(new vec_dbl_Type ( 2, 0. ) ); //0:linear iterations, 1: nonlinear iterations
847 ExporterTxtPtr_Type exporterTimeTxt;
848 ExporterTxtPtr_Type exporterDisplXTxt;
849 ExporterTxtPtr_Type exporterDisplYTxt;
850 ExporterTxtPtr_Type exporterIterations;
851 ExporterTxtPtr_Type exporterNewtonIterations;
852
853 if (printData) {
854 exporterTimeTxt = Teuchos::rcp(new ExporterTxt());
855 exporterDisplXTxt = Teuchos::rcp(new ExporterTxt());
856 exporterDisplYTxt = Teuchos::rcp(new ExporterTxt());
857 exporterTimeTxt->setup( "time", this->comm_ );
858
859 std::string suffix = parameterList_->sublist("General").get("Export Suffix","");
860
861 exporterNewtonIterations = Teuchos::rcp(new ExporterTxt());
862 exporterNewtonIterations->setup( "newtonIterations" + suffix, this->comm_ );
863
864 exporterIterations = Teuchos::rcp(new ExporterTxt());
865 exporterIterations->setup( "linearIterations" + suffix, this->comm_ );
866 }
867 if (printExtraData) {
868
869 vec_dbl_Type v(3,-9999.);
870 this->problemTime_->getValuesOfInterest(v);
871 vec_dbl_Type vGathered(this->comm_->getSize());
872 Teuchos::gatherAll<int,double>( *this->comm_, 1, &v[0], vGathered.size(), &vGathered[0] );
873 int targetRank=0;
874 while (vGathered[targetRank] < 0){
875 targetRank++;
876 TEUCHOS_TEST_FOR_EXCEPTION( targetRank == vGathered.size(), std::runtime_error, "No targetRank for export of displacements was found!" );
877 }
878
879 std::string suffix = parameterList_->sublist("General").get("Export Suffix","");
880
881 exporterDisplXTxt->setup( "displ_x" + suffix, this->comm_ , targetRank);
882 exporterDisplYTxt->setup( "displ_y" + suffix, this->comm_ , targetRank);
883
884 }
885
886 // Notwendige Parameter
887 bool geometryExplicit = this->parameterList_->sublist("Parameter").get("Geometry Explicit",true);
888 int sizeFSI = timeStepDef_.size();
889
890 // ACHTUNG
891 int sizeFluid = 2; // u_f + p
892 int sizeStructure = 1; // d_s
893
894 double dt = timeSteppingTool_->get_dt();
895 double beta = timeSteppingTool_->get_beta();
896 double gamma = timeSteppingTool_->get_gamma();
897 int nmbBDF = timeSteppingTool_->getBDFNumber();
898
899 // ######################
900 // Fluid: Mass-, Problem, SourceTerm Koeffizienten
901 // ######################
902 SmallMatrix<double> massCoeffFluid(sizeFluid);
903 SmallMatrix<double> problemCoeffFluid(sizeFluid);
904 double coeffSourceTermFluid = 0.0;
905
906 for (int i=0; i<sizeFluid; i++) {
907 for (int j=0; j<sizeFluid; j++) {
908 if (timeStepDef_[i][j]>0 && i==j) {
909 massCoeffFluid[i][j] = timeSteppingTool_->getInformationBDF(0) / dt;
910 }
911 else{
912 massCoeffFluid[i][j] = 0.0;
913 }
914 }
915 }
916 for (int i=0; i<sizeFluid; i++) {
917 for (int j=0; j<sizeFluid; j++){
918 if (timeStepDef_[i][j]>0){
919 problemCoeffFluid[i][j] = timeSteppingTool_->getInformationBDF(1);
920 coeffSourceTermFluid = timeSteppingTool_->getInformationBDF(1);
921 }
922 else{
923 problemCoeffFluid[i][j] = 1.;
924 }
925 }
926 }
927
928
929 // ######################
930 // Struktur: Mass-, Problem, SourceTerm Koeffizienten
931 // ######################
932 // Koeffizienten vor der Massematrix und vor der Systemmatrix des steady-Problems
933 SmallMatrix<double> massCoeffStructure(sizeStructure);
934 SmallMatrix<double> problemCoeffStructure(sizeStructure);
935 double coeffSourceTermStructure = 0.0; // Koeffizient fuer den Source-Term (= rechte Seite der DGL); mit Null initialisieren
936
937 // Koeffizient vor der Massematrix
938 for(int i = 0; i < sizeStructure; i++)
939 {
940 for(int j = 0; j < sizeStructure; j++)
941 {
942 // Falls in dem Block von timeStepDef_ zeitintegriert werden soll.
943 // i == j, da vektorwertige Massematrix blockdiagonal ist
944 if(timeStepDef_[i + sizeFluid][j + sizeFluid] > 0 && i == j) // Weil: (u_f, p, d_s,...) und timeStepDef_ von FSI
945 {
946 // Vorfaktor der Massematrix in der LHS
947 massCoeffStructure[i][j] = 1.0/(dt*dt*beta);
948 }
949 else
950 {
951 massCoeffStructure[i][j] = 0.;
952 }
953 }
954 }
955
956
957 // Die anderen beiden Koeffizienten
958 for(int i = 0; i < sizeStructure; i++)
959 {
960 for(int j = 0; j < sizeStructure; j++)
961 {
962 if(timeStepDef_[i + sizeFluid][j + sizeFluid] > 0 )
963 {
964 problemCoeffStructure[i][j] = 1.0;
965 // Der Source Term ist schon nach der Assemblierung mit der Dichte \rho skaliert worden
966 coeffSourceTermStructure = 1.0; // ACHTUNG FUER SOURCE TERM, DER NICHT IN DER ZEIT DISKRETISIERT WIRD!
967 }
968 else // Die steady-Systemmatrix ist nicht zwingend blockdiagonal
969 {
970 problemCoeffStructure[i][j] = 1.0;
971 }
972 }
973 }
974
975
976 // ######################
977 // FSI: Mass-, Problem-Koeffizienten
978 // ######################
979 SmallMatrix<double> massCoeffFSI(sizeFSI);
980 SmallMatrix<double> problemCoeffFSI(sizeFSI);
981 for (int i = 0; i < sizeFluid; i++)
982 {
983 for (int j = 0; j < sizeFluid; j++)
984 {
985 massCoeffFSI[i][j] = massCoeffFluid[i][j];
986 problemCoeffFSI[i][j] = problemCoeffFluid[i][j];
987 }
988 }
989
990 for (int i = 0; i < sizeStructure; i++)
991 {
992 for (int j = 0; j < sizeStructure; j++)
993 {
994 massCoeffFSI[i + sizeFluid][j + sizeFluid] = massCoeffStructure[i][j];
995 problemCoeffFSI[i + sizeFluid][j + sizeFluid] = problemCoeffStructure[i][j];
996 }
997 }
998
999 // Setze noch Einsen an die Stellen, wo Eintraege (Kopplungsbloecke) vorhanden sind.
1000 problemCoeffFSI[0][3] = 1.0; // C1_T
1001 problemCoeffFSI[2][3] = 1.0; // C3_T
1002 problemCoeffFSI[3][0] = 1.0; // C1
1003 problemCoeffFSI[3][2] = 1.0; // C2
1004 if(!geometryExplicit)
1005 {
1006 problemCoeffFSI[4][2] = 1.0; // C4
1007 problemCoeffFSI[4][4] = 1.0; // H (Geometrie)
1008 std::string linearization = this->parameterList_->sublist("General").get("Linearization","Extrapolation");
1009 if(linearization == "Newton" || linearization == "NOX")
1010 {
1011 problemCoeffFSI[0][4] = 1.0; // Shape-Derivatives Velocity
1012 problemCoeffFSI[1][4] = 1.0; // Shape-Derivatives Div-Nebenbedingung
1013 }
1014 }
1015
1016 this->problemTime_->setTimeParameters(massCoeffFSI, problemCoeffFSI);
1017
1018 if (printExtraData) {
1019 exporterTimeTxt->exportData( timeSteppingTool_->currentTime() );
1020 vec_dbl_Type v(3,0.);
1021 this->problemTime_->getValuesOfInterest( v );
1022
1023 exporterDisplXTxt->exportData( v[0] );
1024 exporterDisplYTxt->exportData( v[1] );
1025 }
1026
1027// {
1028// // Initialize mass matrix for fluid problem
1029// MatrixPtr_Type massmatrix;
1030// TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Fix reassembly of mass matrix for FSI.");
1031// MatrixPtr_Type massmatrix;
1032// fsi->setSolidMassmatrix( massmatrix );
1034// }
1035 // ######################
1036 // Time loop
1037 // ######################
1038#ifdef FEDD_TIMER
1039 TimeMonitor_Type solveTM(*solveProblemTimer_);
1040#endif
1041 while(timeSteppingTool_->continueTimeStepping())
1042 {
1043 problemTime_->updateTime ( timeSteppingTool_->currentTime() );
1044
1045 std::string linearization = this->parameterList_->sublist("General").get("Linearization","Extrapolation");
1046
1047 // Ist noetig, falls wir extrapolieren, damit wir
1048 // immer die korrekten previousSolution_ haben.
1049 // TODO: Vermutlich reicht lediglich (da erstmal nur BDF2):
1050 // this->problemTime_->updateSolutionMultiPreviousStep(nmbBDF);
1051 if(nmbBDF<2 && !parameterList_->sublist("General").get("Linearization","FixedPoint").compare("Extrapolation"))
1052 {// we need the last two solution for a second order extrapolation.
1053 if (timeSteppingTool_->currentTime() != 0.0)
1054 {
1055 this->problemTime_->updateSolutionMultiPreviousStep(2);
1056 }
1057 else
1058 {
1059 this->problemTime_->updateSolutionMultiPreviousStep(1);
1060 }
1061 }
1062 else
1063 {
1064 this->problemTime_->updateSolutionMultiPreviousStep(nmbBDF);
1065 }
1066 {
1067#ifdef FEDD_DETAIL_TIMER
1068 TimeMonitor_Type reassmbleTM(*reassmbleAddInterfaceRHSTimer_);
1069#endif
1070 // Den Block C2*d_s^n in der RHS im Interface-Block setzen.
1071 this->problemTime_->assemble("AddInterfaceBlockRHS");
1072 }
1073 {
1074#ifdef FEDD_DETAIL_TIMER
1075 TimeMonitor_Type reassmbleTM(*reassmbleUpdateMeshDisplacementTimer_);
1076#endif
1077 // Alte Gitterbewegung mit der Geometrieloesung ueberschreiben.
1078 this->problemTime_->assemble("UpdateMeshDisplacement");
1079 }
1080 // Das Geometry-Problem separat loesen, falls GE.
1081 if(geometryExplicit)
1082 {
1083 {
1084#ifdef FEDD_DETAIL_TIMER
1085 TimeMonitor_Type reassmbleTM(*reassmbleSolveGeometryTimer_);
1086#endif
1087 this->problemTime_->assemble("SolveGeometryProblem");
1088 }
1089#ifdef FEDD_DETAIL_TIMER
1090 TimeMonitor_Type reassmbleTM(*reassmbleMoveMeshTimer_);
1091#endif
1092 this->problemTime_->assemble("MoveMesh");
1093 }
1094
1095
1096 // ######################
1097 // Struktur Zeitsystem
1098 // ######################
1099 // In jedem Zeitschritt die RHS der Struktur holen.
1100 // Die Massematrix wird in FSI jedoch nur fuer t = 0 berechnet, da Referenzkonfiguration
1101 // in der Struktur.
1102 {
1103
1104
1105#ifdef FEDD_DETAIL_TIMER
1106 TimeMonitor_Type reassmbleTM(*reassmbleSolidMassAndRHSTimer_);
1107#endif
1108 // Hier wird auch direkt ein Update der Loesung bei der Struktur gemacht.
1109 // Aehnlich zu "UpdateFluidInTime".
1110
1111 if(timeSteppingTool_->currentTime() == 0.0)
1112 {
1113 // We extract the underlying FSI problem
1114 MatrixPtr_Type massmatrix;
1115 fsi->setSolidMassmatrix( massmatrix );
1116 this->problemTime_->systemMass_->addBlock( massmatrix, 2, 2 );
1117 }
1118 // this should be done automatically rhs will not be used here
1119// this->problemTime_->getRhs()->addBlock( Teuchos::rcp_const_cast<MultiVector_Type>(rhs->getBlock(0)), 2 );
1120 this->problemTime_->assemble("ComputeSolidRHSInTime");
1121 }
1122
1123
1124 if(geometryExplicit) // && linearization != "Extrapolation"
1125 {
1126#ifdef FEDD_DETAIL_TIMER
1127 TimeMonitor_Type reassmbleTM(*reassmbleForTimeTimer_);
1128#endif
1129 this->problemTime_->assemble("ForTime");
1130 }
1131
1132 // ######################
1133 // Fluid Zeitsystem
1134 // ######################
1135 // Fluid-Loesung aktualisieren fuer die naechste(n) BDF2-Zeitintegration(en)
1136 // in diesem Zeitschritt.
1137 {
1138#ifdef FEDD_DETAIL_TIMER
1139 TimeMonitor_Type reassmbleTM(*reassmbleUpdateFluidInTimeTimer_);
1140#endif
1141 //Do we need this, if BDF for FSI is used correctly? We still need it to save the mass matrices
1142 this->problemTime_->assemble("UpdateFluidInTime");
1143 }
1144 // Aktuelle Massematrix auf dem Gitter fuer BDF2-Integration und
1145 // fuer das FSI-System (bei GI wird die Massematrix weiterhin in TimeProblem.reAssemble() assembliert).
1146 // In der ersten nichtlinearen Iteration wird bei GI also die Massematrix zweimal assembliert.
1147 // Massematrix fuer FSI holen und fuer timeProblemFluid setzen (fuer BDF2)
1148 MatrixPtr_Type massmatrix;
1149 fsi->setFluidMassmatrix( massmatrix );
1150 this->problemTime_->systemMass_->addBlock( massmatrix, 0, 0 );
1151
1152
1153 // RHS nach BDF2
1154 this->problemTime_->assemble( "ComputeFluidRHSInTime" ); // hier ist massmatrix nicht relevant
1155// this->problemTime_->getRhs()->addBlock( Teuchos::rcp_const_cast<MultiVector_Type>(rhs->getBlock(0)), 0 );
1156
1157
1158 // ######################
1159 // System loesen
1160 // ######################
1161 // Use BDF1 Parameters for first system
1162 if (timeSteppingTool_->currentTime() == 0.) {
1163 for (int i = 0; i < sizeFluid; i++)
1164 {
1165 for (int j = 0; j < sizeFluid; j++){
1166 if (massCoeffFSI[i][j] != 0.)
1167 massCoeffFSI[i][j] = 1./dt ;
1168 }
1169 }
1170 this->problemTime_->setTimeParameters(massCoeffFSI, problemCoeffFSI);
1171 }
1172
1173
1174 double time = timeSteppingTool_->currentTime() + dt;
1175 problemTime_->updateTime ( time );
1176 NonLinearSolver<SC, LO, GO, NO> nlSolver(parameterList_->sublist("General").get("Linearization","FixedPoint"));
1177
1178 nlSolver.solve(*this->problemTime_, time, its);
1179
1180 if (timeSteppingTool_->currentTime() <= dt+1.e-10) {
1181 for (int i = 0; i < sizeFluid; i++)
1182 {
1183 for (int j = 0; j < sizeFluid; j++){
1184 massCoeffFSI[i][j] = massCoeffFluid[i][j];
1185 }
1186 }
1187 this->problemTime_->setTimeParameters(massCoeffFSI, problemCoeffFSI);
1188 }
1189
1190 this->problemTime_->computeValuesOfInterestAndExport();
1191
1192 timeSteppingTool_->advanceTime(true/*output info*/);
1193 this->problemTime_->assemble("UpdateTime"); // Zeit in FSI inkrementieren
1194 if (printData) {
1195 exporterTimeTxt->exportData( timeSteppingTool_->currentTime() );
1196 exporterIterations->exportData( (*its)[0] );
1197 exporterNewtonIterations->exportData( (*its)[1] );
1198 }
1199 if (printExtraData) {
1200 vec_dbl_Type v(3,-9999.);
1201 this->problemTime_->getValuesOfInterest(v);
1202
1203 exporterDisplXTxt->exportData( v[0] );
1204 exporterDisplYTxt->exportData( v[1] );
1205 }
1206 if (print)
1207 {
1208 exportTimestep();
1209 }
1210
1211 }
1212
1213 comm_->barrier();
1214 if (printExtraData) {
1215 exporterTimeTxt->closeExporter();
1216 exporterIterations->closeExporter();
1217 exporterNewtonIterations->closeExporter();
1218 }
1219 if (printExtraData) {
1220 exporterDisplXTxt->closeExporter();
1221 exporterDisplYTxt->closeExporter();
1222 }
1223 if (print)
1224 {
1225 closeExporter();
1226 }
1227}
1228
1229
1230/* UEBERARBEITEN!!!!!!!!!!!!!!!!! */
1231template<class SC,class LO,class GO,class NO>
1232void DAESolverInTime<SC,LO,GO,NO>::advanceInTimeLinearMultistep(){
1233
1234 //TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "advanceInTimeLinearMultistep rework.");
1235 bool print = parameterList_->sublist("General").get("ParaViewExport",false);
1236 if (print) {
1237 exportTimestep();
1238 }
1239 int size = timeStepDef_.size();
1240 double dt = timeSteppingTool_->get_dt();
1241 int nmbBDF = timeSteppingTool_->getBDFNumber();
1242 vec_dbl_Type coeffPrevSteps(nmbBDF);
1243 for (int i=0; i<coeffPrevSteps.size(); i++) {
1244 coeffPrevSteps.at(i) = timeSteppingTool_->getInformationBDF(i+2) / dt;
1245 }
1246
1247 SmallMatrix<double> massCoeff(size);
1248 SmallMatrix<double> problemCoeff(size);
1249 double coeffSourceTerm = 0.;
1250
1251 for (int i=0; i<size; i++) {
1252 for (int j=0; j<size; j++) {
1253 if (timeStepDef_[i][j]==1 && i==j) {
1254 massCoeff[i][j] = timeSteppingTool_->getInformationBDF(0) / dt;
1255 }
1256 else{
1257 massCoeff[i][j] = 0.;
1258 }
1259 }
1260 }
1261 for (int i=0; i<size; i++) {
1262 for (int j=0; j<size; j++){
1263 if (timeStepDef_[i][j]==1){
1264 problemCoeff[i][j] = timeSteppingTool_->getInformationBDF(1);
1265 coeffSourceTerm = timeSteppingTool_->getInformationBDF(1); // ACHTUNG FUER SOURCE TERM, DER NICHT IN DER ZEIT DISKRETISIERT WIRD!
1266 }
1267 else{
1268 problemCoeff[i][j] = 1.;
1269 }
1270 }
1271 }
1272 problemTime_->setTimeParameters(massCoeff, problemCoeff);
1273
1274 //#########
1275 //time loop
1276 //#########
1277 while (timeSteppingTool_->continueTimeStepping()) {
1278
1279 problemTime_->updateSolutionMultiPreviousStep(nmbBDF);
1280
1281 double time = timeSteppingTool_->currentTime() + dt;
1282 problemTime_->updateMultistepRhs(coeffPrevSteps,nmbBDF);/*apply mass matrix to u_t*/
1283 if (problemTime_->hasSourceTerm()) {
1284 problemTime_->assembleSourceTerm(time);
1285 addSourceTermToRHS(coeffSourceTerm);
1286 }
1287
1288 problemTime_->combineSystems();
1289 // Uebergabeparameter fuer BC noch hinzunehmen!
1290 problemTime_->setBoundaries(time);
1291 problemTime_->solve();
1292
1293 timeSteppingTool_->advanceTime(true/*output info*/);
1294
1295 if (print) {
1296 exportTimestep();
1297 }
1298
1299 }
1300 comm_->barrier();
1301 if (print) {
1302 closeExporter();
1303 }
1304
1305}
1306
1307template<class SC,class LO,class GO,class NO>
1308void DAESolverInTime<SC,LO,GO,NO>::advanceInTimeNonLinearMultistep(){
1309
1310 bool print = parameterList_->sublist("General").get("ParaViewExport",false);
1311 if (print) {
1312 exportTimestep();
1313 }
1314
1315 int size = timeStepDef_.size();
1316 double dt = timeSteppingTool_->get_dt();
1317 int nmbBDF = timeSteppingTool_->getBDFNumber();
1318
1319 vec_dbl_Type coeffPrevSteps(nmbBDF);
1320 for (int i=0; i<coeffPrevSteps.size(); i++) {
1321 coeffPrevSteps.at(i) = timeSteppingTool_->getInformationBDF(i+2) / dt;
1322 }
1323
1324 SmallMatrix<double> massCoeff(size);
1325 SmallMatrix<double> problemCoeff(size);
1326 double coeffSourceTerm = 0.;
1327
1328 for (int i=0; i<size; i++) {
1329 for (int j=0; j<size; j++) {
1330 if (timeStepDef_[i][j]>0 && i==j) {
1331 massCoeff[i][j] = timeSteppingTool_->getInformationBDF(0) / dt;
1332 }
1333 else{
1334 massCoeff[i][j] = 0.;
1335 }
1336 }
1337 }
1338 for (int i=0; i<size; i++) {
1339 for (int j=0; j<size; j++){
1340 if (timeStepDef_[i][j]>0){
1341 problemCoeff[i][j] = timeSteppingTool_->getInformationBDF(1);
1342 coeffSourceTerm = timeSteppingTool_->getInformationBDF(1);
1343 }
1344 else{
1345 problemCoeff[i][j] = 1.;
1346 }
1347 }
1348 }
1349 problemTime_->setTimeParameters(massCoeff, problemCoeff);
1350 //#########
1351 //time loop
1352 //#########
1353 while (timeSteppingTool_->continueTimeStepping()) {
1354
1355 // For the first time step we use BDF1
1356 if (timeSteppingTool_->currentTime()==0.) {
1357 SmallMatrix<double> tmpmassCoeff(size);
1358 SmallMatrix<double> tmpproblemCoeff(size);
1359 for (int i=0; i<size; i++) {
1360 for (int j=0; j<size; j++) {
1361 if (timeStepDef_[i][j]>0 && i==j) {
1362 tmpmassCoeff[i][j] = 1. / dt;
1363 }
1364 else{
1365 tmpmassCoeff[i][j] = 0.;
1366 }
1367 }
1368 }
1369 for (int i=0; i<size; i++) {
1370 for (int j=0; j<size; j++){
1371 if (timeStepDef_[i][j]>0){
1372 tmpproblemCoeff[i][j] = 1.; // ist das richtig? Vermutlich schon, da BDF so geschrieben ist, dass zu berechnende Lsg den Koeffizienten 1 hat
1373 }
1374 else{
1375 tmpproblemCoeff[i][j] = 1.;
1376 }
1377 }
1378 }
1379 problemTime_->setTimeParameters(tmpmassCoeff, tmpproblemCoeff);
1380 }
1381 if(nmbBDF<2 && !parameterList_->sublist("General").get("Linearization","FixedPoint").compare("Extrapolation")) {
1382 if (timeSteppingTool_->currentTime()!=0.){
1383 problemTime_->updateSolutionMultiPreviousStep(2);
1384 }
1385 else{
1386 problemTime_->updateSolutionMultiPreviousStep(1);
1387 }
1388 }
1389 else{
1390 problemTime_->updateSolutionMultiPreviousStep(nmbBDF);
1391 }
1392 double time = timeSteppingTool_->currentTime() + dt;
1393 problemTime_->updateTime ( time );
1394
1395 if (timeSteppingTool_->currentTime()==0.) {
1396 vec_dbl_Type tmpcoeffPrevSteps(1, 1. / dt);
1397 problemTime_->updateMultistepRhs(tmpcoeffPrevSteps,1);/*apply (mass matrix / dt) to u_t*/
1398 }
1399 else{
1400 problemTime_->updateMultistepRhs(coeffPrevSteps,nmbBDF);/*apply (mass matrix / dt) to u_t*/
1401 }
1402 if (problemTime_->hasSourceTerm()) {
1403 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Check sourceterm.");
1404// problemTime_->AssembleSourceTerm(time);
1405// if (timeSteppingTool_->CurrentTime()==0.) {
1406// AddSourceTermToRHS(1.);
1407// }
1408// else{
1409// AddSourceTermToRHS(coeffSourceTerm); //ACHTUNG
1410// }
1411 }
1412
1413 NonLinearSolver<SC, LO, GO, NO> nlSolver(parameterList_->sublist("General").get("Linearization","FixedPoint"));
1414 nlSolver.solve(*problemTime_,time);
1415
1416 // After the first time step we can use the desired BDF Parameters
1417 if (timeSteppingTool_->currentTime()==0.) {
1418 problemTime_->setTimeParameters(massCoeff, problemCoeff);
1419 }
1420
1421 timeSteppingTool_->advanceTime(true/*output info*/);
1422
1423 if (print) {
1424 exportTimestep();
1425 }
1426 }
1427
1428 if (print) {
1429 closeExporter();
1430 }
1431
1432}
1433
1434template<class SC,class LO,class GO,class NO>
1435void DAESolverInTime<SC,LO,GO,NO>::advanceInTimeLinearExternal(){
1436 bool print = parameterList_->sublist("General").get("ParaViewExport",false);
1437 if (print) {
1438 exportTimestep();
1439 }
1440
1441 double dt = timeSteppingTool_->get_dt();
1442 int counter=0;
1443 //#########
1444 //time loop
1445 //#########
1446 while (timeSteppingTool_->continueTimeStepping()) {
1447
1448 double time = timeSteppingTool_->currentTime() + dt;
1449 problemTime_->updateTime ( time );
1450
1451 problemTime_->assemble( "Assemble" );
1452
1453 if (problemTime_->hasSourceTerm()){
1454 problemTime_->assembleSourceTerm(time); // assemble source term and add to rhs
1455 problemTime_->addToRhs( problemTime_->getSourceTerm() );
1456 }
1457
1458 problemTime_->setBoundaries( time );
1459
1460 BlockMultiVectorPtr_Type tmpSol = Teuchos::rcp(new BlockMultiVector_Type(problemTime_->getSolution()) );
1461
1462 //problemTime_->getSystemCombined()->print();
1463 //problemTime_->getRhs()->print();
1464
1465 problemTime_->solve();
1466
1467 //AceGen systems and solutions are always for a Newton method, i.e., we solve for an update even in the linear case.
1468 // ?? Alpha a + beta this?
1469 problemTime_->getSolution()->update( 1., tmpSol, -1. );
1470
1471 problemTime_->assemble( "SetSolutionNewton" ); // Newton solution is actually the solution at t+1 and time solution is still at time t
1472
1473 problemTime_->assemble( "OnlyUpdate" ); // updates AceGEN history
1474
1475 problemTime_->assemble( "SetSolutionInTime" ); // Here, we update the time solution with the Newton solution, which basically means that we can go to the next timestep
1476
1477 timeSteppingTool_->advanceTime(true/*output info*/);
1478 counter++;
1479 if (print)
1480 exportTimestep();
1481 }
1482
1483 if (print) {
1484 closeExporter();
1485 }
1486}
1487
1488template<class SC,class LO,class GO,class NO>
1489void DAESolverInTime<SC,LO,GO,NO>::advanceInTimeNonLinearExternal(){
1490
1491 bool print = parameterList_->sublist("General").get("ParaViewExport",false);
1492 if (print) {
1493 exportTimestep();
1494 }
1495
1496 double dt = timeSteppingTool_->get_dt();
1497 int counter=0;
1498 //#########
1499 //time loop
1500 //#########
1501 while (timeSteppingTool_->continueTimeStepping()) {
1502
1503 double time = timeSteppingTool_->currentTime() + dt;
1504 problemTime_->updateTime ( time );
1505
1506 if (problemTime_->hasSourceTerm()){
1507 problemTime_->assembleSourceTerm(time); // assemble source term; added to residual vector in calculateNonLinResidualVec()
1508 }
1509 NonLinearSolver<SC, LO, GO, NO> nlSolver(parameterList_->sublist("General").get("Linearization","Newton"));
1510 nlSolver.solve(*problemTime_,time);
1511 problemTime_->assemble( "OnlyUpdate" ); // updates AceGEN history
1512
1513 problemTime_->assemble( "SetSolutionInTime" ); // Here, we update the time solution with the Newton solution, which basically means that we can go to the next timestep
1514
1515 timeSteppingTool_->advanceTime(true/*output info*/);
1516 counter++;
1517 if (print) {
1518 exportTimestep();
1519 }
1520 }
1521
1522 if (print) {
1523 closeExporter();
1524 }
1525}
1526
1527template<class SC,class LO,class GO,class NO>
1528void DAESolverInTime<SC,LO,GO,NO>::addRhsDAE(SmallMatrix<double> coeff, BlockMatrixPtr_Type bMat, BlockMultiVectorPtr_Type vec){
1529
1530 BlockMultiVectorPtr_Type mv = Teuchos::rcp( new BlockMultiVector_Type( vec ) );
1531 bMat->apply( *vec, *mv , coeff );
1532 problemTime_->getRhs()->update( 1., *mv, 1. );
1533}
1534
1535template<class SC,class LO,class GO,class NO>
1536void DAESolverInTime<SC,LO,GO,NO>::addRhsDAE(SmallMatrix<double> coeff, BlockMultiVectorPtr_Type vec){
1537 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Is this correct? addRhsDAE!");
1538 for (int i=0; i<vec->size(); i++)
1539 problemTime_->getRhs()->getBlockNonConst(i)->update( coeff[i][i], vec->getBlock(i), 1. );
1540}
1541
1542template<class SC,class LO,class GO,class NO>
1543void DAESolverInTime<SC,LO,GO,NO>::addSourceTermToRHS(double coeff)
1544{
1545 BlockMultiVectorPtr_Type tmpMV = problemTime_->getSourceTerm();
1546
1547 problemTime_->getRhs()->update(coeff, *tmpMV, 1.);
1548}
1549
1550template<class SC,class LO,class GO,class NO>
1551void DAESolverInTime<SC,LO,GO,NO>::exportTimestep(){
1552
1553 if (!boolExporterSetup_) {
1554 setupExporter();
1555 }
1556 if (verbose_) {
1557 std::cout << "-- Exporting..."<< std::flush;
1558 }
1559 for (int i=0; i<exporter_vector_.size(); i++) {
1560
1561 exporter_vector_[i]->save( timeSteppingTool_->currentTime() );
1562
1563 }
1564
1565 if (verbose_) {
1566 std::cout << "done! --"<< std::endl;
1567 }
1568
1569}
1570
1571template<class SC,class LO,class GO,class NO>
1572void DAESolverInTime<SC,LO,GO,NO>::exportTimestep(BlockMultiVectorPtr_Type& solShort){
1573
1574 if (!boolExporterSetup_) {
1575 setupExporter(solShort);
1576 }
1577 if (verbose_) {
1578 std::cout << "-- Exporting..."<< std::flush;
1579 }
1580 for (int i=0; i<exporter_vector_.size(); i++) {
1581
1582 exporter_vector_[i]->save( timeSteppingTool_->currentTime() );
1583
1584 }
1585
1586 if (verbose_) {
1587 std::cout << "done! --"<< std::endl;
1588 }
1589
1590}
1591
1592template<class SC,class LO,class GO,class NO>
1593void DAESolverInTime<SC,LO,GO,NO>::closeExporter(){
1594
1595 if (boolExporterSetup_) {
1596 for (int i=0; i<exporter_vector_.size(); i++)
1597 exporter_vector_[i]->closeExporter();
1598 }
1599}
1600
1601
1602template<class SC,class LO,class GO,class NO>
1603void DAESolverInTime<SC,LO,GO,NO>::setupExporter(){
1604 for (int i=0; i<timeStepDef_.size(); i++) {
1605 // \lambda in FSI, koennen wir nicht exportieren, weil keine Elementliste dafuer vorhanden
1606 bool exportThisBlock = true;
1607 if(this->parameterList_->sublist("Parameter").get("FSI",false) == true )
1608 exportThisBlock = (i != 3);
1609 else if(this->parameterList_->sublist("Parameter").get("FSCI",false) == true)
1610 exportThisBlock = (i != 4);
1611
1612 if(exportThisBlock)
1613 {
1614 ExporterPtr_Type exporterPtr(new Exporter_Type());
1615 MultiVectorConstPtr_Type exportVector = problemTime_->getSolution()->getBlock(i);
1616
1617 DomainConstPtr_Type dom = problemTime_->getDomain(i);
1618
1619 int exportEveryXTimesteps = parameterList_->sublist("Exporter").get( "Export every X timesteps", 1 );
1620 std::string plSuffix = "Suffix variable" + std::to_string(i+1);
1621 std::string suffix = parameterList_->sublist("Exporter").get(plSuffix, "" );
1622 std::string varName = problemTime_->getVariableName(i) + suffix;
1623 MeshPtr_Type meshNonConst = Teuchos::rcp_const_cast<Mesh_Type>(dom->getMesh());
1624 exporterPtr->setup(varName, meshNonConst, dom->getFEType(), parameterList_);
1625
1626// exporterPtr->setup(dom->getDimension(), dom->getNumElementsGlobal(), dom->getElements(), dom->getPointsUnique(), dom->getMapUnique(), dom->getMapRepeated(), dom->getFEType(), varName, exportEveryXTimesteps, comm_ , parameterList_);
1627
1628 UN dofsPerNode = problemTime_->getDofsPerNode(i);
1629
1630 if (dofsPerNode == 1)
1631 exporterPtr->addVariable( exportVector, varName, "Scalar", dofsPerNode, dom->getMapUnique() );
1632 else
1633 exporterPtr->addVariable( exportVector, varName, "Vector", dofsPerNode, dom->getMapUnique() );
1634
1635 exporter_vector_.push_back(exporterPtr);
1636 export_solution_vector_.push_back(exportVector);
1637 }
1638 }
1639 boolExporterSetup_ = true;
1640
1641}
1642
1643template<class SC,class LO,class GO,class NO>
1644void DAESolverInTime<SC,LO,GO,NO>::setupExporter(BlockMultiVectorPtr_Type& solShort){
1645 for (int i=0; i<timeStepDef_.size(); i++) {
1646 // \lambda in FSI, koennen wir nicht exportieren, weil keine Elementliste dafuer vorhanden
1647 bool exportThisBlock = true;
1648 exportThisBlock = !(this->parameterList_->sublist("Parameter").get("FSI",false) && i == 3);
1649 if(exportThisBlock)
1650 {
1651 ExporterPtr_Type exporterPtr(new Exporter_Type());
1652 MultiVectorConstPtr_Type exportVector = problemTime_->getSolution()->getBlock(i);
1653 MultiVectorConstPtr_Type exportVectorShort = solShort->getBlock(i);
1654
1655 DomainConstPtr_Type dom = problemTime_->getDomain(i);
1656
1657 int exportEveryXTimesteps = parameterList_->sublist("Exporter").get( "Export every X timesteps", 1 );
1658 std::string plSuffix = "Suffix variable" + std::to_string(i+1);
1659 std::string suffix = parameterList_->sublist("Exporter").get(plSuffix, "" );
1660 std::string varName = problemTime_->getVariableName(i) + suffix;
1661 std::string varNameShort = problemTime_->getVariableName(i) + "_short_" + suffix;
1662
1663 MeshPtr_Type meshNonConst = Teuchos::rcp_const_cast<Mesh_Type>(dom->getMesh());
1664 exporterPtr->setup(varName, meshNonConst, dom->getFEType(), parameterList_);
1665
1666// exporterPtr->setup(dom->getDimension(), dom->getNumElementsGlobal(), dom->getElements(), dom->getPointsUnique(), dom->getMapUnique(), dom->getMapRepeated(), dom->getFEType(), varName, exportEveryXTimesteps, comm_ , parameterList_);
1667
1668 UN dofsPerNode = problemTime_->getDofsPerNode(i);
1669
1670 if (dofsPerNode == 1){
1671 exporterPtr->addVariable( exportVector, varName, "Scalar", dofsPerNode, dom->getMapUnique() );
1672 exporterPtr->addVariable( exportVectorShort, varNameShort, "Scalar", dofsPerNode, dom->getMapUnique() );
1673 }
1674 else {
1675 exporterPtr->addVariable( exportVector, varName, "Vector", dofsPerNode, dom->getMapUnique() );
1676 exporterPtr->addVariable( exportVectorShort, varNameShort, "Vector", dofsPerNode, dom->getMapUnique() );
1677 }
1678
1679
1680 exporter_vector_.push_back(exporterPtr);
1681 export_solution_vector_.push_back(exportVector);
1682 }
1683 }
1684 boolExporterSetup_ = true;
1685
1686}
1687
1688
1689 //ch 21.03.19: Funktion aendern!
1690template<class SC,class LO,class GO,class NO>
1691void DAESolverInTime<SC,LO,GO,NO>::setupTimeStepping(){
1692
1693 int size = this->problem_->getSystem()->size();
1694
1695 problemTime_.reset(new TimeProblem<SC,LO,GO,NO>(*this->problem_,comm_));
1696
1697 // Fuer FSI
1698 if(this->parameterList_->sublist("Parameter").get("FSI",false) || this->parameterList_->sublist("Parameter").get("SCI",false) || this->parameterList_->sublist("Parameter").get("FSCI",false))
1699 {
1700 // Beachte: Massematrix ist schon vektorwertig!
1701 // Reset auf Massesystem von problemTime_ (=FSI), da auf problemTime_ kein assemble() bzw. assembleMassSystem() aufgerufen wird.
1702 this->problemTime_->systemMass_.reset(new BlockMatrix_Type(this->problemTime_->getSystem()->size()));
1703 this->problemTime_->systemCombined_.reset( new BlockMatrix_Type( this->problemTime_->getSystem()->size() ));
1704 }
1705 else
1706 {
1707 size = timeStepDef_.size();
1708 SmallMatrix<double> massCoeff(size);
1709 SmallMatrix<double> problemCoeff(size); //hier egal, nur Massenmatrix wichtig. Deswegen auf Null belassen
1710
1711 for (int i=0; i<size; i++) {
1712 for (int j=0; j<size; j++) {
1713 if (timeStepDef_[i][j]>1 && i==j) {
1714 massCoeff[i][j] = 1.0;
1715 }
1716 else{
1717 massCoeff[i][j] = 0.;
1718 }
1719 }
1720 }
1721
1722 // Setze massCoeff und problemCoeff in TimeProblem
1723 // ACHTUNG: problemCoeff ist Null. Es wird also nur die Massematrix in systemCombined_ geschrieben.
1724 problemTime_->setTimeParameters(massCoeff,problemCoeff);
1725
1726 // Assembliere Massematrix -> ggf. ReAssemble() falls nichtlinear ->
1727 // -> das linearProblem (bzw. nonlinearProblem) von oben mit der Massematrix verbinden
1728 problemTime_->setTimeDef( timeStepDef_ );
1729 problemTime_->assemble( "MassSystem" );
1730 }
1731
1732
1733}
1734
1735template<class SC,class LO,class GO,class NO>
1736void DAESolverInTime<SC,LO,GO,NO>::setTimeStep(double dt){
1737
1738 checkTimeSteppingDef();
1739
1740
1741}
1742
1743template<class SC,class LO,class GO,class NO>
1744void DAESolverInTime<SC,LO,GO,NO>::setFinalTime(double T){
1745
1746 checkTimeSteppingDef();
1747
1748}
1749
1750template<class SC,class LO,class GO,class NO>
1751void DAESolverInTime<SC,LO,GO,NO>::checkTimeSteppingDef(){
1752#ifdef ASSERTS_WARNINGS
1753 MYASSERT(isTimeSteppingDefined_,"Time stepping not defined!");
1754#endif
1755
1756}
1757}
1758#endif
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5