Page MenuHomec4science

stimulation_field_mesh.cc
No OneTemporary

File Metadata

Created
Sat, Nov 16, 13:37

stimulation_field_mesh.cc

/**
* @file stimulation_field_mesh.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Till Junge <till.junge@epfl.ch>
*
* @date Fri Jul 25 11:42:31 2014
*
* @brief Impose a field to a set of DOFs
*
* @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_field.hh"
#include "lib_md.hh"
#include "lib_dd.hh"
#include "lib_continuum.hh"
#include "filter_manager.hh"
#include "compute.hh"
#include "filter.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
template <typename Cont>
void StimulationField<Cont>::stimulate(Cont & cont, UInt stage) {
static const UInt Dim = Cont::Dim;
switch (ftype){
case _position0: stimulateField<Dim,_position0>(cont);break;
case _position: stimulateField<Dim,_position>(cont);break;
case _displacement: stimulateField<Dim,_displacement>(cont);break;
case _velocity: stimulateField<Dim,_velocity>(cont);break;
case _force: stimulateField<Dim,_force>(cont);break;
case _temperature: stimulateField<1,_temperature>(cont);break;
default: LM_FATAL("cannot treat field type \"" << ftype << "\"");
}
}
/* -------------------------------------------------------------------------- */
template <typename Cont>
template <UInt Dim,FieldType type>
void StimulationField<Cont>::stimulateField(Cont & cont){
if (cont.size() == 0) return;
ComputeInterface * ptr =
dynamic_cast<ComputeInterface *>(FilterManager::getManager().getObject(compute_id));
if (!ptr) LM_FATAL("invalid compute id: " << compute_id);
ptr->build();
UInt dim_compute = ptr->getDim();
if (dim_compute != Dim)
LM_FATAL(this->getID() << ": incompatible dimensions " << dim_compute << " != " << Dim
<< " cont size: " << cont.size() << " compute size: " << ptr->size());
if (ptr->nbElem()/dim_compute != cont.nbElem())
LM_FATAL(this->getID() << ": compute or filter contains " << ptr->nbElem()/dim_compute << " entries"
<< " while container have " << cont.nbElem() << " : incompatible match");
ComputeInterface & comp = *ptr;
typedef typename Cont::Ref RefDof;
typename Cont::iterator it = cont.getIterator();
typename ComputeInterface::iterator itCompute = comp.getIterator();
Real val = itCompute.getFirst();
if (this->additive_flag) {
for(RefDof at = it.getFirst(); !it.end(); at = it.getNext()) {
for (UInt i = 0; i < Dim; ++i){
at.template field<type>(i) = val + at.template field<type>(i);
val = itCompute.getNext();
}
}
} else {
for(RefDof at = it.getFirst(); !it.end(); at = it.getNext()) {
for (UInt i = 0; i < Dim; ++i){
at.template field<type>(i) = val;
val = itCompute.getNext();
}
}
}
}
/* -------------------------------------------------------------------------- */
DECLARE_STIMULATION(StimulationField,LIST_CONTINUUM_MODEL)
__END_LIBMULTISCALE__

Event Timeline