Program Listing for File elasticity_freq_problem_parameters.h

↰ Return to documentation for file (include/immersx/physics/elasticity_freq_problem_parameters.h)

// ---------------------------------------------------------------------
//
// Copyright (C) 2024 by Luca Heltai
//
// This file is part of the ImmersX application, based on
// the deal.II library.
//
// The ImmersX application is free software; you can use
// it, redistribute it, and/or modify it under the terms of the Apache-2.0
// License WITH LLVM-exception as published by the Free Software Foundation;
// either version 3.0 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE.md at the top
// level of the ImmersX distribution.
//
// ---------------------------------------------------------------------

#ifndef immersx_elasticity_freq_problem_parameters_h
#define immersx_elasticity_freq_problem_parameters_h

#include <deal.II/base/parameter_acceptor.h>
#include <deal.II/base/patterns.h>
#include <deal.II/base/types.h>

#include <deal.II/lac/solver_control.h>

#include <immersx/core/domain.h>
#include <immersx/physics/material_properties.h>
#include <immersx/physics/modulated_parsed_function.h>

#include <array>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>

namespace ImmersX
{
  template <int dim, int spacedim = dim>
  class ElasticityFreqProblemParameters : public ParameterAcceptor
  {
    std::vector<double> owned_frequencies{100.0};

  public:
    explicit ElasticityFreqProblemParameters(
      const std::string   &subsection         = "/Immersed Problem/",
      std::vector<double> *shared_frequencies = nullptr);

    const MaterialProperties &
    get_material_properties(const types::material_id material_id) const;

    const ModulatedParsedFunction<spacedim> &
    get_dirichlet_bc(const types::boundary_id boundary_id) const;

    const ModulatedParsedFunction<spacedim> &
    get_neumann_bc(const types::boundary_id boundary_id) const;

    const Functions::ParsedFunction<spacedim> &
    get_robin_coefficient(const types::boundary_id boundary_id) const;

    const ModulatedParsedFunction<spacedim> &
    get_robin_bc(const types::boundary_id boundary_id) const;

    const ModulatedParsedFunction<spacedim> &
    get_rhs(const types::material_id material_id) const;

    void
    set_rhs_times(const double time) const;

    void
    set_boundary_condition_times(const double time) const;

    void
    validate_parameters();

    DomainParameters<dim, spacedim> domain_parameters;

    std::vector<double> &frequencies;
    double dirichlet_phase = 0.0, neumann_phase = 0.0, rhs_phase = 0.0;
    std::map<types::boundary_id, double> dirichlet_phase_by_id,
      neumann_phase_by_id;
    std::map<types::material_id, double> rhs_phase_by_id;
    double                               robin_phase = 0.;
    std::map<types::boundary_id, double> robin_phase_by_id;
    unsigned int                         gmres_basis_size = 200;

    std::string   output_directory = ".";
    std::string   output_name      = "solution";
    unsigned int  fe_degree        = 1;
    unsigned int &initial_refinement =
      domain_parameters.initial_refinement;
    std::set<types::boundary_id> dirichlet_ids{0};
    std::set<types::boundary_id> weak_dirichlet_ids{};
    std::set<types::boundary_id> neumann_ids{};
    std::set<types::boundary_id> normal_flux_ids{};
    std::set<types::boundary_id> robin_ids{};

    MaterialProperties default_material_properties;
    std::map<types::material_id, std::string>
      material_tags_by_material_id;

    std::map<types::material_id, std::unique_ptr<MaterialProperties>>
      material_properties_by_id;
    std::set<types::material_id> rhs_material_ids{};

    std::string  domain_type = "generate";
    std::string &triangulation_type =
      domain_parameters.triangulation_type;
    std::string &name_of_grid =
      domain_parameters.name_of_grid;
    std::string &arguments_for_grid =
      domain_parameters.arguments_for_grid;
    double     &grid_scale = domain_parameters.grid_scale;
    std::string refinement_strategy =
      "fixed_fraction";
    double       coarsening_fraction = 0.0;
    double       refinement_fraction = 0.3;
    unsigned int n_refinement_cycles = 1;
    unsigned int max_cells           = 20000;
    double       penalty_term        = 1.0e4;

  private:
    const std::string function_prefix;
    const std::string material_prefix;

  public:
    mutable ModulatedParsedFunction<spacedim> rhs;
    std::map<types::material_id,
             std::shared_ptr<ModulatedParsedFunction<spacedim>>>
      rhs_by_material_id;

    mutable ModulatedParsedFunction<spacedim> bc;
    std::map<types::boundary_id,
             std::shared_ptr<ModulatedParsedFunction<spacedim>>>
      dirichlet_bc_by_id;

    mutable ModulatedParsedFunction<spacedim>
      Neumann_bc;
    std::map<types::boundary_id,
             std::shared_ptr<ModulatedParsedFunction<spacedim>>>
      neumann_bc_by_id;
    mutable ParameterAcceptorProxy<Functions::ParsedFunction<spacedim>>
      robin_coefficient;
    std::map<types::boundary_id,
             std::shared_ptr<
               ParameterAcceptorProxy<Functions::ParsedFunction<spacedim>>>>
                                              robin_coefficient_by_id;
    mutable ModulatedParsedFunction<spacedim> robin_bc;
    std::map<types::boundary_id,
             std::shared_ptr<ModulatedParsedFunction<spacedim>>>
      robin_bc_by_id;

    mutable ParameterAcceptorProxy<ReductionControl>
      displacement_solver_control;

  private:
    std::map<types::boundary_id, std::array<bool, 3>>
      robin_coefficient_entries_set;
  };

} // namespace ImmersX

#endif