Program Listing for File material_properties.h

Return to documentation for file (include/immersx/physics/material_properties.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_material_properties_h
#define immersx_material_properties_h

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

#include <string>

namespace ImmersX
{
  using namespace dealii;

  struct MaterialProperties : public ParameterAcceptor
  {
    MaterialProperties(
      const std::string &material_tag = "default",
      const std::string &subsection = "/Immersed Problem/Material properties/")
      : ParameterAcceptor(normalize_subsection(subsection) + material_tag + "/")
      , material_tag(material_tag)
    {
      add_parameter("Lame mu", Lame_mu);
      add_parameter("Lame lambda", Lame_lambda);
      add_parameter("Density", rho);
      add_parameter("Viscosity eta", neta);
      add_parameter("Rayleigh alpha", rayleigh_alpha);
      add_parameter("Rayleigh beta", rayleigh_beta);

      parse_parameters_call_back.connect([this]() {
        // Elastic modulus for isotropic materials in 3D
        elastic_modulus =
          Lame_mu * (3 * Lame_lambda + 2 * Lame_mu) / (Lame_lambda + Lame_mu);

        // Poisson ratio for isotropic materials in 3D
        poisson_ratio = Lame_lambda / (2 * (Lame_lambda + Lame_mu));

        // Bulk modulus for isotropic materials in 3D
        bulk_modulus = Lame_lambda + (2.0 / 3.0) * Lame_mu;

        // Shear modulus is just Lame mu
        shear_modulus = Lame_mu;
      });
    }

    static std::string
    normalize_subsection(std::string subsection)
    {
      if (subsection.empty() || subsection == "/")
        return "/";
      if (subsection.front() != '/')
        subsection.insert(subsection.begin(), '/');
      if (subsection.back() != '/')
        subsection.push_back('/');
      return subsection;
    }

    std::string material_tag = "default";
    double Lame_mu = 1.0;
    double Lame_lambda = 1.0;
    double rho = 0.0;
    double neta = 0.0;
    double rayleigh_alpha = 0.0;
    double rayleigh_beta = 0.0;
    double elastic_modulus = 0.0;
    double poisson_ratio = 0.0;
    double bulk_modulus = 0.0;
    double shear_modulus = 0.0;
  };

} // namespace ImmersX

#endif