Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build-and-test-feature-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
fail-fast: false
matrix:
platform:
- macos-13 # x86_64 (free)
- macos-14 # arm64 (free)
build_type:
- Release
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/build-and-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jobs:
fail-fast: false
matrix:
platform:
- macos-13 # x86_64 (free)
- macos-13-xlarge # arm64 (billable)
- macos-14 # arm64 (free)
build_type:
- Release
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:

# Step: Restore cached user-provided dependencies
- name: Restore cached user-provided dependencies
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
id: restore-cached-external-dependencies
with:
key: ${{ inputs.platform }}-${{ inputs.build_type }}-cache-key
Expand All @@ -77,7 +77,7 @@ jobs:

# Step: Cache user-provided dependencies, executes only if no cache restored
- name: Cache user-provided dependencies
uses: actions/cache/save@v3
uses: actions/cache/save@v4
if: steps.restore-cached-external-dependencies.outputs.cache-hit != 'true'
with:
key: ${{ inputs.platform }}-${{ inputs.build_type }}-cache-key
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include(cmake/options.cmake)
include(cmake/compiler_config.cmake)

# fetch dependencies, must appear after options.cmake
include(cmake/fetch_content.cmake)
include(cmake/fetch_contents.cmake)

# organize targets into folders, can be remove in version > 3.26 (ON by default)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Expand Down
File renamed without changes.
36 changes: 36 additions & 0 deletions cmake/find_packages.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# zlib
if(WIN32)
# Set the path to the shared library
if(DEFINED ENV{ZLIB_ROOT})
message(VERBOSE "ZLIB_ROOT is an env var")
set(ZLIB_LIBRARY_PATH "$ENV{ZLIB_ROOT}")
elseif(DEFINED ZLIB_ROOT)
message(VERBOSE "ZLIB_ROOT is a config option")
set(ZLIB_LIBRARY_PATH "${ZLIB_ROOT}")
else()
message(FATAL_ERROR "ZLIB_ROOT is undefined")
endif()
set(ZLIB_LIBRARY "${ZLIB_LIBRARY_PATH}/bin/zlib.dll")
endif()
find_package(ZLIB REQUIRED)
if (ZLIB_FOUND)
message(STATUS "Found ZLIB ${ZLIB_VERSION}")
else()
message(FATAL_ERROR "Could not find ZLIB")
endif()

check_runtime_dependency(ZLIB::ZLIB UNKNOWN_LIBRARY)

set(
THIRD_PARTY_RUNTIME_DEPS
$<TARGET_FILE:ZLIB::ZLIB> # not an element of TARGET_RUNTIME_DLLS, helaas speculaas
CACHE STRING "Third-party runtime dependencies" FORCE
)

# cache all runtime dependencies
set(
ALL_RUNTIME_DEPS
${THIRD_PARTY_RUNTIME_DEPS}
$<TARGET_FILE:UGridCSharpWrapper>
CACHE STRING "All runtime dependencies" FORCE
)
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,33 @@ namespace meshkernel
for (UInt n = 0; n < numNodes; ++n)
{
const auto node = m_mesh.Node(n);
m_nodeResults[n] = Interpolation(node);

if (node.IsValid())
{
m_nodeResults[n] = Interpolation(node);
}
}

m_edgeResults.resize(numEdges);
std::ranges::fill(m_edgeResults, constants::missing::doubleValue);
for (UInt e = 0; e < numEdges; ++e)
{
const auto& [first, second] = m_mesh.GetEdge(e);
m_edgeResults[e] = 0.5 * (m_nodeResults[first] + m_nodeResults[second]);

if (first != constants::missing::uintValue && second != constants::missing::uintValue)
{
m_edgeResults[e] = 0.5 * (m_nodeResults[first] + m_nodeResults[second]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible either the first or the second noderesult is missing::doubleValue, either because Interpolation returned missing::doubleValue or because a node is invalid. In that case edgeResult should also be missing::doubleValue, I suppose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The m_edgeResults is filled with missing::doubleValue just before the loop (line 162)

}
}

m_faceResults.resize(numFaces, constants::missing::doubleValue);
std::ranges::fill(m_faceResults, constants::missing::doubleValue);
for (UInt f = 0; f < numFaces; ++f)
{
m_faceResults[f] = Interpolation(m_mesh.m_facesMassCenters[f]);
if (m_mesh.m_facesMassCenters[f].IsValid())
{
m_faceResults[f] = Interpolation(m_mesh.m_facesMassCenters[f]);
}
}
}

Expand Down
55 changes: 55 additions & 0 deletions libs/MeshKernelApi/tests/src/Mesh2DRefinmentTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1324,3 +1324,58 @@ TEST(MeshRefinement, SplitAlongRow_FailureTests)
errorCode = meshkernelapi::mkernel_mesh2d_split_row(meshKernelId, node1, node2);
ASSERT_EQ(meshkernel::ExitCode::ConstraintErrorCode, errorCode);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test here that demonstrates that an Interpolation returning missing::doubleValue produces a missing::doubleValue edge-result.

TEST(MeshRefinement, Mesh2DWithHoleRefineBasedOnGriddedSamplesWaveCourant_WithGriddedSamples_ShouldRefineMesh)
{
int meshKernelId = -1;
int errorCode = -1;

constexpr int isSpherical = 1;

meshkernelapi::mkernel_allocate_state(isSpherical, meshKernelId);

meshkernel::MakeGridParameters gridParameters;
gridParameters.origin_x = 99.0;
gridParameters.origin_y = -7.0;
gridParameters.block_size_x = 0.4;
gridParameters.block_size_y = 0.4;
gridParameters.upper_right_x = 114.0;
gridParameters.upper_right_y = 13.5;

errorCode = meshkernelapi::mkernel_curvilinear_compute_rectangular_grid_on_extension(meshKernelId, gridParameters);
ASSERT_EQ(meshkernel::ExitCode::Success, errorCode);
errorCode = meshkernelapi::mkernel_curvilinear_convert_to_mesh2d(meshKernelId);
ASSERT_EQ(meshkernel::ExitCode::Success, errorCode);

std::vector<double> pxs{98.0, 107.5, 98.0, 98};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment hat this part cuts a hole

std::vector<double> pys{2.5, -7.5, -7.5, 2.5};
meshkernelapi::GeometryList polygon{};
polygon.coordinates_x = pxs.data();
polygon.coordinates_y = pys.data();
polygon.num_coordinates = static_cast<int>(pxs.size());
errorCode = mkernel_mesh2d_delete(meshKernelId, polygon, 0, 0);
ASSERT_EQ(meshkernel::ExitCode::Success, errorCode);

std::vector<double> sampleDataXs{99.0, 114.0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next 4 blocks can be one block, with a comment about creating samples for refinement

std::vector<double> sampleDataYs{-7.0, 13.5};
std::vector<double> sampleDataValues{-9999.0, -9999.0, -9999.0, -9999.0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is some magic number?


meshkernelapi::GriddedSamples sampleData;

sampleData.num_x = static_cast<int>(sampleDataXs.size());
sampleData.num_y = static_cast<int>(sampleDataYs.size());

sampleData.x_coordinates = sampleDataXs.data();
sampleData.y_coordinates = sampleDataYs.data();
sampleData.values = sampleDataValues.data();

meshkernel::MeshRefinementParameters meshRefinementParameters;
meshRefinementParameters.min_edge_size = 1250.0;
meshRefinementParameters.refinement_type = 1; // WAVE_COURANT?
meshRefinementParameters.smoothing_iterations = 2;

meshkernelapi::GeometryList refPolygon{};

errorCode = mkernel_mesh2d_refine_based_on_gridded_samples(meshKernelId, refPolygon, sampleData, meshRefinementParameters, true);
ASSERT_EQ(meshkernel::ExitCode::Success, errorCode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this also assert some actual refinement result? Otherwise it's not tested anywhere that the algorithm actually works, or is that tested somewhere else?

}
Loading