// $Id$
// Version: $Name$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008 by the deal.II authors
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2010 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
param.declare_entry("Write all faces", "true", Patterns::Bool(),
"Write all faces, not only boundary");
}
-
+
void DX::parse_parameters (ParameterHandler& param)
{
write_cells = param.get_bool("Write cells");
write_measure = param.get_bool("Write measure");
write_all_faces = param.get_bool("Write all faces");
}
-
-
- Msh::Msh (const bool write_faces,
+
+
+ Msh::Msh (const bool write_faces,
const bool write_lines) :
write_faces (write_faces),
write_lines (write_lines)
{}
-
+
void Msh::declare_parameters (ParameterHandler& param)
{
param.declare_entry("Write faces", "false", Patterns::Bool());
write_lines = param.get_bool("Write lines");
}
-
+
Ucd::Ucd (const bool write_preamble,
const bool write_faces,
const bool write_lines) :
write_lines (write_lines)
{}
-
-
+
+
void Ucd::declare_parameters (ParameterHandler& param)
{
param.declare_entry("Write preamble", "true", Patterns::Bool());
write_lines = param.get_bool("Write lines");
}
-
+
Gnuplot::Gnuplot (const bool write_cell_numbers,
const unsigned int n_boundary_face_points,
const bool curved_inner_cells) :
curved_inner_cells(curved_inner_cells)
{}
-
-
+
+
void Gnuplot::declare_parameters (ParameterHandler& param)
{
param.declare_entry("Cell number", "false", Patterns::Bool());
n_boundary_face_points = param.get_integer("Boundary points");
}
-
+
EpsFlagsBase::EpsFlagsBase (const SizeType size_type,
const unsigned int size,
const double line_width,
n_boundary_face_points(n_boundary_face_points),
color_lines_level(color_lines_level)
{}
-
+
void EpsFlagsBase::declare_parameters (ParameterHandler& param)
{
color_lines_level = param.get_bool("Color by level");
}
-
-
+
+
Eps<1>::Eps (const SizeType size_type,
const unsigned int size,
const double line_width,
n_boundary_face_points)
{}
-
+
void Eps<1>::declare_parameters (ParameterHandler&)
{}
EpsFlagsBase::parse_parameters(param);
}
-
-
+
+
Eps<2>::Eps (const SizeType size_type,
const unsigned int size,
const double line_width,
write_cell_number_level (write_cell_number_level),
write_vertex_numbers (write_vertex_numbers)
{}
-
-
+
+
void Eps<2>::declare_parameters (ParameterHandler& param)
{
param.declare_entry("Cell number", "false", Patterns::Bool(),
write_vertex_numbers = param.get_bool("Vertex number");
}
-
-
+
+
Eps<3>::Eps (const SizeType size_type,
const unsigned int size,
const double line_width,
azimut_angle (azimut_angle),
turn_angle (turn_angle)
{}
-
-
+
+
void Eps<3>::declare_parameters (ParameterHandler& param)
{
param.declare_entry("Azimuth", "30", Patterns::Double(),
"Azimuth of the viw point, that is, the angle "
"in the plane from the x-axis.");
param.declare_entry("Elevation", "30", Patterns::Double(),
- "Elevation of the view point above the xy-plane.");
+ "Elevation of the view point above the xy-plane.");
}
turn_angle = param.get_double("Azimuth");
}
-
-
+
+
XFig::XFig ()
:
draw_boundary(true),
boundary_thickness(3)
{}
-
+
void XFig::declare_parameters (ParameterHandler& param)
{
param.declare_entry("Boundary", "true", Patterns::Bool());
boundary_thickness = param.get_integer("Boundary width");
}
-
+
} // end namespace GridOutFlags
-void GridOut::set_flags (const GridOutFlags::DX &flags)
+GridOut::GridOut ()
+ :
+ default_format (none)
+{}
+
+
+void GridOut::set_flags (const GridOutFlags::DX &flags)
{
dx_flags = flags;
}
-void GridOut::set_flags (const GridOutFlags::Msh &flags)
+void GridOut::set_flags (const GridOutFlags::Msh &flags)
{
msh_flags = flags;
}
-void GridOut::set_flags (const GridOutFlags::Ucd &flags)
+void GridOut::set_flags (const GridOutFlags::Ucd &flags)
{
ucd_flags = flags;
}
-void GridOut::set_flags (const GridOutFlags::Gnuplot &flags)
+void GridOut::set_flags (const GridOutFlags::Gnuplot &flags)
{
gnuplot_flags = flags;
}
-void GridOut::set_flags (const GridOutFlags::Eps<1> &flags)
+void GridOut::set_flags (const GridOutFlags::Eps<1> &flags)
{
eps_flags_1 = flags;
}
-void GridOut::set_flags (const GridOutFlags::Eps<2> &flags)
+void GridOut::set_flags (const GridOutFlags::Eps<2> &flags)
{
eps_flags_2 = flags;
}
-void GridOut::set_flags (const GridOutFlags::Eps<3> &flags)
+void GridOut::set_flags (const GridOutFlags::Eps<3> &flags)
{
eps_flags_3 = flags;
}
-void GridOut::set_flags (const GridOutFlags::XFig &flags)
+void GridOut::set_flags (const GridOutFlags::XFig &flags)
{
xfig_flags = flags;
}
std::string
-GridOut::default_suffix (const OutputFormat output_format)
+GridOut::default_suffix (const OutputFormat output_format)
{
- switch (output_format)
+ switch (output_format)
{
case none:
return "";
case dx:
return ".dx";
- case gnuplot:
+ case gnuplot:
return ".gnuplot";
- case ucd:
+ case ucd:
return ".inp";
- case eps:
+ case eps:
return ".eps";
case xfig:
return ".fig";
case msh:
return ".msh";
- default:
- Assert (false, ExcNotImplemented());
+ default:
+ Assert (false, ExcNotImplemented());
return "";
};
}
if (format_name == "eps")
return eps;
-
+
if (format_name == "xfig")
return xfig;
-
+
if (format_name == "msh")
return msh;
-
+
AssertThrow (false, ExcInvalidState ());
// return something weird
return OutputFormat(-1);
-std::string GridOut::get_output_format_names ()
+std::string GridOut::get_output_format_names ()
{
return "none|dx|gnuplot|eps|ucd|xfig|msh";
}
param.enter_subsection("DX");
GridOutFlags::DX::declare_parameters(param);
param.leave_subsection();
-
+
param.enter_subsection("Msh");
GridOutFlags::Msh::declare_parameters(param);
param.leave_subsection();
-
+
param.enter_subsection("Ucd");
GridOutFlags::Ucd::declare_parameters(param);
param.leave_subsection();
-
+
param.enter_subsection("Gnuplot");
GridOutFlags::Gnuplot::declare_parameters(param);
param.leave_subsection();
-
+
param.enter_subsection("Eps");
GridOutFlags::EpsFlagsBase::declare_parameters(param);
GridOutFlags::Eps<1>::declare_parameters(param);
GridOutFlags::Eps<2>::declare_parameters(param);
GridOutFlags::Eps<3>::declare_parameters(param);
param.leave_subsection();
-
+
param.enter_subsection("XFig");
GridOutFlags::XFig::declare_parameters(param);
param.leave_subsection();
GridOut::parse_parameters(ParameterHandler& param)
{
default_format = parse_output_format(param.get("Format"));
-
+
param.enter_subsection("DX");
dx_flags.parse_parameters(param);
param.leave_subsection();
-
+
param.enter_subsection("Msh");
msh_flags.parse_parameters(param);
param.leave_subsection();
-
+
param.enter_subsection("Ucd");
ucd_flags.parse_parameters(param);
param.leave_subsection();
-
+
param.enter_subsection("Gnuplot");
gnuplot_flags.parse_parameters(param);
param.leave_subsection();
-
+
param.enter_subsection("Eps");
eps_flags_1.parse_parameters(param);
eps_flags_2.parse_parameters(param);
eps_flags_3.parse_parameters(param);
param.leave_subsection();
-
+
param.enter_subsection("XFig");
xfig_flags.parse_parameters(param);
param.leave_subsection();
// $Id$
// Version: $Name$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2009 by the deal.II authors
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2009, 2010 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
DEAL_II_NAMESPACE_OPEN
-TimeDependent::TimeSteppingData::TimeSteppingData (const unsigned int look_ahead,
- const unsigned int look_back)
- :
- look_ahead (look_ahead),
- look_back (look_back)
-{}
-
-
-TimeDependent::TimeDependent (const TimeSteppingData &data_primal,
- const TimeSteppingData &data_dual,
- const TimeSteppingData &data_postprocess):
- sweep_no (numbers::invalid_unsigned_int),
- timestepping_data_primal (data_primal),
- timestepping_data_dual (data_dual),
- timestepping_data_postprocess (data_postprocess)
-{}
-
-
-TimeDependent::~TimeDependent ()
-{
- while (timesteps.size() != 0)
- delete_timestep (0);
-}
-
-
-void
-TimeDependent::insert_timestep (const TimeStepBase *position,
- TimeStepBase *new_timestep)
-{
- Assert ((std::find(timesteps.begin(), timesteps.end(), position) != timesteps.end()) ||
- (position == 0),
- ExcInvalidPosition());
- // first insert the new time step
- // into the doubly linked list
- // of timesteps
- if (position == 0)
- {
- // at the end
- new_timestep->set_next_timestep (0);
- if (timesteps.size() > 0)
- {
- timesteps.back()->set_next_timestep (new_timestep);
- new_timestep->set_previous_timestep (timesteps.back());
- }
- else
- new_timestep->set_previous_timestep (0);
- }
- else
- if (position == timesteps[0])
- {
- // at the beginning
- new_timestep->set_previous_timestep (0);
- if (timesteps.size() > 0)
- {
- timesteps[0]->set_previous_timestep (new_timestep);
- new_timestep->set_next_timestep (timesteps[0]);
- }
- else
- new_timestep->set_next_timestep (0);
- }
- else
- {
- // inner time step
- std::vector<SmartPointer<TimeStepBase,TimeDependent> >::iterator insert_position
- = std::find(timesteps.begin(), timesteps.end(), position);
-
- (*(insert_position-1))->set_next_timestep (new_timestep);
- new_timestep->set_previous_timestep (*(insert_position-1));
- new_timestep->set_next_timestep (*insert_position);
- (*insert_position)->set_previous_timestep (new_timestep);
- };
-
- // finally enter it into the
- // array
- timesteps.insert ((position == 0 ?
- timesteps.end() :
- std::find(timesteps.begin(), timesteps.end(), position)),
- new_timestep);
-}
-
-
-void
-TimeDependent::add_timestep (TimeStepBase *new_timestep)
-{
- insert_timestep (0, new_timestep);
-}
-
-
-void TimeDependent::delete_timestep (const unsigned int position)
-{
- Assert (position<timesteps.size(),
- ExcInvalidPosition());
-
- // Remember time step object for
- // later deletion and unlock
- // SmartPointer
- TimeStepBase* t = timesteps[position];
- timesteps[position] = 0;
- // Now delete unsubscribed object
- delete t;
-
- timesteps.erase (timesteps.begin() + position);
-
- // reset "next" pointer of previous
- // time step if possible
- //
- // note that if now position==size,
- // then we deleted the last time step
- if (position != 0)
- timesteps[position-1]->set_next_timestep ((position<timesteps.size()) ?
- timesteps[position] :
- /*null*/SmartPointer<TimeStepBase,TimeDependent>());
-
- // same for "previous" pointer of next
- // time step
- if (position<timesteps.size())
- timesteps[position]->set_previous_timestep ((position!=0) ?
- timesteps[position-1] :
- /*null*/SmartPointer<TimeStepBase,TimeDependent>());
-}
-
-
-void
-TimeDependent::solve_primal_problem ()
-{
- do_loop (std::mem_fun(&TimeStepBase::init_for_primal_problem),
- std::mem_fun(&TimeStepBase::solve_primal_problem),
- timestepping_data_primal,
- forward);
-}
-
-
-void
-TimeDependent::solve_dual_problem ()
-{
- do_loop (std::mem_fun(&TimeStepBase::init_for_dual_problem),
- std::mem_fun(&TimeStepBase::solve_dual_problem),
- timestepping_data_dual,
- backward);
-}
-
-
-void
-TimeDependent::postprocess ()
-{
- do_loop (std::mem_fun(&TimeStepBase::init_for_postprocessing),
- std::mem_fun(&TimeStepBase::postprocess_timestep),
- timestepping_data_postprocess,
- forward);
-}
-
-
-
-void TimeDependent::start_sweep (const unsigned int s)
-{
- sweep_no = s;
-
- // reset the number each
- // time step has, since some time
- // steps might have been added since
- // the last time we visited them
- //
- // also set the sweep we will
- // process in the sequel
- for (unsigned int step=0; step<timesteps.size(); ++step)
- {
- timesteps[step]->set_timestep_no (step);
- timesteps[step]->set_sweep_no (sweep_no);
- };
-
- for (unsigned int step=0; step<timesteps.size(); ++step)
- timesteps[step]->start_sweep ();
-}
-
-
-
-void TimeDependent::end_sweep (const unsigned int n_threads)
-{
- if (DEAL_II_USE_MT && (n_threads > 1))
- {
- const unsigned int stride = timesteps.size() / n_threads;
- Threads::ThreadGroup<> threads;
- void (TimeDependent::*p) (const unsigned int, const unsigned int)
- = &TimeDependent::end_sweep;
- for (unsigned int i=0; i<n_threads; ++i)
- threads += Threads::new_thread (p, *this, i*stride,
- (i == n_threads-1 ?
- timesteps.size() :
- (i+1)*stride));
- threads.join_all();
- }
- else
- // now do the work
- end_sweep (0, timesteps.size());
-}
-
-
-
-void TimeDependent::end_sweep (const unsigned int begin,
- const unsigned int end)
-{
- for (unsigned int step=begin; step<end; ++step)
- timesteps[step]->end_sweep ();
-}
-
-
-
-unsigned int TimeDependent::memory_consumption () const
-{
- unsigned int mem = (MemoryConsumption::memory_consumption (timesteps) +
- MemoryConsumption::memory_consumption (sweep_no) +
- sizeof(timestepping_data_primal) +
- sizeof(timestepping_data_dual) +
- sizeof(timestepping_data_postprocess));
- for (unsigned int i=0; i<timesteps.size(); ++i)
- mem += MemoryConsumption::memory_consumption (*timesteps[i]);
-
- return mem;
-}
-
-
-
-/* --------------------------------------------------------------------- */
-
-
-TimeStepBase::TimeStepBase (const double time) :
- previous_timestep(0),
- next_timestep (0),
- sweep_no (numbers::invalid_unsigned_int),
- timestep_no (numbers::invalid_unsigned_int),
- time (time)
-{}
-
-
-
-TimeStepBase::~TimeStepBase ()
-{}
-
-
-
-void
-TimeStepBase::wake_up (const unsigned )
-{}
-
-
-
-void
-TimeStepBase::sleep (const unsigned)
-{}
-
-
-
-void
-TimeStepBase::start_sweep ()
-{}
-
-
-
-void
-TimeStepBase::end_sweep ()
-{}
-
-
-
-void
-TimeStepBase::init_for_primal_problem ()
-{
- next_action = primal_problem;
-}
-
-
-
-void
-TimeStepBase::init_for_dual_problem ()
-{
- next_action = dual_problem;
-}
-
-
-
-void
-TimeStepBase::init_for_postprocessing ()
-{
- next_action = postprocess;
-}
-
-
-
-void
-TimeStepBase::solve_dual_problem ()
-{
- Assert (false, ExcPureFunctionCalled());
-}
-
-
-
-void
-TimeStepBase::postprocess_timestep ()
-{
- Assert (false, ExcPureFunctionCalled());
-}
-
-
-
-double
-TimeStepBase::get_time () const
-{
- return time;
-}
-
-
-
-unsigned int
-TimeStepBase::get_timestep_no () const
-{
- return timestep_no;
-}
-
-
-
-double
-TimeStepBase::get_backward_timestep () const
-{
- Assert (previous_timestep != 0, ExcCantComputeTimestep());
- return time - previous_timestep->time;
-}
-
-
-
-double
-TimeStepBase::get_forward_timestep () const
-{
- Assert (next_timestep != 0, ExcCantComputeTimestep());
- return next_timestep->time - time;
-}
-
-
-
-void
-TimeStepBase::set_previous_timestep (const TimeStepBase *previous)
-{
- previous_timestep = previous;
-}
-
-
-
-void
-TimeStepBase::set_next_timestep (const TimeStepBase *next)
-{
- next_timestep = next;
-}
-
-
-
-void
-TimeStepBase::set_timestep_no (const unsigned int step_no)
-{
- timestep_no = step_no;
-}
-
-
-
-void
-TimeStepBase::set_sweep_no (const unsigned int sweep)
-{
- sweep_no = sweep;
-}
-
-
-
-unsigned int
-TimeStepBase::memory_consumption () const
-{
- // only simple data types
- return sizeof(*this);
-}
-
-
-/* ------------------------------------------------------------------------- */
-
template <int dim>
TimeStepBase_Tria<dim>::TimeStepBase_Tria() :
template <int dim>
-TimeStepBase_Tria<dim>::~TimeStepBase_Tria ()
+TimeStepBase_Tria<dim>::~TimeStepBase_Tria ()
{
if (!flags.delete_and_rebuild_tria)
{
}
else
Assert (tria==0, ExcInternalError());
-
+
coarse_grid = 0;
}
TimeStepBase_Tria<dim>::wake_up (const unsigned wakeup_level)
{
TimeStepBase::wake_up (wakeup_level);
-
+
if (wakeup_level == flags.wakeup_level_to_build_grid)
if (flags.delete_and_rebuild_tria || !tria)
restore_grid ();
if (sleep_level == flags.sleep_level_to_delete_grid)
{
Assert (tria!=0, ExcInternalError());
-
+
if (flags.delete_and_rebuild_tria)
{
Triangulation<dim>* t = tria;
// for each of the previous refinement
// sweeps
for (unsigned int previous_sweep=0; previous_sweep<refine_flags.size();
- ++previous_sweep)
+ ++previous_sweep)
{
// get flags
tria->load_refine_flags (refine_flags[previous_sweep]);
// have a few helper functions
-namespace
+namespace
{
template <int dim>
void
// no problem at all, if it is on a lower
// level than the present one, then it
// will be refined below anyway.
- if (new_cell->active())
+ if (new_cell->active())
{
if (new_cell->refine_flag_set() && old_cell->active())
{
old_cell->set_refine_flag();
};
-
+
return;
};
const typename Triangulation<dim>::cell_iterator &cell2)
{
- if (cell2->has_children() && cell1->has_children())
+ if (cell2->has_children() && cell1->has_children())
{
bool grids_changed = false;
Assert(cell2->n_children()==cell1->n_children(), ExcNotImplemented());
- for (unsigned int c=0; c<cell1->n_children(); ++c)
+ for (unsigned int c=0; c<cell1->n_children(); ++c)
grids_changed |= dealii::adapt_grid_cells<dim> (cell1->child(c),
cell2->child(c));
return grids_changed;
cell1->clear_coarsen_flag();
return true;
};
-
+
return false;
};
cell2->clear_coarsen_flag();
changed_grid = true;
};
-
+
if (!cell2->refine_flag_set())
for (unsigned int c=0; c<cell1->n_children(); ++c)
if (cell1->child(c)->refine_flag_set() ||
- cell1->child(c)->has_children())
+ cell1->child(c)->has_children())
{
cell2->set_refine_flag();
changed_grid = true;
cell1->clear_coarsen_flag();
changed_grid = true;
};
-
+
if (!cell1->refine_flag_set())
for (unsigned int c=0; c<cell2->n_children(); ++c)
if (cell2->child(c)->refine_flag_set() ||
Triangulation<dim> &tria2)
{
bool grids_changed = false;
-
+
typename Triangulation<dim>::cell_iterator cell1 = tria1.begin(),
cell2 = tria2.begin();
typename Triangulation<dim>::cell_iterator endc;
{
Vector<float> criteria;
get_tria_refinement_criteria (criteria);
-
+
// copy the following two values since
// we may need modified values in the
// process of this function
// since its computation is rather
// expensive and since it doesn't change
const unsigned int n_active_cells = tria->n_active_cells ();
-
+
// if not on first time level: try to
// adjust the number of resulting
// cells to those on the previous
// also)
if (refinement_flags.adapt_grids)
dealii::adapt_grids<dim> (*previous_tria, *tria);
-
+
// perform flagging of cells
// needed to regularize the
// triangulation
if (cell->coarsen_flag_set())
previous_cells -= (GeometryInfo<dim>::max_children_per_cell-1) /
GeometryInfo<dim>::max_children_per_cell;
-
+
// @p{previous_cells} now gives the
// number of cells which would result
// from the flags on the previous grid
delta_down *= relaxations[r].second;
break;
};
-
+
// now, if the number of estimated
// cells exceeds the number of cells
// on the old time level by more than
// we unflag we have to diminish the
// estimated number of cells by
// @p{children_per_cell}.
- if (estimated_cells > previous_cells*(1.+delta_up))
+ if (estimated_cells > previous_cells*(1.+delta_up))
{
// only limit the cell number
// if there will not be less
// of the flagged cells.
if (loop != refinement_flags.cell_number_correction_steps-1)
delta_cells *= 0.9;
-
+
// if more cells need to be
// refined, we need to lower
// the thresholds, i.e. to
ExcInternalError());
--p_refinement_threshold;
};
-
+
coarsening_threshold = *p_coarsening_threshold;
refinement_threshold = *p_refinement_threshold;
GridRefinement::refine (*tria, criteria, refinement_threshold);
GridRefinement::coarsen (*tria, criteria, coarsening_threshold);
};
-
+
// if step number is greater than
// one: adapt this and the previous
// grid to each other. Don't do so
for (; new_cell!=endc; ++new_cell, ++old_cell)
dealii::mirror_refinement_flags<dim> (new_cell, old_cell);
};
-
+
tria->prepare_coarsening_and_refinement ();
previous_tria->prepare_coarsening_and_refinement ();
-
+
// adapt present and previous grids
// to each other: flag additional
// cells to avoid the previous grid
template <int dim>
-void TimeStepBase_Tria<dim>::init_for_refinement ()
+void TimeStepBase_Tria<dim>::init_for_refinement ()
{
next_action = grid_refinement;
}
template <int dim>
typename TimeStepBase_Tria_Flags::RefinementFlags<dim>::CorrectionRelaxations
-TimeStepBase_Tria_Flags::RefinementFlags<dim>::default_correction_relaxations
+TimeStepBase_Tria_Flags::RefinementFlags<dim>::default_correction_relaxations
(1, // one element, denoting the first and all subsequent sweeps
std::vector<std::pair<unsigned int,double> >(1, // one element, denoting the upper bound
// for the following
const unsigned int min_cells_for_correction,
const double cell_number_corridor_top,
const double cell_number_corridor_bottom,
- const CorrectionRelaxations &correction_relaxations,
+ const CorrectionRelaxations &correction_relaxations,
const unsigned int cell_number_correction_steps,
const bool mirror_flags_to_previous_grid,
const bool adapt_grids) :
// explicit instantiations
template class TimeStepBase_Tria<deal_II_dimension>;
-namespace TimeStepBase_Tria_Flags
+namespace TimeStepBase_Tria_Flags
{
template class Flags<deal_II_dimension>;
template class RefinementFlags<deal_II_dimension>;