-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Adding SIMPLEC #29865
base: next
Are you sure you want to change the base?
Adding SIMPLEC #29865
Conversation
@grmnptr added a couple of tests showing that we can converge fine with pressure equation relaxation equal 1.0. Tried to add minimal changes to your architecture @freiler don't think a technical review is needed at this point as this is mostly a step towards VOF. However, I leave this to your technical reviewer judgement. Thanks! |
Job Precheck, step Clang format on a594e5e wanted to post the following: Your code requires style changes. A patch was auto generated and copied here
Alternatively, with your repository up to date and in the top level of your repository:
|
// Pressure projection | ||
params.addParam<MooseEnum>( | ||
"pressure_projection_method", | ||
MooseEnum("SIMPLE SIMPLEC", "SIMPLE"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the benefits espoused on the associated issue, why not make SIMPLEC the default?
if (_pressure_projection_method == "SIMPLEC") | ||
{ | ||
|
||
// Consistent Corrections to Simple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Consistent Corrections to Simple | |
// Consistent Corrections to SIMPLE |
sum_vector.zero(); | ||
|
||
// Local row size | ||
const unsigned int local_size = mmat->row_stop() - mmat->row_start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const unsigned int local_size = mmat->row_stop() - mmat->row_start(); | |
const auto local_size = mmat->local_m(); |
for (const auto row_i : make_range(local_size)) | ||
{ | ||
// Get all non-zero components of the row of the matrix | ||
const unsigned int global_index = mmat->row_start() + row_i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const unsigned int global_index = mmat->row_start() + row_i; | |
const auto global_index = mmat->row_start() + row_i; |
|
||
// Create vector with new inverse projection matrix | ||
auto Ainv_full = current_local_solution.zero_clone(); | ||
PetscVector<Number> * Ainv_full_vec = dynamic_cast<PetscVector<Number> *>(Ainv_full.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PetscVector<Number> * Ainv_full_vec = dynamic_cast<PetscVector<Number> *>(Ainv_full.get()); | |
PetscVector<Number> * Ainv_full_vec = cast_ptr<PetscVector<Number> *>(Ainv_full.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually don't need this vector. The NumericVector is enough, it has the functions you need. The cost of the virtual call for this will be negligible compared to the operations within this function.
[] | ||
|
||
[Executioner] | ||
type = SIMPLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be kind of nice to not have a discrepancy between the executioner name and pressure projection method, but maybe experienced CFD users wouldn't find this confusing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this discrepancy wouldn't appear when using Physics
? Then it would be much less a concern to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this design. The projection type only comes in the picture through the fields that are computed in the RC object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree the code design is nice
Job Documentation, step Docs: sync website on fe10d3d wanted to post the following: View the site here This comment will be updated on new commits. |
Job Coverage, step Generate coverage on fe10d3d wanted to post the following: Framework coverage
Modules coverageNavier stokes
Full coverage reportsReports
This comment will be updated on new commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elegant solution! For the records, could you provide some numbers here on speedup on cases within the flow test bed?
@@ -22,6 +22,15 @@ Besides these capabilities, this user object is also responsible for reconstruct | |||
cell velocities at the end of the pressure corrector step. | |||
For more information on these fields and processes, we suggest visiting [SIMPLE.md]. | |||
|
|||
The object enables the computation of the standard (SIMPLE) or consistent (SIMPLEC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
std::vector<Real> values; | ||
mmat->get_row(global_index, indices, values); | ||
|
||
// Use std::accumulate with a lambda to sum row elements (no absolute values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Use std::accumulate with a lambda to sum row elements (no absolute values) | |
// Sum row elements (no absolute values) |
_console << "Performing SIMPLEC projection." << std::endl; | ||
|
||
// Lambda function to calculate the sum of diagonal and neighbor coefficients | ||
auto get_row_sum_excluding_diagonal = [mmat](NumericVector<Number> & sum_vector) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto get_row_sum_excluding_diagonal = [mmat](NumericVector<Number> & sum_vector) | |
auto get_row_sum = [mmat](NumericVector<Number> & sum_vector) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering that the diagonal is actually in here
auto Ainv_full = current_local_solution.zero_clone(); | ||
PetscVector<Number> * Ainv_full_vec = dynamic_cast<PetscVector<Number> *>(Ainv_full.get()); | ||
*working_vector_petsc = 1.0; | ||
Ainv_full_vec->pointwise_divide(*working_vector_petsc, *neighbor_sum_petsc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ainv_full_vec->pointwise_divide(*working_vector_petsc, *neighbor_sum_petsc); | |
Ainv_full->pointwise_divide(*working_vector_petsc, *row_sum); |
|
||
// Create vector with new inverse projection matrix | ||
auto Ainv_full = current_local_solution.zero_clone(); | ||
PetscVector<Number> * Ainv_full_vec = dynamic_cast<PetscVector<Number> *>(Ainv_full.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually don't need this vector. The NumericVector is enough, it has the functions you need. The cost of the virtual call for this will be negligible compared to the operations within this function.
|
||
// Correct HbyA | ||
Ainv_full_vec->add(-1.0, Ainv); | ||
working_vector_petsc->pointwise_mult(*Ainv_full_vec, *pressure_gradient[system_i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
working_vector_petsc->pointwise_mult(*Ainv_full_vec, *pressure_gradient[system_i]); | |
working_vector_petsc->pointwise_mult(*Ainv_full, *pressure_gradient[system_i]); |
HbyA.add(-1.0, *working_vector_petsc); | ||
|
||
// Correct Ainv | ||
Ainv = *Ainv_full_vec_hold; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ainv = *Ainv_full_vec_hold; | |
Ainv = *Ainv_full_old; |
[] | ||
|
||
[Executioner] | ||
type = SIMPLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this design. The projection type only comes in the picture through the fields that are computed in the RC object.
@@ -0,0 +1,15 @@ | |||
[Tests] | |||
issues = '#27280 #28951 #29150' | |||
design = 'SIMPLE.md PIMPLE.md LinearFVDivergence.md LinearWCNSFVMomentumFlux.md LinearFVMomentumPressure.md LinearFVEnergyAdvection.md LinearFVMomentumBoussinesq.md' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
design = 'SIMPLE.md PIMPLE.md LinearFVDivergence.md LinearWCNSFVMomentumFlux.md LinearFVMomentumPressure.md LinearFVEnergyAdvection.md LinearFVMomentumBoussinesq.md' | |
design = 'RhieChowMassFlux.md SIMPLE.md' |
@@ -0,0 +1,15 @@ | |||
[Tests] | |||
issues = '#27280' | |||
design = 'SIMPLE.md LinearFVDivergence.md LinearWCNSFVMomentumFlux.md LinearFVMomentumPressure.md' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
design = 'SIMPLE.md LinearFVDivergence.md LinearWCNSFVMomentumFlux.md LinearFVMomentumPressure.md' | |
design = 'RhieChowMassFlux.md SIMPLE.md' |
Closes #29864