[dune-pdelab] Reg.: Data Map in parallel
Shubhangi Gupta
sgupta at geomar.de
Fri Aug 28 19:00:03 CEST 2020
Dear all,
After reading the mesh and getting the grid view, I construct a 'map'
where I attach a struct (of one integer id and one neighbour codim 0
entity) to each (codim 0) element of the mesh.
The problem is, in parallel this map breaks down and I get segmentation
fault.
Can somebody give me hints on what I should do here?
Thanks, and warm wishes, Shubhangi
PS: Here's some parts of my code for reference:
*In driver:*
// MESH
const int dim =2;
using GridType = Dune::UGGrid<dim>;
MeshParameters meshparam;
ImplicitSurfaceMesh2DQuad<GridType,MeshParameters> reactor(meshparam);
reactor.grid().globalRefine(0);
using GV = GridType::LeafGridView;
GV gv = reactor.grid().leafGridView();
reactor.grid().loadBalance();
//GFS
.....
// BEGIN MAPPING
SomeMap<GFS,GV,PTree> map(gfs, gv, ptree);
map.get_map();
// LOP
using LOP = LocalOperator< GV, SomeMap<GFS,GV,PTree>, GFS, U >;
// spatial part
LOP lop( gv, map, gfs, &u_new);
*In map.hh:*
template<typename GFS,typename GV,typename PTree>
class SomeMap {
private:
GFS gfs;
const GV& gv;
const PTree& ptree;
public:
typedef Dune::PDELab::LocalFunctionSpace<GFS> LFS;
typedef typename GV::IndexSet IndexSet;
static const int dim = GV::dimension;
typedef typename GV::Grid::template Codim<0>::Entity Element;
typedef typename GV::Traits::template Codim<0>::Iterator
ElementIterator;
typedef typename GV::IntersectionIterator IntersectionIterator;
SomeMap(GFS gfs_, const GV& gv_, const PTree& ptree_ ): gfs(gfs_),
gv(gv_), ptree(ptree_) {
const IndexSet &indexSet = gv.indexSet();
int NumElements = indexSet.size(0);
Map = std::vector<MapEntries> ( NumElements );
}
virtual ~SomeMap(){}
struct MapEntries{
bool is_L;
Element L_elem;
};
std::vector<MapEntries> Map;
void get_map(){
const IndexSet &indexSet = gv.indexSet();
ElementIterator begin = gv.template begin<0>();
ElementIterator end = gv.template end<0>();
for ( ElementIterator self = begin; self!= end; ++self )
{
int elementNumber = indexSet.index(*self);
bool flag = false; //DEFAULT
Element elem = (*self); //initialized with self entity
(interation over edges...)
if(some condition){
flag = true;
elem = some_neighbour;
}
MapEntries newEntry;
newEntry.is_L = flag;
newEntry.L_elem = elem;
Map.at( elementNumber ) = newEntry;
}//end:: ElementIterator
}//end: get_map()
};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dune-project.org/pipermail/dune-pdelab/attachments/20200828/7e1a6093/attachment.htm>
More information about the dune-pdelab
mailing list