+/* ----------------------- Declare some global exceptions which are
+ not generated by the Assert mechanism, but
+ are rather used for the throw and catch
+ way.
+*/
+
+#include <exception>
+
+class GlobalExcIO : public exception {
+ public:
+ virtual const char * what () const {
+ return __PRETTY_FUNCTION__;
+ };
+};
+
+
+
+
/*---------------------------- exceptions.h ---------------------------*/
/* end of #ifndef __exceptions_H */
#endif
bool ParameterHandler::read_input (istream &input) {
+ if (!input)
+ throw GlobalExcIO ();
+
string line;
int lineno=0;
while (input)
// given as "style"
Assert ((style == Text) || (style == LaTeX), ExcNotImplemented());
+ if (!out)
+ throw GlobalExcIO ();
+
switch (style)
{
case Text:
// assert that only known formats are
// given as "style"
Assert ((style == Text) || (style == LaTeX), ExcNotImplemented());
-
+
+ if (!out)
+ throw GlobalExcIO ();
+
Section *pd = get_present_defaults_subsection ();
Section *pc = get_present_changed_subsection ();
bool MultipleParameterLoop::read_input (istream &input) {
+ if (!input)
+ throw GlobalExcIO ();
+
bool x = ParameterHandler::read_input (input);
if (x) init_branches ();
return x;
};
+
bool MultipleParameterLoop::read_input (const string &filename) {
// I don't know why it is necessary to
// declare this function: simply not
};
+
bool MultipleParameterLoop::read_input_from_string (const char *s) {
bool x = ParameterHandler::read_input (s);
init_branches ();
input parameters shall precede the output parameters, unless there
are good reasons to change this order.
-11./ Each class has to have at least 200 pages of documentation ;-)
+11./ Exceptions are used for internal parameter checking and for
+ consistency checks through the Assert macro. Exception handling
+ like done by the C++ language (try/throw/catch) are used to
+ handle run time errors (like I/O failures) which must be on
+ in any case, not only in debug mode.
+
+12./ Each class has to have at least 200 pages of documentation ;-)
(previous ones worked flawless)
+Check the pattern matching in the parameter handler module using
+ the C++ exception handling mechanism rather than Asserts, since
+ this should be on also when debug mode is off.
+
+
for (unsigned int i=0; i<dim-1; ++i)
out << p(i) << ' ';
out << p(dim-1);
+
+ if (!out)
+ throw GlobalExcIO ();
+
return out;
};
inline
ostream & operator << (ostream &out, const Point<1> &p) {
out << p(0);
+
+ if (!out)
+ throw GlobalExcIO ();
+
return out;
};
out << " " << lines[i].line
<< " " << lines[i].entries[j].first
<< ": " << lines[i].entries[j].second << endl;
+
+ if (!out)
+ throw GlobalExcIO ();
};
active_cell_iterator(end()) :
begin_active (level+1));
+ if (!out)
+ throw GlobalExcIO ();
+
out << "#Active cells on level " << level
<< ": " << n_active_cells (level) << endl;
for (; cell != endc; ++cell)
print_gnuplot (out, cell);
+
+ if (!out)
+ throw GlobalExcIO ();
};
template <>
void Triangulation<1>::print_gnuplot (ostream &out,
const active_cell_iterator & cell) const {
+ if (!out)
+ throw GlobalExcIO ();
+
out << cell->vertex(0) << " " << cell->level() << endl
<< cell->vertex(1) << " " << cell->level() << endl
<< endl;
+
+ if (!out)
+ throw GlobalExcIO ();
};
#endif
template <>
void Triangulation<2>::print_gnuplot (ostream &out,
const active_cell_iterator & cell) const {
+ if (!out)
+ throw GlobalExcIO ();
+
out << cell->vertex(0) << " " << cell->level() << endl
<< cell->vertex(1) << " " << cell->level() << endl
<< cell->vertex(2) << " " << cell->level() << endl
<< cell->vertex(0) << " " << cell->level() << endl
<< endl // double new line for gnuplot 3d plots
<< endl;
+
+ if (!out)
+ throw GlobalExcIO ();
};
#endif
for (unsigned int position=0; position<N; ++position)
flags[position/8] |= (v[position] ? (1<<(position%8)) : 0);
+ if (!out)
+ throw GlobalExcIO ();
+
// format:
// 0. magic number
// 1. number of flags
out << static_cast<unsigned int>(flags[i]) << " ";
out << endl << magic_number2 << endl;
-
+
delete[] flags;
+
+ if (!out)
+ throw GlobalExcIO ();
};
vector<bool> &v,
const unsigned int magic_number2,
istream &in) {
+ if (!in)
+ throw GlobalExcIO ();
+
unsigned int magic_number;
in >> magic_number;
Assert (magic_number==magic_number1, ExcGridReadError());
Assert (magic_number==magic_number2, ExcGridReadError());
delete[] flags;
+
+ if (!in)
+ throw GlobalExcIO ();
};
Assert (tria != 0, ExcNoTriangulationSelected());
Assert ((1<=dim) && (dim<=2), ExcNotImplemented());
+ if (!in)
+ throw GlobalExcIO ();
// skip comments at start of file
char c;
// check that no forbidden arrays are used
Assert (subcelldata.check_consistency(dim), ExcInternalError());
-
+
+ if (!in)
+ throw GlobalExcIO ();
+
tria->create_triangulation (vertices, cells, subcelldata);
};
DoFHandler<dim>::active_cell_iterator cell,
endc = dofs->end();
- unsigned int n_vertex_dofs;
+ unsigned int n_vertex_dofs = 0;
// first loop over all cells to
// find out how many degrees of
++vertex)
is_vertex_dof[cell->vertex_dof_index(vertex,0)] = true;
- n_vertex_dofs = 0;
for (unsigned i=0; i!=is_vertex_dof.size(); ++i)
if (is_vertex_dof[i] == true)
++n_vertex_dofs;
};
// no cell data
// no model data
+ if (!out)
+ throw GlobalExcIO ();
+
};
++index;
};
+
+ if (!out)
+ throw GlobalExcIO ();
};
Assert (false, ExcNotImplemented());
};
};
+
+ if (!out)
+ throw GlobalExcIO ();
};
<< endl;
};
out << "}";
+
+ if (!out)
+ throw GlobalExcIO ();
};
CXX = c++
INCLUDE = -I../include -I../../base/include
CXXFLAGS.g= -DDEBUG -g -Wall -W -pedantic -Wconversion \
- -Winline -Woverloaded-virtual -fno-rtti -fno-exceptions \
+ -Winline -Woverloaded-virtual -fno-rtti \
$(INCLUDE)
CXXFLAGS =-O3 -Wuninitialized -finline-functions -ffast-math \
-funroll-loops -felide-constructors -fnonnull-objects \
out << endl;
};
+ if (!out)
+ throw GlobalExcIO ();
+
out.setf (0, ios::floatfield); // reset output format
};
for (unsigned int j=rowstart[i]; j<rowstart[i+1]; ++j)
if (colnums[j]>=0)
out << i << " " << -colnums[j] << endl;
+
+ if (!out)
+ throw GlobalExcIO ();
}
for (unsigned int i=0; i<cols->rows; ++i)
for (unsigned int j=cols->rowstart[i]; j<cols->rowstart[i+1]; ++j)
out << "(" << i << "," << cols->colnums[j] << ") " << val[j] << endl;
+
+ if (!out)
+ throw GlobalExcIO ();
};
out << setw(precision+8) << " ";
out << endl;
};
+ if (!out)
+ throw GlobalExcIO ();
out.setf (0, ios::floatfield); // reset output format
};
Assert (dim!=0, ExcEmptyVector());
for (unsigned int i=0; i<size(); ++i)
out << val[i] << endl;
+
+ if (!out)
+ throw GlobalExcIO ();
};