From 9e27ee17f4c44225b6ececcb32276b228eab71ff Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Thu, 22 May 2014 20:35:37 +0000 Subject: [PATCH] astyle on recent changes git-svn-id: https://svn.dealii.org/trunk@32968 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/algorithms/any_data.h | 402 +++++++++--------- deal.II/include/deal.II/algorithms/newton.h | 2 +- .../deal.II/algorithms/newton.templates.h | 16 +- deal.II/include/deal.II/algorithms/operator.h | 10 +- .../deal.II/algorithms/operator.templates.h | 116 +++-- .../algorithms/theta_timestepping.templates.h | 24 +- 6 files changed, 284 insertions(+), 286 deletions(-) diff --git a/deal.II/include/deal.II/algorithms/any_data.h b/deal.II/include/deal.II/algorithms/any_data.h index f903bbe693..9d67972c95 100644 --- a/deal.II/include/deal.II/algorithms/any_data.h +++ b/deal.II/include/deal.II/algorithms/any_data.h @@ -36,159 +36,159 @@ DEAL_II_NAMESPACE_OPEN * for long enough, then change to a map. */ class AnyData : - public Subscriptor + public Subscriptor { - public: - /// Default constructor for empty object - AnyData(); - - /// Number of stored data objects. - unsigned int size() const; - - /// Add a new data object - template - void add(type entry, const std::string& name); - - /** - * @brief Merge the data of another NamedData to the end of this object. - */ - void merge(const AnyData& other); - - /** - * @brief Access to stored data object by name. - * - * Find the object with given name, try to convert it to - * type and return it. This function throws an exception - * if either the name does not exist or if the conversion - * fails. If such an exception is not desired, use try_read() - * instead. - */ - template - type entry (const std::string& name); - - /** - * @brief Read-only access to stored data object by name. - * - * Find the object with given name, try to convert it to - * type and return it. This function throws an exception - * if either the name does not exist or if the conversion - * fails. If such an exception is not desired, use try_read() - * instead. - */ - template - const type entry (const std::string& name) const; - - /** - * @brief Dedicated read only access by name. - * - * For a constant object, this function equals entry(). For a - * non-const object, it forces read only access to the data. In - * particular, it throws an exception if the object is not found - * or cannot be converted to type. If such an exception is not - * desired, use try_read() instead. - * - * @warning Do not use this function for stored objects which are - * pointers. Use read_ptr() instead! - */ - template - const type read (const std::string& name) const; - - /** - * @brief Dedicated read only access by name for pointer data. - * - * If the stored data object is a pointer to a constant object, the logic - * of access becomes fairly complicated. Namely, the standard read - * function may fail, depending on whether it was a const pointer - * or a regular pointer. This function fixes the logic and - * ascertains that the object does not become mutable by accident. - */ - template - const type* read_ptr (const std::string& name) const; - - /** - * Perform the same action as read_ptr(), but do not throw an - * exception if the pointer does not exist. Return a null pointer - * instead. - */ - template - const type* try_read_ptr (const std::string& name) const; - - /** - * @brief Dedicated read only access by name without exceptions. - * - * This function tries to find the name in the list and return a - * pointer to the associated object. If either the name is not - * found or the object cannot be converted to the return type, a - * null pointer is returned. - */ - template - const type * try_read (const std::string& name) const; - +public: + /// Default constructor for empty object + AnyData(); + + /// Number of stored data objects. + unsigned int size() const; + + /// Add a new data object + template + void add(type entry, const std::string &name); + + /** + * @brief Merge the data of another NamedData to the end of this object. + */ + void merge(const AnyData &other); + + /** + * @brief Access to stored data object by name. + * + * Find the object with given name, try to convert it to + * type and return it. This function throws an exception + * if either the name does not exist or if the conversion + * fails. If such an exception is not desired, use try_read() + * instead. + */ + template + type entry (const std::string &name); + + /** + * @brief Read-only access to stored data object by name. + * + * Find the object with given name, try to convert it to + * type and return it. This function throws an exception + * if either the name does not exist or if the conversion + * fails. If such an exception is not desired, use try_read() + * instead. + */ + template + const type entry (const std::string &name) const; + + /** + * @brief Dedicated read only access by name. + * + * For a constant object, this function equals entry(). For a + * non-const object, it forces read only access to the data. In + * particular, it throws an exception if the object is not found + * or cannot be converted to type. If such an exception is not + * desired, use try_read() instead. + * + * @warning Do not use this function for stored objects which are + * pointers. Use read_ptr() instead! + */ + template + const type read (const std::string &name) const; + + /** + * @brief Dedicated read only access by name for pointer data. + * + * If the stored data object is a pointer to a constant object, the logic + * of access becomes fairly complicated. Namely, the standard read + * function may fail, depending on whether it was a const pointer + * or a regular pointer. This function fixes the logic and + * ascertains that the object does not become mutable by accident. + */ + template + const type *read_ptr (const std::string &name) const; + + /** + * Perform the same action as read_ptr(), but do not throw an + * exception if the pointer does not exist. Return a null pointer + * instead. + */ + template + const type *try_read_ptr (const std::string &name) const; + + /** + * @brief Dedicated read only access by name without exceptions. + * + * This function tries to find the name in the list and return a + * pointer to the associated object. If either the name is not + * found or the object cannot be converted to the return type, a + * null pointer is returned. + */ + template + const type *try_read (const std::string &name) const; + /** * Access to stored data object by index. */ - template - type entry (const unsigned int i); - - /// Read-only access to stored data object by index. - template - const type entry (const unsigned int i) const; - - /// Dedicated read only access. - template - const type read (const unsigned int i) const; - - /// Dedicated read only access to pointer object. - template - const type* read_ptr (const unsigned int i) const; - - /// Dedicated read only access to pointer object without exception. - template - const type* try_read_ptr (const unsigned int i) const; - - /// Dedicated read only access without exception. - template - const type* try_read (const unsigned int i) const; - - /// Name of object at index. - const std::string &name(const unsigned int i) const; - - /** - * @brief Find index of a named object - * - * Try to find the objecty and return its index in the list. Throw - * an exception if the object has not been found. - */ - unsigned int find(const std::string &name) const; - - /** - * @brief Try to find index of a named object - * - * Try to find the objecty and return its index in the - * list. returns numbers::invalid_unsigned_int if the name was not - * found. - */ - unsigned int try_find(const std::string &name) const; - - /// Find out if object is of a certain type - template - bool is_type(const unsigned int i) const; - - /// Conversion from old NamedData - template - AnyData(const NamedData&); - - /// An entry with this name does not exist in the AnyData object. - DeclException1(ExcNameNotFound, std::string&, - << "No entry with the name " << arg1 << " exists"); - - /// The requested type and the stored type are different - DeclException2(ExcTypeMismatch, - char*, char*, - << "The requested type " << arg1 - << " and the stored type " << arg2 - << " must coincide"); - + template + type entry (const unsigned int i); + + /// Read-only access to stored data object by index. + template + const type entry (const unsigned int i) const; + + /// Dedicated read only access. + template + const type read (const unsigned int i) const; + + /// Dedicated read only access to pointer object. + template + const type *read_ptr (const unsigned int i) const; + + /// Dedicated read only access to pointer object without exception. + template + const type *try_read_ptr (const unsigned int i) const; + + /// Dedicated read only access without exception. + template + const type *try_read (const unsigned int i) const; + + /// Name of object at index. + const std::string &name(const unsigned int i) const; + + /** + * @brief Find index of a named object + * + * Try to find the objecty and return its index in the list. Throw + * an exception if the object has not been found. + */ + unsigned int find(const std::string &name) const; + + /** + * @brief Try to find index of a named object + * + * Try to find the objecty and return its index in the + * list. returns numbers::invalid_unsigned_int if the name was not + * found. + */ + unsigned int try_find(const std::string &name) const; + + /// Find out if object is of a certain type + template + bool is_type(const unsigned int i) const; + + /// Conversion from old NamedData + template + AnyData(const NamedData &); + + /// An entry with this name does not exist in the AnyData object. + DeclException1(ExcNameNotFound, std::string &, + << "No entry with the name " << arg1 << " exists"); + + /// The requested type and the stored type are different + DeclException2(ExcTypeMismatch, + char *, char *, + << "The requested type " << arg1 + << " and the stored type " << arg2 + << " must coincide"); + /** * Exception indicating that a function expected a vector to have a * certain name, but NamedData had a different name in that @@ -196,11 +196,11 @@ class AnyData : */ DeclException2(ExcNameMismatch, int, std::string, << "Name at position " << arg1 << " is not equal to " << arg2); - private: - /// The stored data - std::vector data; - /// The names of the stored data - std::vector names; +private: + /// The stored data + std::vector data; + /// The names of the stored data + std::vector names; }; @@ -211,9 +211,9 @@ AnyData::AnyData() template inline -AnyData::AnyData(const NamedData& other) +AnyData::AnyData(const NamedData &other) { - for (unsigned int i=0;i(&data[i]); + type *p = boost::any_cast(&data[i]); Assert(p != 0, - ExcTypeMismatch(typeid(type).name(),data[i].type().name())); + ExcTypeMismatch(typeid(type).name(),data[i].type().name())); return *p; } @@ -246,11 +246,11 @@ const type AnyData::entry (const unsigned int i) const { AssertIndexRange(i, size()); - const type* p = boost::any_cast(&data[i]); + const type *p = boost::any_cast(&data[i]); if (p==0 ) p = boost::any_cast(&data[i]); Assert(p != 0, - ExcTypeMismatch(typeid(type).name(),data[i].type().name())); + ExcTypeMismatch(typeid(type).name(),data[i].type().name())); return *p; } @@ -261,50 +261,50 @@ const type AnyData::read(const unsigned int i) const { AssertIndexRange(i, size()); - const type* p = boost::any_cast(&data[i]); + const type *p = boost::any_cast(&data[i]); if (p==0) p = boost::any_cast(&data[i]); Assert(p != 0, - ExcTypeMismatch(typeid(type).name(),data[i].type().name())); + ExcTypeMismatch(typeid(type).name(),data[i].type().name())); return *p; } template inline -const type* +const type * AnyData::read_ptr(const unsigned int i) const { AssertIndexRange(i, size()); - const type* const * p = boost::any_cast(&data[i]); + const type *const *p = boost::any_cast(&data[i]); if (p==0) - p = boost::any_cast(&data[i]); + p = boost::any_cast(&data[i]); Assert(p != 0, - ExcTypeMismatch(typeid(type*).name(),data[i].type().name())); + ExcTypeMismatch(typeid(type *).name(),data[i].type().name())); return *p; } template inline -const type* +const type * AnyData::try_read_ptr(const unsigned int i) const { AssertIndexRange(i, size()); - const type* const * p = boost::any_cast(&data[i]); + const type *const *p = boost::any_cast(&data[i]); if (p==0) - p = boost::any_cast(&data[i]); + p = boost::any_cast(&data[i]); return *p; } template inline -const type* +const type * AnyData::try_read(const unsigned int i) const { AssertIndexRange(i, size()); - const type* p = boost::any_cast(&data[i]); + const type *p = boost::any_cast(&data[i]); if (p==0) p = boost::any_cast(&data[i]); return p; @@ -312,7 +312,7 @@ AnyData::try_read(const unsigned int i) const inline -const std::string& +const std::string & AnyData::name(const unsigned int i) const { AssertIndexRange(i, size()); @@ -322,25 +322,25 @@ AnyData::name(const unsigned int i) const inline unsigned int -AnyData::try_find(const std::string& n) const +AnyData::try_find(const std::string &n) const { std::vector::const_iterator it = std::find(names.begin(), names.end(), n); - + if (it == names.end()) return numbers::invalid_unsigned_int; - + return it - names.begin(); } inline unsigned int -AnyData::find(const std::string& n) const +AnyData::find(const std::string &n) const { const unsigned int i = try_find(n); Assert(i != numbers::invalid_unsigned_int, ExcNameNotFound(n)); - + return i; } @@ -357,12 +357,12 @@ AnyData::is_type(const unsigned int i) const template inline type -AnyData::entry (const std::string& n) +AnyData::entry (const std::string &n) { const unsigned int i = find(n); - type* p = boost::any_cast(&data[i]); + type *p = boost::any_cast(&data[i]); Assert(p != 0, - ExcTypeMismatch(typeid(type).name(),data[i].type().name())); + ExcTypeMismatch(typeid(type).name(),data[i].type().name())); return *p; } @@ -370,12 +370,12 @@ AnyData::entry (const std::string& n) template inline const type -AnyData::entry (const std::string& n) const +AnyData::entry (const std::string &n) const { const unsigned int i = find(n); - const type* p = boost::any_cast(&data[i]); + const type *p = boost::any_cast(&data[i]); Assert(p != 0, - ExcTypeMismatch(typeid(type).name(),data[i].type().name())); + ExcTypeMismatch(typeid(type).name(),data[i].type().name())); return *p; } @@ -383,51 +383,51 @@ AnyData::entry (const std::string& n) const template inline const type -AnyData::read(const std::string& n) const +AnyData::read(const std::string &n) const { const unsigned int i = find(n); - const type* p = boost::any_cast(&data[i]); + const type *p = boost::any_cast(&data[i]); Assert(p != 0, - ExcTypeMismatch(typeid(type).name(),data[i].type().name())); + ExcTypeMismatch(typeid(type).name(),data[i].type().name())); return *p; } template inline -const type* -AnyData::read_ptr(const std::string& n) const +const type * +AnyData::read_ptr(const std::string &n) const { const unsigned int i = find(n); - const type* const * p = boost::any_cast(&data[i]); + const type *const *p = boost::any_cast(&data[i]); if (p==0) - p = boost::any_cast(&data[i]); + p = boost::any_cast(&data[i]); Assert(p != 0, - ExcTypeMismatch(typeid(type).name(),data[i].type().name())); + ExcTypeMismatch(typeid(type).name(),data[i].type().name())); return *p; } template inline -const type* -AnyData::try_read_ptr(const std::string& n) const +const type * +AnyData::try_read_ptr(const std::string &n) const { const unsigned int i = try_find(n); if (i == numbers::invalid_unsigned_int) return 0; - - const type* const * p = boost::any_cast(&data[i]); + + const type *const *p = boost::any_cast(&data[i]); if (p==0) - p = boost::any_cast(&data[i]); + p = boost::any_cast(&data[i]); return *p; } template inline -const type* -AnyData::try_read(const std::string& n) const +const type * +AnyData::try_read(const std::string &n) const { // Try to find name std::vector::const_iterator it = @@ -438,7 +438,7 @@ AnyData::try_read(const std::string& n) const // Compute index and return casted pointer unsigned int i=it-names.begin(); - const type* p = boost::any_cast(&data[i]); + const type *p = boost::any_cast(&data[i]); return p; } @@ -446,7 +446,7 @@ AnyData::try_read(const std::string& n) const template inline void -AnyData::add(type ent, const std::string& n) +AnyData::add(type ent, const std::string &n) { boost::any e = ent; data.push_back(e); @@ -456,7 +456,7 @@ AnyData::add(type ent, const std::string& n) inline void -AnyData::merge(const AnyData& other) +AnyData::merge(const AnyData &other) { for (unsigned int i=0; i &out, const NamedData &in); + virtual void operator() (NamedData &out, const NamedData &in); virtual void notify(const Event &); diff --git a/deal.II/include/deal.II/algorithms/newton.templates.h b/deal.II/include/deal.II/algorithms/newton.templates.h index acb61f4712..c397fd22be 100644 --- a/deal.II/include/deal.II/algorithms/newton.templates.h +++ b/deal.II/include/deal.II/algorithms/newton.templates.h @@ -80,7 +80,7 @@ namespace Algorithms inverse_derivative->notify(e); } - + template double Newton::threshold(const double thr) @@ -89,8 +89,8 @@ namespace Algorithms assemble_threshold = thr; return t; } - - + + template void Newton::operator() (NamedData &out, const NamedData &in) @@ -105,7 +105,7 @@ namespace Algorithms Assert (out.size() == 1, ExcNotImplemented()); deallog.push ("Newton"); - VECTOR &u = *out.entry(0); + VECTOR &u = *out.entry(0); if (debug>2) deallog << "u: " << u.l2_norm() << std::endl; @@ -117,14 +117,14 @@ namespace Algorithms res->reinit(u); AnyData src1; AnyData src2; - src1.add(&u, "Newton iterate"); + src1.add(&u, "Newton iterate"); src1.merge(in); - src2.add(res, "Newton residual"); + src2.add(res, "Newton residual"); src2.merge(src1); AnyData out1; - out1.add(res, "Residual"); + out1.add(res, "Residual"); AnyData out2; - out2.add(Du, "Update"); + out2.add(Du, "Update"); unsigned int step = 0; // fill res with (f(u), v) diff --git a/deal.II/include/deal.II/algorithms/operator.h b/deal.II/include/deal.II/algorithms/operator.h index bad83a96dd..2f5e935127 100644 --- a/deal.II/include/deal.II/algorithms/operator.h +++ b/deal.II/include/deal.II/algorithms/operator.h @@ -103,7 +103,7 @@ namespace Algorithms * of reassembling the matrix. */ Event notifications; - + }; /** @@ -141,7 +141,7 @@ namespace Algorithms { public: Operator(); - + /** * Implementation of the function in the base class in order to do * compatibility conversions between the old and the new @@ -161,7 +161,7 @@ namespace Algorithms * Set this true to avoid compatibility warnings. */ bool silent_compatibility; - + private: /** * While we are providing compatibility functions to the old @@ -203,8 +203,8 @@ namespace Algorithms /** * Output all the vectors in AnyData. */ - virtual OutputOperator &operator<< (const AnyData& vectors); - + virtual OutputOperator &operator<< (const AnyData &vectors); + /** * @deprecated Output all the vectors in NamedData. */ diff --git a/deal.II/include/deal.II/algorithms/operator.templates.h b/deal.II/include/deal.II/algorithms/operator.templates.h index 0a941933ed..0824616807 100644 --- a/deal.II/include/deal.II/algorithms/operator.templates.h +++ b/deal.II/include/deal.II/algorithms/operator.templates.h @@ -24,58 +24,56 @@ namespace Algorithms { template Operator::Operator() - : silent_compatibility(false), compatibility_flag(false) + : silent_compatibility(false), compatibility_flag(false) {} template void - Operator::operator() (AnyData& out, const AnyData& in) + Operator::operator() (AnyData &out, const AnyData &in) { // Had this function been overloaded in a derived clas, it would // not have been called. Therefore, we have to start the // compatibility engine. But before, we have to avoid an endless loop. Assert(!compatibility_flag, ExcMessage("Compatibility resolution of Operator generates and endless loop\n" - "Please provide an operator() in a derived class")); + "Please provide an operator() in a derived class")); compatibility_flag = true; - - NamedData new_out; - for (unsigned int i=0;i new_out; + for (unsigned int i=0; i(i)) - new_out.add(out.entry(i), out.name(i)); - else - if (!silent_compatibility) - deallog << "Cannot convert AnyData argument " << out.name(i) << " to NamedData" - << std::endl; + if (out.is_type(i)) + new_out.add(out.entry(i), out.name(i)); + else if (!silent_compatibility) + deallog << "Cannot convert AnyData argument " << out.name(i) << " to NamedData" + << std::endl; } - - NamedData new_in; - for (unsigned int i=0;i new_in; + for (unsigned int i=0; i(i)) - { - // This const cast is due to the wrong constness handling - // in NamedData. As soon as NamedData is gone, this code - // will not be necessary anymore. And deprecating begins - // now. - VECTOR* p = const_cast (in.entry(i)); - new_in.add(p, in.name(i)); - } - else if (in.is_type(i)) - { - // This const cast is due to the wrong constness handling - // in NamedData. As soon as NamedData is gone, this code - // will not be necessary anymore. And deprecating begins - // now. - VECTOR* p = const_cast (in.entry(i)); - new_in.add(p, in.name(i)); - } - else - if (!silent_compatibility) - deallog << "Cannot convert AnyData argument " << in.name(i) - << " to NamedData" << std::endl; + // deallog << "Convert " << in.name(i) << std::endl; + if (in.is_type(i)) + { + // This const cast is due to the wrong constness handling + // in NamedData. As soon as NamedData is gone, this code + // will not be necessary anymore. And deprecating begins + // now. + VECTOR *p = const_cast (in.entry(i)); + new_in.add(p, in.name(i)); + } + else if (in.is_type(i)) + { + // This const cast is due to the wrong constness handling + // in NamedData. As soon as NamedData is gone, this code + // will not be necessary anymore. And deprecating begins + // now. + VECTOR *p = const_cast (in.entry(i)); + new_in.add(p, in.name(i)); + } + else if (!silent_compatibility) + deallog << "Cannot convert AnyData argument " << in.name(i) + << " to NamedData" << std::endl; } this->operator() (new_out, new_in); compatibility_flag = false; @@ -84,21 +82,21 @@ namespace Algorithms template void - Operator::operator() (NamedData& out, const NamedData& in) + Operator::operator() (NamedData &out, const NamedData &in) { // Had this function been overloaded in a derived clas, it would // not have been called. Therefore, we have to start the // compatibility engine. But before, we have to avoid an endless loop. Assert(!compatibility_flag, ExcMessage("Compatibility resolution of Operator generates and endless loop\n" - "Please provide an operator() in a derived class")); + "Please provide an operator() in a derived class")); compatibility_flag = true; - + AnyData new_out; - for (unsigned int i=0;ioperator() (new_out, new_in); @@ -124,37 +122,37 @@ namespace Algorithms template OutputOperator & - OutputOperator::operator<< (const AnyData& vectors) + OutputOperator::operator<< (const AnyData &vectors) { if (os == 0) { deallog << "Step " << step << std::endl; for (unsigned int i=0; i(i); - if (v == 0) continue; - for (unsigned int j=0; jsize(); ++j) - (*os) << ' ' << (*v)(j); - deallog << std::endl; - } + { + const VECTOR *v = vectors.try_read_ptr(i); + if (v == 0) continue; + for (unsigned int j=0; jsize(); ++j) + (*os) << ' ' << (*v)(j); + deallog << std::endl; + } deallog << std::endl; } else { (*os) << ' ' << step; for (unsigned int i=0; i(i); - if (v == 0) continue; - for (unsigned int j=0; jsize(); ++j) - (*os) << ' ' << (*v)(j); - (*os) << std::endl; - } + { + const VECTOR *v = vectors.try_read_ptr(i); + if (v == 0) continue; + for (unsigned int j=0; jsize(); ++j) + (*os) << ' ' << (*v)(j); + (*os) << std::endl; + } (*os) << std::endl; } return *this; } - + template OutputOperator & diff --git a/deal.II/include/deal.II/algorithms/theta_timestepping.templates.h b/deal.II/include/deal.II/algorithms/theta_timestepping.templates.h index ab0d36a243..3e3e19c765 100644 --- a/deal.II/include/deal.II/algorithms/theta_timestepping.templates.h +++ b/deal.II/include/deal.II/algorithms/theta_timestepping.templates.h @@ -67,8 +67,8 @@ namespace Algorithms { Operator::operator() (out, in); } - - + + template void ThetaTimestepping::operator() (AnyData &out, const AnyData &in) @@ -77,7 +77,7 @@ namespace Algorithms deallog.push ("Theta"); - VECTOR& solution = *out.entry(0); + VECTOR &solution = *out.entry(0); GrowingVectorMemory mem; typename VectorMemory::Pointer aux(mem); aux->reinit(solution); @@ -90,20 +90,20 @@ namespace Algorithms // vector associated with the old // timestep AnyData src1; - src1.add(&solution, "Previous iterate"); - src1.add(&d_explicit.time, "Time"); - src1.add(&d_explicit.step, "Timestep"); + src1.add(&solution, "Previous iterate"); + src1.add(&d_explicit.time, "Time"); + src1.add(&d_explicit.step, "Timestep"); src1.merge(in); AnyData src2; - src2.add(&solution, "Previous iterate"); + src2.add(&solution, "Previous iterate"); AnyData out1; - out1.add(aux, "Solution"); + out1.add(aux, "Solution"); // The data provided to the inner solver - src2.add(aux, "Previous time"); - src2.add(&d_implicit.time, "Time"); - src2.add(&d_explicit.step, "Timestep"); + src2.add(aux, "Previous time"); + src2.add(&d_implicit.time, "Time"); + src2.add(&d_explicit.step, "Timestep"); src2.merge(in); if (output != 0) @@ -114,7 +114,7 @@ namespace Algorithms const bool implicit_silent = op_implicit->silent_compatibility; op_explicit->silent_compatibility = true; op_implicit->silent_compatibility = true; - + for (unsigned int count = 1; d_explicit.time < control.final(); ++count) { const bool step_change = control.advance(); -- 2.39.5