@@ -32,7 +32,7 @@ void Computation::runSimulation()
3232
3333 time += dt_;
3434
35- (*outputWriterParaview_).writeFile (time);
35+ // (*outputWriterParaview_).writeFile(time);
3636 // (*outputWriterText_).writeFile(time);
3737 }
3838}
@@ -48,9 +48,11 @@ void Computation::initialize(int argc, char *argv[])
4848 settings_.loadFromFile (filename);
4949
5050 // calculates mesh width in x- and y-direction based on given parameters
51- const double meshWidthX = settings_.physicalSize [0 ] / settings_.nCells [0 ];
52- const double meshWidthY = settings_.physicalSize [1 ] / settings_.nCells [1 ];
53- meshWidth_ = {meshWidthX, meshWidthY};
51+ dx_ = settings_.physicalSize [0 ] / settings_.nCells [0 ];
52+ dy_ = settings_.physicalSize [1 ] / settings_.nCells [1 ];
53+ meshWidth_ = {dx_, dy_};
54+ dxSquared_ = dx_ * dx_;
55+ dySquared_ = dy_ * dy_;
5456
5557 // either the Central Differences or the Donor cell scheme is used
5658 if (settings_.useDonorCell )
@@ -66,7 +68,7 @@ void Computation::initialize(int argc, char *argv[])
6668 else
6769 throw std::invalid_argument (" Only SOR and GaussSeidel are supported as pressure solvers." );
6870
69- outputWriterParaview_ = std::make_unique<OutputWriterParaview>(discretization_);
71+ // outputWriterParaview_ = std::make_unique<OutputWriterParaview>(discretization_);
7072 // outputWriterText_ = std::make_unique<OutputWriterText>(discretization_);
7173
7274 // boundary conditions for u and v on the boundary faces only need to be set once in the beginning of the computation
@@ -137,9 +139,7 @@ void Computation::applyPreliminaryBCOnBoundary()
137139
138140void Computation::computeTimeStepWidth ()
139141{
140- const double dx = meshWidth_[0 ];
141- const double dy = meshWidth_[1 ];
142- const double dtDiffusive = (settings_.re /2.0 ) * (dx*dx * dy*dy) / (dx*dx + dy*dy);
142+ const double dtDiffusive = (settings_.re /2.0 ) * (dxSquared_ * dySquared_) / (dxSquared_ + dySquared_);
143143
144144 double uAbsMax = 0.0 ;
145145 for (int i=(*discretization_).uIBegin ()-1 ; i < (*discretization_).uIEnd ()+1 ; i++)
@@ -162,12 +162,17 @@ void Computation::computeTimeStepWidth()
162162 }
163163 }
164164
165- const double dtConvectiveU = dx / uAbsMax;
166- const double dtConvectiveV = dy / vAbsMax;
165+ double dtConvectiveU = settings_.maximumDt ;
166+ double dtConvectiveV = settings_.maximumDt ;
167+ if (uAbsMax > 0.0 )
168+ dtConvectiveU = dx_ / uAbsMax;
169+ if (vAbsMax > 0.0 )
170+ dtConvectiveV = dy_ / vAbsMax;
167171
168172 // makes sure that all stability conditions (the convective conditions and the diffusive condition) are fulfilled
169173 // and that the demanded maximal time step is not exceeded
170- dt_ = settings_.tau * std::min ({dtDiffusive, dtConvectiveU, dtConvectiveV, settings_.maximumDt });
174+ dt_ = settings_.tau * std::min ({dtDiffusive, dtConvectiveU, dtConvectiveV});
175+ dt_ = std::min (dt_, settings_.maximumDt );
171176}
172177
173178void Computation::computePreliminaryVelocities ()
@@ -204,8 +209,8 @@ void Computation::computeRightHandSide()
204209 {
205210 for (int j=(*discretization_).pJBegin (); j < (*discretization_).pJEnd (); j++)
206211 {
207- const double fDiffQuotient = ((*discretization_).f (i,j) - (*discretization_).f (i-1 ,j)) / meshWidth_[ 0 ] ;
208- const double gDiffQuotient = ((*discretization_).g (i,j) - (*discretization_).g (i,j-1 )) / meshWidth_[ 1 ] ;
212+ const double fDiffQuotient = ((*discretization_).f (i,j) - (*discretization_).f (i-1 ,j)) / dx_ ;
213+ const double gDiffQuotient = ((*discretization_).g (i,j) - (*discretization_).g (i,j-1 )) / dy_ ;
209214 (*discretization_).rhs (i,j) = (1.0 /dt_) * (fDiffQuotient + gDiffQuotient );
210215 }
211216 }
@@ -222,15 +227,15 @@ void Computation::computeVelocities()
222227 {
223228 for (int j=(*discretization_).uJBegin (); j < (*discretization_).uJEnd (); j++)
224229 {
225- (*discretization_).u (i,j) = (*discretization_).f (i,j) - (dt_/meshWidth_[ 0 ] )
230+ (*discretization_).u (i,j) = (*discretization_).f (i,j) - (dt_/dx_ )
226231 * ((*discretization_).p (i+1 ,j) - (*discretization_).p (i,j));
227232 }
228233 }
229234 for (int i=(*discretization_).vIBegin (); i < (*discretization_).vIEnd (); i++)
230235 {
231236 for (int j=(*discretization_).vJBegin (); j < (*discretization_).vJEnd (); j++)
232237 {
233- (*discretization_).v (i,j) = (*discretization_).g (i,j) - (dt_/meshWidth_[ 1 ] )
238+ (*discretization_).v (i,j) = (*discretization_).g (i,j) - (dt_/dy_ )
234239 * ((*discretization_).p (i,j+1 ) - (*discretization_).p (i,j));
235240 }
236241 }
0 commit comments