Skip to content

Commit

Permalink
Fix fvoptions seg fault (#369)
Browse files Browse the repository at this point in the history
* Called fvOptions constrain to avoid seg fault.

* Fixed an issue.
  • Loading branch information
friedenhe authored Oct 12, 2022
1 parent a175e43 commit 0009b91
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/adjoint/DAResidual/DAResidualRhoSimpleFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ DAResidualRhoSimpleFoam::DAResidualRhoSimpleFoam(
Info << "molWeight " << molWeight_ << endl;
Info << "Cp " << Cp_ << endl;
}

// this is just a dummy call because we need to run the constrain once
// to initialize fvOptions, before we can use it. Otherwise, we may get
// a seg fault when we call fvOptions_.correct(U_) in updateIntermediateVars
fvVectorMatrix UEqn(
fvm::div(phi_, U_)
- fvOptions_(rho_, U_));
fvOptions_.constrain(UEqn);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Expand Down
8 changes: 8 additions & 0 deletions src/adjoint/DAResidual/DAResidualSimpleFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ DAResidualSimpleFoam::DAResidualSimpleFoam(
{
hasFvSource_ = 1;
}

// this is just a dummy call because we need to run the constrain once
// to initialize fvOptions, before we can use it. Otherwise, we may get
// a seg fault when we call fvOptions_.correct(U_) in updateIntermediateVars
fvVectorMatrix UEqn(
fvm::div(phi_, U_)
- fvOptions_(U_));
fvOptions_.constrain(UEqn);
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Expand Down
8 changes: 8 additions & 0 deletions src/adjoint/DAResidual/DAResidualSimpleTFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ DAResidualSimpleTFoam::DAResidualSimpleTFoam(
false));
Pr_ = readScalar(transportProperties.lookup("Pr"));
Prt_ = readScalar(transportProperties.lookup("Prt"));

// this is just a dummy call because we need to run the constrain once
// to initialize fvOptions, before we can use it. Otherwise, we may get
// a seg fault when we call fvOptions_.correct(U_) in updateIntermediateVars
fvVectorMatrix UEqn(
fvm::div(phi_, U_)
- fvOptions_(U_));
fvOptions_.constrain(UEqn);
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Expand Down

0 comments on commit 0009b91

Please sign in to comment.