Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ Result<> ComputeGBCDMetricBased::operator()()
float64 misResolution = k_ResolutionChoices[m_InputValues->ChosenLimitDists][0];
float64 planeResolution = k_ResolutionChoices[m_InputValues->ChosenLimitDists][1];

misResolution *= nx::core::Constants::k_PiOver180F;
planeResolution *= nx::core::Constants::k_PiOver180F;
misResolution *= nx::core::Constants::k_PiOver180D;
planeResolution *= nx::core::Constants::k_PiOver180D;
const float64 planeResolutionSq = planeResolution * planeResolution;

auto& crystalStructures = m_DataStructure.getDataRefAs<UInt32Array>(m_InputValues->CrystalStructuresArrayPath);
Expand Down Expand Up @@ -455,7 +455,7 @@ Result<> ComputeGBCDMetricBased::operator()()
}

// Convert axis angle to matrix representation of mis orientation
auto gFixedAngle = m_InputValues->MisorientationRotation[3] * nx::core::Constants::k_PiOver180F;
auto gFixedAngle = m_InputValues->MisorientationRotation[3] * nx::core::Constants::k_PiOver180D;
Eigen::Vector3d gFixedAxis = {m_InputValues->MisorientationRotation[0], m_InputValues->MisorientationRotation[1], m_InputValues->MisorientationRotation[2]};
gFixedAxis.normalize();
auto oMatrix = ebsdlib::AxisAngleDType(gFixedAxis[0], gFixedAxis[1], gFixedAxis[2], gFixedAngle).toOrientationMatrix();
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/OrientationAnalysis/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ if(EXISTS "${DREAM3D_DATA_DIR}" AND SIMPLNX_DOWNLOAD_TEST_FILES)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME 12_IN625_GBCD.tar.gz SHA512 f696a8af181505947e6fecfdb1a11fda6c762bba5e85fea8d484b1af00bf18643e1d930d48f092ee238d1c19c9ce7c4fb5a8092d17774bda867961a1400e9cea)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME 6_5_h5ebsd_exemplar.tar.gz SHA512 9e5936b6e8e6fd51ecc7c17521ff29898bb0e8bc3d516741c47ae65577b4f2e0f3df8f485f19ecf93f1848b70aeeb98b91c2c5742965107acabeaa40182d898d)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME 6_6_ebsd_segment_features.tar.gz SHA512 acbb493a0668e0115ac49d4fedbbf7600759b9a66deb5d1004c2749a61d2bad2fcc60344bf72b2aeda5c8c098f458949dd1f8d58cb21682fa1393dfb7d0a1b84)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME 6_6_find_gbcd_metric_based.tar.gz SHA512 46032c758acc982eccaff38c3252a4f063b6ff5dc9ba3f33ed7f123c6f10771e1a2bdcbff8aab0fae7c91c03bb6025f49f0edbb085b3946b93b87980d31e4543)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME compute_gbcd_metric_based.tar.gz SHA512 fc326f260c42114031f2a914a0f21b60174b7215618c63db3ee4159ff5ed485b81d0f55d78de573344f1b24d35e95ce272686b3c2ad13cfdf0dd9f06f2e2d38d)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME 6_6_find_gbpd_metric_based.tar.gz SHA512 79c383024c926e97d647c609a866253a446bde41a6b821991bd9211789421a02ca8ec6253bc1bcca8e955169faed278d483b0ca129422ed1c24d756fb550f678)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME 6_6_ImportH5Data.tar.gz SHA512 68cf620d28a515d04040d66c4f8fa9d8d46707c65138b366b47f40d1d56a36c40e2e2cd0c9d35168b68c2cb5b2ce95650fa2a0d4e6ffce980d0dd0654908f40d)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME 6_6_read_ctf_data_2.tar.gz SHA512 f397fa3bf457615a90a4b48eaafded2aa4952b41ccb28d9da6a83adc38aea9c22f2bb5a955f251edeca9ef8265b6bf1d74e829b1340f45cf52620a237aad1707)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ TEST_CASE("OrientationAnalysis::ComputeGBCDMetricBasedFilter: Valid Filter Execu
{
UnitTest::LoadPlugins();

const nx::core::UnitTest::TestFileSentinel testDataSentinel(nx::core::unit_test::k_TestFilesDir, "6_6_find_gbcd_metric_based.tar.gz", "6_6_find_gbcd_metric_based");
const nx::core::UnitTest::TestFileSentinel testDataSentinel(nx::core::unit_test::k_TestFilesDir, "compute_gbcd_metric_based.tar.gz", "compute_gbcd_metric_based");

UnitTest::LoadPlugins();
const auto* filterListPtr = Application::Instance()->getFilterList();

// Read Exemplar DREAM3D File Input
auto exemplarInputFilePath = fs::path(fmt::format("{}/6_6_find_gbcd_metric_based/6_6_find_gbcd_metric_based.dream3d", unit_test::k_TestFilesDir));
auto exemplarInputFilePath = fs::path(fmt::format("{}/compute_gbcd_metric_based/compute_gbcd_metric_based.dream3d", unit_test::k_TestFilesDir));
DataStructure dataStructure = UnitTest::LoadDataStructure(exemplarInputFilePath);

const fs::path exemplarDistOutput(fmt::format("{}/6_6_find_gbcd_metric_based/6_6_gbcd_distribution_1.dat", unit_test::k_TestFilesDir));
const fs::path exemplarErrorsOutput(fmt::format("{}/6_6_find_gbcd_metric_based/6_6_gbcd_distribution_errors_1.dat", unit_test::k_TestFilesDir));
const fs::path computedDistOutput(fmt::format("{}/6_6_find_gbcd_metric_based/7_0_computed_gbcd_distribution_1.dat", unit_test::k_TestFilesDir));
const fs::path computedErrorsOutput(fmt::format("{}/6_6_find_gbcd_metric_based/7_0_computed_gbcd_distribution_errors_1.dat", unit_test::k_TestFilesDir));
const fs::path exemplarDistOutput(fmt::format("{}/compute_gbcd_metric_based/gbcd_distribution_1.dat", unit_test::k_TestFilesDir));
const fs::path exemplarErrorsOutput(fmt::format("{}/compute_gbcd_metric_based/gbcd_distribution_errors_1.dat", unit_test::k_TestFilesDir));
const fs::path computedDistOutput(fmt::format("{}/compute_gbcd_metric_based/7_0_computed_gbcd_distribution_1.dat", unit_test::k_TestFilesDir));
const fs::path computedErrorsOutput(fmt::format("{}/compute_gbcd_metric_based/7_0_computed_gbcd_distribution_errors_1.dat", unit_test::k_TestFilesDir));

// Run the ComputeGBCDMetricBased filter
{
Expand Down Expand Up @@ -171,10 +171,10 @@ TEST_CASE("OrientationAnalysis::ComputeGBCDMetricBasedFilter: InValid Filter Exe
{
UnitTest::LoadPlugins();

const nx::core::UnitTest::TestFileSentinel testDataSentinel(nx::core::unit_test::k_TestFilesDir, "6_6_find_gbcd_metric_based.tar.gz", "6_6_find_gbcd_metric_based");
const nx::core::UnitTest::TestFileSentinel testDataSentinel(nx::core::unit_test::k_TestFilesDir, "compute_gbcd_metric_based.tar.gz", "compute_gbcd_metric_based");

// Read Exemplar DREAM3D File Input
auto exemplarInputFilePath = fs::path(fmt::format("{}/6_6_find_gbcd_metric_based/6_6_find_gbcd_metric_based.dream3d", unit_test::k_TestFilesDir));
auto exemplarInputFilePath = fs::path(fmt::format("{}/compute_gbcd_metric_based/compute_gbcd_metric_based.dream3d", unit_test::k_TestFilesDir));
DataStructure dataStructure = UnitTest::LoadDataStructure(exemplarInputFilePath);

const fs::path computedDistOutput(fmt::format("{}/computed_gbcd_distribution_1.dat", unit_test::k_BinaryTestOutputDir));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ TEST_CASE("OrientationAnalysis::ComputeGBPDMetricBasedFilter: InValid Filter Exe
{
UnitTest::LoadPlugins();

const nx::core::UnitTest::TestFileSentinel testDataSentinel(nx::core::unit_test::k_TestFilesDir, "6_6_find_gbcd_metric_based.tar.gz", "6_6_find_gbcd_metric_based");
const nx::core::UnitTest::TestFileSentinel testDataSentinel(nx::core::unit_test::k_TestFilesDir, "compute_gbcd_metric_based.tar.gz", "compute_gbcd_metric_based");

// Read Exemplar DREAM3D File Input
auto exemplarInputFilePath = fs::path(fmt::format("{}/6_6_find_gbcd_metric_based/6_6_find_gbcd_metric_based.dream3d", unit_test::k_TestFilesDir));
auto exemplarInputFilePath = fs::path(fmt::format("{}/compute_gbcd_metric_based/compute_gbcd_metric_based.dream3d", unit_test::k_TestFilesDir));
DataStructure dataStructure = UnitTest::LoadDataStructure(exemplarInputFilePath);

fs::path computedDistOutput(fmt::format("{}/computed_gbcd_distribution_1.dat", unit_test::k_BinaryTestOutputDir));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <unordered_map>
#include <utility>
Expand All @@ -39,22 +38,10 @@ using SpMat = Eigen::SparseMatrix<double>;
using Triplet = Eigen::Triplet<double>;
using Smoother = Eigen::ConjugateGradient<SpMat, Eigen::Upper | Eigen::Lower>;

constexpr std::size_t k_CircShift = sizeof(std::size_t) * 4;

struct EdgePairHash
{
std::size_t operator()(const EdgePair& ep) const
{
return std::hash<std::size_t>{}(static_cast<std::size_t>(ep.first) << k_CircShift | static_cast<std::size_t>(ep.second));
}
};

template <typename T>
using EdgeDict = std::unordered_map<EdgePair, T, EdgePairHash>;

// Use std::map for the boundary dictionary to ensure deterministic iteration order.
// The algorithm is hierarchical: earlier boundary results affect later ones,
// so deterministic ordering is required for reproducible results.
// Use std::map for the edge/boundary dictionaries to ensure deterministic iteration
// order across platforms and STL implementations (libc++ vs libstdc++). The algorithm
// is hierarchical and its boundary/free-boundary traversal order is result-affecting,
// so a hash-ordered container would produce non-reproducible cross-platform output.
template <typename T>
using OrderedEdgeDict = std::map<EdgePair, T>;

Expand Down Expand Up @@ -300,7 +287,10 @@ class Triangulation
EdgeList m_FreeBoundary;
EdgeList m_FreeBoundarySegments;
std::vector<int> m_Unique;
EdgeDict<EdgeCount> m_Dict;
// Ordered (std::map) so freeBoundary iteration order is identical across platforms/STL
// implementations. m_Dict order feeds the freeBoundary sequence -> chain-link/segment
// assignment, so a hash-ordered map (libc++ vs libstdc++) caused cross-platform divergence.
OrderedEdgeDict<EdgeCount> m_Dict;
std::vector<double> m_DiagCount;

void differentiateFaces()
Expand Down Expand Up @@ -545,9 +535,14 @@ meshnode smooth(const meshnode& nodesIn, const matindex& nFixed, SpMat& gl, doub
double fobj2 = getObjFn(smth, fEps + fThresh, fSmallEye, ltl, ltk, nMobile, yMobile, d, ayIn, yOut);
double fslope = (fobj2 - fobj1) / fThresh;

while(std::fabs(fslope) < fThresh && nCount < nIter)
// Adaptive bisection over the smoothing parameter fEps, matching the reference
// MATLAB/Python implementation (Smooth.m / HierarchicalSmooth.py):
// - iterate while the objective slope is still steep (|fslope| > fThresh)
// - step fEps in the direction given by the sign of the slope
// - halve the step each iteration (true bisection)
while(std::fabs(fslope) > fThresh && nCount < nIter)
{
if(fStep > 0.0)
if(fslope > 0.0)
{
fEps -= fStep;
}
Expand All @@ -556,7 +551,7 @@ meshnode smooth(const meshnode& nodesIn, const matindex& nFixed, SpMat& gl, doub
fEps += fStep;
}

fEps /= 2.0;
fStep /= 2.0;
fobj1 = getObjFn(smth, fEps, fSmallEye, ltl, ltk, nMobile, yMobile, d, ayIn, yOut);
fobj2 = getObjFn(smth, fEps + fThresh, fSmallEye, ltl, ltk, nMobile, yMobile, d, ayIn, yOut);
fslope = (fobj2 - fobj1) / fThresh;
Expand Down
1 change: 0 additions & 1 deletion src/Plugins/SimplnxCore/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ if(EXISTS "${DREAM3D_DATA_DIR}" AND SIMPLNX_DOWNLOAD_TEST_FILES)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME write_lammps_test.tar.gz SHA512 82bb5360b76e857f3233d37733c602f67fd2ac667e49b24741a70ab649e8046fb7905493df37d142808b740c2771fe7cdccd71c9d70679afafe398529ee5771e)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME write_stl_overflow_test.tar.gz SHA512 d8f8eac901479100ffb5813b3ac72c86da496d3620d406f8691adc0d95eb4670bf4e887f57ccc702bac7e6eeaffdf61db9b4c06157423845dd198722870b0c0b)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME compute_grouping_densities_v2.tar.gz SHA512 3aaabb63c4fa16f7fa192ae4ee9dbba9394ec7f1cd19aff55e399a624d495a3a778c7f6f282911f681e85cea99e4c6d15344274e9107f337af7d4a19f93784ff)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME hierarchical_smoothing.tar.gz SHA512 47217ee420d9438c3d36a195c06ae060917f5fb7ee295feffdabf05741bec87bf29c3b44016b744930cda7383cd05e0d58df7e7776a7732dc46c12b780e51398)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME identify_sample_v2.tar.gz SHA512 a7ffac3eaad479c07215c1dd16274c45a52466708a9d27b5f85a29b0eba3b6705b627e1052a7a27e9bfe89cd6e7df673beb7a1e98b262b6c52ea383b4848ac31)

endif()
Expand Down
Loading
Loading