Page MenuHomec4science

compute_impulse.hh
No OneTemporary

File Metadata

Created
Tue, Sep 10, 14:17

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
};
}
template <typename _Input>
class ComputeImpulse : public Compute<_Input>
{
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
ComputeImpulse(const std::string & name, UInt dim=1):Compute<_Input>(name,1){
impulseType = Impulse::PLANAR;
direction = 0;
for (UInt i = 0; i < 3; ++i) {
center[i] = 0.0;
}
};
ComputeImpulse(const std::string & name, ComponentLMInterface & d):
Compute<_Input>(name,d,d.getDim()){
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
void build(_Input & cont);
//! 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;
};
/* -------------------------------------------------------------------------- */
template <typename _Input>
inline void ComputeImpulse<_Input>::init(){
wave_number = 2*M_PI/wave_length;
}
/* -------------------------------------------------------------------------- */
template <typename _Input>
inline Real ComputeImpulse<_Input>::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