Page MenuHomec4science

dof_association.hh
No OneTemporary

File Metadata

Created
Wed, Jul 17, 11:05

dof_association.hh

/**
* @file dof_association.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Tue Jan 21 12:37:46 2014
*
* @brief Mother of all object which associates DOFs for coupling purpose
*
* @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 __LIBMULTISCALE_DOF_ASSOCIATION_HH__
#define __LIBMULTISCALE_DOF_ASSOCIATION_HH__
/* -------------------------------------------------------------------------- */
#include "spatial_grid_libmultiscale.hh"
#include "lm_parsable.hh"
#include "duo_distributed_vector.hh"
#include "compute_extract.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
template <typename ContainerA, typename ContainerB, UInt Dim>
class DofAssociation : public Parsable {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
DofAssociation(const std::string & name, ContainerA & cA,ContainerB & cB);
virtual ~DofAssociation();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
//! set the name of the bridging zone (usefull for dumped files)
void setID(const std::string & name){
ID = name;
};
//! return the name of the bridging zone (usefull for dumped files)
const std::string & getID(){
return ID;
};
//! method to clear every data or object allocated (for a reuse)
virtual void clearAll() = 0;
//! Init this object : select DOFs, associate them and compute shapematrix
virtual void init() = 0;
//! delete grid structure to sort elements
void deleteGrid();
//! return the local number of points (parallel safe)
UInt getLocalPoints();
protected:
void declareParams();
/* ------------------------------------------------------------------------ */
/* Parallel Methods */
/* ------------------------------------------------------------------------ */
public:
//! function used to redistribute a vector from A to B
void distributeVectorA2B(const std::string & name_vec,std::vector<Real> & vec,
UInt stride=1);
//! function used to redistribute a vector from B to A
void distributeVectorB2A(const std::string & name_vec,std::vector<Real> & vec,
UInt stride=1);
//! function used to synchronize vectors (by summing them)
void synchronizeVectorBySum(const std::string & name_vec,std::vector<Real> & vec,
UInt stride=1);
//! function used update the duo vector for migrations
void synchronizeMigration(CommGroup group1,CommGroup group2);
//! return the association vector
UInt getAssoc(UInt i){return assoc[i];};
protected:
//! exchange geometries: for coarse desc of communication scheme
template <typename ContA,typename ContB>
void exchangeGeometries(ContA & subA, ContB & subB);
void exchangeGeometries(Cube& cube);
//! exchange points positions following coarse description
void exchangePositions();
//! exchange association information for full communication scheme description
void exchangeAssociationInformation(std::vector<UInt> & managed);
//! exchange duplicate points info from A processors to B ones
void exchangeRejectedContinuumOwners(std::vector<std::vector<UInt> > & unassociated_points);
void createDuoVectorA(const std::string & name,
std::vector<UInt> & managed,
std::vector<std::vector<UInt> > & unassociated_points);
//! create duo vector
void createDuoVectorB(const std::string & name);
//! get duo vector
DuoDistributedVector & getDuoVector();
//! extract a position vector from a subset container
template <typename ContA> void buildPositions(ContA & sub);
//! filter associations so that removed DOF are acknowledged
void filterAssoc();
private:
void exchangeNbPointsPerProc();
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
//! the spatial grid used to speedup the association build
SpatialGridLibMultiScale<UInt,Dim> * grid;
//! ID given to the zone
std::string ID;
// to parametrize the grid to speed search (decomposition in each direction)
UInt grid_division[3];
//! Container of whatever
ContainerA & contA;
//! Container of whatever
ContainerB & contB;
//! the intersection geometry ID
GeomID geomID;
//! parallel id of group A
CommGroup comm_group_A;
//! parallel id of group B
CommGroup comm_group_B;
//! array that specifies what processor I should communicate with
std::vector<UInt> com_with;
//! total number of points in the associated zone
UInt total_points;
//! array that specifies the number of points per proc
std::vector<UInt> nb_points_per_proc;
//! generated positions (by BuildPosition method)
std::vector<Real> positions;
//! local atoms in the bridged zone
UInt local_points;
//! association vector
std::vector<UInt> assoc;
//! number of processors in zone A
UInt nb_zone_A;
//! number of processors in zone B
UInt nb_zone_B;
//! am i in group A
bool in_group_A;
//! am i in group B
bool in_group_B;
private:
//! duodistributed vector used to synchronize vectors/matrices
DuoDistributedVector * duo_vector;
};
/* -------------------------------------------------------------------------- */
template <typename ContainerA, typename ContainerB, UInt Dim>
template <typename ContA,typename ContB>
void DofAssociation<ContainerA, ContainerB, Dim>::
exchangeGeometries(ContA & subA, ContB & subB){
if (comm_group_A == comm_group_B) return;
Cube localGeom;
if(in_group_A) localGeom = subA.getBoundingBox();
if(in_group_B) localGeom = subB.getBoundingBox();
exchangeGeometries(localGeom);
}
/* -------------------------------------------------------------------------- */
template <typename ContainerA, typename ContainerB, UInt Dim>
template <typename ContA>
void DofAssociation<ContainerA,ContainerB,Dim>::buildPositions(ContA & sub){
ComputeExtract<ContA> c_positions("ComputeExtract:"+this->getID(),Dim);
c_positions.setParam("FIELD",_position0);
c_positions.manualBuild(sub);
this->positions = c_positions;
}
/* -------------------------------------------------------------------------- */
__END_LIBMULTISCALE__
#endif /* __LIBMULTISCALE_DOF_ASSOCIATION_HH__ */

Event Timeline