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

Adding SIMPLEC #29865

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open

Adding SIMPLEC #29865

wants to merge 1 commit into from

Conversation

tanoret
Copy link
Contributor

@tanoret tanoret commented Feb 12, 2025

Closes #29864

@tanoret
Copy link
Contributor Author

tanoret commented Feb 12, 2025

@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!

@moosebuild
Copy link
Contributor

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
You can directly apply the patch by running, in the top level of your repository:

curl -s https://mooseframework.inl.gov/docs/PRs/29865/clang_format/style.patch | git apply -v

Alternatively, with your repository up to date and in the top level of your repository:

git clang-format cd66266a7dec6c2ec22f5902dba3e2ab6eeb8b19

// Pressure projection
params.addParam<MooseEnum>(
"pressure_projection_method",
MooseEnum("SIMPLE SIMPLEC", "SIMPLE"),
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PetscVector<Number> * Ainv_full_vec = dynamic_cast<PetscVector<Number> *>(Ainv_full.get());
PetscVector<Number> * Ainv_full_vec = cast_ptr<PetscVector<Number> *>(Ainv_full.get());

Copy link
Contributor

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
Copy link
Member

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?

Copy link
Member

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

Copy link
Contributor

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.

Copy link
Member

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

@moosebuild
Copy link
Contributor

moosebuild commented Feb 12, 2025

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.

@moosebuild
Copy link
Contributor

Job Coverage, step Generate coverage on fe10d3d wanted to post the following:

Framework coverage

cd6626 #29865 fe10d3
Total Total +/- New
Rate 85.29% 85.29% -0.00% -
Hits 108457 108456 -1 0
Misses 18702 18703 +1 0

Diff coverage report

Full coverage report

Modules coverage

Navier stokes

cd6626 #29865 fe10d3
Total Total +/- New
Rate 84.83% 84.85% +0.02% 96.67%
Hits 17777 17805 +28 29
Misses 3178 3179 +1 1

Diff coverage report

Full coverage report

Full coverage reports

Reports

This comment will be updated on new commits.

Copy link
Contributor

@grmnptr grmnptr left a 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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto get_row_sum_excluding_diagonal = [mmat](NumericVector<Number> & sum_vector)
auto get_row_sum = [mmat](NumericVector<Number> & sum_vector)

Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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());
Copy link
Contributor

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]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ainv = *Ainv_full_vec_hold;
Ainv = *Ainv_full_old;

[]

[Executioner]
type = SIMPLE
Copy link
Contributor

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
design = 'SIMPLE.md LinearFVDivergence.md LinearWCNSFVMomentumFlux.md LinearFVMomentumPressure.md'
design = 'RhieChowMassFlux.md SIMPLE.md'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding SIMPLEC
4 participants