Skip to content

Commit

Permalink
Ensure compilation works with dealii distributed vectors (#1239)
Browse files Browse the repository at this point in the history
Description
Compilation with deal.II distributed vectors did not work anymore because of an addition in the CHN equation. This has been fixed. To ensure that this does not happen again I have added a CI step to test LDV compilation. This is a first step in removing Trilinos Vectors from Lethe.
  • Loading branch information
blaisb authored Aug 14, 2024
1 parent 09f4a50 commit 93ec65f
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 6 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/main_dealii_distributed_vectors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI-Lethe-with-dealii-vectors

on:
push:
# Runs on every push on master branch
branches:
- master
# Runs on every push on master branch. If a push contains multiple commits, it will be ran on the latest one.
pull_request:
paths-ignore:
- 'doc/**'
- 'contrib/**'
- 'examples/**'

# Cancels running instances when a pull request is updated by a commit
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
cancel-in-progress: true

env:
COMPILE_JOBS: 4
MULTI_CORE_TESTS_REGEX: "mpirun=2"

jobs:
build:
name: Build (deal.ii:${{ matrix.dealii_version }})
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
dealii_version: ["master"]

# Run steps in container of dealii's master branch
container:
image: dealii/dealii:${{ matrix.dealii_version }}-focal
options: --user root

steps:
- name: Setup
run: |
# Since dealii image doesn't include Node.js, we'll install it
sudo apt-get update
sudo apt-get install -y --no-install-recommends nodejs
echo "Github actions is sane!"
echo "Running build with deal.ii version ${{ matrix.dealii_version }} on branch ${GITHUB_REF#refs/heads/}"
# Checks-out Lethe with branch of triggering commit
- name: Checkout code
uses: actions/checkout@v2

#
# Warnings
#
- name: Compile Lethe with deal.II distribtued vectors (deal.ii:${{ matrix.dealii_version }})
run: |
mkdir build-warnings
cd build-warnings
cmake ../ -DCMAKE_BUILD_TYPE=Debug -DLETHE_USE_LDV=ON
make -j${{ env.COMPILE_JOBS }}
2 changes: 1 addition & 1 deletion include/solvers/cahn_hilliard.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ class CahnHilliard : public AuxiliaryPhysics<dim, GlobalVectorType>
AffineConstraints<double> nonzero_constraints;
AffineConstraints<double> zero_constraints;
TrilinosWrappers::SparseMatrix system_matrix;
TrilinosWrappers::MPI::Vector filtered_solution;
GlobalVectorType filtered_solution;


// Previous solutions vectors
Expand Down
6 changes: 3 additions & 3 deletions include/solvers/navier_stokes_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ class NavierStokesBase : public PhysicsSolver<VectorType>
get_cell_temperature_values(
const typename DoFHandler<dim>::active_cell_iterator &cell,
const DoFHandler<dim> *dof_handler_ht,
const TrilinosWrappers::MPI::Vector &temperature_solution,
const GlobalVectorType &temperature_solution,
std::vector<double> &local_temperature_values)
{
const typename DoFHandler<dim>::active_cell_iterator temperature_cell(
Expand Down Expand Up @@ -515,8 +515,8 @@ class NavierStokesBase : public PhysicsSolver<VectorType>
get_cell_filtered_phase_fraction_values(
const typename DoFHandler<dim>::active_cell_iterator &cell,
const DoFHandler<dim> *dof_handler_vof,
const TrilinosWrappers::MPI::Vector &filtered_phase_fraction_solution,
std::vector<double> &local_filtered_phase_fraction_values)
const GlobalVectorType &filtered_phase_fraction_solution,
std::vector<double> &local_filtered_phase_fraction_values)
{
const typename DoFHandler<dim>::active_cell_iterator vof_cell(
&(*(this->triangulation)), cell->level(), cell->index(), dof_handler_vof);
Expand Down
4 changes: 2 additions & 2 deletions source/solvers/cahn_hilliard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1405,8 +1405,8 @@ CahnHilliard<dim>::apply_phase_filter()

const FEValuesExtractors::Scalar phase_order(0);

TrilinosWrappers::MPI::Vector filtered_solution_owned(
this->locally_owned_dofs, mpi_communicator);
GlobalVectorType filtered_solution_owned(this->locally_owned_dofs,
mpi_communicator);
filtered_solution_owned = this->present_solution;

filtered_solution.reinit(this->present_solution);
Expand Down
16 changes: 16 additions & 0 deletions source/solvers/fluid_dynamics_matrix_free.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2417,8 +2417,14 @@ FluidDynamicsMatrixFree<dim>::update_multiphysics_time_average_solution()
this->average_velocities->get_average_velocities());
this->multiphysics_average_velocities = temp_average_velocities;

#ifndef LETHE_USE_LDV
this->multiphysics->set_time_average_solution(
PhysicsID::fluid_dynamics, &this->multiphysics_average_velocities);
#else
this->multiphysics->set_time_average_solution(
PhysicsID::fluid_dynamics,
&this->average_velocities->get_average_velocities());
#endif
}
}

Expand Down Expand Up @@ -2548,8 +2554,13 @@ FluidDynamicsMatrixFree<dim>::update_solutions_for_multiphysics()
convert_vector_dealii_to_trilinos(temp_solution, this->present_solution);
multiphysics_present_solution = temp_solution;

#ifndef LETHE_USE_LDV
this->multiphysics->set_solution(PhysicsID::fluid_dynamics,
&this->multiphysics_present_solution);
#else
this->multiphysics->set_solution(PhysicsID::fluid_dynamics,
&this->present_solution);
#endif

// Convert the previous solutions to multiphysics vector type and provide them
// to the multiphysics interface
Expand All @@ -2571,8 +2582,13 @@ FluidDynamicsMatrixFree<dim>::update_solutions_for_multiphysics()
this->multiphysics_previous_solutions[i] = temp_previous_solutions[i];
}

#ifndef LETHE_USE_LDV
this->multiphysics->set_previous_solutions(
PhysicsID::fluid_dynamics, &this->multiphysics_previous_solutions);
#else
this->multiphysics->set_previous_solutions(PhysicsID::fluid_dynamics,
&this->previous_solutions);
#endif
}

template <int dim>
Expand Down
2 changes: 2 additions & 0 deletions source/solvers/heat_transfer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ double
HeatTransfer<dim>::calculate_delta_T_ref(double minimum_delta_T_ref)
{
double solution_maximum, solution_minimum;
#ifndef LETHE_USE_LDV
if (is_steady(simulation_parameters.simulation_control.method))
{
solution_maximum = this->present_solution.max();
Expand All @@ -788,6 +789,7 @@ HeatTransfer<dim>::calculate_delta_T_ref(double minimum_delta_T_ref)
solution_maximum = this->previous_solutions[0].max();
solution_minimum = this->previous_solutions[0].min();
}
#endif

// Calculate delta_T_ref.
double delta_T_ref =
Expand Down

0 comments on commit 93ec65f

Please sign in to comment.