Skip to content

Commit

Permalink
update 3D
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Jan 13, 2025
1 parent bd24120 commit 3b2c4c2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions soilFluxes3D/header/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@

bool GaussSeidelRelaxation (int myApproximation, double myResidualTolerance, int myProcess);

bool JacobiRelaxation (int approximation, double toleranceThreshold, int process);

#endif // SOLVER_H

36 changes: 36 additions & 0 deletions soilFluxes3D/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,39 @@ bool GaussSeidelRelaxation (int approximation, double toleranceThreshold, int pr

return true;
}


bool JacobiRelaxation (int approximation, double toleranceThreshold, int process)
{
double currentNorm = 1.0;
double bestNorm = currentNorm;

int maxIterationsNr = getMaxIterationsNr(approximation);
int iteration = 0;

while ((currentNorm > toleranceThreshold) && (iteration < maxIterationsNr))
{
if (process == PROCESS_HEAT)
{
currentNorm = GaussSeidelIterationHeat();
}
if (process == PROCESS_WATER)
{
// TODO Jacobi method

if (currentNorm < bestNorm)
{
bestNorm = currentNorm;
}
else if (currentNorm > (bestNorm * 10.0))
{
// non-convergent system
return false;
}
}

iteration++;
}

return true;
}
1 change: 0 additions & 1 deletion soilFluxes3D/water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ double redistribution(long i, TlinkedNode *link, int linkType)
}



bool computeFlux(long i, int matrixIndex, TlinkedNode *link, double deltaT, unsigned long myApprox, int linkType)
{
if ((*link).index == NOLINK) return false;
Expand Down

0 comments on commit 3b2c4c2

Please sign in to comment.