}
compute_number_cache (*this, levels.size(), number_cache);
-
+
// now verify that there are indeed
// no distorted cells. as per the
// documentation of this class, we
much bigger than the minimal data required, but it makes the code more readable.
*/
- if (dim < spacedim) {
-
- Table<2,bool> correct(GeometryInfo< dim >::faces_per_cell,
- GeometryInfo< dim >::faces_per_cell);
- switch (dim)
- {
- case 1:
- {
- bool values [][2] = {{false,true},
- {true,false} };
- for (unsigned int i=0; i< GeometryInfo< dim >::faces_per_cell; ++i)
- for (unsigned int j=0; j< GeometryInfo< dim >::faces_per_cell; ++j)
- correct(i,j) = ( values[i][j]);
- break;
- }
- case 2:
+ if (dim < spacedim)
+ {
+ Table<2,bool> correct(GeometryInfo< dim >::faces_per_cell,
+ GeometryInfo< dim >::faces_per_cell);
+ switch (dim)
{
- bool values [][4]= {{false,true ,true , false},
- {true ,false,false, true },
- {true ,false,false, true },
- {false,true ,true , false} };
- for (unsigned int i=0; i< GeometryInfo< dim >::faces_per_cell; ++i)
- for (unsigned int j=0; j< GeometryInfo< dim >::faces_per_cell; ++j)
- correct(i,j) = ( values[i][j]);
- break;
+ case 1:
+ {
+ bool values [][2] = {{false,true},
+ {true,false} };
+ for (unsigned int i=0; i< GeometryInfo< dim >::faces_per_cell; ++i)
+ for (unsigned int j=0; j< GeometryInfo< dim >::faces_per_cell; ++j)
+ correct(i,j) = ( values[i][j]);
+ break;
+ }
+ case 2:
+ {
+ bool values [][4]= {{false,true ,true , false},
+ {true ,false,false, true },
+ {true ,false,false, true },
+ {false,true ,true , false} };
+ for (unsigned int i=0; i< GeometryInfo< dim >::faces_per_cell; ++i)
+ for (unsigned int j=0; j< GeometryInfo< dim >::faces_per_cell; ++j)
+ correct(i,j) = ( values[i][j]);
+ break;
+ }
+ default:
+ Assert (false, ExcNotImplemented());
}
- default:
- Assert (false, ExcNotImplemented());
- }
- std::list<active_cell_iterator> this_round, next_round;
- active_cell_iterator neighbor;
+ std::list<active_cell_iterator> this_round, next_round;
+ active_cell_iterator neighbor;
- this_round.push_back (begin_active());
- begin_active()->set_direction_flag (true);
- begin_active()->set_user_flag ();
+ this_round.push_back (begin_active());
+ begin_active()->set_direction_flag (true);
+ begin_active()->set_user_flag ();
- while (this_round.size() > 0)
- {
- for ( typename std::list<active_cell_iterator>::iterator cell = this_round.begin();
- cell != this_round.end(); ++cell)
- {
- for (unsigned int i = 0; i < GeometryInfo< dim >::faces_per_cell; ++i)
- {
- if ( !((*cell)->face(i)->at_boundary()) )
- {
- neighbor = (*cell)->neighbor(i);
+ while (this_round.size() > 0)
+ {
+ for ( typename std::list<active_cell_iterator>::iterator cell = this_round.begin();
+ cell != this_round.end(); ++cell)
+ {
+ for (unsigned int i = 0; i < GeometryInfo< dim >::faces_per_cell; ++i)
+ {
+ if ( !((*cell)->face(i)->at_boundary()) )
+ {
+ neighbor = (*cell)->neighbor(i);
- unsigned int cf = (*cell)->face_index(i);
- unsigned int j = 0;
- while(neighbor->face_index(j) != cf)
- {++j;}
+ unsigned int cf = (*cell)->face_index(i);
+ unsigned int j = 0;
+ while(neighbor->face_index(j) != cf)
+ {++j;}
- if ( (correct(i,j) && !(*cell)->direction_flag())
- ||
- (!correct(i,j) && (*cell)->direction_flag()) )
- {
- if (neighbor->user_flag_set() == false)
- {
- neighbor->set_direction_flag (false);
- neighbor->set_user_flag ();
- next_round.push_back (neighbor);
- }
- else
- Assert (neighbor->direction_flag() == false,
- ExcNonOrientableTriangulation());
-
- }
- }
- }
- }
+ if ( (correct(i,j) && !(*cell)->direction_flag())
+ ||
+ (!correct(i,j) && (*cell)->direction_flag()) )
+ {
+ if (neighbor->user_flag_set() == false)
+ {
+ neighbor->set_direction_flag (false);
+ neighbor->set_user_flag ();
+ next_round.push_back (neighbor);
+ }
+ else
+ Assert (neighbor->direction_flag() == false,
+ ExcNonOrientableTriangulation());
- // Before we quit let's check
- // that if the triangulation
- // is disconnected that we
- // still get all cells
- if (next_round.size() == 0)
- for (active_cell_iterator cell = begin_active();
- cell != end(); ++cell)
- if (cell->user_flag_set() == false)
- {
- next_round.push_back (cell);
- cell->set_direction_flag (true);
- cell->set_user_flag ();
- break;
+ }
+ }
+ }
}
- this_round = next_round;
- next_round.clear();
+ // Before we quit let's check
+ // that if the triangulation
+ // is disconnected that we
+ // still get all cells
+ if (next_round.size() == 0)
+ for (active_cell_iterator cell = begin_active();
+ cell != end(); ++cell)
+ if (cell->user_flag_set() == false)
+ {
+ next_round.push_back (cell);
+ cell->set_direction_flag (true);
+ cell->set_user_flag ();
+ break;
+ }
+
+ this_round = next_round;
+ next_round.clear();
+ }
}
- }
+
+ // inform all listeners that the
+ // triangulation has been created
+ typename std::list<RefinementListener *>::iterator
+ ref_listener = refinement_listeners.begin (),
+ end_listener = refinement_listeners.end ();
+ for (; ref_listener != end_listener; ++ref_listener)
+ (*ref_listener)->create_notification (*this);
}
+template<int dim, int spacedim>
+void Triangulation<dim, spacedim>::
+RefinementListener::create_notification (const Triangulation<dim, spacedim> &)
+{}
+
+
+
template<int dim, int spacedim>
void
Triangulation<dim, spacedim>::add_refinement_listener (RefinementListener &listener) const
--- /dev/null
+//---------------------------- crash_20.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2005, 2006, 2011 by the deal.II authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- crash_20.cc ---------------------------
+
+
+// if the mesh is generated after the hp::DoFHandler is attached to the
+// triangulation object, then we can't set active fe indices -- which is
+// somewhat tragic since we have to assign active fe indices before we can
+// call distribute_dofs
+//
+// originally, this problem was avoided because the hp::DoFHandler listens to
+// the refinement listener signal to rebuild its data structures; so if you
+// create a triangulation object, attach the hp::DoFHandler, create a coarse
+// mesh, then refine the mesh, everything is ok again. the solution is to also
+// listen to the creation of triangulations.
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_accessor.h>
+#include <grid/grid_out.h>
+#include <grid/tria_iterator.h>
+#include <hp/dof_handler.h>
+#include <dofs/dof_accessor.h>
+#include <fe/fe_dgq.h>
+
+#include <fstream>
+
+
+
+template <int dim>
+void test ()
+{
+ Triangulation<dim> tria;
+ hp::DoFHandler<dim> dof_handler(tria);
+
+ GridGenerator::hyper_cube(tria);
+
+ for (typename hp::DoFHandler<dim>::active_cell_iterator
+ cell=dof_handler.begin_active();
+ cell!=dof_handler.end(); ++cell)
+ cell->set_active_fe_index (0);
+}
+
+
+int main ()
+{
+ std::ofstream logfile("crash_20/output");
+ logfile.precision(2);
+
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ test<1> ();
+ test<2> ();
+ test<3> ();
+
+ deallog << "OK" << std::endl;
+}