Skip to content

Commit

Permalink
Avoid invalid pointer when there is no history data ref idaholab#59
Browse files Browse the repository at this point in the history
bwspenc committed Mar 29, 2019
1 parent 72dc574 commit d62c698
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/materials/NEMLStress.C
Original file line number Diff line number Diff line change
@@ -74,8 +74,8 @@ NEMLStress::computeQpStress()
double T_np1 = _temperature[_qp];
double T_n = _temperature_old[_qp];

double * h_np1 = &(_hist[_qp][0]);
const double * const h_n = &(_hist_old[_qp][0]);
double * h_np1 = (_model->nhist() > 0 ? &(_hist[_qp][0]) : nullptr);
const double * const h_n = (_model->nhist() > 0 ? &(_hist_old[_qp][0]) : nullptr);

double A_np1[36];

@@ -129,9 +129,12 @@ NEMLStress::initQpStatefulProperties()
// Figure out initial history
_hist[_qp].resize(_model->nhist());

int ier = _model->init_hist(&(_hist[_qp][0]));
if (ier != neml::SUCCESS)
mooseError("Error initializing NEML history!");
if (_model->nhist() > 0)
{
int ier = _model->init_hist(&(_hist[_qp][0]));
if (ier != neml::SUCCESS)
mooseError("Error initializing NEML history!");
}

_energy[_qp] = 0.0;
_dissipation[_qp] = 0.0;

0 comments on commit d62c698

Please sign in to comment.