Skip to content

Commit

Permalink
Add option to dump mesh on failed jacobian check
Browse files Browse the repository at this point in the history
  • Loading branch information
psakievich committed Oct 23, 2023
1 parent 5b978b2 commit 8ee92d0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion include/Realm.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Realm
void compute_vrtm(const std::string& = "velocity");
void compute_l2_scaling();
void output_converged_results();
void provide_output();
void provide_output(bool forcedOutput=false);
void provide_restart_output();

void register_interior_algorithm(stk::mesh::Part* part);
Expand Down Expand Up @@ -481,6 +481,7 @@ class Realm

// check if there are negative Jacobians
bool checkJacobians_;
bool outputFailedJacobians_;

// types of physics
bool isothermalFlow_;
Expand Down
9 changes: 5 additions & 4 deletions src/Realm.C
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Realm::Realm(Realms& realms, const YAML::Node& node)
edgesPart_(0),
checkForMissingBcs_(false),
checkJacobians_(false),
outputFailedJacobians_(false),
isothermalFlow_(true),
uniformFlow_(true),
provideEntityCount_(false),
Expand Down Expand Up @@ -670,6 +671,7 @@ Realm::load(const YAML::Node& node)

// check for bad Jacobians in the mesh
get_if_present(node, "check_jacobians", checkJacobians_, checkJacobians_);
get_if_present(node, "output_on_failed_jacobian_check", outputFailedJacobians_, outputFailedJacobians_);

// entity count
get_if_present(
Expand Down Expand Up @@ -3152,7 +3154,7 @@ Realm::overset_field_update(
//-------- provide_output --------------------------------------------------
//--------------------------------------------------------------------------
void
Realm::provide_output()
Realm::provide_output(bool forcedOutput)
{
stk::diag::TimeBlock mesh_output_timeblock(Simulation::outputTimer());
const double start_time = NaluEnv::self().nalu_time();
Expand All @@ -3169,7 +3171,6 @@ Realm::provide_output()
const int modStep = timeStepCount - outputInfo_->outputStart_;

// check for elapsed WALL time threshold
bool forcedOutput = false;
if (outputInfo_->userWallTimeResults_.first) {
const double elapsedWallTime = stk::wall_time() - wallTimeStart_;
// find the max over all core
Expand All @@ -3179,8 +3180,7 @@ Realm::provide_output()
1);
// convert to hours
g_elapsedWallTime /= 3600.0;
// only force output the first time the timer is exceeded
if (g_elapsedWallTime > outputInfo_->userWallTimeResults_.second) {
if (g_elapsedWallTime > outputInfo_->userWallTimeResults_.second || forcedOutput) {
forcedOutput = true;
outputInfo_->userWallTimeResults_.first = false;
NaluEnv::self().naluOutputP0() << "Realm::provide_output()::Forced "
Expand Down Expand Up @@ -3234,6 +3234,7 @@ Realm::provide_output()
}
}


//--------------------------------------------------------------------------
//-------- provide_restart_output ------------------------------------------
//--------------------------------------------------------------------------
Expand Down
12 changes: 10 additions & 2 deletions src/ngp_algorithms/GeometryInteriorAlg.C
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,16 @@ template <typename AlgTraits>
void
GeometryInteriorAlg<AlgTraits>::execute()
{
if (realm_.checkJacobians_)
impl_negative_jacobian_check();
if (realm_.checkJacobians_){
try{
impl_negative_jacobian_check();
}
catch (const std::exception& e){
// dump exodus file if the user enabled this feature then rethrow
realm_.provide_output(realm_.outputFailedJacobians_);
throw e;
}
}

impl_compute_dual_nodal_volume();

Expand Down

0 comments on commit 8ee92d0

Please sign in to comment.