]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix Functions::Monomial::gradient 1057/head
authorangelrca <angel.rcarballo@udc.es>
Mon, 29 Jun 2015 15:48:37 +0000 (17:48 +0200)
committerangelrca <angel.rcarballo@udc.es>
Tue, 30 Jun 2015 07:34:19 +0000 (09:34 +0200)
Fix Functions::Monomial::gradient

Fix Functions::Monomial::gradient

Fix Functions::Monomial::gradient

Fix Functions::Monomial::gradient

doc/news/changes.h
include/deal.II/base/function_lib.h
source/base/function_lib.cc

index d7ba82cc23798e7b65c41f6505d4c01209beed03..397572b333b1fc02032dd813d5f884e62ff51d9c 100644 (file)
@@ -93,7 +93,7 @@ inconvenience this causes.
   <br>
   (Matthias Maier, 2015/03/26)
   </li>
-  
+
   <li> Changed: The TrilinosWrappers::SparseMatrix::clear_row() function used
   to call TrilinosWrappers::SparseMatrix::compress() before doing its work,
   but this is neither efficient nor safe. You will now have to do this
@@ -423,7 +423,7 @@ inconvenience this causes.
   <br>
   (Wolfgang Bangerth, 2015/04/19)
   </li>
-  
+
   <li> New: A LinearOperator class that stores the abstract concept of a
   linear operator. The class is fully compatible with the solver and
   preconditioner interfaces. The primary purpose of this class is to
@@ -456,9 +456,9 @@ inconvenience this causes.
   (Wolfgang Bangerth, 2015/04/11)
   </li>
 
-  <li> Changed: All example programs used to have calls to set_boundary() 
-  methods to deal with curved boundaries. These have been replaced with 
-  the corresponding set_manifold() equivalent. 
+  <li> Changed: All example programs used to have calls to set_boundary()
+  methods to deal with curved boundaries. These have been replaced with
+  the corresponding set_manifold() equivalent.
   <br>
   (Luca Heltai, 2015/04/06)
   </li>
@@ -532,6 +532,13 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+  <li> Improved: Functions::Monomial::gradient function now works when both base and exponent
+  are equal to zero for one or more components of the monomial.
+  Also, an assertion is added to avoid exponentiation of negative base numbers with real exponents.
+  <br>
+  (Angel Rodriguez,  2015/06/29)
+  </li>
+
   <li> Improved: The SparseMatrix class can now also use <code>std::complex</code>
   scalars for its elements.
   <br>
@@ -542,7 +549,7 @@ inconvenience this causes.
   the quadrature rule was Gauss points.
   <br>
   (Guido Kanschat, 2015/06/22)
-  </li>  
+  </li>
 
   <li> Improved: DoFRenumbering::Cuthill_McKee() can now also
   use starting indices for parallel triangulations.
@@ -579,8 +586,8 @@ inconvenience this causes.
   (Wolfgang Bangerth, 2015/05/11)
   </li>
 
-  <li> Changed: TrilinosWrappers::Vector, TrilinosWrappers::BlockVector, 
-  PETScWrappers::Vector, and PETScWrappers::BlockVector are deprecated. Either 
+  <li> Changed: TrilinosWrappers::Vector, TrilinosWrappers::BlockVector,
+  PETScWrappers::Vector, and PETScWrappers::BlockVector are deprecated. Either
   use the MPI or the deal.II version of the Vector/BlockVector.
   <br>
   (Bruno Turcksin, 2015/05/04)
@@ -609,7 +616,7 @@ inconvenience this causes.
   <br>
   (Timo Heister, Florian Sonner, 2015/04/30)
   </li>
-  
+
   <li> New: There are now MPI sum functions for Tensors and SymmetricTensors
   in the Utilities::MPI namespace.
   <br>
@@ -628,7 +635,7 @@ inconvenience this causes.
   <br>
   (Lei Qiao, 2015/04/19)
   </li>
-  
+
   <li> New: The VectorTools::integrate_difference() function can now
   also compute the $H_\text{div}$ seminorm, using the
   VectorTools::NormType::Hdiv_seminorm argument.
@@ -648,16 +655,16 @@ inconvenience this causes.
   (Wolfgang Bangerth, 2015/04/13)
   </li>
 
-  <li> New: The GridGenerator::subdivided_hyper_cube() and 
+  <li> New: The GridGenerator::subdivided_hyper_cube() and
   GridGenerator::subdivided_hyper_rectangle() now work also for codimension
   one and two Triangulation;
   <br>
   (Luca Heltai, 2015/04/12)
   </li>
 
-  <li> New: A new VectorTools::get_position_vector() function has been 
-  added to the library that allows one to interpolate the Geometry of 
-  a (possibly curved) triangulation to vector finite element fields 
+  <li> New: A new VectorTools::get_position_vector() function has been
+  added to the library that allows one to interpolate the Geometry of
+  a (possibly curved) triangulation to vector finite element fields
   of at least spacedim components.
   <br>
   (Luca Heltai, 2015/04/11)
index 985d892c24719fff697252c96a6629277e0ccfc5..42ec3ca5b361af8908d36e12752f5a85ed3f6458 100644 (file)
@@ -1031,7 +1031,8 @@ namespace Functions
    * described by a $dim$-tuple of exponents. Consequently, the class's
    * constructor takes a Tensor<1,dim> to describe the set of exponents. Most
    * of the time these exponents will of course be integers, but real
-   * exponents are of course equally valid.
+   * exponents are of course equally valid. Exponents can't be real when
+   * the bases are negative numbers.
    *
    * @author Wolfgang Bangerth, 2006
    */
index 6abfcbe38db5d646e02d2116cb740998b2e1b388..ea7cc38dc26466109c12024529a5ef49c26c9765 100644 (file)
@@ -2112,8 +2112,13 @@ namespace Functions
 
     double prod = 1;
     for (unsigned int s=0; s<dim; ++s)
-      prod *= std::pow(p[s], exponents[s]);
-
+      {
+        if (p[s] < 0)
+          Assert(std::floor(exponents[s]) == exponents[s],
+                 ExcMessage("Exponentiation of a negative base number with "
+                            "a real exponent can't be performed."));
+        prod *= std::pow(p[s], exponents[s]);
+      }
     return prod;
   }
 
@@ -2154,6 +2159,10 @@ namespace Functions
               }
             else
               {
+                if (p[s] < 0)
+                  Assert(std::floor(exponents[s]) == exponents[s],
+                         ExcMessage("Exponentiation of a negative base number with "
+                                    "a real exponent can't be performed."));
                 prod *= (s==d
                          ?
                          exponents[s] * std::pow(p[s], exponents[s]-1)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.