Page MenuHomec4science

compute_impulse.hh
No OneTemporary

File Metadata

Created
Wed, Jun 12, 02:43

compute_impulse.hh

/**
* @file compute_impulse.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Wed Dec 04 12:14:29 2013
*
* @brief This stimulator sets an initial impulse displacement field that will
* generate a wave
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* LibMultiScale 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.
*
* LibMultiScale 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 LibMultiScale. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef COMPUTE_IMPULSE_H
#define COMPUTE_IMPULSE_H
/* -------------------------------------------------------------------------- */
#include "compute.hh"
#include "lm_parser.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
namespace Impulse {
enum ImpulseType { PLANAR = 1, CIRCULAR = 2 };
}
class ComputeImpulse : public Compute {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
ComputeImpulse(const std::string &name, UInt dim = 1) : Compute(name, 1) {
impulseType = Impulse::PLANAR;
direction = 0;
for (UInt i = 0; i < 3; ++i) {
center[i] = 0.0;
}
};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
//! initialization function
inline void init();
//! most generic stimulate function
template <typename _Input> void build(_Input &cont);
void compute_make_call();
//! return scale deformation impulse provided a scale position
Real computeScaleImpulse(Real d);
void declareParams();
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
//! the direction for planar impulse wave
UInt direction;
//! wavelength of the impulse
Quantity<Length> wave_length;
//! wave number
Real wave_number;
//! intensity factor
Real intensity;
//! radius of the radial impulse
Quantity<Length> radius;
//! code for impulse
std::string impulse;
//! select PLANAR vs RADIAL impulse type
Impulse::ImpulseType impulseType;
//! center of the
Quantity<Length, 3> center;
};
/* -------------------------------------------------------------------------- */
inline void ComputeImpulse::init() { wave_number = 2 * M_PI / wave_length; }
/* -------------------------------------------------------------------------- */
inline Real ComputeImpulse::computeScaleImpulse(Real d) {
const Real k = wave_number;
const Real res = intensity * sin(k * d) * exp(-k * k / 9 * d * d);
DUMP("impulse computed: " << d << " " << k << " " << intensity << " => "
<< res,
DBG_INFO);
return res;
}
/* -------------------------------------------------------------------------- */
template <>
inline UInt Parser::parse(Impulse::ImpulseType &type, std::stringstream &line) {
std::string name;
UInt nb = strNext(name, line);
if (name == "CIRCULAR")
type = Impulse::CIRCULAR;
else if (name == "PLANAR")
type = Impulse::PLANAR;
else
LM_FATAL("unknown impulse type " << name);
return nb;
}
/* -------------------------------------------------------------------------- */
__END_LIBMULTISCALE__
#endif

Event Timeline