Page MenuHomec4science

stimulation_rigidify.cc
No OneTemporary

File Metadata

Created
Sun, Aug 4, 08:43

stimulation_rigidify.cc

/**
* @file stimulation_rigidify.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Wed Jul 09 21:59:47 2014
*
* @brief This stimulator allows to reduce the force to let a group act like a rigid body
*
* @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/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "lm_common.hh"
#include "stimulation_rigidify.hh"
#include "lib_md.hh"
#include "lib_continuum.hh"
#include "lib_dd.hh"
#include "filter.hh"
#include "ref_point_data.hh"
#include "communicator.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
template <typename Cont>
void StimulationRigidify<Cont>::stimulate(Cont & cont, UInt stage)
{
static const UInt Dim = Cont::Dim;
UInt cpt = cont.nbElem();
Real f[Dim];
for (UInt i = 0; i < Dim ; ++i) f[i] = 0.0;
typedef typename Cont::Ref RefDof;
typename Cont::iterator it = cont.getIterator();
for (RefDof at = it.getFirst() ; !it.end() ; at = it.getNext()) {
for (UInt i = 0; i < Dim; ++i) f[i] += at.force(i);
}
//then reduce for multiple processors
Communicator & comm = Communicator::getCommunicator();
CommGroup group = cont.getCommGroup();
comm.allReduce(f,Dim,group,"reduce force",OP_SUM);
comm.allReduce(&cpt,1,group,"reduce number atoms",OP_SUM);
for (UInt i = 0; i < Dim; ++i) f[i] += global_force[i];
for (UInt i = 0; i < Dim; ++i) f[i] /= cpt;
for (RefDof at = it.getFirst() ; !it.end() ; at = it.getNext()) {
for (UInt i = 0; i < Dim; ++i) at.force(i) = f[i]/factor;
}
}
/* -------------------------------------------------------------------------- */
/* LMDESC RIGIDIFY
This stimulator allows to reduce the force acting over a set of degrees of
freedom to a single scalar and assign this last to all forces of that set.
Such a set will then act like a rigid body. More precisely the algorithm is:\\
\begin{equation}
f_{global} = \sum_i f_i + f^{ext}
\end{equation}
\begin{equation}
f_i := \frac{f_{global}}{\#dof \cdot factor}
\end{equation}
where $\#dof$ is the number of dof in the subset $f^{ext}$ (GLOBAL\_FORCE) is an external force
applied onto the rigid body and $factor$ (FACTOR) is a flexibility factor to accelerate
linear motion.
*/
/* LMHERITATE action_interface */
/* LMEXAMPLE STIMULATION rigid RIGIDIFY INPUT md GLOBAL_FORCE 1 0 0 MASS_FACTOR 1e-3 */
//! most generic stimulate function
template <typename Cont>
void StimulationRigidify<Cont>::declareParams(){
Stimulation<Cont>::declareParams();
this->changeDefault("STAGE",PRE_STEP3);
/* LMKEYWORD GLOBAL_FORCE
Specifiy the external force to be applied to the rigid body.
*/
this->parseVectorKeyword("GLOBAL_FORCE",spatial_dimension,global_force);
/* LMKEYWORD FACTOR
Correction factor to augment/reduce the forces applied to the rigid body.
*/
this->parseKeyword("FACTOR",factor,1.);
}
/* -------------------------------------------------------------------------- */
DECLARE_STIMULATION(StimulationRigidify,LIST_ATOM_MODEL)
DECLARE_STIMULATION(StimulationRigidify,LIST_CONTINUUM_MODEL)
DECLARE_STIMULATION(StimulationRigidify,LIST_DD_MODEL)
DECLARE_STIMULATION_REFPOINT(StimulationRigidify)
DECLARE_STIMULATION_GENERIC_MESH(StimulationRigidify)
__END_LIBMULTISCALE__

Event Timeline