Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/fromm3/penalty check #132

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
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
20 changes: 10 additions & 10 deletions src/tribol/mesh/CouplingScheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,6 @@ bool CouplingScheme::isValidCouplingScheme()
valid = false;
}

if ( !this->isValidEnforcement() ) {
this->m_couplingSchemeErrors.printEnforcementErrors();
valid = false;
} else if ( this->checkEnforcementData() != 0 ) {
this->m_couplingSchemeErrors.printEnforcementDataErrors();
valid = false;
}

switch ( this->checkExecutionModeData() ) {
case 1:
this->m_couplingSchemeErrors.printExecutionModeErrors();
Expand All @@ -441,6 +433,14 @@ bool CouplingScheme::isValidCouplingScheme()
break;
}

if ( !this->isValidEnforcement() ) {
this->m_couplingSchemeErrors.printEnforcementErrors();
valid = false;
} else if ( this->checkEnforcementData() != 0 ) {
this->m_couplingSchemeErrors.printEnforcementDataErrors();
valid = false;
}

return valid;
} // end CouplingScheme::isValidCouplingScheme()

Expand Down Expand Up @@ -772,8 +772,8 @@ int CouplingScheme::checkEnforcementData()
case PENALTY: {
// check penalty data. Note, this routine is guarded against null-meshes
PenaltyEnforcementOptions& pen_enfrc_options = this->m_enforcementOptions.penalty_options;
if ( this->m_mesh1->checkPenaltyData( pen_enfrc_options ) != 0 ||
this->m_mesh2->checkPenaltyData( pen_enfrc_options ) != 0 ) {
if ( this->m_mesh1->checkPenaltyData( pen_enfrc_options, this->m_exec_mode ) != 0 ||
this->m_mesh2->checkPenaltyData( pen_enfrc_options, this->m_exec_mode ) != 0 ) {
this->m_couplingSchemeErrors.cs_enforcement_data_error = ERROR_IN_REGISTERED_ENFORCEMENT_DATA;
err = 1;
}
Expand Down
54 changes: 32 additions & 22 deletions src/tribol/mesh/MeshData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
namespace tribol {

//------------------------------------------------------------------------------
bool MeshElemData::isValidKinematicPenalty( PenaltyEnforcementOptions& pen_options )
bool MeshElemData::isValidKinematicPenalty( PenaltyEnforcementOptions& pen_options, ExecutionMode exec_mode,
int alloc_id )
{
// Note, this routine is, and should be called only for non-null meshes
KinematicPenaltyCalculation kin_calc = pen_options.kinematic_calculation;
Expand Down Expand Up @@ -60,26 +61,35 @@ bool MeshElemData::isValidKinematicPenalty( PenaltyEnforcementOptions& pen_optio
return false;
}

// check for positive material modulus and thickness values
bool isValidMatMod = true;
bool isValidElemThickness = true;
for ( int i = 0; i < this->m_num_cells; ++i ) {
if ( this->m_mat_mod[i] <= 0. ) {
isValidMatMod = false;
}
if ( this->m_thickness[i] <= 0. ) {
isValidElemThickness = false;
}

SLIC_WARNING_IF( !isValidMatMod, "MeshElemData::isValidKinematicPenalty(): "
<< "invalid nonpositive element material modulus encountered." );
ArrayT<IndexT> mod_ok_data( { static_cast<IndexT>( true ) }, alloc_id );
ArrayViewT<IndexT> mod_ok = mod_ok_data;
ArrayT<IndexT> thickness_ok_data( { static_cast<IndexT>( true ) }, alloc_id );
ArrayViewT<IndexT> thickness_ok = thickness_ok_data;
Array1DView<const RealT> mod = this->m_mat_mod;
Array1DView<const RealT> thickness = this->m_thickness;

SLIC_WARNING_IF( !isValidElemThickness, "MeshElemData::isValidKinematicPenalty(): "
<< "invalid nonpositive element thickness encountered." );

if ( !isValidMatMod || !isValidElemThickness ) {
return false;
forAllExec( exec_mode, this->m_num_cells, [mod, thickness, mod_ok, thickness_ok] TRIBOL_HOST_DEVICE( IndexT i ) {
if ( mod[i] <= 0. ) {
RAJA::atomicMin<RAJA::auto_atomic>( mod_ok.data(), static_cast<IndexT>( false ) );
}
if ( thickness[i] <= 0. ) {
RAJA::atomicMin<RAJA::auto_atomic>( thickness_ok.data(), static_cast<IndexT>( false ) );
}
} ); // end element loop

ArrayT<IndexT, 1, MemorySpace::Host> mod_ok_data_host( mod_ok_data );
SLIC_WARNING_IF(
!mod_ok_data_host[0],
axom::fmt::format(
"MeshElemData::isValidKinematicPenalty(): invalid nonpositive element material modulus encountered." ) );
ArrayT<IndexT, 1, MemorySpace::Host> thickness_ok_data_host( thickness_ok_data );
SLIC_WARNING_IF(
!thickness_ok_data_host[0],
axom::fmt::format(
"MeshElemData::isValidKinematicPenalty(): invalid nonpositive element thickness encountered." ) );

if ( !mod_ok_data_host[0] || !thickness_ok_data_host[0] ) {
return false;
} // end for loop over elements
break;
} // end case KINEMATIC_ELEMENT
Expand Down Expand Up @@ -583,22 +593,22 @@ int MeshData::checkLagrangeMultiplierData()
return err;
}
//------------------------------------------------------------------------------
int MeshData::checkPenaltyData( PenaltyEnforcementOptions& p_enfrc_options )
int MeshData::checkPenaltyData( PenaltyEnforcementOptions& p_enfrc_options, ExecutionMode exec_mode )
{
int err = 0;
if ( this->numberOfElements() > 0 ) {
PenaltyConstraintType constraint_type = p_enfrc_options.constraint_type;
// switch over penalty enforcement options and check for required data
switch ( constraint_type ) {
case KINEMATIC: {
if ( !m_element_data.isValidKinematicPenalty( p_enfrc_options ) ) {
if ( !m_element_data.isValidKinematicPenalty( p_enfrc_options, exec_mode, this->m_allocator_id ) ) {
err = 1;
}
break;
} // end KINEMATIC case

case KINEMATIC_AND_RATE: {
if ( !m_element_data.isValidKinematicPenalty( p_enfrc_options ) ) {
if ( !m_element_data.isValidKinematicPenalty( p_enfrc_options, exec_mode, this->m_allocator_id ) ) {
err = 1;
}
if ( !m_element_data.isValidRatePenalty( p_enfrc_options ) ) {
Expand Down
4 changes: 2 additions & 2 deletions src/tribol/mesh/MeshData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct MeshElemData {
*
* \return true if the kinematic penalty option has valid data
*/
bool isValidKinematicPenalty( PenaltyEnforcementOptions& pen_options );
bool isValidKinematicPenalty( PenaltyEnforcementOptions& pen_options, ExecutionMode exec_mode, int alloc_id );

/*!
* \brief Checks if the rate penalty data is valid
Expand Down Expand Up @@ -647,7 +647,7 @@ class MeshData {
*
* \param [in] p_enfrc_options penalty enforcement options guiding check
*/
int checkPenaltyData( PenaltyEnforcementOptions& p_enfrc_options );
int checkPenaltyData( PenaltyEnforcementOptions& p_enfrc_options, ExecutionMode exec_mode );

/*!
* \brief Computes the face normals and centroids for all faces in the mesh
Expand Down