Skip to content

Commit 8698e5b

Browse files
committed
Merge branch 'feature/weiss27/mir' into feature/mir
2 parents d811ce0 + 557e910 commit 8698e5b

23 files changed

+1112
-594
lines changed

src/axom/core/tests/utils_utilities.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,34 @@ TEST(core_Utilities,minmax)
116116
EXPECT_EQ(a, axom::utilities::max(a,b));
117117
}
118118
}
119+
120+
TEST(core_Utilities, lerp)
121+
{
122+
std::cout<<"Testing linear interpolation (lerp) function."<< std::endl;
123+
124+
double f0 = 50.0;
125+
double f1 = 100.0;
126+
127+
// Test end points
128+
{
129+
EXPECT_DOUBLE_EQ( f0, axom::utilities::lerp(f0, f1, 0.) );
130+
EXPECT_DOUBLE_EQ( f1, axom::utilities::lerp(f1, f0, 0.) );
131+
132+
EXPECT_DOUBLE_EQ( f1, axom::utilities::lerp(f0, f1, 1.) );
133+
EXPECT_DOUBLE_EQ( f0, axom::utilities::lerp(f1, f0, 1.) );
134+
}
135+
136+
// Test midpoint
137+
{
138+
double t = 0.5;
139+
double exp = 75.;
140+
EXPECT_DOUBLE_EQ( exp, axom::utilities::lerp(f0, f1, t));
141+
}
142+
143+
// Another test
144+
{
145+
double t = 0.66;
146+
double exp = 83.;
147+
EXPECT_DOUBLE_EQ( exp, axom::utilities::lerp(f0, f1, t));
148+
}
149+
}

src/axom/core/utilities/Utilities.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ inline T log2( T& val)
9696
return std::log2(val);
9797
}
9898

99+
100+
/*!
101+
* \brief Linearly interpolates between two values
102+
* \param [in] val0 The first value
103+
* \param [in] val2 The second value
104+
* \param [in] t The interpolation parameter.
105+
* \return The interpolated value
106+
*/
107+
template < typename T >
108+
inline AXOM_HOST_DEVICE
109+
T lerp( T v0, T v1, T t)
110+
{
111+
constexpr T one = T(1);
112+
return (one-t)*v0 + t*v1;
113+
}
114+
99115
/*!
100116
* \brief Clamps an input value to a given range.
101117
* \param [in] val The value to clamp.
@@ -113,7 +129,6 @@ T clampVal( T val, T lower, T upper )
113129
: (val > upper) ? upper : val;
114130
}
115131

116-
117132
/*!
118133
* \brief Clamps the upper range on an input value
119134
*

src/axom/mainpage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Dependencies between components are as follows:
2121
- Slic optionally depends on Lumberjack
2222
- Slam, Primal, Mint, Quest, Spin, and Sidre depend on Slic
2323
- Mint optionally depends on Sidre
24-
- Mir depends on Slic
24+
- Mir depends on Slic, Slam and Primal
2525
- Spin depends on Primal and Slam
2626
- Quest depends on Slam, Primal, Spin, and Mint
2727

src/axom/mir/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Check necessary dependencies
1111
#------------------------------------------------------------------------------
1212
axom_component_requires(NAME MIR
13-
COMPONENTS SLIC)
13+
COMPONENTS SLIC SLAM PRIMAL)
1414

1515
#------------------------------------------------------------------------------
1616
# Specify all headers/sources
@@ -40,7 +40,7 @@ set(mir_sources
4040
#------------------------------------------------------------------------------
4141
# Build and install the library
4242
#------------------------------------------------------------------------------
43-
set(mir_depends_on core slic)
43+
set(mir_depends_on core slic slam)
4444

4545
blt_add_library(
4646
NAME mir
@@ -61,9 +61,6 @@ axom_install_component(NAME mir
6161
#------------------------------------------------------------------------------
6262
if (AXOM_ENABLE_TESTS)
6363
add_subdirectory(tests)
64-
if (ENABLE_BENCHMARKS)
65-
# add_subdirectory(benchmarks)
66-
endif()
6764
endif()
6865

6966
if (AXOM_ENABLE_EXAMPLES)

src/axom/mir/CellGenerator.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ void CellGenerator::generateVertexPositions(const mir::Shape shapeType,
9191
int vIDFrom = mir::utilities::getEdgeEndpoint(shapeType, vID, true);
9292
int vIDTo = mir::utilities::getEdgeEndpoint(shapeType, vID, false);
9393

94-
out_cellData.m_mapData.m_vertexPositions.push_back( mir::utilities::interpolateVertexPosition( vertexPositions[vIDFrom], vertexPositions[vIDTo], tValues[vID] ) );
94+
out_cellData.m_mapData.m_vertexPositions.push_back(
95+
mir::Point2::lerp( vertexPositions[vIDFrom], vertexPositions[vIDTo], tValues[vID] ) );
9596
}
9697
}
9798
}
@@ -123,7 +124,8 @@ void CellGenerator::generateVertexVolumeFractions(const mir::Shape shapeType,
123124
int vIDFrom = mir::utilities::getEdgeEndpoint(shapeType, vID, true);
124125
int vIDTo = mir::utilities::getEdgeEndpoint(shapeType, vID, false);
125126

126-
out_cellData.m_mapData.m_vertexVolumeFractions[matID].push_back( mir::utilities::lerpFloat( vertexVF[matID][vIDFrom], vertexVF[matID][vIDTo], tValues[vID] ) );
127+
out_cellData.m_mapData.m_vertexVolumeFractions[matID].push_back(
128+
axom::utilities::lerp( vertexVF[matID][vIDFrom], vertexVF[matID][vIDTo], tValues[vID] ) );
127129
}
128130
}
129131
}
@@ -215,4 +217,4 @@ mir::Shape CellGenerator::determineElementShapeType(const Shape parentShapeType
215217

216218

217219
}
218-
}
220+
}

src/axom/mir/InterfaceReconstructor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void InterfaceReconstructor::computeReconstructedInterface(mir::MIRMesh& inputMe
3939
for (int matID = 0; matID < m_originalMesh.m_numMaterials; ++matID)
4040
{
4141
// Copy the mesh to be split
42-
mir::MIRMesh intermediateMesh(&finalMesh);
42+
mir::MIRMesh intermediateMesh(finalMesh);
4343

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

273273
}
274-
}
274+
}

0 commit comments

Comments
 (0)