From 6ab532c50a9022b640d47b880121ec90830f8969 Mon Sep 17 00:00:00 2001 From: hartmann Date: Wed, 14 Jun 2006 09:09:15 +0000 Subject: [PATCH] Move TriaLevel implementations to new tria_levels.cc file (similar to the *dof_levels.cc files). git-svn-id: https://svn.dealii.org/trunk@13243 0785d39b-7218-0410-832d-ea1e28bc413d --- .../source/grid/tria.all_dimensions.cc | 102 ------------- deal.II/deal.II/source/grid/tria_levels.cc | 136 ++++++++++++++++++ 2 files changed, 136 insertions(+), 102 deletions(-) create mode 100644 deal.II/deal.II/source/grid/tria_levels.cc diff --git a/deal.II/deal.II/source/grid/tria.all_dimensions.cc b/deal.II/deal.II/source/grid/tria.all_dimensions.cc index f9186abc37..5abb299596 100644 --- a/deal.II/deal.II/source/grid/tria.all_dimensions.cc +++ b/deal.II/deal.II/source/grid/tria.all_dimensions.cc @@ -51,108 +51,6 @@ namespace internal { namespace Triangulation { - - void - TriaLevel<0>::reserve_space (const unsigned int total_cells, - const unsigned int dimension) - { - // we need space for total_cells - // cells. Maybe we have more already - // with those cells which are unused, - // so only allocate new space if needed. - // - // note that all arrays should have equal - // sizes (checked by @p{monitor_memory} - if (total_cells > refine_flags.size()) - { - refine_flags.reserve (total_cells); - refine_flags.insert (refine_flags.end(), - total_cells - refine_flags.size(), - false); - - coarsen_flags.reserve (total_cells); - coarsen_flags.insert (coarsen_flags.end(), - total_cells - coarsen_flags.size(), - false); - - subdomain_ids.reserve (total_cells); - subdomain_ids.insert (subdomain_ids.end(), - total_cells - subdomain_ids.size(), - 0); - - neighbors.reserve (total_cells*(2*dimension)); - neighbors.insert (neighbors.end(), - total_cells*(2*dimension) - neighbors.size(), - std::make_pair(-1,-1)); - }; - } - - - - void - TriaLevel<0>::monitor_memory (const unsigned int true_dimension) const - { - // check that we have not allocated - // too much memory. note that bool - // vectors allocate their memory in - // chunks of whole integers, so - // they may over-allocate by up to - // as many elements as an integer - // has bits - Assert (refine_flags.size() <= refine_flags.capacity() + sizeof(int)*8 || - refine_flags.size()::memory_consumption () const - { - return (MemoryConsumption::memory_consumption (refine_flags) + - MemoryConsumption::memory_consumption (coarsen_flags) + - MemoryConsumption::memory_consumption (neighbors)); - } - - unsigned int - TriaLevel<1>::memory_consumption () const - { - return (TriaLevel<0>::memory_consumption() + - MemoryConsumption::memory_consumption (lines)); - } - - unsigned int - TriaLevel<2>::memory_consumption () const - { - return (TriaLevel<0>::memory_consumption() + - MemoryConsumption::memory_consumption (quads)); - } - - unsigned int - TriaLevel<3>::memory_consumption () const - { - return (TriaLevel<0>::memory_consumption() + - MemoryConsumption::memory_consumption (hexes)); - } - - NumberCache<1>::NumberCache () : n_lines (0), diff --git a/deal.II/deal.II/source/grid/tria_levels.cc b/deal.II/deal.II/source/grid/tria_levels.cc new file mode 100644 index 0000000000..305da34e61 --- /dev/null +++ b/deal.II/deal.II/source/grid/tria_levels.cc @@ -0,0 +1,136 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + + +#include +#include + +namespace internal +{ + namespace Triangulation + { + + void + TriaLevel<0>::reserve_space (const unsigned int total_cells, + const unsigned int dimension) + { + // we need space for total_cells + // cells. Maybe we have more already + // with those cells which are unused, + // so only allocate new space if needed. + // + // note that all arrays should have equal + // sizes (checked by @p{monitor_memory} + if (total_cells > refine_flags.size()) + { + refine_flags.reserve (total_cells); + refine_flags.insert (refine_flags.end(), + total_cells - refine_flags.size(), + false); + + coarsen_flags.reserve (total_cells); + coarsen_flags.insert (coarsen_flags.end(), + total_cells - coarsen_flags.size(), + false); + + subdomain_ids.reserve (total_cells); + subdomain_ids.insert (subdomain_ids.end(), + total_cells - subdomain_ids.size(), + 0); + + neighbors.reserve (total_cells*(2*dimension)); + neighbors.insert (neighbors.end(), + total_cells*(2*dimension) - neighbors.size(), + std::make_pair(-1,-1)); + }; + } + + + + void + TriaLevel<0>::monitor_memory (const unsigned int true_dimension) const + { + // check that we have not allocated + // too much memory. note that bool + // vectors allocate their memory in + // chunks of whole integers, so + // they may over-allocate by up to + // as many elements as an integer + // has bits + Assert (refine_flags.size() <= refine_flags.capacity() + sizeof(int)*8 || + refine_flags.size()::memory_consumption () const + { + return (MemoryConsumption::memory_consumption (refine_flags) + + MemoryConsumption::memory_consumption (coarsen_flags) + + MemoryConsumption::memory_consumption (neighbors)); + } + +#if deal_II_dimension == 1 + + unsigned int + TriaLevel<1>::memory_consumption () const + { + return (TriaLevel<0>::memory_consumption() + + MemoryConsumption::memory_consumption (lines)); + } + +#endif + +#if deal_II_dimension == 2 + + unsigned int + TriaLevel<2>::memory_consumption () const + { + return (TriaLevel<0>::memory_consumption() + + MemoryConsumption::memory_consumption (quads)); + } + +#endif + +#if deal_II_dimension == 3 + + unsigned int + TriaLevel<3>::memory_consumption () const + { + return (TriaLevel<0>::memory_consumption() + + MemoryConsumption::memory_consumption (hexes)); + } + +#endif + + } +} -- 2.39.5