]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Detect the minimal capacity of vectors. Use it.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 26 Sep 2003 15:01:29 +0000 (15:01 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 26 Sep 2003 15:01:29 +0000 (15:01 +0000)
git-svn-id: https://svn.dealii.org/trunk@8036 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/aclocal.m4
deal.II/base/include/base/config.h.in
deal.II/configure
deal.II/configure.in
deal.II/deal.II/source/grid/tria.all_dimensions.cc

index 8c8ee69057caca1d8e72ff1c24d3b59d9f4097f4..50570ef1bb168fe71884c00eb2790fed937cd2a5 100644 (file)
@@ -2824,6 +2824,9 @@ static preload_terminate_dummy dummy;
 
 
 
+
+
+
 dnl -------------------------------------------------------------
 dnl gcc versions up to 2.95.3 had a problem with the std::advance function,
 dnl when the number of steps forward was given by an unsigned number, since
@@ -2866,6 +2869,67 @@ AC_DEFUN(DEAL_II_CHECK_ADVANCE_WARNING, dnl
 
 
 
+dnl -------------------------------------------------------------
+dnl
+dnl Usage: DEAL_II_CHECK_MIN_VECTOR_CAPACITY
+dnl -------------------------------------------------------------
+AC_DEFUN(DEAL_II_CHECK_MIN_VECTOR_CAPACITY, dnl
+[
+  AC_LANG(C++)
+  CXXFLAGS="$CXXFLAGSG -Werror"
+
+  AC_MSG_CHECKING(for minimal std::vector<T> capacity)
+  AC_TRY_RUN(
+       [
+#include <vector>
+int main () {
+    std::vector<int> v(1);
+    v.reserve (1);
+    v.resize (1);
+    return v.capacity();
+}
+       ],
+       [
+         dnl That's impossible: the return value can't be zero!
+         AC_MSG_ERROR(impossible result -- aborting)
+       ],
+       [
+         result="$?"
+         AC_MSG_RESULT($result)
+          AC_DEFINE_UNQUOTED(DEAL_II_MIN_VECTOR_CAPACITY, $result, 
+                   [Set to the minimal number of elements a std::vector<T> can
+                   always hold, i.e. its minimal capacity.])
+       ]
+  )
+
+  dnl Do same thing with std::vector<bool>
+  AC_MSG_CHECKING(for minimal std::vector<bool> capacity)
+  AC_TRY_RUN(
+       [
+#include <vector>
+int main () {
+    std::vector<bool> v(1);
+    v.reserve (1);
+    v.resize (1);
+    return v.capacity();
+}
+       ],
+       [
+         dnl That's impossible: the return value can't be zero!
+         AC_MSG_ERROR(impossible result -- aborting)
+       ],
+       [
+         result="$?"
+         AC_MSG_RESULT($result)
+          AC_DEFINE_UNQUOTED(DEAL_II_MIN_BOOL_VECTOR_CAPACITY, $result, 
+                   [Set to the minimal number of elements a std::vector<bool> can
+                   always hold, i.e. its minimal capacity.])
+       ]
+  )
+])
+
+
+
 dnl -------------------------------------------------------------
 dnl Check whether the numeric_limits classes are available
 dnl
index 32d66a866d154a59628ad403327d2d1a4d813754..86146093d1004be2b108e76a3b2844f4df908ba8 100644 (file)
 /* Minor version number of deal.II */
 #undef DEAL_II_MINOR
 
+/* Set to the minimal number of elements a std::vector<bool> can always hold,
+   i.e. its minimal capacity. */
+#undef DEAL_II_MIN_BOOL_VECTOR_CAPACITY
+
+/* Set to the minimal number of elements a std::vector<T> can always hold,
+   i.e. its minimal capacity. */
+#undef DEAL_II_MIN_VECTOR_CAPACITY
+
 /* Define if we have to work around a bug in gcc with marking all instances of
    a template class as friends to this class if the class is inside a
    namespace. See the aclocal.m4 file in the top-level directory for a
index 961722b610aeb665e8c1c02e3037446bbf7a5dd4..fe70fafefbcd3a657b57bc8bfca65b99588e0832 100755 (executable)
@@ -5727,6 +5727,141 @@ fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
 
+  ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+  CXXFLAGS="$CXXFLAGSG -Werror"
+
+  echo "$as_me:$LINENO: checking for minimal std::vector<T> capacity" >&5
+echo $ECHO_N "checking for minimal std::vector<T> capacity... $ECHO_C" >&6
+  if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <vector>
+int main () {
+    std::vector<int> v(1);
+    v.reserve (1);
+    v.resize (1);
+    return v.capacity();
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+                 { { echo "$as_me:$LINENO: error: impossible result -- aborting" >&5
+echo "$as_me: error: impossible result -- aborting" >&2;}
+   { (exit 1); exit 1; }; }
+
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+
+         result="$?"
+         echo "$as_me:$LINENO: result: $result" >&5
+echo "${ECHO_T}$result" >&6
+
+cat >>confdefs.h <<_ACEOF
+#define DEAL_II_MIN_VECTOR_CAPACITY $result
+_ACEOF
+
+
+
+fi
+rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+    echo "$as_me:$LINENO: checking for minimal std::vector<bool> capacity" >&5
+echo $ECHO_N "checking for minimal std::vector<bool> capacity... $ECHO_C" >&6
+  if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <vector>
+int main () {
+    std::vector<bool> v(1);
+    v.reserve (1);
+    v.resize (1);
+    return v.capacity();
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+                 { { echo "$as_me:$LINENO: error: impossible result -- aborting" >&5
+echo "$as_me: error: impossible result -- aborting" >&2;}
+   { (exit 1); exit 1; }; }
+
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+
+         result="$?"
+         echo "$as_me:$LINENO: result: $result" >&5
+echo "${ECHO_T}$result" >&6
+
+cat >>confdefs.h <<_ACEOF
+#define DEAL_II_MIN_BOOL_VECTOR_CAPACITY $result
+_ACEOF
+
+
+
+fi
+rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
   echo "$as_me:$LINENO: checking whether getrusage is properly declared" >&5
 echo $ECHO_N "checking whether getrusage is properly declared... $ECHO_C" >&6
   ac_ext=cc
index 0dfc4d10d793ab7820de518fd4c2b4585e868564..51402e25de39a5406b5fd72722b8668f336ef166 100644 (file)
@@ -188,6 +188,7 @@ DEAL_II_HAVE_STD_OSTREAM_HEADER
 DEAL_II_HAVE_STD_IOSFWD_HEADER
 DEAL_II_HAVE_BUILTIN_EXPECT
 DEAL_II_HAVE_VERBOSE_TERMINATE
+DEAL_II_CHECK_MIN_VECTOR_CAPACITY
 DEAL_II_CHECK_GETRUSAGE
 DEAL_II_CHECK_ISNAN
 DEAL_II_CHECK_RAND_R
index c3012b6ddab10646cc481b4400cfd17e016bd548..b3f53e477cad9d3ae30715ac033c34db71fd6c34 100644 (file)
@@ -179,19 +179,19 @@ TriangulationLevel<0>::monitor_memory (const unsigned int true_dimension) const
                                   // as many elements as an integer
                                   // has bits
   Assert (refine_flags.size() <= refine_flags.capacity() + sizeof(int)*8 ||
-         refine_flags.size()<256,
+         refine_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
          ExcMemoryWasted ("refine_flags",
                           refine_flags.size(), refine_flags.capacity()));
   Assert (coarsen_flags.size() <= coarsen_flags.capacity() + sizeof(int)*8 ||
-         coarsen_flags.size()<256,
+         coarsen_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
          ExcMemoryWasted ("coarsen_flags",
                           coarsen_flags.size(), coarsen_flags.capacity()));
   Assert (neighbors.size() ==  neighbors.capacity() ||
-         neighbors.size()<256,
+         neighbors.size()<DEAL_II_MIN_VECTOR_CAPACITY,
          ExcMemoryWasted ("neighbors",
                           neighbors.size(), neighbors.capacity()));
   Assert (subdomain_ids.size() ==  subdomain_ids.capacity() ||
-         subdomain_ids.size()<256,
+         subdomain_ids.size()<DEAL_II_MIN_VECTOR_CAPACITY,
          ExcMemoryWasted ("subdomain_ids",
                           subdomain_ids.size(), subdomain_ids.capacity()));
   Assert (2*true_dimension*refine_flags.size() == neighbors.size(),
@@ -262,19 +262,19 @@ TriangulationLevel<1>::monitor_memory (const unsigned int true_dimension) const
                                   // as many elements as an integer
                                   // has bits
   Assert (lines.lines.size() == lines.lines.capacity() ||
-         lines.lines.size()<256,
+         lines.lines.size()<DEAL_II_MIN_VECTOR_CAPACITY,
          ExcMemoryWasted ("lines",
                           lines.lines.size(), lines.lines.capacity()));
   Assert (lines.children.size() == lines.children.capacity() ||
-         lines.children.size()<256,
+         lines.children.size()<DEAL_II_MIN_VECTOR_CAPACITY,
          ExcMemoryWasted ("children",
                           lines.children.size(), lines.children.capacity()));
   Assert (lines.used.size() <= lines.used.capacity() + sizeof(int)*8 ||
-         lines.used.size()<256,
+         lines.used.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
          ExcMemoryWasted ("used",
                           lines.used.size(), lines.used.capacity()));
   Assert (lines.user_flags.size() <= lines.user_flags.capacity() + sizeof(int)*8 ||
-         lines.user_flags.size()<256,
+         lines.user_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
          ExcMemoryWasted ("user_flags",
                           lines.user_flags.size(), lines.user_flags.capacity()));
   Assert (lines.lines.size() == lines.used.size(),
@@ -356,19 +356,19 @@ TriangulationLevel<2>::monitor_memory (const unsigned int true_dimension) const
                                   // as many elements as an integer
                                   // has bits
   Assert (quads.quads.size() == quads.quads.capacity() ||
-         quads.quads.size()<256,
+         quads.quads.size()<DEAL_II_MIN_VECTOR_CAPACITY,
          ExcMemoryWasted ("quads",
                           quads.quads.size(), quads.quads.capacity()));
   Assert (quads.children.size() == quads.children.capacity() ||
-         quads.children.size()<256,
+         quads.children.size()<DEAL_II_MIN_VECTOR_CAPACITY,
          ExcMemoryWasted ("children",
                           quads.children.size(), quads.children.capacity()));
   Assert (quads.used.size() <= quads.used.capacity() + sizeof(int)*8 ||
-         quads.used.size()<256,
+         quads.used.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
          ExcMemoryWasted ("used",
                           quads.used.size(), quads.used.capacity()));
   Assert (quads.user_flags.size() <= quads.user_flags.capacity() + sizeof(int)*8 ||
-         quads.user_flags.size()<256,
+         quads.user_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
          ExcMemoryWasted ("user_flags",
                           quads.user_flags.size(), quads.user_flags.capacity()));
   Assert (quads.quads.size() == quads.used.size(),
@@ -434,6 +434,12 @@ TriangulationLevel<3>::reserve_space (const unsigned int new_hexes)
       hexes.user_pointers.reserve (new_size);
       hexes.user_pointers.insert (hexes.user_pointers.end(),
                                  new_size-hexes.user_pointers.size(), 0);
+
+      hexes.face_orientations.reserve (new_size * GeometryInfo<3>::faces_per_cell);
+      hexes.face_orientations.insert (hexes.face_orientations.end(),
+                                      new_size * GeometryInfo<3>::faces_per_cell
+                                      - hexes.face_orientations.size(),
+                                      true);
     };
 }
 
@@ -450,19 +456,19 @@ TriangulationLevel<3>::monitor_memory (const unsigned int true_dimension) const
                                   // as many elements as an integer
                                   // has bits
   Assert (hexes.hexes.size() == hexes.hexes.capacity() ||
-         hexes.hexes.size()<256,
+         hexes.hexes.size()<DEAL_II_MIN_VECTOR_CAPACITY,
          ExcMemoryWasted ("hexes",
                           hexes.hexes.size(), hexes.hexes.capacity()));
   Assert (hexes.children.size() == hexes.children.capacity() ||
-         hexes.children.size()<256,
+         hexes.children.size()<DEAL_II_MIN_VECTOR_CAPACITY,
          ExcMemoryWasted ("children",
                           hexes.children.size(), hexes.children.capacity()));
   Assert (hexes.used.size() <= hexes.used.capacity() + sizeof(int)*8 ||
-         hexes.used.size()<256,
+         hexes.used.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
          ExcMemoryWasted ("used",
                           hexes.used.size(), hexes.used.capacity()));
   Assert (hexes.user_flags.size() <= hexes.user_flags.capacity() + sizeof(int)*8 ||
-         hexes.user_flags.size()<256,
+         hexes.user_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
          ExcMemoryWasted ("user_flags",
                           hexes.user_flags.size(), hexes.user_flags.capacity()));
   Assert (hexes.hexes.size() == hexes.used.size(),
@@ -475,6 +481,10 @@ TriangulationLevel<3>::monitor_memory (const unsigned int true_dimension) const
          ExcMemoryInexact (hexes.hexes.size(), hexes.material_id.size()));
   Assert (hexes.hexes.size() == hexes.user_pointers.size(),
          ExcMemoryInexact (hexes.hexes.size(), hexes.user_pointers.size()));
+  Assert (hexes.hexes.size() * GeometryInfo<3>::faces_per_cell
+          == hexes.face_orientations.size(),
+         ExcMemoryInexact (hexes.hexes.size() * GeometryInfo<3>::faces_per_cell,
+                            hexes.face_orientations.size()));
 
   TriangulationLevel<2>::monitor_memory (true_dimension);
 }
@@ -490,7 +500,8 @@ TriangulationLevel<3>::memory_consumption () const
          MemoryConsumption::memory_consumption (hexes.used) +
          MemoryConsumption::memory_consumption (hexes.user_flags) +
          MemoryConsumption::memory_consumption (hexes.material_id) +
-         MemoryConsumption::memory_consumption (hexes.user_pointers));
+         MemoryConsumption::memory_consumption (hexes.user_pointers) +
+         MemoryConsumption::memory_consumption (hexes.face_orientations));
 }
 
 

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.