Skip to content

Commit 0f052a3

Browse files
committed
Merge commit 'f1bf754611e24d34fcd93d0b5ec86e46e1c8c18f'
2 parents 2526f15 + f1bf754 commit 0f052a3

File tree

13 files changed

+268
-133
lines changed

13 files changed

+268
-133
lines changed

agrolib/criteriaModel/criteria1DCase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ bool Crit1DCase::initializeNumericalFluxes(std::string &error)
154154

155155
float horizontalConductivityRatio = 10.0;
156156
soilFluxes3D::setHydraulicProperties(fittingOptions.waterRetentionCurve, MEAN_LOGARITHMIC, horizontalConductivityRatio);
157-
soilFluxes3D::setNumericalParameters(60, 3600, 100, 10, 12, 3);
157+
soilFluxes3D::setNumericalParameters(60, 3600, 100, 10, 10, 3);
158158

159159
// set soil properties (units of measurement: MKS)
160160
int soilIndex = 0;

agrolib/gis/color.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ bool Crit3DColorScale::classify()
9797
nrIntervals = MAXVALUE(_nrKeyColors -1, 1);
9898
nrStep = _nrColors / nrIntervals;
9999

100+
_nrColors = nrStep * nrIntervals;
101+
color.resize(_nrColors);
102+
100103
for (i = 0; i < nrIntervals; i++)
101104
{
102105
dRed = float(keyColor[i+1].red - keyColor[i].red) / float(nrStep);
@@ -120,24 +123,7 @@ bool Crit3DColorScale::classify()
120123

121124
Crit3DColor* Crit3DColorScale::getColor(float value)
122125
{
123-
unsigned int index = 0;
124-
125-
if (value <= _minimum)
126-
{
127-
index = 0;
128-
}
129-
else if (value >= _maximum)
130-
{
131-
index = _nrColors-1;
132-
}
133-
else
134-
{
135-
if (_classification == classificationMethod::EqualInterval)
136-
{
137-
index = unsigned(float(_nrColors-1) * ((value - _minimum) / (_maximum - _minimum)));
138-
}
139-
}
140-
126+
unsigned int index = getColorIndex(value);
141127
return &color[index];
142128
}
143129

@@ -237,7 +223,7 @@ bool setAnomalyScale(Crit3DColorScale* myScale)
237223

238224
bool setPrecipitationScale(Crit3DColorScale* myScale)
239225
{
240-
myScale->initialize(6, 252);
226+
myScale->initialize(6, 256);
241227

242228
myScale->keyColor[0] = Crit3DColor(255, 255, 255); /*!< white */
243229
myScale->keyColor[1] = Crit3DColor(0, 0, 255); /*!< blue */

agrolib/graphics/mapGraphicsRasterUtm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ bool RasterUtmObject::drawRaster(QPainter* painter)
370370
// check outliers (transparent)
371371
if (_rasterPointer->colorScale->isHideOutliers())
372372
{
373-
if (value <= _rasterPointer->colorScale->minimum() || value > _rasterPointer->colorScale->maximum())
373+
if (isEqual(value, 0) || value <= _rasterPointer->colorScale->minimum() || value > _rasterPointer->colorScale->maximum())
374374
continue;
375375
}
376376

agrolib/mathFunctions/commonConstants.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@
109109
#define BOUNDARY_SOLUTEFLUX 30
110110
#define BOUNDARY_NONE 99
111111

112-
#define RELAXATION 1
112+
#define GAUSS_SEIDEL 1
113+
#define JACOBI 2
113114

114115
// --------------- heat model -----------------
115116
#define SAVE_HEATFLUXES_NONE 0

agrolib/meteo/meteo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ bool setColorScale(meteoVariable variable, Crit3DColorScale *colorScale)
792792
case snowFall: case snowWaterEquivalent: case snowLiquidWaterContent: case snowMelt:
793793
case dailyWaterTableDepth:
794794
setPrecipitationScale(colorScale);
795-
if (variable == snowFall || variable == snowWaterEquivalent
795+
if (variable == precipitation || variable == snowFall || variable == snowWaterEquivalent
796796
|| variable == snowLiquidWaterContent || variable == snowMelt)
797797
{
798798
colorScale->setHideOutliers(true);

agrolib/soilFluxes3D/header/parameters.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
void initialize()
2424
{
25-
numericalSolutionMethod = RELAXATION;
25+
numericalSolutionMethod = GAUSS_SEIDEL;
2626
delta_t_min = 1;
2727
delta_t_max = 600;
2828
current_delta_t = delta_t_max;

agrolib/soilFluxes3D/header/solver.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
double arithmeticMean(double v1, double v2);
1313

14-
bool GaussSeidelRelaxation (int myApproximation, double myResidualTolerance, int myProcess);
15-
16-
bool JacobiRelaxation (int approximation, double toleranceThreshold, int process);
14+
bool solver(int myApproximation, double myResidualTolerance, int myProcess);
1715

1816
#endif // SOLVER_H
1917

agrolib/soilFluxes3D/header/types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
extern TCrit3Dnode *nodeList;
146146
extern TmatrixElement **A;
147147
extern Tculvert myCulvert;
148-
extern double *b, *C, *X;
148+
extern double *b, *C, *X, *X1;
149149
extern double *invariantFlux; // array accessorio per flussi avvettivi e latenti
150150
extern double Courant;
151151

agrolib/soilFluxes3D/heat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ bool HeatComputation(double timeStep, double timeStepWater)
991991
return (false);
992992
}
993993

994-
GaussSeidelRelaxation(0, myParameters.ResidualTolerance, PROCESS_HEAT);
994+
solver(0, myParameters.ResidualTolerance, PROCESS_HEAT);
995995

996996
for (i = 1; i < myStructure.nrNodes; i++)
997997
nodeList[i].extra->Heat->T = X[i];

agrolib/soilFluxes3D/memory.cpp

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ void cleanArrays()
4444
}
4545

4646
/*! free arrays */
47+
if (invariantFlux != nullptr) { free(invariantFlux); invariantFlux = nullptr; }
4748
if (b != nullptr) { free(b); b = nullptr; }
4849
if (C != nullptr) { free(C); C = nullptr; }
49-
if (invariantFlux != nullptr) { free(invariantFlux); invariantFlux = nullptr; }
5050
if (X != nullptr) { free(X); X = nullptr; }
51+
if (X1 != nullptr) { free(X1); X1 = nullptr; }
5152
}
5253

5354

@@ -72,38 +73,49 @@ void cleanNodes()
7273
*/
7374
int initializeArrays()
7475
{
75-
long i, j, n;
76-
7776
/*! clean previous arrays */
7877
cleanArrays();
7978

80-
/*! matrix solver: rows */
79+
/*! matrix A: rows */
8180
A = (TmatrixElement **) calloc(myStructure.nrNodes, sizeof(TmatrixElement *));
8281

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

87-
/*! initialize matrix solver */
88-
for (i = 0; i < myStructure.nrNodes; i++)
89-
for (j = 0; j < (myStructure.nrLateralLinks + 2); j++)
88+
/*! initialize matrix A */
89+
for (long i = 0; i < myStructure.nrNodes; i++)
90+
{
91+
for (int j = 0; j < myStructure.maxNrColumns; j++)
9092
{
9193
A[i][j].index = NOLINK;
9294
A[i][j].val = 0.;
9395
}
96+
}
9497

9598
b = (double *) calloc(myStructure.nrNodes, sizeof(double));
96-
for (n = 0; n < myStructure.nrNodes; n++) b[n] = 0.;
99+
for (long i = 0; i < myStructure.nrNodes; i++)
100+
{
101+
b[i] = 0.;
102+
}
97103

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

100-
/*! mass diagonal matrix */
101-
C = (double *) calloc(myStructure.nrNodes, sizeof(double));
102-
for (n = 0; n < myStructure.nrNodes; n++) C[n] = 0.;
106+
if (myParameters.numericalSolutionMethod == JACOBI)
107+
{
108+
X1 = (double *) calloc(myStructure.nrNodes, sizeof(double));
109+
}
103110

104111
/*! mass diagonal matrix */
112+
C = (double *) calloc(myStructure.nrNodes, sizeof(double));
105113
invariantFlux = (double *) calloc(myStructure.nrNodes, sizeof(double));
106-
for (n = 0; n < myStructure.nrNodes; n++) invariantFlux[n] = 0.;
114+
for (long n = 0; n < myStructure.nrNodes; n++)
115+
{
116+
C[n] = 0.;
117+
invariantFlux[n] = 0.;
118+
}
107119

108120
if (A == nullptr)
109121
return MEMORY_ERROR;

0 commit comments

Comments
 (0)