Page MenuHomec4science

compute_extract_mesh.cc
No OneTemporary

File Metadata

Created
Sat, Oct 19, 23:22

compute_extract_mesh.cc

/**
* @file compute_extract_mesh.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Tue Jul 22 14:47:56 2014
*
* @brief This compute extract data from mesh references
*
* @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 "compute_extract.hh"
#include "lib_continuum.hh"
#include "lib_dd.hh"
#include "lib_md.hh"
#include "lm_common.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
template <typename Cont> void ComputeExtract<Cont>::build(Cont &cont) {
const UInt Dim = Cont::Dim;
this->empty();
UInt cpt = 0;
typename Cont::iterator it = cont.getIterator();
typedef typename Cont::Ref RefPoint;
for (RefPoint at = it.getFirst(); !it.end(); at = it.getNext()) {
++cpt;
}
if (cont.size() != cpt) {
int a = 1;
while (a) {
}
a = cont.size();
for (RefPoint at = it.getFirst(); !it.end(); at = it.getNext()) {
++cpt;
}
LM_FATAL("BBBBBBBBBBBB " << cpt << " " << cont.size());
}
switch (field) {
case _displacement:
buildContainerNodalField<Dim, _displacement>(cont);
break;
case _position0:
buildContainerNodalField<Dim, _position0>(cont);
break;
case _position:
buildContainerNodalField<Dim, _position>(cont);
break;
case _velocity:
buildContainerNodalField<Dim, _velocity>(cont);
break;
case _force:
buildContainerNodalField<Dim, _force>(cont);
break;
case _temperature:
buildContainerNodalField<1, _temperature>(cont);
break;
case _stress:
buildContainerElementalField<Dim * Dim, _stress>(cont);
break;
case _strain:
buildContainerElementalField<Dim * Dim, _strain>(cont);
break;
default:
LM_FATAL("unknown field type " << field);
}
}
/* -------------------------------------------------------------------------- */
template <typename Cont>
template <UInt Dim, FieldType ftype>
void ComputeExtract<Cont>::buildContainerNodalField(Cont &cont) {
if (component >= 0)
this->setDim(1);
else
this->setDim(Dim);
typename Cont::iterator it = cont.getIterator();
typedef typename Cont::Ref RefPoint;
for (RefPoint at = it.getFirst(); !it.end(); at = it.getNext()) {
if (component >= 0)
this->add(at.template field<ftype>()[component]);
else
for (UInt i = 0; i < Dim; ++i) {
this->add(at.template field<ftype>()[i]);
}
}
this->name_computed.clear();
for (UInt i = 0; i < Dim; ++i) {
std::stringstream field_name;
field_name << ftype;
if (Dim > 1)
field_name << i;
this->name_computed.push_back(field_name.str());
}
}
/* -------------------------------------------------------------------------- */
template <typename Cont>
template <UInt Dim, FieldType ftype>
void ComputeExtract<Cont>::buildContainerElementalField(Cont &cont) {
if (component >= 0)
this->setDim(1);
else
this->setDim(Dim);
typename Cont::ContainerElems elements = cont.getContainerElems();
typename Cont::ContainerElems::iterator it = elements.getIterator();
typedef typename Cont::RefElem RefElem;
for (RefElem at = it.getFirst(); !it.end(); at = it.getNext()) {
if (component >= 0)
this->add(at.template field<ftype>(component));
else
for (UInt i = 0; i < Dim; ++i) {
this->add(at.template field<ftype>(i));
}
}
this->name_computed.clear();
for (UInt i = 0; i < Dim; ++i) {
std::stringstream field_name;
field_name << ftype;
if (Dim > 1)
field_name << i;
this->name_computed.push_back(field_name.str());
}
}
/* -------------------------------------------------------------------------- */
DECLARE_COMPUTE_REF(ComputeExtract, LIST_CONTINUUM_MODEL);
__END_LIBMULTISCALE__

Event Timeline