Hi,
I want to get a patch of all elements and initialize a new submesh with
these elements.
Say all the neighbors of one element (I didnt use the neighbor iterator
because later I will have different types of patchs)
So this is what I did,
////---------------------------------------------------------------------
const_active_local_elem_iterator elem_it (mesh.elements_begin());
const const_active_local_elem_iterator elem_end(mesh.elements_end());
for (; elem_it != elem_end; ++elem_it)
{
const Elem* input_el= *elem_it;
Mesh patch_mesh (2);
// a vector to store the patch elements
std::vector<const Elem *> elements_patch;
elements_patch.reserve(input_el->n_neighbors()+1);
// insert the element itself
elements_patch.push_back(input_el);
for (unsigned int n_e=0; n_e<input_el->n_neighbors(); n_e++)
if (input_el->neighbor(n_e) != NULL)
{
Elem* ef = input_el->neighbor(n_e);
elements_patch.push_back(ef);
} // end neighbors
// create iterators to pass it to create_submesh
const_elem_iterator
it(std::make_pair( elements_patch.begin(),
elements_patch.end()));
const const_elem_iterator
it_end(std::make_pair( ((std::vector<const Elem*>*)
&elements_patch)->end(),
((std::vector<const Elem*>*)
&elements_patch)->end()));
mesh.create_submesh (patch_mesh, it, it_end);
patch_mesh.print_info();
} // end of elem_it
//-------------------------------------------------------------------------------
So far everything works fine and the patch_mesh.print_info(); shows a
correct size of the patch.
When I try to extract infromation from the patch_mesh I used
const_active_local_elem_iterator pelem_it
(patch_mesh.elements_begin());
const const_active_local_elem_iterator
pelem_end(patch_mesh.elements_end());
for (; pelem_it != pelem_end; ++pelem_it)
{
const Elem* e = *pelem_it;
e->write_tecplot_connectivity(std::cout);
for (unsigned int n=0; n<e->n_nodes(); n++) e->point(n).print();
}
But I got an error related to the iterators. I'll attach it at the end
of
this email.
Any advice of what I am missing.
Ahmed
///// ------------------- compilation errors
/usr/local/include/c++/3.3.3/bits/stl_pair.h: In constructor
`std::pair<_T1,
_T2>::pair(const std::pair<_U1, _U2>&) [with _U1 =
__gnu_cxx::__normal_iterator<Elem**, std::vector<Elem*,
std::allocator<Elem*> > >, _U2 = __gnu_cxx::__normal_iterator<Elem**,
std::vector<Elem*, std::allocator<Elem*> > >, _T1 =
__gnu_cxx::__normal_iterator<const Elem* const*, std::vector<const
Elem*,
std::allocator<const Elem*> > >, _T2 =
__gnu_cxx::__normal_iterator<const
Elem* const*, std::vector<const Elem*, std::allocator<const Elem*> >
>]':
/work/elsheiam/libmesh/include/mesh/elem_iterators.h:851: instantiated
from here
/usr/local/include/c++/3.3.3/bits/stl_pair.h:88: error: no matching
function
for call to `__gnu_cxx::__normal_iterator<const Elem* const*,
std::vector<const Elem*, std::allocator<const Elem*> >
>::__normal_iterator(
const __gnu_cxx::__normal_iterator<Elem**, std::vector<Elem*,
std::allocator<Elem*> > >&)'
/usr/local/include/c++/3.3.3/bits/stl_iterator.h:580: error: candidates
are:
__gnu_cxx::__normal_iterator<const Elem* const*, std::vector<const
Elem*,
std::allocator<const Elem*> > >::__normal_iterator(const
__gnu_cxx::__normal_iterator<const Elem* const*, std::vector<const
Elem*,
std::allocator<const Elem*> > >&)
/usr/local/include/c++/3.3.3/bits/stl_iterator.h:593: error:
__gnu_cxx::__normal_iterator<_Iterator,
_Container>::__normal_iterator(const
_Iterator&) [with _Iterator = const Elem* const*, _Container =
std::vector<const Elem*, std::allocator<const Elem*> >]
/usr/local/include/c++/3.3.3/bits/stl_iterator.h:590: error:
__gnu_cxx::__normal_iterator<_Iterator,
_Container>::__normal_iterator()
[with _Iterator = const Elem* const*, _Container = std::vector<const
Elem*,
std::allocator<const Elem*> >]
/usr/local/include/c++/3.3.3/bits/stl_pair.h:88: error: no matching
function
for call to `__gnu_cxx::__normal_iterator<const Elem* const*,
std::vector<const Elem*, std::allocator<const Elem*> >
>::__normal_iterator(
const __gnu_cxx::__normal_iterator<Elem**, std::vector<Elem*,
std::allocator<Elem*> > >&)'
/usr/local/include/c++/3.3.3/bits/stl_iterator.h:580: error: candidates
are:
__gnu_cxx::__normal_iterator<const Elem* const*, std::vector<const
Elem*,
std::allocator<const Elem*> > >::__normal_iterator(const
__gnu_cxx::__normal_iterator<const Elem* const*, std::vector<const
Elem*,
std::allocator<const Elem*> > >&)
/usr/local/include/c++/3.3.3/bits/stl_iterator.h:593: error:
__gnu_cxx::__normal_iterator<_Iterator,
_Container>::__normal_iterator(const
_Iterator&) [with _Iterator = const Elem* const*, _Container =
std::vector<const Elem*, std::allocator<const Elem*> >]
/usr/local/include/c++/3.3.3/bits/stl_iterator.h:590: error:
__gnu_cxx::__normal_iterator<_Iterator,
_Container>::__normal_iterator()
[with _Iterator = const Elem* const*, _Container = std::vector<const
Elem*,
std::allocator<const Elem*> >]
|