Skip to content

Commit

Permalink
Finish cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
blaisb committed Dec 3, 2024
1 parent 5e69de9 commit d319ff0
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 287 deletions.
2 changes: 0 additions & 2 deletions include/fem-dem/fluid_dynamics_vans.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ class FluidDynamicsVANS : public FluidDynamicsMatrixBased<dim>
void
read_dem();



protected:
/**
* @brief associates the degrees of freedom to each vertex of the finite elements
Expand Down
22 changes: 0 additions & 22 deletions include/fem-dem/void_fraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,26 +365,10 @@ class VoidFractionBase : public PhysicsLinearSubequationsSolver
/// Locally owned solution of the void fraction
GlobalVectorType void_fraction_locally_owned;

/// ??? Not fully sure of this yet
TrilinosWrappers::SparseMatrix complete_system_matrix_void_fraction;
GlobalVectorType complete_system_rhs_void_fraction;

/// Mass matrix used to constraint the value of the void fraction to be
/// bounded
TrilinosWrappers::SparseMatrix mass_matrix;

/// Mass matrix diagonal used to constraint the value of the void fraction to
/// be bounded
GlobalVectorType diagonal_of_mass_matrix;

/// ??? BB Not fully sure of this yet
IndexSet active_set;

/// Preconditioner used for the solution of the smoothed L2 projection of the
/// void fraction
std::shared_ptr<TrilinosWrappers::PreconditionILU> ilu_preconditioner;


/// System matrix used to assembled the smoothed L2 projection of the void
/// fraction
TrilinosWrappers::SparseMatrix system_matrix_void_fraction;
Expand All @@ -399,12 +383,6 @@ class VoidFractionBase : public PhysicsLinearSubequationsSolver
std::set<typename DoFHandler<dim>::active_cell_iterator>>
vertices_to_cell;


/**
* Member related to boundary conditions. At the moment, only a single
* boundary condition is supported.
*/

/// Boolean to indicate if the mesh has periodic boundaries
bool has_periodic_boundaries;

Expand Down
226 changes: 0 additions & 226 deletions source/fem-dem/fluid_dynamics_vans.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,88 +64,9 @@ FluidDynamicsVANS<dim>::setup_dofs()
{
FluidDynamicsMatrixBased<dim>::setup_dofs();

// Define constraints for periodic boundary conditions
// auto &boundary_conditions =
// this->cfd_dem_simulation_parameters.cfd_parameters.boundary_conditions;
// for (auto const &[id, type] : boundary_conditions.type)
// {
// if (type == BoundaryConditions::BoundaryType::periodic)
// {
// periodic_direction = boundary_conditions.periodic_direction.at(id);
// DoFTools::make_periodicity_constraints(
// this->void_fraction_manager.dof_handler,
// id,
// boundary_conditions.periodic_neighbor_id.at(id),
// periodic_direction,
// this->void_fraction_manager.void_fraction_constraints);

// // Get periodic offset if void fraction method is qcm or spm
// if (this->cfd_dem_simulation_parameters.void_fraction->mode ==
// Parameters::VoidFractionMode::qcm ||
// this->cfd_dem_simulation_parameters.void_fraction->mode ==
// Parameters::VoidFractionMode::spm)
// {
// periodic_offset = get_periodic_offset_distance(id);
// }
// }
// }

// void_fraction_manager.void_fraction_constraints.close();
void_fraction_manager.setup_dofs();
void_fraction_manager.setup_constraints(
this->cfd_dem_simulation_parameters.cfd_parameters.boundary_conditions);


// nodal_void_fraction_relevant.reinit(locally_owned_dofs_voidfraction,
// locally_relevant_dofs_voidfraction,
// this->mpi_communicator);

// // Initialize vector of previous solutions for the void fraction
// for (auto &solution : this->previous_void_fraction)
// {
// solution.reinit(this->locally_owned_dofs_voidfraction,
// this->locally_relevant_dofs_voidfraction,
// this->mpi_communicator);
// }

// nodal_void_fraction_owned.reinit(locally_owned_dofs_voidfraction,
// this->mpi_communicator);

// DynamicSparsityPattern dsp(locally_relevant_dofs_voidfraction);
// DoFTools::make_sparsity_pattern(void_fraction_dof_handler,
// dsp,
// void_fraction_constraints,
// false);
// SparsityTools::distribute_sparsity_pattern(
// dsp,
// locally_owned_dofs_voidfraction,
// this->mpi_communicator,
// locally_relevant_dofs_voidfraction);

// system_matrix_void_fraction.reinit(locally_owned_dofs_voidfraction,
// locally_owned_dofs_voidfraction,
// dsp,
// this->mpi_communicator);

// complete_system_matrix_void_fraction.reinit(locally_owned_dofs_voidfraction,
// locally_owned_dofs_voidfraction,
// dsp,
// this->mpi_communicator);

// system_rhs_void_fraction.reinit(locally_owned_dofs_voidfraction,
// this->mpi_communicator);

// complete_system_rhs_void_fraction.reinit(locally_owned_dofs_voidfraction,
// this->mpi_communicator);

// active_set.set_size(void_fraction_dof_handler.n_dofs());

// mass_matrix.reinit(locally_owned_dofs_voidfraction,
// locally_owned_dofs_voidfraction,
// dsp,
// this->mpi_communicator);
//
// assemble_mass_matrix_diagonal(mass_matrix);
}

template <int dim>
Expand Down Expand Up @@ -237,153 +158,6 @@ FluidDynamicsVANS<dim>::calculate_void_fraction(const double time,
void_fraction_manager.calculate_void_fraction(time);
}

template <int dim>
void
FluidDynamicsVANS<dim>::assemble_mass_matrix_diagonal(
TrilinosWrappers::SparseMatrix &mass_matrix)
{
// Assert(fe_void_fraction.degree == 1, ExcNotImplemented());
// QGauss<dim> quadrature_formula(this->number_quadrature_points);
// FEValues<dim> fe_void_fraction_values(fe_void_fraction,
// quadrature_formula,
// update_values | update_JxW_values);
// const unsigned int dofs_per_cell = fe_void_fraction.dofs_per_cell;
// const unsigned int n_qpoints = quadrature_formula.size();
// FullMatrix<double> cell_matrix(dofs_per_cell, dofs_per_cell);
// std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
// for (const auto &cell : void_fraction_dof_handler.active_cell_iterators())
// {
// if (cell->is_locally_owned())
// {
// fe_void_fraction_values.reinit(cell);
// cell_matrix = 0;
// for (unsigned int q = 0; q < n_qpoints; ++q)
// for (unsigned int i = 0; i < dofs_per_cell; ++i)
// cell_matrix(i, i) += (fe_void_fraction_values.shape_value(i, q) *
// fe_void_fraction_values.shape_value(i, q) *
// fe_void_fraction_values.JxW(q));
// cell->get_dof_indices(local_dof_indices);
// void_fraction_constraints.distribute_local_to_global(
// cell_matrix, local_dof_indices, mass_matrix);
// }
// }
}

template <int dim>
void
FluidDynamicsVANS<dim>::update_solution_and_constraints()
{
// const double penalty_parameter = 100;

// GlobalVectorType lambda(locally_owned_dofs_voidfraction,
// this->mpi_communicator);

// nodal_void_fraction_owned = nodal_void_fraction_relevant;

// complete_system_matrix_void_fraction.residual(lambda,
// nodal_void_fraction_owned,
// system_rhs_void_fraction);

// void_fraction_constraints.clear();

// // reinitialize affine constraints
// void_fraction_constraints.reinit(locally_relevant_dofs_voidfraction);

// // Remake hanging node constraints
// DoFTools::make_hanging_node_constraints(void_fraction_dof_handler,
// void_fraction_constraints);

// // Define constraints for periodic boundary conditions
// auto &boundary_conditions =
// this->cfd_dem_simulation_parameters.cfd_parameters.boundary_conditions;
// for (auto const &[id, type] : boundary_conditions.type)
// {
// if (type == BoundaryConditions::BoundaryType::periodic)
// {
// periodic_direction = boundary_conditions.periodic_direction.at(id);
// DoFTools::make_periodicity_constraints(
// void_fraction_dof_handler,
// id,
// boundary_conditions.periodic_neighbor_id.at(id),
// periodic_direction,
// void_fraction_constraints);

// // Get periodic offset if void fraction method is qcm or spm
// if (this->cfd_dem_simulation_parameters.void_fraction->mode ==
// Parameters::VoidFractionMode::qcm ||
// this->cfd_dem_simulation_parameters.void_fraction->mode ==
// Parameters::VoidFractionMode::spm)
// {
// periodic_offset = get_periodic_offset_distance(id);
// }
// }
// }

// active_set.clear();

// for (const auto &cell : void_fraction_dof_handler.active_cell_iterators())
// {
// if (cell->is_locally_owned())
// {
// for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell;
// ++v)
// {
// Assert(void_fraction_dof_handler.get_fe().dofs_per_cell ==
// GeometryInfo<dim>::vertices_per_cell,
// ExcNotImplemented());
// const unsigned int dof_index = cell->vertex_dof_index(v, 0);
// if (locally_owned_dofs_voidfraction.is_element(dof_index))
// {
// const double solution_value =
// nodal_void_fraction_owned(dof_index);
// if (lambda(dof_index) +
// penalty_parameter * mass_matrix(dof_index, dof_index)
// *
// (solution_value -
// this->cfd_dem_simulation_parameters
// .void_fraction->l2_upper_bound)
// >
// 0)
// {
// active_set.add_index(dof_index);
// void_fraction_constraints.add_line(dof_index);
// void_fraction_constraints.set_inhomogeneity(
// dof_index,
// this->cfd_dem_simulation_parameters.void_fraction
// ->l2_upper_bound);
// nodal_void_fraction_owned(dof_index) =
// this->cfd_dem_simulation_parameters.void_fraction
// ->l2_upper_bound;
// lambda(dof_index) = 0;
// }
// else if (lambda(dof_index) +
// penalty_parameter *
// mass_matrix(dof_index, dof_index) *
// (solution_value -
// this->cfd_dem_simulation_parameters
// .void_fraction->l2_lower_bound) <
// 0)
// {
// active_set.add_index(dof_index);
// void_fraction_constraints.add_line(dof_index);
// void_fraction_constraints.set_inhomogeneity(
// dof_index,
// this->cfd_dem_simulation_parameters.void_fraction
// ->l2_lower_bound);
// nodal_void_fraction_owned(dof_index) =
// this->cfd_dem_simulation_parameters.void_fraction
// ->l2_lower_bound;
// lambda(dof_index) = 0;
// }
// }
// }
// }
// }
// active_set.compress();
// nodal_void_fraction_relevant = nodal_void_fraction_owned;
// void_fraction_constraints.close();
}

template <int dim>
void
FluidDynamicsVANS<dim>::vertices_cell_mapping()
Expand Down
37 changes: 0 additions & 37 deletions source/fem-dem/void_fraction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ VoidFractionBase<dim>::calculate_void_fraction(const double time)
}

solve_linear_system_and_update_solution(false);
// if (this->cfd_dem_simulation_parameters.void_fraction
// ->bound_void_fraction == true)
// update_solution_and_constraints();
}

template <int dim>
Expand Down Expand Up @@ -1137,40 +1134,6 @@ VoidFractionBase<dim>::solve_linear_system_and_update_solution(
void_fraction_locally_relevant = completely_distributed_solution;
}

template <int dim>
void
VoidFractionBase<dim>::assemble_mass_matrix_diagonal(
TrilinosWrappers::SparseMatrix &diagonal_mass_matrix)
{
Assert(
fe->degree == 1,
ExcMessage(
"Constraining the void fraction between lower and upper bound is not supported when using a FE_Q with a degree higher than 1"));
FEValues<dim> fe_void_fraction_values(*fe,
*quadrature,
update_values | update_JxW_values);
const unsigned int dofs_per_cell = fe->dofs_per_cell;
const unsigned int n_qpoints = quadrature->size();
FullMatrix<double> cell_matrix(dofs_per_cell, dofs_per_cell);
std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
for (const auto &cell : dof_handler.active_cell_iterators())
{
if (cell->is_locally_owned())
{
fe_void_fraction_values.reinit(cell);
cell_matrix = 0;
for (unsigned int q = 0; q < n_qpoints; ++q)
for (unsigned int i = 0; i < dofs_per_cell; ++i)
cell_matrix(i, i) += (fe_void_fraction_values.shape_value(i, q) *
fe_void_fraction_values.shape_value(i, q) *
fe_void_fraction_values.JxW(q));
cell->get_dof_indices(local_dof_indices);
void_fraction_constraints.distribute_local_to_global(
cell_matrix, local_dof_indices, mass_matrix);
}
}
}

// Pre-compile the 2D and 3D Navier-Stokes solver to ensure that the
// library is valid before we actually compile the solver This greatly
// helps with debugging
Expand Down

0 comments on commit d319ff0

Please sign in to comment.