From 3134ff533d628580d53b9c869a2ff0400b71902c Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 23 Mar 1998 07:44:41 +0000 Subject: [PATCH] Make deal.II compilable with gcc2.8 git-svn-id: https://svn.dealii.org/trunk@88 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/function.h | 2 +- deal.II/base/include/base/parameter_handler.h | 22 ++- deal.II/base/source/parameter_handler.cc | 42 +++-- deal.II/deal.II/Attic/examples/Makefile | 9 +- deal.II/deal.II/Todo | 2 + deal.II/deal.II/include/dofs/dof_accessor.h | 14 +- deal.II/deal.II/include/dofs/dof_handler.h | 16 ++ deal.II/deal.II/include/fe/fe.h | 12 +- deal.II/deal.II/include/grid/tria.h | 15 ++ deal.II/deal.II/include/grid/tria_iterator.h | 2 +- deal.II/deal.II/include/numerics/base.h | 99 +++++++++- deal.II/deal.II/include/numerics/data_io.h | 2 +- deal.II/deal.II/source/dofs/dof_accessor.cc | 8 +- .../deal.II/source/dofs/dof_constraints.cc | 21 ++- deal.II/deal.II/source/dofs/dof_handler.cc | 31 +++- deal.II/deal.II/source/fe/Makefile | 9 +- deal.II/deal.II/source/fe/fe_lib.linear.cc | 20 +- deal.II/deal.II/source/grid/Makefile | 9 +- deal.II/deal.II/source/grid/tria.cc | 85 ++++----- deal.II/deal.II/source/grid/tria_accessor.cc | 173 ++++++++++++++---- deal.II/deal.II/source/numerics/Makefile | 9 +- deal.II/deal.II/source/numerics/base.cc | 45 ++++- tests/big-tests/Makefile | 9 +- 23 files changed, 499 insertions(+), 157 deletions(-) diff --git a/deal.II/base/include/base/function.h b/deal.II/base/include/base/function.h index b70514af93..a00e86d2a6 100644 --- a/deal.II/base/include/base/function.h +++ b/deal.II/base/include/base/function.h @@ -1,5 +1,5 @@ /*---------------------------- function.h ---------------------------*/ -/* */ +/* $Id$ */ #ifndef __function_H #define __function_H /*---------------------------- function.h ---------------------------*/ diff --git a/deal.II/base/include/base/parameter_handler.h b/deal.II/base/include/base/parameter_handler.h index 81aff2ad10..810debb6ae 100644 --- a/deal.II/base/include/base/parameter_handler.h +++ b/deal.II/base/include/base/parameter_handler.h @@ -6,8 +6,8 @@ // public classes; to be declared below -class ParameterHandler; -template class MultipleParameterLoop; +class ParameterHandler; +class MultipleParameterLoop; #include @@ -464,6 +464,14 @@ class ParameterHandler { */ ParameterHandler (); + /** + * Destructor. Declare this only to have + * a virtual destructor, which is safer + * as we have virtual functions. + * It actually does nothing spectacular. + */ + virtual ~ParameterHandler (); + /** * Read input from a stream until stream * returns #eof# condition or error. @@ -720,7 +728,7 @@ class ParameterHandler { */ const Section* get_present_changed_subsection () const; - friend class MultipleParameterLoop; + friend class MultipleParameterLoop; }; @@ -982,6 +990,14 @@ class MultipleParameterLoop : public ParameterHandler { */ MultipleParameterLoop (); + /** + * Destructor. Declare this only to have + * a virtual destructor, which is safer + * as we have virtual functions. + * It actually does nothing spectacular. + */ + virtual ~MultipleParameterLoop (); + /** * Read input from a stream until stream * returns #eof# condition or error. diff --git a/deal.II/base/source/parameter_handler.cc b/deal.II/base/source/parameter_handler.cc index 9471f0caf1..6b0b5d3a8e 100644 --- a/deal.II/base/source/parameter_handler.cc +++ b/deal.II/base/source/parameter_handler.cc @@ -32,6 +32,10 @@ ParameterHandler::ParameterHandler () : status(true) {}; +ParameterHandler::~ParameterHandler () {}; + + + bool ParameterHandler::read_input (istream &input) { String line; int lineno=0; @@ -536,8 +540,7 @@ bool ParameterHandler::scan_line (String line, const unsigned int lineno) { ParameterHandler::Section* ParameterHandler::get_present_defaults_subsection () { Section* sec = &defaults; - vector::const_iterator SecName; - SecName = subsection_path.begin(); + vector::const_iterator SecName = subsection_path.begin(); while (SecName != subsection_path.end()) { @@ -551,20 +554,24 @@ ParameterHandler::Section* ParameterHandler::get_present_defaults_subsection () const ParameterHandler::Section* ParameterHandler::get_present_defaults_subsection () const { - // simply call the non-const version - // of this function - typedef Section* (ParameterHandler::*xptr) (); - xptr x = &get_present_defaults_subsection; + Section* sec = (Section*)&defaults; // not nice, but needs to be and + // after all: we do not change #sec# + vector::const_iterator SecName = subsection_path.begin(); + + while (SecName != subsection_path.end()) + { + sec = sec->subsections[*SecName]; + ++SecName; + }; - return x(); + return sec; }; ParameterHandler::Section* ParameterHandler::get_present_changed_subsection () { Section* sec = &changed_entries; - vector::iterator SecName; - SecName = subsection_path.begin(); + vector::iterator SecName = subsection_path.begin(); while (SecName != subsection_path.end()) { @@ -578,12 +585,16 @@ ParameterHandler::Section* ParameterHandler::get_present_changed_subsection () { const ParameterHandler::Section* ParameterHandler::get_present_changed_subsection () const { - // simply call the non-const version - // of this function - typedef Section* (ParameterHandler::*xptr) (); - xptr x = &get_present_changed_subsection; + Section* sec = (Section*)&changed_entries; // same as in get_present_default_s... + vector::const_iterator SecName = subsection_path.begin(); + + while (SecName != subsection_path.end()) + { + sec = sec->subsections[*SecName]; + ++SecName; + }; - return x(); + return sec; }; @@ -608,6 +619,9 @@ MultipleParameterLoop::MultipleParameterLoop() : n_branches(0) {}; +MultipleParameterLoop::~MultipleParameterLoop () {}; + + bool MultipleParameterLoop::read_input (istream &input) { bool x = ParameterHandler::read_input (input); if (x) init_branches (); diff --git a/deal.II/deal.II/Attic/examples/Makefile b/deal.II/deal.II/Attic/examples/Makefile index 6c77979105..5825f83c2e 100644 --- a/deal.II/deal.II/Attic/examples/Makefile +++ b/deal.II/deal.II/Attic/examples/Makefile @@ -14,8 +14,13 @@ LIBS.g = $(LIBPATH) -lbasic.g -lgrid.g -lfe.g -lnumerics.g -llac.g LIBS = $(LIBS.g:.g=) ifeq ($(shell uname),SunOS) -CXXFLAGS := -V2.7.2.3 $(CXXFLAGS) -CXXFLAGS.g:= -V2.7.2.3 $(CXXFLAGS.g) +#CXXFLAGS := -V2.7.2.3 $(CXXFLAGS) +#CXXFLAGS.g:= -V2.7.2.3 $(CXXFLAGS.g) +INCLUDE2.8 = -I/usr/local/source/libstdc++-2.8.0/libstdc++ \ + -I/usr/local/source/libstdc++-2.8.0/libstdc++/stl \ + -I/usr/local/source/libstdc++-2.8.0/libio +CXXFLAGS := $(CXXFLAGS) -fno-rtti -fno-exceptions $(INCLUDE2.8) +CXXFLAGS.g:= $(CXXFLAGS.g) -W -fno-rtti -fno-exceptions $(INCLUDE2.8) endif diff --git a/deal.II/deal.II/Todo b/deal.II/deal.II/Todo index ac08c1d01b..4086d29f8f 100644 --- a/deal.II/deal.II/Todo +++ b/deal.II/deal.II/Todo @@ -39,6 +39,8 @@ Make AssemblerData a local class to Assembler again if gcc2.8 supports it. Let ParameterHandler and DataIn/Out throw exceptions. Make more tests on the input. +Replace function objects by mem_fun, fun_ptr, ... when member function + templates are supported. diff --git a/deal.II/deal.II/include/dofs/dof_accessor.h b/deal.II/deal.II/include/dofs/dof_accessor.h index 87d4791d7f..57cad67c7f 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.h @@ -7,11 +7,9 @@ template class Triangulation; template class DoFHandler; -template class vector; - #include - +#include @@ -45,6 +43,16 @@ class DoFAccessor { * Exception for child classes */ DeclException0 (ExcInvalidObject); + /** + * Exception for child classes + */ + DeclException3 (ExcInvalidIndex, + int, + int, + int, + << "Invalid index " << arg1 + << ", index must be between " << arg2 + << " and " << arg3 << "."); protected: /** diff --git a/deal.II/deal.II/include/dofs/dof_handler.h b/deal.II/deal.II/include/dofs/dof_handler.h index 78a868da31..e8fcc9713f 100644 --- a/deal.II/deal.II/include/dofs/dof_handler.h +++ b/deal.II/deal.II/include/dofs/dof_handler.h @@ -413,6 +413,22 @@ enum RenumberingMethod { template class DoFHandler : public DoFDimensionInfo { public: + // insert these definitions for gcc2.8, + // since it can't inherit typedefs (I + // believe it should, but it can't) + typedef typename DoFDimensionInfo::raw_line_iterator raw_line_iterator; + typedef typename DoFDimensionInfo::line_iterator line_iterator; + typedef typename DoFDimensionInfo::active_line_iterator active_line_iterator; + + typedef typename DoFDimensionInfo::raw_quad_iterator raw_quad_iterator; + typedef typename DoFDimensionInfo::quad_iterator quad_iterator; + typedef typename DoFDimensionInfo::active_quad_iterator active_quad_iterator; + + typedef typename DoFDimensionInfo::raw_cell_iterator raw_cell_iterator; + typedef typename DoFDimensionInfo::cell_iterator cell_iterator; + typedef typename DoFDimensionInfo::active_cell_iterator active_cell_iterator; + + /** * Constructor. Take #tria# as the * triangulation to work on. diff --git a/deal.II/deal.II/include/fe/fe.h b/deal.II/deal.II/include/fe/fe.h index d23143ef7e..7757b1148f 100644 --- a/deal.II/deal.II/include/fe/fe.h +++ b/deal.II/deal.II/include/fe/fe.h @@ -238,12 +238,12 @@ class FiniteElementBase { */ FiniteElementBase (const FiniteElementBase &f); -// /** -// * Destructor. Only declared to have a -// * virtual destructor which the compiler -// * wants to have. -// */ -// virtual ~FiniteElementBase () {}; + /** + * Destructor. Only declared to have a + * virtual destructor which the compiler + * wants to have. + */ + virtual ~FiniteElementBase () {}; /** diff --git a/deal.II/deal.II/include/grid/tria.h b/deal.II/deal.II/include/grid/tria.h index a7eea19f2d..5bd827fa3a 100644 --- a/deal.II/deal.II/include/grid/tria.h +++ b/deal.II/deal.II/include/grid/tria.h @@ -857,6 +857,21 @@ class TriaDimensionInfo<2> { template class Triangulation : public TriaDimensionInfo { public: + // insert these definitions for gcc2.8, + // since it can't inherit typedefs (I + // believe it should, but it can't) + typedef typename TriaDimensionInfo::raw_line_iterator raw_line_iterator; + typedef typename TriaDimensionInfo::line_iterator line_iterator; + typedef typename TriaDimensionInfo::active_line_iterator active_line_iterator; + + typedef typename TriaDimensionInfo::raw_quad_iterator raw_quad_iterator; + typedef typename TriaDimensionInfo::quad_iterator quad_iterator; + typedef typename TriaDimensionInfo::active_quad_iterator active_quad_iterator; + + typedef typename TriaDimensionInfo::raw_cell_iterator raw_cell_iterator; + typedef typename TriaDimensionInfo::cell_iterator cell_iterator; + typedef typename TriaDimensionInfo::active_cell_iterator active_cell_iterator; + /** * Create a triangulation and create * the first level of the hierarchy. diff --git a/deal.II/deal.II/include/grid/tria_iterator.h b/deal.II/deal.II/include/grid/tria_iterator.h index 9e260ee31e..9521b5a2c6 100644 --- a/deal.II/deal.II/include/grid/tria_iterator.h +++ b/deal.II/deal.II/include/grid/tria_iterator.h @@ -223,7 +223,7 @@ template class Triangulation; @author Wolfgang Bangerth, 1998 */ template -class TriaRawIterator : public bidirectional_iterator { +class TriaRawIterator : public bidirectional_iterator{ public: /** * Empty constructor. Such an object diff --git a/deal.II/deal.II/include/numerics/base.h b/deal.II/deal.II/include/numerics/base.h index 2a5f1e94f4..7b2772ef41 100644 --- a/deal.II/deal.II/include/numerics/base.h +++ b/deal.II/deal.II/include/numerics/base.h @@ -16,7 +16,7 @@ template class DoFHandler; template class FiniteElement; template class Quadrature; template class DataOut; - +template class Function; @@ -46,6 +46,14 @@ template class DataOut; \item Condense the system matrix and right hand side with the constraints induced by hanging nodes. \end{itemize} + + + {\bf Solving} + + Calling the #solve# function with a solver object, the system of equations + which results after having called the #assemble# function is solved. After + this, the solution vector is distributed again, i.e. the constrained nodes + are given their correct values. */ template class ProblemBase { @@ -60,6 +68,14 @@ class ProblemBase { ProblemBase (Triangulation *tria, DoFHandler *dof_handler); + /** + * Destructor. Declare this only to have + * a virtual destructor, which is safer + * as we have virtual functions. + * It actually does nothing spectacular. + */ + virtual ~ProblemBase (); + /** * Initiate the process of assemblage of * vectors and system matrix. Use the @@ -74,8 +90,81 @@ class ProblemBase { const FiniteElement &fe); - void solve (); - void fill_data (DataOut &) const; + /** + * Solve the system of equations. + */ + virtual void solve (); + + /** + * Integrate the difference between + * the solution computed before and + * the reference solution, which + * is given as a continuous function + * object. The integration is + * performed using the given quadrature + * rule and assumes that the given + * finite element objects equals + * that used for the computation of + * the solution. + * + * The result ist stored in the + * #difference# object, where each + * entry equals the L_1 norm of + * the difference on one cell. The + * order of entries is the same as + * a #cell_iterator# takes when + * started with #begin_active# and + * promoted with the #++# operator. + * + * You can use the + * #distribute_cell_to_dof_vector# + * function to convert cell based + * data to a data vector with values + * on the degrees of freedom, which + * can then be attached to a + * #DataOut# object. + * + * To get the global L_1 error, + * you have to sum up the entries + * in #difference#, e.g. using the STL + * function + * #accumulate (d.begin(), d.end(), 0)#, + * if #d# is the difference vector. + */ + void integrate_L1_difference (const Function &exact_solution, + vector &difference, + const Quadrature &q, + const FiniteElement &fe) const; + + /** + * Initialize the #DataOut# object with + * the grid and DoF handler used for this + * computation, as well as with the + * solution. Overload this function if + * you have multiple data sets to be + * written, or alternativelt call this + * function and attach the additional + * vectors directly to the #DataOut# + * object. + * + * Solution name and physical units are + * derived by calling the virtual + * function #get_solution_name#. + */ + virtual void fill_data (DataOut &) const; + + + /** + * Return solution name and + * physical units as a pair of + * #char*#. The default implementation + * returns #make_pair ("solution","")#, + * which results in "" + * upon output. + * Overload this function, if you + * want anything else. + */ + virtual pair get_solution_name () const; /** * Exception @@ -85,6 +174,10 @@ class ProblemBase { * Exception */ DeclException0 (ExcNoMemory); + /** + * Exception + */ + DeclException0 (ExcInvalidFE); protected: /** diff --git a/deal.II/deal.II/include/numerics/data_io.h b/deal.II/deal.II/include/numerics/data_io.h index 91401d1e30..b55ea675ec 100644 --- a/deal.II/deal.II/include/numerics/data_io.h +++ b/deal.II/deal.II/include/numerics/data_io.h @@ -21,7 +21,7 @@ template class DoFHandler; class dVector; -template class map; +template class map; template struct less; diff --git a/deal.II/deal.II/source/dofs/dof_accessor.cc b/deal.II/deal.II/source/dofs/dof_accessor.cc index 8252274496..b7c0c6c181 100644 --- a/deal.II/deal.II/source/dofs/dof_accessor.cc +++ b/deal.II/deal.II/source/dofs/dof_accessor.cc @@ -99,7 +99,7 @@ DoFLineAccessor::child (const unsigned int i) const { #ifdef DEBUG if (q.state() != past_the_end) - Assert (q->used(), ExcUnusedCellAsChild()); + Assert (q->used(), typename TriaAccessor::ExcUnusedCellAsChild()); #endif return q; }; @@ -209,7 +209,7 @@ DoFQuadAccessor::child (const unsigned int i) const { #ifdef DEBUG if (q.state() != past_the_end) - Assert (q->used(), ExcUnusedCellAsChild()); + Assert (q->used(), typename TriaAccessor::ExcUnusedCellAsChild()); #endif return q; }; @@ -238,7 +238,7 @@ DoFCellAccessor::neighbor (const unsigned int i) const { #ifdef DEBUG if (q.state() != past_the_end) - Assert (q->used(), ExcUnusedCellAsNeighbor()); + Assert (q->used(), typename TriaAccessor::ExcUnusedCellAsNeighbor()); #endif return q; }; @@ -255,7 +255,7 @@ DoFCellAccessor::child (const unsigned int i) const { #ifdef DEBUG if (q.state() != past_the_end) - Assert (q->used(), ExcUnusedCellAsChild()); + Assert (q->used(), typename TriaAccessor::ExcUnusedCellAsChild()); #endif return q; }; diff --git a/deal.II/deal.II/source/dofs/dof_constraints.cc b/deal.II/deal.II/source/dofs/dof_constraints.cc index 66251c0e9a..1ec514f779 100644 --- a/deal.II/deal.II/source/dofs/dof_constraints.cc +++ b/deal.II/deal.II/source/dofs/dof_constraints.cc @@ -181,10 +181,17 @@ void ConstraintMatrix::condense (dSMatrixStruct &sparsity) const { // otherwise, the number states which // line in the constraint matrix handles // this index + // + // for gcc2.9: replace this by + // distribute(sparsity.n_rows(), -1) vector distribute; distribute.reserve (sparsity.n_rows()); - distribute.insert (distribute.end(), sparsity.n_rows(), -1); - + // replace the following line, since + // gcc2.8 chokes over it. +// distribute.insert (distribute.end(), sparsity.n_rows(), -1); + for (unsigned int i=0; i<(unsigned int)sparsity.n_rows(); ++i) + distribute.push_back (-1); + for (int c=0; c<(signed int)lines.size(); ++c) distribute[lines[c].line] = c; @@ -350,10 +357,18 @@ void ConstraintMatrix::condense (dSMatrix &uncondensed) const { // otherwise, the number states which // line in the constraint matrix handles // this index + // + // for gcc2.9: replace this by + // distribute(sparsity.n_rows(), -1) vector distribute; distribute.reserve (sparsity.n_rows()); - distribute.insert (distribute.end(), sparsity.n_rows(), -1); + // replace the following line, since + // gcc2.8 chokes over it. +// distribute.insert (distribute.end(), sparsity.n_rows(), -1); + for (unsigned int i=0; i<(unsigned int)sparsity.n_rows(); ++i) + distribute.push_back (-1); + for (int c=0; c<(signed int)lines.size(); ++c) distribute[lines[c].line] = c; diff --git a/deal.II/deal.II/source/dofs/dof_handler.cc b/deal.II/deal.II/source/dofs/dof_handler.cc index 1eface5a24..a1c040bb48 100644 --- a/deal.II/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/deal.II/source/dofs/dof_handler.cc @@ -620,7 +620,6 @@ int DoFHandler<2>::distribute_dofs_on_cell (active_cell_iterator &cell, - template void DoFHandler::renumber_dofs (const RenumberingMethod method, bool use_constraints, @@ -635,26 +634,38 @@ void DoFHandler::renumber_dofs (const RenumberingMethod method, make_constraint_matrix (constraints); constraints.condense (sparsity); }; - + int n_dofs = sparsity.n_rows(); // store the new dof numbers; -1 means // that no new number was chosen yet - vector new_number(sparsity.n_rows(), -1); - + // + // the commented line is what would be the + // correct way to do, but gcc2.8 chokes + // over that. The other lines are a + // workaround +// vector new_number(sparsity.n_rows(), -1); + vector new_number; + new_number.reserve (sparsity.n_rows()); + for (unsigned int i=0; i<(unsigned int)sparsity.n_rows(); ++i) + new_number.push_back (-1); + // store the indices of the dofs renumbered // in the last round. Default to starting // points vector last_round_dofs (starting_points); + // delete disallowed elements for (unsigned int i=0; i=n_dofs)) last_round_dofs[i] = -1; + remove_if (last_round_dofs.begin(), last_round_dofs.end(), bind2nd(equal_to(), 0)); - + // now if no valid points remain: // find dof with lowest coordination // number + if (last_round_dofs.size() == 0) { int starting_point = -1; @@ -973,7 +984,7 @@ void DoFHandler<2>::make_sparsity_pattern (dSMatrixStruct &sparsity) const { sparsity.add (dofs_on_this_cell[i], dofs_on_this_cell[j]); }; - + delete[] dofs_on_this_cell; }; @@ -1034,8 +1045,8 @@ void DoFHandler::make_transfer_matrix (const DoFHandler &transfer_from template -void DoFHandler::transfer_cell (const TriaIterator > &old_cell, - const TriaIterator > &new_cell, +void DoFHandler::transfer_cell (const typename DoFHandler::cell_iterator &old_cell, + const typename DoFHandler::cell_iterator &new_cell, dSMatrixStruct &transfer_pattern) const { if (!new_cell->active() && !old_cell->active()) // both cells have children; go deeper @@ -1130,8 +1141,8 @@ void DoFHandler::transfer_cell (const TriaIterator template -void DoFHandler::transfer_cell (const TriaIterator > &old_cell, - const TriaIterator > &new_cell, +void DoFHandler::transfer_cell (const typename DoFHandler::cell_iterator &old_cell, + const typename DoFHandler::cell_iterator &new_cell, dSMatrix &transfer_matrix) const { if (!new_cell->active() && !old_cell->active()) // both cells have children; go deeper diff --git a/deal.II/deal.II/source/fe/Makefile b/deal.II/deal.II/source/fe/Makefile index debc97db8a..354115c466 100644 --- a/deal.II/deal.II/source/fe/Makefile +++ b/deal.II/deal.II/source/fe/Makefile @@ -9,8 +9,13 @@ CXXFLAGS =-O3 -Wuninitialized -finline-functions -ffast-math \ -funroll-loops -felide-constructors -fnonnull-objects $(INCLUDE) ifeq ($(shell uname),SunOS) -CXXFLAGS := -V2.7.2.3 $(CXXFLAGS) -CXXFLAGS.g:= -V2.7.2.3 $(CXXFLAGS.g) +#CXXFLAGS := -V2.7.2.3 $(CXXFLAGS) +#CXXFLAGS.g:= -V2.7.2.3 $(CXXFLAGS.g) +INCLUDE2.8 = -I/usr/local/source/libstdc++-2.8.0/libstdc++ \ + -I/usr/local/source/libstdc++-2.8.0/libstdc++/stl \ + -I/usr/local/source/libstdc++-2.8.0/libio +CXXFLAGS := $(CXXFLAGS) -fno-rtti -fno-exceptions $(INCLUDE2.8) +CXXFLAGS.g:= $(CXXFLAGS.g) -W -fno-rtti -fno-exceptions $(INCLUDE2.8) endif diff --git a/deal.II/deal.II/source/fe/fe_lib.linear.cc b/deal.II/deal.II/source/fe/fe_lib.linear.cc index 16c685166e..7edaae69ee 100644 --- a/deal.II/deal.II/source/fe/fe_lib.linear.cc +++ b/deal.II/deal.II/source/fe/fe_lib.linear.cc @@ -336,8 +336,8 @@ double FEQuadratic::shape_value (const unsigned int i, const Point &) const { - Assert (i::ExcInvalidIndex(i)); + Assert (false, typename FiniteElementBase::ExcNotImplemented()); return 0.; }; @@ -348,8 +348,8 @@ Point FEQuadratic::shape_grad (const unsigned int i, const Point &) const { - Assert (i::ExcInvalidIndex(i)); + Assert (false, typename FiniteElementBase::ExcNotImplemented()); return Point (); }; @@ -359,7 +359,7 @@ void FEQuadratic<2>::fill_fe_values (const Triangulation<2>::cell_iterator &, const vector > &, vector &, vector > &) const { - Assert (false, ExcNotImplemented()); + Assert (false, typename FiniteElementBase<2>::ExcNotImplemented()); }; @@ -394,8 +394,8 @@ double FECubic::shape_value (const unsigned int i, const Point &) const { - Assert (i::ExcInvalidIndex(i)); + Assert (false, typename FiniteElementBase::ExcNotImplemented()); return 0.; }; @@ -406,8 +406,8 @@ Point FECubic::shape_grad (const unsigned int i, const Point &) const { - Assert (i::ExcInvalidIndex(i)); + Assert (false, typename FiniteElementBase::ExcNotImplemented()); return Point (); }; @@ -417,7 +417,7 @@ void FECubic<2>::fill_fe_values (const Triangulation<2>::cell_iterator &, const vector > &, vector &, vector > &) const { - Assert (false, ExcNotImplemented()); + Assert (false, typename FiniteElementBase<2>::ExcNotImplemented()); }; diff --git a/deal.II/deal.II/source/grid/Makefile b/deal.II/deal.II/source/grid/Makefile index 6fce69f393..f6e9cdc473 100644 --- a/deal.II/deal.II/source/grid/Makefile +++ b/deal.II/deal.II/source/grid/Makefile @@ -9,8 +9,13 @@ CXXFLAGS =-O3 -Wuninitialized -finline-functions -ffast-math \ -funroll-loops -felide-constructors -fnonnull-objects $(INCLUDE) ifeq ($(shell uname),SunOS) -CXXFLAGS := -V2.7.2.3 $(CXXFLAGS) -CXXFLAGS.g:= -V2.7.2.3 $(CXXFLAGS.g) +#CXXFLAGS := -V2.7.2.3 $(CXXFLAGS) +#CXXFLAGS.g:= -V2.7.2.3 $(CXXFLAGS.g) +INCLUDE2.8 = -I/usr/local/source/libstdc++-2.8.0/libstdc++ \ + -I/usr/local/source/libstdc++-2.8.0/libstdc++/stl \ + -I/usr/local/source/libstdc++-2.8.0/libio +CXXFLAGS := $(CXXFLAGS) -fno-rtti -fno-exceptions $(INCLUDE2.8) +CXXFLAGS.g:= $(CXXFLAGS.g) -W -fno-rtti -fno-exceptions $(INCLUDE2.8) endif diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 4841727281..0a757181b7 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -368,7 +368,8 @@ void Triangulation<1>::create_hypercube (const double left, vertices.push_back (Point<1> (left)); vertices.push_back (Point<1> (right)); - vertices_used.insert (vertices_used.end(), 2, true); + vertices_used.push_back (true); + vertices_used.push_back (true); levels[0]->lines.lines.push_back (Line(0,1)); levels[0]->lines.children.push_back (-1); @@ -377,7 +378,7 @@ void Triangulation<1>::create_hypercube (const double left, levels[0]->neighbors.push_back (make_pair(-1,-1)); levels[0]->neighbors.push_back (make_pair(-1,-1)); - levels[0]->refine_flags.insert (levels[0]->refine_flags.end(), 1, false); + levels[0]->refine_flags.push_back (false); }; @@ -388,47 +389,19 @@ void Triangulation<2>::create_hypercube (const double left, Assert (vertices.size() == 0, ExcTriangulationNotEmpty()); Assert (n_lines() == 0, ExcTriangulationNotEmpty()); Assert (n_quads() == 0, ExcTriangulationNotEmpty()); - - // create vertices - vertices.push_back (Point<2> (left,left)); - vertices.push_back (Point<2> (right,left)); - vertices.push_back (Point<2> (right,right)); - vertices.push_back (Point<2> (left,right)); - vertices_used.insert (vertices_used.end(), 4, true); - - // create lines - levels[0]->lines.lines.push_back (Line (0,1)); - levels[0]->lines.children.push_back (-1); - levels[0]->lines.used.push_back (true); - levels[0]->lines.user_flags.push_back (false); - levels[0]->lines.lines.push_back (Line (1,2)); - levels[0]->lines.children.push_back (-1); - levels[0]->lines.used.push_back (true); - levels[0]->lines.user_flags.push_back (false); - - levels[0]->lines.lines.push_back (Line (3,2)); - levels[0]->lines.children.push_back (-1); - levels[0]->lines.used.push_back (true); - levels[0]->lines.user_flags.push_back (false); - - levels[0]->lines.lines.push_back (Line (0,3)); - levels[0]->lines.children.push_back (-1); - levels[0]->lines.used.push_back (true); - levels[0]->lines.user_flags.push_back (false); + const Point<2> vertices[4] = { Point<2>(left,left), + Point<2>(right,left), + Point<2>(right,right), + Point<2>(left,right) }; + const int cell_vertices[1][4] = { { 0,1,2,3 } }; + vector > cells (1, vector()); + cells[0].reserve (4); + for (unsigned int j=0; j<4; ++j) + cells[0].push_back (cell_vertices[0][j]); - // create quads - levels[0]->quads.quads.push_back (Quad (0,1,2,3)); - levels[0]->quads.children.push_back (-1); - levels[0]->quads.used.push_back (true); - levels[0]->quads.user_flags.push_back (false); - - levels[0]->neighbors.push_back (make_pair(-1,-1)); - levels[0]->neighbors.push_back (make_pair(-1,-1)); - levels[0]->neighbors.push_back (make_pair(-1,-1)); - levels[0]->neighbors.push_back (make_pair(-1,-1)); - - levels[0]->refine_flags.insert (levels[0]->refine_flags.end(), 1, false); + create_triangulation (vector >(&vertices[0], &vertices[8]), + cells); }; @@ -452,7 +425,16 @@ void Triangulation<2>::create_hyper_L (const double a, const double b) { const int cell_vertices[3][4] = {{0, 1, 4, 3}, {1, 2, 5, 4}, {3, 4, 7, 6}}; - vector > cells (3, vector(4,-1)); + + // with gcc2.9, uncomment this line + // and delete following workaraound +// vector > cells (3, vector(4,-1)); + vector tmp; + tmp.reserve (4); + for (unsigned int i=0; i<4; ++i) + tmp.push_back (-1); + vector > cells (3, tmp); + for (unsigned int i=0; i<3; ++i) for (unsigned int j=0; j<4; ++j) cells[i][j] = cell_vertices[i][j]; @@ -485,7 +467,16 @@ void Triangulation<2>::create_hyper_ball (const Point<2> p, const double radius) {2, 3, 5, 4}, {1, 7, 5, 3}, {6, 4, 5, 7}}; - vector > cells (5, vector(4,-1)); + + // with gcc2.9, uncomment this line + // and delete following workaraound +// vector > cells (5, vector(4,-1)); + vector tmp; + tmp.reserve (4); + for (unsigned int i=0; i<4; ++i) + tmp.push_back (-1); + vector > cells (5, tmp); + for (unsigned int i=0; i<5; ++i) for (unsigned int j=0; j<4; ++j) cells[i][j] = cell_vertices[i][j]; @@ -550,7 +541,7 @@ void Triangulation::save_refine_flags (ostream &out) const { template void Triangulation::load_refine_flags (istream &in) { - int magic_number; + unsigned int magic_number; in >> magic_number; Assert (magic_number==mn_tria_refine_flags_begin, ExcGridReadError()); @@ -655,7 +646,7 @@ void Triangulation::save_user_flags_line (ostream &out) const { template void Triangulation::load_user_flags_line (istream &in) { - int magic_number; + unsigned int magic_number; in >> magic_number; Assert (magic_number==mn_tria_line_user_flags_begin, ExcGridReadError()); @@ -734,7 +725,7 @@ void Triangulation<1>::load_user_flags_quad (istream &) { template void Triangulation::load_user_flags_quad (istream &in) { - int magic_number; + unsigned int magic_number; in >> magic_number; Assert (magic_number==mn_tria_quad_user_flags_begin, ExcGridReadError()); @@ -1664,7 +1655,7 @@ void Triangulation<1>::execute_refinement () { if (cell->neighbor(1).state() != valid) second_child->set_neighbor (1, cell->neighbor(1)); else - if (cell->neighbor(1)->active) + if (cell->neighbor(1)->active()) second_child->set_neighbor (1, cell->neighbor(1)); else // right neighbor is refined diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index 353d2a457d..7bf6e0ad95 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -445,74 +445,83 @@ template class QuadAccessor<2>; -/*------------------------ Functions: CellAccessor ---------------------*/ -template -int CellAccessor::neighbor_index (const unsigned int i) const { - Assert (i<2*dim, ExcInvalidNeighbor(i)); - return tria->levels[present_level]->neighbors[present_index*2*dim+i].second; + +/*------------------------ Functions: CellAccessor<1> -----------------------*/ + + +bool CellAccessor<1>::at_boundary () const { + return at_boundary(0) || at_boundary(1); }; -template -int CellAccessor::neighbor_level (const unsigned int i) const { - Assert (i<2*dim, ExcInvalidNeighbor(i)); - return tria->levels[present_level]->neighbors[present_index*2*dim+i].first; + +int CellAccessor<1>::neighbor_index (const unsigned int i) const { + Assert (i<2*1, ExcInvalidNeighbor(i)); + return tria->levels[present_level]->neighbors[present_index*2*1+i].second; }; -template -void CellAccessor::set_neighbor (const unsigned int i, - const TriaIterator > &pointer) const { - Assert (i<2*dim, ExcInvalidNeighbor(i)); - tria->levels[present_level]->neighbors[present_index*2*dim+i].first + +int CellAccessor<1>::neighbor_level (const unsigned int i) const { + Assert (i<2*1, ExcInvalidNeighbor(i)); + return tria->levels[present_level]->neighbors[present_index*2*1+i].first; +}; + + + + +void CellAccessor<1>::set_neighbor (const unsigned int i, + const TriaIterator<1,CellAccessor<1> > &pointer) const { + Assert (i<2*1, ExcInvalidNeighbor(i)); + tria->levels[present_level]->neighbors[present_index*2*1+i].first = pointer.accessor.present_level; - tria->levels[present_level]->neighbors[present_index*2*dim+i].second + tria->levels[present_level]->neighbors[present_index*2*1+i].second = pointer.accessor.present_index; }; -template -bool CellAccessor::at_boundary (const unsigned int i) const { + +bool CellAccessor<1>::at_boundary (const unsigned int i) const { Assert (used(), ExcCellNotUsed()); - Assert (i<2*dim, ExcInvalidIndex (i,0,2*dim-1)); + Assert (i<2*1, ExcInvalidIndex (i,0,2*1-1)); return (neighbor(i).state() != valid); }; -template -bool CellAccessor::refine_flag_set () const { + +bool CellAccessor<1>::refine_flag_set () const { Assert (used() && active(), ExcRefineCellNotActive()); return tria->levels[present_level]->refine_flags[present_index]; }; -template -void CellAccessor::set_refine_flag () const { + +void CellAccessor<1>::set_refine_flag () const { Assert (used() && active(), ExcRefineCellNotActive()); tria->levels[present_level]->refine_flags[present_index] = true; }; -template -void CellAccessor::clear_refine_flag () const { + +void CellAccessor<1>::clear_refine_flag () const { Assert (used() && active(), ExcRefineCellNotActive()); tria->levels[present_level]->refine_flags[present_index] = false; }; -template -TriaIterator > -CellAccessor::neighbor (const unsigned int i) const { - TriaIterator > q (tria, neighbor_level (i), neighbor_index (i)); + +TriaIterator<1,CellAccessor<1> > +CellAccessor<1>::neighbor (const unsigned int i) const { + TriaIterator<1,CellAccessor<1> > q (tria, neighbor_level (i), neighbor_index (i)); #ifdef DEBUG if (q.state() != past_the_end) @@ -523,10 +532,10 @@ CellAccessor::neighbor (const unsigned int i) const { -template -TriaIterator > -CellAccessor::child (const unsigned int i) const { - TriaIterator > q (tria, present_level+1, child_index (i)); + +TriaIterator<1,CellAccessor<1> > +CellAccessor<1>::child (const unsigned int i) const { + TriaIterator<1,CellAccessor<1> > q (tria, present_level+1, child_index (i)); #ifdef DEBUG if (q.state() != past_the_end) @@ -537,33 +546,117 @@ CellAccessor::child (const unsigned int i) const { -template -bool CellAccessor::active () const { + +bool CellAccessor<1>::active () const { return !has_children(); }; -/*------------------------ Functions: CellAccessor<1> -----------------------*/ +/*------------------------ Functions: CellAccessor<2> -----------------------*/ -bool CellAccessor<1>::at_boundary () const { - return at_boundary(0) || at_boundary(1); +bool CellAccessor<2>::at_boundary () const { + return at_boundary(0) || at_boundary(1) || at_boundary(2) || at_boundary(3); }; -/*------------------------ Functions: CellAccessor<2> -----------------------*/ +int CellAccessor<2>::neighbor_index (const unsigned int i) const { + Assert (i<2*2, ExcInvalidNeighbor(i)); + return tria->levels[present_level]->neighbors[present_index*2*2+i].second; +}; -bool CellAccessor<2>::at_boundary () const { - return at_boundary(0) || at_boundary(1) || at_boundary(2) || at_boundary(3); + + +int CellAccessor<2>::neighbor_level (const unsigned int i) const { + Assert (i<2*2, ExcInvalidNeighbor(i)); + return tria->levels[present_level]->neighbors[present_index*2*2+i].first; }; +void CellAccessor<2>::set_neighbor (const unsigned int i, + const TriaIterator<2,CellAccessor<2> > &pointer) const { + Assert (i<2*2, ExcInvalidNeighbor(i)); + tria->levels[present_level]->neighbors[present_index*2*2+i].first + = pointer.accessor.present_level; + tria->levels[present_level]->neighbors[present_index*2*2+i].second + = pointer.accessor.present_index; +}; + + + + +bool CellAccessor<2>::at_boundary (const unsigned int i) const { + Assert (used(), ExcCellNotUsed()); + Assert (i<2*2, ExcInvalidIndex (i,0,2*2-1)); + + return (neighbor(i).state() != valid); +}; + + + + +bool CellAccessor<2>::refine_flag_set () const { + Assert (used() && active(), ExcRefineCellNotActive()); + return tria->levels[present_level]->refine_flags[present_index]; +}; + + + + +void CellAccessor<2>::set_refine_flag () const { + Assert (used() && active(), ExcRefineCellNotActive()); + tria->levels[present_level]->refine_flags[present_index] = true; +}; + + + + +void CellAccessor<2>::clear_refine_flag () const { + Assert (used() && active(), ExcRefineCellNotActive()); + tria->levels[present_level]->refine_flags[present_index] = false; +}; + + + + +TriaIterator<2,CellAccessor<2> > +CellAccessor<2>::neighbor (const unsigned int i) const { + TriaIterator<2,CellAccessor<2> > q (tria, neighbor_level (i), neighbor_index (i)); + +#ifdef DEBUG + if (q.state() != past_the_end) + Assert (q->used(), ExcUnusedCellAsNeighbor()); +#endif + return q; +}; + + + + +TriaIterator<2,CellAccessor<2> > +CellAccessor<2>::child (const unsigned int i) const { + TriaIterator<2,CellAccessor<2> > q (tria, present_level+1, child_index (i)); + +#ifdef DEBUG + if (q.state() != past_the_end) + Assert (q->used(), ExcUnusedCellAsChild()); +#endif + return q; +}; + + + + +bool CellAccessor<2>::active () const { + return !has_children(); +}; + diff --git a/deal.II/deal.II/source/numerics/Makefile b/deal.II/deal.II/source/numerics/Makefile index 87d5217a12..0d09b34614 100644 --- a/deal.II/deal.II/source/numerics/Makefile +++ b/deal.II/deal.II/source/numerics/Makefile @@ -9,8 +9,13 @@ CXXFLAGS =-O3 -Wuninitialized -finline-functions -ffast-math \ -funroll-loops -felide-constructors -fnonnull-objects $(INCLUDE) ifeq ($(shell uname),SunOS) -CXXFLAGS := -V2.7.2.3 $(CXXFLAGS) -CXXFLAGS.g:= -V2.7.2.3 $(CXXFLAGS.g) +#CXXFLAGS := -V2.7.2.3 $(CXXFLAGS) +#CXXFLAGS.g:= -V2.7.2.3 $(CXXFLAGS.g) +INCLUDE2.8 = -I/usr/local/source/libstdc++-2.8.0/libstdc++ \ + -I/usr/local/source/libstdc++-2.8.0/libstdc++/stl \ + -I/usr/local/source/libstdc++-2.8.0/libio +CXXFLAGS := $(CXXFLAGS) -fno-rtti -fno-exceptions $(INCLUDE2.8) +CXXFLAGS.g:= $(CXXFLAGS.g) -W -fno-rtti -fno-exceptions $(INCLUDE2.8) endif diff --git a/deal.II/deal.II/source/numerics/base.cc b/deal.II/deal.II/source/numerics/base.cc index 106fdddfaf..ae4c3ef118 100644 --- a/deal.II/deal.II/source/numerics/base.cc +++ b/deal.II/deal.II/source/numerics/base.cc @@ -5,6 +5,7 @@ #include #include #include +#include #include "../../../mia/control.h" #include "../../../mia/vectormemory.h" @@ -12,6 +13,8 @@ + + extern TriaActiveIterator<1,CellAccessor<1> > __dummy1233; // for gcc2.7 extern TriaActiveIterator<2,CellAccessor<2> > __dummy1234; @@ -30,6 +33,10 @@ ProblemBase::ProblemBase (Triangulation *tria, +template +ProblemBase::~ProblemBase () {}; + + template void ProblemBase::assemble (const Equation &equation, @@ -96,12 +103,48 @@ void ProblemBase::solve () { +/* +template +void ProblemBase::integrate_L1_difference (const Function &exact_solution, + vector &difference, + const Quadrature &q, + const FiniteElement &fe) const { + Assert (fe == dof_handler->get_selected_fe(), ExcInvalidFE()); + + difference.erase (difference.begin(), difference.end()); + difference.reserve (tria->n_cells()); + + // loop over all cells + DoFHandler::active_dof_iterator cell = dof_handler->begin_active(), + endc = dof_handler->end(); + for (; cell != end; ++cell) + { + double diff=0; + + difference.push_back (diff); + }; +}; +*/ + + + template void ProblemBase::fill_data (DataOut &out) const { out.clear_data_vectors (); out.attach_dof_handler (*dof_handler); - out.add_data_vector (solution, "solution"); + + pair solution_name = get_solution_name (); + out.add_data_vector (solution, + solution_name.first, solution_name.second); +}; + + +/* +template +pair ProblemBase::get_solution_name () const { + return make_pair("solution", ""); }; +*/ diff --git a/tests/big-tests/Makefile b/tests/big-tests/Makefile index 6c77979105..5825f83c2e 100644 --- a/tests/big-tests/Makefile +++ b/tests/big-tests/Makefile @@ -14,8 +14,13 @@ LIBS.g = $(LIBPATH) -lbasic.g -lgrid.g -lfe.g -lnumerics.g -llac.g LIBS = $(LIBS.g:.g=) ifeq ($(shell uname),SunOS) -CXXFLAGS := -V2.7.2.3 $(CXXFLAGS) -CXXFLAGS.g:= -V2.7.2.3 $(CXXFLAGS.g) +#CXXFLAGS := -V2.7.2.3 $(CXXFLAGS) +#CXXFLAGS.g:= -V2.7.2.3 $(CXXFLAGS.g) +INCLUDE2.8 = -I/usr/local/source/libstdc++-2.8.0/libstdc++ \ + -I/usr/local/source/libstdc++-2.8.0/libstdc++/stl \ + -I/usr/local/source/libstdc++-2.8.0/libio +CXXFLAGS := $(CXXFLAGS) -fno-rtti -fno-exceptions $(INCLUDE2.8) +CXXFLAGS.g:= $(CXXFLAGS.g) -W -fno-rtti -fno-exceptions $(INCLUDE2.8) endif -- 2.39.5