Page MenuHomec4science

kelvin_helper.hh
No OneTemporary

File Metadata

Created
Mon, May 13, 18:17

kelvin_helper.hh

/**
* @file
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2017 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Tamaas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef KELVIN_HELPER_HH
#define KELVIN_HELPER_HH
/* -------------------------------------------------------------------------- */
#include "grid.hh"
#include "grid_hermitian.hh"
#include "model_type.hh"
#include "influence.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
namespace detail {
/// Trait for kelvin local types
template <typename T>
struct KelvinTrait;
template <UInt dim>
struct KelvinTrait<influence::Kelvin<dim, 0>> {
using source_t = VectorProxy<Complex, dim>;
using out_t = VectorProxy<Complex, dim>;
};
template <UInt dim>
struct KelvinTrait<influence::Kelvin<dim, 1>> {
using source_t = MatrixProxy<Complex, dim, dim>;
using out_t = VectorProxy<Complex, dim>;
};
template <UInt dim>
struct KelvinTrait<influence::Kelvin<dim, 2>> {
using source_t = MatrixProxy<Complex, dim, dim>;
using out_t = MatrixProxy<Complex, dim, dim>;
};
template <UInt dim>
struct KelvinTrait<influence::Boussinesq<dim, 0>> {
using source_t = VectorProxy<Complex, dim>;
using out_t = VectorProxy<Complex, dim>;
};
template <UInt dim>
struct KelvinTrait<influence::Boussinesq<dim, 1>> {
using source_t = VectorProxy<Complex, dim>;
using out_t = MatrixProxy<Complex, dim, dim>;
};
/// Helper to apply integral representation on output
template <model_type type, typename T>
struct KelvinHelper {
using kelvin_t = T;
using trait = model_type_traits<type>;
static constexpr UInt dim = trait::dimension;
static constexpr UInt bdim = trait::boundary_dimension;
KelvinHelper(const T& kelvin, Real dij, Real dl, Real cutoff)
: kelvin(kelvin), dij(dij), dl(dl), cutoff(cutoff) {}
template <Int yj_xi>
inline void applyIntegral(GridHermitian<Real, bdim>& out,
GridHermitian<Real, bdim>& source,
const Grid<Real, bdim>& wavevectors) const {
Loop::stridedLoop(
[&](typename KelvinTrait<T>::out_t&& out_local,
typename KelvinTrait<T>::source_t&& source_local,
VectorProxy<const Real, bdim>&& q) {
// Cutoff
if (-q.l2norm() * std::abs(dij) < std::log(cutoff))
return;
influence::KelvinIntegrator<1>::integrate<yj_xi>(
out_local, source_local, kelvin, q, dij, dl);
},
out, source, wavevectors);
}
inline void applyFreeTerm(GridHermitian<Real, bdim>& out,
GridHermitian<Real, bdim>& source,
const Grid<Real, bdim>& wavevectors) const {}
const T& kelvin;
const Real dij, dl, cutoff;
};
template <>
inline void
KelvinHelper<model_type::volume_2d, influence::Kelvin<3, 2>>::applyFreeTerm(
GridHermitian<Real, bdim>& out, GridHermitian<Real, bdim>& source,
const Grid<Real, bdim>& wavevectors) const {
Loop::stridedLoop(
[&](KelvinTrait<kelvin_t>::out_t&& out_local,
KelvinTrait<kelvin_t>::source_t&& source_local,
VectorProxy<const Real, bdim>&& q) {
out_local += kelvin.applyDiscontinuityTerm(q, source_local);
},
out, source, wavevectors);
}
} // namespace detail
__END_TAMAAS__
#endif // KELVIN_HELPER_HH

Event Timeline