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
3 changes: 2 additions & 1 deletion src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ if( MFEM_FOUND )

set(mfem_smoke_depends mfem gtest)
# MFEM's openmp dependency isn't being picked up by FindMFEM.cmake. Force it to be added for now.
blt_list_append(TO mfem_smoke_depends ELEMENTS blt::openmp IF ENABLE_OPENMP )
blt_list_append(TO mfem_smoke_depends ELEMENTS blt::openmp IF TRIBOL_USE_OPENMP )
blt_list_append(TO mfem_smoke_depends ELEMENTS blt::mpi IF TRIBOL_USE_MPI )
blt_add_executable(
NAME mfem_smoke_test
SOURCES mfem_smoke.cpp
Expand Down
6 changes: 3 additions & 3 deletions src/tests/tribol_mfem_jacobian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ TEST_F( MfemJacobianTest, jacobian_primary_dual_assembles_in_ho_and_lor )
EXPECT_EQ( mat->Height(), ctx.mesh_data->GetParentCoords().ParFESpace()->GetTrueVSize() );
EXPECT_EQ( mat->Width(), ctx.submesh_data->GetSubmeshFESpace().GetTrueVSize() );

const int local_pairs = contributions[0].row_elem_ids.size();
int local_pairs = contributions[0].row_elem_ids.size();
int global_pairs = 0;
MPI_Allreduce( &local_pairs, &global_pairs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
if ( global_pairs > 0 ) {
Expand Down Expand Up @@ -724,7 +724,7 @@ TEST_F( MfemJacobianTest, jacobian_dual_primary_assembles_in_ho_and_lor )
EXPECT_EQ( mat->Height(), ctx.submesh_data->GetSubmeshFESpace().GetTrueVSize() );
EXPECT_EQ( mat->Width(), ctx.mesh_data->GetParentCoords().ParFESpace()->GetTrueVSize() );

const int local_pairs = contributions[0].row_elem_ids.size();
int local_pairs = contributions[0].row_elem_ids.size();
int global_pairs = 0;
MPI_Allreduce( &local_pairs, &global_pairs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
if ( global_pairs > 0 ) {
Expand Down Expand Up @@ -795,7 +795,7 @@ TEST_F( MfemJacobianTest, jacobian_primary_primary_aggregates_mortar_and_nonmort
expected += AssembleSolverBlockJacobian( ctx, { nm }, SolverBlock::Primary, SolverBlock::Primary );
expected += AssembleSolverBlockJacobian( ctx, { nn }, SolverBlock::Primary, SolverBlock::Primary );

const int local_pairs =
int local_pairs =
mm.row_elem_ids.size() + mn.row_elem_ids.size() + nm.row_elem_ids.size() + nn.row_elem_ids.size();
int global_pairs = 0;
MPI_Allreduce( &local_pairs, &global_pairs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
Expand Down
156 changes: 83 additions & 73 deletions src/tribol/geom/CompGeom.hpp

Large diffs are not rendered by default.

38 changes: 21 additions & 17 deletions src/tribol/geom/GeomUtilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <float.h>
#include <cmath>
#include <limits>

#include "axom/slic.hpp"

Expand Down Expand Up @@ -54,7 +55,7 @@ TRIBOL_HOST_DEVICE inline void ComputeLocalBasis( RealT nx, RealT ny, RealT nz,
*
* \pre length(pX), length(pY), length(pZ) >= number of nodes on face
*/
TRIBOL_HOST_DEVICE inline void ProjectFaceNodesToPlane( const MeshData::Viewer& mesh, int faceId, RealT nrmlX,
TRIBOL_HOST_DEVICE inline void ProjectFaceNodesToPlane( const MeshData::Viewer& mesh, IndexT faceId, RealT nrmlX,
RealT nrmlY, RealT nrmlZ, RealT cX, RealT cY, RealT cZ,
RealT* pX, RealT* pY, RealT* pZ );

Expand All @@ -72,7 +73,7 @@ TRIBOL_HOST_DEVICE inline void ProjectFaceNodesToPlane( const MeshData::Viewer&
* \param [out] pY pointer to array of projected nodal y-coordinates
*
*/
TRIBOL_HOST_DEVICE inline void ProjectEdgeNodesToSegment( const MeshData::Viewer& mesh, int edgeId, RealT nrmlX,
TRIBOL_HOST_DEVICE inline void ProjectEdgeNodesToSegment( const MeshData::Viewer& mesh, IndexT edgeId, RealT nrmlX,
RealT nrmlY, RealT cX, RealT cY, RealT* pX, RealT* pY );

/*!
Expand Down Expand Up @@ -1869,14 +1870,14 @@ TRIBOL_HOST_DEVICE inline void ComputeLocalBasis( RealT nx, RealT ny, RealT nz,
}

//------------------------------------------------------------------------------
TRIBOL_HOST_DEVICE inline void ProjectFaceNodesToPlane( const MeshData::Viewer& mesh, int faceId, RealT nrmlX,
TRIBOL_HOST_DEVICE inline void ProjectFaceNodesToPlane( const MeshData::Viewer& mesh, IndexT faceId, RealT nrmlX,
RealT nrmlY, RealT nrmlZ, RealT cX, RealT cY, RealT cZ,
RealT* pX, RealT* pY, RealT* pZ )
{
// loop over nodes and project onto the plane defined by the point-normal
// input arguments
for ( int i = 0; i < mesh.numberOfNodesPerElement(); ++i ) {
const int nodeId = mesh.getGlobalNodeId( faceId, i );
const IndexT nodeId = mesh.getGlobalNodeId( faceId, i );
ProjectPointToPlane( mesh.getPosition()[0][nodeId], mesh.getPosition()[1][nodeId], mesh.getPosition()[2][nodeId],
nrmlX, nrmlY, nrmlZ, cX, cY, cZ, pX[i], pY[i], pZ[i] );
}
Expand All @@ -1886,11 +1887,11 @@ TRIBOL_HOST_DEVICE inline void ProjectFaceNodesToPlane( const MeshData::Viewer&
} // end ProjectFaceNodesToPlane()

//------------------------------------------------------------------------------
TRIBOL_HOST_DEVICE inline void ProjectEdgeNodesToSegment( const MeshData::Viewer& mesh, int edgeId, RealT nrmlX,
TRIBOL_HOST_DEVICE inline void ProjectEdgeNodesToSegment( const MeshData::Viewer& mesh, IndexT edgeId, RealT nrmlX,
RealT nrmlY, RealT cX, RealT cY, RealT* pX, RealT* pY )
{
for ( int i = 0; i < mesh.numberOfNodesPerElement(); ++i ) {
const int nodeId = mesh.getGlobalNodeId( edgeId, i );
const IndexT nodeId = mesh.getGlobalNodeId( edgeId, i );
ProjectPointToSegment( mesh.getPosition()[0][nodeId], mesh.getPosition()[1][nodeId], nrmlX, nrmlY, cX, cY, pX[i],
pY[i] );
}
Expand Down Expand Up @@ -1960,17 +1961,20 @@ TRIBOL_HOST_DEVICE inline void PolyInterYCentroid( const int namax, const RealT*
RealT vol;

// calculate origin shift to avoid roundoff errors
// TODO figure out numeric limits associated with RealT that also works on device
RealT xorg = FLT_MAX;
RealT yorg = FLT_MAX;
RealT xa_min = FLT_MAX;
RealT xa_max = -FLT_MAX;
RealT ya_min = FLT_MAX;
RealT ya_max = -FLT_MAX;
RealT xb_min = FLT_MAX;
RealT xb_max = -FLT_MAX;
RealT yb_min = FLT_MAX;
RealT yb_max = -FLT_MAX;
RealT realt_max = std::numeric_limits<RealT>::max();

// clang-format off
RealT xorg = realt_max;
RealT yorg = realt_max;
RealT xa_min = realt_max;
RealT xa_max = -realt_max;
RealT ya_min = realt_max;
RealT ya_max = -realt_max;
RealT xb_min = realt_max;
RealT xb_max = -realt_max;
RealT yb_min = realt_max;
RealT yb_max = -realt_max;
// clang-format on

RealT qy = 0.0;

Expand Down
24 changes: 12 additions & 12 deletions src/tribol/mesh/CouplingScheme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class CouplingScheme {
*
* @return spatial dimension
*/
TRIBOL_HOST_DEVICE int spatialDimension() const { return m_mesh1.spatialDimension(); }
TRIBOL_HOST_DEVICE int spatialDimension() const { return static_cast<int>( m_mesh1.spatialDimension() ); }

/**
* @brief Return a view of the first mesh in the coupling scheme
Expand Down Expand Up @@ -192,7 +192,7 @@ class CouplingScheme {
*
* @return the gap tolerance for the common plane method
*/
TRIBOL_HOST_DEVICE inline RealT getGapTol( int fid1, int fid2 ) const;
TRIBOL_HOST_DEVICE inline RealT getGapTol( IndexT fid1, IndexT fid2 ) const;

/**
* @brief Get a view of the computational geometry container
Expand Down Expand Up @@ -284,21 +284,21 @@ class CouplingScheme {
*
* @return unique coupling scheme ID
*/
int getId() const { return m_id; }
IndexT getId() const { return m_id; }

/**
* @brief Get the integer ID of the first mesh
*
* @return unique ID of the first mesh
*/
int getMeshId1() const { return m_mesh_id1; }
IndexT getMeshId1() const { return m_mesh_id1; }

/**
* @brief Get the integer ID of the second mesh
*
* @return unique ID of the second mesh
*/
int getMeshId2() const { return m_mesh_id2; }
IndexT getMeshId2() const { return m_mesh_id2; }

/**
* @brief Get the Parameters struct
Expand Down Expand Up @@ -513,7 +513,7 @@ class CouplingScheme {
*
* @return number of active interface pairs
*/
int getNumActivePairs() const { return m_cg_pairs.getNumActivePairs( getContactMethod() ); }
IndexT getNumActivePairs() const { return m_cg_pairs.getNumActivePairs( getContactMethod() ); }

/**
* @brief Return the contact plane given by id
Expand Down Expand Up @@ -1009,7 +1009,7 @@ TRIBOL_HOST_DEVICE inline ContactPlanePair& CouplingScheme::Viewer::getContactPl
}

//------------------------------------------------------------------------------
TRIBOL_HOST_DEVICE inline RealT CouplingScheme::Viewer::getGapTol( int fid1, int fid2 ) const
TRIBOL_HOST_DEVICE inline RealT CouplingScheme::Viewer::getGapTol( IndexT fid1, IndexT fid2 ) const
{
RealT gap_tol = 0.;
// add debug warning if this routine is called for interface methods
Expand Down Expand Up @@ -1072,9 +1072,9 @@ TRIBOL_HOST_DEVICE inline bool CouplingScheme::Viewer::pruneMethodFacePair( cons

auto& mesh1 = this->getMesh1View();
auto& mesh2 = this->getMesh2View();
int dim = mesh1.spatialDimension();
int num_nodes_face_1 = mesh1.numberOfNodesPerElement();
int num_nodes_face_2 = mesh2.numberOfNodesPerElement();
int dim = static_cast<int>( mesh1.spatialDimension() );
int num_nodes_face_1 = static_cast<int>( mesh1.numberOfNodesPerElement() );
int num_nodes_face_2 = static_cast<int>( mesh2.numberOfNodesPerElement() );

RealT fn1[max_dim], cx1[max_dim];
mesh1.getFaceNormal( fid1, fn1 );
Expand All @@ -1094,7 +1094,7 @@ TRIBOL_HOST_DEVICE inline bool CouplingScheme::Viewer::pruneMethodFacePair( cons
RealT z2[max_nodes_per_face];

for ( int i = 0; i < mesh1.numberOfNodesPerElement(); ++i ) {
const int nodeId_1 = mesh1.getGlobalNodeId( fid1, i );
const IndexT nodeId_1 = mesh1.getGlobalNodeId( fid1, i );
x1[i] = mesh1.getPosition()[0][nodeId_1];
y1[i] = mesh1.getPosition()[1][nodeId_1];
if ( dim == 3 ) {
Expand All @@ -1103,7 +1103,7 @@ TRIBOL_HOST_DEVICE inline bool CouplingScheme::Viewer::pruneMethodFacePair( cons
}

for ( int i = 0; i < mesh2.numberOfNodesPerElement(); ++i ) {
const int nodeId_2 = mesh2.getGlobalNodeId( fid2, i );
const IndexT nodeId_2 = mesh2.getGlobalNodeId( fid2, i );
x2[i] = mesh2.getPosition()[0][nodeId_2];
y2[i] = mesh2.getPosition()[1][nodeId_2];
if ( dim == 3 ) {
Expand Down
2 changes: 1 addition & 1 deletion src/tribol/mesh/MeshData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class MeshData {
*
* @return spatial dimension
*/
TRIBOL_HOST_DEVICE int spatialDimension() const { return m_position.size(); }
TRIBOL_HOST_DEVICE IndexT spatialDimension() const { return m_position.size(); }

/**
* @brief Number of nodes in the mesh
Expand Down
2 changes: 1 addition & 1 deletion src/tribol/mesh/MethodCouplingData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class MethodData {
*
* See @ref getElementBlockJacobians for a definition of the blocks.
*/
int getNSpaces() const { return m_blockJSpaces.size(); }
IndexT getNSpaces() const { return m_blockJSpaces.size(); }

/*!
* \brief Get the element ids for each entry of the getBlockJ 2D ArrayT
Expand Down
20 changes: 10 additions & 10 deletions src/tribol/mesh/MfemData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,16 +672,16 @@ class MfemMeshData {
/**
* @brief Get the number of elements in the first Tribol registered mesh
*
* @return int
* @return IndexT
*/
int GetMesh1NE() const { return GetUpdateData().conn_1_.size() / GetUpdateData().num_verts_per_elem_; }
IndexT GetMesh1NE() const { return GetUpdateData().conn_1_.size() / GetUpdateData().num_verts_per_elem_; }

/**
* @brief Get the number of elements in the second Tribol registered mesh
*
* @return int
* @return IndexT
*/
int GetMesh2NE() const { return GetUpdateData().conn_2_.size() / GetUpdateData().num_verts_per_elem_; }
IndexT GetMesh2NE() const { return GetUpdateData().conn_2_.size() / GetUpdateData().num_verts_per_elem_; }

/**
* @brief Get the total number of vertices in both Tribol registered meshes
Expand Down Expand Up @@ -1790,10 +1790,10 @@ struct PackedPairJacobianContribs {
const Array1D<int>* row_elem_map{ nullptr };
/// Tribol element-id -> redecomp element-id map for column element ids
const Array1D<int>* col_elem_map{ nullptr };
Array1D<int, MemorySpace::Host> row_elem_ids; ///< Tribol element IDs for rows
Array1D<int, MemorySpace::Host> col_elem_ids; ///< Tribol element IDs for columns
Array1D<IndexT, MemorySpace::Host> row_elem_ids; ///< Tribol element IDs for rows
Array1D<IndexT, MemorySpace::Host> col_elem_ids; ///< Tribol element IDs for columns
Array1D<double, MemorySpace::Host> jacobian_data; ///< Flattened Jacobian data
Array1D<int, MemorySpace::Host> value_offsets; ///< Offsets into jacobian_data for each element
Array1D<IndexT, MemorySpace::Host> value_offsets; ///< Offsets into jacobian_data for each element

PackedPairJacobianContribs() = default;

Expand All @@ -1817,7 +1817,7 @@ struct PackedPairJacobianContribs {
* @param n_jacobian_scalar_values Total number of scalar Jacobian values that will be appended across all pairs.
* This is used to reserve capacity in @ref jacobian_data.
*/
void reserve( int n_pairs, int n_jacobian_scalar_values )
void reserve( IndexT n_pairs, IndexT n_jacobian_scalar_values )
{
row_elem_ids.reserve( n_pairs );
col_elem_ids.reserve( n_pairs );
Expand All @@ -1833,7 +1833,7 @@ struct PackedPairJacobianContribs {
* @param data Pointer to a contiguous, column-major dense block of Jacobian values.
* @param size Number of scalar entries in @p data (typically `n_row_dofs * n_col_dofs`).
*/
void append( int row_elem_id, int col_elem_id, const double* data, int size )
void append( int row_elem_id, int col_elem_id, const double* data, IndexT size )
{
row_elem_ids.push_back( row_elem_id );
col_elem_ids.push_back( col_elem_id );
Expand All @@ -1846,7 +1846,7 @@ struct PackedPairJacobianContribs {
/**
* @brief Number of element contributions stored in this packed block
*/
int numEntries() const { return row_elem_ids.size(); }
IndexT numEntries() const { return row_elem_ids.size(); }
};

/**
Expand Down
Loading