template<int dim, typename number>
class SolutionTransfer
{
- public:
+ public:
+
/**
* Constructor, takes the current #DoFHandler#
* as argument.
/**
* Exception
*/
- DeclException0(ExcAlreadyPrepForRefAndCoarse);
+ DeclException0(ExcAlreadyPrepForCoarseAndRef);
/**
* Exception
* Exception
*/
DeclException0(ExcInternalError);
-
- /**
- * Exception
- */
- DeclException2 (ExcInvalidVectorSize,
- int, int,
- << "The data vector has the size " << arg1
- << ", but " << arg2 << " was expected.");
private:
unsigned int n_dofs_old;
/**
- * Denotes whether the #SolutionTransfer#
- * is 'prepared for pure refinement'
- * or not.
+ * #PreparationState# denotes the
+ * three possible states of the
+ * #SolutionTransfer#: being
+ * prepared for 'pure refinement',
+ * prepared for 'coarsening and
+ * refinement' or not prepared.
*/
- bool prepared_for_pure_refinement;
+ enum PreparationState {
+ none, pure_refinement, coarsening_and_refinement
+ } prepared_for;
- /**
- * Denotes whether the #SolutionTransfer#
- * is 'prepared for coarsening and refinement'
- * or not.
- */
- bool prepared_for_coarsening_and_refinement;
/**
* Is used for #prepare_for_refining#
SolutionTransfer<dim, number>::SolutionTransfer(const DoFHandler<dim> &dof):
dof_handler(&dof),
n_dofs_old(0),
- prepared_for_pure_refinement(0),
- prepared_for_coarsening_and_refinement(0)
+ prepared_for(none)
{}
if (dof_values_on_cell.size())
dof_values_on_cell.erase(dof_values_on_cell.begin(), dof_values_on_cell.end());
- prepared_for_pure_refinement=false;
- prepared_for_coarsening_and_refinement=false;
+ prepared_for=none;
}
template<int dim, typename number>
void SolutionTransfer<dim, number>::prepare_for_pure_refinement()
{
- Assert(!prepared_for_pure_refinement, ExcAlreadyPrepForRef());
- Assert(!prepared_for_coarsening_and_refinement,
- ExcAlreadyPrepForRefAndCoarse());
+ Assert(prepared_for!=pure_refinement, ExcAlreadyPrepForRef());
+ Assert(prepared_for!=coarsening_and_refinement,
+ ExcAlreadyPrepForCoarseAndRef());
clear();
else
cell->clear_user_pointer();
}
- prepared_for_pure_refinement=true;
+ prepared_for=pure_refinement;
}
SolutionTransfer<dim, number>::refine_interpolate(const Vector<number> &in,
Vector<number> &out) const
{
- Assert(prepared_for_pure_refinement, ExcNotPrepared());
+ Assert(prepared_for==pure_refinement, ExcNotPrepared());
Assert(in.size()==n_dofs_old, ExcWrongVectorSize(in.size(),n_dofs_old));
Assert(out.size()==dof_handler->n_dofs(),
ExcWrongVectorSize(out.size(),dof_handler->n_dofs()));
SolutionTransfer<dim, number>::
prepare_for_coarsening_and_refinement(const vector<Vector<number> > &all_in)
{
- Assert(!prepared_for_pure_refinement, ExcAlreadyPrepForRef());
- Assert(!prepared_for_coarsening_and_refinement,
- ExcAlreadyPrepForRefAndCoarse());
+ Assert(prepared_for!=pure_refinement, ExcAlreadyPrepForRef());
+ Assert(!prepared_for!=coarsening_and_refinement,
+ ExcAlreadyPrepForCoarseAndRef());
const unsigned int in_size=all_in.size();
Assert(in_size!=0, ExcNoInVectorsGiven());
Assert(n_sr==n_cells_to_stay_or_refine, ExcInternalError());
Assert(n_cf==n_coarsen_fathers, ExcInternalError());
- prepared_for_coarsening_and_refinement=true;
+ prepared_for=coarsening_and_refinement;
}
interpolate (const vector<Vector<number> > &all_in,
vector<Vector<number> > &all_out) const
{
- Assert(prepared_for_coarsening_and_refinement, ExcNotPrepared());
+ Assert(prepared_for==coarsening_and_refinement, ExcNotPrepared());
for (unsigned int i=0; i<all_in.size(); ++i)
Assert (all_in[i].size() == n_dofs_old,
- ExcInvalidVectorSize(all_in[i].size(), n_dofs_old));
+ ExcWrongVectorSize(all_in[i].size(), n_dofs_old));
unsigned int out_size=all_out.size();