Skip to content

Commit

Permalink
Merge branch 'feature/weiss27/mir' into feature/mir
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyweiss committed Jul 9, 2019
2 parents d811ce0 + 557e910 commit 8698e5b
Show file tree
Hide file tree
Showing 23 changed files with 1,112 additions and 594 deletions.
31 changes: 31 additions & 0 deletions src/axom/core/tests/utils_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,34 @@ TEST(core_Utilities,minmax)
EXPECT_EQ(a, axom::utilities::max(a,b));
}
}

TEST(core_Utilities, lerp)
{
std::cout<<"Testing linear interpolation (lerp) function."<< std::endl;

double f0 = 50.0;
double f1 = 100.0;

// Test end points
{
EXPECT_DOUBLE_EQ( f0, axom::utilities::lerp(f0, f1, 0.) );
EXPECT_DOUBLE_EQ( f1, axom::utilities::lerp(f1, f0, 0.) );

EXPECT_DOUBLE_EQ( f1, axom::utilities::lerp(f0, f1, 1.) );
EXPECT_DOUBLE_EQ( f0, axom::utilities::lerp(f1, f0, 1.) );
}

// Test midpoint
{
double t = 0.5;
double exp = 75.;
EXPECT_DOUBLE_EQ( exp, axom::utilities::lerp(f0, f1, t));
}

// Another test
{
double t = 0.66;
double exp = 83.;
EXPECT_DOUBLE_EQ( exp, axom::utilities::lerp(f0, f1, t));
}
}
17 changes: 16 additions & 1 deletion src/axom/core/utilities/Utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ inline T log2( T& val)
return std::log2(val);
}


/*!
* \brief Linearly interpolates between two values
* \param [in] val0 The first value
* \param [in] val2 The second value
* \param [in] t The interpolation parameter.
* \return The interpolated value
*/
template < typename T >
inline AXOM_HOST_DEVICE
T lerp( T v0, T v1, T t)
{
constexpr T one = T(1);
return (one-t)*v0 + t*v1;
}

/*!
* \brief Clamps an input value to a given range.
* \param [in] val The value to clamp.
Expand All @@ -113,7 +129,6 @@ T clampVal( T val, T lower, T upper )
: (val > upper) ? upper : val;
}


/*!
* \brief Clamps the upper range on an input value
*
Expand Down
2 changes: 1 addition & 1 deletion src/axom/mainpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Dependencies between components are as follows:
- Slic optionally depends on Lumberjack
- Slam, Primal, Mint, Quest, Spin, and Sidre depend on Slic
- Mint optionally depends on Sidre
- Mir depends on Slic
- Mir depends on Slic, Slam and Primal
- Spin depends on Primal and Slam
- Quest depends on Slam, Primal, Spin, and Mint

Expand Down
7 changes: 2 additions & 5 deletions src/axom/mir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Check necessary dependencies
#------------------------------------------------------------------------------
axom_component_requires(NAME MIR
COMPONENTS SLIC)
COMPONENTS SLIC SLAM PRIMAL)

#------------------------------------------------------------------------------
# Specify all headers/sources
Expand Down Expand Up @@ -40,7 +40,7 @@ set(mir_sources
#------------------------------------------------------------------------------
# Build and install the library
#------------------------------------------------------------------------------
set(mir_depends_on core slic)
set(mir_depends_on core slic slam)

blt_add_library(
NAME mir
Expand All @@ -61,9 +61,6 @@ axom_install_component(NAME mir
#------------------------------------------------------------------------------
if (AXOM_ENABLE_TESTS)
add_subdirectory(tests)
if (ENABLE_BENCHMARKS)
# add_subdirectory(benchmarks)
endif()
endif()

if (AXOM_ENABLE_EXAMPLES)
Expand Down
8 changes: 5 additions & 3 deletions src/axom/mir/CellGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ void CellGenerator::generateVertexPositions(const mir::Shape shapeType,
int vIDFrom = mir::utilities::getEdgeEndpoint(shapeType, vID, true);
int vIDTo = mir::utilities::getEdgeEndpoint(shapeType, vID, false);

out_cellData.m_mapData.m_vertexPositions.push_back( mir::utilities::interpolateVertexPosition( vertexPositions[vIDFrom], vertexPositions[vIDTo], tValues[vID] ) );
out_cellData.m_mapData.m_vertexPositions.push_back(
mir::Point2::lerp( vertexPositions[vIDFrom], vertexPositions[vIDTo], tValues[vID] ) );
}
}
}
Expand Down Expand Up @@ -123,7 +124,8 @@ void CellGenerator::generateVertexVolumeFractions(const mir::Shape shapeType,
int vIDFrom = mir::utilities::getEdgeEndpoint(shapeType, vID, true);
int vIDTo = mir::utilities::getEdgeEndpoint(shapeType, vID, false);

out_cellData.m_mapData.m_vertexVolumeFractions[matID].push_back( mir::utilities::lerpFloat( vertexVF[matID][vIDFrom], vertexVF[matID][vIDTo], tValues[vID] ) );
out_cellData.m_mapData.m_vertexVolumeFractions[matID].push_back(
axom::utilities::lerp( vertexVF[matID][vIDFrom], vertexVF[matID][vIDTo], tValues[vID] ) );
}
}
}
Expand Down Expand Up @@ -215,4 +217,4 @@ mir::Shape CellGenerator::determineElementShapeType(const Shape parentShapeType


}
}
}
4 changes: 2 additions & 2 deletions src/axom/mir/InterfaceReconstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void InterfaceReconstructor::computeReconstructedInterface(mir::MIRMesh& inputMe
for (int matID = 0; matID < m_originalMesh.m_numMaterials; ++matID)
{
// Copy the mesh to be split
mir::MIRMesh intermediateMesh(&finalMesh);
mir::MIRMesh intermediateMesh(finalMesh);

// Create an array to store the output of each element being split.
CellData temp_cellData[intermediateMesh.m_elems.size()];
Expand Down Expand Up @@ -271,4 +271,4 @@ void InterfaceReconstructor::generateCleanCells(const int eID,
//--------------------------------------------------------------------------------

}
}
}
Loading

0 comments on commit 8698e5b

Please sign in to comment.