<commit_before>//
//  NSolver::apply_laplacian_continuation.cpp
//
//  Created by <NAME> on 15/11/5.
//  A work based on deal.II tutorial step-33.
//

#include <NSolver/solver/NSolver.h>

namespace NSFEMSolver
{
  using namespace dealii;

  template <int dim>
  void
  NSolver<dim>::apply_laplacian_continuation()
  {
    typedef Sacado::Fad::DFad<double> DFADD;

    // Apply the laplacian operator
    const unsigned int dofs_per_cell = dof_handler.get_fe().dofs_per_cell;
    const unsigned int n_q_points    = quadrature.size();
    std::vector<types::global_dof_index> dof_indices (dofs_per_cell);

    const UpdateFlags update_flags = update_values
                                     | update_gradients
                                     | update_quadrature_points
                                     | update_JxW_values;
    FEValues<dim> fe_v (*mapping_ptr, fe, quadrature, update_flags);

    std::vector<std::vector<Tensor<1,dim> > > grad_W (n_q_points,
                                                      std::vector<Tensor<1,dim> > (EquationComponents<dim>::n_components));
    std::vector<Vector<double> > W (n_q_points,
                                    Vector<double> (EquationComponents<dim>::n_components));
    std::vector<Vector<double> > W_old (n_q_points,
                                        Vector<double> (EquationComponents<dim>::n_components));

    // Find out global minimum cell size
    double local_h_min = std::numeric_limits<double>::max();
    if (parameters->use_local_time_step_size)
      {
        typename DoFHandler<dim>::active_cell_iterator cell =
          dof_handler.begin_active();
        const typename DoFHandler<dim>::active_cell_iterator endc =
          dof_handler.end();
        for (; cell!=endc; ++cell)
          {
            if (cell->is_locally_owned())
              {
                local_h_min = std::min (cell->diameter(), local_h_min);
              }
          }
      }
    const double global_h_min = Utilities::MPI::min (local_h_min, mpi_communicator);

    unsigned int n_laplacian = 0;
    typename DoFHandler<dim>::active_cell_iterator
    cell = dof_handler.begin_active(),
    endc = dof_handler.end();
    for (; cell!=endc; ++cell)
      if (cell->is_locally_owned())
        {
          ++n_laplacian;

          fe_v.reinit (cell);
          cell->get_dof_indices (dof_indices);

          // Set and adjust coefficients of pseudo and laplacian operators.
          double local_laplacian_coeff = continuation_coeff_laplacian;
          double local_time_coeff = continuation_coeff_time;
          // No adjust need on first step. Use laplacian continuation globally.
          if ((n_time_step > 0) && parameters->enable_partial_laplacian)
            {
              if (laplacian_indicator[cell->active_cell_index()] < laplacian_threshold)
                {
                  // In smooth region, use pseudo time continuation only.
                  local_laplacian_coeff = 0.0;
                  local_time_coeff = continuation_coefficient;
                  --n_laplacian;
                }
            }

          if (parameters->use_local_time_step_size && (local_time_coeff > 0.0))
            {
              local_time_coeff *= (global_h_min/cell->diameter());
            }

          if (parameters->continuation_type == Parameters::StabilizationParameters<dim>::CT_timeCFL)
            {
              local_laplacian_coeff = 0.0;
              local_time_coeff = 1.0/local_time_step_size[cell->active_cell_index()];
            }
          if (local_laplacian_coeff > 0.0)<commit_msg>enable local cell size scaled laplacian continuation coefficient<commit_after>//
//  NSolver::apply_laplacian_continuation.cpp
//
//  Created by <NAME> on 15/11/5.
//  A work based on deal.II tutorial step-33.
//

#include <NSolver/solver/NSolver.h>

namespace NSFEMSolver
{
  using namespace dealii;

  template <int dim>
  void
  NSolver<dim>::apply_laplacian_continuation()
  {
    typedef Sacado::Fad::DFad<double> DFADD;

    // Apply the laplacian operator
    const unsigned int dofs_per_cell = dof_handler.get_fe().dofs_per_cell;
    const unsigned int n_q_points    = quadrature.size();
    std::vector<types::global_dof_index> dof_indices (dofs_per_cell);

    const UpdateFlags update_flags = update_values
                                     | update_gradients
                                     | update_quadrature_points
                                     | update_JxW_values;
    FEValues<dim> fe_v (*mapping_ptr, fe, quadrature, update_flags);

    std::vector<std::vector<Tensor<1,dim> > > grad_W (n_q_points,
                                                      std::vector<Tensor<1,dim> > (EquationComponents<dim>::n_components));
    std::vector<Vector<double> > W (n_q_points,
                                    Vector<double> (EquationComponents<dim>::n_components));
    std::vector<Vector<double> > W_old (n_q_points,
                                        Vector<double> (EquationComponents<dim>::n_components));

    // Find out global minimum cell size
    double local_h_min = std::numeric_limits<double>::max();
    if (parameters->use_local_time_step_size ||
        parameters->use_local_laplacian_coefficient)
      {
        typename DoFHandler<dim>::active_cell_iterator cell =
          dof_handler.begin_active();
        const typename DoFHandler<dim>::active_cell_iterator endc =
          dof_handler.end();
        for (; cell!=endc; ++cell)
          {
            if (cell->is_locally_owned())
              {
                local_h_min = std::min (cell->diameter(), local_h_min);
              }
          }
      }
    const double global_h_min = Utilities::MPI::min (local_h_min, mpi_communicator);

    unsigned int n_laplacian = 0;
    typename DoFHandler<dim>::active_cell_iterator
    cell = dof_handler.begin_active(),
    endc = dof_handler.end();
    for (; cell!=endc; ++cell)
      if (cell->is_locally_owned())
        {
          ++n_laplacian;

          fe_v.reinit (cell);
          cell->get_dof_indices (dof_indices);

          // Set and adjust coefficients of pseudo and laplacian operators.
          double local_laplacian_coeff = continuation_coeff_laplacian;
          double local_time_coeff = continuation_coeff_time;
          // No adjust need on first step. Use laplacian continuation globally.
          if ((n_time_step > 0) && parameters->enable_partial_laplacian)
            {
              if (laplacian_indicator[cell->active_cell_index()] < laplacian_threshold)
                {
                  // In smooth region, use pseudo time continuation only.
                  local_laplacian_coeff = 0.0;
                  local_time_coeff = continuation_coefficient;
                  --n_laplacian;
                }
            }

          if (parameters->use_local_laplacian_coefficient && (local_laplacian_coeff > 0.0))
            {
              local_laplacian_coeff *= (global_h_min/cell->diameter());
            }

          if (parameters->use_local_time_step_size && (local_time_coeff > 0.0))
            {
              local_time_coeff *= (global_h_min/cell->diameter());
            }

          if (parameters->continuation_type == Parameters::StabilizationParameters<dim>::CT_timeCFL)
            {
              local_laplacian_coeff = 0.0;
              local_time_coeff = 1.0/local_time_step_size[cell->active_cell_index()];
            }
          if (local_laplacian_coeff > 0.0)
{'fraction_non_alphanumeric': 0.10108303249097472, 'fraction_numerical': 0.005883139457146677, 'mean_word_length': 2.1441782261454394, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '245466', 'n_tokens_mistral': 2321, 'n_tokens_neox': 2142, 'n_words': 393}