Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/SoilProfile2DHelper.cs =================================================================== diff -u -r5427 -r5434 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/SoilProfile2DHelper.cs (.../SoilProfile2DHelper.cs) (revision 5427) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/SoilProfile2DHelper.cs (.../SoilProfile2DHelper.cs) (revision 5434) @@ -68,49 +68,22 @@ return count > 0; } - public static bool IsAtLeastOneIsolatedInBetweenAquiferPresent(SoilProfile2D soilProfile, out int count) + public static bool IsAtLeastOneIsolatedInBetweenAquiferPresent(SoilProfile2D soilProfile) { double[] xCoordinates = DetermineAllXCoordinatesOfSoilProfile(soilProfile); var previousCount = 0; - count = 0; SoilProfile1D previousCrossSection = null; for (var i = 0; i < xCoordinates.Length; i++) { SoilProfile1D crossSection = soilProfile.GetSoilProfile1D(xCoordinates[i]); int currentCount = crossSection.GetInBetweenAquiferClusters?.Count ?? 0; - count = i == 0 ? currentCount : count; - + if (i > 0 && currentCount != previousCount) { - // If more than one new or one less in-between aquifers are found, at least one is an isolated aquifer. - if (Math.Abs(currentCount - previousCount) > 1) + if (IsAtLeastOneIsolatedInBetweenAquiferPresent(currentCount, previousCount, crossSection, previousCrossSection)) { - count = -1; return true; } - - if (currentCount > 0 && crossSection.GetInBetweenAquiferClusters != null) - { - // If one new in-between aquifer is found, the top layer in the previous cross-section must be an aquifer. - // If not, it is an isolated aquifer. - if (currentCount - previousCount == 1) - { - if (!previousCrossSection.Layers[0].IsAquifer) - { - count = -1; - return true; - } - count++; - } - - // If one less in-between aquifer is found, the top layer in the current section must be an aquifer. - // If not, it is an isolated aquifer. - if (previousCount - currentCount == 1 && !crossSection.Layers[0].IsAquifer) - { - count = -1; - return true; - } - } } previousCount = currentCount; @@ -120,6 +93,31 @@ return false; } + private static bool IsAtLeastOneIsolatedInBetweenAquiferPresent(int currentCount, int previousCount, SoilProfile1D currentCrossSection, SoilProfile1D previousCrossSection) + { + // If more than one new or one less in-between aquifers are found, at least one is an isolated aquifer. + if (Math.Abs(currentCount - previousCount) > 1) + { + return true; + } + + if (currentCount <= 0 || currentCrossSection.GetInBetweenAquiferClusters == null) + { + return false; + } + + // If one new in-between aquifer is found, the top layer in the previous cross-section must be an aquifer. + // If not, it is an isolated aquifer. + if (currentCount - previousCount == 1 && !previousCrossSection.Layers[0].IsAquifer) + { + return true; + } + + // If one less in-between aquifer is found, the top layer in the current section must be an aquifer. + // If not, it is an isolated aquifer. + return previousCount - currentCount == 1 && !currentCrossSection.Layers[0].IsAquifer; + } + /// /// Determines all the points of the layer boundary for the specified layer type: /// - For LayerType = BottomAquiferCluster, layerBoundaryTop is the top boundary of the bottom aquifer (= waternet line for PL3)