Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update parameters (GRIDEDIT-563) #11

Merged
merged 10 commits into from
Jul 5, 2023
74 changes: 38 additions & 36 deletions MeshKernelNET/src/MeshKernelNETCore/Api/MakeGridParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ namespace MeshKernelNETCore.Api
[ProtoContract(AsReferenceDefault = true)]
public class MakeGridParameters : INotifyPropertyChanged
{
private double yGridBlockSize;
private double xGridBlockSize;
private double originZCoordinate;
private double originYCoordinate;
private double originXCoordinate;
private double gridBlockSize;
private double gridAngle;
private int numberOfRows;
private int numberOfColumns;
private double gridAngle;
private double originXCoordinate;
private double originYCoordinate;
private double xGridBlockSize;
private double yGridBlockSize;
private double upperRightCornerXCoordinate;
private double upperRightCornerYCoordinate;


private GridTypeOptions gridType;

public static MakeGridParameters CreateDefault()
Expand All @@ -26,12 +28,12 @@ public static MakeGridParameters CreateDefault()
NumberOfColumns = 3,
NumberOfRows = 3,
GridAngle = 0.0,
GridBlockSize = 0.0,
OriginXCoordinate = 0.0,
OriginYCoordinate = 0.0,
OriginZCoordinate = 0.0,
XGridBlockSize = 10.0,
YGridBlockSize = 10.0
YGridBlockSize = 10.0,
UpperRightCornerXCoordinate = 0.0,
UpperRightCornerYCoordinate = 0.0
};
}

Expand All @@ -50,7 +52,7 @@ public GridTypeOptions GridType
}

/// <summary>
/// * The number of columns in x direction (3)
/// * The number of columns in x direction (0)
/// </summary>
[ProtoMember(2)]
public int NumberOfColumns
Expand All @@ -64,7 +66,7 @@ public int NumberOfColumns
}

/// <summary>
/// * The number of columns in y direction (3)
/// * The number of columns in y direction (0)
/// </summary>
[ProtoMember(3)]
public int NumberOfRows
Expand Down Expand Up @@ -92,85 +94,85 @@ public double GridAngle
}

/// <summary>
/// * The grid block size, used in x and y direction (50.0)
/// * The x coordinate of the origin, located at the bottom left corner (0.0)
/// </summary>
[ProtoMember(5)]
public double GridBlockSize
public double OriginXCoordinate
{
get { return gridBlockSize; }
get { return originXCoordinate; }
set
{
gridBlockSize = value;
originXCoordinate = value;
OnPropertyChanged();
}
}

/// <summary>
/// * The x coordinate of the origin, located at the bottom left corner (0.0)
/// * The y coordinate of the origin, located at the bottom left corner (0.0)
/// </summary>
[ProtoMember(6)]
public double OriginXCoordinate
public double OriginYCoordinate
{
get { return originXCoordinate; }
get { return originYCoordinate; }
set
{
originXCoordinate = value;
originYCoordinate = value;
OnPropertyChanged();
}
}

/// <summary>
/// * The y coordinate of the origin, located at the bottom left corner (0.0)
/// * The grid block size in x dimension, used only for squared grids (0.0)
/// </summary>
[ProtoMember(7)]
public double OriginYCoordinate
public double XGridBlockSize
{
get { return originYCoordinate; }
get { return xGridBlockSize; }
set
{
originYCoordinate = value;
xGridBlockSize = value;
OnPropertyChanged();
}
}

/// <summary>
/// * The z coordinate of the origin, located at the bottom left corner (0.0)
/// * The grid block size in y dimension, used only for squared grids (0.0)
/// </summary>
[ProtoMember(8)]
public double OriginZCoordinate
public double YGridBlockSize
{
get { return originZCoordinate; }
get { return yGridBlockSize; }
set
{
originZCoordinate = value;
yGridBlockSize = value;
OnPropertyChanged();
}
}

/// <summary>
/// * The grid block size in x dimension, used only for squared grids (10.0)
/// * The x coordinate of the upper right corner (0.0)
/// </summary>
[ProtoMember(9)]
public double XGridBlockSize
public double UpperRightCornerXCoordinate
{
get { return xGridBlockSize; }
get { return upperRightCornerXCoordinate; }
set
{
xGridBlockSize = value;
upperRightCornerXCoordinate = value;
OnPropertyChanged();
}
}

/// <summary>
/// * The grid block size in y dimension, used only for squared grids (10.0)
/// * The x coordinate of the upper right corner (0.0)
/// </summary>
[ProtoMember(10)]
public double YGridBlockSize
public double UpperRightCornerYCoordinate
{
get { return yGridBlockSize; }
get { return upperRightCornerYCoordinate; }
set
{
yGridBlockSize = value;
upperRightCornerYCoordinate = value;
OnPropertyChanged();
}
}
Expand Down
45 changes: 34 additions & 11 deletions MeshKernelNET/src/MeshKernelNETCore/Api/MeshRefinementParameters.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ProtoBuf;
using System.Xml.Linq;

namespace MeshKernelNETCore.Api
{
Expand All @@ -9,12 +10,16 @@ public static MeshRefinementParameters CreateDefault()
{
return new MeshRefinementParameters
{
MaxNumRefinementIterations = 3,
RefineIntersected = 0,
MaxNumRefinementIterations = 10,
RefineIntersected = false,
UseMassCenterWhenRefining = true,
MinEdgeSize = 0.5,
RefinementType = 2,
ConnectHangingNodes = 1,
UseMassCenterWhenRefining = 1,
MinFaceSize = 0.5
ConnectHangingNodes = true,
AccountForSamplesOutside = false,
SmoothingIterations = 5,
MaxCourantTime = 120.0,
DirectionalRefinement = false
};
}

Expand All @@ -28,19 +33,19 @@ public static MeshRefinementParameters CreateDefault()
/// Whether to compute faces intersected by polygon (yes=1/no=0)
/// </summary>
[ProtoMember(2)]
public int RefineIntersected { get; set; }
public bool RefineIntersected { get; set; }

/// <summary>
/// Whether to use the mass center when splitting a face in the refinement process (yes=1/no=0)
/// </summary>
[ProtoMember(3)]
public int UseMassCenterWhenRefining { get; set; }
public bool UseMassCenterWhenRefining { get; set; }

/// <summary>
/// Minimum cell size
/// Minimum edge size
/// </summary>
[ProtoMember(4)]
public double MinFaceSize { get; set; }
public double MinEdgeSize { get; set; }

/// <summary>
/// Refinement criterion type
Expand All @@ -52,12 +57,30 @@ public static MeshRefinementParameters CreateDefault()
/// Connect hanging nodes at the end of the iteration, 1 yes or 0 no
/// </summary>
[ProtoMember(6)]
public int ConnectHangingNodes { get; set; }
public bool ConnectHangingNodes { get; set; }

/// <summary>
/// Take samples outside face into account , 1 yes 0 no
/// </summary>
[ProtoMember(7)]
public int AccountForSamplesOutside { get; set; }
public bool AccountForSamplesOutside { get; set; }

/// <summary>
/// The number of smoothing iterations
/// </summary>
[ProtoMember(8)]
public int SmoothingIterations { get; set; }

/// <summary>
/// Maximum courant time in seconds
/// </summary>
[ProtoMember(9)]
public double MaxCourantTime { get; set; }

/// <summary>
/// Directional refinement, cannot be used when the number of smoothing iterations is larger than 0
/// </summary>
[ProtoMember(10)]
public bool DirectionalRefinement { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ public static OrthogonalizationParameters CreateDefault()
{
return new OrthogonalizationParameters
{
OuterIterations = 1,
OuterIterations = 2,
BoundaryIterations = 25,
InnerIterations = 25,
OrthogonalizationToSmoothingFactor = 0.975
OrthogonalizationToSmoothingFactor = 0.975,
OrthogonalizationToSmoothingFactorAtBoundary = 1.0,
ArealToAngleSmoothingFactor = 1.0,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ public static SplinesToCurvilinearParameters CreateDefault()
AspectRatio = 0.1,
AspectRatioGrowFactor = 1.1,
AverageWidth = 500.0,
CurvatureAdaptedGridSpacing = 1,
GrowGridOutside = 1,
CurvatureAdaptedGridSpacing = true,
GrowGridOutside = true,
MaximumNumberOfGridCellsInTheUniformPart = 5,
GridsOnTopOfEachOtherTolerance = 0.0001,
MinimumCosineOfCrossingAngles = 0.95,
CheckFrontCollisions = 0,
CheckFrontCollisions = false,
UniformGridSize = 0.0,
RemoveSkinnyTriangles = 1,
RemoveSkinnyTriangles = true,
};
}

Expand All @@ -45,13 +45,13 @@ public static SplinesToCurvilinearParameters CreateDefault()
/// * Curvature adapted grid spacing, 1 or not 0 (1)
/// </summary>
[ProtoMember(4)]
public int CurvatureAdaptedGridSpacing { get; set; }
public bool CurvatureAdaptedGridSpacing { get; set; }

/// <summary>
/// * Grow the grid outside the prescribed grid height (1)
/// </summary>
[ProtoMember(5)]
public int GrowGridOutside { get; set; }
public bool GrowGridOutside { get; set; }

/// <summary>
/// * Maximum number of layers in the uniform part (5)
Expand All @@ -75,7 +75,7 @@ public static SplinesToCurvilinearParameters CreateDefault()
/// * Check for collisions with other parts of the front, 1 or not 0 (0)
/// </summary>
[ProtoMember(9)]
public int CheckFrontCollisions { get; set; }
public bool CheckFrontCollisions { get; set; }

/// <summary>
/// * Uniform grid size, netboundary to grid only (0.0)
Expand All @@ -87,6 +87,6 @@ public static SplinesToCurvilinearParameters CreateDefault()
/// * Remove skinny triangles (1)
/// </summary>
[ProtoMember(11)]
public int RemoveSkinnyTriangles { get; set; }
public bool RemoveSkinnyTriangles { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ internal static OrthogonalizationParametersNative ToOrthogonalizationParametersN
OuterIterations = orthogonalizationParameters.OuterIterations,
BoundaryIterations = orthogonalizationParameters.BoundaryIterations,
InnerIterations = orthogonalizationParameters.InnerIterations,
OrthogonalizationToSmoothingFactor = 0.975,
OrthogonalizationToSmoothingFactorAtBoundary = 1,
ArealToAngleSmoothingFactor = 1.0
OrthogonalizationToSmoothingFactor = orthogonalizationParameters.OrthogonalizationToSmoothingFactor,
OrthogonalizationToSmoothingFactorAtBoundary = orthogonalizationParameters.OrthogonalizationToSmoothingFactorAtBoundary,
ArealToAngleSmoothingFactor = orthogonalizationParameters.ArealToAngleSmoothingFactor
};
}

Expand All @@ -31,11 +31,12 @@ internal static MakeGridParametersNative ToMakeGridParametersNative(this MakeGri
NumberOfColumns = makeGridParameters.NumberOfColumns,
NumberOfRows = makeGridParameters.NumberOfRows,
GridAngle = makeGridParameters.GridAngle,
GridBlockSize = makeGridParameters.GridBlockSize,
OriginXCoordinate = makeGridParameters.OriginXCoordinate,
OriginYCoordinate = makeGridParameters.OriginYCoordinate,
XGridBlockSize = makeGridParameters.XGridBlockSize,
YGridBlockSize = makeGridParameters.YGridBlockSize
YGridBlockSize = makeGridParameters.YGridBlockSize,
UpperRightCornerXCoordinate = makeGridParameters.UpperRightCornerXCoordinate,
UpperRightCornerYCoordinate = makeGridParameters.UpperRightCornerYCoordinate,
};
}

Expand All @@ -58,13 +59,13 @@ internal static SplinesToCurvilinearParametersNative ToSplinesToCurvilinearParam
AspectRatio = splinesToCurvilinearParameters.AspectRatio,
AspectRatioGrowFactor = splinesToCurvilinearParameters.AspectRatioGrowFactor,
AverageWidth = splinesToCurvilinearParameters.AverageWidth,
CurvatureAdapetedGridSpacing = splinesToCurvilinearParameters.CurvatureAdaptedGridSpacing,
GrowGridOutside = splinesToCurvilinearParameters.GrowGridOutside,
CurvatureAdaptedGridSpacing = Convert.ToInt32(splinesToCurvilinearParameters.CurvatureAdaptedGridSpacing),
GrowGridOutside = Convert.ToInt32(splinesToCurvilinearParameters.GrowGridOutside),
MaximumNumberOfGridCellsInTheUniformPart = splinesToCurvilinearParameters.MaximumNumberOfGridCellsInTheUniformPart,
GridsOnTopOfEachOtherTolerance = splinesToCurvilinearParameters.GridsOnTopOfEachOtherTolerance,
MinimumCosineOfCrossingAngles = splinesToCurvilinearParameters.MinimumCosineOfCrossingAngles,
CheckFrontCollisions = splinesToCurvilinearParameters.CheckFrontCollisions,
RemoveSkinnyTriangles = splinesToCurvilinearParameters.RemoveSkinnyTriangles
CheckFrontCollisions = Convert.ToInt32(splinesToCurvilinearParameters.CheckFrontCollisions),
RemoveSkinnyTriangles = Convert.ToInt32(splinesToCurvilinearParameters.RemoveSkinnyTriangles)
};
}

Expand All @@ -73,13 +74,15 @@ internal static MeshRefinementParametersNative ToMeshRefinementParametersNative(
return new MeshRefinementParametersNative
{
MaxNumRefinementIterations = meshRefinementParameters.MaxNumRefinementIterations,
RefineIntersected = meshRefinementParameters.RefineIntersected,
UseMassCenterWhenRefining = meshRefinementParameters.UseMassCenterWhenRefining,
MinFaceSize = meshRefinementParameters.MinFaceSize,
RefineIntersected = Convert.ToInt32(meshRefinementParameters.RefineIntersected),
UseMassCenterWhenRefining = Convert.ToInt32(meshRefinementParameters.UseMassCenterWhenRefining),
MinEdgeSize = meshRefinementParameters.MinEdgeSize,
RefinementType = meshRefinementParameters.RefinementType,
ConnectHangingNodes = meshRefinementParameters.ConnectHangingNodes,
AccountForSamplesOutside = meshRefinementParameters.AccountForSamplesOutside

ConnectHangingNodes = Convert.ToInt32(meshRefinementParameters.ConnectHangingNodes),
AccountForSamplesOutside = Convert.ToInt32(meshRefinementParameters.AccountForSamplesOutside),
SmoothingIterations = meshRefinementParameters.SmoothingIterations,
MaxCourantTime = meshRefinementParameters.MaxCourantTime,
DirectionalRefinement = Convert.ToInt32(meshRefinementParameters.DirectionalRefinement)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Deltares.MeshKernel" Version="1.0.0-dev.1358" />
<PackageReference Include="Deltares.MeshKernel" Version="1.0.0-dev.1798" />
<PackageReference Include="NetTopologySuite" Version="1.15.0" />
<PackageReference Include="protobuf-net" Version="2.4.6" />
</ItemGroup>
Expand Down
Loading