Skip to content

Commit

Permalink
Merge commit 'f1bf754611e24d34fcd93d0b5ec86e46e1c8c18f'
Browse files Browse the repository at this point in the history
  • Loading branch information
cate-to committed Jan 22, 2025
2 parents 2526f15 + f1bf754 commit 0f052a3
Show file tree
Hide file tree
Showing 13 changed files with 268 additions and 133 deletions.
2 changes: 1 addition & 1 deletion agrolib/criteriaModel/criteria1DCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ bool Crit1DCase::initializeNumericalFluxes(std::string &error)

float horizontalConductivityRatio = 10.0;
soilFluxes3D::setHydraulicProperties(fittingOptions.waterRetentionCurve, MEAN_LOGARITHMIC, horizontalConductivityRatio);
soilFluxes3D::setNumericalParameters(60, 3600, 100, 10, 12, 3);
soilFluxes3D::setNumericalParameters(60, 3600, 100, 10, 10, 3);

// set soil properties (units of measurement: MKS)
int soilIndex = 0;
Expand Down
24 changes: 5 additions & 19 deletions agrolib/gis/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ bool Crit3DColorScale::classify()
nrIntervals = MAXVALUE(_nrKeyColors -1, 1);
nrStep = _nrColors / nrIntervals;

_nrColors = nrStep * nrIntervals;
color.resize(_nrColors);

for (i = 0; i < nrIntervals; i++)
{
dRed = float(keyColor[i+1].red - keyColor[i].red) / float(nrStep);
Expand All @@ -120,24 +123,7 @@ bool Crit3DColorScale::classify()

Crit3DColor* Crit3DColorScale::getColor(float value)
{
unsigned int index = 0;

if (value <= _minimum)
{
index = 0;
}
else if (value >= _maximum)
{
index = _nrColors-1;
}
else
{
if (_classification == classificationMethod::EqualInterval)
{
index = unsigned(float(_nrColors-1) * ((value - _minimum) / (_maximum - _minimum)));
}
}

unsigned int index = getColorIndex(value);
return &color[index];
}

Expand Down Expand Up @@ -237,7 +223,7 @@ bool setAnomalyScale(Crit3DColorScale* myScale)

bool setPrecipitationScale(Crit3DColorScale* myScale)
{
myScale->initialize(6, 252);
myScale->initialize(6, 256);

myScale->keyColor[0] = Crit3DColor(255, 255, 255); /*!< white */
myScale->keyColor[1] = Crit3DColor(0, 0, 255); /*!< blue */
Expand Down
2 changes: 1 addition & 1 deletion agrolib/graphics/mapGraphicsRasterUtm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ bool RasterUtmObject::drawRaster(QPainter* painter)
// check outliers (transparent)
if (_rasterPointer->colorScale->isHideOutliers())
{
if (value <= _rasterPointer->colorScale->minimum() || value > _rasterPointer->colorScale->maximum())
if (isEqual(value, 0) || value <= _rasterPointer->colorScale->minimum() || value > _rasterPointer->colorScale->maximum())
continue;
}

Expand Down
3 changes: 2 additions & 1 deletion agrolib/mathFunctions/commonConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
#define BOUNDARY_SOLUTEFLUX 30
#define BOUNDARY_NONE 99

#define RELAXATION 1
#define GAUSS_SEIDEL 1
#define JACOBI 2

// --------------- heat model -----------------
#define SAVE_HEATFLUXES_NONE 0
Expand Down
2 changes: 1 addition & 1 deletion agrolib/meteo/meteo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ bool setColorScale(meteoVariable variable, Crit3DColorScale *colorScale)
case snowFall: case snowWaterEquivalent: case snowLiquidWaterContent: case snowMelt:
case dailyWaterTableDepth:
setPrecipitationScale(colorScale);
if (variable == snowFall || variable == snowWaterEquivalent
if (variable == precipitation || variable == snowFall || variable == snowWaterEquivalent
|| variable == snowLiquidWaterContent || variable == snowMelt)
{
colorScale->setHideOutliers(true);
Expand Down
2 changes: 1 addition & 1 deletion agrolib/soilFluxes3D/header/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

void initialize()
{
numericalSolutionMethod = RELAXATION;
numericalSolutionMethod = GAUSS_SEIDEL;
delta_t_min = 1;
delta_t_max = 600;
current_delta_t = delta_t_max;
Expand Down
4 changes: 1 addition & 3 deletions agrolib/soilFluxes3D/header/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

double arithmeticMean(double v1, double v2);

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

bool JacobiRelaxation (int approximation, double toleranceThreshold, int process);
bool solver(int myApproximation, double myResidualTolerance, int myProcess);

#endif // SOLVER_H

2 changes: 1 addition & 1 deletion agrolib/soilFluxes3D/header/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
extern TCrit3Dnode *nodeList;
extern TmatrixElement **A;
extern Tculvert myCulvert;
extern double *b, *C, *X;
extern double *b, *C, *X, *X1;
extern double *invariantFlux; // array accessorio per flussi avvettivi e latenti
extern double Courant;

Expand Down
2 changes: 1 addition & 1 deletion agrolib/soilFluxes3D/heat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ bool HeatComputation(double timeStep, double timeStepWater)
return (false);
}

GaussSeidelRelaxation(0, myParameters.ResidualTolerance, PROCESS_HEAT);
solver(0, myParameters.ResidualTolerance, PROCESS_HEAT);

for (i = 1; i < myStructure.nrNodes; i++)
nodeList[i].extra->Heat->T = X[i];
Expand Down
42 changes: 27 additions & 15 deletions agrolib/soilFluxes3D/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ void cleanArrays()
}

/*! free arrays */
if (invariantFlux != nullptr) { free(invariantFlux); invariantFlux = nullptr; }
if (b != nullptr) { free(b); b = nullptr; }
if (C != nullptr) { free(C); C = nullptr; }
if (invariantFlux != nullptr) { free(invariantFlux); invariantFlux = nullptr; }
if (X != nullptr) { free(X); X = nullptr; }
if (X1 != nullptr) { free(X1); X1 = nullptr; }
}


Expand All @@ -72,38 +73,49 @@ void cleanNodes()
*/
int initializeArrays()
{
long i, j, n;

/*! clean previous arrays */
cleanArrays();

/*! matrix solver: rows */
/*! matrix A: rows */
A = (TmatrixElement **) calloc(myStructure.nrNodes, sizeof(TmatrixElement *));

/*! matrix solver: columns */
for (i = 0; i < myStructure.nrNodes; i++)
A[i] = (TmatrixElement *) calloc(myStructure.maxNrColumns, sizeof(TmatrixElement));
/*! matrix A: columns */
for (long i = 0; i < myStructure.nrNodes; i++)
{
A[i] = (TmatrixElement *) calloc(myStructure.maxNrColumns, sizeof(TmatrixElement));
}

/*! initialize matrix solver */
for (i = 0; i < myStructure.nrNodes; i++)
for (j = 0; j < (myStructure.nrLateralLinks + 2); j++)
/*! initialize matrix A */
for (long i = 0; i < myStructure.nrNodes; i++)
{
for (int j = 0; j < myStructure.maxNrColumns; j++)
{
A[i][j].index = NOLINK;
A[i][j].val = 0.;
}
}

b = (double *) calloc(myStructure.nrNodes, sizeof(double));
for (n = 0; n < myStructure.nrNodes; n++) b[n] = 0.;
for (long i = 0; i < myStructure.nrNodes; i++)
{
b[i] = 0.;
}

X = (double *) calloc(myStructure.nrNodes, sizeof(double));

/*! mass diagonal matrix */
C = (double *) calloc(myStructure.nrNodes, sizeof(double));
for (n = 0; n < myStructure.nrNodes; n++) C[n] = 0.;
if (myParameters.numericalSolutionMethod == JACOBI)
{
X1 = (double *) calloc(myStructure.nrNodes, sizeof(double));
}

/*! mass diagonal matrix */
C = (double *) calloc(myStructure.nrNodes, sizeof(double));
invariantFlux = (double *) calloc(myStructure.nrNodes, sizeof(double));
for (n = 0; n < myStructure.nrNodes; n++) invariantFlux[n] = 0.;
for (long n = 0; n < myStructure.nrNodes; n++)
{
C[n] = 0.;
invariantFlux[n] = 0.;
}

if (A == nullptr)
return MEMORY_ERROR;
Expand Down
3 changes: 2 additions & 1 deletion agrolib/soilFluxes3D/soilFluxes3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ TmatrixElement **A = nullptr;

double *invariantFlux = nullptr;
double *C = nullptr;
double *X = nullptr;
double *b = nullptr;
double *X = nullptr;
double *X1 = nullptr;

std::vector< std::vector<Tsoil>> Soil_List;
std::vector<Tsoil> Surface_List;
Expand Down
Loading

0 comments on commit 0f052a3

Please sign in to comment.