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

Add option to dump mesh on failed jacobian check #1226

Merged
merged 7 commits into from
Oct 24, 2023
Merged
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 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
12 changes: 8 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,9 @@ 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 +3156,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 +3173,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 +3182,9 @@ 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
11 changes: 9 additions & 2 deletions src/ngp_algorithms/GeometryInteriorAlg.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "SolutionOptions.h"
#include "utils/StkHelpers.h"
#include "stk_mesh/base/NgpMesh.hpp"
#include <stk_util/parallel/ParallelReduce.hpp>

namespace sierra {
namespace nalu {
Expand Down Expand Up @@ -57,8 +58,9 @@ template <typename AlgTraits>
void
GeometryInteriorAlg<AlgTraits>::execute()
{
if (realm_.checkJacobians_)
if (realm_.checkJacobians_) {
impl_negative_jacobian_check();
}

impl_compute_dual_nodal_volume();

Expand Down Expand Up @@ -145,7 +147,12 @@ GeometryInteriorAlg<AlgTraits>::impl_negative_jacobian_check()
},
reducer);

if (numNegVol > 0) {
size_t globalNegVol = 0;
stk::all_reduce_sum(
NaluEnv::self().parallel_comm(), &numNegVol, &globalNegVol, 1);

if (globalNegVol > 0) {
realm_.provide_output(realm_.outputFailedJacobians_);
const stk::topology topology(AlgTraits::topo_);
throw std::runtime_error(
"GeometryInteriorAlg encountered " + std::to_string(numNegVol) +
Expand Down