Page MenuHomec4science

filter_geometry_mesh.cc
No OneTemporary

File Metadata

Created
Mon, Jul 22, 15:20

filter_geometry_mesh.cc

/**
* @file filter_geometry_mesh.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Srinivasa Babu Ramisetti <srinivasa.ramisetti@epfl.ch>
*
* @date Thu Jul 24 14:21:58 2014
*
* @brief This filter allows to select DOFs based on geometrical criteria
*
* @section LICENSE
*
* Copyright INRIA and CEA
*
* The LibMultiScale is a C++ parallel framework for the multiscale
* coupling methods dedicated to material simulations. This framework
* provides an API which makes it possible to program coupled simulations
* and integration of already existing codes.
*
* This Project was initiated in a collaboration between INRIA Futurs Bordeaux
* within ScAlApplix team and CEA/DPTA Ile de France.
* The project is now continued at the Ecole Polytechnique Fédérale de Lausanne
* within the LSMS/ENAC laboratory.
*
* This software is governed by the CeCILL-C license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL-C
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C license and that you accept its terms.
*
*/
/* -------------------------------------------------------------------------- */
#include "lm_common.hh"
#include "lib_continuum.hh"
#include "filter_geometry.hh"
#include "geometry.hh"
#include "geometry_manager.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
template <typename Cont>
void FilterGeometry<Cont>::build(Cont & cont){
const UInt Dim = Cont::Dim;
if (this->nbElem() && !current_position_flag) return;
if(!do_not_reset_boundingbox_flag)
this->getBoundingBox().resetDimensions();
if(based_on_nodes_flag){
buildBasedOnNodes<Dim>(cont);
return;
}
Geometry * g = GeometryManager::getManager().getGeometry(geom);
this->empty();
std::vector<UInt> connectivity;
typename Cont::ContainerElems & contElems = cont.getContainerElems();
typename Cont::ContainerNodes & contNodes = cont.getContainerNodes();
typename FilterGeometry<Cont>::ContainerElems & contElemsFiltered =
this->getContainerElems();
typename Cont::ContainerElems::Ref el;
typename Cont::ContainerNodes::Ref nd;
// first filter the elements
typename Cont::ContainerElems::iterator itElem = contElems.getIterator(this->dt);
for(el = itElem.getFirst() ; !itElem.end() ; el = itElem.getNext()) {
el.globalIndexes(connectivity);
UInt nb_nodes = connectivity.size();
bool test = false;
if(centroid_flag){
Real centriod[3]={0,0,0};
for (UInt i=0; i< nb_nodes ; ++i) {
nd = contNodes.get(connectivity[i]);
auto X = nd.position0();
for(UInt j=0;j<Dim;++j)
centriod[j]+=X[j];
}
for(UInt j=0;j<Dim;++j){
centriod[j]/=nb_nodes;
}
test = test | g->contains<Dim>(centriod);
}
else {
std::vector<Real> node_coords;
for (UInt i=0; i< nb_nodes ; ++i) {
nd = contNodes.get(connectivity[i]);
auto X = nd.position0();
test = test | g->contains<Dim>(X);
}
}
if(test) contElemsFiltered.add(el);
}
// recompute connectivity in altered connectivity
this->computeAlteredConnectivity(contNodes);
// reshape the geometry
if(!do_not_reset_boundingbox_flag){
typename FilterGeometry<Cont>::ContainerNodes::iterator itNodes =
this->getContainerNodes().getIterator(this->dt);
for (nd = itNodes.getFirst(); !itNodes.end(); nd = itNodes.getNext()){
auto X = nd.position0();
this->getBoundingBox().extendBoundingBox(X);
}
}
}
/* -------------------------------------------------------------------------- */
template <typename T>
template <UInt Dim, typename Cont>
void FilterGeometry<T>::buildBasedOnNodes(Cont & cont){
this->empty();
Geometry * g = GeometryManager::getManager().getGeometry(geom);
typename Cont::iterator it = cont.getIterator(this->dt);
typename Cont::Ref at;
for(at = it.getFirst() ; !it.end() ; at = it.getNext()) {
auto positions0 = at.position0();
DUMP("Testing point at position " << at.position0(),DBG_ALL);
if (g->contains<Dim>(positions0)) {
if(!do_not_reset_boundingbox_flag)
this->getBoundingBox().extendBoundingBox(positions0);
DUMP("Accepting atom " << at,DBG_ALL);
Filter<T>::add(at);
}
}
#ifndef LM_OPTIMIZED
UInt nb = Filter<T>::nbElem();
#endif // LM_OPTIMIZED
DUMP("le filter a trouve " << nb << " atoms in geometry " << *g,DBG_INFO);
}
/* -------------------------------------------------------------------------- */
DECLARE_FILTER(FilterGeometry,LIST_CONTINUUM_MODEL)
__END_LIBMULTISCALE__

Event Timeline