PRISMS-PF  v2.1
solve.cc
Go to the documentation of this file.
1 //solve() method for MatrixFreePDE class
2 
3 #include "../../include/matrixFreePDE.h"
4 
5 //solve BVP
6 template <int dim, int degree>
8  //log time
9  computing_timer.enter_section("matrixFreePDE: solve");
10  pcout << "\nsolving...\n\n";
11 
12  //time dependent BVP
13  if (isTimeDependentBVP){
14 
15  // If grain reassignment is activated, reassign grains
16  if (userInputs.grain_remapping_activated and (currentIncrement%userInputs.skip_grain_reassignment_steps == 0 or currentIncrement == 0) ) {
17  reassignGrains();
18  }
19 
20  // For any nonlinear equation, set the initial guess as the solution to Laplace's equations
21  generatingInitialGuess = true;
22  setNonlinearEqInitialGuess();
23  generatingInitialGuess = false;
24 
25  // Do an initial solve to set the elliptic fields
26  solveIncrement(true);
27 
28  //output initial conditions for time dependent BVP
29  if (userInputs.outputTimeStepList[currentOutput] == currentIncrement) {
30 
31  for(unsigned int fieldIndex=0; fieldIndex<fields.size(); fieldIndex++){
32  constraintsDirichletSet[fieldIndex]->distribute(*solutionSet[fieldIndex]);
33  constraintsOtherSet[fieldIndex]->distribute(*solutionSet[fieldIndex]);
34  solutionSet[fieldIndex]->update_ghost_values();
35  }
36  outputResults();
37  currentOutput++;
38  }
39 
40  if (userInputs.checkpointTimeStepList[currentCheckpoint] == currentIncrement) {
41  save_checkpoint();
42  currentCheckpoint++;
43  }
44 
45  // Increase the current increment from 0 to 1 now that the initial conditions have been output
46  currentIncrement++;
47 
48  // Cycle up to the proper output and checkpoint counters
49  while (userInputs.outputTimeStepList.size() > 0 && userInputs.outputTimeStepList[currentOutput] < currentIncrement){
50  currentOutput++;
51  }
52  while (userInputs.checkpointTimeStepList.size() > 0 && userInputs.checkpointTimeStepList[currentCheckpoint] < currentIncrement){
53  currentCheckpoint++;
54  }
55 
56  //time stepping
57  pcout << "\nTime stepping parameters: timeStep: " << userInputs.dtValue << " timeFinal: " << userInputs.finalTime << " timeIncrements: " << userInputs.totalIncrements << "\n";
58 
59  // This is the main time-stepping loop
60  for (; currentIncrement<=userInputs.totalIncrements; ++currentIncrement){
61  //increment current time
62  currentTime+=userInputs.dtValue;
63  if (currentIncrement%userInputs.skip_print_steps==0){
64  pcout << "\ntime increment:" << currentIncrement << " time: " << currentTime << "\n";
65  }
66 
67  //check and perform adaptive mesh refinement
68  adaptiveRefine(currentIncrement);
69 
70  // Update the list of nuclei (if relevant)
71  updateNucleiList();
72 
73  // If grain reassignment is activated, reassign grains
74  if (userInputs.grain_remapping_activated and (currentIncrement%userInputs.skip_grain_reassignment_steps == 0 or currentIncrement == 0) ) {
75  reassignGrains();
76  }
77 
78  //solve time increment
79  solveIncrement(false);
80 
81  // Output results to file (on the proper increments)
82  if (userInputs.outputTimeStepList[currentOutput] == currentIncrement) {
83  for(unsigned int fieldIndex=0; fieldIndex<fields.size(); fieldIndex++){
84  constraintsDirichletSet[fieldIndex]->distribute(*solutionSet[fieldIndex]);
85  constraintsOtherSet[fieldIndex]->distribute(*solutionSet[fieldIndex]);
86  solutionSet[fieldIndex]->update_ghost_values();
87  }
88  outputResults();
89  currentOutput++;
90  }
91 
92  // Create a checkpoint (on the proper increments)
93  if (userInputs.checkpointTimeStepList[currentCheckpoint] == currentIncrement) {
94  save_checkpoint();
95  currentCheckpoint++;
96  }
97 
98  }
99  }
100 
101  //time independent BVP
102  else{
103  generatingInitialGuess = false;
104 
105  //solve
106  solveIncrement(false);
107 
108  //output results to file
109  outputResults();
110  }
111 
112  //log time
113  computing_timer.exit_section("matrixFreePDE: solve");
114 }
115 
116 #include "../../include/matrixFreePDE_template_instantiations.h"
void solve()
Definition: solve.cc:7